/* ─── Juice Docs — Design System ───────────────────────────────── */
/* Accessible, responsive, dark/light. WCAG 2.1 AA contrast.       */
/* ──────────────────────────────────────────────────────────────── */

/* ─── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg: #09090b;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --code-bg: #111113;
  --border: #27272a;
  --border-h: #3f3f46;

  /* Text — all pass WCAG AA on --bg */
  --text: #fafafa; /* 19.5:1 on #09090b */
  --text-2: #d4d4d8; /* 13.1:1 */
  --muted: #a1a1aa; /* 7.3:1  */

  /* Interactive */
  --link: #60a5fa; /* 6.1:1 on #09090b */
  --link-h: #93bbfd;
  --focus: #3b82f6;

  /* Status */
  --green: #4ade80;
  --yellow: #facc15;
  --red: #f87171;

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h: 48px;
  --content-max: 1080px;
  --layout-max: 1520px;

  /* Type */
  --font: "Avenir Next", "Segoe UI Variable Text", "IBM Plex Sans",
    "Source Sans 3", "Helvetica Neue", sans-serif;
  --mono: "Berkeley Mono", "CommitMono", "JetBrains Mono", "Cascadia Code",
    ui-monospace, monospace;
  --base: 16px;
  --scale: 1.2;

  color-scheme: dark;
}

/* ─── Light Mode ──────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #fafafa;
    --surface-2: #f4f4f5;
    --code-bg: #f4f4f5;
    --border: #e4e4e7;
    --border-h: #d4d4d8;

    --text: #09090b; /* 19.5:1 on #fff */
    --text-2: #27272a; /* 16.0:1 */
    --muted: #52525b; /* 7.5:1  */

    --link: #2563eb; /* 5.1:1 on #fff */
    --link-h: #1d4ed8;
    --focus: #2563eb;

    --green: #16a34a;
    --yellow: #ca8a04;
    --red: #dc2626;

    color-scheme: light;
  }
}

/* ─── Reset ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: var(--base);
  background: var(--bg);
  background-image: radial-gradient(
      1100px 500px at 8% -10%,
      rgba(96, 165, 250, 0.11),
      transparent 60%
    ),
    radial-gradient(
      900px 450px at 95% 0%,
      rgba(74, 222, 128, 0.07),
      transparent 62%
    );
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Links & Focus ───────────────────────────────────────────── */
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--link-h);
  text-decoration: underline;
}

/* Visible focus ring for keyboard navigation (accessibility) */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip nav link for screen readers */
.skip-nav {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-nav:focus {
  position: fixed;
  left: 1rem;
  top: 0.5rem;
  width: auto;
  height: auto;
  overflow: visible;
  padding: 0.5rem 1rem;
  background: var(--focus);
  color: #fff;
  border-radius: 4px;
  z-index: 100;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ─── Typography ──────────────────────────────────────────────── */
code {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  word-break: break-word;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.65;
  margin: 1.25rem 0;
  tab-size: 2;
  -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
}
pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
  word-break: normal;
}

/* ─── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(1rem, 2vw, 1.5rem);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0;
  isolation: isolate;
}

/* Brand */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  margin-right: 1.5rem;
  flex-shrink: 0;
}
.topbar-brand:hover {
  text-decoration: none;
}
.topbar-icon {
  font-size: 1.15rem;
  line-height: 1;
}
.topbar-wordmark {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.topbar-version {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.01em;
  margin-left: 0.15rem;
}

/* Navigation links */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.topbar-nav a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.topbar-nav a:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.topbar .spacer {
  flex: 1;
}

/* Right actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
  text-decoration: none;
}
.topbar-icon-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.topbar-icon-link svg {
  display: block;
}

.topbar-cta {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bg) !important;
  background: var(--text);
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  text-decoration: none !important;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.topbar-cta:hover {
  opacity: 0.85;
}

/* Hamburger */
.topbar .menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
  transition: color 0.12s, border-color 0.12s;
}
.topbar .menu-btn:hover {
  color: var(--text);
  border-color: var(--border-h);
}
.topbar .menu-btn svg {
  display: block;
}

/* ─── Doc Layout ──────────────────────────────────────────────── */
.doc-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 2rem);
  width: min(100%, var(--layout-max));
  margin: 0 auto;
  padding: 0 clamp(0.75rem, 1.5vw, 1.5rem);
  min-height: calc(100vh - var(--topbar-h));
}

.doc-layout.has-toc {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 260px;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 1.25rem 0;
  position: sticky;
  top: calc(var(--topbar-h) + 0.9rem);
  margin-top: 0.9rem;
  height: calc(100vh - var(--topbar-h) - 1.8rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar nav {
  /* semantic nav wrapper */
}
.sidebar .group {
  margin-bottom: 1.75rem;
}
.sidebar .group-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 1.25rem;
  margin-bottom: 0.35rem;
}
.sidebar a {
  display: block;
  padding: 0.3rem 1.25rem;
  font-size: 0.87rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.sidebar a:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.sidebar a.active {
  color: var(--text);
  font-weight: 500;
  border-left-color: var(--text);
  background: var(--surface);
}
/* Keyboard focus in sidebar */
.sidebar a:focus-visible {
  outline-offset: -2px;
}

/* ─── Content ─────────────────────────────────────────────────── */
.doc-content {
  width: min(100%, var(--content-max));
  min-width: 0;
  margin: 0 auto;
  padding: 2.65rem clamp(1.5rem, 3.2vw, 3.4rem) 4rem;
  position: relative;
  z-index: 1;
}

/* ─── Right Rail TOC ───────────────────────────────────────────── */
.toc {
  display: none;
  align-self: start;
  position: sticky;
  top: calc(var(--topbar-h) + 0.9rem);
  margin-top: 0.9rem;
}

.toc-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 0.9rem 0.9rem 0.7rem;
}

.toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.55rem;
}

.toc-nav a {
  display: block;
  padding: 0.2rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  line-height: 1.4;
}

.toc-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-nav a.active {
  color: var(--text);
  font-weight: 600;
}

.toc-empty {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}
.doc-content h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.3;
}
.doc-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2.75rem 0 0.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.35;
}
.doc-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
}
.doc-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  color: var(--text-2);
  line-height: 1.4;
}
.doc-content p {
  color: var(--text-2);
  margin-bottom: 1rem;
  max-width: 70ch; /* readable line length */
}
.doc-content ul,
.doc-content ol {
  max-width: 72ch;
}
.doc-content pre,
.doc-content .table-wrap,
.doc-content table {
  max-width: none;
}
.doc-content strong {
  color: var(--text);
  font-weight: 600;
}
.lead {
  font-size: 1.05rem;
  color: var(--text-2);
  margin-bottom: 1.5rem;
  line-height: 1.65;
  max-width: 60ch;
}

/* Lists */
.doc-content ul,
.doc-content ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
  color: var(--text-2);
}
.doc-content li {
  margin-bottom: 0.35rem;
}
.doc-content li code {
  font-size: 0.83em;
}

/* ─── Tables ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  background: var(--bg);
}
td code {
  color: var(--green);
  background: none;
  border: none;
  padding: 0;
}

/* ─── Callout ─────────────────────────────────────────────────── */
.callout {
  background: var(--surface);
  border-left: 3px solid var(--border-h);
  padding: 0.85rem 1.1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.5rem 0;
}
.callout p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-2);
  max-width: none;
}
.callout strong {
  color: var(--text);
}

/* ─── Page Navigation ─────────────────────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  font-size: 0.88rem;
  color: var(--text-2);
  text-decoration: none;
}
.page-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}
.page-nav .label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

/* ─── Feature Grid ────────────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.feature {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.feature:hover {
  border-color: var(--border-h);
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.feature:focus-visible {
  outline-offset: 2px;
}
.feature h3 {
  margin: 0 0 0.3rem;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}
.feature p {
  font-size: 0.83rem;
  margin: 0;
  color: var(--muted);
  max-width: none;
}

/* ─── Landing Page ────────────────────────────────────────────── */
.landing {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Hero */
.landing-hero {
  text-align: center;
  padding: 5rem 0 3rem;
}
.landing-hero-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.9rem;
  border-radius: 100px;
  margin-bottom: 1.5rem;
}
.landing-hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 1.25rem;
}
.landing-hero-sub {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto 2rem;
  line-height: 1.65;
}
.landing-hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.cta-secondary {
  display: inline-block;
  padding: 0.65rem 1.75rem;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.cta-secondary:hover {
  border-color: var(--border-h);
  color: var(--text);
  text-decoration: none;
}
.landing-hero-code {
  max-width: 520px;
  margin: 0 auto 0.75rem;
  text-align: left;
  justify-self: center;
}
.landing-hero-code,
.landing-hero-code code {
  font-size: 0.82rem !important;
}
.landing-hero-caption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0;
}

/* Numbers bar */
.landing-numbers {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 2rem 0;
  margin: 1rem 0 2rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.landing-number {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0;
}
.landing-number + .landing-number {
  border-left: 1px solid var(--border);
}
.landing-number-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.landing-number-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

/* Sections */
.landing-section {
  padding: 3rem 0;
  border-bottom: 1px solid var(--border);
}
.landing-section:last-of-type {
  border-bottom: none;
}
.landing-section-header {
  margin-bottom: 2rem;
}
.landing-section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.landing-section-header p {
  color: var(--text-2);
  max-width: 560px;
  line-height: 1.65;
  margin-bottom: 0;
}

/* Principles */
.landing-principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.landing-principle {
  padding: 0;
}
.landing-principle-icon {
  font-size: 1.25rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  line-height: 1;
}
.landing-principle h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.landing-principle p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

/* Honesty / When Not To Use */
.landing-honesty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.landing-honesty-item {
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.landing-honesty-item strong {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
}
.landing-honesty-item p {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  max-width: none;
}

/* Final CTA */
.landing-final {
  text-align: center;
  padding: 4rem 0 3rem;
}
.landing-final h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}
.landing-final pre {
  max-width: 400px;
  margin: 0 auto 1.5rem;
  text-align: left;
}
.landing-final .landing-hero-actions {
  margin-bottom: 0;
}

/* ─── Hero (doc pages — kept for compatibility) ───────────────── */
.hero {
  padding: 4rem 0 2.5rem;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.1;
}
.hero .tagline {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}
.hero .stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.stat {
  text-align: center;
  min-width: 60px;
}
.stat .number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat .label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cta {
  display: inline-block;
  padding: 0.65rem 1.75rem;
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.15s;
}
.cta:hover {
  opacity: 0.85;
  color: var(--bg);
  text-decoration: none;
}
.cta:focus-visible {
  outline-color: var(--focus);
}

/* ─── Footer ──────────────────────────────────────────────────── */
footer {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ─── Platform Tabs ───────────────────────────────────────────── */
/* Tabs for runtime-specific code. Vanilla JS toggles visibility. */
.platform-tabs {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.25rem 0;
  overflow: hidden;
}
.platform-tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.platform-tab-bar button {
  flex: none;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.platform-tab-bar button:hover {
  color: var(--text);
}
.platform-tab-bar button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.platform-tab-bar button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}
.platform-panel {
  display: none;
  padding: 0.85rem 1rem 1rem;
}
.platform-panel[data-active] {
  display: block;
}
.platform-panel pre {
  margin: 0.5rem 0;
}
.platform-panel p {
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}
@media (max-width: 480px) {
  .platform-tab-bar button { padding: 0.45rem 0.75rem; font-size: 0.78rem; }
}

/* ─── Prism Overrides ─────────────────────────────────────────── */
pre[class*="language-"],
code[class*="language-"] {
  background: none;
  text-shadow: none;
}
pre[class*="language-"] {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6b7280;
  font-style: italic;
}
.token.punctuation {
  color: #9ca3af;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
  color: #f59e0b;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
  color: #34d399;
}
.token.operator,
.token.entity,
.token.url {
  color: #9ca3af;
}
.token.atrule,
.token.attr-value,
.token.keyword {
  color: #60a5fa;
}
.token.function,
.token.class-name {
  color: #c084fc;
}
.token.regex,
.token.important,
.token.variable {
  color: #fb923c;
}
.token.tag .token.punctuation {
  color: #9ca3af;
}
.token.tag .token.attr-name {
  color: #60a5fa;
}
.token.tag .token.attr-value {
  color: #34d399;
}
.token.tag .token.tag {
  color: #f87171;
}

@media (prefers-color-scheme: light) {
  .token.comment,
  .token.prolog,
  .token.doctype,
  .token.cdata {
    color: #9ca3af;
  }
  .token.punctuation {
    color: #6b7280;
  }
  .token.property,
  .token.tag,
  .token.boolean,
  .token.number,
  .token.constant,
  .token.symbol {
    color: #d97706;
  }
  .token.selector,
  .token.attr-name,
  .token.string,
  .token.char,
  .token.builtin {
    color: #059669;
  }
  .token.operator,
  .token.entity,
  .token.url {
    color: #6b7280;
  }
  .token.atrule,
  .token.attr-value,
  .token.keyword {
    color: #2563eb;
  }
  .token.function,
  .token.class-name {
    color: #7c3aed;
  }
  .token.regex,
  .token.important,
  .token.variable {
    color: #ea580c;
  }
  .token.tag .token.attr-name {
    color: #2563eb;
  }
  .token.tag .token.attr-value {
    color: #059669;
  }
  .token.tag .token.tag {
    color: #dc2626;
  }
}

/* ─── Responsive: Tablet (≤960px) ─────────────────────────────── */
@media (max-width: 960px) {
  .topbar-cta {
    display: none;
  }
  .topbar-version {
    display: none;
  }
  .doc-layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .doc-layout.has-toc {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .doc-content {
    padding: 2rem 2rem 3rem;
  }
  .sidebar {
    width: 200px;
  }
  .features {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 1200px) {
  .doc-layout.has-toc .toc {
    display: block;
  }
}

/* ─── Responsive: Mobile (≤768px) ─────────────────────────────── */
@media (max-width: 768px) {
  .landing-hero {
    padding: 3rem 0 2rem;
  }
  .landing-principles {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .landing-honesty-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .landing-numbers {
    flex-wrap: wrap;
    gap: 0;
  }
  .landing-number {
    flex: 0 0 50%;
  }
  .landing-number:nth-child(n + 3) {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
  }
  .landing-number:nth-child(2n + 1) {
    border-left: none;
  }
  .topbar {
    padding: 0 0.75rem;
  }
  .topbar .menu-btn {
    display: block;
  }
  .topbar-nav {
    display: none;
  }
  .topbar-actions {
    display: none;
  }
  .topbar-version {
    display: none;
  }

  .sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: 280px;
    height: calc(100vh - var(--topbar-h));
    background: var(--bg);
    border-radius: 0;
    z-index: 40;
    border: none;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
    margin-top: 0;
  }
  .sidebar.open {
    display: block;
  }

  /* Overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }
  .sidebar-overlay.open {
    display: block;
  }

  .doc-layout {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .doc-layout.has-toc {
    grid-template-columns: 1fr;
  }

  .doc-content {
    padding: 1.5rem 1rem 3rem;
    max-width: 100%;
  }

  .toc {
    display: none !important;
  }
  .doc-content h1 {
    font-size: 1.5rem;
  }
  .doc-content h2 {
    font-size: 1.15rem;
  }
  .doc-content p {
    max-width: 100%;
  }

  pre {
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
  }

  .hero {
    padding: 3rem 0 2rem;
  }
  .hero h1 {
    font-size: 2rem;
  }
  .hero .stats {
    gap: 1rem;
  }

  .features {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.82rem;
  }
  th,
  td {
    padding: 0.5rem;
  }

  .page-nav {
    flex-direction: column;
  }
}

/* ─── Responsive: Small Mobile (≤480px) ───────────────────────── */
@media (max-width: 480px) {
  .topbar {
    gap: 0.5rem;
  }
  .topbar a {
    font-size: 0.78rem;
  }
  .doc-content {
    padding: 1rem 0.75rem 2rem;
  }
  pre,
  pre code,
  pre[class*="language-"],
  code[class*="language-"] {
    font-size: 0.73rem !important;
    padding: 0.75rem;
  }
  .hero .stats {
    gap: 0.75rem;
  }
  .stat .number {
    font-size: 1.25rem;
  }
  .landing-hero-code,
  .landing-hero-code code {
    font-size: 0.73rem !important;
  }
}

/* ─── Print ───────────────────────────────────────────────────── */
@media print {
  .topbar,
  .sidebar,
  .page-nav,
  footer {
    display: none;
  }
  .doc-layout {
    display: block;
  }
  .doc-content {
    padding: 0;
    max-width: 100%;
  }
  body {
    background: #fff;
    color: #000;
  }
  a {
    color: #000;
    text-decoration: underline;
  }
  pre {
    border: 1px solid #ccc;
  }
}

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