/* Base: reset, type, shared marks and controls */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + var(--safe-t) + 12px); }
body { margin: 0; min-height: 100dvh; background: var(--ground); color: var(--ink); font: 400 var(--t-body)/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; overflow-x: clip; }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-color: color-mix(in oklch, currentColor 35%, transparent); text-underline-offset: .18em; }
h1, h2, h3, h4 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -.012em; }
p, ul, ol, dl, figure, blockquote { margin: 0; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--lapis); outline-offset: 3px; border-radius: 4px; }
::selection { background: color-mix(in oklch, var(--lapis) 24%, transparent); }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--f-mono); font-size: .8125rem; letter-spacing: 0; }
.eyebrow { font: 600 .6875rem/1.2 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
code { font: .875em/1.4 var(--f-mono); padding: .1em .35em; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
kbd { font: 600 .75rem/1 var(--f-mono); padding: 3px 6px; border-radius: 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2); }

.skip { position: fixed; left: 12px; top: calc(var(--safe-t) + 8px); z-index: 100; padding: 10px 14px; border-radius: var(--r-sm); background: var(--ink); color: var(--ground);
  font-weight: 600; transform: translateY(-160%); transition: transform var(--d-2) var(--ease-out); }
.skip:focus { transform: none; }

/* ---------- Provenance: pigment in type ---------- */
.flux { --fl: var(--ink-l); --fc: var(--ink-c);
  background: linear-gradient(100deg,
    oklch(var(--fl) var(--fc) calc(var(--h-lapis) + var(--fh))) 0%,
    oklch(var(--fl) var(--fc) calc(var(--h-tyrian) + var(--fh))) 30%,
    oklch(var(--fl) var(--fc) calc(var(--h-madder) + 360 + var(--fh))) 55%,
    oklch(var(--fl) var(--fc) calc(var(--h-viridian) + var(--fh))) 80%,
    oklch(var(--fl) var(--fc) calc(var(--h-lapis) + var(--fh))) 100%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: flux-move calc(var(--beat) * 4) steps(96) infinite, flux-hue calc(var(--beat) * 10) steps(48) infinite alternate; }
/* Pigment drifts slowly, so it steps at about ten frames a second: the same flow at a fraction of the paint cost */
@keyframes flux-move { to { background-position: -220% 0; } }
@keyframes flux-hue { from { --fh: -24; } to { --fh: 24; } }
/* Flowing = model-written, awaiting a person. Still pigment = model-written, accepted. The dotted line carries state when motion is off. */
.prov { text-decoration: underline dotted color-mix(in oklch, var(--ink-2) 60%, transparent); text-underline-offset: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.prov.is-accepted { animation: none; text-decoration: none; }
.pig { background: var(--pigment); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* ---------- Marks ---------- */
/* The model's caret: blinks while it thinks, holds steady while it writes, leaves when done */
.mcaret { display: inline-block; width: 2px; height: 1.15em; margin: 0 1px -.22em; border-radius: 1px; background: linear-gradient(var(--lapis), var(--tyrian)); }
.mcaret.wait { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* The model mark: something the model said. It turns only while the model writes. */
.mm { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--pigment-c); }
.mm.live, .is-live .mm { animation: spin var(--beat) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Reach marks: ○ person only · ◐ model prepares, you confirm · ● model may act */
.reach { display: inline-flex; align-items: center; gap: 6px; font: 600 .6875rem/1 var(--f-mono); color: var(--ink-2); white-space: nowrap; }
.rmark { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.r-none { box-shadow: inset 0 0 0 1.5px var(--ink); }
.r-shared { background: linear-gradient(90deg, var(--tyrian) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--tyrian); }
.r-model { background: var(--pigment-c); }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); border: 0;
  font: 650 var(--t-sub)/1 var(--f-body); text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: transform var(--d-1) var(--ease-out), background var(--d-2), box-shadow var(--d-2), color var(--d-2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--ink); color: var(--ground); }
.btn-lapis { background: var(--lapis); color: var(--on-ink); }
.btn-quiet { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-pill); border: 0; background: transparent; color: inherit;
  -webkit-tap-highlight-color: transparent; transition: background var(--d-2), transform var(--d-1) var(--ease-out); }
.icon-btn:hover { background: color-mix(in oklch, currentColor 8%, transparent); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill);
  padding: 6px 12px; font: 600 .75rem/1 var(--f-mono); color: var(--ink-2); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color var(--d-2), background var(--d-2), color var(--d-2), transform var(--d-1) var(--ease-out); }
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { color: var(--ground); background: var(--ink); border-color: var(--ink); }
.chip:disabled { opacity: .45; cursor: default; transform: none; }

/* Segmented control */
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--r-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.segmented button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: 600 var(--t-foot)/1 var(--f-body);
  transition: background var(--d-2), color var(--d-2), box-shadow var(--d-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--e-1), inset 0 0 0 1px var(--line); }

/* Switch */
.switch { position: relative; width: 52px; height: 32px; flex: none; border: 0; border-radius: var(--r-pill); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background var(--d-2); padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); box-shadow: var(--e-1), 0 2px 6px oklch(0 0 0 / .18);
  transition: transform var(--d-2) var(--ease-spring); }
.switch[aria-checked="true"] { background: var(--lapis); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Fields */
.field { width: 100%; min-height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 0 14px; font: 500 var(--t-callout)/1.3 var(--f-body);
  transition: border-color var(--d-2), box-shadow var(--d-2); }
.field::placeholder { color: var(--ink-3); }
.field:focus { outline: none; border-color: var(--lapis); box-shadow: 0 0 0 4px color-mix(in oklch, var(--lapis) 14%, transparent); }

/* Thin native scrollbars everywhere else */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* Pigment gradient for inline SVG pictograms (stop colours come from tokens) */
.pg-defs .pg0 { stop-color: var(--lapis); } .pg-defs .pg1 { stop-color: var(--tyrian); } .pg-defs .pg2 { stop-color: var(--madder); } .pg-defs .pg3 { stop-color: var(--viridian); }

/* Sleep: CSS motion pauses off-screen, like the canvases */
.offscreen, .offscreen *, .offscreen *::before, .offscreen *::after { animation-play-state: paused !important; }
