:root {
  --bg: #f7f8f8;
  --surface: #ffffff;
  --surface-2: #edf7f5;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #dbe4e8;
  --line-soft: #edf1f4;
  --teal: #0f766e;
  --blue: #2563eb;
  --red: #dc2626;
  --amber: #b7791f;
  --green: #15803d;
  --radius: 8px;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

body {
  background:
    linear-gradient(180deg, rgba(255,255,255,.84), rgba(247,248,248,.96)),
    repeating-linear-gradient(0deg, rgba(15,23,42,.035) 0 1px, transparent 1px 38px),
    repeating-linear-gradient(90deg, rgba(15,23,42,.035) 0 1px, transparent 1px 38px);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
textarea { width: 100%; resize: vertical; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(247,248,248,.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(15,118,110,.35);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--teal);
  font-weight: 900;
}

.brand strong, .brand small { display: block; line-height: 1.15; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 12px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.76);
}

.nav-links a {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 14px;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--surface-2);
  color: var(--teal);
}

.nav-links a.is-disabled {
  color: #a0aab6;
  cursor: not-allowed;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.hero,
.page-head,
.lab-head,
.section,
.panel,
.site-footer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 20px;
  padding: 38px;
  overflow: hidden;
}

.hero-copy h1,
.page-head h1,
.lab-head h1 {
  margin: 8px 0 14px;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead,
.page-head p,
.lab-head p,
.large-copy {
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.85;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-family: "Cascadia Mono", "SF Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 700;
}

.btn.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.metric strong {
  display: block;
  color: var(--teal);
  font-size: 30px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.section,
.page-head,
.lab-head {
  margin-top: 18px;
  padding: 24px;
}

.band { background: rgba(255,255,255,.72); }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2,
.panel h2 {
  margin: 5px 0 0;
  font-size: 24px;
}

.chapter-grid,
.lab-grid,
.project-grid,
.two-col,
.lab-workbench {
  display: grid;
  gap: 14px;
}

.chapter-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.lab-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lab-workbench {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  margin-top: 18px;
}

.chapter-card,
.lab-card,
.project-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.chapter-card span,
.lab-status {
  color: var(--teal);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.chapter-card h3,
.lab-card h3,
.project-card h3 {
  margin: 8px 0;
  font-size: 17px;
  line-height: 1.35;
}

.chapter-card p,
.lab-card p,
.chapter-card small,
.lab-card small,
.project-card p,
.project-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.lab-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 190px;
}

.chapter-card,
.project-card {
  display: block;
}

.chapter-card:hover,
.project-card:hover {
  border-color: rgba(15,118,110,.35);
  background: #effaf7;
}

.project-card {
  min-height: 220px;
}

.project-card span,
.learning-card em,
.project-card em {
  color: var(--teal);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.learning-card em,
.project-card em {
  display: block;
  margin-top: 14px;
}

.learning-card.is-complete,
.project-card.is-complete {
  border-color: rgba(21,128,61,.4);
  background: #f0fdf4;
}

.lab-card:hover,
.lab-card.is-online {
  border-color: rgba(15,118,110,.35);
  background: #effaf7;
}

.lab-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.6;
}

.panel {
  padding: 20px;
}

.span-2 { grid-column: span 2; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label,
.check-line {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid input,
.form-grid select,
textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.mono-box {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #0f172a;
  color: #dbeafe;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-x: auto;
}

.mini-table {
  display: grid;
  gap: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 80px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--ink-2);
  font-size: 13px;
}

.mini-row strong {
  color: var(--teal);
}

.mini-row.is-match {
  border-color: rgba(15,118,110,.4);
  background: #effaf7;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-step {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--muted);
  line-height: 1.65;
}

.timeline-step.is-done {
  border-color: rgba(15,118,110,.35);
  background: #effaf7;
  color: var(--ink-2);
}

.timeline-step.is-blocked {
  border-color: rgba(220,38,38,.35);
  background: #fff1f2;
  color: #991b1b;
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.action-grid .btn {
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.packet-stack {
  display: grid;
  gap: 8px;
}

.packet-layer {
  padding: 10px 12px;
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  background: #effaf7;
  color: var(--ink-2);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.packet-layer strong {
  color: var(--teal);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-list span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--ink-2);
  font-size: 12px;
}

.resource-list {
  display: grid;
  gap: 9px;
}

.resource-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.resource-list a:hover {
  border-color: rgba(15,118,110,.35);
  background: #effaf7;
}

.resource-list span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.progress-track {
  height: 12px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width .2s ease;
}

.graph-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.graph-metrics span {
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.graph-metrics strong {
  color: var(--teal);
}

.graph-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
}

.graph-toolbar label {
  display: grid;
  flex: 1 1 260px;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.graph-toolbar input,
.graph-toolbar select {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  margin-top: 18px;
}

.graph-stage {
  min-width: 0;
}

.graph-stage canvas {
  aspect-ratio: 16 / 9;
  min-height: 560px;
  max-height: 760px;
}

.graph-inspector {
  position: sticky;
  top: 88px;
  align-self: start;
}

.graph-inspector h3 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.graph-legend i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.graph-legend .root { background: #0f766e; }
.graph-legend .chapter { background: #2563eb; }
.graph-legend .concept { background: #f59e0b; }

.tag-list button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12px;
}

.tag-list button:hover {
  border-color: rgba(15,118,110,.4);
  background: #effaf7;
}

.check-line {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin: 14px 0;
}

.delay-bars,
.trace-list,
.result-box {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 86px;
  gap: 10px;
  align-items: center;
  color: var(--ink-2);
  font-size: 13px;
}

.bar-row div {
  height: 10px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar-row div span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.result-box,
.trace-step {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--ink-2);
  line-height: 1.7;
}

.trace-step.is-active {
  border-color: rgba(15,118,110,.4);
  background: #effaf7;
  color: var(--ink);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.clean-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-2);
  line-height: 1.8;
}

.table-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 90px;
  gap: 14px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.table-row:last-child { border-bottom: 0; }
.table-row span { color: var(--muted); }
.table-row em { color: var(--teal); font-style: normal; font-weight: 800; text-align: right; }

.grade-bars {
  display: grid;
  gap: 12px;
}

.grade-bars div {
  position: relative;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #f8fafc;
}

.grade-bars span {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(15,118,110,.15);
}

.grade-bars strong {
  position: relative;
}

.ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.site-footer {
  width: min(1440px, calc(100% - 40px));
  margin: 18px auto 22px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .chapter-grid,
  .lab-grid,
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hero,
  .lab-workbench,
  .graph-layout {
    grid-template-columns: 1fr;
  }
  .graph-inspector { position: static; }
  .span-2 { grid-column: span 1; }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }
  .brand { min-width: 0; }
  .nav-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  main { padding: 10px; }
  .hero,
  .section,
  .page-head,
  .lab-head {
    padding: 18px;
  }
  .chapter-grid,
  .lab-grid,
  .project-grid,
  .two-col,
  .form-grid,
  .table-row {
    grid-template-columns: 1fr;
  }
  .hero-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canvas-toolbar,
  .section-head,
  .graph-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .graph-stage canvas { min-height: 440px; }
  .resource-list a {
    align-items: start;
    flex-direction: column;
  }
  .resource-list span { text-align: left; }
}
