/* OpenLens. No JavaScript. One palette with light-dark(); html[data-theme] picks the scheme. */

@layer tokens, base, layout, components, motion, utilities;

@layer tokens {
  :root {
    color-scheme: light dark;
    --bg:      light-dark(oklch(97.6% 0.005 85),  oklch(15.5% 0.010 285));
    --surface: light-dark(oklch(100% 0 0),        oklch(19.5% 0.012 285));
    --raised:  light-dark(oklch(98.6% 0.004 85),  oklch(22.5% 0.013 285));
    --ink:     light-dark(oklch(21% 0.018 285),   oklch(95% 0.006 285));
    --ink-2:   light-dark(oklch(38% 0.016 285),   oklch(83% 0.010 285));
    --muted:   light-dark(oklch(49% 0.014 285),   oklch(70% 0.012 285));
    --line:    light-dark(oklch(91.5% 0.006 85),  oklch(28% 0.014 285));
    --line-2:  light-dark(oklch(95% 0.005 85),    oklch(24% 0.012 285));
    /* Form control borders: >= 3:1 (WCAG 1.4.11, #680). */
    --field-line: light-dark(oklch(62% 0.008 85), oklch(54% 0.014 285));
    --accent:  light-dark(oklch(51% 0.22 281),    oklch(73% 0.15 281));
    --on-accent: light-dark(oklch(99% 0 0),       oklch(17% 0.02 281));
    --good:    light-dark(oklch(49% 0.12 155),    oklch(76% 0.14 155));
    --bad:     light-dark(oklch(52% 0.19 18),     oklch(72% 0.16 18));
    --warn:    light-dark(oklch(53% 0.12 70),     oklch(80% 0.13 80));
    --info:    light-dark(oklch(52% 0.14 245),    oklch(75% 0.11 245));
    --tint: 11%;
    --r-l: 16px; --r: 12px; --r-s: 8px; --r-pill: 999px;
    --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    --step--1: 12.5px; --step-0: 14px; --step-1: 15.5px; --step-2: 19px; --step-3: 26px; --step-4: 34px;
    --shadow: 0 0 0 1px light-dark(transparent, oklch(100% 0 0 / .02)),
              0 1px 2px light-dark(oklch(20% 0.02 285 / .04), transparent),
              0 6px 20px -12px light-dark(oklch(20% 0.02 285 / .12), transparent);
    /* Earlier names, kept as aliases until the components move to v2. */
    --violet: var(--accent); --mint: var(--good); --sky: var(--info); --sun: var(--warn); --coral: var(--bad);
    /* The logo keeps the v1 colours exactly (the aliases above follow the v2 status tones). */
    --logo-violet: light-dark(#5b4ef0, #8f84ff); --logo-sky: light-dark(#2f8cf0, #58a8ff); --logo-mint: light-dark(#0e9f6e, #34c38f);
    --logo-sun: light-dark(#d99400, #f2b544); --logo-coral: light-dark(#e5486a, #ff6f8b);
  }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
}

@layer base {
  :root {
    font: 400 var(--step-0)/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--ink); background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }
  /* Focus clear of the sticky top bar (WCAG 2.4.11, #680). */
  html { scroll-padding-top: 64px; }
  * { box-sizing: border-box; }
  body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
  a { color: var(--violet); text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 3px; }
  /* Type scale (v2): page title --step-4, card title --step-2, sub-heading --step-1. */
  h1, h2, h3 { text-wrap: balance; letter-spacing: -.018em; }
  h1 { font-size: var(--step-4); line-height: 1.1; font-weight: 600; letter-spacing: -.03em; margin: 0; }
  h2 { font-size: var(--step-2); line-height: 1.3; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
  h3 { font-size: var(--step-1); font-weight: 600; }
  p { text-wrap: pretty; }
  code, .mono, pre { font-family: var(--mono); font-size: .92em; }
  .muted { color: var(--muted); } .small { font-size: var(--step--1); } .center { text-align: center; }
  .icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
  button { font: inherit; font-weight: 500; font-size: 13px; border: 1px solid var(--ink); border-radius: var(--r-s); padding: 7px 14px;
    cursor: pointer; background: var(--ink); color: var(--bg); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  select, input, textarea { font: inherit; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--field-line); border-radius: var(--r-s); padding: 7px 10px; }
  select:not([multiple]) { appearance: none; padding-right: 28px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 14px center, right 10px center; background-size: 4px 4px; background-repeat: no-repeat; }
  select:hover, input:hover, textarea:hover { border-color: color-mix(in oklab, var(--ink) 35%, var(--field-line)); }
  /* Tables (v2): quiet sentence-case headers, hairline rows, aligned numbers. */
  table { width: 100%; border-collapse: collapse; }
  th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line-2); font-weight: 400; font-size: 13.5px; }
  tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
  thead th { color: var(--muted); font-size: 12.5px; font-weight: 500; padding-top: 4px; padding-bottom: 10px; white-space: nowrap; }
  tbody th { font-weight: 500; }
  tbody tr:hover :is(td, th) { background: var(--raised); }
  .num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px; border-top: 1px solid var(--line-2); }
  @media (max-width: 640px) {
    h1 { font-size: var(--step-3); }
    table th, table td { padding-left: 6px; padding-right: 6px; }
  }
}

@layer layout {
  .shell { display: flex; min-height: 100vh; }
  .content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  main { flex: 1; width: min(1200px, 100% - 40px); min-width: 0; margin: 0 auto; padding: 10px 0 40px; }
  body.shared .content { max-width: 1280px; margin: 0 auto; }
  @media (max-width: 640px) { main { width: calc(100% - 20px); } }
}

@layer components {
  /* Links inside text are underlined, so they don't rely on colour alone (WCAG 1.4.1). */
  p a:not(.btn), .small a:not(.btn), .hint a { text-decoration: underline; text-underline-offset: 2px; }
  /* Small text links are still 24 × 24 px targets (WCAG 2.5.8, #303). */
  .small a, a.small { display: inline-flex; align-items: center; min-height: 24px; min-width: 24px; }
  /* The sidebar, collapsible to icons by a cookie (#170); hidden on a phone (#801). */
  .side { position: sticky; top: 0; flex: none; box-sizing: border-box; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; overflow-x: hidden; z-index: 2; }
  :is(.side, .drawer) .switch { display: flex; align-items: center; border: 1px solid var(--line); color: var(--ink); font-weight: 500; margin-bottom: 6px; }
  .side .switch:hover { text-decoration: none; }
  img.picon { flex: none; width: 24px; height: 24px; border-radius: 7px; object-fit: contain; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
  .side-nav a { display: flex; align-items: center; gap: 11px; color: var(--ink-2); background: none; border: 0; font: inherit; cursor: pointer; width: 100%; box-sizing: border-box; text-align: left; }
  .side-nav a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
  .side-nav svg { flex: none; }
  /* Underline tabs (v2): the section tabs under the top bar and in-page tab rows. */
  .section-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
  .section-tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; margin-bottom: -1px; white-space: nowrap;
    color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
  .section-tabs a:hover { color: var(--ink); text-decoration: none; }
  .section-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
  .side .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side .expand { display: none; }
  html[data-nav="collapsed"] .side { width: 64px; align-items: center; }
  html[data-nav="collapsed"] .side .label { display: none; }
  html[data-nav="collapsed"] .side .collapse { display: none; }
  html[data-nav="collapsed"] .side .expand { display: flex; }
  html[data-nav="collapsed"] .side .switch { border: 0; padding: 7px; justify-content: center; }
  html[data-nav="collapsed"] .side-nav a { justify-content: center; padding: 10px; }
  .brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
  .brand:hover { text-decoration: none; }
  /* The OpenLens logo: a colour blob that slowly changes shape (also docs/img/logo.svg). */
  .blob { display: inline-block; flex: none;
    background: conic-gradient(from 200deg, var(--logo-violet), var(--logo-sky), var(--logo-mint), var(--logo-sun), var(--logo-coral), var(--logo-violet));
    border-radius: 42% 58% 61% 39% / 45% 39% 61% 55%; }
  .brand .blob { width: 22px; height: 22px; }

  /* Buttons (v2): a plain <button> is the primary; .soft/.ghost/.danger are old names of .btn variants. */
  .btn, button:is(.soft, .ghost, .danger) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
    padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    font: inherit; font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer; }
  .btn:hover, button:is(.soft, .danger):hover { text-decoration: none; border-color: color-mix(in oklab, var(--ink) 22%, var(--line)); }
  .btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
  button:not([class]):hover, .btn.primary:hover { background: color-mix(in oklab, var(--ink) 88%, var(--accent)); }
  .btn.ghost, button.ghost { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 8px; }
  .btn.ghost:hover, button.ghost:hover { background: color-mix(in oklab, var(--accent) 8%, transparent); }
  .btn.sm { min-height: 30px; padding: 0 10px; font-size: var(--step--1); }
  .btn.ghost.sm { padding-inline: 6px; }
  :is(.btn.danger-btn, .btn.danger, button.danger) { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); background: var(--surface); }
  :is(.btn.danger-btn, .btn.danger, button.danger):hover { border-color: var(--bad); }
  .btn.danger-solid { background: var(--bad); border-color: var(--bad); color: oklch(99% 0 0); }
  .btn.danger-solid:hover { background: color-mix(in oklab, var(--bad) 85%, var(--ink)); border-color: transparent; }
  :is(.btn, button)[disabled] { opacity: .55; cursor: not-allowed; }
  :is(.btn, button)[hidden] { display: none; }
  .pw-toggle { grid-column: 1 / -1; justify-self: start; align-self: start; }

  /* Page heading (the v2 page head): title, one muted line, actions at the end. */
  .heading { margin: 8px 0 24px; display: flex; align-items: end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
  .heading p { margin: 6px 0 0; }
  .heading p.muted { font-size: var(--step-1); max-width: 72ch; }
  .filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 22px; padding: 12px;
    border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow); }
  .filters label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 4px; }

  /* Stat tiles: the v2 KPI card. */
  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; margin-bottom: 24px; }
  .tile { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 10px; min-height: 132px; padding: 16px 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); }
  .tile .label { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; color: var(--muted); font-size: 13px; }
  .tile .label a.stretch { min-width: 0; overflow-wrap: anywhere; }
  .kpi-info { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; margin-left: -4px; padding: 0; border: 0; background: none; color: var(--muted); cursor: help; border-radius: 50%; font: inherit; font-size: 13px; }
  .kpi-info:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }
  /* Native popover (#682). */
  .kpi-def[popover] { inset: auto; margin: 0; max-width: min(320px, calc(100vw - 24px)); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 400; line-height: 1.4; text-align: left; box-shadow: 0 6px 20px rgb(0 0 0 / .12); white-space: normal; }
  .kpi-def[popover]:popover-open { position: fixed; left: 50%; top: 50%; translate: -50% -50%; }
  @supports (position-area: block-end) {
    .kpi-def[popover]:popover-open { translate: none; left: auto; top: auto; position-area: block-end span-inline-end; margin-top: 4px; }
  }
  .chip-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--accent);
    background: color-mix(in oklab, var(--accent) var(--tint), transparent); }
  .tile .value { font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
  .tile .hint { margin-top: auto; color: var(--muted); font-size: var(--step--1); }
  .violet { --accent: var(--violet); } .mint { --accent: var(--mint); } .sky { --accent: var(--sky); }
  .sun { --accent: var(--sun); } .coral { --accent: var(--coral); }
  /* --hue is set only by a colour class (--accent also has a page-wide value). */
  .violet, .mint, .sky, .sun, .coral { --hue: var(--accent); }

  /* Cards */
  .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 16px; align-items: start; }
  /* Absolutely placed bits stay inside the card. */
  .card { position: relative; min-width: 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
    padding: 20px 22px; box-shadow: var(--shadow); }
  :where(:not(.grid, .split, .people-grid, .kpis, .focus-grid)) > :is(.card, .grid) + :is(.card, .grid) { margin-top: 16px; }
  .card.wide { grid-column: 1 / -1; overflow-x: auto; }
  .card h2 .icon { color: var(--hue, var(--muted)); }

  /* Charts */
  .spark { width: 100%; height: 76px; display: block; }
  .spark .bar { fill: color-mix(in oklab, var(--violet) 22%, transparent); }
  .spark .bar.now, .spark .bar:hover { fill: var(--violet); }

  .bars .meter { width: 46%; }
  .fill { display: block; width: 100%; height: 6px; overflow: visible; }
  .fill rect { fill: var(--accent, var(--violet)); opacity: .85; }
  /* Status words in cells and lists: the v2 tag, toned. */
  span.status { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: var(--r-pill); white-space: nowrap;
    font-size: 12.5px; font-weight: 550; color: var(--tone, var(--ink-2)); background: color-mix(in oklab, var(--tone, var(--ink-2)) var(--tint), transparent); }
  span.status .icon { width: 13px; height: 13px; }
  .status.good { --tone: var(--good); } .status.warn { --tone: var(--warn); } .status.bad { --tone: var(--bad); } .status.muted { --tone: var(--muted); }
  span.chip { font-family: var(--mono); font-size: 12.5px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; }
  .events td { font-size: 13px; }

  /* Journeys */
  .journeys { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
  .journeys li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
  .journeys .step { border-radius: var(--r-pill); padding: 2px 10px; background: var(--line-2); color: var(--ink-2); }
  .journeys .step.done { color: var(--good); background: color-mix(in oklab, var(--good) var(--tint), transparent); font-weight: 550; }
  .arrow { color: var(--muted); font-size: 12.5px; }

  /* Forms on cards */
  form.inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; margin: 6px 0 10px; }

  /* Login & empty states */
  .login, .empty { max-width: 540px; margin: 56px auto; background: var(--surface); border: 1px solid var(--line); padding: 32px; border-radius: 20px; box-shadow: var(--shadow); }
  .login form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
  .login label { font-size: 12.5px; color: var(--muted); }
  .alert { background: color-mix(in oklab, var(--bad) var(--tint), transparent); color: var(--bad); padding: 8px 12px; border-radius: var(--r-s); font-size: 13px; }
  .empty h2 { margin-top: 22px; color: var(--ink); }
  /* Form errors (#683); the summary is also an .alert. */
  .error-summary :is(h2, a), .field-error { color: var(--bad); }
  [aria-invalid=true] { border-color: var(--bad); }
  .empty .blob { display: block; width: 56px; height: 56px; margin-bottom: 6px; }
  pre.copy { white-space: pre-wrap; word-break: break-all; background: var(--raised); border: 1px dashed var(--line); padding: 12px; border-radius: var(--r-s); user-select: all; }

  footer a.update-security { color: var(--bad); font-weight: 600; }
  /* Phones (#170): nothing wider than the screen. */
  @media (max-width: 640px) {
    .filters { gap: 8px; }
    .filters label { flex: 1 1 140px; }
    .filters select { width: 100%; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  }

  a.icon-link { display: inline-flex; color: var(--muted); }
  a.icon-link:hover { color: var(--violet); }
  #ol-player .ol-stage { position: relative; overflow: hidden; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--raised); min-height: 240px; margin: 0 auto; max-width: 100%; box-sizing: content-box; }
  #ol-player .ol-main { min-width: 0; }
  #ol-player .ol-controls, #ol-player .ol-info, #ol-player .ol-legend, #ol-player .ol-help { max-width: var(--ol-w, 100%); margin-left: auto; margin-right: auto; }
  #ol-player .ol-info { margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
  #ol-player .ol-zoom[aria-pressed="true"] { border-color: var(--violet); color: var(--violet); font-weight: 600; }
  /* Event list beside the video on wide screens (#212), below it elsewhere. */
  @media (min-width: 1024px) and (min-height: 500px) {
    #ol-player { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
    #ol-player .ol-log { margin-top: 0; max-height: calc(100dvh - 200px); position: sticky; top: 16px; }
    #ol-player:has(> .ol-log[hidden]) { grid-template-columns: minmax(0, 1fr); }
  }
  #ol-player .ol-stage iframe { border: 0; background: #fff; }
  #ol-player { --k-page: var(--info); --k-goal: var(--warn); --k-submit: var(--good); --k-click: var(--accent); --k-rage: light-dark(oklch(60% 0.2 8), oklch(70% 0.17 8)); --k-error: var(--bad); }
  #ol-player .ol-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; font-size: 13px; }
  #ol-player .ol-controls > button { font: inherit; min-width: 40px; height: 34px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
  #ol-player .ol-controls > button:hover { border-color: var(--violet); }
  #ol-player .ol-controls .ol-play { min-width: 46px; background: var(--violet); border-color: var(--violet); color: var(--on-accent); font-size: 14px; }
  #ol-player .ol-track { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  #ol-player .ol-track input[type=range] { width: 100%; accent-color: var(--violet); margin: 0; }
  #ol-player .ol-marks { position: relative; height: 24px; }
  #ol-player .ol-mark { position: absolute; top: 0; width: 24px; height: 24px; margin-left: -12px; padding: 0; border: 0; background: none; cursor: pointer; }
  #ol-player .ol-mark::before { content: ""; position: absolute; left: 7px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--k); box-shadow: 0 0 0 2px var(--surface); }
  #ol-player .ol-mark.k-error::before { left: 10px; top: 1px; width: 4px; height: 20px; border-radius: 2px; }
  #ol-player .ol-mark:hover::before, #ol-player .ol-mark:focus-visible::before { transform: scale(1.35); }
  #ol-player .k-page { --k: var(--k-page); } #ol-player .k-goal { --k: var(--k-goal); } #ol-player .k-submit { --k: var(--k-submit); }
  #ol-player .k-note { --k: var(--ink-2); } #ol-player .ol-mark.k-note::before { border-radius: 2px; transform: rotate(45deg); }
  #ol-player .k-click { --k: var(--k-click); } #ol-player .k-rage { --k: var(--k-rage); } #ol-player .k-error { --k: var(--k-error); }
  /* Idle gaps (#404): a pause glyph where the seek bar jumps a gap. */
  #ol-player .k-idle { --k: var(--muted); }
  #ol-player .ol-mark.ol-gap { font-size: 12.5px; line-height: 24px; color: var(--muted); }
  #ol-player .ol-mark.ol-gap::before { content: none; }
  #ol-player .ol-mark.ol-gap:hover, #ol-player .ol-mark.ol-gap:focus-visible { color: var(--ink); }
  #ol-player .ol-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--k); }
  #ol-player .k-error .ol-dot { width: 4px; height: 13px; border-radius: 2px; }
  #ol-player .ol-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-2); }
  #ol-player .ol-legend li { display: inline-flex; align-items: center; gap: 6px; }
  #ol-player .ol-log { list-style: none; margin: 10px 0 0; padding: 4px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); position: relative; }
  #ol-player .ol-log button { width: 100%; display: grid; grid-template-columns: 44px 12px 1fr; align-items: center; gap: 8px; text-align: left; font: inherit; font-size: 13px; color: var(--ink); background: none; border: 0; border-radius: 6px; padding: 6px 8px; cursor: pointer; min-height: 34px; }
  #ol-player .ol-log button:hover { background: var(--line-2); }
  #ol-player .ol-log li[aria-current] button { background: color-mix(in oklab, var(--violet) var(--tint), transparent); font-weight: 600; }
  #ol-player .ol-at { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
  #ol-player .ol-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #ol-player .ol-help { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
  #ol-player { min-width: 0; max-width: 100%; }
  @media (max-width: 640px) {
    #ol-player .ol-track { order: -1; flex-basis: 100%; }
    #ol-player .ol-help { display: none; }
  }
  @media (pointer: coarse) { #ol-player .ol-controls > button, #ol-player select { min-height: 44px; } #ol-player .ol-log button { min-height: 44px; } }
  #ol-player .ol-time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 92px; }
  #ol-player select { appearance: auto; padding: 4px 6px; background: var(--surface); }
  #ol-player label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }

  /* Roles × features grid: one hue, five steps (darker = more of the role uses it). */

  /* Icon sprite: definitions only, never drawn (no inline styles under the CSP). */
  svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

  /* Project switcher */
  a.project { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; padding: 4px 8px; border-radius: 999px; }
  a.project:hover { color: var(--ink); background: var(--line-2); text-decoration: none; }
  a.project .icon { width: 14px; height: 14px; }
  ul.project-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px; }
  ul.project-list a.card { display: block; color: var(--ink); }
  ul.project-list a.card:hover { text-decoration: none; border-color: var(--violet); }

  /* Click heatmap */
  svg.heatmap { display: block; width: 100%; height: auto; border-radius: var(--r-s); }
  svg.heatmap rect.page { fill: var(--raised); stroke: var(--line); }
  svg.heatmap .dot { fill: var(--violet); }
  svg.heatmap .dot.rage { fill: var(--coral); }
  #ol-player .ol-heat { position: absolute; inset: 0; pointer-events: none; }
  #ol-player .ol-heat span { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(229, 72, 106, .85), rgba(109, 94, 252, .35) 60%, transparent 70%); transform: translate(-50%, -50%); }

  /* Digest */
  span.up { color: var(--good); font-weight: 600; } span.down { color: var(--bad); font-weight: 600; }

  /* Team */
  form.invite { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
  form.invite label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }

  /* Project settings (#219) */
  form.settings { flex-wrap: wrap; }
  form.settings label, form.inline label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
  form.inline label.check { flex-direction: row; align-items: center; gap: 6px; }
  form.settings fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
  form.settings legend { padding: 0 0 4px; }
  form.settings label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
  form.settings input[name=app_url] { min-width: 260px; }
  pre.snippet { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; user-select: all; }
  ul.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
  ul.checks li { display: flex; align-items: center; gap: 8px; color: var(--bad); }
  ul.checks li span { color: var(--ink); }
  ul.checks li.ok { color: var(--good); }
  dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; margin: 0 0 10px; }
  dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; }
  .notice { background: color-mix(in oklab, var(--mint) var(--tint), transparent); color: var(--good); padding: 8px 12px; border-radius: var(--r-s); font-size: 13px; }
  section.danger { border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); }
  .qr svg { display: block; width: 200px; height: 200px; margin: 8px 0; border-radius: var(--r-s); }
  .new-project { align-items: center; margin-bottom: 16px; }
  .shared-projects li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 0; }
  .project-list h2 img.picon { margin-right: 2px; }

  /* Surveys */
  form.inline input[type=number] { width: 64px; padding: 4px 6px; }

  .filters input[type=text], .filters input[type=date] { width: 130px; }
  @media (max-width: 640px) { .filters input[type=text], .filters input[type=date] { width: 100%; box-sizing: border-box; } }

  /* Team (#216) */
  .table-scroll { overflow-x: auto; }
  div.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  div.actions form.inline { margin: 0; }

  /* Replay comments (#213) */
  ol.comment-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
  ol.comment-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
  ol.comment-list li:target { background: color-mix(in oklab, var(--violet) var(--tint), transparent); border-radius: var(--r-s); }
  .ol-c-at { font-variant-numeric: tabular-nums; font-weight: 600; }
  .comment-body { white-space: pre-wrap; }
  form.comment-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
  form.comment-form label { flex-basis: 100%; font-size: 12.5px; color: var(--muted); }
  form.comment-form textarea { flex: 1 1 260px; }


  /* Share links (#229) */
  .shared-banner { margin: 0; padding: 10px 24px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
  .shared-banner .blob { width: 16px; height: 16px; }

  /* Goals (#235) */
  svg.goal-chart { width: 100%; height: auto; display: block; margin: 6px 0; }
  svg.goal-chart .target { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 4 3; }
  svg.goal-chart .tlabel { font-size: 12.5px; fill: var(--good); }
  svg.goal-chart .series { fill: none; stroke: var(--violet); stroke-width: 2; }
  svg.goal-chart .dot { fill: var(--violet); stroke: var(--surface); stroke-width: 2; }

  /* Explorer (#222) */
  ul.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
  .sql-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
  .sql-layout .schema summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 6px; }
  form.sqlbox { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
  form.sqlbox label { font-size: 12.5px; color: var(--muted); }
  form.sqlbox textarea { font-family: var(--mono); padding: 8px 10px; }
  table.sqlres td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  @media (max-width: 760px) { .sql-layout { grid-template-columns: 1fr; } .sql-layout .schema:not([open]) { padding-bottom: 12px; } }

  /* Feature map (#221) */
  pre.diff { font-size: 12.5px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; overflow-x: auto; max-height: 420px; }
  pre.diff ins { text-decoration: none; color: var(--good); background: color-mix(in oklab, var(--mint) var(--tint), transparent); }
  pre.diff del { text-decoration: none; color: var(--bad); background: color-mix(in oklab, var(--bad) var(--tint), transparent); }

  /* Retention (#619): the survival curve, a step line. */
  svg.survival { width: 100%; height: auto; display: block; }
  svg.survival .grid { stroke: var(--line); }
  svg.survival text { fill: var(--muted); font-size: 12.5px; }
  svg.survival .km { fill: none; stroke: var(--accent); stroke-width: 2; }
  svg.survival circle { fill: var(--accent); }

  /* Audience map (#225): one hue, five steps; no data stays neutral. */
  svg.world { width: 100%; height: auto; display: block; }
  svg.world path { stroke: var(--surface); stroke-width: .5; }
  svg.world path:hover { stroke: var(--ink); stroke-width: 1; }
  .c0 { fill: var(--line); }
  .c1 { fill: color-mix(in oklab, var(--violet) 22%, var(--surface)); }
  .c2 { fill: color-mix(in oklab, var(--violet) 40%, var(--surface)); }
  .c3 { fill: color-mix(in oklab, var(--violet) 60%, var(--surface)); }
  .c4 { fill: color-mix(in oklab, var(--violet) 80%, var(--surface)); }
  .c5 { fill: var(--violet); }
  .legend-scale { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin: 8px 0; }
  .legend-scale i { display: inline-block; width: 22px; height: 10px; border-radius: 2px; background: currentColor; }
  .legend-scale i.c1 { color: color-mix(in oklab, var(--violet) 22%, var(--surface)); }
  .legend-scale i.c2 { color: color-mix(in oklab, var(--violet) 40%, var(--surface)); }
  .legend-scale i.c3 { color: color-mix(in oklab, var(--violet) 60%, var(--surface)); }
  .legend-scale i.c4 { color: color-mix(in oklab, var(--violet) 80%, var(--surface)); }
  .legend-scale i.c5 { color: var(--violet); }
  details.table-view summary { cursor: pointer; font-size: 13px; color: var(--ink-2); margin: 6px 0; }

  /* Feature flow (#224) */
  .sankey-scroll { overflow-x: auto; }
  svg.sankey { width: 100%; min-width: 640px; height: auto; display: block; }
  svg.sankey .ribbon.drop { fill: color-mix(in oklab, var(--bad) 18%, transparent); }
  svg.sankey .node { fill: var(--violet); }
  svg.sankey .slabel { font-size: 12.5px; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }

  /* Goals part 2 (#272) */
  input.narrow { width: 9em; }
  .objective { padding: 6px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); }
  .objective:last-of-type { border-bottom: 0; }

  /* Streamed board page (#301, D-073): no script. */
  .board-waiting { display: flex; align-items: flex-start; gap: 12px; margin: 24px 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; max-width: 28rem; }
  .board-waiting > div { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .board-waiting:not(:last-child) { display: none; }
  .board-waiting .spinner { flex: none; margin-top: 2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink-2, currentColor); }
  .board-waiting .waiting-bar { display: block; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--line); overflow: hidden; }
  .board-waiting .waiting-bar span { display: block; width: 30%; height: 100%; background: var(--ink-2, currentColor); }
  @media (prefers-reduced-motion: reduce) { .board-waiting .spinner, .board-waiting .waiting-bar span { animation: none; } }

  /* Environment pickers (#799): the free field only with "Other…" picked. No script. */
  .env-pick:has(select option[value=""]:not(:checked)) .env-other { display: none; }

  /* AI settings (#406): presets need only the key; Custom shows every field. No script. */
  .ai-form .custom-only, .ai-form .url-field, .ai-form .key-help > span { display: none; }
  .ai-form:has(select[name="preset"] option[value="custom"]:checked) .custom-only,
  .ai-form:has(select[name="preset"] option[value="custom"]:checked) .url-field,
  .ai-form:has(select[name="preset"] option[value="ollama"]:checked) .url-field { display: block; }
  .ai-form:has(select[name="preset"] option[value="anthropic"]:checked) .key-help .for-anthropic { display: inline; }
  .ai-form:has(select[name="preset"] option[value="openai"]:checked) .key-help .for-openai { display: inline; }
  .ai-form:has(select[name="preset"] option[value="google"]:checked) .key-help .for-google { display: inline; }
  .ai-form:has(select[name="preset"] option[value="mistral"]:checked) .key-help .for-mistral { display: inline; }
  .ai-form:has(select[name="preset"] option[value="openrouter"]:checked) .key-help .for-openrouter { display: inline; }
  .ai-form:has(select[name="preset"] option[value="ollama"]:checked) .key-help .for-ollama { display: inline; }
  .crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 10px; padding: 0; font-size: 12.5px; color: var(--muted); }
  .crumbs li + li::before { content: "›"; margin-right: 6px; color: var(--muted); }
  .crumbs a { color: var(--ink-2); }
  .crumbs [aria-current="page"] { color: var(--ink); }

  .card h3 { font-size: var(--step-0); font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }
  /* Forms: one grid, so labels, fields and checkboxes line up (#403). */
  form.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 14px 16px; align-items: end; }
  form.settings > button, form.settings > .actions, form.settings > details, form.settings > fieldset,
  form.settings > p, form.settings > div, form.settings > label.check { grid-column: 1 / -1; }
  form.settings > label.check + label.check { margin-top: -8px; }
  form.settings > button { justify-self: start; }
  form.settings label { font-weight: 500; }
  form.settings input, form.settings select { width: 100%; box-sizing: border-box; padding: 8px 10px; }
  form.settings input[type=checkbox] { width: auto; }
  .actions { display: flex; gap: 8px; flex-wrap: wrap; }
  @media (max-width: 640px) {
    .tile .value { font-size: 24px; }
    .section-tabs { flex-wrap: nowrap; overflow-x: auto; }
  }
  .prev-next { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
  /* Cards and tiles open their detail (#409): one stretched link per card. */
  a.stretch { color: inherit; text-decoration: none; }
  a.stretch::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
  .card a:not(.stretch), .card button, .card select, .card input, .card summary, .card .kpi-info, .tile .kpi-info { position: relative; z-index: 1; }
  details.why { position: relative; z-index: 1; margin: 2px 0 6px; } details.why summary { cursor: pointer; font-size: 12.5px; color: var(--violet); } details.why ol { margin: 4px 0 8px; padding-left: 20px; }
  a.stretch .details { margin-left: 8px; font-size: 12.5px; font-weight: 500; color: var(--violet); opacity: 0; }
  .card:hover a.stretch .details, .tile:hover a.stretch .details, a.stretch:focus-visible .details { opacity: 1; }
  @media (pointer: coarse) { a.stretch .details { opacity: 1; } }
  .card:has(a.stretch):hover, .tile:has(a.stretch):hover { border-color: color-mix(in oklab, var(--violet) 35%, var(--line)); }
  a.stretch:focus-visible { outline: none; }
  .card:has(a.stretch:focus-visible), .tile:has(a.stretch:focus-visible) { outline: 2px solid var(--violet); outline-offset: 2px; }
  .setup progress { width: 100%; height: 8px; accent-color: var(--violet); margin: 4px 0 10px; }
  .kpi-def { max-width: min(260px, 72vw); }
  @media (max-width: 640px) { a.stretch .details { display: none; } }
}

@layer utilities {
  /* Skip link (#680): first stop on Tab, hidden until focused. */
  .skip-link { position: absolute; left: 8px; top: 8px; z-index: 10; padding: 8px 14px; border-radius: var(--r-s);
    background: var(--ink); color: var(--bg); font-weight: 500; transform: translateY(-200%); }
  .skip-link:focus { transform: none; }
  main:focus { outline: none; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
}

/* Go to… (#541) */
@layer components {
  .side form.goto input { width: 100%; box-sizing: border-box; }
  html[data-nav="collapsed"] .side form.goto { display: none; }
  ul.goto-results { margin: 8px 0 16px; padding-left: 20px; line-height: 1.8; }

  /* Uptime: 90 daily bars (#559), CSS only; a tooltip from the title. */
  .uptime-days { display: flex; gap: 2px; align-items: stretch; height: 34px; margin: 4px 0 8px; }
  .uptime-day { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: color-mix(in oklab, var(--muted) 28%, transparent); }
  .uptime-day.up { background: var(--good); }
  .uptime-day.partial { background: var(--warn); }
  .uptime-day.down { background: var(--bad); }
  .uptime-day:hover { opacity: .75; }
  @media (max-width: 480px) { .uptime-days { gap: 1px; } }
}

/* Availability and the error budget (#560), v2 parts. */
@layer components {
  .availability > .section-head { margin: 24px 0 8px; }
  .availability h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 8px; }
  .kpi-head { justify-content: space-between; gap: 8px; }
  .card.budget { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
  .card.budget h3 { margin: 0; }
  svg.budget-meter { display: block; width: 100%; height: 6px; }
  svg.budget-meter .track { fill: var(--line); }
  svg.budget-meter .fill { fill: var(--tone, var(--accent)); }
  .card.form-card { margin-top: 16px; display: flex; flex-direction: column; gap: 20px; }
  .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); font-weight: 500; }
  .field input, .field select { height: 38px; font-size: 14px; }
  .field small { color: var(--muted); font-weight: 400; font-size: var(--step--1); line-height: 1.45; }
}

/* Public status page (#561) and its Settings card (v2 parts). */
@layer components {
  .field textarea { padding: 8px 10px; resize: vertical; }
  .field.wide { grid-column: 1 / -1; }
  .card.danger .item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-2); }
  .card.danger .item:first-of-type { border-top: 0; }
  .tone-muted { --tone: var(--muted); }
  .table-card .pad { padding: 0 20px 12px; }
  .form-card label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
  .form-card h2 { margin: 0; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .row-actions form { display: inline; }
  .notice-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
  .notice-list > li { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; }
  .notice-list > li:first-child { border-top: 0; }
  .notice-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .notice-updates { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
  .form-card form { display: flex; flex-direction: column; gap: 16px; }
  .field label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
  .table-card { overflow: hidden; padding: 18px 0 6px; }
  .table-card h2 { padding: 0 20px; }

  .status-page { background: var(--bg); }
  main.status { width: min(780px, 100% - 32px); margin: 0 auto; padding: 40px 0 24px; display: flex; flex-direction: column; gap: 14px; }
  main.status .card { padding: 20px 22px; margin: 0; }
  main.status .card.table-card { padding: 18px 0 6px; }
  main.status .card.empty { max-width: none; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px 22px; align-items: center; padding: 24px 22px; }
  main.status .empty .art { width: 96px; height: 72px; color: var(--muted); }
  main.status .empty h2 { margin: 0 0 4px; }
  main.status .empty p { color: var(--muted); margin: 0; }
  .status-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
  .status-head h1 { margin: 0; }
  .status-head p { margin: 0; }
  .status-icon { border-radius: var(--r-s); flex: none; }
  .status-now { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
  .status-now .tag { height: 32px; padding: 0 14px; font-size: var(--step-1); }
  .status-now p { margin: 0; }
  .status-line { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
  .status-line h2 { margin: 0; }
  .status-component .uptime-days { margin: 14px 0 12px; }
  .status-figures { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
  .status-figures div { display: flex; flex-direction: column; gap: 2px; }
  .status-figures dt { font-size: 12.5px; color: var(--muted); }
  .status-figures dd { margin: 0; font-weight: 550; font-variant-numeric: tabular-nums; }
  .status-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
  .status-list ul > li + li { border-top: 1px solid var(--line-2); padding-top: 14px; }
  .status-list p { margin: 6px 0 0; }
  .status-updates { margin: 8px 0 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
  .status-legend { margin: 0; }
  .status-foot { border-top: 0; padding: 12px 0 0; }
  @media (max-width: 480px) { main.status .card.empty { grid-template-columns: minmax(0, 1fr); } }
}

/* Shell (#540) */
@layer components {
  /* Sidebar: brand, project switcher, Go to…, the sections, the user menu. */
  .side { height: 100dvh; width: 232px; gap: 12px; padding: 16px 12px 12px; font-size: var(--step-0); }
  .side .brand { padding: 2px 6px; }
  :is(.side, .drawer) .switch { gap: 10px; padding: 8px 10px; margin: 0; border-radius: var(--r); background: var(--raised); font-size: var(--step-0); }
  .side .switch:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
  :is(.switch, .me) .label small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
  .monogram { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none;
    font-size: 12.5px; font-weight: 600; line-height: 1; color: var(--accent); background: color-mix(in oklab, var(--accent) var(--tint), transparent); }
  .side form.goto { margin: 0; }
  .side form.goto input { height: 36px; padding: 0 10px; border-radius: var(--r-s); background: var(--bg); font-size: 13px; }
  .side form.goto input::placeholder { color: var(--muted); }
  .side-nav a { min-height: 36px; padding: 0 10px; border-radius: var(--r-s); font-size: var(--step-0); font-weight: 450; }
  .side-nav a[aria-current="page"] { color: var(--accent); background: color-mix(in oklab, var(--accent) var(--tint), transparent); font-weight: 550; }
  .side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-2); }
  .me { anchor-name: --me; display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-s);
    background: transparent; color: var(--ink); font-size: var(--step-0); font-weight: 500; text-align: left; }
  .me:hover { background: var(--line-2); transform: none; }
  .avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--ink-2); background: var(--line); }
  html[data-nav="collapsed"] .me { justify-content: center; padding: 6px; }
  /* The account button and the sidebar toggle on one row (#897); stacked on the rail. */
  .me-row { display: flex; align-items: center; gap: 4px; }
  .me-row .me { flex: 1; min-width: 0; }
  .nav-toggle { flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-s); color: var(--ink-2); }
  .nav-toggle:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
  html[data-nav="collapsed"] .me-row { flex-direction: column; }
  .avatar.initial { color: var(--accent); background: color-mix(in oklab, var(--accent) var(--tint), transparent); font-size: 13px; font-weight: 600; }
  .me .chev { margin-left: auto; display: flex; color: var(--muted); }
  html[data-nav="collapsed"] .me .chev { display: none; }

  /* The user menu: a native popover, anchored where supported. */
  .me-menu { flex-direction: column; gap: 2px; min-width: 220px; padding: 6px; color: var(--ink); }
  .me-menu[popover] { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
    box-shadow: 0 12px 32px -8px oklch(20% 0.03 285 / .22), 0 2px 6px oklch(20% 0.03 285 / .08); }
  .me-menu[popover]:popover-open { display: flex; }
  @supports (position-area: block-start) {
    .me-menu[popover] { position-anchor: --me; position-area: block-start span-inline-end; margin: 0 0 6px; }
  }
  .me-menu a, .me-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0;
    border-radius: var(--r-s); background: none; color: var(--ink-2); font-size: var(--step-0); font-weight: 450; text-align: left; }
  .me-menu a:hover, .me-menu button:hover { background: var(--line-2); color: var(--ink); text-decoration: none; transform: none; }
  .me-menu a[aria-current="page"] { color: var(--accent); }
  .me-menu form { margin: 2px 0 0; padding-top: 2px; border-top: 1px solid var(--line-2); }
  html[data-nav="collapsed"] .me-menu[popover] .label { display: inline; }

  /* Top bar: the breadcrumb, then the page's context; sticky, translucent. */
  .topbar { position: sticky; top: 0; z-index: 3; border-bottom: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .topbar .bar, .subnav .section-tabs { width: min(1200px, 100% - 40px); margin-inline: auto; }
  .topbar .bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-height: 52px; padding-block: 8px; font-size: var(--step-0); }
  .topbar .crumbs ol { margin: 0; font-size: 13px; }
  .topbar .context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 0 auto; }

  /* Section tabs, under the top bar: an underline on the current one. */
  .subnav { border-bottom: 1px solid var(--line); }
  .subnav .section-tabs { margin-block: 0; border-bottom: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  /* Overflowing tabs fade at the scrolling edge (#684). */
  @property --fade-l { syntax: "<length>"; inherits: false; initial-value: 0px; }
  @property --fade-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
  @keyframes tabs-fade { 0% { --fade-l: 0px; --fade-r: 28px; } 6% { --fade-l: 16px; } 94% { --fade-r: 28px; } 100% { --fade-l: 16px; --fade-r: 0px; } }
  @media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: scroll(x)) {
      .subnav .section-tabs { animation: tabs-fade linear both; animation-timeline: scroll(self x);
        mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent); }
    }
  }
  .subnav .section-tabs a { margin-bottom: 0; }
  .subnav + main { padding-top: 14px; }

  /* A pill in the top bar (Live's refresh). */
  .signal { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--line);
    border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font-size: 13px; }
  /* Production right now (#614): a dot, a word, a line, per cell; they stack on a phone. */
  .now { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
  .now > * { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; color: inherit; min-width: 0; }
  .now > * + * { border-left: 1px solid var(--line-2); }
  .now a:hover { background: var(--raised); text-decoration: none; }
  .now .k { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
  .now .v { font-size: var(--step-1); font-weight: 600; }
  .now .tone-bad .v { color: var(--bad); }
  .now .s { font-size: 12.5px; color: var(--muted); }
  .now .state-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--tone, var(--muted)); }
  @media (max-width: 760px) { .now > * + * { border-left: 0; border-top: 1px solid var(--line-2); } }

  /* Phones (#801): one line; the logo opens a drawer, Filters a sheet. */
  .logo-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; background: none; }
  .logo-btn .blob { width: 26px; height: 26px; }
  .short-title, .env-badge { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .env-badge { flex: none; margin-right: auto; padding: 2px 8px; border-radius: var(--r-pill); background: var(--line-2); font: 12px var(--mono); }
  .filters-btn { flex: none; min-height: 36px; white-space: nowrap; }
  .drawer[popover] { inset: 0 auto 0 0; margin: 0; width: min(300px, 86vw); height: 100dvh; }
  .drawer-foot { margin-top: auto; border-top: 1px solid var(--line-2); }
  .sheet[popover] { inset: auto 0 0; margin: 0; padding: 12px; width: 100%; max-height: 85dvh; border: 1px solid var(--line); background: var(--surface); }
  .sheet .field :is(select, input) { font-size: 16px; }
  .sheet .pop-foot { justify-content: flex-end; }
  :is(.drawer, .sheet)::backdrop { background: #0005; }
  @media (min-width: 641px) { .topbar .bar > :is(.logo-btn, .short-title, .env-badge, .filters-btn), .topbar.is-empty { display: none; } }
  @media (max-width: 640px) {
    .side { display: none; }
    .topbar .bar { flex-wrap: nowrap; gap: 8px; min-height: 52px; padding-block: 4px; }
    .topbar .crumbs, .topbar .context { display: none; }
    .topbar .signal { flex: none; white-space: nowrap; }
    .topbar .bar, .subnav .section-tabs { width: calc(100% - 20px); }
  }

}

/* Entry pages (#547) */
@layer components {
  .auth { flex: 1; min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 20px; padding: 32px 16px;
    background-image: radial-gradient(color-mix(in oklab, var(--ink) 9%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
  .auth-card { width: min(400px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 22px; overflow: visible; }
  .auth-card h1 { font-size: var(--step-3); font-weight: 600; letter-spacing: -.025em; margin: 0; }
  .auth-card p { color: var(--muted); margin: 0; }
  .auth-card p.alert { color: var(--bad); }
  .auth-card .brand { padding: 0; }
  .auth-form { display: flex; flex-direction: column; gap: 14px; }
  .auth-card .field input { height: 42px; padding: 0 12px; font-size: 14px; font-weight: 400; }
  .auth-card .field input.mono { font-family: var(--mono); }
  .auth-card .btn { min-height: 42px; width: 100%; font-size: 14px; }
  .auth-card details.token-login summary { cursor: pointer; font-size: 13px; color: var(--accent); margin-bottom: 12px; }
  .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
  .or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .auth-foot { color: var(--muted); font-size: 12.5px; text-align: center; margin: 0; }
  .shared-banner .pill { margin-left: auto; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500;
    color: var(--accent); background: color-mix(in oklab, var(--accent) var(--tint), transparent);
    border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line)); }

}

/* Context bar (#542) */
@layer components {
  .context { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 22px; }
  :is(.context .chip, .filters-btn) { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; box-sizing: border-box; padding: 0 10px 0 12px;
    border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink);
    font: inherit; font-size: 13px; font-weight: 450; text-decoration: none; cursor: pointer; box-shadow: var(--shadow); transition: none; }
  :is(.context .chip, .filters-btn):hover { transform: none; border-color: color-mix(in oklab, var(--ink) 22%, var(--line)); }
  .context .chip span { color: var(--muted); }
  :is(.context .chip, .filters-btn) .icon { width: 14px; height: 14px; color: var(--muted); }
  .context .chip .chev { font-size: 12.5px; }
  .context .chip:has(+ .pop:popover-open) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent); }
  .context .chip.is-off { box-shadow: none; background: transparent; border-style: dashed; color: var(--muted); }
  .context .pop { width: min(340px, calc(100vw - 32px)); box-sizing: border-box; padding: 14px; border: 1px solid var(--line); border-radius: var(--r);
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 12px 32px -12px color-mix(in oklab, var(--ink) 30%, transparent); }
  :is(.context .pop, .sheet) form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
  :is(.context .pop, .sheet) h3 { margin: 0; font-size: 12.5px; font-weight: 550; color: var(--muted); letter-spacing: 0; }
  :is(.context .pop, .sheet) p { margin: 0; }
  :is(.context, .sheet) .seg { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; margin: 0; padding: 3px; border: 0;
    border-radius: 10px; background: var(--line-2); }
  :is(.context, .sheet) .seg label { position: relative; display: grid; place-items: center; min-height: 32px; padding: 0 6px; border-radius: 8px;
    font-size: 12.5px; color: var(--ink-2); cursor: pointer; text-align: center; }
  :is(.context, .sheet) .seg label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: var(--shadow); }
  :is(.context, .sheet) .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
  :is(.context, .sheet) .seg input { position: absolute; opacity: 0; pointer-events: none; }
  :is(.context, .sheet) .range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  :is(.context, .sheet) .field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
  :is(.context, .sheet) .field :is(input, select) { height: auto; min-height: 34px; width: 100%; font-size: 13px; }
  :is(.context, .sheet) .pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
  :is(.context, .sheet) .pop-foot button { padding: 6px 14px; font-size: 13px; background: var(--accent); color: var(--on-accent); }
  :is(.context, .sheet) .pop-foot button:hover { transform: none; }
  /* Each chip anchors its own popover (ids: the CSP forbids style=). */
  #ctx-period-btn { anchor-name: --ctx-period; }
  #ctx-env-btn { anchor-name: --ctx-env; }
  #ctx-role-btn { anchor-name: --ctx-role; }
  #ctx-release-btn { anchor-name: --ctx-release; }
  #ctx-period { position-anchor: --ctx-period; }
  #ctx-env { position-anchor: --ctx-env; }
  #ctx-role { position-anchor: --ctx-role; }
  #ctx-release { position-anchor: --ctx-release; }
  /* Without anchor positioning the popover keeps its centred top-layer place. */
  @supports (position-area: block-end) {
    .context .pop { inset: auto; margin: 8px 0 0; position-area: block-end span-inline-end; position-try-fallbacks: flip-inline; }
  }
}

/* Tables and empty states (#544) */
@layer components {
  /* Refine bar: the page's own filters, one form, one submit. */
  .card.refine { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; padding: 12px; margin: 0 0 8px; }
  .refine label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; max-width: 200px; font-size: 12.5px; color: var(--muted); }
  .refine label.check { flex-direction: row; align-items: center; flex: 0 1 auto; max-width: none; min-height: 34px; }
  .refine select, .refine input[type=text] { width: 100%; min-height: 34px; font-size: 13px; }
  .refine button[type=submit] { margin-left: auto; }
  .active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
  .active-filters strong { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; }
  .active-filters a { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 8px 0 10px; border-radius: var(--r-pill);
    background: var(--line-2); color: var(--ink-2); text-decoration: none; }
  .active-filters a:hover { background: var(--line); text-decoration: none; }

  /* Data table: one card, sticky header, day groups, a pager. */
  .card.table-card { padding: 0; overflow: hidden; margin-bottom: 16px; }
  .table-card .table-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; padding: 16px 20px 4px; }
  .table-card .table-head h2 { margin: 0; }
  .table-card .table-head a { font-size: 13px; }
  .table-card .scroll { overflow-x: auto; }
  .table-card thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); padding-top: 14px; }
  .table-card td, .table-card tbody th { padding-block: 10px; border-bottom: 0; border-top: 1px solid var(--line-2); vertical-align: top; }
  .table-card td:first-child, .table-card th:first-child { padding-left: 20px; }
  .table-card td:last-child, .table-card th:last-child { padding-right: 20px; }
  .table-card td.when { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
  .table-card tr.group td { padding: 18px 20px 6px; border-top: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
  .table-card tbody tr.group:hover, .table-card tbody tr.group:hover td { background: transparent; }
  .ev { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 8px; border-radius: 6px; max-width: 100%;
    font-family: var(--mono); font-size: 12.5px; font-weight: 500; line-height: 1.3;
    color: var(--tone, var(--ink-2)); background: color-mix(in oklab, var(--tone, var(--ink-2)) 9%, transparent); overflow-wrap: anywhere; }
  .ev .icon { width: 13px; height: 13px; }
  /* In a table, break a long name only between words: `anywhere` lets the
     auto layout shrink the Event column to one letter on a phone. */
  .table-card td .ev { overflow-wrap: break-word; }
  /* A path still breaks anywhere (it has no spaces), but never below a
     readable width. */
  td.path { min-width: 12ch; }
  .ev-view { --tone: var(--info); } .ev-click { --tone: var(--accent); } .ev-error { --tone: var(--bad); }
  .ev-vital { --tone: var(--good); } .ev-identify { --tone: var(--warn); } .ev-other { --tone: var(--ink-2); }
  .path { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
  .pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px;
    border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }

  /* Empty state: the reason, what fills it, one or two actions. */
  .card.empty { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px 22px; align-items: center;
    max-width: none; margin-bottom: 16px; padding: 28px; }
  .card.empty .art { width: 96px; height: 72px; color: var(--muted); }
  .card.empty h2 { margin: 0; font-size: var(--step-2); }
  .card.empty p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
  .card.empty pre { margin: 12px 0 0; max-width: 70ch; }
  .card.empty .actions { margin-top: 16px; }
  @media (max-width: 640px) { .card.empty { grid-template-columns: minmax(0, 1fr); } }

  /* Live: the refresh pill; the dot is grey when nothing is happening. */
  .topbar .signal.refresh { margin-left: auto; gap: 8px; }
  .live-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--good);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--good) 18%, transparent); }
  .live-dot.off { background: var(--muted); box-shadow: none; }
}

/* Settings and forms (#546) */
@layer components {
  /* Setup steps: numbered, ticked when done, one action when not. */
  .card.setup { padding: 0; }
  .setup-head { display: flex; flex-direction: column; gap: 10px; padding: 18px 22px 14px; }
  :is(.setup, .form-card) .section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
  :is(.setup, .form-card) .section-head h2 { margin: 0; font-size: var(--step-2); }
  :is(.setup, .form-card) .section-head p { margin: 0; color: var(--muted); font-size: 13px; }
  .setup .section-head .num { font-size: 13px; }
  svg.progress { display: block; width: 100%; height: 6px; border-radius: var(--r-pill); overflow: hidden; }
  svg.progress .track { fill: var(--line-2); }
  svg.progress .bar { fill: var(--accent); }
  .steps { display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
  .steps .step { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; padding: 16px 22px;
    background: none; border: 0; border-radius: 0; font-size: var(--step-0); font-weight: 400; color: var(--ink); }
  .steps .step + .step { border-top: 1px solid var(--line-2); }
  .steps .state { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--line);
    color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .steps .state .icon { width: 18px; height: 18px; vertical-align: 0; }
  .steps .step.done .state { border: 0; background: color-mix(in oklab, var(--good) 14%, transparent); color: var(--good); }
  .steps .step.todo .state { border: 1.5px solid var(--accent); color: var(--accent); }
  .steps .step.next { background: color-mix(in oklab, var(--accent) 5%, transparent); }
  .steps .step.next .state { background: color-mix(in oklab, var(--accent) 14%, transparent); }
  .steps .step.you .state { border-color: var(--sun); color: var(--sun); background: color-mix(in oklab, var(--sun) 12%, transparent); }
  /* #857: the steps, and what the agent does beside them (under on a phone). */
  .setup-grid { display: grid; gap: 16px; align-items: start; margin-bottom: 16px; }
  .setup-grid > .card { grid-column: auto; margin: 0; }
  @media (min-width: 900px) { .setup-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
  .setup-done { padding: 16px 22px; border-top: 1px solid var(--line-2); }
  .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
  .choice { display: grid; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r); color: inherit; }
  .choice:is(:hover, :focus-visible) { text-decoration: none; border-color: var(--accent); }
  .choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .choice-icon { width: 40px; height: 40px; border-radius: var(--r); display: grid; place-items: center; background: color-mix(in oklab, var(--accent) 12%, transparent); }
  .choice-icon .icon { width: 24px; height: 24px; color: var(--accent); }
  .steps .step b { font-weight: 550; }
  .steps .step p { margin: 2px 0 0; color: var(--muted); font-size: var(--step--1); }
  .steps .step.done b { color: var(--muted); font-weight: 500; text-decoration: line-through; text-decoration-color: var(--line); }
  .steps details { border-top: 1px solid var(--line-2); }
  .steps .step + details { border-top: 1px solid var(--line-2); }
  .steps details > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 14px 22px; font-size: 13px; font-weight: 500; }
  .steps details > summary span { color: var(--muted); font-weight: 400; }
  @media (max-width: 640px) {
    .setup-head, .steps .step, .steps details > summary { padding-inline: 16px; }
    .steps .step { grid-template-columns: 36px minmax(0, 1fr); }
    .steps .step > :last-child { grid-column: 2; justify-self: start; }
  }

  /* Get started (#777): the compact line atop the projects and the board. */
  .get-started-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 16px; padding: 10px 16px; color: var(--ink); text-decoration: none; }
  .get-started-line svg.progress { flex: 1 1 120px; max-width: 220px; }
  .agent-blocks h3 { margin: 18px 0 6px; font-size: var(--step-0); }

  .form-card.danger { border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); }

  /* Form card: the form is the card; fields in a grid, help under each. */
  .form-card, .form-body { display: flex; flex-direction: column; gap: 18px; margin: 0; }
  .card.form-card { padding: 22px; }
  .form-body { margin-top: 14px; }
  :is(.form-card, .form-body) > p, .form-card details { margin: 0; }
  :is(.form-card, .form-body) fieldset { min-width: 0; margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 12px; }
  :is(.form-card, .form-body) legend { padding: 0; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
  .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px 20px; align-items: start; }
  .copy-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
  .app-hosts { display: grid; gap: 8px; margin: 8px 0 12px; } .app-host { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
  .form-grid > .wide { grid-column: 1 / -1; }
  .form-grid .field { min-width: 0; }
  .form-grid fieldset.field legend { margin-bottom: 6px; font-weight: 500; color: var(--ink); }
  .form-grid .field :is(input:not([type=checkbox], [type=radio]), select) { width: 100%; min-height: 38px; box-sizing: border-box;
    font-size: 14px; }
  .form-card details.models > summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); }
  .form-card details.models[open] > summary { margin-bottom: 14px; }
  .form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line-2); }
  .form-foot p { margin: 0; color: var(--muted); font-size: var(--step--1); }

  /* Segmented control: radio inputs, the checked one raised. */
  :is(.form-card, .form-body) .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 4px; padding: 3px;
    border-radius: 10px; background: var(--line-2); }
  :is(.form-card, .form-body) .seg label { position: relative; display: grid; place-items: center; gap: 6px; min-height: 32px; padding: 4px 8px;
    border-radius: 8px; font-size: 13px; font-weight: 450; color: var(--ink-2); text-align: center; cursor: pointer; }
  :is(.form-card, .form-body) .seg label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: var(--shadow); }
  :is(.form-card, .form-body) .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
  :is(.form-card, .form-body) .seg input { position: absolute; opacity: 0; pointer-events: none; }
  .seg.themes { max-width: 520px; }
  .seg.themes label { padding: 10px 8px; }
  .seg .swatch { display: block; width: 56px; height: 34px; border-radius: 6px; border: 1px solid var(--line); position: relative; overflow: hidden; }
  .seg .swatch::after { content: ""; position: absolute; left: 8px; top: 10px; width: 24px; height: 4px; border-radius: 2px; }
  .seg .swatch.light { background: oklch(97.6% 0.005 85); }
  .seg .swatch.light::after { background: oklch(21% 0.018 285); }
  .seg .swatch.dark { background: oklch(15.5% 0.010 285); }
  .seg .swatch.dark::after { background: oklch(95% 0.006 285); }
  .seg .swatch.auto { background: linear-gradient(135deg, oklch(97.6% 0.005 85) 50%, oklch(15.5% 0.010 285) 50%); }
  .seg .swatch.auto::after { background: var(--accent); }

  /* Switch: a checkbox with role=switch. */
  label.switch { display: flex; align-items: flex-start; gap: 12px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
  label.switch b { display: block; font-weight: 550; }
  label.switch small { display: block; color: var(--muted); font-size: var(--step--1); }
  label.switch input[type=checkbox]:not([role=switch]) { flex: none; margin: 3px 0 0; accent-color: var(--bad); }
  input[role=switch] { appearance: none; flex: none; position: relative; width: 36px; height: 20px;
    margin: 1px 0 0; padding: 0; border: 0; border-radius: var(--r-pill); background: color-mix(in oklab, var(--muted) 45%, var(--line)); cursor: pointer; }
  input[role=switch]::before { content: ""; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px color-mix(in oklab, var(--ink) 25%, transparent); }
  input[role=switch]:checked { background: var(--accent); }
  input[role=switch]:checked::before { left: 18px; }
  input[role=switch]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* Alerts: one row per alert type, its switch and its fields. */
  ul.alert-rows { list-style: none; margin: 0; padding: 0; }
  ul.alert-rows li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px 24px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line-2); }
  ul.alert-rows li:last-child { border-bottom: 1px solid var(--line-2); }
  ul.alert-rows li .form-grid:empty { display: none; }
  ul.alert-rows li:has(input[role=switch]:not(:checked)) .form-grid { opacity: .55; }
  @media (max-width: 760px) { ul.alert-rows li { grid-template-columns: minmax(0, 1fr); } }
}

/* Focus board v2 (#543) */
@layer components {
  .board { display: flex; flex-direction: column; }
  .board .card, .board .card + .card { margin: 0; }
  .board h2, .board h3 { margin: 0; }
  .board .stack { display: flex; flex-direction: column; gap: 14px; }
  .board .pad { padding: 20px 22px; }
  .board .scroll { overflow-x: auto; }

  /* Page head */
  .page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
  .page-head h1 { margin: 0; font-size: var(--step-4); font-weight: 600; line-height: 1.1; letter-spacing: -.03em; }
  .page-head p { margin: 6px 0 0; max-width: 72ch; color: var(--muted); }
  .page-head > div > p:first-of-type { font-size: var(--step-1); }
  .page-head p strong { color: var(--ink); font-weight: 550; }

  /* Eyebrows and tags */
  .eyebrow { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 550; color: var(--muted);
    text-transform: uppercase; letter-spacing: .06em; }
  .board .eyebrow { margin: 0 0 12px; }
  .eyebrow .count { padding: 3px 6px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); letter-spacing: 0;
    font: 500 12.5px/1 var(--mono); }
  .tag { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 9px; border-radius: var(--r-pill);
    font-size: 12.5px; font-weight: 550; color: var(--tone, var(--ink-2));
    background: color-mix(in oklab, var(--tone, var(--ink-2)) var(--tint), transparent); }
  .tag .icon { width: 13px; height: 13px; }
  .tone-bad { --tone: var(--bad); } .tone-warn { --tone: var(--warn); } .tone-good { --tone: var(--good); }
  .tone-info { --tone: var(--info); } .tone-accent { --tone: var(--accent); }
  .tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }

  /* Focus: one lead insight, the rest ranked */
  .focus { container-type: inline-size; }
  .focus-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  @container (width < 860px) { .focus-grid { grid-template-columns: minmax(0, 1fr); } }
  .focus-empty p + p { margin-top: 6px; }
  .rank { font: 600 12.5px/1 var(--mono); color: var(--muted); }
  .card.lead { padding: 24px; display: flex; flex-direction: column; gap: 18px; overflow: visible; }
  .lead-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .lead-text { display: flex; flex-direction: column; gap: 8px; }
  .lead h2 { display: block; font-size: var(--step-3); font-weight: 600; line-height: 1.18; letter-spacing: -.025em; text-wrap: balance; }
  .lead .evidence { margin: 0; color: var(--muted); }
  .compare { display: grid; grid-template-columns: minmax(52px, auto) minmax(0, 1fr) minmax(64px, auto); align-items: center;
    gap: 10px 12px; margin: 0; font-size: 13px; }
  .compare dt { color: var(--muted); font: 12.5px/1.3 var(--mono); }
  .compare dd { margin: 0; }
  .compare svg { display: block; width: 100%; height: 10px; }
  .compare .bg { fill: var(--line-2); }
  .compare .fg { fill: color-mix(in oklab, var(--ink) 30%, var(--line)); }
  .compare .fg.bad { fill: var(--bad); } .compare .fg.good { fill: var(--good); }
  .compare .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
  .compare .v small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
  .next { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--line-2); }
  .next strong { display: block; margin-bottom: 2px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
  .next p { margin: 0; color: var(--ink-2); }
  .next > .icon { color: var(--accent); margin-top: 2px; }
  .card.ranked { padding: 6px; }
  .ranked ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
  .row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 12px; padding: 14px; border-radius: var(--r); }
  .row + .row { border-top: 1px solid var(--line-2); }
  .row:hover { background: var(--raised); }
  .row .rank { padding-top: 3px; }
  .row h3 { font-size: var(--step-1); font-weight: 550; line-height: 1.35; letter-spacing: -.01em; }
  .row .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
  .row .step { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
  .row .step .label { color: var(--muted); }
  .row .links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; font-weight: 500; }
  .row .links a { display: inline-flex; align-items: center; min-height: 24px; }
  .ranked summary { padding: 10px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
  /* A regressed release's lead (#615): its checks by layer, each a mark, a label, from → to. */
  .layers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; }
  .layer { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--raised); }
  .layer h3 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
  .layer .check { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; font-size: 13px; }
  .layer .mark { display: grid; place-items: center; align-self: center; width: 16px; height: 16px; border-radius: 50%; font-size: 12.5px; font-weight: 700;
    line-height: 1; color: var(--surface); background: var(--tone, var(--muted)); }
  .layer .mark .icon { width: 11px; height: 11px; }
  .layer .fromto { white-space: nowrap; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .layer .fromto b { color: var(--tone); font-weight: 600; }

  /* Key numbers: the tile is the link; its definition sits beside it. */
  .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
  .kpi-slot { position: relative; display: flex; min-width: 0; }
  .card.kpi { flex: 1; min-width: 0; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-height: 132px;
    color: var(--ink); text-decoration: none; overflow: visible; }
  a.card.kpi:hover { text-decoration: none; border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }
  a.card.kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .kpi-head { display: flex; align-items: center; min-height: 24px; padding-right: 28px; color: var(--muted); font-size: 13px; }
  .kpi-head .eyebrow { display: block; margin: 0 0 2px; font-size: 12.5px; }
  .kpi-mid { display: flex; align-items: end; justify-content: space-between; gap: 8px; }
  .kpi-value { font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); }
  .kpi-value small { margin-left: 6px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
  .kpi-sub { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
  .kpi-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; margin-top: auto; font-size: 12.5px; color: var(--muted); }
  .delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 550; font-variant-numeric: tabular-nums; }
  .delta.bad { color: var(--bad); } .delta.good { color: var(--good); } .delta.flat { color: var(--muted); }
  .delta .icon { width: 13px; height: 13px; }
  .kpi.is-alert { border-color: color-mix(in oklab, var(--bad) 45%, var(--line)); }
  .kpi.is-alert .kpi-value { color: var(--bad); }
  .kpi-slot > .info { position: absolute; top: 14px; right: 12px; z-index: 1; display: inline-grid; place-items: center;
    width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: help; }
  .kpi-slot > .info:hover { transform: none; background: var(--line-2); color: var(--ink); }
  .kpi-slot > .info .icon { width: 15px; height: 15px; vertical-align: 0; }
  .kpi-pop { width: max-content; max-width: min(300px, calc(100vw - 32px)); padding: 10px 12px; border: 1px solid var(--line);
    border-radius: var(--r-s); background: var(--surface); color: var(--ink); font-size: 12.5px; line-height: 1.45;
    box-shadow: var(--shadow), 0 12px 32px -12px color-mix(in oklab, var(--ink) 30%, transparent); }
  /* Each ⓘ anchors its own popover (ids: the CSP forbids style=). */
  #kpi-active-users-btn { anchor-name: --kpi-active-users; }
  #kpi-active-users { position-anchor: --kpi-active-users; }
  #kpi-tasks-per-session-btn { anchor-name: --kpi-tasks-per-session; }
  #kpi-tasks-per-session { position-anchor: --kpi-tasks-per-session; }
  #kpi-largest-paint-p75-btn { anchor-name: --kpi-largest-paint-p75; }
  #kpi-largest-paint-p75 { position-anchor: --kpi-largest-paint-p75; }
  #kpi-revenue-btn { anchor-name: --kpi-revenue; }
  #kpi-revenue { position-anchor: --kpi-revenue; }
  #kpi-sessions-with-errors-btn { anchor-name: --kpi-sessions-with-errors; }
  #kpi-sessions-with-errors { position-anchor: --kpi-sessions-with-errors; }
  @supports (position-area: block-end) {
    .kpi-pop { inset: auto; margin: 6px 0 0; position-area: block-end span-inline-start; position-try-fallbacks: flip-inline; }
  }

  /* Sections and charts */
  .section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
  .section-head h2 { display: block; font-size: var(--step-2); font-weight: 600; }
  .section-head h2 > .icon { margin-right: 8px; color: var(--muted); }
  .section-head > a { position: relative; z-index: 1; font-size: 13px; }
  .split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
  .split:empty { display: none; }
  .loop-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 0; }
  .loop-item + .loop-item { border-top: 1px solid var(--line-2); }
  .chart { position: relative; z-index: 1; }
  .chart svg { display: block; width: 100%; height: 140px; }
  .chart .b { fill: color-mix(in oklab, var(--accent) 28%, var(--surface)); }
  .chart .b:hover { fill: var(--accent); }
  .chart .b.now { fill: color-mix(in oklab, var(--accent) 14%, var(--surface)); stroke: color-mix(in oklab, var(--accent) 50%, var(--surface));
    stroke-width: 1; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
  .axis { display: flex; margin-top: 8px; color: var(--muted); font: 12.5px/1 var(--mono); }
  .axis span { flex: 1 1 0; min-width: 0; text-align: center; }
  .markers { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; }
  .marker { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
  .marker i { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); rotate: 45deg; }
  .marker.alert i { background: var(--bad); } .marker.change i { background: var(--info); }
  .barcell { display: flex; align-items: center; gap: 10px; min-width: 120px; }
  .barcell svg { flex: 1; display: block; min-width: 60px; height: 6px; }
  .barcell .bg { fill: var(--line-2); } .barcell .fg { fill: var(--accent); }
  .barcell .num { min-width: 3.5em; }
  .rolebar { display: block; } .rolebar rect { fill: var(--accent); } .rolebar .z { fill: var(--bad); }
  .journeys .arrow { color: var(--muted); }

  /* Cohorts: the share printed, the shade by tenths. */
  .heat th.c { text-align: center; }
  .heat td.c { padding: 2px; text-align: center; border-bottom: 0; }
  .heat .hc { display: block; padding: 8px 4px; border-radius: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); }
  .heat .p0 { background: var(--line-2); }
  .heat .p1 { background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
  .heat .p2 { background: color-mix(in oklab, var(--accent) 11%, var(--surface)); }
  .heat .p3 { background: color-mix(in oklab, var(--accent) 17%, var(--surface)); }
  .heat .p4 { background: color-mix(in oklab, var(--accent) 22%, var(--surface)); }
  .heat .p5 { background: color-mix(in oklab, var(--accent) 28%, var(--surface)); }
  .heat .p6 { background: color-mix(in oklab, var(--accent) 33%, var(--surface)); }
  .heat .p7 { background: color-mix(in oklab, var(--accent) 39%, var(--surface)); }
  .heat .p8 { background: color-mix(in oklab, var(--accent) 44%, var(--surface)); }
  .heat .p9 { background: color-mix(in oklab, var(--accent) 50%, var(--surface)); }
  .heat .p10 { background: color-mix(in oklab, var(--accent) 55%, var(--surface)); font-weight: 600; }

  /* Disclosures (Churn, Feature flow's table). */
  .card.disclose { padding: 0; overflow: visible; }
  .disclose summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 18px 22px; }
  .disclose summary::-webkit-details-marker { display: none; }
  .disclose summary h2 { display: block; font-size: var(--step-2); font-weight: 600; }
  .disclose summary > .icon:last-child { margin-left: auto; color: var(--muted); }
  .disclose[open] summary > .icon:last-child { rotate: 180deg; }
  .disclose .body { display: flex; flex-direction: column; gap: 14px; padding: 0 22px 22px; }
  @media (max-width: 640px) {
    .card.lead { padding: 18px; }
    .page-head h1 { font-size: var(--step-3); }
  }
}

/* Motion (#552): CSS only, opacity/transform/colour, never layout; the reduce rule in `utilities` wins. */
@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    :root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.3, 1.4, .5, 1); interpolate-size: allow-keywords; }

    /* Page to page: the sidebar and the top bar stay still, the content fades and rises. */
    @view-transition { navigation: auto; }
    .side { view-transition-name: side; }
    .topbar { view-transition-name: topbar; }
    ::view-transition-old(root) { animation: 140ms var(--ease-out) both vt-out; }
    ::view-transition-new(root) { animation: 240ms var(--ease-out) both vt-in; }
    @keyframes vt-out { to { opacity: 0; } }
    @keyframes vt-in { from { opacity: 0; translate: 0 6px; } }

    /* Control feedback */
    button, .btn, .chip, .side-nav a, .side .switch, .section-tabs a, .me-menu a, .seg label, .row {
      transition: background-color 120ms, border-color 120ms, color 120ms, box-shadow 160ms, opacity 120ms,
                  transform 150ms var(--ease-out), scale 120ms var(--ease-out);
    }
    :is(button, .btn):active { scale: .97; }
    tbody td { transition: background-color 120ms; }
    .chart .b, .spark .bar { transition: fill 120ms; }
    a.stretch .details { transition: opacity 150ms; }

    /* The logo morphs slowly; the board's wait indicators move on their own */
    .blob { animation: morph 8s ease-in-out infinite; }
    /* Setup (#841): a step just done ticks in, the next one breathes, a choice lifts. */
    .steps .step.done .state { animation: tick 360ms var(--ease-spring) both; }
    .steps .step.next .state { animation: breathe 2.4s ease-in-out infinite; }
    .choice { transition: translate 150ms var(--ease-out), border-color 120ms, box-shadow 160ms; }
    .choice:hover { translate: 0 -2px; box-shadow: 0 6px 18px -10px var(--accent); }
    @keyframes tick { from { scale: .3; opacity: 0; } }
    @keyframes breathe { 50% { box-shadow: 0 0 0 5px color-mix(in oklab, var(--accent) 18%, transparent); } }
    @keyframes morph { 50% { border-radius: 58% 42% 37% 63% / 61% 52% 48% 39%; transform: rotate(20deg); } }
    .board-waiting .spinner { animation: ol-spin 0.8s linear infinite; }
    .board-waiting .waiting-bar span { animation: ol-slide 1.4s ease-in-out infinite; }
    @keyframes ol-spin { to { transform: rotate(360deg); } }
    @keyframes ol-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

    /* Linked cards lift a little */
    a.card, .card:has(a.stretch) { transition: translate 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms; }
    a.card:hover, .card:has(a.stretch):hover { translate: 0 -2px; box-shadow: var(--shadow), 0 6px 18px -8px color-mix(in oklab, var(--ink) 18%, transparent); }

    /* Content arrives in order: the page, the board's parts, the focus grid, the numbers */
    main > *, .board > *, .focus-grid > *, .kpis > * { animation: rise 420ms var(--ease-out) both; }
    :is(main, .board) > :nth-child(2) { animation-delay: 40ms; }
    :is(main, .board) > :nth-child(3) { animation-delay: 80ms; }
    :is(main, .board) > :nth-child(4) { animation-delay: 120ms; }
    :is(main, .board) > :nth-child(n+5) { animation-delay: 160ms; }
    .focus-grid > :nth-child(2) { animation-delay: 90ms; }
    .kpis > :nth-child(2) { animation-delay: 40ms; } .kpis > :nth-child(3) { animation-delay: 80ms; }
    .kpis > :nth-child(4) { animation-delay: 120ms; } .kpis > :nth-child(n+5) { animation-delay: 160ms; }
    @keyframes rise { from { opacity: 0; translate: 0 8px; } }

    /* Data draws in: bars grow from their baseline, fills extend, the line draws */
    .chart .b, .spark .bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y 600ms var(--ease-out) both; }
    :is(.chart .b, .spark .bar):nth-child(2) { animation-delay: 20ms; } :is(.chart .b, .spark .bar):nth-child(3) { animation-delay: 40ms; }
    :is(.chart .b, .spark .bar):nth-child(4) { animation-delay: 60ms; } :is(.chart .b, .spark .bar):nth-child(5) { animation-delay: 80ms; }
    :is(.chart .b, .spark .bar):nth-child(6) { animation-delay: 100ms; } :is(.chart .b, .spark .bar):nth-child(7) { animation-delay: 120ms; }
    :is(.chart .b, .spark .bar):nth-child(8) { animation-delay: 140ms; } :is(.chart .b, .spark .bar):nth-child(9) { animation-delay: 160ms; }
    :is(.chart .b, .spark .bar):nth-child(10) { animation-delay: 180ms; } :is(.chart .b, .spark .bar):nth-child(11) { animation-delay: 200ms; }
    :is(.chart .b, .spark .bar):nth-child(12) { animation-delay: 220ms; } :is(.chart .b, .spark .bar):nth-child(13) { animation-delay: 240ms; }
    :is(.chart .b, .spark .bar):nth-child(n+14) { animation-delay: 260ms; }
    @keyframes grow-y { from { scale: 1 0; } }

    .barcell .fg, .compare .fg, .fill rect, svg.progress .bar, svg.budget-meter .fill, .signal .meter .done {
      transform-box: fill-box; transform-origin: left; animation: grow-x 700ms 200ms var(--ease-out) both;
    }
    @keyframes grow-x { from { scale: 0 1; } }

    .heat .hc { animation: fade 500ms var(--ease-out) both; }
    .heat tbody tr:nth-child(2) .hc { animation-delay: 60ms; } .heat tbody tr:nth-child(3) .hc { animation-delay: 120ms; }
    .heat tbody tr:nth-child(4) .hc { animation-delay: 180ms; } .heat tbody tr:nth-child(5) .hc { animation-delay: 240ms; }
    .heat tbody tr:nth-child(n+6) .hc { animation-delay: 300ms; }
    @keyframes fade { from { opacity: 0; } }

    /* Emphasis: the alerting number rings twice, its arrow nudges once */
    .kpi.is-alert { animation: alert-ring 1.6s 600ms var(--ease-out) 2; }
    @keyframes alert-ring {
      0% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in oklab, var(--bad) 35%, transparent); }
      100% { box-shadow: var(--shadow), 0 0 0 10px color-mix(in oklab, var(--bad) 0%, transparent); }
    }
    .kpi .delta .icon { animation: nudge 500ms 650ms var(--ease-spring) both; }
    @keyframes nudge { from { opacity: 0; translate: 0 3px; } }

    /* Popovers (the context chips, the KPI definitions, the user menu) fade and scale in and out */
    [popover] {
      transition: opacity 180ms var(--ease-out), scale 220ms var(--ease-spring), translate 220ms var(--ease-out),
                  display 220ms allow-discrete, overlay 220ms allow-discrete;
    }
    [popover]:not(:popover-open) { opacity: 0; scale: .96; translate: 0 -4px; }
    @starting-style {
      [popover]:popover-open { opacity: 0; scale: .96; translate: 0 -4px; }
    }
    .context .chip + .pop, .kpi-pop { transform-origin: top left; }
    .me-menu[popover] { transform-origin: bottom left; }

    /* Disclosures open smoothly (browsers without ::details-content just snap) */
    :is(.disclose, .steps details)::details-content {
      block-size: 0; overflow: clip;
      transition: block-size 320ms var(--ease-out), content-visibility 320ms allow-discrete;
    }
    :is(.disclose, .steps details)[open]::details-content { block-size: auto; }
    .disclose summary > .icon:last-child { transition: rotate 240ms var(--ease-spring); }

    /* The top bar gains its shadow over the first 64 px of scroll */
    @supports (animation-timeline: scroll()) {
      .topbar { animation: bar-shadow linear both; animation-timeline: scroll(root); animation-range: 0 64px; }
      @keyframes bar-shadow { to { box-shadow: 0 6px 16px -10px color-mix(in oklab, var(--ink) 25%, transparent); } }
    }

    /* Signals: the incident dot and the live dot breathe; the rest stays still */
    .signal.bad .dot { --pulse: var(--bad); animation: breathe 2.4s ease-in-out infinite; }
    .live-dot:not(.off) { --pulse: var(--good); animation: breathe 2.4s ease-in-out infinite; }
    @keyframes breathe { 50% { box-shadow: 0 0 0 6px color-mix(in oklab, var(--pulse) 0%, transparent); } }

    /* Setup: a done step's tick pops once */
    .steps .step.done .state .icon { animation: pop-in 360ms 300ms var(--ease-spring) both; }
    @keyframes pop-in { from { opacity: 0; scale: .6; } }

    /* The ?confirm= dialog (#545) fades in and rises. */
    .scrim { animation: fade 200ms var(--ease-out) both; }
    .scrim > dialog.dialog { animation: dialog-in 260ms var(--ease-spring) both; }
    @keyframes dialog-in { from { opacity: 0; scale: .96; translate: 0 -4px; } }
  }
}

/* Detail pages and danger zones (#545) */
@layer components {
  /* Entity header (Person, Feature page): monogram, title, facts, actions. */
  .entity { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin: 6px 0 20px; }
  .entity .avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 18px; font-weight: 600;
    background: color-mix(in oklab, var(--accent) var(--tint), var(--surface)); color: var(--accent); }
  .entity-main { flex: 1; min-width: min(240px, 100%); display: flex; flex-direction: column; gap: 8px; }
  .entity h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    font-size: var(--step-4); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
  .entity h1 .mono { letter-spacing: -0.02em; }
  .entity h1 .tag { font-size: 12.5px; font-weight: 500; letter-spacing: 0; }
  .entity p { margin: 0; }
  .entity dl.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; font-size: 14px; }
  .entity .facts div { display: flex; flex-direction: column; gap: 2px; }
  .entity .facts dt { font-size: 12.5px; color: var(--muted); }
  .entity .facts dd { margin: 0; font-weight: 550; font-variant-numeric: tabular-nums; }
  .entity .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .entity ~ .kpis, .entity ~ .kpis + * { margin-top: 16px; }

  /* Mini cards: the summary blocks of a detail page. */
  .card.mini { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
  .card.mini h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--step-1); font-weight: 600; }
  .card.mini h2 .icon { color: var(--muted); }
  .card.mini h2 .tag { margin-left: auto; }
  .card.mini ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
  .card.mini p, .card.mini table { margin: 0; font-size: 13px; }
  .card.mini > a { font-size: 13px; font-weight: 500; }
  .empty-line { color: var(--muted); font-size: 13px; }

  /* Danger zone: always the last card of its page. */
  .card.danger { margin-top: 24px; border-color: color-mix(in oklab, var(--bad) 30%, var(--line)); }
  .card.danger > h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; font-size: var(--step-2); font-weight: 600; }
  .card.danger > h2 .icon { color: var(--bad); }
  .card.danger .item { gap: 12px 24px; padding: 16px 0 4px; }
  .card.danger .item + .item { margin-top: 12px; }
  .card.danger .item b { font-weight: 600; }
  .card.danger .item p { margin: 2px 0 0; max-width: 70ch; color: var(--muted); font-size: 13px; }

  /* Confirmation without script: `?confirm=` renders an open dialog. */
  .scrim { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; overflow-y: auto;
    background: color-mix(in oklab, oklch(15% 0.02 285) 45%, transparent); backdrop-filter: blur(2px); }
  .scrim > dialog.dialog { position: static; inset: auto; margin: 0; max-width: none; max-height: none; width: min(460px, 100%);
    display: flex; flex-direction: column; gap: 16px; padding: 24px; border: 1px solid var(--line); border-radius: var(--r-l);
    background: var(--surface); color: var(--ink);
    box-shadow: 0 24px 60px -20px color-mix(in oklab, oklch(15% 0.02 285) 45%, transparent); }
  .dialog h2 { margin: 0; font-size: var(--step-2); font-weight: 600; }
  .dialog p { margin: 0; color: var(--ink-2); }
  .dialog form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
  .dialog .field input { width: 100%; }
  .dialog .actions { justify-content: flex-end; }
}

/* Behaviour screens (#548) */
@layer components {
  /* In-page tabs: the v2 underline tabs. */
  nav.tabs { display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; scrollbar-width: none;
    margin: 0 0 16px; border-bottom: 1px solid var(--line); }
  nav.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
    color: var(--muted); font-size: var(--step-0); font-weight: 500; white-space: nowrap; text-decoration: none; }
  nav.tabs a:hover { color: var(--ink); }
  nav.tabs a[aria-current="page"] { background: none; color: var(--ink); border-bottom-color: var(--ink); }

  /* Bar cells in the Breakdown, Pages and Forms tables. */
  .table-card td.users, .table-card td.views, .table-card td.funnel { min-width: 180px; }
  .table-card td.funnel .fg { fill: color-mix(in oklab, var(--accent) 80%, var(--surface)); }

  /* Pages: Web Vitals as small rated pills. */
  .table-card td.vitals { min-width: 150px; }
  .vital { display: inline-block; padding: 3px 7px; margin: 1px 0; border-radius: var(--r-pill); white-space: nowrap;
    font: 500 12.5px/1.2 var(--mono); color: var(--ink-2);
    background: color-mix(in oklab, currentColor 10%, transparent); }
  .vital.good { color: var(--good); } .vital.warn { color: var(--warn); } .vital.bad { color: var(--bad); }

  /* Forms: the summary line under each form's title. */
  .table-card .table-head .form-sum { flex-basis: 100%; margin: 0; font-size: 13.5px; color: var(--ink-2); }

  /* Heatmap: ranked bars (most clicked elements) and scroll depth. */
  ol.ranked-bars { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
  ol.ranked-bars li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) minmax(140px, 1.2fr); align-items: center; gap: 10px; font-size: 13.5px; }
  ol.ranked-bars li:not(:has(.rank)) { grid-template-columns: minmax(0, 1fr) minmax(140px, 1.2fr); }
  ol.ranked-bars .rank { font: 600 12.5px/1 var(--mono); color: var(--muted); }
  ol.ranked-bars .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  ol.ranked-bars .barcell { min-width: 0; }
  .no-replay { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; }

  /* Feature flow: accent tints, --good, --bad. */
  svg.sankey .node.s0 { fill: color-mix(in oklab, var(--accent) 45%, var(--surface)); }
  svg.sankey .node.s1 { fill: color-mix(in oklab, var(--accent) 60%, var(--surface)); }
  svg.sankey .node.s2 { fill: color-mix(in oklab, var(--accent) 74%, var(--surface)); }
  svg.sankey .node.s3 { fill: color-mix(in oklab, var(--accent) 87%, var(--surface)); }
  svg.sankey .node.s4 { fill: var(--accent); }
  svg.sankey .node.ok { fill: var(--good); }
  svg.sankey .node.exit { fill: var(--bad); }
  svg.sankey .ribbon { fill: color-mix(in oklab, var(--accent) 20%, transparent); }
  svg.sankey .ribbon:hover { fill: color-mix(in oklab, var(--accent) 42%, transparent); }
  .flow-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; }
  .flow-key .key::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px;
    vertical-align: -1px; background: color-mix(in oklab, var(--accent) 60%, var(--surface)); }
  .flow-key .key.ok::before { background: var(--good); }
  .flow-key .key.exit::before { background: var(--bad); }
  .flow-table .scroll { overflow-x: auto; }
  .flow-table table { width: 100%; }
}

/* People screens (#550) */
@layer components {
  .people .notice { margin: 0; }
  .people-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }

  /* Breakdowns: the share as a bar cell, the count after it. */
  table.share-bars { width: 100%; }
  table.share-bars th { max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  table.share-bars td.bar { width: 60%; }
  .table-card td.bar { min-width: 160px; }

  /* Acquisition: what to group by, and which touch, as underlined tabs. */
  .people-tabs { display: flex; flex-wrap: wrap; align-items: end; gap: 4px 28px; border-bottom: 1px solid var(--line); }
  /* The underline tabs come from the Behaviour block; here they sit on the row's own line. */
  .people-tabs nav.tabs { margin: 0; border-bottom: 0; }

  /* Goals: the value now, the progress bar (SVG rects), the forms. */
  .goal .section-head { align-items: center; }
  .goal-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
  .goal-now .kpi-value { font-size: 26px; }
  .goal-now strong { color: var(--ink); font-weight: 550; }
  .goal-progress { display: flex; flex-direction: column; gap: 6px; }
  .goal .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .goal .actions form { margin: 0; }
  .goal-choices { display: flex; flex-direction: column; gap: 8px; }
  .goal-choice { border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
  .goal-choice[open] { border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }
  .goal-choice summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-height: 44px; padding: 10px 14px; cursor: pointer; }
  .goal-choice form { display: flex; flex-direction: column; gap: 16px; padding: 4px 14px 14px; }

  /* Churn: the at-risk exports and the win-back form. */
  .people .table-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .people .table-card form.inline { margin: 0; }

  /* Each ⓘ anchors its own popover (ids: the CSP forbids style=). */
  #kpi-churn-rate-btn { anchor-name: --kpi-churn-rate; }
  #kpi-churn-rate { position-anchor: --kpi-churn-rate; }
  #kpi-net-change-btn { anchor-name: --kpi-net-change; }
  #kpi-net-change { position-anchor: --kpi-net-change; }
  #kpi-at-risk-now-btn { anchor-name: --kpi-at-risk-now; }
  #kpi-at-risk-now { position-anchor: --kpi-at-risk-now; }
  #kpi-median-lifetime-btn { anchor-name: --kpi-median-lifetime; }
  #kpi-median-lifetime { position-anchor: --kpi-median-lifetime; }
  #kpi-reached-value-btn { anchor-name: --kpi-reached-value; }
  #kpi-reached-value { position-anchor: --kpi-reached-value; }
  #kpi-came-back-btn { anchor-name: --kpi-came-back; }
  #kpi-came-back { position-anchor: --kpi-came-back; }
}

/* Quality and Live screens (#549) */
@layer components {
  /* Uptime: one big status line, the word next to a coloured dot. */
  .state-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 8px 0 4px;
    font-size: var(--step-3); font-weight: 600; letter-spacing: -.02em; color: var(--tone, var(--muted)); }
  .state-line.good { --tone: var(--good); } .state-line.bad { --tone: var(--bad); } .state-line.warn { --tone: var(--warn); }
  .state-line .state-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--tone, var(--muted));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--tone, var(--muted)) 18%, transparent); }
  .state-line .since { font-size: var(--step-0); font-weight: 400; letter-spacing: 0; color: var(--muted); }
  .card.setup { margin-bottom: 16px; }

  /* Tables of these screens: tags and small buttons in cells. */
  .table-card td .tag { white-space: nowrap; }
  .table-card td .delta { font-size: 12.5px; }
  .table-card ul.reasons { list-style: none; margin: 6px 0 0; padding: 0; color: var(--muted); font-size: 12.5px; max-width: 44ch; }
  .table-card ul.reasons li + li { margin-top: 2px; }
  .table-card form.inline { margin: 0; }
  .plain-list .tag { min-height: 20px; padding: 0 7px; font-size: 12.5px; }

  /* Ask: each answer a card, the question a form card. */
  .card.answer-card { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; padding: 20px 22px; }
  .answer-card .q { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
  .answer-card .q h2 { margin: 0; font-size: var(--step-1); font-weight: 600; }
  .answer-card .answer > :first-child { margin-top: 0; }
  .answer-card .answer > :last-child { margin-bottom: 0; }
  .answer-card .pending { padding: 12px 14px; border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--line)); border-radius: var(--r-s);
    background: color-mix(in oklab, var(--warn) 6%, var(--surface)); }
  .answer-card .pending p { margin: 0 0 8px; }
  .answer-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px;
    padding-top: 10px; border-top: 1px solid var(--line-2); }
  .card.form-card.ask-form { margin-bottom: 16px; }
  .ask-form textarea { width: 100%; box-sizing: border-box; min-height: 84px; padding: 8px 10px; border-radius: var(--r-s);
    background: var(--bg); font: inherit; font-size: 14px; resize: vertical; }
  .card.ask-more { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 22px; margin-bottom: 16px; }
  .card.ask-more form { margin: 0; }
}

/* Product and instance screens (#551) */
@layer components {
  /* Feature map: the health score as a lead card, its findings ranked. */
  .map-health { container-type: inline-size; margin: 0 0 16px; }
  .map-health .score { display: flex; align-items: baseline; gap: 6px; margin: 0; }
  .map-health .score strong { font-size: var(--step-4); font-weight: 600; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
  .map-health .score small { color: var(--muted); font-size: var(--step-0); }
  .findings details.fix { margin-top: 8px; }
  .findings details.fix > summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 24px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
  .findings details.fix pre.diff { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

  /* Table cards: a search form or a status in the head. */
  .table-card .table-head form.inline { margin: 0; }
  .table-card td.rollout { min-width: 180px; }
  .table-card td.rollout form.inline { margin: 6px 0 0; }
  .table-card td.path { font-size: 12.5px; }

  /* Surveys: the state and the answer type as tags over the results. */
  .card.survey .section-head h2 { margin: 0; }
  .card.survey .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; font-size: 13px; color: var(--muted); }

  /* Weekly digest: the board's parts, without links. */
  .digest .kpis .card.kpi { min-height: 112px; }
  .digest .card.pad h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: var(--step-2); }

  /* Forms: monospace text areas, ticked lists, the actions under a card. */
  .form-grid .field textarea { width: 100%; box-sizing: border-box; min-height: 120px; }
  .form-grid .field textarea.mono { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
  .form-grid fieldset.field label.check { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; margin-right: 14px; font-weight: 400; }
  form.form-foot { margin: 0; }
  .backup-actions { margin: 0 0 16px; }
  .card.about .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
  .card.about .section-head h2 { margin: 0; }

  /* Message pages (not found, not available): one empty-state card. */
  .card.empty.message { max-width: 760px; margin: 48px auto; }
  .card.empty.message h1 { margin: 0; font-size: var(--step-2); }
}

/* Board fidelity (#588) */
@layer components {
  /* The mockup's rhythm: 32px between parts. */
  .board { gap: 32px; padding-top: 12px; }
  .board > .signals + .page-head { margin-top: -16px; }
  /* The lead and the ranked list, the chart and in flight: equal heights. */
  .board .focus-grid, .board > .split { align-items: stretch; }
  /* Features and funnels: the adoption bar takes the room. */
  table.pulse td.adopt { width: 40%; }
}

/* Events and Person fidelity (#589, #590) */
@layer components {
  /* Events: the page's own filters on one row, the short ones narrower. */
  .refine label.sm { flex-basis: 110px; max-width: 150px; }
}

/* Sign-in, logo and heatmap fidelity (#591, #592) */
@layer components {
  /* The agent's login link under the "or", as on the mockup. */
  .auth-card p.hint { font-size: 13px; line-height: 1.5; }
  .auth-card p.hint code { color: var(--ink); font-size: 12.5px; overflow-wrap: anywhere; }
  /* The logo is the sidebar's blob everywhere the brand shows. */
  .auth-card .brand .blob { width: 22px; height: 22px; }
  /* The Heatmap tab before any page view: one empty card under the picker. */
  .card.empty.heat-empty { margin-top: 16px; }
}

/* Forced colours (#685): mark the current item by a border, not a tint. */
@media (forced-colors: active) {
  .side-nav a[aria-current="page"], .me-menu a[aria-current="page"] { border: 2px solid Highlight; font-weight: 700; }
  .section-tabs a[aria-current="page"] { border-bottom: 3px solid Highlight; text-decoration: underline; }
  .kpi-info:focus-visible { outline: 2px solid Highlight; }
  .kpi-def[popover] { border: 1px solid CanvasText; }
}
