/* ==========================================================================
   Kryon OS — Material Design 3
   A from-scratch implementation of the M3 system.

   Everything is derived from the distro's own ANSI palette via M3 tonal
   roles. Colour is never written directly in a component; components only
   reference role tokens (--md-*), which is what makes a single seed able to
   restyle the whole page.

   Contents
     1  Tokens: tones, roles, shape, elevation, motion, type
     2  Baseline and reset
     3  Typography
     4  Layout primitives
     5  Top app bar
     6  Navigation bar and rail
     7  Buttons
     8  Cards
     9  Chips, badges, lists
     10  Callouts
     11  Tables
     12  Code
     13  Timeline
     14  Footer
     15  Motion, print, forced colours
   ========================================================================== */

/* ==========================================================================
   1  TOKENS
   ========================================================================== */
:root {
  color-scheme: dark;

  /* ---- Brand seeds: the exact ANSI values from branding/ ---- */
  --seed-cyan:   #8fd3f4;   /* SGR 96  — bright cyan */
  --seed-yellow: #ffda00;   /* SGR 93  — bright yellow */
  --seed-blue:   #1793d1;   /* PRETTY_NAME 38;2;23;147;209 */
  --seed-grey:   #8a8a8a;   /* SGR 90  — dim grey */
  --seed-bg:     #005db9;   /* SGR 46  — dark cyan */

  /* ---- Colour roles: dark scheme ---- */
  --md-primary:                     #8fd3f4;
  --md-on-primary:                  #00344a;
  --md-primary-container:           #1d4e64;
  --md-on-primary-container:        #bee9ff;
  --md-inverse-primary:             #00658a;

  --md-secondary:                   #e8c400;
  --md-on-secondary:                #3a2f00;
  --md-secondary-container:         #564500;
  --md-on-secondary-container:      #ffe066;

  --md-tertiary:                    #6fc3ef;
  --md-on-tertiary:                 #00344e;
  --md-tertiary-container:          #004b69;
  --md-on-tertiary-container:       #a8dcff;

  --md-error:                       #ffb4ab;
  --md-on-error:                    #690005;
  --md-error-container:             #93000a;
  --md-on-error-container:          #ffdad6;

  --md-success:                     #7ddba0;
  --md-success-container:           #00522f;
  --md-on-success-container:        #99f7bf;

  --md-surface:                     #0b1016;
  --md-on-surface:                  #dfe3e7;
  --md-surface-variant:             #3f4850;
  --md-on-surface-variant:          #bfc8d0;
  --md-surface-container-lowest:    #05090d;
  --md-surface-container-low:       #131a20;
  --md-surface-container:           #171e24;
  --md-surface-container-high:      #22282e;
  --md-surface-container-highest:   #2c333a;
  --md-inverse-surface:             #dfe3e7;
  --md-inverse-on-surface:          #1b2126;
  --md-outline:                     #89939b;
  --md-outline-variant:             #3f4850;
  --md-scrim:                       #000000;

  /* ---- State layer opacities (M3 spec) ---- */
  --md-state-hover:   0.08;
  --md-state-focus:   0.10;
  --md-state-press:   0.10;
  --md-state-drag:    0.16;

  /* ---- Shape scale ---- */
  --md-shape-none:   0;
  --md-shape-xs:     4px;
  --md-shape-sm:     8px;
  --md-shape-md:     12px;
  --md-shape-lg:     16px;
  --md-shape-xl:     28px;
  --md-shape-xxl:    28px;
  --md-shape-full:   9999px;

  /* ---- Elevation ---- */
  --md-elev-0: none;
  --md-elev-1: 0 1px 2px rgb(0 0 0 / .30), 0 1px 3px 1px rgb(0 0 0 / .15);
  --md-elev-2: 0 1px 2px rgb(0 0 0 / .30), 0 2px 6px 2px rgb(0 0 0 / .15);
  --md-elev-3: 0 1px 3px rgb(0 0 0 / .30), 0 4px 8px 3px rgb(0 0 0 / .15);
  --md-elev-4: 0 2px 3px rgb(0 0 0 / .30), 0 6px 10px 4px rgb(0 0 0 / .15);

  /* ---- Motion ---- */
  --md-ease-standard:   cubic-bezier(.2, 0, 0, 1);
  --md-ease-emphasized: cubic-bezier(.2, 0, 0, 1);
  --md-ease-decelerate: cubic-bezier(.05, .7, .1, 1);
  --md-ease-accelerate: cubic-bezier(.3, 0, .8, .15);
  --md-dur-short:  100ms;
  --md-dur-medium: 250ms;
  --md-dur-long:  400ms;

  /* ---- Type ---- */
  --md-font: Roboto, "Helvetica Neue", system-ui, -apple-system, "Segoe UI", sans-serif;
  --md-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ---- Metrics ---- */
  /* Rail (88) + gap (32) + content. Sized so four-up card grids still fit and
   the content column lands near a comfortable measure. */
--md-content-max: 1160px;
  --md-gutter: 24px;
  --md-app-bar-h: 64px;
  --md-nav-bar-h: 80px;
}

/* Light scheme overrides the same role names, so components need no light-specific rules. */
:root[data-theme="light"] {
  color-scheme: light;

  --md-primary:                #00658a;
  --md-on-primary:             #ffffff;
  --md-primary-container:      #c7e7ff;
  --md-on-primary-container:   #001e2c;
  --md-inverse-primary:        #8fd3f4;

  --md-secondary:              #6b5d00;
  --md-on-secondary:           #ffffff;
  --md-secondary-container:    #ffde6b;
  --md-on-secondary-container: #201b00;

  --md-tertiary:               #004b69;
  --md-on-tertiary:            #ffffff;
  --md-tertiary-container:     #a8dcff;
  --md-on-tertiary-container:  #001e2f;

  --md-error:                  #ba1a1a;
  --md-on-error:               #ffffff;
  --md-error-container:        #ffdad6;
  --md-on-error-container:     #410002;

  --md-success:                #146c2e;
  --md-success-container:      #a6f2b8;
  --md-on-success-container:   #00210a;

  --md-surface:                     #f9fafb;
  --md-on-surface:                  #191c1e;
  --md-surface-variant:             #dfe3e6;
  --md-on-surface-variant:          #3f484b;
  --md-surface-container-lowest:    #ffffff;
  --md-surface-container-low:       #f3f5f7;
  --md-surface-container:           #eceff1;
  --md-surface-container-high:      #e5e8ea;
  --md-surface-container-highest:   #dfe3e6;
  --md-inverse-surface:             #2e3134;
  --md-inverse-on-surface:          #eff1f3;
  --md-outline:                     #6f797d;
  --md-outline-variant:             #bfc8cc;
}

/* ==========================================================================
   2  BASELINE AND RESET
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--md-app-bar-h) + 16px);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-family: var(--md-font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .0071em;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

::selection { background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* ---- Focus: M3 shows focus with the container colour, not an outline ---- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--md-primary);
  outline-offset: 2px;
}

/* ---- State layer primitive ----
   Every interactive surface opts in with .state and gets an 8/10/16%
   currentColor overlay on hover/focus/press. */
.state { position: relative; isolation: isolate; }
.state::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-dur-short) linear;
  z-index: -1;
}
.state:hover::before  { opacity: var(--md-state-hover); }
.state:focus-visible::before { opacity: var(--md-state-focus); }
.state:active::before { opacity: var(--md-state-press); }

/* A theme swap must not animate: body recolours instantly while every other
   role snaps, so animating them would render new text on the old background. */
.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: none !important;
}

/* ==========================================================================
   3  TYPOGRAPHY  (M3 type scale)
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--md-on-surface);
  font-family: var(--md-font);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

/* Display small */
h1 {
  font-size: clamp(1.875rem, 1.25rem + 2.4vw, 3rem);
  line-height: 1.15;
  letter-spacing: -.0156em;
}

/* Headline small — section headings */
h2 {
  font-size: 1.5rem;
  letter-spacing: 0;
  margin: 72px 0 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--md-outline-variant);
}

/* Title large */
h3 {
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: 0;
  margin: 32px 0 8px;
}

/* Title medium */
h4 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .0098em;
  margin: 24px 0 8px;
}

p { margin: 0 0 16px; }

strong { font-weight: 500; color: var(--md-on-surface); }

/* Overline — small, tracked, uppercase */
.overline {
  margin: 0 0 8px;
  color: var(--md-primary);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.lede {
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--md-on-surface-variant);
  max-width: 60ch;
}

.body-small {
  font-size: .875rem;
  line-height: 1.43;
  color: var(--md-on-surface-variant);
}

hr {
  height: 1px;
  border: none;
  background: var(--md-outline-variant);
  margin: 56px 0;
}

ul, ol { margin: 0 0 16px; padding-left: 24px; }
li { margin-bottom: 8px; }
li::marker { color: var(--md-primary); }

/* ==========================================================================
   4  LAYOUT
   ========================================================================== */
/* The shell is the rail plus the content column. The rail is part of the
   measured width, so the content stays centred against the page rather than
   being pushed right by a rail parked outside the max-width. */
.shell {
  display: flex;
  flex: 1;
  gap: 32px;
  width: 100%;
  max-width: var(--md-content-max);
  margin: 0 auto;
  padding: 40px var(--md-gutter) 96px;
}

main { flex: 1; min-width: 0; }

@media (max-width: 904px) {
  .shell { padding: 24px var(--md-gutter) 128px; }
}

/* Tracks are sized so common card counts land on full rows: four-up at
   desktop, two-up at tablet. A 300px floor forced 3 + 1 and left an orphan
   card alone in a half-empty row. */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin: 24px 0;
}

/* Two-up: paired comparisons, and anything holding a table. */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }

/* Four-up: short one-paragraph cards. */
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.stack   { display: flex; flex-direction: column; gap: 16px; }
.row     { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ==========================================================================
   5  TOP APP BAR
   ========================================================================== */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--md-surface);
  color: var(--md-on-surface);
  transition: background-color var(--md-dur-medium) var(--md-ease-standard),
              box-shadow var(--md-dur-medium) var(--md-ease-standard);
}
/* M3 elevates the app bar once content scrolls beneath it. */
.app-bar[data-elevated="true"] {
  background: var(--md-surface-container);
  box-shadow: var(--md-elev-2);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: var(--md-content-max);
  height: var(--md-app-bar-h);
  margin: 0 auto;
  padding: 0 var(--md-gutter);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px 6px 4px;
  border-radius: var(--md-shape-full);
  color: var(--md-on-surface);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  text-decoration: none;
}
/* The app bar carries an icon + title, as M3 apps do. The full wordmark is
   reserved for the hero: at app-bar size the letterforms are too fine to read. */
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--md-shape-sm);
  flex: none;
}

.app-bar-spacer { flex: 1; }
.app-bar-actions { display: flex; align-items: center; gap: 8px; }

/* One navigation pattern at a time. When JS runs it builds the rail (medium+)
   or the navigation bar (compact), so the app-bar destinations are redundant
   and hidden. Without JS they remain visible as the fallback. */
.js .nav-links { display: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}
.nav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--md-shape-full);
  color: var(--md-on-surface-variant);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .0179em;
  text-decoration: none;
  isolation: isolate;
}
.nav-links a::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-dur-short) linear;
  z-index: -1;
}
.nav-links a:hover { color: var(--md-on-surface); text-decoration: none; }
.nav-links a:hover::before { opacity: var(--md-state-hover); }
.nav-links a[aria-current="page"] {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.nav-links a[aria-current="page"]::before { opacity: 0; }

/* Icon button */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--md-shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
}
.icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.icon-button:hover { color: var(--md-on-surface); }

/* ==========================================================================
   6  NAVIGATION BAR (compact)
   ========================================================================== */
.nav-bar { display: none; }

/* Navigation rail — medium and up. */
@media (min-width: 905px) {
  .nav-rail {
    position: sticky;
    top: var(--md-app-bar-h);
    flex: none;
    width: 88px;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
  }
  .nav-rail a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 2px;
    border-radius: var(--md-shape-md);
    color: var(--md-on-surface-variant);
    font-size: .6875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    isolation: isolate;
  }
  .nav-rail a::before {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
  }
  .nav-rail a:hover { color: var(--md-on-surface); text-decoration: none; }
  .nav-rail a:hover::before { opacity: var(--md-state-hover); }
  .nav-rail .nav-indicator {
    display: grid;
    place-items: center;
    width: 56px;
    height: 32px;
    border-radius: var(--md-shape-full);
    flex: none;
    transition: background-color var(--md-dur-medium) var(--md-ease-standard);
  }
  .nav-rail .nav-indicator svg { width: 20px; height: 20px; fill: currentColor; }
  .nav-rail a[aria-current="page"] { color: var(--md-on-surface); }
  .nav-rail a[aria-current="page"] .nav-indicator {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
  }
}

@media (max-width: 904px) {
  /* Compact: a navigation bar pinned to the bottom. */
  .nav-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    gap: 4px;
    min-height: var(--md-nav-bar-h);
    padding: 12px 8px calc(12px + env(safe-area-inset-bottom));
    background: var(--md-surface-container);
    box-shadow: var(--md-elev-2);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .nav-bar::-webkit-scrollbar { display: none; }

  .nav-bar a {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 72px;
    padding: 4px;
    border-radius: var(--md-shape-md);
    color: var(--md-on-surface-variant);
    font-size: .6875rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    isolation: isolate;
  }
  .nav-bar a::before {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
  }
  .nav-bar a:hover { text-decoration: none; }
  .nav-bar a:hover::before { opacity: var(--md-state-hover); }
  .nav-bar .nav-indicator {
    display: grid;
    place-items: center;
    width: 64px;
    height: 32px;
    border-radius: var(--md-shape-full);
    flex: none;
  }
  .nav-bar .nav-indicator svg { width: 20px; height: 20px; fill: currentColor; }
  .nav-bar a[aria-current="page"] { color: var(--md-on-surface); }
  .nav-bar a[aria-current="page"] .nav-indicator {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
  }

  /* Compact replaces the rail with a navigation bar, so the rail is dropped. */
  .nav-rail { display: none !important; }
  .nav-links { display: none; }
}

/* ==========================================================================
   7  BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border: none;
  border-radius: var(--md-shape-full);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .0179em;
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  transition: border-radius var(--md-dur-medium) var(--md-ease-standard);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-dur-short) linear;
  z-index: -1;
}
.btn:hover { text-decoration: none; }
.btn:hover::before { opacity: var(--md-state-hover); }
.btn:focus-visible::before { opacity: var(--md-state-focus); }
.btn:active::before { opacity: var(--md-state-press); }
/* M3 presses round the corners back toward the shape scale. */
.btn:active { border-radius: var(--md-shape-sm); }

.btn-filled    { background: var(--md-primary); color: var(--md-on-primary); }
.btn-tonal     { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-elevated  { background: var(--md-surface-container-low); color: var(--md-primary); box-shadow: var(--md-elev-1); }
.btn-outlined  { background: transparent; color: var(--md-primary); border: 1px solid var(--md-outline); }
.btn-text      { background: transparent; color: var(--md-primary); padding: 0 12px; }
.btn-error     { background: var(--md-error); color: var(--md-on-error); }

.btn .icon { width: 18px; height: 18px; fill: currentColor; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0; }

/* ==========================================================================
   8  CARDS
   ========================================================================== */
.card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid transparent;
  border-radius: var(--md-shape-lg);
  background: var(--md-surface-container-low);
  color: var(--md-on-surface);
  transition: background-color var(--md-dur-medium) var(--md-ease-standard),
              box-shadow var(--md-dur-medium) var(--md-ease-standard),
              border-color var(--md-dur-medium) var(--md-ease-standard);
}
.card h3, .card h4 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card a { font-weight: 500; }

.card-elevated  { box-shadow: var(--md-elev-1); }
.card-elevated:hover { box-shadow: var(--md-elev-3); }
.card-filled    { background: var(--md-surface-container-highest); }
.card-outlined  { background: transparent; border-color: var(--md-outline-variant); }
.card:hover     { background: var(--md-surface-container); }

/* Hero: a large shape-xl surface */
.hero {
  position: relative;
  overflow: hidden;
  padding: 40px;
  margin-bottom: 16px;
  border-radius: var(--md-shape-xl);
  /* The wash lives on the element itself so the hover circle is a sibling
     layer above it, rather than a pseudo-element painting on top. */
  background:
    linear-gradient(115deg,
      color-mix(in srgb, var(--seed-bg) 30%, transparent) 0%,
      transparent 58%),
    var(--md-surface-container-low);
}

/* The hover circle. A large soft disc that tracks the pointer, revealed on
   hover. JS writes --mx/--my in pixels; the 50% default centres it before the
   first move, and on devices with no pointer it simply stays hidden. */
.hero-spot {
  position: absolute;
  z-index: 0;
  top: var(--my, 50%);
  left: var(--mx, 50%);
  width: 520px;
  height: 520px;
  translate: -50% -50%;
  border-radius: var(--md-shape-full);
  pointer-events: none;
  opacity: 0;
  scale: 0.82;
  background: radial-gradient(circle at center,
    color-mix(in srgb, var(--seed-cyan) 34%, transparent) 0%,
    color-mix(in srgb, var(--seed-cyan) 20%, transparent) 38%,
    color-mix(in srgb, var(--seed-blue) 12%, transparent) 58%,
    transparent 72%);
  /* A faint rim so the disc reads as a circle rather than a smudge. */
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--seed-cyan) 22%, transparent);
  transition: opacity var(--md-dur-long) var(--md-ease-standard),
              scale var(--md-dur-long) var(--md-ease-emphasized);
}
.hero:hover .hero-spot { opacity: 1; scale: 1; }

/* No hover means no trigger, so the circle simply stays at its hidden default
   on touch. Forcing it visible there parked a permanent arc across the text. */

/* Only the content columns are lifted. A blanket `.hero > *` would also
   retarget the spot, flipping it from absolute to relative and turning it into
   a grid item that shoved the text into the second column. */
.hero-body, .hero-mark { position: relative; z-index: 1; }
.hero h1 { margin: 8px 0 16px; }

/* Two columns: text left, mark right. A single left-aligned column left
   roughly half the hero empty, which read as a layout mistake. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 40px;
  align-items: center;
}
.hero-body { min-width: 0; }

/* The wordmark is the hero's visual anchor, so the headline sits below it in
   scale rather than fighting it. At the page-title size it wrapped to six
   lines in this column. */
.hero h1 {
  font-size: clamp(1.5rem, 1rem + 1.7vw, 2.5rem);
}

.hero-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.hero-mark img {
  width: 100%;
  height: auto;
}

@media (max-width: 904px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  /* Mark first on compact, so the identity leads. */
  .hero-mark { order: -1; }
}

/* ==========================================================================
   9  CHIPS, BADGES, LISTS
   ========================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--md-shape-sm);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  font-family: var(--md-font-mono);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .02em;
  white-space: nowrap;
}
/* Assist chips carry a leading dot instead of a checkmark. */
.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--md-shape-full);
  background: currentColor;
  flex: none;
}
.chip-primary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.chip-warn    { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.chip-error   { background: var(--md-error-container); color: var(--md-on-error-container); }
.chip-success { background: var(--md-success-container); color: var(--md-on-success-container); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--md-shape-full);
  background: var(--md-error);
  color: var(--md-on-error);
  font-size: .6875rem;
  font-weight: 500;
}

/* List item with a leading slot */
.list { list-style: none; margin: 0 0 24px; padding: 0; }
.list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}
.list li:last-child { border-bottom: none; }
.list .leading {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  font-size: .875rem;
  font-weight: 500;
}
.list .leading svg { width: 20px; height: 20px; fill: currentColor; }

/* ==========================================================================
   10  CALLOUTS
   ========================================================================== */
.callout {
  display: flex;
  gap: 16px;
  padding: 16px;
  margin: 24px 0;
  border-radius: var(--md-shape-md);
  border-left: 4px solid var(--md-outline);
  background: var(--md-surface-container-low);
  color: var(--md-on-surface-variant);
}
.callout > :last-child { margin-bottom: 0; }
.callout p { max-width: none; }
.callout-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--md-shape-full);
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  font-size: .8125rem;
  font-weight: 700;
}
.callout-info   .callout-icon { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.callout-warn   { border-left-color: var(--md-secondary); }
.callout-warn   .callout-icon { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.callout-error  { border-left-color: var(--md-error); }
.callout-error  .callout-icon { background: var(--md-error-container); color: var(--md-on-error-container); }
.callout-success .callout-icon { background: var(--md-success-container); color: var(--md-on-success-container); }

/* ==========================================================================
   11  TABLES
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
}
/* A table inside a narrow grid card wrapped one word per line. Give the table
   a floor width and let the wrapper scroll instead of crushing it. */
.table-wrap table { min-width: 440px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
/* Commands and paths are single tokens: never break them mid-word. */
td code, th code { white-space: nowrap; }
thead th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  color: var(--md-on-surface-variant);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--md-on-surface) 5%, transparent); }

/* ==========================================================================
   12  CODE
   ========================================================================== */
/* Inline code. A filled box per token turned prose into button soup, so the
   treatment is a faint tint with a hairline instead of a solid chip. */
code {
  padding: 1px 5px;
  border-radius: var(--md-shape-xs);
  background: color-mix(in srgb, var(--md-primary) 11%, transparent);
  color: var(--md-on-surface);
  font-family: var(--md-font-mono);
  font-size: .8125em;
  font-weight: 500;
}
/* Code inside a heading must not read as a chip sitting in the title. Keep the
   monospace, drop the tint, and let it take the heading's size. */
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
  padding: 0;
  background: none;
  color: var(--md-primary);
  font-size: .9em;
  font-weight: 500;
}

pre {
  overflow-x: auto;
  margin: 0 0 24px;
  padding: var(--md-gutter);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  background: var(--md-surface-container-lowest);
  color: var(--md-on-surface);
  font-family: var(--md-font-mono);
  font-size: .875rem;
  line-height: 1.6;
}
pre code { padding: 0; background: none; font-size: inherit; border-radius: 0; }
pre .tok-cmd { color: var(--md-primary); }
pre .tok-com { color: var(--md-on-surface-variant); }
pre .tok-key { color: var(--md-tertiary); }
pre .tok-str { color: var(--md-secondary); }

/* ==========================================================================
   13  TIMELINE
   ========================================================================== */
.timeline {
  list-style: none;
  counter-reset: tstep;
  margin: 24px 0;
  padding: 0;
}
.timeline li {
  position: relative;
  min-height: 48px;
  padding: 0 0 24px 56px;
}
.timeline li::before {
  counter-increment: tstep;
  content: counter(tstep);
  position: absolute;
  left: 0;
  top: -4px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-full);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: .875rem;
  font-weight: 500;
}
.timeline li::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--md-outline-variant);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }

/* ==========================================================================
   14  FOOTER
   ========================================================================== */
.app-footer {
  padding: 32px var(--md-gutter);
  border-top: 1px solid var(--md-outline-variant);
  background: var(--md-surface-container);
  color: var(--md-on-surface-variant);
}
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--md-content-max);
  margin: 0 auto;
  font-size: .8125rem;
}
.footer a { color: var(--md-on-surface-variant); }
.footer a:hover { color: var(--md-primary); }
.footer code { background: transparent; padding: 0; color: inherit; }

/* ==========================================================================
   15  MOTION, PRINT, FORCED COLOURS
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast: lean on system colours and force borders on outlined things. */
@media (forced-colors: active) {
  .card, .callout, .chip, .btn, .table-wrap, pre { border: 1px solid CanvasText; }
  .nav-links a[aria-current="page"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

@media print {
  .app-bar, .nav-bar, .app-footer, .btn-row { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  a::after { content: " (" attr(href) ")"; font-size: .75em; color: #444; }
}