/* tera UI kit 1.0.0. Generated by `make ui-kit` from web/ui/src/tokens, base.css and patterns. Do not edit: pkg/uikit's drift test fails on a hand edit. */

@layer tera.tokens, tera.base, tera.patterns, tera.shell;

@layer tera.tokens {

/* ── Tokens: the state palette ──────────────────────────────────────────────
   tera-plugin-dashboard's ADR-003 palette, renamed --wo-* to --tera-* and
   otherwise unchanged (ADR-186 D2 item 1). No style touches it (the dashboard's
   ADR-016 D4).

   Hue carries the attention axis, the MEANING and never the state's name:
   violet is waiting on you (attention, and draft at lower chroma), amber is
   waiting on the system (blocked), red is broken (failed), green is done, blue
   is under way (running), and the two greys are what nobody needs to look at
   (idle nearest the surface, cancelled a clear step from it). Interactive is a
   conversation surface, apart from the lifecycle colours.

   Light is soft tinted fills with dark same-hue text; dark is deep tinted
   fills with near-white same-hue text. Every background has a matched -fg,
   and every value sits inside the sRGB gamut with room to spare: an
   out-of-gamut oklch() is gamut-mapped by the browser to a colour nobody
   measured.

   test/contrast.ts parses THIS FILE and measures every pair; it holds no copy
   of these numbers. The explicit dark block and the system-dark fallback carry
   the same declarations, and test/palette.test.ts holds them equal. */

:root {
  color-scheme: light;

  --tera-surface: oklch(98.4% 0.002 255); /* #f9fafb */
  --tera-surface-fg: oklch(24% 0.014 255);

  --tera-draft: oklch(90% 0.048 308); /* filed, never committed: the quiet half of the family */
  --tera-draft-fg: oklch(33% 0.090 308);

  --tera-idle: oklch(93% 0.008 255); /* scheduled: cool grey, nearest the surface, recedes on purpose */
  --tera-idle-fg: oklch(35% 0.016 255);

  --tera-interactive: oklch(82% 0.085 185);
  --tera-interactive-fg: oklch(27% 0.045 185);
  --tera-interactive-console: oklch(100% 0 0);
  --tera-interactive-console-fg: oklch(24% 0.014 255);

  --tera-running: oklch(85% 0.062 250); /* under way */
  --tera-running-fg: oklch(32% 0.072 250);

  --tera-blocked: oklch(88% 0.085 75); /* waiting on the system */
  --tera-blocked-fg: oklch(34% 0.058 75);

  --tera-attention: oklch(79% 0.115 308); /* waiting on you: the loud half of the family */
  --tera-attention-fg: oklch(28% 0.115 308);

  --tera-done: oklch(88% 0.090 150);
  --tera-done-fg: oklch(33% 0.072 150);

  --tera-failed: oklch(84% 0.070 27); /* its own hue family */
  --tera-failed-fg: oklch(31% 0.100 27);

  --tera-cancelled: oklch(83% 0.006 70); /* cancelled and superseded: do not act */
  --tera-cancelled-fg: oklch(38% 0.012 70);
}

/* Explicit dark: wins whatever the system prefers. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --tera-surface: oklch(17.5% 0.015 255);
  --tera-surface-fg: oklch(93% 0.010 255);

  --tera-draft: oklch(28% 0.060 308);
  --tera-draft-fg: oklch(86% 0.030 308);

  --tera-idle: oklch(24% 0.012 255);
  --tera-idle-fg: oklch(88% 0.010 255);

  --tera-interactive: oklch(32% 0.045 185);
  --tera-interactive-fg: oklch(91% 0.060 185);
  --tera-interactive-console: oklch(38% 0.035 185);
  --tera-interactive-console-fg: oklch(96% 0.015 185);

  --tera-running: oklch(33% 0.075 250);
  --tera-running-fg: oklch(89% 0.040 250);

  --tera-blocked: oklch(34% 0.060 75);
  --tera-blocked-fg: oklch(91% 0.055 75);

  --tera-attention: oklch(37% 0.145 308);
  --tera-attention-fg: oklch(91% 0.042 308);

  --tera-done: oklch(33% 0.075 150);
  --tera-done-fg: oklch(90% 0.065 150);

  --tera-failed: oklch(33% 0.105 27);
  --tera-failed-fg: oklch(90% 0.038 27);

  --tera-cancelled: oklch(34% 0.005 70);
  --tera-cancelled-fg: oklch(79% 0.010 70);
}

/* No scheme chosen: the system decides. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --tera-surface: oklch(17.5% 0.015 255); /* #0c1117 */
    --tera-surface-fg: oklch(93% 0.010 255);

    --tera-draft: oklch(28% 0.060 308);
    --tera-draft-fg: oklch(86% 0.030 308);

    --tera-idle: oklch(24% 0.012 255);
    --tera-idle-fg: oklch(88% 0.010 255);

    --tera-interactive: oklch(32% 0.045 185);
    --tera-interactive-fg: oklch(91% 0.060 185);
    --tera-interactive-console: oklch(38% 0.035 185);
    --tera-interactive-console-fg: oklch(96% 0.015 185);

    --tera-running: oklch(33% 0.075 250);
    --tera-running-fg: oklch(89% 0.040 250);

    --tera-blocked: oklch(34% 0.060 75);
    --tera-blocked-fg: oklch(91% 0.055 75);

    --tera-attention: oklch(37% 0.145 308);
    --tera-attention-fg: oklch(91% 0.042 308);

    --tera-done: oklch(33% 0.075 150);
    --tera-done-fg: oklch(90% 0.065 150);

    --tera-failed: oklch(33% 0.105 27);
    --tera-failed-fg: oklch(90% 0.038 27);

    --tera-cancelled: oklch(34% 0.005 70);
    --tera-cancelled-fg: oklch(79% 0.010 70);
  }
}

/* ── Tokens: classic, and the vocabulary every style declares ───────────────
   The dashboard's ADR-016 chrome tokens with its classic values, renamed to
   --tera-*, and the tokens a page needs that a board did not (ADR-186 D2
   item 1). These are the DEFAULTS, on plain :root, so they apply under any
   style and under none; a style overrides some of them under its own
   data-style selector. Classic overrides nothing, which is why it is also what
   an unknown style renders as.

   Written as references where classic's value IS a palette token, so they
   follow the scheme without a dark copy. The few with a dark value of their
   own carry it in the dark block below, and in the system-dark fallback with
   the same declarations.

   THE VOCABULARY (a style may override any of these, and the surface pair):
     --tera-canvas            the page behind cards and panels
     --tera-raised            what sits on the page: a card, a panel, a dialog, a field
     --tera-rule              a strong rule; classic's is the text colour
     --tera-hairline          a quiet rule inside a card or panel
     --tera-muted             secondary text: a label, an aside, an empty value
     --tera-hover             the wash under a hovered row; translucent, carries no text
     --tera-accent[-fg]       the primary action and a selected control; never a state colour
     --tera-accent-hover      the primary button's hovered fill, away from its label
     --tera-control[-fg]      an unselected segmented control
     --tera-link              a link
     --tera-focus             the focus ring
     --tera-brand             tera's name, in the shell
     --tera-field-border      the edge of a field and a button
     --tera-font-ui, --tera-font-display, --tera-font-mono   the faces
     --tera-meta-font, --tera-meta-style   freshness and other small asides
     --tera-text-xs … --tera-text-xl       the type scale
     --tera-space-1 … --tera-space-12      the spacing scale, 4px steps
     --tera-radius-sm, -md, -lg            corners
     --tera-card-shadow, --tera-pop-shadow  a card's lift, and a popover's
     --tera-stamp-border, -radius, -font    a state label or pill
     --tera-panel-title-size, --tera-panel-head-rule, --tera-panel-head-inset   a side panel's head
     --tera-figure-size       a headline number
     --tera-panel-figure-size a headline number in a side panel's figures, smaller: a
                              panel is narrow, and its figures share one row
     --tera-leader            the rule between a property's label and value

   test/style.test.ts measures every pair here, in every style and scheme. */

:root {
  /* The dashboard's chrome tokens, classic. */
  --tera-canvas: var(--tera-surface);
  --tera-rule: currentColor;
  /* Classic's own blue, never the palette's --tera-running: hue there means a
     state, and the fill must stand at 3:1 against the page (ADR-186 D2
     Amendment 1). */
  --tera-accent: oklch(50% 0.14 252);
  --tera-accent-fg: oklch(98.4% 0.002 255);
  --tera-accent-hover: oklch(45% 0.13 252);
  --tera-control: var(--tera-idle);
  --tera-control-fg: var(--tera-idle-fg);
  /* Mixed from the surface pair, so they follow both schemes and every style
     that sets a surface. test/style.test.ts resolves the mix to measure it. */
  --tera-muted: color-mix(in oklab, var(--tera-surface-fg) 68%, var(--tera-surface));
  --tera-hairline: color-mix(in oklab, var(--tera-surface-fg) 12%, var(--tera-surface));
  --tera-hover: color-mix(in oklab, var(--tera-surface-fg) 6%, transparent);

  --tera-font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tera-font-display: var(--tera-font-ui);
  --tera-meta-font: var(--tera-font-ui);
  --tera-meta-style: normal;
  --tera-card-shadow: 0 0 #0000;
  --tera-stamp-border: 0px;
  --tera-stamp-radius: 9999px;
  --tera-stamp-font: var(--tera-font-ui);
  --tera-panel-title-size: 0.875rem;
  --tera-panel-head-rule: 1px solid var(--tera-rule);
  --tera-panel-head-inset: 0rem;
  --tera-figure-size: 1.875rem;
  --tera-panel-figure-size: 1.0625rem;
  --tera-leader: 0 none;
  --tera-radius-sm: 0.25rem;
  --tera-radius-md: 0.375rem;
  --tera-radius-lg: 0.5rem;

  /* What a page needs that a board did not. */
  --tera-raised: oklch(100% 0 0);
  --tera-link: oklch(48% 0.13 250);
  --tera-focus: oklch(60% 0.15 250);
  --tera-brand: oklch(53% 0.13 252);
  --tera-field-border: color-mix(in oklab, var(--tera-surface-fg) 24%, var(--tera-raised));
  --tera-pop-shadow: 0 12px 32px -8px oklch(20% 0.02 255 / .28), 0 2px 6px oklch(20% 0.02 255 / .10);
  --tera-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tera-text-xs: 11.5px;
  --tera-text-sm: 12.5px;
  --tera-text-md: 14px;
  --tera-text-lg: 17px;
  --tera-text-xl: 22px;

  --tera-space-1: 4px;
  --tera-space-2: 8px;
  --tera-space-3: 12px;
  --tera-space-4: 16px;
  --tera-space-5: 20px;
  --tera-space-6: 24px;
  --tera-space-8: 32px;
  --tera-space-12: 48px;
}

:root[data-theme="dark"] {
  --tera-accent: oklch(53% 0.14 252);
  --tera-accent-fg: oklch(98.4% 0.002 255);
  --tera-accent-hover: oklch(51% 0.14 252);
  --tera-raised: oklch(21% 0.016 255);
  --tera-link: oklch(78% 0.10 250);
  --tera-focus: oklch(72% 0.13 250);
  --tera-brand: oklch(73% 0.12 245);
  --tera-pop-shadow: 0 16px 40px -8px oklch(0% 0 0 / .6), 0 0 0 1px oklch(100% 0 0 / .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --tera-accent: oklch(53% 0.14 252);
    --tera-accent-fg: oklch(98.4% 0.002 255);
    --tera-accent-hover: oklch(51% 0.14 252);
    --tera-raised: oklch(21% 0.016 255);
    --tera-link: oklch(78% 0.10 250);
    --tera-focus: oklch(72% 0.13 250);
    --tera-brand: oklch(73% 0.12 245);
    --tera-pop-shadow: 0 16px 40px -8px oklch(0% 0 0 / .6), 0 0 0 1px oklch(100% 0 0 / .06);
  }
}

/* ── Tokens: paper & ink ────────────────────────────────────────────────────
   The dashboard's ADR-016 "Paper & ink", renamed to --tera-*: warm sheets on
   an ivory desk, serif titles, states printed as ink stamps. Same markup; only
   the tokens differ, and the state palette is not touched.

   Four blocks, and the split is the scheme:
     - scheme-free:   type, shape and ink weight; a card is a sheet in both
     - light:         warm paper
     - dark:          warm charcoal
     - system dark:   the dark block again, for a page that chose no scheme
   The light and dark blocks declare the same names, so the system-dark
   fallback replaces every light value it inherits (test/style.test.ts). */

:root[data-style="paper"] {
  --tera-font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --tera-meta-font: var(--tera-font-display);
  --tera-meta-style: italic;
  /* Print conventions: a state is an ink stamp, a section is ruled off in
     ink, a figure is set large, a property list has dotted leaders. */
  --tera-stamp-border: 1.2px;
  --tera-stamp-radius: 2px;
  --tera-stamp-font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tera-panel-title-size: 1.375rem;
  --tera-panel-head-inset: 1rem;
  --tera-figure-size: 3.5rem;
  --tera-panel-figure-size: 1.80625rem;
  --tera-text-xl: 26px;
  /* Paper is cut, not moulded. */
  --tera-radius-sm: 1px;
  --tera-radius-md: 2px;
  --tera-radius-lg: 2px;
  /* A card is a sheet: what sits on the desk is the surface itself. */
  --tera-raised: var(--tera-surface);
}

:root[data-style="paper"]:not([data-theme="dark"]) {
  --tera-surface: oklch(99.2% 0.007 85); /* a sheet */
  --tera-surface-fg: oklch(26% 0.02 60); /* ink */
  --tera-canvas: oklch(96.4% 0.016 85); /* the desk under the sheets */
  --tera-rule: oklch(85% 0.026 78);
  --tera-accent: oklch(31% 0.03 60);
  --tera-accent-fg: oklch(97% 0.015 85);
  --tera-accent-hover: color-mix(in oklab, var(--tera-accent) 90%, var(--tera-accent-fg));
  --tera-control: oklch(97.2% 0.012 85);
  --tera-control-fg: oklch(38% 0.025 60);
  --tera-hairline: oklch(89% 0.02 80); /* a pencil line, the rule's lighter sibling */
  --tera-link: oklch(42% 0.09 45);
  --tera-field-border: oklch(80% 0.03 78);
  --tera-card-shadow: 0 1px 0 oklch(85% 0.02 80), 0 10px 22px -16px oklch(35% 0.05 70 / .45);
  --tera-panel-head-rule: 2px solid oklch(26% 0.02 60);
  --tera-leader: 1.5px dotted oklch(76% 0.03 75);
}

:root[data-style="paper"][data-theme="dark"] {
  --tera-surface: oklch(22% 0.012 65);
  --tera-surface-fg: oklch(92% 0.018 85);
  --tera-canvas: oklch(18% 0.01 65);
  --tera-rule: oklch(37% 0.018 70);
  --tera-accent: oklch(87% 0.035 85);
  --tera-accent-fg: oklch(22% 0.02 60);
  --tera-accent-hover: color-mix(in oklab, var(--tera-accent) 90%, var(--tera-accent-fg));
  --tera-control: oklch(26% 0.012 65);
  --tera-control-fg: oklch(86% 0.015 85);
  --tera-hairline: oklch(31% 0.015 70);
  --tera-link: oklch(82% 0.07 70);
  --tera-field-border: color-mix(in oklab, var(--tera-surface-fg) 24%, var(--tera-raised));
  --tera-card-shadow: 0 1px 0 oklch(14% 0.01 65), 0 12px 24px -16px oklch(0% 0 0 / .6);
  --tera-panel-head-rule: 2px solid oklch(92% 0.018 85);
  --tera-leader: 1.5px dotted oklch(42% 0.02 70);
}

@media (prefers-color-scheme: dark) {
  :root[data-style="paper"]:not([data-theme]) {
    --tera-surface: oklch(22% 0.012 65);
    --tera-surface-fg: oklch(92% 0.018 85);
    --tera-canvas: oklch(18% 0.01 65);
    --tera-rule: oklch(37% 0.018 70);
    --tera-accent: oklch(87% 0.035 85);
    --tera-accent-fg: oklch(22% 0.02 60);
    --tera-accent-hover: color-mix(in oklab, var(--tera-accent) 90%, var(--tera-accent-fg));
    --tera-control: oklch(26% 0.012 65);
    --tera-control-fg: oklch(86% 0.015 85);
    --tera-hairline: oklch(31% 0.015 70);
    --tera-link: oklch(82% 0.07 70);
    --tera-field-border: color-mix(in oklab, var(--tera-surface-fg) 24%, var(--tera-raised));
    --tera-card-shadow: 0 1px 0 oklch(14% 0.01 65), 0 12px 24px -16px oklch(0% 0 0 / .6);
    --tera-panel-head-rule: 2px solid oklch(92% 0.018 85);
    --tera-leader: 1.5px dotted oklch(42% 0.02 70);
  }
}

}

@layer tera.base {

/* ── Base: native elements ──────────────────────────────────────────────────
   Buttons, fields, checkboxes, tables, links, headings and code, styled at
   zero specificity: every selector here is wholly inside :where(), so an app's
   own CSS always wins without !important (ADR-186 D2 item 2). A button is a
   <button>; its variant is an attribute. No element carries an outer margin:
   the container it sits in spaces it (D3 item 5). The build puts this sheet
   in the `tera.base` cascade layer, under every layer an app declares after
   it and under the app's unlayered CSS.

   EVERY NATIVE CONTROL IS THE KIT'S UNLESS THE APP OPTS IT OUT. The base
   styles draw every button, field, heading, link, table, code and rule,
   whatever classes it carries: `<button class="ml-2">` is the kit's button
   with a margin. An app that draws an element entirely its own way (a
   Tailwind-styled control, a component with its own scoped CSS) marks it,
   or any element around it, `data-tera-unstyled`, and every rule below that
   styles one ends in

     :not([data-tera-unstyled], [data-tera-unstyled] *)

   so that element, and everything inside a marked one, gets exactly what the
   app's classes and its reset say, with no reset of the kit's. The opt-out is
   an attribute rather than a guess from the class list because a class says
   nothing about intent: a layout utility on a kit button must not cost the
   button its look. The page itself (`body`), the box model and the focus ring
   are not gated: they are the kit's on every element. A kit class
   (`tera-button`) keeps the kit's look even inside a marked element, and so
   does every pattern: none leans on a rule here, each drawing its headings,
   buttons, links and fields whole in `tera.patterns` (ADR-186 D3 item 8).

   A link slotted into <tera-shell> takes the shell's look (`.tera-shell-link`,
   or the shell's own `::slotted()` rules), not a link's. */

:where(html) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:where(*, *::before, *::after) { box-sizing: border-box; }
/* `hidden` hides, whatever display a pattern gives the element: the one
   declaration here that is important, so a page toggling it never has to know
   which patterns set display. */
:where([hidden]:not([hidden="until-found"])) { display: none !important; }
:where(body) {
  margin: 0;
  background: var(--tera-canvas);
  color: var(--tera-surface-fg);
  font: 400 var(--tera-text-md)/1.5 var(--tera-font-ui);
  -webkit-font-smoothing: antialiased;
}
:where(:is(h1, h2, h3, h4):not([data-tera-unstyled], [data-tera-unstyled] *)) { margin: 0; font-family: var(--tera-font-display); line-height: 1.25; }
:where(h1:not([data-tera-unstyled], [data-tera-unstyled] *)) { font-size: var(--tera-text-xl); font-weight: 650; letter-spacing: -0.01em; }
:where(h2:not([data-tera-unstyled], [data-tera-unstyled] *)) { font-size: var(--tera-text-lg); font-weight: 650; }
:where(:is(h3, h4):not([data-tera-unstyled], [data-tera-unstyled] *)) { font-size: var(--tera-text-md); font-weight: 650; }
:where(p, figure, blockquote, dl, dd) { margin: 0; }
:where(a:not([data-tera-unstyled], [data-tera-unstyled] *):not(tera-shell > [slot])) { color: var(--tera-link); text-decoration-line: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:where(a:not([data-tera-unstyled], [data-tera-unstyled] *):not(tera-shell > [slot]):hover) { text-decoration-thickness: 2px; }
:where(:is(code, kbd, samp, pre):not([data-tera-unstyled], [data-tera-unstyled] *)) { font-family: var(--tera-font-mono); font-size: 0.92em; }
:where(pre) { margin: 0; overflow: auto; }
:where(kbd:not([data-tera-unstyled], [data-tera-unstyled] *)) {
  padding: 1px 5px;
  border: 1px solid var(--tera-rule); border-bottom-width: 2px; border-radius: var(--tera-radius-sm);
  background: var(--tera-raised);
  font-size: var(--tera-text-xs);
}
:where(hr:not([data-tera-unstyled], [data-tera-unstyled] *)) { margin: 0; border: 0; border-top: 1px solid var(--tera-hairline); }
:where(:focus-visible) { outline: 2px solid var(--tera-focus); outline-offset: 2px; }

/* Buttons: one native element, variants by attribute. At most one primary per view. */
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *), .tera-button) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
  background: var(--tera-raised); color: var(--tera-surface-fg);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *):hover, .tera-button:hover) { background: color-mix(in oklab, var(--tera-raised), var(--tera-surface-fg) 5%); }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *):active, .tera-button:active) { transform: translateY(0.5px); }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="primary"], .tera-button[data-variant="primary"]) {
  background: var(--tera-accent); color: var(--tera-accent-fg); border-color: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tera-accent-fg) 18%, transparent);
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="primary"]:hover, .tera-button[data-variant="primary"]:hover) {
  background: var(--tera-accent-hover);
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="quiet"], .tera-button[data-variant="quiet"]) { background: transparent; border-color: transparent; }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="quiet"]:hover, .tera-button[data-variant="quiet"]:hover) { background: var(--tera-hover); }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="danger"], .tera-button[data-variant="danger"]) {
  background: var(--tera-failed); color: var(--tera-failed-fg); border-color: transparent;
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-variant="danger"]:hover, .tera-button[data-variant="danger"]:hover) {
  background: color-mix(in oklab, var(--tera-failed), var(--tera-failed-fg) 10%);
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-size="sm"], .tera-button[data-size="sm"]) { height: 26px; padding: 0 9px; font-size: var(--tera-text-xs); }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-size="lg"], .tera-button[data-size="lg"]) { height: 40px; padding: 0 18px; font-size: var(--tera-text-md); }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-icon], .tera-button[data-icon]) { width: 32px; padding: 0; }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[data-icon][data-size="sm"], .tera-button[data-icon][data-size="sm"]) { width: 26px; }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *):disabled, button:not([data-tera-unstyled], [data-tera-unstyled] *)[aria-disabled="true"], .tera-button[aria-disabled="true"]) {
  opacity: .5; cursor: not-allowed; transform: none;
}
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[aria-busy="true"], .tera-button[aria-busy="true"]) { cursor: progress; }
:where(button:not([data-tera-unstyled], [data-tera-unstyled] *)[aria-busy="true"], .tera-button[aria-busy="true"])::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: tera-spin .72s linear infinite;
}
@keyframes tera-spin { to { transform: rotate(360deg); } }

/* Fields. */
:where(:is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]), select, textarea):not([data-tera-unstyled], [data-tera-unstyled] *)) {
  width: 100%; min-height: 32px; padding: 6px 10px;
  border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
  background: var(--tera-raised); color: inherit;
  font: 400 var(--tera-text-md)/1.4 var(--tera-font-ui);
}
:where(textarea:not([data-tera-unstyled], [data-tera-unstyled] *)) { min-height: 88px; resize: vertical; }
:where(:is(input, select, textarea):not([data-tera-unstyled], [data-tera-unstyled] *):focus-visible) {
  outline: none; border-color: var(--tera-focus);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--tera-focus) 28%, transparent);
}
:where(:is(input, select, textarea):not([data-tera-unstyled], [data-tera-unstyled] *)[aria-invalid="true"]) { border-color: var(--tera-failed-fg); }
:where(:is(input, textarea):not([data-tera-unstyled], [data-tera-unstyled] *))::placeholder { color: var(--tera-muted); }
:where(input:is([type="checkbox"], [type="radio"]):not([data-tera-unstyled], [data-tera-unstyled] *)) { width: 15px; height: 15px; margin: 0; accent-color: var(--tera-running-fg); }
:where(label:not([data-tera-unstyled], [data-tera-unstyled] *)) { font-weight: 500; }

/* Tables. Sorting, virtualisation and resizing are the app's: a data grid is not in the kit. */
:where(table:not([data-tera-unstyled], [data-tera-unstyled] *)) { width: 100%; border-collapse: collapse; font-size: var(--tera-text-sm); }
:where(th:not([data-tera-unstyled], [data-tera-unstyled] *)) {
  padding: 6px 10px; border-bottom: 1px solid var(--tera-rule);
  text-align: left; font-weight: 600; font-size: var(--tera-text-xs); color: var(--tera-muted);
}
:where(td:not([data-tera-unstyled], [data-tera-unstyled] *)) { padding: 8px 10px; border-bottom: 1px solid var(--tera-hairline); vertical-align: baseline; }
:where(tbody tr:not([data-tera-unstyled], [data-tera-unstyled] *):hover) { background: var(--tera-hover); }

}

@layer tera.patterns {

/* Small text helpers: secondary text, an aside, a screen-reader-only label. */

.tera-muted { color: var(--tera-muted); }
.tera-meta {
  color: var(--tera-muted);
  font-family: var(--tera-meta-font); font-style: var(--tera-meta-style); font-size: var(--tera-text-sm);
}
.tera-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* A tone is one of the state tokens, never a colour of an app's own
   (ADR-186 D3 item 4). `data-tone="<state>"` sets --tone and --tone-fg for the
   element and what is inside it; a pattern reads them. */

[data-tone="draft"]       { --tone: var(--tera-draft);       --tone-fg: var(--tera-draft-fg); }
[data-tone="idle"]        { --tone: var(--tera-idle);        --tone-fg: var(--tera-idle-fg); }
[data-tone="interactive"] { --tone: var(--tera-interactive); --tone-fg: var(--tera-interactive-fg); }
[data-tone="running"]     { --tone: var(--tera-running);     --tone-fg: var(--tera-running-fg); }
[data-tone="blocked"]     { --tone: var(--tera-blocked);     --tone-fg: var(--tera-blocked-fg); }
[data-tone="attention"]   { --tone: var(--tera-attention);   --tone-fg: var(--tera-attention-fg); }
[data-tone="done"]        { --tone: var(--tera-done);        --tone-fg: var(--tera-done-fg); }
[data-tone="failed"]      { --tone: var(--tera-failed);      --tone-fg: var(--tera-failed-fg); }
[data-tone="cancelled"]   { --tone: var(--tera-cancelled);   --tone-fg: var(--tera-cancelled-fg); }

/* The page: a header, then its content, spaced by the page itself. The shell
   sits above it. A page with a side panel is two columns, the main one
   scrolling on its own.

   An app opens and closes its panel by adding and removing the panel and
   `data-with-panel`, never by re-parenting its content: without the
   attribute, `.tera-page-main` is only a column of the page, and with it the
   page fills the viewport under the shell when it is the body's own child. */

.tera-page {
  display: grid; gap: var(--tera-space-6); align-content: start;
  max-width: 1180px; margin-inline: auto;
  padding: var(--tera-space-6) var(--tera-space-6) 120px;
}
.tera-page[data-with-panel] {
  grid-template-columns: minmax(0, 1fr) auto; align-content: stretch;
  max-width: none; height: 100%; min-height: 0; padding: 0 0 0 var(--tera-space-6);
}
.tera-page-main {
  display: grid; gap: var(--tera-space-6); align-content: start;
  min-width: 0; min-height: 0; overflow-y: auto;
  padding: var(--tera-space-6) var(--tera-space-1) 120px 0;
}
.tera-page:not([data-with-panel]) > .tera-page-main { overflow: visible; padding: 0; }
:where(body:has(> .tera-page[data-with-panel])) { display: flex; flex-direction: column; height: 100dvh; }
:where(body) > .tera-page[data-with-panel] { flex: 1 1 0; height: auto; margin-inline: 0; }

/* The header: the title block on the left, the page's actions on the right. */
.tera-page-header { display: flex; align-items: flex-end; gap: var(--tera-space-4); }
.tera-page-title { flex: 1; min-width: 0; display: grid; gap: 6px; }
.tera-page-title > h1 { margin: 0; font: 650 var(--tera-text-xl)/1.25 var(--tera-font-display); letter-spacing: -0.01em; }
.tera-page-title > .tera-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.tera-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--tera-text-sm); color: var(--tera-muted); }
.tera-crumbs > a { color: inherit; text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tera-crumbs > a:hover { color: var(--tera-surface-fg); text-decoration: underline; text-decoration-thickness: 2px; }
.tera-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tera-space-2); }
/* On a phone the actions go under the title block, which keeps the width. */
@media (max-width: 560px) { .tera-page-header { flex-direction: column; align-items: stretch; } }

/* A stack: blocks one above the next, the gap between them the stack's. */
.tera-stack { display: grid; gap: var(--tera-space-4); align-content: start; min-width: 0; }

/* A card: a raised block on the page. Its head is a title and an aside; its
   body spaces what it holds. */

.tera-card {
  min-width: 0;
  background: var(--tera-raised); border: 1px solid var(--tera-hairline);
  border-radius: var(--tera-radius-lg); box-shadow: var(--tera-card-shadow);
}
.tera-card-head { display: flex; align-items: baseline; gap: var(--tera-space-3); padding: 14px var(--tera-space-5) 0; }
.tera-card-head > h2 { margin: 0; font: 650 15px/1.25 var(--tera-font-display); }
.tera-card-head > .tera-aside { margin-left: auto; color: var(--tera-muted); font-size: var(--tera-text-sm); }
.tera-card-body { display: grid; gap: var(--tera-space-3); padding: 10px var(--tera-space-5) var(--tera-space-4); }
.tera-card-body > p.tera-muted { font-size: var(--tera-text-sm); }

/* The action bar: sticky at the foot of the page, the primary action at its
   right. A disabled primary says why beside it, in .tera-why. */

.tera-actionbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--tera-space-3);
  padding: 12px var(--tera-space-5);
  background: color-mix(in oklab, var(--tera-raised) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-lg);
  box-shadow: var(--tera-pop-shadow);
}
.tera-actionbar > .tera-why { margin-left: auto; text-align: right; color: var(--tera-muted); font-size: var(--tera-text-sm); }
.tera-actionbar > .tera-actions { margin-left: auto; }
.tera-actionbar > .tera-why + .tera-actions { margin-left: 0; }

/* The readiness row: what stands between the person and the primary action,
   one column per question, each a label over its value and a note. */

.tera-checklist {
  display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  margin: 0; padding: 0; list-style: none;
}
.tera-checklist > li {
  display: grid; gap: 2px; align-content: start; min-width: 0;
  padding: 2px var(--tera-space-4); border-left: 1px solid var(--tera-hairline);
}
.tera-checklist > li:first-child { padding-left: 0; border-left: 0; }
.tera-check-label { display: flex; align-items: center; gap: 6px; font-size: var(--tera-text-xs); color: var(--tera-muted); }
.tera-check-value { font: 600 15px/1.35 var(--tera-font-display); }
.tera-check-value[data-tone] { color: var(--tone-fg); }
.tera-check-note { font-size: var(--tera-text-xs); color: var(--tera-muted); }

/* On a phone the row is two columns, each pair of questions a row of its own. */
@media (max-width: 560px) {
  .tera-checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--tera-space-3); }
  .tera-checklist > li:nth-child(odd) { padding-left: 0; border-left: 0; }
}

/* A notice: a sentence on a wash of one state token, an icon in its ink, and
   an action at the end when there is one. */

.tera-notice {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 14px; border-radius: var(--tera-radius-md);
  background: color-mix(in oklab, var(--tone, var(--tera-idle)) 55%, var(--tera-raised));
  color: var(--tera-surface-fg);
  font-size: var(--tera-text-sm);
}
.tera-notice > svg { translate: 0 1px; color: var(--tone-fg, var(--tera-idle-fg)); }
.tera-notice > :not(svg):last-child:nth-child(2) { grid-column: 2 / -1; }
.tera-notice[hidden] { display: none; }

/* Toasts: bottom-left, one line each. A toast confirms what already happened. */

.tera-toasts { position: fixed; left: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; }
.tera-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--tera-radius-md);
  background: var(--tera-surface-fg); color: var(--tera-surface);
  font-size: var(--tera-text-sm); box-shadow: var(--tera-pop-shadow);
  animation: tera-rise .18s ease-out;
}
.tera-toast > button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border: 1px solid color-mix(in oklab, var(--tera-surface) 40%, transparent); border-radius: var(--tera-radius-md);
  background: transparent; color: inherit;
  font: 600 var(--tera-text-xs)/1 var(--tera-font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-toast > button[data-icon] { width: 26px; padding: 0; }
.tera-toast > button:hover { background: color-mix(in oklab, var(--tera-surface) 14%, transparent); }
@keyframes tera-rise { from { opacity: 0; transform: translateY(6px); } }

/* An empty state: what is missing and what to do about it. */

.tera-empty-state {
  display: grid; justify-items: center; gap: var(--tera-space-2);
  padding: var(--tera-space-8) var(--tera-space-4);
  text-align: center; color: var(--tera-muted);
}
.tera-empty-state > svg { color: var(--tera-muted); opacity: .7; }
.tera-empty-state > h3 { margin: 0; color: var(--tera-surface-fg); font: 650 var(--tera-text-md)/1.25 var(--tera-font-display); }
.tera-empty-state > p { max-width: 38ch; font-size: var(--tera-text-sm); }

/* Rows: a list parted by hairlines, each row a name over its meta and an end
   column the rows share, so their states line up. A row that opens something
   says so with data-open.

   The row that is open now (the one a side panel shows) is
   aria-current="true". aria-selected is a choice in a list a person picks
   from, and belongs only to a list that is role="listbox" with rows that are
   role="option". It draws the same, and within v1 still does on any row. */

.tera-items {
  display: grid; grid-template-columns: minmax(0, 1fr) max-content; column-gap: var(--tera-space-4);
  margin: 0 -8px; padding: 0; list-style: none;
}
.tera-items > li {
  position: relative;
  display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center;
  padding: 9px 8px; border-radius: var(--tera-radius-md);
}
.tera-items > li + li::before {
  content: ""; position: absolute; top: 0; left: 8px; right: 8px;
  border-top: 1px solid var(--tera-hairline);
}
.tera-items > li[data-open] { cursor: pointer; }
.tera-items > li[data-open]:hover { background: var(--tera-hover); }
.tera-items > li[aria-current]:not([aria-current="false"]),
.tera-items > li[aria-selected="true"] { background: color-mix(in oklab, var(--tera-running) 40%, transparent); }
.tera-item-lead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tera-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.tera-item-meta {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: var(--tera-text-xs); color: var(--tera-muted);
}
.tera-item-end { display: flex; align-items: center; gap: var(--tera-space-2); justify-self: end; }

/* A property list: label and value, the label muted, leaders in paper. */

.tera-props {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px var(--tera-space-4);
  font-size: 13px;
}
.tera-props > dt { display: flex; align-items: baseline; gap: 6px; color: var(--tera-muted); }
.tera-props > dt::after { content: ""; flex: 1; border-bottom: var(--tera-leader); transform: translateY(-3px); }
.tera-props > dd { min-width: 0; }

/* A group question: one decision for many items, which opens to each of them.
   A native <details>, so it folds with no script.

   Its action ("Include all") is never inside the <summary>. A summary is one
   control, the whole row, and takes its name from everything inside it: a
   button there is a control nested in a control, and the question is read out
   as "Include the 6 linked ADRs? … Include all". The group is a
   <div class="tera-group"> that holds the <details> and, beside its summary,
   the action in a .tera-group-action:

     <div class="tera-group">
       <details open>
         <summary><svg class="tera-chev">…</svg><span class="tera-group-title">Include the 6 linked ADRs?<span class="tera-group-note">…</span></span></summary>
         <div class="tera-group-body">…</div>
       </details>
       <div class="tera-group-action"><button type="button" data-size="sm">Include all</button></div>
     </div>

   The action sits on the question's first line, and the items open beneath
   the question beside it. A group with no action may still be the <details>
   itself, <details class="tera-group">. */

.tera-group { border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-md); }
.tera-group:has(> details) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.tera-group > details { grid-row: 1; grid-column: 1; min-width: 0; }
.tera-group > summary,
.tera-group > details > summary {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px; list-style: none; cursor: pointer;
}
.tera-group > details > summary { grid-template-columns: 14px minmax(0, 1fr); }
.tera-group > summary::-webkit-details-marker,
.tera-group > details > summary::-webkit-details-marker { display: none; }
.tera-group > summary > .tera-chev,
.tera-group > details > summary > .tera-chev { color: var(--tera-muted); transition: transform .15s; }
.tera-group[open] > summary > .tera-chev,
.tera-group > details[open] > summary > .tera-chev { transform: rotate(90deg); }
.tera-group-action {
  grid-row: 1; grid-column: 2;
  display: flex; align-items: center; gap: var(--tera-space-2); padding: 7px 12px 0 0;
}
.tera-group-title { display: grid; gap: 1px; font-weight: 550; }
.tera-group-note { font-size: var(--tera-text-xs); font-weight: 400; color: var(--tera-muted); }
.tera-group-body { display: grid; padding: 2px 12px 10px 36px; }
.tera-check-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; font-weight: 500; }
.tera-check-row + .tera-check-row { border-top: 1px solid var(--tera-hairline); }
.tera-check-row > .tera-muted { margin-left: auto; font-size: var(--tera-text-xs); }

/* A form: the container spaces its fields, so a field drops into any grid
   unchanged (ADR-186 D3 item 5). A field is a label, the control, help, and an
   error when there is one; how a field shows its error is the kit's, and what
   makes it one is the app's. */

.tera-form { display: grid; gap: var(--tera-space-4); align-content: start; }
.tera-field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.tera-field-label { display: flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 600; }
.tera-field-opt { font-size: var(--tera-text-xs); font-weight: 400; color: var(--tera-muted); }
.tera-field-help { font-size: var(--tera-text-xs); color: var(--tera-muted); }
.tera-field-error {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--tera-text-xs); font-weight: 600; color: var(--tera-failed-fg);
}
.tera-checks { display: grid; gap: var(--tera-space-2); font-size: 13px; }
.tera-checks > label { display: flex; align-items: center; gap: var(--tera-space-2); font-weight: 400; }
.tera-field-error[hidden] { display: none; }
.tera-form[hidden] { display: none; }

/* A segmented control: a few mutually exclusive choices, all visible. Radio
   inputs inside labels, so it is a form control with no script. */

.tera-segmented {
  display: inline-flex; justify-self: start; overflow: hidden;
  border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
}
.tera-segmented > label {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  background: var(--tera-control); color: var(--tera-control-fg);
  font-size: var(--tera-text-sm); font-weight: 600; cursor: pointer;
}
.tera-segmented > label + label { border-left: 1px solid var(--tera-field-border); }
.tera-segmented > label > input { position: absolute; width: 15px; height: 15px; margin: 0; accent-color: var(--tera-running-fg); opacity: 0; pointer-events: none; }
.tera-segmented > label:has(> input:checked) { background: var(--tera-accent); color: var(--tera-accent-fg); }
.tera-segmented > label:has(> input:focus-visible) { outline: 2px solid var(--tera-focus); outline-offset: -2px; }
/* The same control as submit buttons, for a form that saves the choice the
   moment it is pressed with no script: the pressed one says so. */
.tera-segmented > button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: 0; box-shadow: none;
  background: var(--tera-control); color: var(--tera-control-fg);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-segmented > button + button { border-left: 1px solid var(--tera-field-border); }
.tera-segmented > button:hover { background: color-mix(in oklab, var(--tera-control), var(--tera-control-fg) 6%); }
.tera-segmented > button[aria-pressed="true"] { background: var(--tera-accent); color: var(--tera-accent-fg); }
.tera-segmented > button:focus-visible { outline: 2px solid var(--tera-focus); outline-offset: -2px; }

/* Choice cards: a radio choice that needs a sentence to explain it. */

.tera-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--tera-space-2); }
.tera-choice {
  display: grid; grid-template-columns: 16px 1fr; gap: 2px 10px;
  padding: 10px 12px; border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
  font-weight: 400; cursor: pointer;
}
.tera-choice > input { translate: 0 2px; }
.tera-choice > b { font-weight: 600; }
.tera-choice > span { grid-column: 2; font-size: var(--tera-text-xs); color: var(--tera-muted); }
.tera-choice:has(> input:checked) {
  border-color: var(--tera-running-fg);
  background: color-mix(in oklab, var(--tera-running) 30%, transparent);
}

/* Tabs: a row of views over one area. A count beside a label says how many
   are inside; its tone says whether they need a person. */

.tera-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--tera-hairline); }
.tera-tabs > :is(button, a) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 0; border-radius: 0; background: none; box-shadow: inset 0 -2px 0 transparent;
  color: var(--tera-muted); font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); text-decoration: none;
  white-space: nowrap; cursor: pointer; transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-tabs > a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tera-tabs > :is(button, a):hover { background: none; color: var(--tera-surface-fg); }
.tera-tabs > :is(button, a)[aria-selected="true"],
.tera-tabs > a[aria-current="page"] { color: var(--tera-surface-fg); box-shadow: inset 0 -2px 0 var(--tera-running-fg); }

.tera-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--tone, var(--tera-idle)); color: var(--tone-fg, var(--tera-idle-fg));
  font-size: 11px; font-weight: 700;
}

/* Steps: where a person is in a flow of a few steps, and which are done. */

.tera-steps { display: flex; margin: 0; padding: 0; list-style: none; counter-reset: tera-step; }
.tera-steps > li {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  font-size: 13px; color: var(--tera-muted); counter-increment: tera-step;
}
.tera-steps > li::before {
  content: counter(tera-step);
  display: grid; place-items: center; flex: none; width: 24px; height: 24px;
  border: 1.5px solid var(--tera-field-border); border-radius: 50%; background: var(--tera-raised);
  font-size: 12px; font-weight: 700;
}
.tera-steps > li + li { padding-left: 12px; }
.tera-steps > li:not(:last-child)::after {
  content: ""; flex: 1; min-width: 16px; height: 1.5px; margin: 0 12px; background: var(--tera-hairline);
}
.tera-steps > li[data-done]::before { content: "✓"; border-color: transparent; background: var(--tera-done); color: var(--tera-done-fg); }
.tera-steps > li[aria-current="step"] { color: var(--tera-surface-fg); font-weight: 600; }
.tera-steps > li[aria-current="step"]::before { border-color: transparent; background: var(--tera-accent); color: var(--tera-accent-fg); }
.tera-steps > li > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A searchable list: the field filters, the list picks, one row is the choice.
   Its selectors reach only its own rows, so a tree or a list nested in a row
   is unharmed (ADR-186 D3 item 6). */

.tera-combo {
  overflow: hidden;
  border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
  background: var(--tera-raised);
}
.tera-combo-search {
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border-bottom: 1px solid var(--tera-hairline); color: var(--tera-muted);
}
.tera-combo-search > input {
  width: 100%; min-height: 32px; padding: 6px 10px 6px 0;
  border: 0; border-radius: var(--tera-radius-md); background: transparent; box-shadow: none; color: inherit;
  font: 400 var(--tera-text-md)/1.4 var(--tera-font-ui);
}
.tera-combo-search > input:focus-visible { outline: none; box-shadow: none; }
.tera-combo-search > input::placeholder { color: var(--tera-muted); }
.tera-combo > ul { max-height: 300px; margin: 0; padding: 4px; overflow: auto; list-style: none; }
.tera-combo > ul > li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: var(--tera-radius-md);
  font-size: 13px; cursor: pointer;
}
.tera-combo > ul > li:hover { background: var(--tera-hover); }
.tera-combo > ul > li[aria-selected="true"] { background: color-mix(in oklab, var(--tera-running) 45%, transparent); }
.tera-combo > ul > li.tera-combo-group {
  display: block; padding: 8px 10px 4px; cursor: default;
  font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--tera-muted);
}
.tera-combo > ul > li.tera-combo-group:hover { background: none; }
.tera-combo-sub { display: block; font-size: var(--tera-text-xs); color: var(--tera-muted); }

/* A tree: folders open and close; leaves can be chosen. Every level is a
   .tera-tree list, so its selectors reach only its own nodes. */

.tera-tree { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.tera-tree > li > .tera-tree { padding-left: 18px; }
.tera-tree-node {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px;
  border-radius: var(--tera-radius-sm); font-weight: 400;
}
.tera-tree-node:hover { background: var(--tera-hover); }
.tera-tree-node[data-dim] { color: var(--tera-muted); }
.tera-tree-node > svg { flex: none; color: var(--tera-muted); }
.tera-tree-end { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: var(--tera-text-xs); color: var(--tera-muted); }

/* A menu: a raised list of actions, for an app's own popover. */

.tera-menu {
  display: grid; min-width: 200px; padding: 6px;
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-lg);
  background: var(--tera-raised); box-shadow: var(--tera-pop-shadow);
}
.tera-menu > :is(button, a) {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  width: 100%; height: 30px; padding: 0 10px;
  border: 0; border-radius: var(--tera-radius-md); background: none;
  color: var(--tera-surface-fg); font: 500 var(--tera-text-sm)/1 var(--tera-font-ui); text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.tera-menu > button { transition: background-color .12s, border-color .12s, box-shadow .12s; }
.tera-menu > a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tera-menu > :is(button, a):hover { background: var(--tera-hover); }
.tera-menu > hr { margin: 6px 0; border: 0; border-top: 1px solid var(--tera-hairline); }

/* A dialog: a native <dialog> in the kit's frame, its actions in a footer in
   the standard order (quiet, secondary, primary). The kit centres it with its
   own `margin: auto` rather than the browser's: a reset such as Tailwind's
   preflight zeroes every margin, which would put a modal at the top left. */

dialog.tera-dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0; margin: auto;
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-lg);
  background: var(--tera-raised); color: var(--tera-surface-fg);
  box-shadow: var(--tera-pop-shadow);
}
dialog.tera-dialog[data-size="lg"] { width: min(680px, calc(100vw - 32px)); }
dialog.tera-dialog::backdrop { background: oklch(20% 0.02 255 / .38); backdrop-filter: blur(1.5px); }
.tera-dialog-head { display: flex; align-items: flex-start; gap: var(--tera-space-3); padding: 18px var(--tera-space-6) 0; }
.tera-dialog-head > h2 { flex: 1; margin: 0; font: 650 var(--tera-text-lg)/1.25 var(--tera-font-display); }
.tera-dialog-body { display: grid; gap: var(--tera-space-3); padding: 10px var(--tera-space-6) var(--tera-space-5); font-size: 13.5px; }
.tera-dialog-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: var(--tera-space-2);
  padding: 14px var(--tera-space-6);
  border-top: 1px solid var(--tera-hairline);
  border-radius: 0 0 var(--tera-radius-lg) var(--tera-radius-lg);
  background: color-mix(in oklab, var(--tera-surface) 60%, var(--tera-raised));
}
.tera-foot-note {
  display: flex; align-items: center; gap: 6px; margin-right: auto;
  font-size: var(--tera-text-xs); color: var(--tera-muted);
}

/* The side panel (the dashboard's ADR-029, whole): status first, problems
   lead, pills mark exceptions, an unremarkable list folds, an empty section is
   one line, explanations sit behind a help tip, and its left edge widens it.
   The markup is the panel's own; the element that adds the resizable edge
   and its memory renders into these same classes. */

.tera-panel {
  position: relative; display: flex; flex-direction: column;
  width: var(--panel-width, 28rem); max-width: 100%; height: 100%; min-height: 0;
  background: var(--tera-raised); border-left: 1px solid var(--tera-hairline);
  font-size: 13px; line-height: 1.45;
  /* A panel is narrow and its figures share one row, so inside it a headline
     figure takes the panel's own size token, which is what an app overrides
     to resize them. */
  --tera-figure-size: var(--tera-panel-figure-size);
}
.tera-panel[data-docked] { position: absolute; inset: 0 0 0 auto; z-index: 10; box-shadow: var(--tera-pop-shadow); }
.tera-panel-resize { position: absolute; inset: 0 auto 0 -4px; z-index: 2; width: 8px; cursor: col-resize; }
.tera-panel-resize::after { content: ""; position: absolute; inset: 0 auto 0 3px; width: 2px; border-radius: 2px; transition: background .12s; }
.tera-panel-resize:hover::after,
.tera-panel-resize:focus-visible::after { background: color-mix(in oklab, var(--tera-running-fg) 50%, transparent); }
.tera-panel-resize:focus-visible { outline: none; }
.tera-panel-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; padding: 16px 20px 14px; border-bottom: var(--tera-panel-head-rule); margin-inline: var(--tera-panel-head-inset); padding-inline: calc(20px - var(--tera-panel-head-inset)); }
.tera-panel-title-row { display: flex; align-items: flex-start; gap: 12px; }
.tera-panel-title {
  flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 650 var(--tera-panel-title-size)/1.25 var(--tera-font-display);
}
.tera-panel-close {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 28px; height: 28px; padding: 0; margin: -3px -6px 0 0;
  border: 0; border-radius: var(--tera-radius-md); background: none; color: var(--tera-muted);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-panel-close:hover { background: var(--tera-hover); color: var(--tera-surface-fg); }
.tera-panel-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--tera-text-xs); color: var(--tera-muted); }
.tera-panel-body { flex: 1; display: grid; align-content: start; gap: var(--tera-space-4); min-height: 0; overflow-y: auto; padding: 14px 20px 24px; }

/* Headline figures: a few numbers, the exceptional one in its tone's ink. */
.tera-figures { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tera-figures > div { display: grid; gap: 2px; align-content: start; min-width: 0; padding: 0 12px; border-left: 1px solid var(--tera-hairline); }
.tera-figures > div:first-child { padding-left: 0; border-left: 0; }
.tera-figures > div > b { font: 650 var(--tera-figure-size)/1.1 var(--tera-font-display); font-variant-numeric: tabular-nums; }
.tera-figures > div > b[data-tone] { color: var(--tone-fg); }
.tera-figures > div > b > small { font-size: .55em; font-weight: 500; color: var(--tera-muted); }
.tera-figures > div > span { font-size: var(--tera-text-xs); color: var(--tera-muted); }

/* What needs attention: the problems, leading, each a link to its section. */
.tera-attention {
  display: grid; gap: 2px; padding: 4px 0; border-radius: var(--tera-radius-lg);
  background: color-mix(in oklab, var(--tone, var(--tera-blocked)) 45%, var(--tera-raised));
}
.tera-attention > h3 { margin: 0; padding: 6px 14px 0; font: 600 var(--tera-text-xs)/1.4 var(--tera-font-ui); color: var(--tera-muted); }
.tera-attention > ul { margin: 0; padding: 0; list-style: none; }
.tera-attention > ul > li > :is(a, div) {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px;
  padding: 6px 14px; border-radius: var(--tera-radius-md);
  color: inherit; text-decoration: none;
}
.tera-attention > ul > li > a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tera-attention > ul > li > a:hover { background: var(--tera-hover); }
.tera-attention > ul > li > :is(a, div) > svg { translate: 0 2px; color: var(--tone-fg, var(--tera-blocked-fg)); }
.tera-attention-what { display: block; font-weight: 550; }
.tera-attention-detail { display: block; font-size: var(--tera-text-xs); color: var(--tera-muted); }
.tera-attention-target { font-size: var(--tera-text-xs); color: var(--tera-muted); }

/* A section: a head (title and aside), a lead that stays above the fold, and
   a body. A collapsible section folds its body and never its lead, so the
   exceptions stay in sight; an empty section is its head alone. The head is a
   <button> when the section folds, and data-open says it is open; it is drawn
   alike either way, wrapping and aligned to the start like any block. */
.tera-section { display: grid; gap: 10px; padding-top: var(--tera-space-4); border-top: 1px solid var(--tera-hairline); scroll-margin-top: 16px; }
.tera-section:first-of-type { padding-top: 0; border-top: 0; }
.tera-section-head {
  display: flex; align-items: baseline; justify-content: flex-start; gap: 10px; width: 100%; min-height: 20px; height: auto;
  padding: 0; border: 0; border-radius: var(--tera-radius-md); background: none; color: inherit;
  font: inherit; text-align: left; white-space: normal; cursor: default; transition: none;
}
.tera-section-head:hover { background: none; }
.tera-section[data-collapsible] > .tera-section-head { cursor: pointer; }
.tera-section-title { margin: 0; font: 600 12.5px/1.4 var(--tera-font-ui); letter-spacing: .01em; }
.tera-section-aside {
  display: inline-flex; align-items: center; gap: 4px; margin-left: auto;
  font-size: var(--tera-text-xs); font-weight: 400; color: var(--tera-muted);
}
.tera-section-head > .tera-section-chev { align-self: center; color: var(--tera-muted); transition: transform .15s; }
.tera-section[data-open] > .tera-section-head > .tera-section-chev { transform: rotate(90deg); }
.tera-section-lead,
.tera-section-body { display: grid; gap: var(--tera-space-2); min-width: 0; }
.tera-section[data-collapsible]:not([data-open]) > .tera-section-body,
.tera-section-lead:empty,
.tera-section-body:empty { display: none; }

/* A hosted panel fills the window its host frames, and leaves the window's
   own controls room over its header's right end. While the edge is dragged,
   the page's text is not selected and the edge stays lit. */
.tera-panel[data-hosted] { width: 100%; border-left: 0; }
.tera-panel[data-hosted] > .tera-panel-head > .tera-panel-title-row { padding-right: 80px; }
.tera-panel[data-dragging] { user-select: none; }
.tera-panel[data-dragging] > .tera-panel-resize::after { background: color-mix(in oklab, var(--tera-running-fg) 50%, transparent); }
.tera-panel-meta[hidden] { display: none; }

/* A status: a state token as a dot beside a plain label, or — once per panel,
   in its header — a filled pill, which a style that prints its states takes
   as an ink stamp. <tera-status> renders this; a page drawn on the server
   writes it: <span class="tera-status" data-tone="done"><span
   class="tera-status-dot"></span>Rendered</span>.

   A label wraps only where its container is narrower than the label, so a
   short one stays on one line and a long one ("Unreadable: the file is
   password-protected") stays inside its box. The dot sits centred on the
   first line, however many lines follow. */

.tera-status {
  display: inline-flex; align-items: flex-start; gap: 6px; max-width: 100%;
  font-size: var(--tera-text-xs); font-weight: 500; overflow-wrap: break-word; text-wrap: pretty;
}
.tera-status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone-fg, var(--tera-idle-fg)); }
.tera-status > .tera-status-dot { margin-top: calc((1lh - 8px) / 2); }
/* A pill on one line is fully round; on two it is a rounded box, not a lozenge. */
.tera-status[data-variant="pill"] {
  padding: 2px 8px 2px 6px;
  border: var(--tera-stamp-border) solid currentColor;
  border-radius: min(var(--tera-stamp-radius), calc(0.5lh + 2px + var(--tera-stamp-border)));
  background: var(--tone, var(--tera-idle)); color: var(--tone-fg, var(--tera-idle-fg));
  font-family: var(--tera-stamp-font); font-weight: 600;
}
.tera-status[data-variant="pill"] > .tera-status-dot { background: currentColor; }

/* An identifier: the only thing in monospace, middle-truncated, whole on
   hover, copyable whole. The copy button sits over the end of the
   identifier's own text, inside its box: it takes no room, so an identifier
   sits in a sentence with no gap after it and does not shift when the button
   shows, and it never covers what follows. While it shows, it hides the
   text's last characters, which the title shows whole. The box is never
   narrower than the button, so an identifier of one or two characters keeps
   a little room after it. */

.tera-identifier {
  position: relative; display: inline-flex; align-items: center; min-width: 20px; max-width: 100%;
  font-family: var(--tera-font-mono); font-size: 0.92em;
}
.tera-identifier-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tera-identifier-copy {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 20px; height: auto; margin: 0; padding: 0;
  border: 0; border-radius: var(--tera-radius-sm); background: var(--tera-raised); color: var(--tera-muted);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
  opacity: 0;
}
.tera-identifier-copy:hover { background: var(--tera-raised); color: var(--tera-surface-fg); }
.tera-identifier:hover > .tera-identifier-copy,
.tera-identifier-copy:focus-visible,
.tera-identifier-copy[data-copied],
.tera-identifier-copy[data-failed] { opacity: 1; }
.tera-identifier-copy[data-copied] { color: var(--tera-done-fg); }
.tera-identifier-copy[data-failed] { color: var(--tera-failed-fg); }

/* The three absences, never confused: absent is not zero. None (tera
   answered, and there is nothing), Unknown (tera cannot say), and — (the
   question does not apply). */

.tera-empty { color: var(--tera-muted); }
.tera-empty[data-kind="unknown"] { font-style: italic; }
.tera-empty[data-kind="na"] { letter-spacing: .1em; }

/* A help tip: the explanation behind a value, on hover or focus, never inline
   where a person scans. Escape hides it (data-dismissed) until the pointer or
   focus leaves. */

.tera-help { position: relative; display: inline-grid; vertical-align: -2px; }
.tera-help-button {
  display: grid; place-items: center; justify-content: center; gap: 6px; width: 16px; height: 16px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--tera-muted);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); white-space: nowrap; cursor: help;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-help-button:hover { background: none; color: var(--tera-surface-fg); }
.tera-help-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 30;
  width: max-content; max-width: 260px; padding: 7px 10px;
  border-radius: var(--tera-radius-md); background: var(--tera-surface-fg); color: var(--tera-surface);
  box-shadow: var(--tera-pop-shadow);
  font: 400 var(--tera-text-xs)/1.4 var(--tera-font-ui); font-style: normal; letter-spacing: normal; text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-50%);
  transition: opacity .12s, visibility .12s;
}
.tera-help:is(:hover, :focus-within):not([data-dismissed]) > .tera-help-tip { opacity: 1; visibility: visible; }

/* <tera-help> lifts its tip into the top layer as a manual popover, so no
   scrolling ancestor clips it. Above its button by anchor, flipped below
   where the viewport has no room; without anchor positioning the element
   places it. Hidden, it is not rendered at all (the popover's own display). */
.tera-help-tip[popover] {
  position: fixed; inset: auto auto 6px; margin: 0; border: 0; overflow: visible;
  position-area: top; position-try-fallbacks: flip-block;
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .12s;
}
.tera-help-tip[popover]:not(:popover-open) { display: none; }
@starting-style {
  .tera-help-tip[popover]:popover-open { opacity: 0; }
}

/* A person: their initials and their name, never a subject. A guest's avatar
   is quieter. */

.tera-person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.tera-person-avatar {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--tera-running); color: var(--tera-running-fg);
  font-size: 10.5px; font-weight: 700; line-height: 1;
}
.tera-person[data-size="lg"] > .tera-person-avatar { width: 36px; height: 36px; font-size: 13px; }
.tera-person[data-guest] > .tera-person-avatar { background: var(--tera-idle); color: var(--tera-idle-fg); }
.tera-person-who { display: grid; min-width: 0; line-height: 1.25; }
.tera-person-name { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.tera-person-email { overflow: hidden; color: var(--tera-muted); font-size: var(--tera-text-xs); text-overflow: ellipsis; white-space: nowrap; }

/* A sheet: one centred column for a page that asks one thing — sign in, a
   code, a consent, a refusal — under the shell, its parts spaced by the sheet.
   `data-wide` is the same column for a page that lists things. A heading
   block leads (a mark in one state token, the title, the sentence under it);
   the form, doors parted by `.tera-or`, and a foot line follow. tera draws
   its own pages with it (ADR-186 D5); a plugin's page that asks one thing may
   too. */

.tera-sheet {
  display: grid; gap: var(--tera-space-5); align-content: start;
  width: 100%; max-width: calc(400px + 2 * var(--tera-space-4)); margin-inline: auto;
  padding: 56px var(--tera-space-4) 72px;
}
.tera-sheet[data-wide] { max-width: calc(680px + 2 * var(--tera-space-4)); }
/* A small window — the step-up window an app opens — or a phone: the sheet
   starts near the top, so what it asks fits without scrolling. */
@media (max-height: 720px), (max-width: 520px) {
  .tera-sheet { padding-block: var(--tera-space-6) var(--tera-space-8); }
}
.tera-sheet > h2, .tera-sheet > .tera-form > h2 { margin: 0; font: 650 15px/1.25 var(--tera-font-display); }
.tera-sheet-head > .tera-sheet-mark { margin-bottom: 6px; }
/* A form or a door in a narrow sheet spans it. */
.tera-sheet:not([data-wide]) > .tera-form > button,
.tera-sheet:not([data-wide]) > .tera-form > .tera-button,
.tera-sheet:not([data-wide]) > .tera-button,
.tera-sheet:not([data-wide]) > form > button { width: 100%; }
/* What shows only while the form before it is hidden: a page's way on
   without script, where the form needs script and reveals itself. */
.tera-sheet > form:not([hidden]) ~ .tera-sheet-fallback { display: none; }

.tera-sheet-head { display: grid; gap: 6px; }
.tera-sheet-head > h1 { margin: 0; font: 650 var(--tera-text-xl)/1.25 var(--tera-font-display); letter-spacing: -0.01em; }
.tera-sheet-head > p { color: var(--tera-muted); font-size: 13.5px; }
.tera-sheet-mark {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--tone, var(--tera-running)); color: var(--tone-fg, var(--tera-running-fg));
}
.tera-sheet-foot { padding-top: var(--tera-space-1); text-align: center; color: var(--tera-muted); font-size: var(--tera-text-xs); }
/* Two choices side by side: deny and allow. */
.tera-sheet-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--tera-space-2); }
/* A figure the sheet centres, on its own white: a QR code. */
.tera-sheet-figure {
  justify-self: center; width: 232px; padding: 0; overflow: hidden;
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-lg);
}
.tera-sheet-figure > svg { display: block; width: 100%; height: auto; }

/* "or" between two ways in. */
.tera-or {
  display: flex; align-items: center; gap: var(--tera-space-3);
  color: var(--tera-muted); font-size: var(--tera-text-xs); letter-spacing: .06em; text-transform: uppercase;
}
.tera-or::before, .tera-or::after { content: ""; flex: 1; border-top: 1px solid var(--tera-hairline); }

/* A note: a sentence that qualifies what is above it. */
.tera-note { color: var(--tera-muted); font-size: var(--tera-text-sm); }

/* A one-time code: six digits, spaced, centred, in a field drawn whole. */
.tera-code {
  width: 100%; min-height: 32px; height: 48px; padding: 6px 10px;
  border: 1px solid var(--tera-field-border); border-radius: var(--tera-radius-md);
  background: var(--tera-raised); color: inherit;
  font: 600 22px/1 var(--tera-font-mono); letter-spacing: .35em; text-align: center;
}
.tera-code:focus-visible {
  outline: none; border-color: var(--tera-focus);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--tera-focus) 28%, transparent);
}
.tera-code[aria-invalid="true"] { border-color: var(--tera-failed-fg); }
.tera-code::placeholder { color: var(--tera-muted); }

/* A form on one line: a field and its button, the button at the field's foot. */
.tera-inline-form { display: flex; align-items: end; gap: var(--tera-space-2); }
.tera-inline-form > .tera-field, .tera-inline-form > input { flex: 1; }

/* A plain list of sentences, spaced by the list. */
.tera-list { display: grid; gap: 6px; margin: 0; padding-left: 18px; font-size: 13.5px; }
.tera-list > li > .tera-list { margin-top: 6px; color: var(--tera-muted); font-size: var(--tera-text-sm); gap: 2px; }

/* Doors: several ways in, one under the next, each spanning the sheet. */
.tera-sheet-doors { display: grid; gap: var(--tera-space-2); }
.tera-sheet-doors > * { width: 100%; }
/* The address a figure stands for, written out beneath it. */
.tera-sheet-target { overflow-wrap: anywhere; text-align: center; color: var(--tera-muted); font: 12px/1.5 var(--tera-font-mono); }
/* Words that are someone else's — a plugin's, a Work Order type's — set off as theirs. */
.tera-sheet-quote { padding-left: var(--tera-space-3); border-left: 3px solid var(--tera-rule); }
/* A record shown as it is. */
.tera-sheet-pre {
  max-height: 240px; padding: 10px 12px; overflow: auto;
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-md); background: var(--tera-raised);
  font: 12px/1.5 var(--tera-font-mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* App cards: the apps a person may open, each card one link — the app's
   tile, its title, its summary and "Open". tera's front page lists a
   person's apps with them (ADR-186 D4); any page that offers apps to open
   may too. The list is a `ul`, each `li` holding one `a.tera-app-card`. */

.tera-app-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--tera-space-3);
  margin: 0; padding: 0; list-style: none;
}
.tera-app-cards > li { display: grid; min-width: 0; }

.tera-app-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr auto;
  column-gap: var(--tera-space-3); row-gap: 2px; align-items: start; min-width: 0;
  padding: var(--tera-space-4);
  background: var(--tera-raised); border: 1px solid var(--tera-hairline);
  border-radius: var(--tera-radius-lg); box-shadow: var(--tera-card-shadow);
  color: var(--tera-surface-fg); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.tera-app-card:hover { border-color: var(--tera-field-border); background: color-mix(in oklab, var(--tera-raised), var(--tera-surface-fg) 3%); }
.tera-app-card:focus-visible { outline: 2px solid var(--tera-focus); outline-offset: 2px; }
.tera-app-card > .tera-app-card-tile {
  grid-row: 1 / span 3; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--tera-running); color: var(--tera-running-fg);
  font-size: 17px; font-weight: 750; line-height: 1;
}
/* An app's icon over the tile's letter, drawn as the shell's tile draws it:
   an image that fails to load has no box, and the tile is its letter. The
   tile is positioned whether or not it holds an image, as shell.css says. */
.tera-app-card > .tera-app-card-tile { position: relative; }
.tera-app-card > .tera-app-card-tile > img {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  height: 100%; max-width: 100%; object-fit: contain;
  border-radius: inherit; background: inherit;
}
.tera-app-card > .tera-app-card-title {
  grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 15px; font-weight: 650; line-height: 1.35;
}
.tera-app-card > .tera-app-card-summary { grid-column: 2; color: var(--tera-muted); font-size: var(--tera-text-sm); }
.tera-app-card > .tera-app-card-open {
  grid-column: 2; display: inline-flex; align-items: center; gap: 4px; padding-top: var(--tera-space-2);
  color: var(--tera-link); font-size: var(--tera-text-sm); font-weight: 600;
}
.tera-app-card:hover > .tera-app-card-open { text-decoration: underline; text-underline-offset: 3px; }

/* A link in <tera-shell>'s nav slot: the app's own pages, the current one
   marked with aria-current="page".

     <a slot="nav" class="tera-shell-link" href="./" aria-current="page">Reviews</a>

   A slotted link is the app's light DOM, where the page's CSS beats the
   shell's own `::slotted()` rules: a reset such as Tailwind's preflight
   flattens a link with no class. This class is the same look in the kit's
   patterns layer, which beats any reset in a layer before it and loses to the
   app's later layers and unlayered CSS, so an app's utility on one link still
   wins. tera's own pages draw their nav in shell.css. */

.tera-shell-link {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 7px; background: transparent; color: var(--tera-muted);
  font-size: 13.5px; font-weight: 550; line-height: 1.5; text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; white-space: nowrap;
}
.tera-shell-link:hover { background: var(--tera-hover); color: var(--tera-surface-fg); }
.tera-shell-link[aria-current="page"] { background: var(--tera-hover); color: var(--tera-surface-fg); font-weight: 600; }
.tera-shell-link > svg { flex: none; }
/* On a phone the nav is the shell's "More" menu, whose rows are taller. */
@media (max-width: 720px) {
  .tera-shell-link { height: 36px; font-size: 14px; }
}

/* A confirmation: one act a person is asked to confirm, as tera's step-up
   page draws it (ADR-186 D5 item 4). Who asks, in tera's words; what it
   asks, in its own; the request it sends, as fields drawn by their shape,
   the keys that only bind it, and as it is; the ways to confirm, and the
   quiet ways out.
   `.tera-confirm-done` is the same sheet once it is confirmed. It sits in a
   narrow `.tera-sheet`, which a small window and a phone both fit, and its
   tracks are `minmax(0, 1fr)` so an open exact request scrolls rather than
   widening the sheet. */

.tera-confirm { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--tera-space-4); }

.tera-confirm-head { display: grid; gap: 14px; }

/* Who asks: a tile with the app's first letter, its icon over the letter
   when it has one, and tera's line naming it, which leads into the plugin's
   own words (its quieter tail). */
.tera-confirm-from { display: flex; align-items: center; gap: 10px; color: var(--tera-muted); font-size: 13px; }
.tera-confirm-from > p { min-width: 0; overflow-wrap: anywhere; }
.tera-confirm-from > p > b { color: var(--tera-surface-fg); font-weight: 600; }
.tera-confirm-from > p > span { color: var(--tera-muted); }
.tera-confirm-tile {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: var(--tera-running); color: var(--tera-running-fg); font-size: 13px; font-weight: 750;
}
/* The icon over the letter, drawn as the shell's tile draws it (shell.css). */
.tera-confirm-from > .tera-confirm-tile { position: relative; }
.tera-confirm-from > .tera-confirm-tile > img {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  height: 100%; max-width: 100%; object-fit: contain;
  border-radius: inherit; background: inherit;
}

/* What it asks: a heading. In the plugin's words, a rule at its left sets it
   off from tera's line above. */
.tera-confirm-act { display: grid; gap: var(--tera-space-1); }
.tera-confirm-act > h1 { margin: 0; font: 650 19px/1.3 var(--tera-font-display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tera-confirm-act[data-words="plugin"] > h1 {
  padding-left: 12px; border-left: 3px solid var(--tera-hairline);
}

/* The request it sends: what the record carries, and the record itself. */
.tera-confirm-request {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--tera-space-2); padding: 12px 14px;
  border: 1px solid var(--tera-hairline); border-radius: var(--tera-radius-md); background: var(--tera-raised);
}
.tera-confirm-request > h2 { margin: 0; font: 600 var(--tera-text-xs)/1.25 var(--tera-font-display); }
.tera-confirm-request > .tera-props { grid-template-columns: 92px minmax(0, 1fr); font-size: var(--tera-text-sm); }
.tera-confirm-request > .tera-props > dd { overflow-wrap: anywhere; }
/* A plugin's request as a person reads it: one field a block, its name
   above its value, a hairline between fields. A name that is the key's own,
   on a page whose other names are the plugin's labels, carries the key
   beside it in a `<code>`. */
.tera-confirm-request > .tera-confirm-fields { display: grid; margin: 0; }
.tera-confirm-fields > div { display: grid; gap: 3px; padding: 9px 0; border-top: 1px solid var(--tera-hairline); }
.tera-confirm-fields > div:first-child { border-top: 0; padding-top: 2px; }
.tera-confirm-fields > div > dt { color: var(--tera-muted); font: 600 var(--tera-text-xs)/1.3 var(--tera-font-ui); }
.tera-confirm-fields > div > dt > code { margin-left: 6px; font: 400 11px/1 var(--tera-font-mono); color: var(--tera-muted); }
.tera-confirm-fields > div > dd { margin: 0; min-width: 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
/* An array of scalars: one value a line. */
.tera-confirm-values { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
/* An array of objects: one entry an element, a lead (when the plugin named
   one) above its pairs. */
.tera-confirm-items { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tera-confirm-items > li { display: grid; gap: 1px; }
.tera-confirm-items > li > b { font-weight: 550; }
/* An object's pairs, and an entry's: each name before its value, on one
   line that wraps. */
.tera-confirm-pairs { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--tera-muted); font-size: 13px; }
.tera-confirm-pairs > span > b { color: var(--tera-surface-fg); font-weight: 550; }
.tera-confirm-fields > div > dd > .tera-confirm-pairs { font-size: 14px; }
/* A URL: its scheme quieter than where it points. */
.tera-confirm-url > span { color: var(--tera-muted); }
/* The keys the plugin marked as binding the act whose values are ids and
   digests, named on one line beneath the list in tera's words. */
.tera-confirm-request > .tera-confirm-bound { color: var(--tera-muted); font-size: var(--tera-text-xs); overflow-wrap: anywhere; }
.tera-confirm-request > .tera-confirm-bound > code { font: 11px/1.5 var(--tera-font-mono); color: var(--tera-surface-fg); }
.tera-confirm-exact { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--tera-space-2); font-size: 12px; }
.tera-confirm-exact > summary { cursor: pointer; color: var(--tera-muted); }
.tera-confirm-exact > pre {
  max-height: 140px; padding: 10px; overflow: auto;
  border-radius: var(--tera-radius-sm); background: var(--tera-surface);
  font: 11px/1.5 var(--tera-font-mono);
}

/* The ways to confirm, each spanning the sheet, and the quiet ways out on
   one line beneath them. */
.tera-confirm-go { display: grid; gap: var(--tera-space-2); }
.tera-confirm-go > .tera-form > button,
.tera-confirm-go > .tera-button { width: 100%; }
.tera-confirm-alt { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--tera-space-1); font-size: var(--tera-text-sm); }
.tera-confirm-alt > form:only-child { margin-inline-start: auto; }
.tera-confirm-alt > form > button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 6px;
  border: 1px solid transparent; border-radius: var(--tera-radius-md); background: transparent; color: var(--tera-surface-fg);
  font: 600 var(--tera-text-sm)/1 var(--tera-font-ui); white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.tera-confirm-alt > form > button:hover { background: var(--tera-hover); }
.tera-confirm-alt > .tera-confirm-code > button { color: var(--tera-link); }
.tera-confirm-expiry { color: var(--tera-muted); font-size: var(--tera-text-xs); text-align: center; }

/* Confirmed. */
.tera-confirm-done { display: grid; justify-items: center; gap: 6px; padding-top: 40px; text-align: center; }
.tera-confirm-done > h1 { margin: 0; font: 650 20px/1.25 var(--tera-font-display); letter-spacing: -0.01em; }
.tera-confirm-done > p { color: var(--tera-muted); font-size: 13px; }
.tera-confirm-done > .tera-button { margin-top: var(--tera-space-3); }
.tera-confirm-done > .tera-confirm-ring { margin-bottom: 10px; }
.tera-confirm-ring {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--tone, var(--tera-done)); color: var(--tone-fg, var(--tera-done-fg));
}
.tera-confirm-ring > svg { width: 30px; height: 30px; }

/* A page of sections: an index of them down the side, which stays in view as
   the page scrolls, and the sections in one column beside it — a settings
   page, and tera's Account page (ADR-186 D6). The index links to each
   section's id; the column spaces its sections. On a narrow screen the index
   goes and the column is the page.

   Three shapes such a page repeats travel with it: fields two to a row
   (`.tera-field-grid`), a figure beside what it describes (`.tera-beside`: a
   person's avatar beside their profile), and the letter tile of an account
   held elsewhere (`.tera-logo`). */

.tera-sections {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 36px; align-items: start;
  max-width: 980px; margin-inline: auto; padding: 28px var(--tera-space-6) 80px;
}
.tera-sections-nav { position: sticky; top: 76px; display: grid; gap: 1px; font-size: 13px; }
.tera-sections-nav > a {
  display: flex; align-items: center; gap: 9px; margin-left: -10px; padding: 6px 10px;
  border-radius: 7px; color: inherit; text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.tera-sections-nav > a:hover, .tera-sections-nav > a[aria-current] { background: var(--tera-hover); }
.tera-sections-nav > a[aria-current] { font-weight: 600; }
.tera-sections-nav > a > svg { flex: none; color: var(--tera-muted); }
.tera-sections-main { display: grid; gap: var(--tera-space-4); align-content: start; min-width: 0; }
.tera-sections-main > .tera-page-header { padding-bottom: var(--tera-space-1); }
.tera-sections-main > [id] { scroll-margin-top: 70px; }
.tera-sections-foot { padding-top: var(--tera-space-2); color: var(--tera-muted); font-size: var(--tera-text-xs); }
@media (max-width: 720px) {
  .tera-sections { grid-template-columns: minmax(0, 1fr); padding-inline: var(--tera-space-4); }
  .tera-sections-nav { display: none; }
}

/* Fields two to a row; one to a row on a narrow screen. */
.tera-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 560px) { .tera-field-grid { grid-template-columns: minmax(0, 1fr); } }

/* A figure beside what it describes. */
.tera-beside { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--tera-space-5); align-items: start; }

/* An account held elsewhere, as a tile of its first letter. */
.tera-logo {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 7px;
  background: var(--tera-surface-fg); color: var(--tera-surface);
  font-size: 12px; font-weight: 700; line-height: 1;
}

}
