/* Cocoa landing — themeable */

:root {
  --bg: #f5efe2;
  --bg-soft: #efe7d4;
  --paper: #fbf6ee;
  --ink: #241914;
  --ink-2: #4a3a2e;
  --muted: #8a7866;
  --rule: rgba(36, 25, 20, 0.12);
  --rule-strong: rgba(36, 25, 20, 0.22);
  --accent: #b4571f;
  --accent-soft: rgba(180, 87, 31, 0.10);

  --code-bg: #fbf6ee;
  --code-fg: #241914;
  --code-kw: #a14a1a;
  --code-cm: #9c8d7b;
  --code-nm: #715124;
  --code-st: #557a3a;
  --code-tp: #4a6580;
  --code-pn: #7a6a5a;
  --code-gut: #b8a890;
  --code-border: rgba(36, 25, 20, 0.10);

  --serif: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans:  "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="mono"] {
  --bg: #f4f3f0;
  --bg-soft: #ebe9e4;
  --paper: #fafaf8;
  --ink: #16140f;
  --ink-2: #3a3833;
  --muted: #7d7a72;
  --rule: rgba(22, 20, 15, 0.12);
  --rule-strong: rgba(22, 20, 15, 0.24);
  --accent: #16140f;
  --accent-soft: rgba(22, 20, 15, 0.06);

  --code-bg: #fafaf8;
  --code-fg: #16140f;
  --code-kw: #16140f;
  --code-cm: #9b988f;
  --code-nm: #5a5750;
  --code-st: #5a5750;
  --code-tp: #16140f;
  --code-pn: #6e6b62;
  --code-gut: #bcb8ad;
  --code-border: rgba(22, 20, 15, 0.12);
}

[data-theme="dark"] {
  --bg: #14100c;
  --bg-soft: #1c1812;
  --paper: #1a1611;
  --ink: #f1e6d3;
  --ink-2: #c8b89e;
  --muted: #8a7b66;
  --rule: rgba(241, 230, 211, 0.10);
  --rule-strong: rgba(241, 230, 211, 0.22);
  --accent: #e0884a;
  --accent-soft: rgba(224, 136, 74, 0.14);

  --code-bg: #100c08;
  --code-fg: #e8ddc8;
  --code-kw: #e0884a;
  --code-cm: #7a6e60;
  --code-nm: #d4b066;
  --code-st: #a3c977;
  --code-tp: #88a8d0;
  --code-pn: #9a8a78;
  --code-gut: #5a4f42;
  --code-border: rgba(241, 230, 211, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px;
}

.wrap.wide {
  max-width: 1280px;
}

/* ── Tutorial ─────────────────────────────────────── */
.tut-header {
  padding-top: 56px;
  padding-bottom: 24px;
}
.tut-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(32px, 4vw, 44px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 28px;
}
.tut-lede {
  max-width: 70ch;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.tut-lede p { margin: 0 0 14px; }
.tut-lede p:last-child { margin-bottom: 0; }
.tut-lede code, .ex-prose code, .note code, .toc-label code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
}

.tut-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 64px;
  padding-top: 24px;
  padding-bottom: 64px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 28px;
  align-self: start;
  font-family: var(--mono);
  font-size: 12px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding-right: 8px;
}
.toc-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.toc nav { display: flex; flex-direction: column; gap: 2px; }
.toc-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: baseline;
  padding: 6px 8px 6px 0;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s ease, background 0.12s ease;
}
.toc-item:hover { color: var(--ink); }
.toc-item.active { color: var(--accent); }
.toc-num {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.toc-item.active .toc-num { color: var(--accent); }
.toc-label {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
}

.tut-article {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.ex {
  scroll-margin-top: 32px;
}
.ex-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.ex-num {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.ex-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0;
}
.ex-prose {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
  max-width: 72ch;
  margin-bottom: 24px;
}
.ex-prose p { margin: 0 0 12px; }
.ex-prose p:last-child { margin-bottom: 0; }
.ex-prose strong { color: var(--ink); font-weight: 600; }

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.panel {
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--code-border);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.02em;
  color: var(--code-pn);
}
.panel-head .dotmark {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.panel .code {
  margin: 0;
  padding: 14px 0;
  font: 12.5px/1.55 var(--mono);
  color: var(--code-fg);
  background: var(--code-bg);
  overflow: auto;
  position: relative;
}
.panel .code .line {
  display: grid;
  grid-template-columns: 38px 1fr;
  padding: 0 14px 0 0;
}
.panel .code .ln {
  color: var(--code-gut);
  text-align: right;
  padding-right: 12px;
  user-select: none;
  font-size: 11px;
  padding-top: 1px;
}
.panel .code .src { white-space: pre; }
.panel .code::-webkit-scrollbar { height: 8px; width: 8px; }
.panel .code::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 8px;
  border: 2px solid var(--code-bg);
  background-clip: padding-box;
}

.note {
  margin-top: 24px;
  padding: 14px 18px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.note p { margin: 0 0 8px; }
.note p:last-child { margin-bottom: 0; }
.note ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.note li + li { margin-top: 4px; }
.note strong { color: var(--ink); font-weight: 600; }

@media (max-width: 1024px) {
  .tut-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .toc {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 18px;
    margin-bottom: 12px;
  }
  .toc nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 16px;
  }
}

@media (max-width: 760px) {
  .panels { grid-template-columns: 1fr; }
  .toc nav { grid-template-columns: 1fr; }
}

/* ── Nav ─────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 28px;
}
.brand {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .ver-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  height: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0 7px;
}
.brand .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  margin: 0 0 4px 2px;
}
.nav-links {
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ── Hero ────────────────────────────────────────── */
.hero {
  position: relative;
  padding-top: 80px;
  padding-bottom: 64px;
  overflow: hidden;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow .pill {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--ink-2);
}
.headline {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 28px;
  max-width: 22ch;
  text-wrap: balance;
}
.headline em {
  font-style: normal;
  color: var(--accent);
}
.sub {
  font-size: 19px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 58ch;
  margin: 0 0 36px;
  text-wrap: pretty;
}

.install {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 13.5px;
  overflow: hidden;
  min-width: 380px;
}
.install-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
}
.install-row + .install-row { border-top: 1px solid var(--rule); }
.install-row .prompt {
  color: var(--muted);
  user-select: none;
}
.install-row .cmd { color: var(--ink); }
.install-row .copy {
  margin-left: auto;
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.install-row .copy:hover { color: var(--accent); background: var(--accent-soft); }

/* Square-wave decoration */
.hero-wave {
  position: absolute;
  bottom: 40px;
  right: -40px;
  opacity: 0.55;
  pointer-events: none;
  color: var(--rule-strong);
}
[data-theme="dark"] .hero-wave { opacity: 0.7; }

/* ── Section common ──────────────────────────────── */
.section {
  padding: 72px 0;
  border-top: 1px solid var(--rule);
}
.section-label {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  max-width: 28ch;
}
.section-title em { font-style: normal; color: var(--accent); }
.section-lede {
  color: var(--ink-2);
  font-size: 16.5px;
  max-width: 56ch;
  margin: 0 0 40px;
}

/* ── Carousel ────────────────────────────────────── */
.carousel {
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}
.carousel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
  gap: 16px;
}
.example-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.example-title .idx {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.example-title .nm {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.example-title .nm em { font-style: italic; }

.carousel-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.arrow {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.arrow:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.arrow:disabled { opacity: 0.35; cursor: default; }
.arrow:disabled:hover { background: var(--paper); color: var(--ink-2); border-color: var(--rule); }

.dots {
  display: flex;
  gap: 6px;
  margin: 0 8px;
}
.dot-btn {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--rule-strong);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease, width 0.2s ease;
}
.dot-btn.active {
  background: var(--accent);
  width: 18px;
}

/* Example body */
.example-body {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.caption {
  font-size: 14.5px;
  color: var(--ink-2);
  max-width: 64ch;
  margin: 0;
}
.caption .key { color: var(--accent); font-family: var(--mono); font-size: 13px; }

/* Tabs */
.tabs-wrap {
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}
.tabs {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--code-border);
  background: var(--code-bg);
  padding: 0 10px;
}
.tab {
  position: relative;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--code-pn);
  font: 500 12.5px/1 var(--mono);
  padding: 14px 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab .tag {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--code-pn);
  opacity: 0.7;
}
.tab.active { color: var(--code-fg); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab .dotmark {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--code-pn);
  opacity: 0.5;
}
.tab.active .dotmark { background: var(--accent); opacity: 1; }

.stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 6px;
  font: 500 11.5px/1 var(--mono);
  color: var(--code-pn);
}
.stats .delta { color: var(--accent); }

/* Code block */
.code {
  margin: 0;
  padding: 18px 0 18px;
  font: 13px/1.6 var(--mono);
  color: var(--code-fg);
  background: var(--code-bg);
  overflow-x: auto;
  position: relative;
  transition: opacity 0.18s ease;
}
.code.swap { opacity: 0; }
.code .line {
  display: grid;
  grid-template-columns: 48px 1fr;
  padding: 0 18px 0 0;
}
.code .ln {
  color: var(--code-gut);
  text-align: right;
  padding-right: 14px;
  user-select: none;
  font-size: 11.5px;
  padding-top: 1px;
}
.code .src {
  white-space: pre;
}
.tk-k  { color: var(--code-kw); font-weight: 500; }
.tk-c  { color: var(--code-cm); font-style: italic; }
.tk-n  { color: var(--code-nm); }
.tk-s  { color: var(--code-st); }
.tk-tp { color: var(--code-tp); }
.tk-i  { color: var(--code-fg); }
.tk-p  { color: var(--code-pn); }

.code::-webkit-scrollbar { width: 10px; height: 10px; }
.code::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 8px;
  border: 2px solid var(--code-bg);
  background-clip: padding-box;
}
.code::-webkit-scrollbar-track { background: transparent; }

/* ── Features ────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}
.section-title.why {
  font-size: 36px;
  margin-bottom: 40px;
}
.feat .num {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.feat h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.3;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.feat p {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  text-wrap: pretty;
}

/* ── Footer ──────────────────────────────────────── */
.footer {
  padding-top: 48px;
  padding-bottom: 56px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}
.footer .left { font-family: var(--serif); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.footer .right { display: flex; gap: 22px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 720px) {
  .wrap { padding-left: 22px; padding-right: 22px; }
  .hero { padding-top: 64px; padding-bottom: 48px; }
  .install { min-width: 0; width: 100%; }
  .features { grid-template-columns: 1fr; gap: 28px; }
  .nav-links { gap: 16px; }
  .nav-links .ver { display: none; }
  .stats { display: none; }
  .section { padding: 56px 0; }
  .example-title .nm { font-size: 18px; }
  .code .line { grid-template-columns: 38px 1fr; }
}

/* ── Reference page ───────────────────────────────── */
.ref-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 64px;
  padding-top: 24px;
  padding-bottom: 64px;
  align-items: start;
}
.ref-article {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 64px;
}
.ref-section { display: flex; flex-direction: column; gap: 48px; }
.ref-h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-strong);
}

.ref-group { scroll-margin-top: 32px; }
.ref-group-title {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}
.ref-rows {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
}
.ref-row {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 36px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}
.ref-syntax {
  font: 12.5px/1.55 var(--mono);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--code-fg);
  overflow-x: auto;
}
.ref-syntax .line { display: block; white-space: pre; grid-template-columns: none; padding: 0; }
.ref-syntax .ln { display: none; }
.ref-syntax .src { white-space: pre; }

.ref-desc h4 {
  font: 500 14.5px/1.3 var(--sans);
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.ref-desc p {
  margin: 0 0 10px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.ref-desc p code, .ref-gen code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
}
.ref-gen {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font: 12px/1.4 var(--mono);
  color: var(--muted);
  margin-top: 4px;
}
.ref-gen-lbl {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

.sem { scroll-margin-top: 32px; }
.sem-title {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}
.sem-body {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 72ch;
}
.sem-body p { margin: 0 0 12px; }
.sem-body p:last-child { margin-bottom: 0; }
.sem-body strong { color: var(--ink); font-weight: 600; }
.sem-body ul { margin: 8px 0 12px; padding-left: 20px; }
.sem-body li { margin-bottom: 6px; }
.sem-body li:last-child { margin-bottom: 0; }
.sem-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
}
.sem-block {
  margin: 8px 0 14px;
  padding: 14px 16px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  font: 12.5px/1.55 var(--mono);
  color: var(--code-fg);
  overflow-x: auto;
  white-space: pre;
}
.sem-block .line { display: block; white-space: pre; grid-template-columns: none; padding: 0; }
.sem-block .ln { display: none; }

.toc-group-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.toc-group-label:first-child { margin-top: 0; }
.toc-item.sub {
  grid-template-columns: 1fr;
  padding: 5px 8px 5px 0;
}
.toc-item.sub .toc-label { font-size: 12.5px; }

@media (max-width: 1024px) {
  .ref-layout { grid-template-columns: 1fr; gap: 24px; }
  .ref-row { grid-template-columns: 1fr; gap: 14px; }
}

/* ── Mobile: section bar + drawer + tabbed panels ── */

/* Desktop default: mobile bits hidden. */
.m-bar, .m-drawer, .m-drawer-backdrop, .panel-tabs { display: none; }

@media (max-width: 900px) {
  /* Stack panels and show the tab strip. */
  .panels { grid-template-columns: 1fr; gap: 0; }
  .panel-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-soft);
    border: 1px solid var(--rule);
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .panel-tabs button {
    flex: 1;
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 7px;
    padding: 9px 10px;
    font: 500 12px/1 var(--mono);
    color: var(--muted);
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.12s ease, color 0.12s ease;
  }
  .panel-tabs button .dotmark {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rule-strong);
  }
  .panel-tabs button.active {
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .panel-tabs button.active .dotmark { background: var(--accent); }

  /* Show only the selected panel. */
  .panels-wrap.show-cocoa .panel[data-which="rtl"]    { display: none; }
  .panels-wrap.show-rtl   .panel[data-which="cocoa"]  { display: none; }
  .panel .panel-head { display: none; }  /* tab strip replaces individual heads */

  /* Hide the desktop sidebar TOC; the bottom bar replaces it. */
  .tut-layout, .ref-layout { grid-template-columns: 1fr; gap: 16px; }
  .tut-layout > .toc, .ref-layout > .toc { display: none; }

  /* Bottom-fixed section bar. */
  .m-bar {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 90;
    align-items: stretch;
    gap: 6px;
    padding: 6px;
    background: rgba(245, 239, 226, 0.92);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    border-radius: 14px;
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  }
  [data-theme="mono"] .m-bar { background: rgba(244,243,240,0.92); }
  [data-theme="dark"] .m-bar { background: rgba(28,24,18,0.92); }

  .m-bar-btn {
    width: 40px;
    flex: 0 0 auto;
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--ink-2);
    border-radius: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .m-bar-btn:disabled { opacity: 0.3; }
  .m-bar-btn:not(:disabled):active { background: var(--accent-soft); color: var(--accent); }

  .m-bar-toc {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 0;
    border-radius: 9px;
    padding: 6px 12px;
    text-align: left;
    color: var(--ink);
    cursor: pointer;
  }
  .m-bar-toc:active { background: var(--accent-soft); }
  .m-bar-num {
    font: 500 10.5px/1 var(--mono);
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .m-bar-title {
    font: 500 13.5px/1.1 var(--sans);
    color: var(--ink);
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-bar-caret { color: var(--muted); flex-shrink: 0; }

  /* Drawer (slides up from bottom) */
  .m-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 12, 0.42);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
  .m-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

  .m-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 96;
    max-height: 78vh;
    background: var(--bg);
    border-top: 1px solid var(--rule-strong);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.16);
    overflow: hidden;
  }
  .m-drawer.open { transform: translateY(0); }
  .m-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--rule);
    position: relative;
  }
  .m-drawer-head::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--rule-strong);
  }
  .m-drawer-eyebrow {
    font: 500 11px/1 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .m-drawer-x {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--ink-2);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .m-drawer-x:active { background: var(--accent-soft); color: var(--accent); }
  .m-drawer-list {
    overflow-y: auto;
    padding: 8px 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .m-drawer-group {
    font: 500 10.5px/1 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 18px 8px 8px;
  }
  .m-drawer-item {
    display: grid;
    grid-template-columns: 32px 1fr;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    text-decoration: none;
    color: var(--ink-2);
    border-radius: 8px;
    transition: background 0.1s ease, color 0.1s ease;
  }
  .m-drawer-item:active { background: var(--accent-soft); }
  .m-drawer-item.active { color: var(--accent); background: var(--accent-soft); }
  .m-drawer-num {
    font: 500 10.5px/1 var(--mono);
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  .m-drawer-item.active .m-drawer-num { color: var(--accent); }
  .m-drawer-title {
    font: 500 14px/1.3 var(--sans);
  }

  /* Add bottom padding to the layout so the bar doesn't cover content. */
  .tut-layout, .ref-layout { padding-bottom: 96px; }

  /* Tighten code in tabbed view. */
  .panel .code { font-size: 12px; line-height: 1.55; }
  .panel .code .line { grid-template-columns: 32px 1fr; padding-right: 10px; }
  .panel .code .ln { padding-right: 8px; font-size: 10.5px; }

  /* Nav: smaller links, hide trailing items. */
  .nav-links { gap: 16px; font-size: 11px; }
  .nav-links a:nth-child(n+3) { display: none; }  /* keep first 2 visible */

  /* Tutorial/reference headers: more compact. */
  .tut-header { padding-top: 32px; padding-bottom: 16px; }
  .tut-title { font-size: 32px; }
  .tut-lede { font-size: 15px; }
  .ex-title { font-size: 22px; }
  .ex-prose { font-size: 15px; }
  .ref-h2 { font-size: 24px; }

  /* Cheat-sheet rows: stack neatly. */
  .ref-row { padding: 18px 0; }
  .ref-syntax { font-size: 12px; padding: 10px 12px; }

  /* Semantics: hide block code overflow scrollbars on touch. */
  .sem-body { font-size: 15px; }
}

/* ── Landing-specific mobile tightening ─────────────── */
@media (max-width: 640px) {
  .hero { padding-top: 56px; padding-bottom: 40px; }
  .install {
    min-width: 0;
    width: 100%;
    font-size: 12.5px;
  }
  .install-row { padding: 9px 12px; }
  .nav-links { font-size: 11px; gap: 14px; }
  .nav-links a:last-child { display: none; }
  .ver-pill { font-size: 10px; padding: 2px 6px; }
  .section { padding: 48px 0; }
  .carousel-head { flex-wrap: wrap; gap: 10px; }
  .example-title .nm { font-size: 16px; }
}
