/* -- Site layout styles ------------------------------------ */
/* Nav, sidebar, preview box, code blocks, swatches, etc.    */

/* Prevent horizontal overflow on mobile */
html { overflow-x: clip; }

/* -- Scroll offset for fixed header + sticky page header ----
   --anchor-pad is published at runtime by layout.js (updateAnchorPad):
   .page-header is `position: sticky` pinned right under the fixed site
   header, so the true clearance = site header + page header + breathing
   room, which only the browser can measure (content-dependent height).
   The 4rem fallback covers pre-JS and pages without a .page-header. */
html { scroll-padding-top: var(--anchor-pad, 4rem); }
/* The shipped typography .h1–.h4 carry scroll-margin-top for consumer apps;
   on the docs page the measured --anchor-pad already provides the clearance,
   so the extra scroll-margin would stack and leave a gap above the heading. */
main .h1, main .h2, main .h3, main .h4 { scroll-margin-top: 0; }

/* -- Site header ------------------------------------------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 3.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  background: oklch(from var(--background) l c h / 0.88);
  backdrop-filter: blur(14px);
}

/* -- Header brand (logo + version) ------------------------- */
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}
.header-brand-name {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--foreground);
  white-space: nowrap;
}
.header-brand-version {
  white-space: nowrap;
}
.header-brand-logo {
  width: auto;
  height: 32px;
}

/* -- Site sidebar ------------------------------------------ */
.site-sidebar {
  width: 14rem; flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  position: sticky; top: 3.5rem;
  height: calc(100vh - 3.5rem);
  background: var(--sidebar);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem 0.75rem;
}
/* -- Nav section heading (a <summary> of a collapsible group; the docs
   dogfood the sidebar component's .sidebar-group collapse pattern) ----- */
.nav-heading {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  /* sidebar-scoped token: section headings sit on --sidebar; --primary is
     only paired against --background and fails on most theme presets */
  color: var(--sidebar-foreground);
  padding: 0.25rem 0.75rem;
  margin: 0 0 0.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: var(--radius-md);
  transition: color 120ms;
}
.nav-heading::-webkit-details-marker { display: none; }
.nav-heading:hover { color: var(--sidebar-accent-foreground); }
.nav-heading svg {
  width: 0.875rem; height: 0.875rem;
  margin-left: auto;
  flex-shrink: 0;
  transition: rotate 200ms ease;
}
details[open] > .nav-heading svg { rotate: 90deg; }
/* collapsed: tighten the group so the sidebar shrinks to just headings */
details.nav-section:not([open]) { margin-bottom: 0.25rem !important; }
@media (prefers-reduced-motion: reduce) {
  .nav-heading, .nav-heading svg { transition: none; }
}

/* -- Header action button / link --------------------------- */
.header-action {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 150ms, background 150ms;
}
.header-action:hover {
  color: var(--foreground);
  background: var(--accent);
}
.theme-toggle-btn {
  width: 2.25rem; height: 2.25rem;
  padding: 0; justify-content: center;
  border: 1px solid var(--border);
  color: var(--foreground);
}

/* -- Wide mode (header toggle, html.wide) -------------------
   Each doc page caps <main> with an inline max-width for readable
   prose; the toggle (see layout.js #wide-toggle) releases the cap so
   wide layouts — the marketing blocks — render unconstrained. Only
   !important can override an inline style, and this is its single
   intentional home. */
html.wide main {
  max-width: none !important;
}

/* -- SPA view transition for main content ------------------ */
main {
  view-transition-name: main-content;
}

/* Old page fades out, new page fades in — subtle crossfade */
::view-transition-old(main-content) {
  animation: vt-fade-out 150ms ease-out both;
}
::view-transition-new(main-content) {
  animation: vt-fade-in 150ms ease-in 50ms both;
}

/* Keep header/sidebar stable — instant swap, no animation */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

@keyframes vt-fade-out {
  to { opacity: 0; }
}
@keyframes vt-fade-in {
  from { opacity: 0; }
}

/* -- Nav link ---------------------------------------------- */
.nav-link {
  display: block;
  padding: 0.3125rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  /* sidebar-scoped tokens: the nav sits on --sidebar, so its text must be
     paired with --sidebar, not with the page-level muted/primary/accent
     tokens (theme authors pair those against --background only) */
  color: var(--sidebar-foreground);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  transition: all 120ms;
  line-height: 1.6;
}
.nav-link:hover { color: var(--sidebar-foreground); background: var(--sidebar-accent); }
.nav-link.active { color: var(--sidebar-accent-foreground); font-weight: 500; background: var(--sidebar-accent); }
.nav-link.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* -- Header search (nav filter) ----------------------------- */
/* The sidebar's filter input lives in the header next to the version badge;
   its filtering logic binds in <site-nav>. */
.header-search {
  flex: 0 1 16rem;
  min-width: 0;
}
.header-search .header-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  background: var(--sidebar);
  color: var(--foreground);
  outline: none;
  /* trigger, not a field: it opens the command palette on focus/click */
  cursor: text;
  text-overflow: ellipsis;
}
.header-search-input:hover {
  border-color: var(--muted-foreground);
}
.header-search-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(from var(--ring) l c h / 0.18);
}
.header-search-input::placeholder {
  color: var(--muted-foreground);
  opacity: 0.65;
}

/* -- Component type badges ---------------------------------
   Atomic-design taxonomy (ATM/MOL/ORG/BLK/TPL) shown in the sidebar
   (replacing the old generic PREVIEW marker) and on each component doc
   page. Colors follow the taxonomy spec: one identity per type, dark
   variant for the dark scheme (forced-colors falls back to system ink). */
.type-badge {
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  padding: 0.125rem 0.375rem;
  border: 1px solid;
  border-radius: var(--radius-sm);
  background: transparent;
  flex-shrink: 0;
  line-height: 1.4;
}
.type-badge[data-type="ATM"] { color: #06B6D4; border-color: color-mix(in oklch, #06B6D4 40%, transparent); }
.type-badge[data-type="MOL"] { color: #3B82F6; border-color: color-mix(in oklch, #3B82F6 40%, transparent); }
.type-badge[data-type="ORG"] { color: #8B5CF6; border-color: color-mix(in oklch, #8B5CF6 40%, transparent); }
.type-badge[data-type="BLK"] { color: #F59E0B; border-color: color-mix(in oklch, #F59E0B 40%, transparent); }
.type-badge[data-type="TPL"] { color: #64748B; border-color: color-mix(in oklch, #64748B 40%, transparent); }
html.dark .type-badge[data-type="ATM"] { color: #22D3EE; border-color: color-mix(in oklch, #22D3EE 40%, transparent); }
html.dark .type-badge[data-type="MOL"] { color: #60A5FA; border-color: color-mix(in oklch, #60A5FA 40%, transparent); }
html.dark .type-badge[data-type="ORG"] { color: #A78BFA; border-color: color-mix(in oklch, #A78BFA 40%, transparent); }
html.dark .type-badge[data-type="BLK"] { color: #FBBF24; border-color: color-mix(in oklch, #FBBF24 40%, transparent); }
html.dark .type-badge[data-type="TPL"] { color: #94A3B8; border-color: color-mix(in oklch, #94A3B8 40%, transparent); }
@media (forced-colors: active) {
  .type-badge { color: CanvasText; border-color: CanvasText; }
}
/* Doc page title badge: sits right after the component name, on the heading's
   baseline (baseline-aligned inline-block keeps its border box on the text line). */
.page-header h1 .type-badge {
  display: inline-block;
  margin-inline-start: 0.5rem;
  vertical-align: baseline;
}
/* Sidebar keeps the right-aligned slot the old PREVIEW marker had. */
.nav-link .type-badge { margin-left: auto; }
/* Palette rows use flex space-between already; nudge badge off the label. */
.command-item .type-badge { margin-inline-start: auto; }

/* -- Built-with pills -------------------------------------- */
a.built-with-pill {
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
a.built-with-pill:hover {
  background: var(--accent);
  border-color: var(--foreground);
}

/* -- Details chevron rotation ------------------------------ */
details[open] > summary svg:first-child {
  transform: rotate(90deg);
}

/* -- Architecture page (ARCH.md render, see scripts/lib/arch-page.ts) ---
   Same typographic scale the spec modal uses for markdown — one prose
   style, two hosts. */
.arch-prose { font-size: 0.9375rem; line-height: 1.85; }
.arch-prose h2 { font-family: var(--font-display); font-size: 1.375rem; font-weight: 400; letter-spacing: -0.02em; margin: 2.5rem 0 0.875rem; }
.arch-prose h3 { font-size: 1.0625rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
.arch-prose p { margin: 0 0 1rem; color: var(--muted-foreground); }
.arch-prose ul { margin: 0 0 1rem; padding-left: 1.5rem; list-style: disc; color: var(--muted-foreground); }
.arch-prose ol { margin: 0 0 1rem; padding-left: 1.5rem; list-style: decimal; color: var(--muted-foreground); }
.arch-prose li { margin-bottom: 0.375rem; }
.arch-prose li > strong:first-child { color: var(--foreground); }
.arch-prose code { font-family: var(--font-mono); font-size: 0.8125em; background: var(--muted); padding: 0.125em 0.375em; border-radius: var(--radius-sm); }
.arch-prose pre { background: var(--muted); border-radius: var(--radius-lg); padding: 1rem; margin: 0.5rem 0 1.25rem; overflow-x: auto; }
.arch-prose pre code { background: none; padding: 0; font-size: 0.8125rem; }
.arch-prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.arch-prose table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1.25rem; font-size: 0.8125rem; }
.arch-prose th, .arch-prose td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.arch-prose th { font-weight: 600; background: var(--muted); }

/* -- Component Skill link -----------------------------------
   The `[data-spec-href]` span lives inside the skill `<summary>` — clicking it
   (or anywhere in the summary) toggles the <details> natively. No JS, no modal. */
[data-spec-href] { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted-foreground); }

/* -- Preview box ------------------------------------------- */
.preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  min-height: 11rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.875rem;
  padding: 2.5rem 1.5rem;
  background-color: var(--background);
  background-image:
    radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  position: relative;
}

/* -- Code block -------------------------------------------- */
pre {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.8;
}
code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--muted);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
pre code { background: none; padding: 0; border: none; font-size: inherit; }

/* -- Shiki dual-theme: light default, dark via html.dark --- */
pre.shiki {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  overflow: hidden;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.8;
}
/* Nested pre inside a card/container — remove its own border/radius/bg */
pre.shiki[style*="border-radius:0"],
div[style*="overflow:hidden"] > pre.shiki,
div[style*="overflow:hidden"] > div > pre.shiki {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}
pre.shiki code {
  white-space: pre-wrap;
  word-break: break-all;
}
pre.shiki,
pre.shiki span {
  color: var(--shiki-light) !important;
  background-color: transparent !important;
}
html.dark pre.shiki,
html.dark pre.shiki span {
  color: var(--shiki-dark) !important;
  background-color: transparent !important;
}
.dim { color: var(--muted-foreground); }

/* -- Doc tabs (preview/pattern/html switcher) -------------- */
.tab-list {
  display: inline-flex;
  background: var(--muted);
  border-radius: var(--radius-md);
  padding: 0.2rem;
  gap: 0.125rem;
  margin-bottom: 1rem;
}
.tab-btn {
  padding: 0.3rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 150ms;
  line-height: 1.6;
}
.tab-btn[aria-selected="true"] {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 4px oklch(0 0 0 / 0.08), 0 0 0 1px var(--border);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* -- Token swatch ------------------------------------------ */
.swatch-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 0;
  overflow: hidden;
}

/* -- Copy button ------------------------------------------- */
.copy-btn {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--background);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 150ms;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.copy-btn:hover { color: var(--foreground); }

/* -- API pill links (Web Platform APIs in spec details) ---- */
.api-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--foreground);
  text-decoration: none;
  transition: background 150ms;
}
.api-pill:hover { background: var(--accent); }
.api-pill code { font-size: inherit; background: none; border: none; padding: 0; }
.api-pill svg { width: 10px; height: 10px; opacity: 0.4; flex-shrink: 0; }

/* -- Code collapse toggle ---------------------------------- */
.code-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: fit-content;
  margin-left: auto;
  margin-top: 0.25rem;
  padding: 0 0.375rem;
  height: 1.5rem;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  background: transparent;
  color: var(--muted-foreground);
  border: none;
  cursor: pointer;
  transition: color 150ms;
}
.code-toggle-btn:hover { color: var(--foreground); }

.code-block-wrapper.code-collapsed { display: none; }

/* -- Collapse-all toolbar ---------------------------------- */
.code-collapse-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}
.code-collapse-all-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0 0.625rem;
  height: 1.875rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: transparent;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 150ms, background 150ms;
}
.code-collapse-all-btn:hover {
  color: var(--foreground);
  background: var(--accent);
}

/* -- Sticky page header ------------------------------------ */
.page-header {
  position: sticky;
  top: 3.5rem;
  z-index: 10;
  background: var(--background);
  padding: 1rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.page-header > details {
  margin-bottom: 0 !important;
}
.page-header > :last-child {
  margin-bottom: 0 !important;
}

/* -- Theme selector popover -------------------------------- */
.theme-popover {
  position: fixed;
  inset: unset;
  top: 3.5rem;
  right: 0.75rem;
  width: 20rem;
  max-height: calc(100vh - 4.5rem);
  overflow-y: auto;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-lg);
}
.theme-popover::backdrop {
  background: transparent;
}
.theme-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}
.theme-popover-title {
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--foreground);
}
.theme-reset-btn {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 150ms, background 150ms;
}
.theme-reset-btn:hover {
  color: var(--foreground);
  background: var(--accent);
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375rem;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: border-color 150ms, background 150ms;
  color: var(--foreground);
  width: 100%;
}
.theme-swatch:hover {
  border-color: var(--foreground);
}
.theme-swatch.active {
  border-color: var(--primary);
  background: var(--accent);
}
.theme-swatch-label {
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.theme-swatch-colors {
  display: flex;
  gap: 0.25rem;
}
.theme-swatch-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid oklch(0 0 0 / 0.12);
  flex-shrink: 0;
}

/* -- Separator --------------------------------------------- */
.sep {
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* -- GitHub star count in header --------------------------- */
.github-stars {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--muted);
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-width: 1.25rem;
  text-align: center;
}
.github-stars:empty { display: none; }

/* -- Site footer ------------------------------------------- */
.site-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  border-top: 1px solid var(--border);
}
.site-footer p { margin: 0; }
.site-footer-tagline {
  font-style: italic;
  margin: 0 0 0.25rem !important;
  color: var(--foreground);
  opacity: 0.7;
}
.site-footer a {
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--muted-foreground);
  transition: text-decoration-color 150ms;
}
.site-footer a:hover { text-decoration-color: var(--foreground); }
.site-footer-dot { color: var(--border); }

/* -- Table of contents (right sidebar) --------------------- */
.site-toc {
  width: 12rem;
  flex-shrink: 0;
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0;
}
.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground);
  margin: 0 0 0.5rem;
  padding: 0 0.5rem;
}
.toc-link {
  display: block;
  padding: 0.1875rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 150ms, border-color 150ms;
  line-height: 1.6;
}
/* § permalink before every TOC-listed heading (injected by layout.js buildToc) */
.heading-anchor {
  color: var(--muted-foreground);
  text-decoration: none;
  margin-right: 0.375rem;
  font-weight: 400;
}
.heading-anchor:hover { color: var(--primary); text-decoration: underline; }
.toc-link:hover { color: var(--foreground); }
.toc-link.active {
  color: var(--foreground);
  border-left-color: var(--primary);
}

/* Hide TOC on narrow screens */
@media (max-width: 72rem) {
  .site-toc { display: none; }
}

/* -- Mobile responsive ------------------------------------- */

/* Hamburger menu button (hidden on desktop) */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  flex-shrink: 0;
}

/* Sidebar overlay backdrop (hidden on desktop) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: 3.5rem;
  z-index: 39;
  background: oklch(0 0 0 / 0.4);
}

@media (max-width: 48rem) {
  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  /* Sidebar: off-canvas overlay on mobile */
  .site-sidebar {
    position: fixed;
    top: 3.5rem;
    left: 0;
    z-index: 40;
    width: 16rem;
    height: calc(100vh - 3.5rem);
    transform: translateX(-100%);
    transition: transform 250ms ease;
    box-shadow: var(--shadow-lg);
  }
  .site-sidebar.open {
    transform: translateX(0);
  }

  /* Show backdrop when sidebar open */
  .sidebar-backdrop.open {
    display: block;
  }

  /* Reduce main padding on mobile */
  main {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Search shrinks hard on small screens but stays usable */
  .header-search {
    flex: 1 1 auto;
    min-width: 4rem;
  }

  /* Reduce header padding */
  .site-header {
    padding: 0 0.75rem;
    gap: 0.375rem;
  }

  /* Stack brand name + version vertically, shrink */
  .header-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
  }
  .header-brand-name {
    font-size: 0.9375rem;
    line-height: 1.2;
  }
  .header-brand-version {
    font-size: 0.5625rem;
    padding: 0 0.25rem;
    line-height: 1.4;
  }

  /* Shrink header action buttons on mobile */
  .header-action.theme-toggle-btn {
    width: 2rem;
    height: 2rem;
  }
  .header-action.theme-toggle-btn svg {
    width: 13px;
    height: 13px;
  }

  /* Preview boxes: allow wrapping, reduce padding */
  .preview {
    padding: 1.5rem 1rem;
    gap: 0.625rem;
  }

  /* Code blocks: reduce padding, smaller font */
  pre, pre.shiki {
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
  }

  /* Page nav: single column on mobile */
  .page-nav {
    grid-template-columns: 1fr;
  }

  /* Sticky page header: reduce top offset for mobile */
  .page-header {
    padding: 0.75rem 0;
  }

  /* Hide "GitHub" text, keep icon */
  .header-action .github-label {
    display: none;
  }

  /* Theme popover: wider on mobile */
  .theme-popover {
    right: 0.25rem;
    width: calc(100vw - 0.5rem);
    max-width: 20rem;
  }

  /* Swatch rows */
  .swatch-row {
    flex-wrap: wrap;
  }

}

@media (max-width: 48rem) and (prefers-reduced-motion: reduce) {
  .site-sidebar {
    transition: none;
  }
}

/* -- Prev / Next page navigation --------------------------- */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.page-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: var(--foreground);
  transition: border-color 150ms, background 150ms;
}
.page-nav-link:hover {
  border-color: var(--foreground);
  background: var(--accent);
}
.page-nav-link svg {
  flex-shrink: 0;
  color: var(--muted-foreground);
}
.page-nav-prev { justify-content: flex-start; }
.page-nav-next { justify-content: flex-end; text-align: right; }
.page-nav-label {
  display: block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  margin-bottom: 0.125rem;
}
.page-nav-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
}


