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

/* Shared keyboard-focus ring for every interactive element site-wide, so
 * no control (sidebar links, the Edit link, theme pills, etc.) falls back
 * to the browser's default outline. Same values as .seg-btn:focus-visible
 * below, which stays as-is since it already matches. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 2px;
}

/* -----------------------------------------------------------------
 * CSS custom property theming
 *
 * --t-bg and --t-fg drive the entire page color scheme.
 * All other colors are derived via color-mix(). When a theme is
 * selected from the pill bar, JS updates these two variables on
 * <body> — and the whole page adapts instantly.
 * ----------------------------------------------------------------- */
body {
  --t-bg: #ffffff;
  --t-fg: #27272a;
  --t-accent: #3b82f6;
  /* Shared muted-text token: kept high enough (85%) that .description
   * clears WCAG AA's 4.5:1 contrast ratio for 16px body text across every
   * bundled theme (see .description below, issue #278). */
  --t-muted: color-mix(in srgb, var(--t-fg) 85%, var(--t-bg));
  --foreground-rgb: 39, 39, 42;
  --accent-rgb: 59, 130, 246;
  --shadow-border-opacity: 0.08;
  --shadow-blur-opacity: 0.06;
  --theme-bar-bg: #f9f9fa; /* Mixed bg for theme bar and top gradient — updated by JS on theme change */

  font-family:
    'Geist',
    system-ui,
    -apple-system,
    sans-serif;
  background: color-mix(in srgb, var(--t-fg) 4%, var(--t-bg));
  color: var(--t-fg);
  line-height: 1.6;
  margin: 0;
  transition:
    background 0.2s,
    color 0.2s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.content-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem;
  padding-top: 0;
}
@media (max-width: 768px) {
  .content-wrapper {
    padding: 1rem;
    padding-top: 0;
  }
}
@media (min-width: 1000px) {
  .content-wrapper {
    padding: 3rem;
    padding-top: 0;
  }
}

/* -----------------------------------------------------------------
 * Page shell: persistent left sidebar (desktop) + main column.
 * On narrow screens the sidebar becomes an off-canvas drawer,
 * toggled by .sidebar-toggle in the theme bar.
 * ----------------------------------------------------------------- */
:root {
  --nav-height: 62px;
  /* Height of the sticky samples-heading bar (theme bar + this stack to
   * occlude the viewport top once both are pinned) — measured and kept
   * live by a ResizeObserver in demo/client.ts, since unlike the theme
   * bar's fixed single row, this one wraps onto two lines on narrow
   * viewports. Defaults to 0 so nothing over-offsets before JS runs. */
  --samples-heading-height: 0px;
}
.page-shell {
  display: flex;
  align-items: flex-start;
}
.page-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* -- Scroll fade gradients (GPU accelerated) -- */
body::before,
body::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  height: 64px;
  pointer-events: none;
  z-index: 1000;
  will-change: transform;
}
body::before {
  top: 0;
  background: linear-gradient(
    to bottom,
    var(--theme-bar-bg) 0%,
    transparent 100%
  );
}
body::after {
  bottom: 0;
  background: linear-gradient(to top, var(--theme-bar-bg) 0%, transparent 100%);
}

/* -- Visually hidden but still exposed to assistive tech — used for the
 * sample search field's real `<label>`, which sighted visitors read via
 * the input's visible placeholder instead. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -- Skip-to-content link --
 * The very first focusable element in the document (see index.ts), so a
 * keyboard-only visitor can jump straight past the theme bar and sidebar
 * to the sample list instead of tabbing through the full nav on every
 * page load. Hidden off-screen until it receives focus. */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0.5rem;
  z-index: 2100;
  padding: 0.6rem 1rem;
  background: var(--t-accent);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus {
  top: 0.5rem;
}

/* -- Scroll progress bar (fixed to the viewport bottom) --
 * Fills as the reader scrolls the whole page. With the samples heading now
 * pinned under the theme bar, a category deep in the list can fill the
 * entire screen with cards and read as "the end" when it isn't — this
 * gives a persistent, content-independent signal of how much is left. */
.scroll-progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
  z-index: 1005;
  pointer-events: none;
}
/* Below 1024px the category-tabbar (further down this file) also pins to
 * the viewport bottom to name the active category — sit just above it
 * instead of underneath, so neither is hidden by the other. */
@media (max-width: 1023px) {
  .scroll-progress {
    /* 53px, not 52: the tabbar's 1px border-top adds to its rendered
     * height beyond its padding box. */
    bottom: calc(53px + env(safe-area-inset-bottom, 0px));
  }
}
.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--t-accent);
}

/* -- Theme selector bar (full-width, sits outside .content-wrapper) -- */
.theme-bar {
  position: sticky;
  top: 0;
  z-index: 1001;
  /* Solid, not transparent: this bar is sticky and must fully obscure
   * sample cards scrolling up underneath it, not just fade them via the
   * gradient below. --theme-bar-bg already tracks the active theme (JS
   * updates it on theme change), so this matches the gradient's own
   * starting color exactly — same look at rest, opaque at any scroll
   * position. */
  background: var(--theme-bar-bg);
  padding: 0.5rem 2rem;
  min-height: var(--nav-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: visible;
}
@media (max-width: 768px) {
  .theme-bar {
    padding: 0.5rem 1rem;
  }
}
.theme-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--t-fg) 35%, var(--t-bg));
  white-space: nowrap;
}
.theme-bar-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}
.theme-pills {
  display: flex;
  gap: 0.3rem;
  overflow: visible;
  padding: 4px;
  margin: -4px;
  position: relative;
  z-index: 2;
}
.theme-pills-inline {
  display: flex;
  gap: 0.3rem;
}
/* Hide inline theme pills on smaller screens, show only "15 Themes" dropdown */
@media (max-width: 1024px) {
  .theme-pills-inline {
    display: none;
  }
}
.theme-pill {
  display: flex;
  align-items: center;
  height: 30px;
  gap: 8px;
  padding: 0 14px 0 12px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-bg) 97%, var(--t-fg));
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s,
    background 0.15s,
    box-shadow 0.2s,
    transform 0.1s;
}
.theme-pill:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.theme-pill.active {
  color: var(--t-fg);
  background: var(--t-bg);
  font-weight: 600;
}
.theme-pill:active {
  transform: translateY(0.5px);
}
.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* -- "More" dropdown for overflow themes -- */
.theme-more-wrapper {
  position: relative;
}
.theme-more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--t-bg);
  border-radius: 12px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  z-index: 1002;
}
.theme-more-dropdown.open {
  display: flex;
}
.theme-more-dropdown .theme-pill {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  box-shadow: none;
}
.theme-more-dropdown .theme-pill:hover {
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
/* Active pill in dropdown gets bg + shadow-minimal (same as inline pills) */
.theme-more-dropdown .theme-pill.active,
.theme-more-dropdown .theme-pill.shadow-tinted {
  background: var(--t-bg);
  box-shadow:
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(var(--foreground-rgb), 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, var(--shadow-blur-opacity)) 0px 1px 1px -0.5px,
    rgba(0, 0, 0, var(--shadow-blur-opacity)) 0px 3px 3px -1.5px;
}

/* -- Brand badge (left-aligned in theme bar) -- */
.brand-badge {
  display: flex;
  align-items: center;
  height: 30px;
  gap: 6px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-bg) 97%, var(--t-fg));
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  font-size: 12px;
  font-weight: 400;
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s,
    box-shadow 0.2s,
    transform 0.1s;
}
.brand-badge:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.brand-badge:active {
  transform: translateY(0.5px);
}

/* -- Sidebar toggle (hamburger, mobile/tablet only — sidebar is always visible ≥1024px) -- */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  height: 30px;
  width: 30px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-bg) 97%, var(--t-fg));
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s,
    transform 0.1s;
}
.sidebar-toggle:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.sidebar-toggle:active {
  transform: translateY(0.5px);
}
.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
@media (max-width: 1023px) {
  .sidebar-toggle {
    display: flex;
  }
}
/* -- Shadow + radius utilities -- */
.rounded-6px {
  border-radius: 6px;
}
.shadow-minimal {
  box-shadow:
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(var(--foreground-rgb), 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, var(--shadow-blur-opacity)) 0px 1px 1px -0.5px,
    rgba(0, 0, 0, var(--shadow-blur-opacity)) 0px 3px 3px -1.5px;
}
.shadow-modal-small {
  box-shadow:
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(var(--foreground-rgb), 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, calc(var(--shadow-blur-opacity) * 0.67)) 0px 1px 1px -0.5px,
    rgba(0, 0, 0, calc(var(--shadow-blur-opacity) * 0.67)) 0px 3px 3px 0px,
    rgba(0, 0, 0, calc(var(--shadow-blur-opacity) * 0.33)) 0px 6px 6px 0px,
    rgba(0, 0, 0, calc(var(--shadow-blur-opacity) * 0.33)) 0px 12px 12px 0px,
    rgba(0, 0, 0, calc(var(--shadow-blur-opacity) * 0.33)) 0px 24px 24px 0px;
}
.shadow-tinted {
  --shadow-color: 0, 0, 0;
  box-shadow:
    rgba(var(--shadow-color), 0) 0px 0px 0px 0px,
    rgba(var(--shadow-color), 0) 0px 0px 0px 0px,
    rgba(var(--shadow-color), calc(var(--shadow-border-opacity) * 1.5)) 0px 0px
      0px 1px,
    rgba(var(--shadow-color), var(--shadow-border-opacity)) 0px 1px 1px -0.5px,
    rgba(var(--shadow-color), var(--shadow-blur-opacity)) 0px 3px 3px -1.5px,
    rgba(var(--shadow-color), calc(var(--shadow-blur-opacity) * 0.67)) 0px 6px
      6px -3px;
}

/* -----------------------------------------------------------------
 * Sidebar navigation — persistent on desktop, off-canvas drawer
 * below 1024px (toggled by .sidebar-toggle in the theme bar).
 * ----------------------------------------------------------------- */
.sidebar {
  flex: 0 0 240px;
  width: 240px;
  position: sticky;
  top: var(--nav-height);
  align-self: flex-start;
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem 2rem;
  box-sizing: border-box;
}
@media (min-width: 1000px) {
  .sidebar {
    padding-left: 3rem;
  }
}
@media (max-width: 1023px) {
  .sidebar-backdrop {
    display: none;
    position: fixed;
    /* Stop below the theme bar, not inset: 0 — otherwise this sits above
       the toggle (z-index 1010 vs. the theme bar's 1001) and intercepts
       taps meant for it, even though the drawer itself no longer does. */
    inset: var(--nav-height) 0 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1010;
  }
  .sidebar-backdrop.open {
    display: block;
  }
  .sidebar {
    display: none;
    position: fixed;
    /* Below the theme bar (not top: 0) so the drawer never covers the
       toggle that opened it — tapping it again still closes the drawer,
       same control either way. */
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    height: calc(100vh - var(--nav-height));
    width: min(300px, 85vw);
    background: var(--t-bg);
    z-index: 1011;
    padding: 1.5rem 1.5rem 2rem;
    box-shadow: rgba(0, 0, 0, 0.15) 4px 0 24px 0;
  }
  .sidebar.open {
    display: block;
  }
}
/* -- Sidebar search — filters samples by title, category, and description
 * client-side (see demo/client.ts's "Sample search / filter" section).
 * Nothing here re-renders; the sidebar list and sample cards just toggle
 * their `hidden` attribute in response to the query. */
.sidebar-search {
  margin-bottom: 1rem;
}
.sidebar-search-field {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search-icon {
  position: absolute;
  left: 0.6rem;
  width: 14px;
  height: 14px;
  color: color-mix(in srgb, var(--t-fg) 40%, var(--t-bg));
  pointer-events: none;
}
.sidebar-search-input {
  width: 100%;
  padding: 0.45rem 1.9rem;
  border: 1px solid color-mix(in srgb, var(--t-fg) 12%, var(--t-bg));
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-fg) 3%, var(--t-bg));
  color: var(--t-fg);
  font: inherit;
  font-size: 0.8rem;
}
.sidebar-search-input::placeholder {
  color: color-mix(in srgb, var(--t-fg) 45%, var(--t-bg));
}
/* WebKit's own cancel-button affordance is redundant with — and styled
 * inconsistently from — the cross-browser .sidebar-search-clear button
 * below, so hide it and keep one clear control everywhere. */
.sidebar-search-input::-webkit-search-cancel-button {
  display: none;
}
.sidebar-search-clear {
  position: absolute;
  right: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.sidebar-search-clear:hover {
  background: color-mix(in srgb, var(--t-fg) 10%, var(--t-bg));
  color: var(--t-fg);
}
.sidebar-search-clear[hidden] {
  display: none;
}
/* Both a visible status line and an aria-live region — sighted visitors
 * see the result count under the field, screen readers hear it announced
 * as it changes (see aria-live on the element in index.ts). */
.sidebar-search-status {
  margin-top: 0.35rem;
  min-height: 1em;
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--t-fg) 55%, var(--t-bg));
}
/* -- "No results" empty state, shown in place of the (all-hidden) category
 * views while a search matches nothing. -- */
.search-empty {
  padding: 2rem 0;
  color: color-mix(in srgb, var(--t-fg) 55%, var(--t-bg));
  font-size: 0.9rem;
}
/* The category banner and mobile tabbar both name a single active
 * category, which doesn't apply while search results span categories —
 * hide both for the duration. */
body.search-active .category-banner {
  display: none;
}
body.search-active .category-tabbar {
  display: none;
}

.sidebar-group {
  border-bottom: 1px solid color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
  padding: 0.6rem 0;
}
.sidebar-group:first-of-type {
  padding-top: 0;
}
.sidebar-group > summary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--t-fg);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-group > summary::-webkit-details-marker {
  display: none;
}
.sidebar-group > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent
    color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
  transition: transform 0.15s;
  flex-shrink: 0;
}
.sidebar-group[open] > summary::before {
  transform: rotate(90deg);
}
.sidebar-group-count {
  font-weight: 400;
  color: color-mix(in srgb, var(--t-fg) 40%, var(--t-bg));
}
.sidebar-list {
  padding: 0;
  margin: 0.5rem 0 0;
  list-style: none;
  font-size: 0.8rem;
}
/* No white-space: nowrap is set on this list, so titles wrap onto
 * multiple lines rather than truncating to one — text-overflow: ellipsis
 * needs nowrap to do anything, so it was never actually active here.
 * overflow: hidden was therefore dead weight for truncation, but it did
 * clip the shared :focus-visible ring (see a:focus-visible above) on
 * these links down to a ~2px sliver. Dropped both properties rather than
 * kept for a "just in case" truncation that isn't wired up (zombie-mermaid#325). */
.sidebar-list li {
  margin-bottom: 0.3rem;
}
.sidebar-list a {
  color: color-mix(in srgb, var(--t-fg) 85%, var(--t-bg));
  text-decoration: none;
}
.sidebar-list a:hover {
  color: var(--t-fg);
  text-decoration: underline;
}
/* Tracks whichever sample is currently under the sticky nav bar — set by
 * the scroll spy in demo/client.ts, the same signal that drives the URL
 * hash. */
.sidebar-list a.active {
  color: var(--t-accent);
  font-weight: 600;
}
.sidebar-list a.active .sidebar-num {
  color: var(--t-accent);
}
.sidebar-num {
  color: color-mix(in srgb, var(--t-fg) 30%, var(--t-bg));
}

/* -- Sample card -- */
.sample {
  background: var(--t-bg);
  margin-bottom: 2rem;
  overflow: hidden;
  /* Both the theme bar and the sticky samples-heading bar sit above any
   * scrolled-to sample and must be cleared, or scrollIntoView lands it
   * partly hidden underneath them. */
  scroll-margin-top: calc(
    var(--nav-height) + var(--samples-heading-height) + 1rem
  );
}

/* -- Hero sample: before/after transform showcase, above Samples heading --
 * Raw Mermaid source (left/top) becomes the live-rendered, theme-reactive
 * diagram (right/bottom) — row layout on desktop, stacked on mobile so
 * neither side ever gets scaled down to illegible text. */
.sample-hero {
  margin-bottom: 0;
  background: transparent;
}
.hero-transform {
  display: flex;
  align-items: stretch;
  gap: 1.75rem;
  padding: 0.5rem 0 2.5rem;
}
@media (max-width: 768px) {
  .hero-transform {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0 2rem;
  }
}

/* "Before": fixed dark terminal, independent of the theme picker — same
 * rationale as .ascii-panel above: raw source text doesn't retheme itself. */
.hero-code-panel {
  flex: 1 1 0;
  min-width: 0;
  background: #0d1117;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (max-width: 768px) {
  .hero-code-panel {
    flex: none;
    width: 100%;
  }
}
.hero-code-titlebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.875rem;
  background: #161b22;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.hero-code-dots {
  display: flex;
  gap: 0.4rem;
}
.hero-code-dots .dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
}
.hero-code-dots .dot-red {
  background: #ff5f56;
}
.hero-code-dots .dot-yellow {
  background: #ffbd2e;
}
.hero-code-dots .dot-green {
  background: #27c93f;
}
.hero-code-title {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #7d8590;
  margin-left: 0.25rem;
}
.hero-code-body {
  padding: 1.1rem 1.25rem;
  font-size: 0.8rem;
  line-height: 1.85;
  overflow-x: auto;
}
.hero-code-body pre {
  background: transparent !important;
  font-family:
    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
  white-space: pre;
}
/* Same generic-monospace-fallback issue as .ascii-output above: Shiki wraps
 * highlighted code in <pre><code>, and the UA stylesheet's `code { font-family:
 * monospace }` rule matches that <code> directly, beating the font-family
 * inherited from .hero-code-body pre. */
.hero-code-body pre code {
  font-family: inherit;
}

/* "Renders as" arrow */
.hero-arrow {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 0.25rem;
}
@media (max-width: 768px) {
  .hero-arrow {
    flex-direction: row-reverse;
    padding: 0.25rem 0;
  }
}
.hero-arrow-caption {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--t-fg) 45%, var(--t-bg));
  white-space: nowrap;
}
.hero-arrow-icon {
  width: 3.5rem;
  height: 3.5rem;
}
@media (max-width: 768px) {
  .hero-arrow-icon {
    width: 2rem;
    height: 2rem;
    transform: rotate(90deg);
  }
}
@keyframes hero-arrow-dash {
  to {
    stroke-dashoffset: -16;
  }
}
.hero-arrow-dash {
  stroke-dasharray: 4 4;
  animation: hero-arrow-dash 0.9s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .hero-arrow-dash {
    animation: none;
  }
}

/* "After": the live-rendered, theme-reactive diagram. Background is the
 * plain --t-bg variable (no per-element JS sync needed — client.ts's
 * "skip hero panels" branch leaves this alone, and it repaints on its own
 * whenever the theme picker updates --t-bg on <body>). */
.hero-diagram-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: var(--t-bg);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--t-fg) 6%, transparent),
    0 8px 24px rgba(0, 0, 0, 0.06);
  padding: 1.75rem;
}
@media (max-width: 768px) {
  .hero-diagram-panel {
    flex: none;
    width: 100%;
    padding: 1.375rem 1.125rem;
  }
}
.hero-diagram-panel .svg-container {
  width: 100%;
  max-width: 26rem;
}
.hero-diagram-panel .svg-container svg {
  width: 100%;
  height: auto;
}
.hero-tag-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}
.hero-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--t-accent) 12%, var(--t-bg));
  color: var(--t-accent);
}
.hero-tag-brand {
  background: color-mix(in srgb, #9570be 14%, var(--t-bg));
  color: #9570be;
}

.sample-header {
  padding: 1.25rem 1.5rem;
  max-width: 48rem;
  border-bottom: 1px solid color-mix(in srgb, var(--t-fg) 5%, var(--t-bg));
}
.sample-header h2 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--t-fg);
}
.description {
  color: var(--t-muted);
  font-size: 1rem;
  font-weight: 400;
  margin-top: 0.1rem;
}
.description code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.875em;
  color: color-mix(in srgb, var(--t-fg) 85%, var(--t-bg));
  background: color-mix(in srgb, var(--t-fg) 6%, var(--t-bg));
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

/* A narrow source rail plus one output pane (SVG/ASCII share it via the
 * segmented toggle below) — not three columns splitting width three ways.
 * `align-items: start` (rather than the grid default `stretch`) means each
 * column sizes to its own content and the row height tracks whichever
 * output view is actually showing, so switching to ASCII on a tall diagram
 * grows the card instead of stretching the short source rail to match. */
.sample-content {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  align-items: start;
  min-height: 420px;
}
@media (max-width: 900px) {
  .sample-content {
    grid-template-columns: 1fr;
  }
  .output-panel {
    border-left: none !important;
    border-top: 1px solid color-mix(in srgb, var(--t-fg) 5%, var(--t-bg)) !important;
  }
}

/* -- Source panel -- */
.source-panel {
  position: relative;
  /* Bottom padding reserves room for the absolutely-positioned .edit-btn
   * below, so wrapped source text that fills the scrollable area doesn't
   * render underneath it (see issue #403). max() with the button's fixed
   * 44px + 0.75rem footprint keeps that true even at a smaller root font
   * size, where a plain rem value would shrink below the button's height. */
  padding: 0.75rem 1.5rem max(3.75rem, calc(44px + 0.75rem));
  border-right: 1px solid color-mix(in srgb, var(--t-fg) 5%, var(--t-bg));
  min-width: 0; /* grid child: allow shrinking below content width */
  overflow-y: auto;
}
.source-panel h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: color-mix(in srgb, var(--t-fg) 35%, var(--t-bg));
  margin-bottom: 0.75rem;
}
.source-panel pre {
  padding: 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.source-panel code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* -- Shiki syntax highlighting overrides --
 * Shiki outputs inline style="color:#hex" per token. We override these with
 * color-mix() rules derived from --t-fg / --t-bg so tokens adapt to any theme.
 * The hex values below are from the github-light Shiki theme used at build time. */
.source-panel {
  background: color-mix(in srgb, var(--t-fg) 1.5%, var(--t-bg));
}
.source-panel .shiki {
  background: transparent !important;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.source-panel .shiki code {
  background: transparent;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}
/* Default text */
.source-panel .shiki,
.source-panel .shiki span[style*='#24292e'],
.source-panel .shiki span[style*='#24292E'] {
  color: color-mix(in srgb, var(--t-fg) 70%, var(--t-bg)) !important;
}
/* Keywords: graph, subgraph, end, participant, -->, classDef, brackets */
.source-panel .shiki span[style*='#D73A49'],
.source-panel .shiki span[style*='#d73a49'] {
  color: color-mix(in srgb, var(--t-fg) 90%, var(--t-bg)) !important;
  font-weight: 500;
}
/* Direction labels, subgraph names */
.source-panel .shiki span[style*='#6F42C1'],
.source-panel .shiki span[style*='#6f42c1'] {
  color: color-mix(in srgb, var(--t-fg) 65%, var(--t-bg)) !important;
}
/* Node IDs */
.source-panel .shiki span[style*='#E36209'],
.source-panel .shiki span[style*='#e36209'] {
  color: color-mix(in srgb, var(--t-fg) 75%, var(--t-bg)) !important;
}
/* Strings, labels, message text */
.source-panel .shiki span[style*='#032F62'],
.source-panel .shiki span[style*='#032f62'] {
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg)) !important;
}
.options {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
}
.options code {
  background: color-mix(in srgb, var(--t-fg) 6%, var(--t-bg));
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

/* -- Edit button (small bordered button, bottom-left of source panel) --
 * Was styled as faint tertiary text (color-mix 35%), which measured well
 * under the 4.5:1 AA minimum on every bundled theme (see issue #279).
 * Promoted to a bordered button so it reads as interactive without relying
 * on text color alone; text color-mix bumped to 80%, matching .theme-pill.
 * min-height/min-width plus flex centering (rather than sizing to the
 * "Edit" text content alone) bring the tap target up to the 44px
 * comfortable minimum from WCAG 2.5.5/2.5.8 — it measured 29x16px before
 * (see issue #285). */
.edit-btn {
  position: absolute;
  bottom: 0.75rem;
  left: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--t-fg) 6%, var(--t-bg));
  border: 1px solid color-mix(in srgb, var(--t-fg) 20%, var(--t-bg));
  border-radius: 6px;
  padding: 0.3rem 1rem;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  cursor: pointer;
  text-decoration: none;
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
}
.edit-btn:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-fg) 10%, var(--t-bg));
  border-color: color-mix(in srgb, var(--t-fg) 30%, var(--t-bg));
}
.edit-btn:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 2px;
}

/* -- Edit dialog overlay -- */
.edit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}
.edit-overlay.open {
  display: flex;
}
.edit-dialog {
  background: var(--t-bg);
  border-radius: 16px;
  width: min(680px, calc(100vw - 3rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.edit-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
}
.edit-dialog-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--t-fg);
}
.edit-dialog-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: color-mix(in srgb, var(--t-fg) 40%, var(--t-bg));
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.edit-dialog-close:hover {
  color: var(--t-fg);
}
.edit-dialog-textarea {
  flex: 1;
  min-height: 300px;
  max-height: 60vh;
  margin: 0;
  padding: 1rem 1.25rem;
  border: none;
  outline: none;
  resize: none;
  background: color-mix(in srgb, var(--t-fg) 2%, var(--t-bg));
  color: var(--t-fg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre;
  tab-size: 2;
}
.edit-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
}
.edit-dialog-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.edit-dialog-btn:hover {
  opacity: 0.85;
}
.edit-dialog-cancel {
  background: color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
  color: var(--t-fg);
}
.edit-dialog-save {
  background: var(--t-fg);
  color: var(--t-bg);
}

/* -- Output panel --
 * Holds the SVG/ASCII segmented toggle plus both views. Only one view is
 * ever visible (`.is-active`) — the inactive one is `display: none`, not
 * just hidden, so it doesn't factor into the row's height and switching
 * views doesn't leave a phantom gap behind the shorter one. */
.output-panel {
  padding: 1.25rem 1.5rem;
  border-left: 1px solid color-mix(in srgb, var(--t-fg) 5%, var(--t-bg));
  display: flex;
  flex-direction: column;
  min-width: 0; /* grid child: allow shrinking below content width */
}
.output-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.seg {
  display: inline-flex;
  padding: 0.2rem;
  background: color-mix(in srgb, var(--t-fg) 4%, var(--t-bg));
  border: 1px solid color-mix(in srgb, var(--t-fg) 10%, var(--t-bg));
  border-radius: 8px;
}
.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--t-fg) 55%, var(--t-bg));
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn:hover {
  color: var(--t-fg);
}
.seg-btn:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 2px;
}
.seg-btn[aria-selected='true'] {
  background: var(--t-bg);
  color: var(--t-fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
/* Narrow viewports: raise the tap target to the 44px comfortable minimum
 * (measured 49x31px on a 375px viewport — see issue #285). Same breakpoint
 * the orientation-swap feature already uses, so the segmented toggle only
 * grows where the desktop layout has no room pressure to justify it. */
@media (max-width: 640px) {
  .seg-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
  }
}
.output-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* -- SVG panel -- */
.svg-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  /* Background set dynamically: matches the SVG --bg in default mode,
     or the global theme bg when a theme is active. */
}
.svg-panel.is-active {
  display: flex;
  flex: 1;
}
.svg-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0; /* flex child: allow shrinking to fit */
}
.svg-container svg {
  max-width: 100%;
  max-height: 100%; /* scale down to fit both axes */
  height: auto;
}

/* A wide (LR/RL) flowchart or state diagram renders two variants — its own
 * orientation plus a TD alternate for narrow viewports (see
 * wideDiagramDirectionLine in demo/client.ts). `display: contents` makes
 * the non-shown wrapper's own box disappear so it doesn't interfere with
 * .svg-container's flex centering; only one variant's <svg> ever actually
 * participates in layout at a time. Samples without an alternate render a
 * single <svg> directly and never get this wrapper at all. */
.orientation-variant {
  display: none;
}
.orientation-variant.orientation-wide {
  display: contents;
}
@media (max-width: 640px) {
  .orientation-variant.orientation-wide {
    display: none;
  }
  .orientation-variant.orientation-narrow {
    display: contents;
  }
}

/* -- ASCII panel --
 * Styled as a terminal window: fixed dark palette + titlebar chrome,
 * independent of the page's theme picker (see TERMINAL_PALETTE in
 * demo/client.ts) — real terminal output doesn't retheme itself. */
.ascii-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
}
.ascii-panel.is-active {
  display: flex;
  flex: 1;
}
/* When ASCII is the active view, the whole chain drops to plain block
 * layout instead of the flex sizing above: block boxes always size to
 * their content, so a diagram taller than the panel grows the card
 * (`.ascii-output` below loses its `overflow: auto` scrollbar) rather than
 * being squeezed into a fixed-height box. Scoped to `.ascii-active`, set by
 * the toggle handler in demo/client.ts, so the SVG view keeps the flex
 * fill-available-height behavior above (there, the stage should still
 * center a small diagram in whatever room the row has). */
.output-panel.ascii-active .output-stage,
.output-panel.ascii-active .ascii-panel.is-active,
.output-panel.ascii-active .terminal-window {
  display: block;
  flex: none;
  min-height: 0;
  overflow: visible;
}
.output-panel.ascii-active .ascii-output {
  display: block;
  flex: none;
  min-height: 0;
  /* Horizontal only: a wide diagram scrolls within the card instead of
     spilling past its right edge. Vertical stays unconstrained so the card
     still grows to fit tall diagrams, per the comment above. */
  overflow-x: auto;
  overflow-y: visible;
}
.terminal-window {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* flex child: allow shrinking to fit */
  background: #0d1117;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: #161b22;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.terminal-dots {
  display: flex;
  gap: 0.4rem;
}
.terminal-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
}
.terminal-dot-red {
  background: #ff5f56;
}
.terminal-dot-yellow {
  background: #ffbd2e;
}
.terminal-dot-green {
  background: #27c93f;
}
.terminal-title {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #7d8590;
  margin-left: 0.25rem;
}
.ascii-output {
  padding: 1rem;
  font-size: 0.7rem;
  line-height: 1.3;
  overflow: auto; /* fallback for a context with no .ascii-active override (e.g. print styles);
     the ASCII view is the .output-panel.ascii-active case above in practice, which renders
     at natural height with no scrollbar instead */
  white-space: pre;
  flex: 1;
  min-height: 0;
  max-width: 100%;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #e6edf3; /* fallback for glyphs the renderer leaves uncolored */
  background: transparent;
  scrollbar-color: #30363d transparent;
}
/* The Chromium UA stylesheet sets `code { font-family: monospace }` directly
 * on the <code> child, which beats the font-family inherited from .ascii-output
 * above (a rule matching the element itself always wins over an inherited
 * value, regardless of specificity) — so without this, the ASCII art renders
 * in the browser's generic monospace fallback instead of JetBrains Mono. */
.ascii-output code {
  font-family: inherit;
}
.ascii-output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.ascii-output::-webkit-scrollbar-track {
  background: transparent;
}
.ascii-output::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 5px;
}
.terminal-cursor {
  display: inline-block;
  width: 0.55em;
  margin-left: 1px;
  background: #e6edf3;
  animation: terminal-blink 1s step-end infinite;
}
@media (prefers-reduced-motion: reduce) {
  .terminal-cursor {
    animation: none;
  }
}
@keyframes terminal-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* -- Loading spinner -- */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid color-mix(in srgb, var(--t-fg) 12%, var(--t-bg));
  border-top-color: color-mix(in srgb, var(--t-fg) 35%, var(--t-bg));
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -- Timing badge -- */
.timing {
  font-size: 0.7rem;
  font-weight: 400;
  color: color-mix(in srgb, var(--t-fg) 30%, var(--t-bg));
  margin-left: 0.5rem;
  text-transform: none;
  letter-spacing: normal;
}

/* -- Error state -- */
.render-error {
  color: #ef4444;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* -- Hero header section -- */
.hero-header {
  max-width: 1440px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
  text-align: left;
}
@media (min-width: 1000px) {
  .hero-header {
    padding: 6rem 3rem 2rem;
  }
}
.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 0.25rem;
  color: var(--t-fg);
}
.hero-tagline {
  font-size: 1rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
  margin: 0 0 1rem;
}
.hero-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: color-mix(in srgb, var(--t-fg) 70%, var(--t-bg));
  margin: 0 0 1.5rem;
  max-width: 680px;
}
.hero-description a {
  color: var(--t-fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hero-description a:hover {
  color: var(--t-accent);
}
.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
@media (max-width: 768px) {
  .hero-buttons {
    flex-direction: column;
  }
}
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: 12px;
  text-decoration: none;
  transition:
    opacity 0.15s,
    transform 0.1s;
  cursor: pointer;
  border: none;
  margin: 0;
  box-sizing: border-box;
  font-family: inherit;
}
.hero-btn:hover {
  opacity: 0.9;
}
.hero-btn:active {
  transform: translateY(0.5px);
}
.hero-btn-primary {
  background: var(--t-fg);
  color: var(--t-bg);
  box-shadow:
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0.1) 0px 1px 3px 0px,
    rgba(0, 0, 0, 0.1) 0px 1px 2px -1px;
}
.hero-btn-secondary {
  background: var(--t-bg);
  color: var(--t-fg);
  box-shadow:
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(0, 0, 0, 0) 0px 0px 0px 0px,
    rgba(var(--foreground-rgb), 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, 0.1) 0px 1px 3px 0px,
    rgba(0, 0, 0, 0.1) 0px 1px 2px -1px;
}
.hero-btn svg {
  width: 16px;
  height: 16px;
}
.hero-description code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* -- Hero meta (below buttons) -- */
.hero-meta {
  margin-top: 1.25rem;
}
.hero-meta .meta {
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--t-fg) 40%, var(--t-bg));
  margin: 0.15rem 0;
  /* Matches `.sample`'s scroll-margin-top so a line like #total-timing
   * clears the sticky theme bar (and, once stuck, the samples-heading
   * bar) instead of rendering underneath them if it's ever scrolled or
   * focused to directly, rather than only as part of a page-top load. */
  scroll-margin-top: calc(
    var(--nav-height) + var(--samples-heading-height) + 1rem
  );
}

.hero-meta .meta a {
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hero-meta .meta a:hover {
  color: var(--t-fg);
}

/* -- Section title -- */
.section-title {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
  padding: 2.5rem 0 1.5rem;
  color: var(--t-fg);
}

/* -----------------------------------------------------------------
 * Category banner — tells the visitor the sample list below is
 * filtered to one diagram type, and gives an explicit way to reach
 * the sidebar's other categories (important on mobile, where the
 * sidebar itself is hidden behind the hamburger toggle).
 * ----------------------------------------------------------------- */
.samples-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 2.5rem;
  padding: 1rem 0;
  /* Pinned directly under the theme bar (same offset the sidebar sticks
   * at) so the active category and its "Browse diagram types" escape
   * hatch stay reachable while scrolling through a long sample list.
   * `margin-top` (not padding) carries the gap from the hero cards above
   * it, since padding would stay part of the sticky box permanently and
   * pad out the bar itself even once pinned. The solid background reuses
   * body's own color-mix formula so sample cards scrolling underneath
   * don't show through; the border gives the pinned bar a visible edge
   * against them. */
  position: sticky;
  top: var(--nav-height);
  z-index: 5;
  background: color-mix(in srgb, var(--t-fg) 4%, var(--t-bg));
  border-bottom: 1px solid color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
}
.samples-heading .section-title {
  padding: 0;
}
.category-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--t-fg) 65%, var(--t-bg));
}
.category-banner strong {
  color: var(--t-fg);
}
.category-banner-btn {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-bg) 97%, var(--t-fg));
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s,
    background 0.15s;
}
.category-banner-btn:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.category-view {
  display: block;
}
.category-view[hidden] {
  display: none;
}

/* -----------------------------------------------------------------
 * Category tabbar — names the active category and gives an escape hatch
 * to the others, persistently, on the screens where the sidebar (which
 * shows the same info) is hidden behind the hamburger. Complements the
 * scroll-progress line above rather than replacing it: that tracks raw
 * scroll position, this tracks category identity.
 * ----------------------------------------------------------------- */
.category-tabbar {
  display: none;
}
@media (max-width: 1023px) {
  .category-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1005;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--t-bg) 92%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-top: 1px solid color-mix(in srgb, var(--t-fg) 10%, var(--t-bg));
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  }
  /* Reserve space so the fixed bar never permanently covers the last bit
     of content or the footer. Scoped to :has(#category-tabbar) rather than
     a bare `body` since this stylesheet is also inlined into fork-fixes.html,
     which has no tabbar and shouldn't gain the extra bottom padding. */
  body:has(#category-tabbar) {
    padding-bottom: calc(53px + env(safe-area-inset-bottom, 0px));
  }
}
.category-tabbar-label {
  font-size: 0.8rem;
  color: color-mix(in srgb, var(--t-fg) 55%, var(--t-bg));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-tabbar-label strong {
  color: var(--t-fg);
  font-weight: 600;
}
#tabbar-browse-btn {
  flex-shrink: 0;
  gap: 0.35rem;
  background: var(--t-accent);
  color: #fff;
}
#tabbar-browse-btn:hover {
  background: color-mix(in srgb, var(--t-accent) 88%, black);
  color: #fff;
}
#tabbar-browse-btn svg {
  width: 14px;
  height: 14px;
}

/* Highlight the sidebar category currently shown in the main column —
   distinct from a plain expanded/collapsed <details> state. */
.sidebar-group[open] > summary {
  color: var(--t-accent);
}
.sidebar-group[open] > summary::before {
  border-left-color: var(--t-accent);
}
/* Brief attention pulse when "Browse diagram types" points at the
   (already-visible, desktop) sidebar. */
@keyframes sidebar-attention-pulse {
  0%,
  100% {
    box-shadow: none;
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-accent) 40%, transparent);
  }
}
.sidebar.attention {
  animation: sidebar-attention-pulse 0.6s ease-in-out 2;
  border-radius: 12px;
}

/* -- Footer -- */
.site-footer {
  position: relative;
  z-index: 10;
  padding: 1.5rem 2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  font-size: 12px;
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
}
@media (min-width: 1000px) {
  .site-footer {
    padding: 1.5rem 3rem 2rem;
  }
}
.footer-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.footer-links a {
  color: color-mix(in srgb, var(--t-fg) 50%, var(--t-bg));
  text-decoration: none;
  transition: color 0.15s;
}
.footer-links a:hover {
  color: var(--t-fg);
}
.footer-links svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

/*
 * Terminal column semantics for ASCII panels.
 *
 * A wide (CJK/fullwidth/emoji) glyph is exactly two columns in a terminal,
 * which is the rule the ASCII renderer's box math is built on. A browser gives
 * it the substitute font's advance instead — about 1.66x the Latin advance
 * here, since JetBrains Mono has no CJK coverage — so box borders drift out of
 * alignment. demo/client.ts wraps each wide grapheme cluster in this class,
 * setting an inline width to the column count the renderer allocated for it;
 * that restores the geometry the diagram was laid out for. The 2ch here is the
 * single-glyph default for the common case, and a floor if the inline style
 * ever fails to apply.
 */
.ascii-wide {
  display: inline-block;
  width: 2ch;
  /* The substitute glyph is narrower than its cell; centring it keeps the text
     from bunching against the left of the span. */
  text-align: center;
}

/**
 * Stylesheet for the per-diagram-type/per-theme SEO landing pages generated
 * by pages.ts (see /diagrams/<type>/<theme>.html).
 *
 * A separate, much smaller stylesheet from demo/styles.css rather than a
 * reuse of it: styles.css is built for the single interactive gallery page
 * (theme picker, sidebar, edit dialog, segmented SVG/ASCII toggle — all of
 * it JS-driven), none of which these static pages have. This file shares
 * the same brand tokens (fonts, accent colors) for visual consistency, but
 * stays plain, unminified CSS with no JS dependency, and is linked once as
 * an external file (not inlined per page) so a visitor's second page load
 * comes from cache instead of re-downloading the same rules 90 times over.
 */

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 2px;
}

body {
  --t-bg: #ffffff;
  --t-fg: #27272a;
  --t-accent: #3b82f6;
  --t-brand: #9570be;
  --t-muted: color-mix(in srgb, var(--t-fg) 55%, var(--t-bg));
  --t-border: color-mix(in srgb, var(--t-fg) 12%, var(--t-bg));

  font-family:
    'Geist',
    system-ui,
    -apple-system,
    sans-serif;
  background: color-mix(in srgb, var(--t-fg) 4%, var(--t-bg));
  color: var(--t-fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* demo/styles.css defines body::before/::after as scroll-fade gradients
 * whose sole purpose is to blend content scrolling underneath the
 * interactive gallery's *sticky* theme bar (see that file's own comment) --
 * this page has no theme bar (its sticky header is the shared Nav, not
 * styles.css's theme-bar), and its dark background lives on the `.dc-root`
 * wrapper below <body>, not on <body> itself, so these fixed/viewport-pinned
 * pseudo-elements just render as a stray band at the default --theme-bar-bg
 * (#f9f9fa, meant to track a theme this fixed-dark page never switches)
 * pinned over the top and bottom edges regardless of scroll position.
 * Suppress them outright rather than recoloring, since they serve no
 * purpose without a theme bar to blend into.
 */
body::before,
body::after {
  content: none;
}

.page-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

/* -- Header -- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0 1.5rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--t-fg);
  font-weight: 600;
  font-size: 0.95rem;
}

.brand-badge:hover {
  color: var(--t-accent);
}

.header-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
}

.header-links a {
  color: var(--t-muted);
  text-decoration: none;
}

.header-links a:hover {
  color: var(--t-accent);
}

/* -- Breadcrumb -- */
.breadcrumb {
  font-size: 0.8125rem;
  color: var(--t-muted);
  margin-bottom: 1.25rem;
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--t-accent);
}

.breadcrumb .sep {
  margin: 0 0.4rem;
  opacity: 0.6;
}

/* -- Page heading -- */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.lede {
  font-size: 1.0625rem;
  color: var(--t-muted);
  max-width: 68ch;
  margin-bottom: 2rem;
}

.lede code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--t-fg) 8%, var(--t-bg));
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* -- Diagram + source layout: source on the left, diagram on the right -- */
.diagram-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.source-column {
  flex: 1 1 40%;
  min-width: 0;
}

.diagram-column {
  flex: 1 1 55%;
  min-width: 0;
}

@media (max-width: 720px) {
  .diagram-layout {
    flex-direction: column;
  }
}

/* -- Diagram panel -- */
.diagram-frame {
  border: 1px solid var(--t-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.diagram-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

/* A short caption, not a section — the theme is a color choice, not the
   page's topic, so it shouldn't compete with the diagram-type content for
   attention via its own heading. */
.theme-caption {
  font-size: 0.875rem;
  color: var(--t-muted);
  margin-bottom: 1.5rem;
}

.theme-caption strong {
  color: var(--t-fg);
  font-weight: 600;
}

/* -- Source panel -- */
.source-heading {
  /* Matches .section h2's weight — this is the page's actual type-specific
     content and shouldn't read as a subordinate label next to the
     theme/navigation sections below it. */
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.source-panel {
  border: 1px solid var(--t-border);
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 0;
}

.source-panel pre {
  margin: 0;
  padding: 1rem 1.25rem;
}

.source-panel code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
}

/* -- Prose sections -- */
.section {
  margin-bottom: 2rem;
}

.section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.section p {
  color: var(--t-muted);
  max-width: 68ch;
}

/* -- Cross-link grids -- */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.link-grid a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--t-border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--t-fg);
  font-size: 0.875rem;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.link-grid a:hover {
  border-color: var(--t-accent);
  color: var(--t-accent);
}

.link-grid a.is-current {
  border-color: var(--t-brand);
  color: var(--t-brand);
  font-weight: 600;
}

.swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* -- CTA row -- */
.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--t-border);
  color: var(--t-fg);
}

.cta-btn.primary {
  background: linear-gradient(135deg, var(--t-brand), var(--t-accent));
  color: #fff;
  border-color: transparent;
}

.cta-btn:not(.primary):hover {
  border-color: var(--t-accent);
  color: var(--t-accent);
}

/* -- Footer -- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--t-border);
  font-size: 0.8125rem;
  color: var(--t-muted);
}

.site-footer a {
  color: inherit;
}

/* -- Index/hub page -- */
.type-group {
  margin-bottom: 2rem;
}

.type-group h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.type-group .type-intro {
  color: var(--t-muted);
  font-size: 0.9375rem;
  max-width: 68ch;
  margin-bottom: 0.75rem;
}
