:root {
  --background: #f7f4ed;
  --surface: #fffdf8;
  --ink: #182622;
  --muted: #53635d;
  --accent: #087e6b;
  --accent-dark: #07594c;
  --highlight: #e7f5ef;
  --line: #d7dfd8;
  --warm: #f1c67a;
  --danger: #b34b3d;
  --shadow: 0 18px 45px rgba(24, 38, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, "Avenir Next", "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--accent-dark);
}

code,
pre {
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

.shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0;
  gap: 16px;
}

.brand {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}

.nav a {
  font-size: 0.94rem;
  text-decoration: none;
}

.lang {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 42px;
  align-items: center;
  padding: 62px 0 64px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 10px 0 16px;
  font-size: clamp(2.6rem, 5.6vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.lede {
  max-width: 610px;
  color: var(--muted);
  font-size: 1.15rem;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  display: inline-block;
  padding: 11px 17px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 650;
  text-decoration: none;
}

.button.primary {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.site-map {
  padding: 20px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.graph {
  position: relative;
  height: 270px;
}

.graph svg {
  display: block;
  width: 100%;
  height: 270px;
}

.graph line {
  stroke: #b7c9c1;
  stroke-width: 2;
}

.graph line.filtered {
  stroke-dasharray: 6 6;
  stroke: var(--warm);
}

.graph line.cycle {
  stroke: #85ad9e;
  stroke-dasharray: 4 4;
}

.graph line.duplicate {
  stroke: #bd9b5d;
  stroke-dasharray: 2 5;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  border: 1px solid #c8dcd3;
  border-radius: 999px;
  background: var(--highlight);
  font-size: 0.8rem;
  font-weight: 650;
}

.node.home { left: 50%; top: 34px; }
.node.tutorial { left: 26%; top: 120px; }
.node.reference { left: 74%; top: 120px; }
.node.basic { left: 26%; top: 220px; }
.node.concurrent { left: 74%; top: 220px; }
.node.external {
  left: 84%;
  top: 34px;
  border-color: #efcf9a;
  background: #fff4dc;
}

.caption {
  margin: 16px 8px 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.section {
  padding: 58px 0;
}

.section h2 {
  margin: 8px 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  letter-spacing: -0.045em;
  line-height: 1.15;
}

.section-intro {
  max-width: 720px;
  margin-bottom: 30px;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  display: block;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 150ms ease, transform 150ms ease;
}

.card:hover,
.card:focus-visible {
  border-color: #9bc7b7;
  transform: translateY(-2px);
}

.card h3 {
  margin: 5px 0 10px;
}

.card p {
  color: var(--muted);
}

.card-action {
  color: var(--accent-dark);
  font-size: 0.91rem;
  font-weight: 700;
}

.lesson-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.lesson-shortcuts a {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
}

.tag {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.steps {
  display: grid;
  gap: 13px;
}

details {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  scroll-margin-top: 24px;
}

summary {
  cursor: pointer;
  padding: 17px 20px;
  font-weight: 700;
}

.lesson-number {
  display: inline-block;
  min-width: 38px;
  margin-right: 12px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
}

.lesson-body {
  padding: 0 20px 20px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  padding-top: 4px;
}

.lesson-grid p {
  color: var(--muted);
}

.lesson-grid ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.challenge {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--highlight);
}

pre {
  overflow-x: auto;
  margin: 14px 0;
  padding: 14px;
  border-radius: 10px;
  color: #dcece7;
  background: #152620;
  font-size: 0.86rem;
}

.code-section {
  background: rgba(231, 245, 239, 0.43);
}

.code-studio {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 12px 0;
}

.code-tab {
  cursor: pointer;
  padding: 10px 14px;
  border: 0;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.code-tab.active {
  color: var(--accent-dark);
  background: var(--highlight);
}

.code-panel {
  padding: 18px 20px 0;
}

.code-panel pre {
  margin-bottom: 18px;
}

.code-note {
  color: var(--muted);
}

.source-link {
  display: block;
  padding: 0 20px 20px;
  font-weight: 700;
  text-decoration: none;
}

.source-browser {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.source-browser-header {
  padding: 20px 20px 0;
}

.source-browser h3 {
  margin: 6px 0 4px;
  font-size: 1.35rem;
}

.source-browser p {
  margin: 0;
  color: var(--muted);
}

.source-browser-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.34fr) minmax(0, 1fr);
  gap: 0;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.source-tree {
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: #f5f7f2;
}

.tree-root {
  margin: 0 0 9px 7px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

.tree-file {
  display: block;
  width: 100%;
  cursor: pointer;
  margin: 2px 0;
  padding: 7px 8px 7px 24px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  text-align: left;
}

.tree-file::before {
  content: "py";
  display: inline-block;
  width: 18px;
  margin-left: -20px;
  color: #5b8d7c;
  font-size: 0.62rem;
  font-weight: 800;
}

.tree-file:hover,
.tree-file:focus-visible,
.tree-file.active {
  background: var(--highlight);
  color: var(--accent-dark);
}

.tree-file.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tree-file.nested {
  padding-left: 38px;
}

.tree-file.nested::before {
  margin-left: -20px;
}

.tree-folder {
  overflow: visible;
  margin: 6px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tree-folder summary {
  padding: 7px 8px 7px 24px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
}

.source-viewer {
  min-width: 0;
}

.source-browser .code-note {
  padding: 16px 20px 0;
}

.source-pre {
  max-height: 620px;
  margin: 16px 20px 18px;
  padding: 0;
  border: 1px solid rgba(127, 160, 150, 0.2);
  background: #101c18;
}

.source-pre code {
  display: block;
  min-width: max-content;
  padding: 12px 0;
}

.source-line {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  min-height: 1.45rem;
  white-space: pre;
}

.source-line.highlighted {
  background: rgba(241, 198, 122, 0.14);
}

.source-line-number {
  padding: 0 14px;
  color: #7fa096;
  text-align: right;
  user-select: none;
}

.source-line-code {
  padding-right: 18px;
}

.token-keyword {
  color: #78d0ff;
  font-weight: 700;
}

.token-builtin,
.token-self {
  color: #f4c78a;
}

.token-constant,
.token-number {
  color: #b6e389;
}

.token-string {
  color: #9de3be;
}

.token-comment {
  color: #7fa096;
  font-style: italic;
}

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

.lab-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.lab-card.wide {
  grid-column: 1 / -1;
}

.lab-card h3 {
  margin: 7px 0 5px;
  font-size: 1.3rem;
}

.lab-card > p {
  margin-top: 0;
  color: var(--muted);
}

.timeline-lab {
  display: grid;
  gap: 20px;
  padding-top: 12px;
}

.control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.timeline {
  display: grid;
  gap: 8px;
}

.lane {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 35px;
}

.lane-label {
  width: 70px;
  color: var(--muted);
  font-size: 0.85rem;
}

.track {
  position: relative;
  flex: 1;
  height: 25px;
  border-radius: 6px;
  background: #eef1ec;
}

.request {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 5px;
  background: var(--accent);
}

.metric {
  font-weight: 700;
}

.state-board {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.state-label {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.chips {
  display: flex;
  min-height: 31px;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--highlight);
  color: var(--accent-dark);
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
}

.state-event {
  min-height: 48px;
  margin: 4px 0 0;
  padding: 10px;
  border-radius: 9px;
  background: #f2f3ee;
  color: var(--muted);
  font-size: 0.92rem;
}

.lab-actions {
  display: flex;
  gap: 8px;
}

.small-button {
  display: inline-block;
  cursor: pointer;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-weight: 650;
  text-decoration: none;
}

.small-button.primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.resilience-lab {
  display: grid;
  gap: 15px;
  margin-top: 18px;
}

.resilience-lab label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.resilience-lab input {
  display: block;
  width: 100%;
  margin-top: 7px;
}

.resilience-lab .result {
  margin: 5px 0 0;
  padding: 13px;
  border-radius: 9px;
  background: var(--highlight);
  color: var(--accent-dark);
  font-weight: 650;
}

.resilience-lab .result.failure {
  background: #fcf1ef;
  color: var(--danger);
}

.micro-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.quiz {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.quiz p {
  margin-top: 0;
  font-weight: 650;
}

.choices {
  display: grid;
  gap: 8px;
}

.choice {
  cursor: pointer;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  text-align: left;
}

.choice.correct {
  border-color: var(--accent);
  background: var(--highlight);
}

.choice.incorrect {
  border-color: var(--danger);
  background: #fcf1ef;
}

.feedback {
  min-height: 25px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.model-answer {
  margin-top: 12px;
  border-radius: 10px;
  background: #f2f3ee;
}

.model-answer summary {
  padding: 10px 12px;
  color: var(--accent-dark);
  font-size: 0.9rem;
}

.model-answer p {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-weight: 400;
}

footer {
  margin-top: 56px;
  padding: 30px 0 54px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

@media (max-width: 860px) {
  .hero,
  .cards,
  .lesson-grid,
  .labs,
  .quiz-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 28px;
  }

  .source-browser-layout {
    grid-template-columns: 1fr;
  }

  .source-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
