:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --soft: #f8fbff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe5f0;
  --teal: #0f766e;
  --cyan: #0891b2;
  --indigo: #4f46e5;
  --green: #059669;
  --rose: #e11d48;
  --amber: #d97706;
  --shadow: 0 22px 55px rgba(15, 23, 42, .10);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15,118,110,.12), transparent 30%),
    linear-gradient(240deg, rgba(79,70,229,.12), transparent 34%),
    var(--bg);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.home {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(520px, 1.08fr);
  align-items: center;
  gap: clamp(32px, 5vw, 76px);
  padding: 54px clamp(28px, 6vw, 110px);
}
.home-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.grid-plane {
  position: absolute;
  inset: 44% -10% -22% -10%;
  background:
    linear-gradient(rgba(15,118,110,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,70,229,.18) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(760px) rotateX(62deg);
  transform-origin: top;
  mask-image: linear-gradient(transparent, #000 22%, transparent 82%);
}
.home-content { position: relative; z-index: 1; max-width: 720px; }
.home-kicker {
  width: fit-content;
  padding: 9px 13px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #115e59;
  font-weight: 950;
}
.home h1 {
  margin: 24px 0 18px;
  font-size: clamp(52px, 5.8vw, 86px);
  line-height: 1.02;
  letter-spacing: 0;
}
.home h1 span {
  color: transparent;
  background: linear-gradient(110deg, var(--teal), var(--cyan), var(--indigo));
  -webkit-background-clip: text;
  background-clip: text;
}
.home p {
  max-width: 660px;
  margin: 0;
  color: #475569;
  font-size: 20px;
  line-height: 1.72;
  font-weight: 650;
}
.home-actions { display: flex; gap: 14px; margin-top: 30px; flex-wrap: wrap; }
.launch-btn {
  border: 0;
  border-radius: 16px;
  min-height: 58px;
  padding: 0 26px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  box-shadow: 0 20px 44px rgba(79,70,229,.24);
  font-weight: 950;
  font-size: 17px;
}
.home-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 148px));
  gap: 12px;
  margin-top: 30px;
}
.home-metrics div {
  padding: 16px 18px;
  border: 1px solid rgba(219,229,240,.9);
  border-radius: 12px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 12px 28px rgba(15,23,42,.06);
}
.home-metrics b { display: block; font-size: 28px; color: var(--teal); }
.home-metrics span { color: var(--muted); font-weight: 850; font-size: 13px; }
.matrix-hero { position: relative; z-index: 1; display: grid; place-items: center; min-height: 520px; }
.hero-panel {
  width: min(640px, 100%);
  padding: 28px;
  border: 1px solid rgba(219,229,240,.96);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 34px 90px rgba(15,23,42,.16);
}
.panel-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-top div { display: grid; gap: 6px; }
.panel-top span { color: var(--muted); font-size: 13px; font-weight: 900; }
.panel-top strong { color: var(--ink); font-size: 22px; font-family: Consolas, "Microsoft YaHei", monospace; }
.panel-top b {
  padding: 8px 11px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #115e59;
  white-space: nowrap;
}
.hero-matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0 18px;
}
.hero-matrix span {
  display: grid;
  place-items: center;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: #94a3b8;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 38px;
  font-weight: 950;
}
.hero-matrix span.on {
  border-color: rgba(15,118,110,.26);
  background: #dcfce7;
  color: #166534;
}
.hero-properties {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.hero-properties span {
  padding: 10px 8px;
  border-radius: 10px;
  text-align: center;
  font-weight: 950;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.hero-properties .ok { color: #166534; background: #dcfce7; border-color: rgba(22,101,52,.18); }
.hero-properties .bad { color: #9f1239; background: #fff1f2; border-color: rgba(159,18,57,.16); }
.closure-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.closure-flow div {
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
}
.closure-flow b { display: block; color: var(--teal); font-size: 22px; }
.closure-flow span { color: var(--muted); font-size: 13px; font-weight: 850; }

.app {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 20px;
  max-width: 1720px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}
.rail, .composer, .visual-card, .verdict {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(219,229,240,.9);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.rail {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  padding: 20px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  overflow: hidden;
}
.rail::before {
  content: "";
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--cyan), var(--indigo));
}
.brand h1 { margin: 14px 0 10px; font-size: 32px; line-height: 1.08; letter-spacing: 0; }
.brand p, .rail-note span, #summary { color: var(--muted); line-height: 1.65; }
.badge {
  display: inline-flex;
  width: fit-content;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}
.rail-block { display: grid; align-content: start; gap: 11px; overflow: auto; }
.rail-title { color: var(--muted); font-size: 13px; font-weight: 900; }
.example-list { display: grid; gap: 9px; }
.example {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  background: linear-gradient(180deg, #fff, #f6f9fd);
  color: var(--ink);
  text-align: left;
}
.example:hover { border-color: rgba(15,118,110,.55); box-shadow: 0 10px 24px rgba(15,118,110,.12); }
.example span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.rail-note {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fbff, #ecfdf5);
}
.stage { display: grid; gap: 18px; min-width: 0; }
.composer, .visual-card, .verdict { padding: 20px; }
.composer-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h2, h3, h4 { margin: 4px 0 0; letter-spacing: 0; }
h2 { font-size: 25px; }
h3 { font-size: 20px; }
.engine-state, .soft-label {
  padding: 8px 11px;
  border-radius: 999px;
  color: #115e59;
  background: #ccfbf1;
  font-size: 13px;
  font-weight: 800;
}
.input-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  margin-top: 18px;
  align-items: end;
}
.matrix-input, .input-side label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
textarea, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}
textarea {
  min-height: 154px;
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 800;
}
textarea:focus, input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15,118,110,.13); }
.input-side { display: grid; gap: 12px; }
.primary, .ghost {
  border: 0;
  border-radius: 10px;
  min-height: 46px;
  padding: 0 16px;
  font-weight: 950;
  white-space: nowrap;
}
.primary { background: linear-gradient(135deg, var(--teal), var(--cyan)); color: white; box-shadow: 0 12px 24px rgba(15,118,110,.22); }
.ghost { background: #eef4ff; color: #1e293b; border: 1px solid #d7e3f5; }

.dashboard { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 18px; }
.verdict { position: relative; overflow: hidden; }
.verdict::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: linear-gradient(180deg, var(--teal), var(--indigo));
}
.verdict h2 { font-size: 31px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.metric-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.metric-grid b { display: block; font-size: 18px; color: var(--teal); }
.metric-grid span { color: var(--muted); font-size: 12px; font-weight: 900; }
.property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.property-card {
  min-height: 138px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}
.property-card.ok { border-color: rgba(5,150,105,.38); background: #f0fdf4; }
.property-card.bad { border-color: rgba(225,29,72,.38); background: #fff1f2; }
.property-name { color: var(--muted); font-size: 13px; font-weight: 900; }
.property-state { margin-top: 6px; font-size: 24px; font-weight: 950; }
.property-card.ok .property-state { color: var(--green); }
.property-card.bad .property-state { color: var(--rose); }
.property-card p { margin: 8px 0 0; color: #475569; line-height: 1.55; }
.split { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 18px; }
.matrix-wrap, .closure-grid, .warshall-steps { margin-top: 14px; }
.matrix-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  background: white;
}
.matrix-table th, .matrix-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: center;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-weight: 900;
}
.matrix-table th { background: #ecfeff; color: #115e59; }
.matrix-table td.one { background: #dcfce7; color: #166534; }
.matrix-table td.zero { background: #f8fafc; color: #94a3b8; }
.pair-set {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #f8fbff;
  color: #334155;
  line-height: 1.7;
  font-weight: 800;
}
.closure-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.closure-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--soft); overflow: auto; }
.closure-card h4 { margin: 0 0 10px; color: var(--teal); }
.warshall-steps { display: grid; gap: 12px; }
.warshall-step { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--soft); }
.step-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: #334155; }
.step-head span { color: var(--muted); font-weight: 800; }
.markdown-body {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  line-height: 1.85;
  color: #243244;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 15px 0 8px; }
.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 21px; }
.markdown-body h3 { font-size: 18px; }
.markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 16px; }
.markdown-body p { margin: 9px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 24px; padding: 0; }
.markdown-body li { margin: 5px 0; }
.markdown-body blockquote {
  margin: 12px 0;
  padding: 11px 14px;
  border-left: 4px solid var(--teal);
  background: #ecfdf5;
  color: #14532d;
  border-radius: 0 10px 10px 0;
}
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.markdown-body code { padding: 2px 5px; border-radius: 5px; background: #eef4ff; font-family: Consolas, monospace; }
.markdown-body pre {
  padding: 13px;
  border-radius: 12px;
  overflow: auto;
  background: #f8fbff;
  color: var(--ink);
  border: 1px solid var(--line);
  white-space: pre-wrap;
}
.md-table {
  width: 100%;
  min-width: 560px;
  margin: 12px 0;
  border-collapse: collapse;
  background: white;
}
.md-table th, .md-table td {
  border: 1px solid var(--line);
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
}
.md-table th {
  background: #ecfeff;
  color: #115e59;
  font-weight: 950;
}

@media (max-width: 1120px) {
  .home, .app, .dashboard, .split, .input-grid, .closure-grid { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .matrix-hero { min-height: 300px; }
}
