/* Stem wears the box's Ink & Seal tokens, copied verbatim from
   ../box/console/src/ds/tokens.css so the plane looks like family. The brand
   overlay section is left out on purpose: Stem is never white-labelled
   (CHARTER rule 7), so there is nothing for an overlay to do. Fonts fall
   back to the system stacks the tokens already name; Stem self-hosts none. */

/* ============================================================================
   THE CORTEX DESIGN CONSTITUTION — TOKENS · "Ink & Seal"
   ============================================================================
   Ported verbatim from the previous build, where the owner locked it on
   20 July 2026 ("Lets go B"). Decision record 0035: the design system is
   HARVESTED, not designed — this constitution is carried whole; components
   enter the system only after they have shipped on a real surface and passed
   the surface verification protocol. If it is not on /design-system, it is
   not in the system.

   THE CONTRACT
   - Components consume ONLY semantic tokens. Raw ramps (--washi-*, --ink-*,
     --seal-*, --gold-* ...) are theme-private; touching one is a defect.
   - Brand overlays may override COLOUR semantics only - never type, spacing,
     radius, motion, elevation. If a brand needs a structural override, the
     brand is wrong.
   - Light and dark are both first-class; no stored choice means the
     operating system decides.
   - If a token is not in this file, the answer is "no".

   THE IDENTITY - INK & SEAL (Gugen: "to give form; materialise")
   The Gugen mark is a hanko - a vermillion seal, the instrument of trust.
   The interface is calligraphy - warm sumi ink on washi paper (ink-stone and
   lacquer in dark mode) - and the seal vermillion appears in EXACTLY ONE
   ROLE: the stamp on trust surfaces (the audit chain, route verdicts, the
   what-leaves-the-building ledger). Nothing else on screen ever wears it;
   the one sanctioned decorative use is the octagon seal-dot in the wordmark.
   Danger is a deliberate oxblood so a failure never reads as the stamp; gold
   serves warning; moss means "stayed on the box".

   Faces: Sora (display) · Figtree (body) · IBM Plex Mono (data) -
   self-hosted always; a client's browser never calls a font network.
   ========================================================================= */

/* ------- raw ramps (theme-private — components may not touch) ---------- */
:root {
  --washi-0: #faf7f2;    /* paper */
  --washi-50: #f4efe7;
  --washi-100: #ece5d9;
  --washi-200: #e0d8cb;
  --washi-300: #c4b9a8;
  --washi-cream: #ece6da;

  --ink-300: #a3988a;
  --ink-500: #786d5f;  /* 4.7:1 on washi — contrast-audited */
  --ink-700: #3a2f26;
  --ink-800: #2e241c;
  --ink-850: #241f1c;
  --ink-880: #1b1715;
  --ink-900: #1a1614;
  --ink-950: #131010;
  --ink-sumi: #221a14;

  --seal-400: #e5573f;   /* the mark, lifted for dark grounds */
  --seal-500: #d13e2d;   /* measured from the Gugen hanko */
  --seal-600: #c43a28;

  --gold-300: #e0b45c;
  --gold-600: #a3761c;

  --moss-300: #9cc48f;
  --moss-600: #43773f;
  --oxblood-300: #ef8f86;
  --oxblood-600: #93312c;
  --slate-300: #8fa9d6;
  --slate-600: #46628e;
  --plum-300: #b78aaf;
  --plum-600: #7d5875;
}

/* ------- semantic tokens — LIGHT (washi) ------------------------------- */
:root {
  color-scheme: light;

  /* The ground moved from washi cream to a pale blue-grey on the owner's
     direction (13 August 2026) — the ink, the seal and every accent stay;
     only the paper cooled. */
  --bg: #f2f4f7;
  --bg-sunken: #ebeef3;
  --panel: #fcfdfe;
  --panel-2: #f1f3f7;
  --border: #dfe4eb;
  --border-strong: #c3cbd6;
  --text: var(--ink-sumi);
  /* Darkened from #6e7582 (measured 4.21:1 carrying 11–12px captions) to
     clear small-text contrast — decision 0079. */
  --muted: #5f6774;

  /* the ink — calm, monochrome interaction */
  --primary: var(--ink-800);
  --primary-hover: #17100b;
  --primary-fg: #fcfdfe;
  --primary-tint: #e8ecf2;

  /* the seal — trust surfaces ONLY */
  --trust: var(--seal-600);
  --trust-tint: #f9e5e0;

  --route-local: var(--moss-600);        /* "stayed on the box" */
  --route-local-tint: #e6efe0;
  --route-external: var(--seal-600);     /* "left — audited": stamped */
  --route-external-tint: var(--trust-tint);

  --success: var(--moss-600);
  --success-tint: #e6efe0;
  --warning: var(--gold-600);
  --warning-tint: #f5edd8;
  --danger: var(--oxblood-600);          /* oxblood — never the seal */
  --danger-tint: #f6e2e0;
  --info: var(--slate-600);
  --info-tint: #e6ebf4;

  /* Each accent in two cuts (decision 0079): the plain role paints bars,
     dots and grounds; the -text cut carries WORDS, dark enough for small
     mono type on its tint. Measured before the split: gold on its tint
     3.48:1 at 10px, moss chips at exactly 4.50:1, seal on trust-tint
     4.35:1 — the provenance colours were the least legible text on
     screen, on the product whose argument they carry. */
  --trust-text: #b03222;
  --route-local-text: #3a6836;
  --success-text: #3a6836;
  --warning-text: #7c590f;
  --danger-text: var(--oxblood-600);
  --info-text: #415c86;

  --ring: color-mix(in srgb, var(--ink-700) 45%, transparent);
  --shadow-1: 0 1px 2px rgb(30 36 46 / 0.06);
  --shadow-2: 0 2px 8px rgb(30 36 46 / 0.08), 0 1px 2px rgb(30 36 46 / 0.05);
  --shadow-3: 0 12px 32px rgb(30 36 46 / 0.14), 0 2px 8px rgb(30 36 46 / 0.08);
  --scrim: rgb(20 24 32 / 0.42);

  --chart-1: var(--seal-500);
  --chart-2: #b98a2e;
  --chart-3: #6d7f4b;
  --chart-4: var(--slate-600);
  --chart-5: var(--plum-600);
  --chart-6: #8a8071;

  /* agent identity hues (avatars) — warm family, never the seal; monogram
     always washi-light on these grounds */
  --agent-1: #5c6e48;  --agent-2: #8a6d2f;  --agent-3: #4f6a8f;
  --agent-4: #7d5875;  --agent-5: #9c5c40;  --agent-6: #4f7a6a;
  --agent-7: #6b5d8e;  --agent-8: #756a5c;
  --agent-fg: #faf7f2;
}

/* ------- semantic tokens — DARK (ink-stone & lacquer) ------------------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: var(--ink-950);
  --bg-sunken: var(--ink-900);
  /* Lifted (decision 0079): panels measured 1.06:1 against the ground and
     borders 1.33:1 against panels — cards dissolved into one field. The
     ladder now clears 1.15:1 and 1.6:1 — values set by measurement
     against the protocol's own floors, not by eye. */
  --panel: #262019;
  --panel-2: #2e2720;
  --border: #4a4238;
  --border-strong: #5d5347;
  --text: var(--washi-cream);
  --muted: var(--ink-300);

  /* light parchment ink on lacquer */
  --primary: #e6ddcd;
  --primary-hover: #f7f1e4;
  --primary-fg: var(--ink-sumi);
  --primary-tint: rgb(230 221 205 / 0.11);

  --trust: var(--seal-400);
  --trust-tint: rgb(229 87 63 / 0.14);

  --route-local: var(--moss-300);
  --route-local-tint: rgb(156 196 143 / 0.12);
  --route-external: var(--seal-400);
  --route-external-tint: var(--trust-tint);

  --success: var(--moss-300);
  --success-tint: rgb(156 196 143 / 0.12);
  --warning: var(--gold-300);
  --warning-tint: rgb(224 180 92 / 0.13);
  --danger: var(--oxblood-300);
  --danger-tint: rgb(239 143 134 / 0.13);
  --info: var(--slate-300);
  --info-tint: rgb(143 169 214 / 0.13);

  /* In dark the 300-series already clears 7:1 on its tints, so the -text
     cuts simply follow the plain roles (decision 0079). */
  --trust-text: var(--seal-400);
  --route-local-text: var(--moss-300);
  --success-text: var(--moss-300);
  --warning-text: var(--gold-300);
  --danger-text: var(--oxblood-300);
  --info-text: var(--slate-300);

  --ring: color-mix(in srgb, var(--washi-cream) 40%, transparent);
  /* Drop shadows cannot separate lacquer from lacquer; a hairline top
     highlight does (decision 0079). */
  --shadow-1: inset 0 1px 0 rgb(255 250 240 / 0.04), 0 1px 2px rgb(0 0 0 / 0.45);
  --shadow-2: inset 0 1px 0 rgb(255 250 240 / 0.04), 0 2px 10px rgb(0 0 0 / 0.5);
  --shadow-3: 0 16px 40px rgb(0 0 0 / 0.6);
  --scrim: rgb(0 0 0 / 0.42); /* lighter on lacquer: the answer landing behind a fresh ask stayed visible (decision 0079) */

  --chart-1: var(--seal-400);
  --chart-2: var(--gold-300);
  --chart-3: #a9bf7f;
  --chart-4: var(--slate-300);
  --chart-5: var(--plum-300);
  --chart-6: #8d8578;

  --agent-1: #7e9465;  --agent-2: #bd9c50;  --agent-3: #7593bd;
  --agent-4: #a97fa0;  --agent-5: #c07f5e;  --agent-6: #6fa18d;
  --agent-7: #9587bd;  --agent-8: #99897a;
  --agent-fg: #131010;
}

/* No explicit choice stored → the OS preference decides. Mirrors the dark
   block; an explicit [data-theme] on <html> always wins. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--ink-950);
    --bg-sunken: var(--ink-900);
    --panel: #262019;
    --panel-2: #2e2720;
    --border: #4a4238;
    --border-strong: #5d5347;
    --text: var(--washi-cream);
    --muted: var(--ink-300);
    --primary: #e6ddcd;
    --primary-hover: #f7f1e4;
    --primary-fg: var(--ink-sumi);
    --primary-tint: rgb(230 221 205 / 0.11);
    --trust: var(--seal-400);
    --trust-tint: rgb(229 87 63 / 0.14);
    --route-local: var(--moss-300);
    --route-local-tint: rgb(156 196 143 / 0.12);
    --route-external: var(--seal-400);
    --route-external-tint: var(--trust-tint);
    --success: var(--moss-300);
    --success-tint: rgb(156 196 143 / 0.12);
    --warning: var(--gold-300);
    --warning-tint: rgb(224 180 92 / 0.13);
    --danger: var(--oxblood-300);
    --danger-tint: rgb(239 143 134 / 0.13);
    --info: var(--slate-300);
    --info-tint: rgb(143 169 214 / 0.13);
    --trust-text: var(--seal-400);
    --route-local-text: var(--moss-300);
    --success-text: var(--moss-300);
    --warning-text: var(--gold-300);
    --danger-text: var(--oxblood-300);
    --info-text: var(--slate-300);
    --ring: color-mix(in srgb, var(--washi-cream) 40%, transparent);
    --shadow-1: inset 0 1px 0 rgb(255 250 240 / 0.04), 0 1px 2px rgb(0 0 0 / 0.45);
    --shadow-2: inset 0 1px 0 rgb(255 250 240 / 0.04), 0 2px 10px rgb(0 0 0 / 0.5);
    --shadow-3: 0 16px 40px rgb(0 0 0 / 0.6);
    --scrim: rgb(0 0 0 / 0.42); /* lighter on lacquer: the answer landing behind a fresh ask stayed visible (decision 0079) */
    --chart-1: var(--seal-400);
    --chart-2: var(--gold-300);
    --chart-3: #a9bf7f;
    --chart-4: var(--slate-300);
    --chart-5: var(--plum-300);
    --chart-6: #8d8578;
    --agent-1: #7e9465;  --agent-2: #bd9c50;  --agent-3: #7593bd;
    --agent-4: #a97fa0;  --agent-5: #c07f5e;  --agent-6: #6fa18d;
    --agent-7: #9587bd;  --agent-8: #99897a;
    --agent-fg: #131010;
  }
}

/* ------- type · spacing · radius · motion (IMMUTABLE across brands) ---- */
:root {
  --font-display: "Sora Variable", "Sora", system-ui, sans-serif;
  --font-body: "Figtree Variable", "Figtree", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* THE SEVEN ROLES — nothing else exists, and a raw font-size in a
     component file fails the build (decision 0079). The floor is 11px:
     8–10px uppercase tracked text is where "appliance" quietly becomes
     "dashboard". */
  --text-hero: clamp(30px, 4vw, 44px);     /* Sora 600 — the greeting, a masthead */
  --text-title: clamp(21px, 2.2vw, 27px);  /* Sora 600 — page heads, the big numbers */
  --text-heading: 16px;                    /* card and panel titles, input text */
  --text-reading: 16.5px;                  /* long-form prose — briefs, evidence */
  --text-body: 14px;                       /* the default */
  --text-caption: 12.5px;                  /* provenance, metadata, footers */
  --text-micro: 11px;                      /* mono labels — the floor */
}

/* Studio widths read at armslength-plus: the reading roles step up half a
   size together (decision 0079's still-owed list; the relook measured 14px
   body as undersized on a 34-inch monitor while headings hit their clamp). */
@media (min-width: 1920px) {
  :root {
    --text-heading: 17px;
    --text-reading: 17.5px;
    --text-body: 15px;
    --text-caption: 13.5px;
    --text-micro: 12px;
  }

  --radius-ctl: 8px;    /* buttons, inputs, chips */
  --radius-card: 14px;  /* panels, cards */
  --radius-modal: 18px;
  --radius-full: 999px;

  /* the octagon seal (the hanko's silhouette) — clip-path for the brand
     mark and seal-stamped moments; the ONE sanctioned decorative seal use */
  --octagon: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-micro: 120ms;  /* hover, focus, chip */
  --t-panel: 220ms;  /* panel/modal entrance */
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-micro: 0ms; --t-panel: 0ms; }
}

/* ------- Stem's own components, in the seven type roles ------------------ */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: var(--text-body); line-height: 1.5; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
header.top { display: flex; align-items: baseline; gap: 18px; border-bottom: 1px solid var(--border); padding: 14px 20px; }
header.top .word { font-family: var(--font-display); font-weight: 600; font-size: var(--text-heading); }
header.top .seal { display: inline-block; width: 10px; height: 10px; background: var(--trust); clip-path: var(--octagon); margin-right: 8px; vertical-align: baseline; }
header.top nav a { margin-right: 14px; color: var(--muted); text-decoration: none; font-size: var(--text-caption); }
header.top nav a[aria-current] { color: var(--text); font-weight: 600; }
header.top .who { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-micro); color: var(--muted); }
h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-title); margin: 0 0 6px; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-heading); margin: 22px 0 8px; }
p.lede { color: var(--muted); margin: 0 0 18px; }
table.estate { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
table.estate th { text-align: left; font-family: var(--font-mono); font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
table.estate td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.estate tr:last-child td { border-bottom: 0; }
table.estate a { color: var(--text); font-weight: 600; text-decoration: none; }
table.estate a:not(.button):hover { text-decoration: underline; }
table.estate a.button { font-size: var(--text-caption); padding: 4px 10px; color: var(--primary-fg); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-caption); }
.chip { display: inline-block; font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 700; padding: 1px 8px; border-radius: var(--radius-full); border: 1px solid var(--border); }
.chip.ok { color: var(--success-text); background: var(--success-tint); border-color: transparent; }
.chip.warn { color: var(--warning-text); background: var(--warning-tint); border-color: transparent; }
.chip.bad { color: var(--danger-text); background: var(--danger-tint); border-color: transparent; }
.chip.quiet { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; margin: 12px 0; box-shadow: var(--shadow-1); }
.panel dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.panel dt { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.08em; padding-top: 3px; }
.panel dd { margin: 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-card); }
button, .button { font-family: inherit; font-size: var(--text-body); border-radius: var(--radius-ctl); border: 1px solid var(--border-strong); background: var(--primary); color: var(--primary-fg); padding: 7px 14px; cursor: pointer; }
button[disabled] { opacity: 0.55; cursor: not-allowed; }
input { font-family: inherit; font-size: var(--text-heading); border-radius: var(--radius-ctl); border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); padding: 6px 10px; }
.why { font-size: var(--text-caption); color: var(--muted); }
