/* Appeal site — the whole design system in one hand-written stylesheet.
 *
 * No build step, no framework, no dependency, no icon package, no webfont.
 * Icons are inline SVG rendered by the server and recoloured with
 * `currentColor`.
 *
 * CSP: `style-src 'self'`, `font-src 'self'`, no `unsafe-inline`. Nothing here
 * imports from a remote host or references a remote image.
 *
 * Per-tenant colour arrives as a SERVED stylesheet, `/t/<slug>/theme.css`,
 * loaded after this one, which redefines the accent family:
 *
 *     --accent  --accent-hover  --accent-soft  --accent-line
 *     --accent-text  --text-on-accent  --focus
 *
 * `layout.themeCss()` computes all seven server-side from relative luminance,
 * so a pale tenant accent flips its button text to ink rather than producing
 * white-on-white. The `:root` defaults below exist only so this sheet is
 * correct on its own (the directory and error pages have no tenant).
 *
 * `--surface-0` and `--surface-1` are duplicated as numbers in `layout.js`
 * (THEMES) because the accent family is contrast-checked against them. If
 * either changes here it must change there.
 *
 * Structure:
 *   1. tokens        2. reset + base       3. shell (bar, sidebar, footer)
 *   4. identity      5. status             6. lists and tiles
 *   7. forms         8. buttons            9. feedback
 *  10. dashboard    11. responsive        12. motion
 */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root {
  color-scheme: light;

  /* Spacing: eight steps on a 4px grid. The only values that may appear as
     padding, margin or gap anywhere in this file. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 40px;
  --sp-8: 64px;

  /* Type: six sizes, four weights. Weight carries hierarchy; size stays
     compressed. The root font-size is never set in px. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;

  --lh-xs: 1.4;
  --lh-sm: 1.5;
  --lh-md: 1.6;
  --lh-lg: 1.45;
  --lh-xl: 1.35;
  --lh-2xl: 1.25;

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi: 600;
  --fw-bold: 700;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell,
    "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;

  /* Radius and border. */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;
  --r-squircle: 28%;
  --bw: 1px;
  --bw-strong: 2px;

  /* Layout. */
  --page-w: 46rem;
  --page-w-wide: 72rem;
  --sidebar-w: 15rem;
  --prose-w: 62ch;
  --bar-h: 3.25rem;
  --tap: 44px;

  /* Motion. Every transition sits inside a reduced-motion guard (§12). */
  --dur-fast: 120ms;
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* Surfaces: opaque, so both themes work and no tenant colour bleeds. */
  --surface-0: #f3f4f7;
  --surface-1: #ffffff;
  --surface-2: #e9ebf0;
  --surface-3: #ffffff;

  --line: #dfe2e8;
  --line-strong: #aeb5c1;
  --sheen: linear-gradient(to right, rgba(20, 24, 34, 0.025), rgba(20, 24, 34, 0));

  /* Text: colour tokens, never opacity. */
  --text-1: #171a21;
  --text-2: #3f4653;
  --text-3: #5d6574;

  /* Semantic state: fixed, never tenant-controlled. A state is a `-soft` fill,
     a `-line` border, the saturated colour on text and glyphs, and an `on-`
     colour for the one saturated fill it is allowed (the status pill). Every
     pair was measured: the weakest text/background pair is 4.6:1. */
  --danger: #b3261e;
  --danger-soft: #fbeae8;
  --danger-line: #e9aaa3;
  --on-danger: #ffffff;

  --warn: #7a4f00;
  --warn-soft: #fbf1d9;
  --warn-line: #dcc07a;
  --on-warn: #ffffff;

  --success: #1b6b3a;
  --success-soft: #e3f2e8;
  --success-line: #9fcbb0;
  --on-success: #ffffff;

  --neutral: #4d5665;
  --neutral-soft: #eceff3;
  --neutral-line: #c6ccd6;
  --on-neutral: #ffffff;

  /* Accent defaults. Overwritten wholesale by the tenant sheet. */
  --accent: #2f6fed;
  --accent-hover: #285fcc;
  --accent-soft: #eaf0fd;
  --accent-line: #abc2f7;
  --accent-text: #2a63d4;
  --text-on-accent: #ffffff;
  --focus: #2f6fed;

  --shadow-pop: 0 6px 20px rgba(15, 20, 30, 0.14), 0 1px 3px rgba(15, 20, 30, 0.08);
  --shadow-modal: 0 18px 48px rgba(15, 20, 30, 0.22), 0 2px 6px rgba(15, 20, 30, 0.1);
  --glow: radial-gradient(60rem 12rem at 0% -40%, var(--accent-soft), transparent 70%);
}

/* Dark: a separate palette, not the light one with backgrounds swapped. The
   semantic FOREGROUNDS invert too — a dark red on a dark tint reads at ~2.6:1,
   which is the bug this avoids. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface-0: #0f1115;
    --surface-1: #171a20;
    --surface-2: #20242c;
    --surface-3: #272c35;

    --line: #2a2f39;
    --line-strong: #4b525f;
    --sheen: linear-gradient(to right, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));

    --text-1: #e9ecf1;
    --text-2: #bfc6d1;
    --text-3: #97a0ae;

    --danger: #ff9b8f;
    --danger-soft: #2c1613;
    --danger-line: #6e2f28;
    --on-danger: #12151b;

    --warn: #f0c060;
    --warn-soft: #2a2112;
    --warn-line: #6b5320;
    --on-warn: #12151b;

    --success: #7fd39b;
    --success-soft: #12261a;
    --success-line: #2b5c3b;
    --on-success: #12151b;

    --neutral: #aeb6c3;
    --neutral-soft: #1f232b;
    --neutral-line: #3a404b;
    --on-neutral: #12151b;

    --accent-hover: #4d84f0;
    --accent-soft: #1b2436;
    --accent-line: #2c4a86;
    --accent-text: #7ea6f5;
    --focus: #6f9cf4;

    --shadow-pop: 0 6px 20px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-modal: 0 18px 48px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-0: #0f1115;
  --surface-1: #171a20;
  --surface-2: #20242c;
  --surface-3: #272c35;

  --line: #2a2f39;
  --line-strong: #4b525f;
  --sheen: linear-gradient(to right, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));

  --text-1: #e9ecf1;
  --text-2: #bfc6d1;
  --text-3: #97a0ae;

  --danger: #ff9b8f;
  --danger-soft: #2c1613;
  --danger-line: #6e2f28;
  --on-danger: #12151b;

  --warn: #f0c060;
  --warn-soft: #2a2112;
  --warn-line: #6b5320;
  --on-warn: #12151b;

  --success: #7fd39b;
  --success-soft: #12261a;
  --success-line: #2b5c3b;
  --on-success: #12151b;

  --neutral: #aeb6c3;
  --neutral-soft: #1f232b;
  --neutral-line: #3a404b;
  --on-neutral: #12151b;

  --accent-hover: #4d84f0;
  --accent-soft: #1b2436;
  --accent-line: #2c4a86;
  --accent-text: #7ea6f5;
  --focus: #6f9cf4;

  --shadow-pop: 0 6px 20px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 18px 48px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Link and ring colours are nudged server-side against `--surface-0` only.
   Card interiors are a little nearer the text; pulling 15% toward `--text-1`
   restores the ratio on every surface for any accent. */
:root {
  --link: var(--accent-text);
  --ring: var(--focus);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --link: color-mix(in srgb, var(--accent-text) 85%, var(--text-1));
    --ring: color-mix(in srgb, var(--focus) 85%, var(--text-1));
  }
}

/* ==========================================================================
   2. Reset and base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-md);
  color: var(--text-1);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
fieldset,
blockquote,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

fieldset {
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--text-1);
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

pre {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

strong {
  font-weight: var(--fw-semi);
}

h1 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-2xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

h2 {
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
  font-weight: var(--fw-semi);
}

h3 {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-medium);
}

:focus-visible {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--text-3);
}

.text-danger {
  color: var(--danger);
}

.eyebrow {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.prose {
  max-width: var(--prose-w);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
}

.inline {
  display: inline;
}

/* ==========================================================================
   3. Shell
   ========================================================================== */

.skip {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-3);
  color: var(--text-1);
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--r-sm);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar-h);
  background: var(--surface-0);
  background-image: var(--glow);
  border-bottom: var(--bw) solid var(--accent-line);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .topbar {
    background-color: color-mix(in srgb, var(--surface-0) 90%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

.topbar-in {
  height: 100%;
  max-width: var(--page-w-wide);
  margin: 0 auto;
  padding: 0 var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.mark {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  color: var(--text-1);
  text-decoration: none;
  font-weight: var(--fw-semi);
}

.mark-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--r-squircle);
  object-fit: cover;
  flex: none;
}

.mark-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
}

.mark-fallback .icon {
  width: 1rem;
  height: 1rem;
}

.mark-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: none;
}

.toplink {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 2.25rem;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
}

.toplink:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.toplink .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.account {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 2.25rem;
  padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  max-width: 12rem;
}

.account-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  flex: none;
}

.account-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Theme switch: a segmented control on three submit buttons. */
.theme-switch {
  display: inline-flex;
  margin-left: var(--sp-2);
}

.theme-set {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-1);
}

.theme-choice {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1.75rem;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.theme-choice .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.theme-choice:hover {
  color: var(--text-1);
}

.theme-choice[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Page column. */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-w);
  margin: 0 auto;
  padding: var(--sp-7) var(--sp-4) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.page:focus {
  outline: none;
}

body.wide .page {
  max-width: var(--page-w-wide);
}

/* Dashboard shell: sidebar + page. */
.shell {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(var(--page-w-wide) + var(--sidebar-w));
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.shell .page {
  margin: 0;
  max-width: none;
}

.sidebar {
  position: sticky;
  top: var(--bar-h);
  max-height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-3) var(--sp-6) var(--sp-4);
  border-right: var(--bw) solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.sidebar-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: 0 var(--sp-2);
}

.sidebar-tenant {
  font-weight: var(--fw-semi);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidenav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sidenav-2 {
  padding-top: var(--sp-3);
  border-top: var(--bw) solid var(--line);
}

.sidenav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 2.5rem;
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: var(--fw-medium);
  text-decoration: none;
}

.sidenav-item .icon {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--text-3);
}

.sidenav-item:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.sidenav-item.on {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.sidenav-item.on .icon {
  color: inherit;
}

.sidenav-item.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: var(--bw-strong);
  border-radius: var(--r-full);
  background: var(--accent);
}

.sidenav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 var(--sp-1);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
}

.sidenav-item.on .count {
  background: var(--accent-line);
  color: var(--text-1);
}

.footer {
  border-top: var(--bw) solid var(--line);
  background: var(--surface-1);
  background-image: var(--sheen);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.footer-in {
  max-width: var(--page-w-wide);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-6);
}

/* Section rhythm: the proximity ladder. */
.section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.section + .section,
.section + .panel,
.panel + .section {
  margin-top: var(--sp-4);
}

.section-note {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: var(--prose-w);
}

.section-more {
  font-size: var(--fs-sm);
}

.section-lead {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* The UA hides [hidden]; our display: grid/flex rules must not win over it. */
[hidden] {
  display: none !important;
}

.unit-select {
  max-width: 9rem;
}

.section-more a,
.side-link a,
.tile-link a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--sp-6);
  font-weight: var(--fw-medium);
}

.section-more .icon,
.side-link .icon,
.tile-link .icon {
  width: 1rem;
  height: 1rem;
}

.crumbs {
  font-size: var(--fs-sm);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--sp-6);
  color: var(--text-3);
  text-decoration: none;
  font-weight: var(--fw-medium);
}

.crumbs a:hover {
  color: var(--text-1);
}

.crumbs .icon {
  width: 1rem;
  height: 1rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.page-head h1 {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.h1-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--text-3);
}

.page-sub {
  color: var(--text-3);
  font-size: var(--fs-sm);
  max-width: var(--prose-w);
}

.page-head-actions {
  flex: none;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.detail-head h1 {
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
}

.case-id {
  font-size: 0.95em;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   4. Identity
   ========================================================================== */

.hero {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  background-image: var(--glow);
}

.hero-icon {
  width: 4rem;
  height: 4rem;
  border-radius: var(--r-squircle);
  object-fit: cover;
  flex: none;
}

.hero-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border: var(--bw) solid var(--accent-line);
  color: var(--accent-text);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
}

.hero-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.hero-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1.5rem;
  padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: var(--lh-xs);
  max-width: 100%;
}

.chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-glyph,
.chip .icon {
  width: 0.875rem;
  height: 0.875rem;
  flex: none;
}

.chip-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
}

.chip-live {
  background: var(--success-soft);
  color: var(--success);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-muted {
  background: var(--neutral-soft);
  color: var(--text-3);
}

.chip-req {
  background: var(--accent-soft);
  border: var(--bw) solid var(--accent-line);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.greeting {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-left: var(--bw-strong) solid var(--accent-line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-1);
  background-image: var(--sheen);
}

.greeting-body {
  color: var(--text-1);
}

/* ==========================================================================
   5. Status
   ========================================================================== */

.panel {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  background-image: var(--sheen);
}

.panel-icon {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral);
  color: var(--on-neutral);
}

.panel-icon .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.panel-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.panel-eyebrow {
  margin-bottom: calc(var(--sp-2) * -1);
}

.panel-title {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-semi);
  overflow-wrap: anywhere;
}

.panel-text {
  color: var(--text-2);
  max-width: var(--prose-w);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.panel-fine {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: var(--prose-w);
  overflow-wrap: anywhere;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.panel-danger {
  background-color: var(--danger-soft);
  border-color: var(--danger-line);
}

.panel-danger .panel-icon {
  background: var(--danger);
  color: var(--on-danger);
}

.panel-danger .panel-title {
  color: var(--danger);
}

.panel-warn {
  background-color: var(--warn-soft);
  border-color: var(--warn-line);
}

.panel-warn .panel-icon {
  background: var(--warn);
  color: var(--on-warn);
}

.panel-warn .panel-title {
  color: var(--warn);
}

.panel-success {
  background-color: var(--success-soft);
  border-color: var(--success-line);
}

.panel-success .panel-icon {
  background: var(--success);
  color: var(--on-success);
}

.panel-success .panel-title {
  color: var(--success);
}

.panel-neutral {
  background-color: var(--neutral-soft);
  border-color: var(--neutral-line);
}

.panel-accent {
  background-color: var(--accent-soft);
  border-color: var(--accent-line);
}

.panel-accent .panel-icon {
  background: var(--accent);
  color: var(--text-on-accent);
}

.panel-quiet {
  background-image: none;
}

.panel-quiet .panel-icon {
  background: var(--surface-2);
  color: var(--text-3);
}

/* Facts: label/value pairs inside a panel or standing alone. */
.facts {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.facts-block {
  padding: var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.fact {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: baseline;
  font-size: var(--fs-sm);
}

.fact-k {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fact-v {
  color: var(--text-1);
  overflow-wrap: anywhere;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}

/* The status chip: saturated fill, glyph, state in words. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1.5rem;
  padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--neutral);
  color: var(--on-neutral);
}

.pill-glyph {
  width: 0.875rem;
  height: 0.875rem;
  flex: none;
  stroke-width: 2.25;
}

.pill-good {
  background: var(--success);
  color: var(--on-success);
}

.pill-bad {
  background: var(--danger);
  color: var(--on-danger);
}

.pill-warn {
  background: var(--warn);
  color: var(--on-warn);
}

.pill-muted {
  background: var(--surface-2);
  color: var(--text-2);
}

/* "How it works" numbered steps. */
.how {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
  max-width: var(--prose-w);
}

.how li {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
}

.how-n {
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}

/* ==========================================================================
   6. Lists and tiles
   ========================================================================== */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.tile {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 3.5rem;
  padding: var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  background-image: var(--sheen);
}

.tile-icon {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-icon .mark-fallback {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.tile-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.tile-title {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
}

/* The whole tile is the hit target. */
.tile-hit {
  color: var(--text-1);
  text-decoration: none;
}

.tile-hit::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.tile-hit:focus-visible {
  outline: none;
}

.tile-hit:focus-visible::after {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 2px;
}

.tile-desc {
  font-size: var(--fs-sm);
  color: var(--text-3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.tile-chips {
  gap: var(--sp-1);
}

.tile-link {
  position: relative;
  z-index: 1;
  font-size: var(--fs-sm);
}

.tile-slot {
  flex: none;
  width: 2.5rem;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--text-3);
}

.tile-slot-wide {
  width: auto;
}

.tile-open:hover {
  background-color: var(--surface-2);
  border-color: var(--line-strong);
}

.tile-open:hover .tile-slot .icon {
  transform: translateX(2px);
}

.tile-good {
  border-left: 3px solid var(--success);
}

.tile-bad {
  border-left: 3px solid var(--danger);
}

.tile-warn {
  border-left: 3px solid var(--warn);
}

.tile-muted .tile-title,
.tile-muted .tile-icon {
  color: var(--text-3);
}

/* Locked: dimmed icon and slot, dashed border, flat surface — the title and
   description keep full contrast so the reason can be read. */
.tile-locked {
  background-image: none;
  border-style: dashed;
}

.tile-locked .tile-icon {
  background: transparent;
  border: var(--bw) dashed var(--line-strong);
  color: var(--text-3);
}

.tile-locked .tile-title {
  color: var(--text-2);
}

.tile-locked .tile-slot {
  color: var(--text-3);
}

.tile-locked .chip-req {
  opacity: 0.7;
}

.lock-notes {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.lock-notes li {
  display: flex;
  gap: var(--sp-1);
  align-items: flex-start;
}

.lock-notes .icon {
  width: 1rem;
  height: 1rem;
  margin-top: 0.2em;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-4);
  border: var(--bw) dashed var(--line);
  border-radius: var(--r-md);
}

.empty-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-2);
}

.empty-icon .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.empty-title {
  font-weight: var(--fw-medium);
}

.empty-text {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 36ch;
}

.empty-action {
  margin-top: var(--sp-2);
}

/* Timeline. */
.timeline {
  display: flex;
  flex-direction: column;
  border-left: var(--bw-strong) solid var(--line);
  margin-left: var(--sp-2);
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-1);
  padding: 0 0 var(--sp-4) var(--sp-5);
}

.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-0.4375rem - 1px);
  top: 0.45rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: var(--r-full);
  background: var(--surface-1);
  border: var(--bw-strong) solid var(--line-strong);
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline-when {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.timeline-what {
  font-size: var(--fs-sm);
  color: var(--text-1);
  overflow-wrap: anywhere;
}

/* ==========================================================================
   7. Forms
   ========================================================================== */

.form-prose,
.form-dense,
.replay {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.form-dense {
  gap: var(--sp-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.field-head {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.field-label {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-medium);
  color: var(--text-1);
  overflow-wrap: anywhere;
}

legend.field-label {
  display: flex;
  float: left;
  width: 100%;
}

legend.field-label + .field-desc-legend {
  clear: both;
  margin-top: calc(var(--sp-2) * -1);
}

.field-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 var(--sp-1);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  align-self: center;
}

.field-desc {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: var(--prose-w);
  overflow-wrap: anywhere;
}

.field-hint {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  color: var(--text-3);
  max-width: var(--prose-w);
}

.req,
.opt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 var(--sp-1);
  border-radius: var(--r-sm);
  align-self: center;
}

.req {
  color: var(--danger);
  background: var(--danger-soft);
}

.opt {
  color: var(--text-3);
  background: var(--surface-2);
}

/* The shared box: input, textarea, select, and the read-back answer. */
.field-box {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3);
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: var(--fs-md);
  line-height: var(--lh-md);
}

textarea.field-box {
  min-height: 7.5rem;
  resize: vertical;
}

select.field-box {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--sp-7);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.field-box-short {
  max-width: 28rem;
}

.field-box.code {
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.field-box:hover {
  border-color: var(--text-3);
}

.field-box:focus {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 0;
  border-color: transparent;
  background: var(--surface-1);
}

.field-box::placeholder {
  color: var(--text-3);
  opacity: 1;
}

.field-box:disabled {
  color: var(--text-3);
  background: var(--surface-1);
  border-style: dashed;
  cursor: not-allowed;
}

.field-invalid .field-box,
.field-box[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 3px 0 0 var(--danger);
}

.answer {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-1);
  border-style: solid;
  border-color: var(--line);
}

.answer-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  white-space: normal;
}

.answer-list li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.answer-list .icon {
  width: 1rem;
  height: 1rem;
  color: var(--success);
}

.field-note {
  padding: var(--sp-4);
  border-left: var(--bw-strong) solid var(--accent-line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-1);
  background-image: var(--sheen);
}

.field-note .field-label {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
}

.note,
.note-body {
  color: var(--text-2);
  max-width: var(--prose-w);
  overflow-wrap: anywhere;
}

.field-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 1.25rem;
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  color: var(--text-3);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  color: var(--danger);
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
}

.field-error:empty {
  display: none;
}

.field-error .icon {
  width: 0.875rem;
  height: 0.875rem;
  margin-top: 0.1em;
}

.field-count {
  flex: none;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.field-count.over {
  color: var(--danger);
  font-weight: var(--fw-semi);
}

/* Checkboxes and radios: a hidden native input, a drawn box, the whole label
   is the hit target. */
.options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.options-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  cursor: pointer;
}

.option:hover {
  background: var(--surface-2);
}

.option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.option-box {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.option-tick {
  width: 0.9rem;
  height: 0.9rem;
  opacity: 0.15;
  stroke-width: 2.5;
}

.option input:checked + .option-box {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.option input:checked + .option-box .option-tick {
  opacity: 1;
}

.option input:focus-visible + .option-box {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 2px;
}

.option:has(input:disabled) {
  cursor: not-allowed;
  color: var(--text-3);
  background: var(--surface-1);
  border-style: dashed;
}

.option-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  overflow-wrap: anywhere;
}

.option-label .icon {
  width: 1rem;
  height: 1rem;
  color: var(--text-3);
}

/* The dense idiom. */
.form-dense .field-label {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.form-dense .field {
  gap: var(--sp-1);
}

.form-dense .field-box {
  min-height: 2.5rem;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
}

.form-dense textarea.field-box {
  min-height: 5rem;
}

.form-dense .option {
  min-height: 2.5rem;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-sm);
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.field-wide {
  grid-column: 1 / -1;
}

.duration-field,
.colour-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.duration-field .field-box,
.colour-field .field-box {
  max-width: 14rem;
}

.unit {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: var(--fw-semi);
}

.swatch {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-sm);
  border: var(--bw) solid var(--line-strong);
  background: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: var(--bw) solid var(--line);
}

.submit-note {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 40ch;
}

.form-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.form-head-icon {
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-head-icon .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.form-meta {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.form-intro {
  white-space: pre-wrap;
}

.withdraw {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
}

.withdraw-text {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: 48ch;
}

/* ==========================================================================
   8. Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-5);
  border: var(--bw) solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.btn-sm {
  min-height: 2.25rem;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-sm);
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--text-on-accent);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface-1);
  color: var(--text-1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-1);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger-line);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-good {
  background: var(--success);
  color: var(--on-success);
}

.btn-good:hover {
  background: var(--success);
  color: var(--on-success);
  filter: brightness(1.08);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text-3);
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

/* Toggle switch on a native checkbox. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.toggle-track {
  position: relative;
  flex: none;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: var(--bw) solid var(--line-strong);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: var(--r-full);
  background: var(--surface-1);
  border: var(--bw) solid var(--line-strong);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-track .toggle-knob {
  left: calc(100% - 1rem - 2px);
  background: var(--text-on-accent);
  border-color: transparent;
}

.toggle input:focus-visible + .toggle-track {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 2px;
}

.toggle:active .toggle-knob {
  width: 1.2rem;
}

.toggle-state::before {
  content: attr(data-off);
}

.toggle input:checked ~ .toggle-state::before {
  content: attr(data-on);
}

.disclosure summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-2);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  list-style: none;
}

.disclosure summary::-webkit-details-marker {
  display: none;
}

.disclosure summary:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.disclosure summary .icon {
  width: 1rem;
  height: 1rem;
}

.disclosure[open] summary {
  margin-bottom: var(--sp-3);
}

/* ==========================================================================
   9. Feedback
   ========================================================================== */

.banner {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bw) solid var(--neutral-line);
  border-radius: var(--r-md);
  background: var(--neutral-soft);
  font-size: var(--fs-sm);
}

.banner-icon {
  flex: none;
  color: var(--neutral);
  margin-top: 0.05em;
}

.banner-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  overflow-wrap: anywhere;
}

.banner-body p {
  color: var(--text-2);
}

.banner-good {
  background: var(--success-soft);
  border-color: var(--success-line);
}

.banner-good .banner-icon {
  color: var(--success);
}

.banner-bad,
.banner-error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.banner-bad .banner-icon,
.banner-error .banner-icon {
  color: var(--danger);
}

.banner-warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
}

.banner-warn .banner-icon {
  color: var(--warn);
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
}

.error-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-icon .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.status-code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.error-page .prose {
  text-align: center;
}

.error-detail {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  color: var(--text-2);
  max-width: 100%;
}

/* ==========================================================================
   10. Dashboard
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: var(--sp-2);
}

.stat a,
.stat-static {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  background-image: var(--sheen);
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--fw-semi);
  min-height: var(--tap);
}

.stat strong {
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.stat a:hover {
  border-color: var(--line-strong);
  background-color: var(--surface-2);
}

.stat.on a {
  border-color: var(--accent-line);
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.stat-failed strong {
  color: var(--danger);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.filter-bar .field {
  flex: 1 1 10rem;
}

.filter-actions {
  display: flex;
  gap: var(--sp-2);
}

.table-wrap {
  overflow-x: auto;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: var(--bw) solid var(--line);
}

.table thead th {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

.row-done td {
  color: var(--text-3);
}

.row-done .pill {
  opacity: 0.75;
}

.row-done:hover td,
.row-done:focus-within td {
  color: var(--text-1);
}

.row-done:hover .pill,
.row-done:focus-within .pill {
  opacity: 1;
}

.row-failed td {
  background: var(--danger-soft);
}

.case-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--sp-6);
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
}

.case-link .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.td-actions {
  text-align: right;
}

.user-ref {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.user-ref .icon {
  width: 1rem;
  height: 1rem;
  color: var(--text-3);
}

.user-ref-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: var(--lh-xs);
}

.user-ref-name {
  font-weight: var(--fw-medium);
}

.user-ref code {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Case review: two columns, context on the right, sticky. */
.review {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: var(--sp-6);
  align-items: start;
}

.review-main,
.review-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  min-width: 0;
}

.review-side {
  position: sticky;
  top: calc(var(--bar-h) + var(--sp-4));
}

.decide {
  padding: var(--sp-4);
  border: var(--bw) solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.decide-actions .btn {
  flex: 1;
}

.claim {
  display: block;
}

/* Moderation case: the evidence the bot captured, shown as text only. */
.evidence-summary {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.evidence-label {
  margin: 0;
}

.evidence-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 24rem;
  overflow-y: auto;
  font-size: var(--fs-sm);
}

.evidence-narrative {
  padding: var(--sp-3) var(--sp-4);
  border-left: var(--bw-strong) solid var(--accent-line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--surface-1);
  white-space: pre-wrap;
  font-size: var(--fs-sm);
}

.evidence-links,
.evidence-signals,
.evidence-reasons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
}

.evidence-links li,
.evidence-reasons li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  overflow-wrap: anywhere;
}

.evidence-links .icon,
.evidence-reasons .icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
}

.evidence-links a {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.evidence-signals li {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.evidence-signal-name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.evidence-signal-detail {
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.evidence-messages {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  list-style: none;
  padding: 0;
}

.evidence-messages li {
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.evidence-messages li.flagged {
  border-color: var(--danger);
}

.case-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.case-link .icon {
  width: 1rem;
  height: 1rem;
}

.case-appeals {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
}

.case-appeals li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.notes {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.notes li {
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.note-meta .icon {
  width: 0.875rem;
  height: 0.875rem;
}

.note-body {
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  color: var(--text-1);
}

.intents {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.intent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  font-size: var(--fs-sm);
}

.intent .field-error {
  flex-basis: 100%;
}

.intent-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.intent-status .icon {
  width: 0.875rem;
  height: 0.875rem;
}

.intent-done .intent-status {
  color: var(--success);
}

.intent-failed .intent-status {
  color: var(--danger);
}

.intent-pending .intent-status,
.intent-claimed .intent-status {
  color: var(--warn);
}

/* Forms manager cards. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--sp-3);
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 12rem;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  background-image: var(--sheen);
  overflow: hidden;
}

.card-hit {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  color: var(--text-1);
  text-decoration: none;
  flex: 1;
}

.card-hit:hover {
  background: var(--surface-2);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.card-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-title {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-medium);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-desc {
  font-size: var(--fs-sm);
  color: var(--text-3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-foot {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: var(--bw) solid var(--line);
}

.card-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Form editor. */
.editor .section {
  padding: var(--sp-5);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  gap: var(--sp-4);
}

.editor .section + .section {
  margin-top: 0;
}

.icon-picker {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.icon-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.icon-choice {
  position: relative;
  cursor: pointer;
}

.icon-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.icon-choice-box {
  width: var(--tap);
  height: var(--tap);
  border: var(--bw) solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-choice:hover .icon-choice-box {
  border-color: var(--text-3);
}

.icon-choice input:checked + .icon-choice-box {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.icon-choice input:focus-visible + .icon-choice-box {
  outline: var(--bw-strong) solid var(--ring);
  outline-offset: 2px;
}

.publish-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: var(--bw) solid var(--success-line);
  border-radius: var(--r-md);
  background: var(--success-soft);
}

.publish-row .section-note {
  color: var(--text-2);
}

.save-bar {
  position: sticky;
  bottom: var(--sp-3);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-3);
  box-shadow: var(--shadow-modal);
}

.save-bar-text {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.save-bar.dirty {
  border-color: var(--accent-line);
}

.save-bar.dirty .save-bar-text {
  color: var(--text-1);
}

/* The structured question editor, built by app.js on top of the JSON. */
.qed {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.qed-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  background-image: var(--sheen);
}

.qed-item.open {
  border-color: var(--accent-line);
}

.qed-grip {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.qed-grip .btn {
  min-height: 1.75rem;
  padding: 0 var(--sp-1);
}

.qed-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.qed-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.qed-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 0;
  background: none;
  padding: var(--sp-1) 0;
  text-align: left;
  cursor: pointer;
}

.qed-summary .eyebrow {
  gap: var(--sp-1);
}

.qed-summary .eyebrow .icon {
  width: 0.875rem;
  height: 0.875rem;
}

.qed-title {
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qed-title:empty::before {
  content: "Untitled question";
  color: var(--text-3);
}

.qed-tools {
  display: flex;
  gap: var(--sp-1);
  flex: none;
}

.qed-tools .btn {
  min-height: 2.25rem;
  padding: 0 var(--sp-2);
}

.qed-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: var(--bw) solid var(--line);
}

.qed-body .field-wide {
  grid-column: 1 / -1;
}

.qed-opts {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.qed-opt {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.qed-opt .field-box {
  flex: 1;
}

.qed-add {
  align-self: flex-start;
}

/* Settings. */
.settings {
  gap: var(--sp-7);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-1);
  overflow: hidden;
}

.settings-group-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2);
  background-image: var(--sheen);
  border-bottom: var(--bw) solid var(--line);
}

.settings-group-head h2 {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
}

.settings-group-head p {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 24rem);
  gap: var(--sp-4) var(--sp-6);
  align-items: start;
  padding: var(--sp-4) var(--sp-5);
  border-top: var(--bw) solid var(--line);
}

.settings-group .option-row:first-of-type,
.settings-group-head + .option-row {
  border-top: 0;
}

.option-row-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.option-row-label {
  font-weight: var(--fw-medium);
  color: var(--text-1);
}

.option-row-help {
  font-size: var(--fs-sm);
  color: var(--text-3);
  max-width: var(--prose-w);
}

.option-row-control {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  justify-content: center;
  min-height: var(--tap);
}

.option-row-control .facts-block {
  padding: var(--sp-3);
}

.danger-zone {
  border-color: var(--danger-line);
}

.danger-zone .settings-group-head {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.danger-zone .settings-group-head h2 {
  color: var(--danger);
}

.editor .option-row {
  padding: var(--sp-3) 0 0;
  border-top: var(--bw) solid var(--line);
}

/* ==========================================================================
   11. Responsive. Two breakpoints: 48rem and 30rem.
   ========================================================================== */

@media (max-width: 48rem) {
  .shell {
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    width: 100%;
    padding: var(--sp-3) var(--sp-4) 0;
    border-right: 0;
    gap: var(--sp-2);
  }

  .sidebar-head {
    display: none;
  }

  .sidenav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-1);
  }

  .sidenav-2 {
    padding-top: 0;
    border-top: 0;
  }

  .sidenav-item {
    min-height: var(--tap);
    padding: 0 var(--sp-3);
    border: var(--bw) solid var(--line);
    background: var(--surface-1);
  }

  .sidenav-item.on::before {
    display: none;
  }

  .sidenav-item.on {
    border-color: var(--accent-line);
  }

  .review {
    grid-template-columns: minmax(0, 1fr);
  }

  .review-side {
    position: static;
    order: -1;
  }

  .option-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .toplink span:not(.sr-only),
  .toplogin span,
  .account-name {
    display: none;
  }

  .toplogin {
    padding: 0 var(--sp-2);
  }

  .toplink {
    padding: 0 var(--sp-2);
  }

  .account {
    padding: 0 var(--sp-1);
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
  }

  .table tr {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: var(--bw) solid var(--line);
    display: grid;
    gap: var(--sp-1);
  }

  .table tr:last-child {
    border-bottom: 0;
  }

  .table td {
    padding: 0;
    border: 0;
    display: flex;
    gap: var(--sp-3);
    align-items: baseline;
  }

  .table td[data-label]::before {
    content: attr(data-label);
    flex: none;
    width: 6rem;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
  }

  .table tbody tr:hover td {
    background: transparent;
  }

  .td-actions {
    text-align: left;
    justify-content: flex-start;
  }
}

@media (max-width: 30rem) {
  :root {
    --sp-7: 28px;
    --sp-8: 40px;
  }

  .page {
    padding-left: var(--sp-3);
    padding-right: var(--sp-3);
  }

  .topbar-in {
    padding: 0 var(--sp-3);
  }

  .theme-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .theme-choice {
    min-width: 2rem;
    justify-content: center;
  }

  .hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-body {
    align-items: center;
  }

  .tile {
    flex-wrap: wrap;
  }

  .tile-body {
    flex-basis: calc(100% - 2.25rem - var(--sp-3));
  }

  /* The trailing slot (chevron / lock) has nowhere to sit once the tile
     wraps; the lock-note already says "locked", so the glyph goes. */
  .tile-slot {
    display: none;
  }

  .fact {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .submit-row,
  .submit-row .actions,
  .decide-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .submit-row .actions .btn,
  .withdraw .btn,
  .empty-action .btn {
    width: 100%;
  }

  .panel {
    padding: var(--sp-4);
    gap: var(--sp-3);
  }

  .grid2,
  .qed-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-box-short {
    max-width: none;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor .section {
    padding: var(--sp-4);
  }

  .save-bar {
    bottom: 0;
    border-radius: var(--r-md) var(--r-md) 0 0;
  }

  .save-bar-text {
    display: none;
  }

  .save-bar .actions,
  .save-bar .btn {
    width: 100%;
  }

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

/* ==========================================================================
   12. Motion — only when the reader has not asked for less.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .toplink,
  .tile-open,
  .sidenav-item,
  .option,
  .option-box,
  .field-box,
  .theme-choice,
  .toggle-track,
  .card-hit,
  .stat a {
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
      color var(--dur-fast) var(--ease);
  }

  .tile-slot .icon,
  .toggle-knob {
    transition: transform var(--dur) var(--ease), left var(--dur) var(--ease), width var(--dur) var(--ease);
  }

  .btn:active {
    transition: transform var(--dur-fast) var(--ease);
  }

  .skip {
    transition: transform var(--dur-fast) var(--ease);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
