/* ==========================================================================
   Node.js & Express tutorial: styles
   Palette: cool paper, slate ink, Node green. Type: Atkinson Hyperlegible
   for reading, JetBrains Mono for code.
   ========================================================================== */

:root {
  --paper: #f5f7f2;
  --surface: #ffffff;
  --ink: #1a2a31;
  --ink-2: #4b5d65;
  --ink-3: #6f8088;
  --rule: #d5dcd3;
  --rule-strong: #b9c4b7;
  --node: #2f6b25;
  --node-strong: #245a1c;
  --node-soft: #e3eedc;
  --node-bright: #6cc24a;
  --why-bg: #faf1dd;
  --why-ink: #6f470c;
  --why-rule: #d9b46a;
  --warn-bg: #fbe9e7;
  --warn-ink: #8f2a1f;
  --warn-rule: #e0a097;
  --code-bg: #15232a;
  --code-head: #1d2f37;
  --code-ink: #d8e3e8;
  --code-dim: #87a0ab;
  --focus: #1f6fd1;

  --tok-comment: #7f959e;
  --tok-string: #b7dc8f;
  --tok-keyword: #86c7f3;
  --tok-builtin: #e8a8e0;
  --tok-fn: #f2ca72;
  --tok-number: #f5ab82;
  --tok-literal: #f5ab82;
  --tok-key: #9fd6e8;
  --tok-flag: #c6a9f2;
  --tok-command: #7fd65a;
  --tok-operator: #e6ecef;

  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --topbar-h: 3.5rem;
  --sidebar-w: 17rem;
  --measure: 46rem;
  --radius-s: 4px;
  --radius-m: 8px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121b1f;
    --surface: #182328;
    --ink: #e4ebe6;
    --ink-2: #b3c1c6;
    --ink-3: #8a9ba1;
    --rule: #2b3a40;
    --rule-strong: #3d4f55;
    --node: #7fcf5d;
    --node-strong: #95dc76;
    --node-soft: #1f3320;
    --why-bg: #2c2414;
    --why-ink: #f0cf8e;
    --why-rule: #7a5b22;
    --warn-bg: #321b18;
    --warn-ink: #f4b0a6;
    --warn-rule: #7d3a31;
    --code-bg: #0e171b;
    --code-head: #172329;
    --focus: #6aa8ff;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--topbar-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0; font-weight: 700; }
h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem); letter-spacing: -0.01em; }
h3 { font-size: 1.3rem; margin: 2.5rem 0 0.75rem; }
h4 { font-size: 1.05rem; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }

a { color: var(--node); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--node-strong); text-decoration-thickness: 2px; }

code, kbd, pre { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: 0.86em;
  background: var(--node-soft);
  color: var(--ink);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-s);
  overflow-wrap: anywhere;
}
kbd {
  font-size: 0.8em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-s);
  padding: 0.05em 0.35em;
  background: var(--surface);
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; margin: -1px;
}

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 1rem; border-radius: var(--radius-s);
}
.skip-link:focus { top: 0.5rem; color: var(--paper); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  font: inherit; font-size: 0.95rem; font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-2); color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--node); border-color: var(--node); color: #fff; }
.btn.primary:hover { background: var(--node-strong); border-color: var(--node-strong); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn.primary, .btn.primary:hover { color: #0e1a0b; }
}
.btn-small { min-height: 2rem; padding: 0.25rem 0.7rem; font-size: 0.85rem; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  height: var(--topbar-h);
  padding: 0 1rem 0 1.25rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand span { color: var(--node); }
.brand:hover { color: var(--ink); }

.module-switch {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.module-switch-label { font-size: 0.8rem; color: var(--ink-3); padding: 0 0.5rem 0 0.6rem; }
.module-switch button {
  font: inherit; font-size: 0.85rem; font-weight: 700;
  padding: 0.3rem 0.8rem;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.module-switch button small { font-weight: 400; opacity: 0.8; }
.module-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.progress-bar {
  display: block; height: 100%;
  background: var(--node-bright);
  transform: scaleX(0); transform-origin: left;
}

.nav-toggle {
  display: none;
  width: 2.5rem; height: 2.5rem;
  border: 1px solid var(--rule); border-radius: var(--radius-m);
  background: var(--surface); cursor: pointer; padding: 0;
  position: relative;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  position: absolute; left: 50%; width: 1.1rem; height: 2px;
  background: var(--ink); border-radius: 2px; transform: translateX(-50%);
}
.nav-toggle-bars { top: 50%; margin-top: -1px; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.5rem 1rem 3rem 1.25rem;
  border-right: 1px solid var(--rule);
}

.toc { list-style: none; margin: 0; padding: 0; }
.toc-group {
  font-size: 0.8rem; color: var(--ink-3);
  margin: 1.4rem 0 0.35rem 0.5rem;
}
.toc-group:first-child { margin-top: 0; }
.toc a {
  display: flex; gap: 0.6rem; align-items: baseline;
  padding: 0.3rem 0.5rem;
  color: var(--ink-2); text-decoration: none;
  font-size: 0.93rem; line-height: 1.35;
  border-radius: var(--radius-s);
  border-left: 2px solid transparent;
}
.toc a:hover { color: var(--ink); background: var(--node-soft); }
.toc a[aria-current] {
  color: var(--ink); font-weight: 700;
  border-left-color: var(--node);
  background: var(--node-soft);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.toc-num {
  flex: none; width: 1.4rem;
  font-family: var(--font-mono); font-size: 0.78rem;
  color: var(--ink-3); text-align: right;
}
.toc a[aria-current] .toc-num { color: var(--node); }

.scrim { display: none; }

main {
  padding: 0 clamp(1.25rem, 4vw, 3.5rem) 4rem;
  min-width: 0;
}
main:focus { outline: none; }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  max-width: 72rem;
  padding: clamp(2.5rem, 6vw, 5rem) 0 3rem;
  border-bottom: 1px solid var(--rule);
}
.hero h1 {
  font-size: clamp(2.3rem, 1.6rem + 3vw, 3.7rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin-bottom: 1.25rem;
}
.lede { font-size: 1.2rem; color: var(--ink-2); max-width: 34rem; }
.hero-meta { font-size: 0.95rem; color: var(--ink-3); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

.terminal {
  margin: 0;
  background: var(--code-bg);
  border-radius: var(--radius-m);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -22px rgba(10, 30, 20, 0.55);
  overflow: hidden;
}
.terminal-chrome {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  background: var(--code-head);
}
.terminal-chrome span { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: #3a4c54; }
.terminal-chrome em { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 0.75rem; color: var(--code-dim); }
.terminal-body {
  margin: 0;
  padding: 1rem 1.1rem 1.25rem;
  min-height: 21rem;
  color: var(--code-ink);
  font-size: 0.85rem; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.t-prompt { color: var(--node-bright); }
.t-cmd { color: #f3f7f9; }
.t-out { color: var(--code-dim); }
.t-ok { color: var(--node-bright); font-weight: 600; }
.t-cursor {
  display: inline-block; width: 0.55em; height: 1.1em;
  vertical-align: text-bottom; background: var(--code-ink);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .t-cursor { animation: none; } }

.intro-notes {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 72rem;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.intro-notes h2 { font-size: 1.2rem; margin-bottom: 0.75rem; }
.legend-list { list-style: none; padding: 0; margin: 0; }
.legend-list li { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.9rem; font-size: 0.95rem; color: var(--ink-2); }
.legend-list .badge { align-self: flex-start; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  font-size: 0.75rem; font-weight: 700; line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-s);
  border: 1px solid;
  white-space: nowrap;
}
.badge-sim { color: var(--node); border-color: currentColor; background: var(--node-soft); }
.badge-sb { color: #1f5fa8; border-color: currentColor; background: #e5eef9; }
.badge-local { color: var(--ink-2); border-color: var(--rule-strong); background: var(--surface); }
@media (prefers-color-scheme: dark) {
  .badge-sb { color: #8bbcf3; background: #172838; }
}

/* ---------- Lessons ---------- */

.lesson {
  max-width: var(--measure);
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--rule);
}
.lesson-wide { max-width: 72rem; }
.lesson-wide > p, .lesson-wide > h3, .lesson-wide > .lesson-head { max-width: var(--measure); }

.lesson-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.1rem;
  align-items: start;
  margin-bottom: 1.75rem;
}
.lesson-num {
  font-family: var(--font-mono); font-weight: 600;
  font-size: 2.6rem; line-height: 0.9;
  color: var(--node);
  min-width: 2.2ch;
  padding-top: 0.1rem;
}
.lesson-where { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 0; }

.note {
  font-size: 0.95rem; color: var(--ink-2);
  padding-left: 1rem;
  border-left: 3px solid var(--rule-strong);
}

.callout {
  margin: 1.75rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-m);
  border: 1px solid;
}
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; margin-bottom: 0.35rem; }
.callout.why { background: var(--why-bg); border-color: var(--why-rule); }
.callout.why .callout-title { color: var(--why-ink); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-rule); }
.callout.warn .callout-title { color: var(--warn-ink); }

.rule {
  margin: 1.5rem 0;
  padding: 1.1rem 1.4rem;
  font-size: 1.3rem; font-weight: 700; line-height: 1.35;
  background: var(--surface);
  border-left: 4px solid var(--node);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
}

ul.plain, ol.steps, ol.exercises { padding-left: 1.25rem; margin: 0 0 1.25rem; }
ul.plain li, ol.steps li, ol.exercises li { margin-bottom: 0.55rem; }
ol.exercises li { margin-bottom: 0.9rem; padding-left: 0.3rem; }
ol.exercises li::marker { font-family: var(--font-mono); color: var(--node); font-weight: 600; }

.field-list, .tool-list { margin: 1.25rem 0 1.75rem; }
.field-list dt, .tool-list dt { font-weight: 700; margin-top: 1.1rem; }
.field-list dd, .tool-list dd { margin: 0.25rem 0 0; color: var(--ink-2); }
.field-list dd p { margin-bottom: 0.6rem; }
.field-list dd p:last-child { margin-bottom: 0; }

.side-by-side {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.5rem;
}
.side-by-side .codeblock { margin: 0 0 0.75rem; }
.choice {
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
}
.choice ul { margin-bottom: 0; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 1.25rem 0 1.75rem; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--rule); }
thead th { font-size: 0.85rem; color: var(--ink-2); background: var(--paper); }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 700; white-space: nowrap; }
.capability td:not(:first-child) { white-space: nowrap; color: var(--ink-2); }

/* ---------- Deep dives (details) ---------- */

.deep-dive {
  margin: 1.25rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.deep-dive > summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 700;
  list-style: none;
  display: flex; gap: 0.6rem; align-items: baseline;
}
.deep-dive > summary::-webkit-details-marker { display: none; }
.deep-dive > summary::before {
  content: "+"; font-family: var(--font-mono); color: var(--node); width: 1ch; flex: none;
}
.deep-dive[open] > summary::before { content: "\2212"; }
.deep-dive[open] > summary { border-bottom: 1px solid var(--rule); }
.deep-dive > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.deep-dive > :nth-child(2) { margin-top: 0.9rem; }
.deep-dive > :last-child { margin-bottom: 1rem; }
.deep-dive .variants { margin-left: 1rem; margin-right: 1rem; }

/* ---------- Code blocks ---------- */

.codeblock {
  margin: 1rem 0 1.5rem;
  background: var(--code-bg);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  background: var(--code-head);
  min-height: 2.35rem;
}
.codeblock-file { font-family: var(--font-mono); font-size: 0.78rem; color: var(--code-dim); overflow-wrap: anywhere; }
.codeblock-bash .codeblock-file::before { content: "> "; color: var(--node-bright); }
.copy-btn {
  flex: none;
  font: 600 0.75rem var(--font-mono);
  color: var(--code-ink);
  background: transparent;
  border: 1px solid #36505a;
  border-radius: var(--radius-s);
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--code-dim); background: rgba(255, 255, 255, 0.05); }
.copy-btn.is-done { color: var(--node-bright); border-color: var(--node-bright); }

pre.code {
  margin: 0;
  padding: 1rem 1.1rem 1.1rem;
  overflow-x: auto;
  color: var(--code-ink);
  font-size: 0.84rem; line-height: 1.65;
  tab-size: 2;
}
pre.code code { font-family: inherit; }
.codeblock-out { background: transparent; border: 1px dashed var(--rule-strong); }
.codeblock-out .codeblock-head { background: transparent; border-bottom: 1px dashed var(--rule-strong); }
.codeblock-out .codeblock-file { color: var(--ink-3); }
.codeblock-out pre.code { color: var(--ink); }

.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-string { color: var(--tok-string); }
.tok-keyword { color: var(--tok-keyword); }
.tok-builtin { color: var(--tok-builtin); }
.tok-fn { color: var(--tok-fn); }
.tok-number, .tok-literal { color: var(--tok-number); }
.tok-key { color: var(--tok-key); }
.tok-flag { color: var(--tok-flag); }
.tok-command { color: var(--tok-command); font-weight: 600; }
.tok-operator { color: var(--tok-operator); }

/* Folder tree */
pre.tree {
  margin: 1.25rem 0 1.75rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  overflow-x: auto;
  font-size: 0.82rem; line-height: 1.7;
  color: var(--ink);
}
.tree-note { color: var(--ink-3); font-family: var(--font-body); font-size: 0.85rem; }

/* ---------- Module variants ---------- */

.variants { margin: 1rem 0 1.5rem; }
.variant-tabs {
  display: inline-flex; gap: 0.2rem;
  padding: 0.2rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.variant-tabs button {
  font: inherit; font-size: 0.82rem; font-weight: 700;
  padding: 0.3rem 0.7rem;
  border: 0; border-radius: var(--radius-s);
  background: transparent; color: var(--ink-2);
  cursor: pointer;
}
.variant-tabs button small { font-weight: 400; }
.variant-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.variant .codeblock:first-child { margin-top: 0; }

html[data-module="cjs"] .variant[data-module="esm"],
html[data-module="esm"] .variant[data-module="cjs"] { display: none; }

/* ---------- OS tabs ---------- */

.tabs { margin: 1.25rem 0 1.75rem; }
.tab-list { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule-strong); }
.tab-list [role="tab"] {
  font: inherit; font-weight: 700; font-size: 0.95rem;
  padding: 0.55rem 1rem;
  background: transparent; color: var(--ink-2);
  border: 1px solid transparent; border-bottom: 0;
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab-list [role="tab"][aria-selected="true"] {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--rule-strong);
}
.tab-panel { padding-top: 1rem; }

/* ---------- Pipeline diagram ---------- */

.pipeline { margin: 1.75rem 0; }
.pipeline-steps {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.pipeline-steps li {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  width: min(100%, 22rem);
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-m);
  font-size: 0.9rem;
}
.pipeline-steps li:first-child { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.pipeline-steps li small { color: var(--ink-3); font-size: 0.8rem; }
/* Arrows between steps (none into the error handler: it's a side path) */
.pipeline-steps li:not(:last-child):not(:nth-last-child(2))::after {
  content: ""; position: absolute;
  left: 1.2rem; bottom: -1rem; width: 2px; height: 0.8rem;
  background: var(--node);
}
.pipeline-steps li:not(:last-child):not(:nth-last-child(2))::before {
  content: ""; position: absolute;
  left: calc(1.2rem - 4px); bottom: -1.15rem;
  border: 5px solid transparent; border-top: 6px solid var(--node); border-bottom: 0;
}
.pipeline-steps li.pipeline-err { margin-left: 2rem; }
.pipeline-steps li.pipeline-err { border-style: dashed; border-color: var(--warn-rule); background: var(--warn-bg); }
.pipeline figcaption { font-size: 0.9rem; color: var(--ink-2); margin-top: 0.75rem; }

/* ---------- Try boxes ---------- */

.try {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem;
  margin: 2rem 0 0;
  padding: 1rem 1.2rem;
  background: var(--node-soft);
  border-radius: var(--radius-m);
}
.try p { margin: 0; flex: 1 1 16rem; font-weight: 700; }
.try-top { margin: 0 0 1.5rem; }

/* ---------- Playground ---------- */

.playground {
  margin: 1.5rem 0 2.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: calc(var(--radius-m) + 4px);
}
.pg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.pg-select { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.9rem; min-width: 0; max-width: 100%; }
.pg-select select { min-width: 0; max-width: 100%; }
.pg-select select,
.pg-req-line select,
.pg-req-line input,
.pg-small-input {
  font: inherit; font-size: 0.9rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-s);
  padding: 0.4rem 0.55rem;
  min-height: 2.35rem;
}
.pg-mode { margin: 0; font-size: 0.9rem; color: var(--ink-2); }
.pg-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.pg-blurb { margin: 0.9rem 0 0; color: var(--ink-2); max-width: var(--measure); }
.pg-notice {
  margin: 0.75rem 0 0; padding: 0.6rem 0.9rem;
  background: var(--why-bg); color: var(--why-ink);
  border: 1px solid var(--why-rule); border-radius: var(--radius-s);
  font-size: 0.92rem;
}

.pg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.pg-filetabs { display: flex; gap: 2px; }
.pg-filetabs button {
  font: 600 0.8rem var(--font-mono);
  padding: 0.45rem 0.9rem;
  background: var(--code-head); color: var(--code-dim);
  border: 0; border-radius: var(--radius-m) var(--radius-m) 0 0;
  cursor: pointer;
}
.pg-filetabs button[aria-selected="true"] { background: var(--code-bg); color: #f3f7f9; }

.editor {
  position: relative;
  height: 30rem;
  background: var(--code-bg);
  border-radius: 0 var(--radius-m) var(--radius-m) var(--radius-m);
  overflow: hidden;
}
.editor-highlight,
.editor-input {
  position: absolute; inset: 0;
  margin: 0;
  padding: 1rem 1.1rem;
  font: 0.84rem/1.65 var(--font-mono);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  word-wrap: normal;
  border: 0;
}
.editor-highlight { overflow: hidden; color: var(--code-ink); pointer-events: none; }
.editor-highlight code { font: inherit; }
.editor-input {
  width: 100%; height: 100%;
  resize: none;
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #ffffff;
  outline: none;
}
.editor-input::selection { background: rgba(134, 199, 243, 0.3); color: transparent; }
.editor:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.pg-help { font-size: 0.8rem; color: var(--ink-3); margin: 0.4rem 0 0; }

.pg-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.pg-panel {
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--paper);
}
.pg-panel h3 { font-size: 1rem; margin: 0 0 0.6rem; }
.pg-quick { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.chip {
  font: 0.78rem var(--font-mono);
  padding: 0.3rem 0.55rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-s);
  cursor: pointer;
  text-align: left;
}
.chip:hover { border-color: var(--node); }
.chip-method { font-weight: 600; }
.method-get { color: var(--node); }
.method-post { color: #1f5fa8; }
.method-put, .method-patch { color: #8a5a00; }
.method-delete { color: var(--warn-ink); }
@media (prefers-color-scheme: dark) {
  .method-post { color: #8bbcf3; }
  .method-put, .method-patch { color: #f0cf8e; }
}

.pg-req-line { display: flex; gap: 0.4rem; }
.pg-req-line input { flex: 1; min-width: 0; font-family: var(--font-mono); }
.pg-label { display: block; font-size: 0.85rem; font-weight: 700; margin: 0.7rem 0 0.25rem; }
.pg-label small { font-weight: 400; color: var(--ink-3); }
.pg-small-input { width: 100%; font-family: var(--font-mono); font-size: 0.8rem; resize: vertical; }
.pg-small-input:disabled { opacity: 0.45; }

.pg-response { font-size: 0.9rem; }
.pg-empty { color: var(--ink-3); margin: 0; }
.res-request { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-3); margin: 0 0 0.35rem; }
.res-status { font-family: var(--font-mono); font-weight: 600; margin: 0 0 0.5rem; display: flex; gap: 0.6rem; align-items: baseline; }
.res-code { font-size: 1.15rem; }
.res-time { margin-left: auto; font-weight: 400; font-size: 0.78rem; color: var(--ink-3); }
.res-2xx .res-code, .res-3xx .res-code { color: var(--node); }
.res-4xx .res-code { color: #8a5a00; }
.res-5xx .res-code { color: var(--warn-ink); }
@media (prefers-color-scheme: dark) { .res-4xx .res-code { color: #f0cf8e; } }
.res-headers summary { cursor: pointer; font-size: 0.82rem; color: var(--ink-2); }
.res-headers pre { font-size: 0.75rem; margin: 0.35rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.res-body {
  margin: 0.6rem 0 0;
  padding: 0.75rem 0.85rem;
  max-height: 15rem; overflow: auto;
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--radius-s);
  font-size: 0.8rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.res-body-empty { color: var(--code-dim); font-style: italic; }
.res-error, .res-hung {
  margin: 0;
  padding: 0.7rem 0.85rem;
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid var(--warn-rule); border-radius: var(--radius-s);
}
.res-hung p { margin: 0.35rem 0 0; }

.pg-console-wrap { margin-top: 1rem; }
.pg-console-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.pg-console-head h3 { font-size: 1rem; margin: 0; }
.pg-console {
  margin: 0;
  height: 12rem; overflow: auto;
  padding: 0.8rem 1rem;
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--radius-m);
  font-size: 0.8rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.con-cmd { color: var(--node-bright); font-weight: 600; }
.con-info, .con-dim { color: var(--code-dim); }
.con-warn { color: #f2ca72; }
.con-error { color: #ff9c8f; }

.pg-sb { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.pg-sb h3 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.pg-sb p { color: var(--ink-2); max-width: var(--measure); font-size: 0.95rem; }
.pg-sb-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pg-sb-frame { margin-top: 1rem; height: 38rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-m); overflow: hidden; }
.pg-sb-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Checklist ---------- */

.checklist { list-style: none; padding: 0; margin: 1.25rem 0 1rem; }
.checklist li { border-bottom: 1px solid var(--rule); }
.checklist label { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.65rem 0.25rem; cursor: pointer; }
.checklist input {
  flex: none; width: 1.15rem; height: 1.15rem; margin-top: 0.25rem;
  accent-color: var(--node);
}
.checklist input:checked + * , .checklist label:has(input:checked) { color: var(--ink-3); }
.checklist-status { font-weight: 700; }

/* ---------- Footer ---------- */

.site-footer { max-width: var(--measure); padding: 2.5rem 0 0; font-size: 0.88rem; color: var(--ink-3); }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .pg-grid { grid-template-columns: minmax(0, 1fr); }
  .editor { height: 24rem; }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-block; flex: none; }
  .sidebar {
    position: fixed; z-index: 50;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: min(20rem, 85vw); height: auto;
    background: var(--paper);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: 8px 0 30px -12px rgba(0, 0, 0, 0.35);
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(10, 20, 25, 0.4); }
  .scrim[hidden] { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .terminal-body { min-height: 0; }
  .intro-notes { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}

@media (max-width: 720px) {
  .module-switch-label { display: none; }
  .module-switch button small { display: none; }
  .brand { display: none; }
  .module-switch { margin-left: auto; }
  .side-by-side { grid-template-columns: minmax(0, 1fr); }
  .lesson { padding-top: 3rem; }
  .lesson-num { font-size: 2rem; }
  .pg-actions { margin-left: 0; width: 100%; }
  .pg-select { width: 100%; }
  .pg-select select { flex: 1; }
  .pg-actions .btn { flex: 1; }
  .playground { padding: 0.9rem; }
  .capability td:not(:first-child) { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print {
  .topbar, .sidebar, .playground, .try, .copy-btn, .variant-tabs { display: none !important; }
  .layout { display: block; }
  html[data-module] .variant { display: block !important; }
}
