/* Theme contract
   --------------
   A theme supplies the light and dark palette inputs below. The scheme block
   selects one palette, semantic roles derive from it, and components consume
   only semantic/component roles. This keeps alternate themes small and lets a
   caller override one component role on any subtree without forking its CSS.

   Public selectors:
     data-theme="matrix" | "workbench" | "workbench-inverse" | "screen" |
       "mineral" (matrix is the default)
     data-color-scheme="light" | "dark" (unset follows the OS)

   Public override examples:
     --color-accent: rebeccapurple;
     --color-scrollbar: #aaa;
     --prompt-bg: var(--color-surface-raised);
     --rail-bg: canvas;

   This file is the house contract: the tokens the workbench and portal apps
   share verbatim. `frontend/workbench/src/styles/tokens.css` layers the
   workbench-private component roles and shell geometry on top of it; it
   redefines nothing here. A portal app loads this file alone.
*/
:root,
:root[data-theme="matrix"] {
  --theme-light-canvas: #e9f7ec;
  --theme-light-surface: #d5ecd9;
  --theme-light-raised: #f4fff6;
  --theme-light-field: #e1f3e5;
  --theme-light-ink: #08240f;
  --theme-light-border: #79a985;
  --theme-light-accent: #087a2f;
  --theme-light-on-accent: #f5fff7;
  --theme-light-success: #087a2f;
  --theme-light-danger: #a52929;
  --theme-light-warning: #7a5200;

  --theme-dark-canvas: #020805;
  --theme-dark-surface: #06140c;
  --theme-dark-raised: #0b2113;
  --theme-dark-field: #081a0f;
  --theme-dark-ink: #b8ffc8;
  --theme-dark-border: #1d6333;
  --theme-dark-accent: #39ff70;
  --theme-dark-on-accent: #001a08;
  --theme-dark-success: #65ff8f;
  --theme-dark-danger: #ff6b6b;
  --theme-dark-warning: #ffd166;
}

/* The previous Workbench default remains available as a neutral alternate. */
:root[data-theme="workbench"],
:root[data-theme="workbench-inverse"] {
  --theme-light-canvas: #f1f1f1;
  --theme-light-surface: #d3d3d4;
  --theme-light-raised: #f1f1f1;
  --theme-light-field: #f1f1f1;
  --theme-light-ink: #1d1c19;
  --theme-light-border: #c0bfbb;
  --theme-light-accent: #1c3c31;
  --theme-light-on-accent: #ffffff;
  --theme-light-success: #16a34a;
  --theme-light-danger: #dc2626;
  --theme-light-warning: #ea580c;

  --theme-dark-canvas: #191a19;
  --theme-dark-surface: #202220;
  --theme-dark-raised: #292b28;
  --theme-dark-field: #252724;
  --theme-dark-ink: #ecece6;
  --theme-dark-border: #444741;
  --theme-dark-accent: #d6eee0;
  --theme-dark-on-accent: #0c1711;
  --theme-dark-success: #4ade80;
  --theme-dark-danger: #f87171;
  --theme-dark-warning: #fb923c;
}

/* The same Workbench profile with only the two largest planes exchanged. */
:root[data-theme="workbench-inverse"] {
  --theme-light-canvas: #d3d3d4;
  --theme-light-surface: #f1f1f1;
  --theme-dark-canvas: #202220;
  --theme-dark-surface: #191a19;
}

/* The original neutral screen palette remains available as an alternate. */
:root[data-theme="screen"] {
  --theme-light-canvas: #f1f1f1;
  --theme-light-surface: #d3d3d4;
  --theme-light-raised: #f1f1f1;
  --theme-light-field: #f1f1f1;
  --theme-light-ink: #1d1c19;
  --theme-light-border: #c0bfbb;
  --theme-light-accent: #01140c;
  --theme-light-on-accent: #ffffff;
  --theme-light-success: #256044;
  --theme-light-danger: #8d302b;
  --theme-light-warning: #824700;

  --theme-dark-canvas: #191a19;
  --theme-dark-surface: #202220;
  --theme-dark-raised: #292b28;
  --theme-dark-field: #252724;
  --theme-dark-ink: #ecece6;
  --theme-dark-border: #444741;
  --theme-dark-accent: #d6eee0;
  --theme-dark-on-accent: #0c1711;
  --theme-dark-success: #73c297;
  --theme-dark-danger: #e28d83;
  --theme-dark-warning: #e4ac65;
}

/* A retained alternate palette: the cooler mineral study from the first
   workbench pass. Geometry and component behavior remain identical. */
:root[data-theme="mineral"] {
  --theme-light-canvas: #e7eae8;
  --theme-light-surface: #f2f4f3;
  --theme-light-raised: #ffffff;
  --theme-light-field: #f7f8f7;
  --theme-light-ink: #121817;
  --theme-light-border: #cbd1ce;
  --theme-light-accent: #214fc7;
  --theme-light-on-accent: #ffffff;
  --theme-light-success: #256044;
  --theme-light-danger: #8d302b;
  --theme-light-warning: #824700;

  --theme-dark-canvas: #171c1a;
  --theme-dark-surface: #1e2522;
  --theme-dark-raised: #27302d;
  --theme-dark-field: #222a27;
  --theme-dark-ink: #edf2ef;
  --theme-dark-border: #46514d;
  --theme-dark-accent: #9eb8ff;
  --theme-dark-on-accent: #101b37;
  --theme-dark-success: #72cdaa;
  --theme-dark-danger: #ee918a;
  --theme-dark-warning: #e1b36d;
}

:root {
  color-scheme: light;
  --palette-canvas: var(--theme-light-canvas);
  --palette-surface: var(--theme-light-surface);
  --palette-raised: var(--theme-light-raised);
  --palette-field: var(--theme-light-field);
  --palette-ink: var(--theme-light-ink);
  --palette-border: var(--theme-light-border);
  --palette-accent: var(--theme-light-accent);
  --palette-on-accent: var(--theme-light-on-accent);
  --palette-success: var(--theme-light-success);
  --palette-danger: var(--theme-light-danger);
  --palette-warning: var(--theme-light-warning);
}

:root[data-color-scheme="dark"] {
  color-scheme: dark;
  --palette-canvas: var(--theme-dark-canvas);
  --palette-surface: var(--theme-dark-surface);
  --palette-raised: var(--theme-dark-raised);
  --palette-field: var(--theme-dark-field);
  --palette-ink: var(--theme-dark-ink);
  --palette-border: var(--theme-dark-border);
  --palette-accent: var(--theme-dark-accent);
  --palette-on-accent: var(--theme-dark-on-accent);
  --palette-success: var(--theme-dark-success);
  --palette-danger: var(--theme-dark-danger);
  --palette-warning: var(--theme-dark-warning);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) {
    color-scheme: dark;
    --palette-canvas: var(--theme-dark-canvas);
    --palette-surface: var(--theme-dark-surface);
    --palette-raised: var(--theme-dark-raised);
    --palette-field: var(--theme-dark-field);
    --palette-ink: var(--theme-dark-ink);
    --palette-border: var(--theme-dark-border);
    --palette-accent: var(--theme-dark-accent);
    --palette-on-accent: var(--theme-dark-on-accent);
    --palette-success: var(--theme-dark-success);
    --palette-danger: var(--theme-dark-danger);
    --palette-warning: var(--theme-dark-warning);
  }
}

:root {
  /* Typography contract. Components never introduce their own family or
     size: changing this block retunes the whole workbench, including the
     Pierre surfaces. The compact default keeps an 8px floor; markdown and
     document tiers stay in em so they ride on their owning text size. */
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --font-size-none: 0px;
  --font-size-2xs: 8px;
  --font-size-xs: 8.5px;
  --font-size-sm: 9px;
  --font-size-body: 10px;
  --font-size-ui: 10.5px;
  --font-size-emphasis: 11.5px;
  --font-size-subheading: 13px;
  --font-size-title: 14.5px;
  --font-size-heading: 16px;
  --font-size-display-min: 18px;
  --font-size-display-max: 25px;
  --font-size-markdown-code: .92em;
  --font-size-markdown-code-block: .9em;
  --font-size-markdown-table: .94em;
  --font-size-markdown-h1: 1.5em;
  --font-size-markdown-h2: 1.3em;
  --font-size-markdown-h3: 1.15em;
  --font-size-markdown-heading: 1em;
  --font-size-document-h1: 1.8em;
  --font-size-document-h2: 1.28em;

  /* Spacing ladder. Rule bodies never restate a px rhythm value; density
     retunes happen only here. Ordinals deliberately do not encode values. */
  --space-01: 1px;
  --space-02: 2px;
  --space-03: 2px;
  --space-04: 3px;
  --space-05: 4px;
  --space-06: 5px;
  --space-07: 6px;
  --space-08: 6px;
  --space-09: 7px;
  --space-10: 8px;
  --space-11: 9px;
  --space-12: 10px;
  --space-13: 10px;
  --space-14: 11px;
  --space-15: 13px;
  --space-16: 14px;
  --space-17: 14px;
  --space-18: 15px;
  --space-19: 16px;
  --space-20: 18px;
  --space-21: 18px;
  --space-22: 19px;
  --space-23: 21px;
  --space-24: 22px;
  --space-25: 27px;
  --space-26: 32px;
  --space-27: 37px;
  --space-28: 38px;
  --space-29: 42px;
  --space-30: 48px;
  --space-31: 50px;
  --space-32: 56px;

  /* Semantic color roles. */
  --color-canvas: var(--palette-canvas);
  --color-surface: var(--palette-surface);
  --color-surface-raised: var(--palette-raised);
  --color-field: var(--palette-field);
  --color-text: var(--palette-ink);
  --color-text-muted: color-mix(in srgb, var(--color-text) 72%, transparent);
  --color-text-faint: color-mix(in srgb, var(--color-text) 66%, transparent);
  --color-border: var(--palette-border);
  --color-border-soft: var(--color-border);
  --color-accent: var(--palette-accent);
  --color-on-accent: var(--palette-on-accent);
  --color-success: var(--palette-success);
  --color-danger: var(--palette-danger);
  --color-warning: var(--palette-warning);
  --color-hover: color-mix(in srgb, var(--color-text) 5%, transparent);
  --color-hover-strong: color-mix(in srgb, var(--color-text) 9%, transparent);
  /* Selection is a translucent ink layer so it remains legible even when a
     profile deliberately gives canvas and raised surfaces the same color. */
  --color-selected: color-mix(in srgb, var(--color-text) 10%, transparent);
  --color-focus: var(--color-accent);
  --color-focus-text: var(--color-on-accent);
  --color-selection: color-mix(in srgb, var(--color-accent) 24%, var(--color-surface-raised));
  --color-disabled: color-mix(in srgb, var(--color-text) 42%, transparent);
  --color-scrollbar: color-mix(in srgb, var(--color-text) 30%, transparent);
  --scrollbar-track: transparent;
  --scrollbar-size: 4px;
}

/* House primitives
   ----------------
   The small primitive vocabulary a portal app gets for free. It consumes only
   the roles in `tokens.css` (load that first) and depends on no framework: a
   plain <link> and `.house-*` classes with data-attribute states.

   Every block below mirrors a rule the workbench already ships, and says
   which. When the two disagree the workbench is right; fix this file rather
   than diverging. Geometry lives in the token block immediately below — rule
   bodies never restate a px value, exactly as the spacing ladder demands.

   The laws these encode (frontend/workbench/docs/DESIGN.md): quiet chrome;
   two-audience failures; no anonymous spinner; one UI face; tokens own
   geometry; selection is a ground; there is no card primitive.
*/

:root {
  /* Geometry mirrored from the workbench's own tokens.css. Those values live
     in the workbench-private sheet because the shell owns them; a portal is
     not the shell, so it takes copies under its own names and may retune them
     without reaching into the workbench. */
  --house-measure: 600px;            /* workbench --content-width */
  --house-edge-buffer: 16px;         /* workbench --content-edge-buffer */
  --house-radius: 3px;               /* workbench --radius-control */
  --house-toolbar-height: 30px;      /* workbench --header-height */
  --house-tab-height: 24px;          /* workbench --tab-height */
  --house-chip-min-height: 24px;     /* primitives --primitive-chip-min-height */
  --house-row-min-height: 19px;      /* primitives --row-min-height */
  --house-row-lead-width: 14px;      /* primitives --row-lead-width */
  --house-field-height: 24px;        /* settings --settings-control-height */
  --house-icon-size: 10px;           /* global --header-control-icon-size */
  /* global.css: the project tabs' inherited 15px line box plus 3px of block
     padding on each side is the silhouette every dense control shares. */
  --house-control-height: calc(var(--space-18) + var(--space-05) + var(--space-05));
  --house-control-font: 500 var(--font-size-sm)/var(--space-18) var(--font-sans);
  --house-line: 1px solid var(--color-border);
  --house-hairline: 1px solid var(--color-border-soft);
  /* The reading measure, squeezed by its pane rather than by the viewport,
     one quiet buffer surviving the squeeze (workbench --content-layout-width). */
  --house-layout-width: min(var(--house-measure), calc(100% - var(--house-edge-buffer) - var(--house-edge-buffer)));
  --house-wide-width: calc(100% - var(--house-edge-buffer) - var(--house-edge-buffer));
  /* A table names its columns once and every header and row inherits it
     (primitives --row-columns). Portals override this on the table element. */
  --house-columns: minmax(0, 1fr);
  /* The plane the page paints. Standalone that is the canvas; framed, the host
     names the plane it painted around the frame (house.js `ground`) so the
     page continues it — the workbench's primary pane is its surface, a tether
     its canvas — instead of sitting on it as a lighter or darker inset. */
  --house-ground: var(--color-canvas);
}
:root[data-house-ground="surface"] { --house-ground: var(--color-surface); }

/* Base ------------------------------------------------------------------
   Mirrors global.css: one box model, one native-scrollbar contract, one UI
   face, and the accent ring reserved for :focus-visible. */

* { box-sizing: border-box; scrollbar-color: var(--color-scrollbar) var(--scrollbar-track); scrollbar-width: thin; }
*::-webkit-scrollbar { width: var(--scrollbar-size); height: var(--scrollbar-size); background: transparent; }
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-track-piece,
*::-webkit-scrollbar-corner { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb { background: var(--color-scrollbar); border-radius: var(--scrollbar-size); }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

html, body { min-height: 100%; margin: 0; }
body {
  color: var(--color-text);
  background: var(--house-ground);
  font: var(--font-size-body)/1.5 var(--font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
/* Disabled and pending controls keep the ordinary pointer: color, icon, and
   accessible name carry state, never a blocked system cursor. */
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
::selection { color: var(--color-text); background: var(--color-selection); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
h1, h2, h3, p, ul, ol { margin: 0; }
h1 { font-size: var(--font-size-title); font-weight: 650; }
h2 { font-size: var(--font-size-subheading); font-weight: 650; }
h3 { font-size: var(--font-size-emphasis); font-weight: 600; }

/* Numbers align; tabular layout does not earn monospace (DESIGN typography). */
.house-num { font-variant-numeric: tabular-nums; }
/* Reader-only naming for chrome that already carries its label visibly. */
.house-hidden { position: absolute; width: var(--space-01); height: var(--space-01); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* A sprite glyph takes the ink of the text around it (icons.svg). */
.house-icon { flex: 0 0 var(--house-icon-size); width: var(--house-icon-size); height: var(--house-icon-size); fill: currentColor; }

/* Surface ---------------------------------------------------------------
   Mirrors global.css's `margin-inline: auto` reading column plus
   --content-layout-width: the measure is stable and only the containing pane
   squeezes it. `data-wide` is the portal's own `l w` — it releases the
   measure and lays on the whole pane, buffer intact. */

.house-surface { width: var(--house-layout-width); min-width: 0; margin-inline: auto; padding: var(--space-19) 0 var(--space-30); container: house / inline-size; }
.house-surface[data-wide] { width: var(--house-wide-width); }
/* The surface is a query container named `house`: an app adapts to the width
   it was actually given — a tether beside a conversation, a full pane, its
   own window — with `@container house (max-width: 40em) { … }`, never to the
   viewport, which framed is the pane and standalone is the window. At the
   house scale 1em is the body's 10px. */

/* Toolbar ---------------------------------------------------------------
   Mirrors views.css `.view-header`: one header-height row, controls at their
   own height inside it, no eyebrow and no ceremonial title decoration. */

.house-toolbar { display: flex; min-height: var(--house-toolbar-height); flex-wrap: wrap; align-items: center; gap: var(--space-06) var(--space-10); padding: 0 var(--space-12); }
.house-toolbar > :is(h1, h2) { min-width: 0; flex: 1 1 auto; overflow: hidden; font-size: var(--font-size-ui); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.house-toolbar-actions { display: flex; flex: 0 0 auto; align-items: center; gap: var(--space-02); margin-left: auto; }
.house-toolbar[data-lined] { border-bottom: var(--house-hairline); }

/* Title -----------------------------------------------------------------
   The app's own name, in the workbench header's silhouette (views.css
   `.view-header`: one header-height row, the title in the control font).
   Framed, the workbench header already says it — and the status, and the
   open-in-window action — so the row goes away rather than repeating the
   frame; standalone in its own window it is the only heading the page has.
   `data-house-framed` is set by house.js the moment it runs. */

.house-title { display: flex; min-height: var(--house-toolbar-height); align-items: center; gap: var(--space-06) var(--space-10); padding: 0 var(--space-12); }
.house-title > :is(h1, h2) { min-width: 0; flex: 0 1 auto; overflow: hidden; font-size: var(--font-size-ui); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.house-title > p { min-width: 0; overflow: hidden; color: var(--color-text-muted); font-size: var(--font-size-xs); text-overflow: ellipsis; white-space: nowrap; }
.house-title[data-lined] { border-bottom: var(--house-hairline); }
:root[data-house-framed] .house-title { display: none; }

/* Field -----------------------------------------------------------------
   Mirrors settings.css's input/select/textarea geometry: the field owns its
   border, padding, focus, and validation — features never restate them. */

.house-field {
  width: 100%;
  min-width: 0;
  height: var(--house-field-height);
  padding: 0 var(--space-08);
  color: var(--color-text);
  background: var(--color-field);
  border: var(--house-line);
  border-radius: var(--house-radius);
  outline: 0;
}
textarea.house-field { height: auto; min-height: calc(var(--house-field-height) * 3); padding: var(--space-07) var(--space-08); line-height: 1.45; resize: vertical; }
.house-field::placeholder { color: var(--color-text-faint); opacity: 1; }
.house-field:hover { border-color: var(--color-border); }
.house-field:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
/* Validation is a border and an ink, never a second shape beside the field. */
.house-field[data-invalid] { border-color: var(--color-danger); }
.house-field:disabled { color: var(--color-disabled); cursor: default; }
.house-field-label { display: grid; gap: var(--space-04); color: var(--color-text-muted); font-size: var(--font-size-sm); }
.house-field-note { color: var(--color-text-faint); font-size: var(--font-size-xs); }
.house-field-label:has(.house-field[data-invalid]) .house-field-note { color: var(--color-danger); }

/* Control ---------------------------------------------------------------
   Mirrors global.css `.primitive-header-control` (height, type, icon
   alignment, hover ground) and views.css `.prompt-submit` for the primary
   variant's accent ground and its in-place pending state. */

.house-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 0;
  height: var(--house-control-height);
  align-items: center;
  gap: var(--space-05);
  padding: 0 var(--space-07);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--house-radius);
  font: var(--house-control-font);
  white-space: nowrap;
}
.house-control:is(:hover, :focus-visible, [aria-expanded="true"], [aria-pressed="true"]) { color: var(--color-text); background: var(--color-hover); }
.house-control:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.house-control[data-variant="outlined"] { color: var(--color-text-muted); background: var(--color-field); border-color: var(--color-border-soft); }
.house-control[data-variant="primary"] { color: var(--color-on-accent); background: var(--color-accent); border-color: transparent; }
.house-control[data-variant="primary"]:not(:disabled):hover { background: color-mix(in srgb, var(--color-accent) 86%, var(--color-text)); }
.house-control:disabled { color: var(--color-text-faint); background: var(--color-hover-strong); border-color: transparent; }
/* No anonymous spinner. The phase word takes the label's own pixels — the
   hidden label still measures the box, so nothing adjacent moves (DESIGN
   feedback: transient state replaces action chrome in place). Give the
   control `data-phase="Sending"`; assistive technology reads it from
   `aria-busy` plus the accessible name the caller sets alongside. */
.house-control[data-pending] { color: var(--color-text-muted); background: transparent; border-color: var(--color-accent); }
.house-control[data-pending] > * { visibility: hidden; }
.house-control[data-pending]::after { position: absolute; display: grid; inset: 0; place-items: center; overflow: hidden; content: attr(data-phase); pointer-events: none; }
.house-control-group { display: inline-flex; align-items: center; gap: var(--space-02); }

/* Chip ------------------------------------------------------------------
   Mirrors primitives.css `.primitive-chip` and global.css `.object-chip`:
   one compact size discipline, the alternate face because a chip quotes an
   exact machine name, and copy as a hairline-divided cell of the same box. */

.house-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: var(--house-chip-min-height);
  align-items: center;
  overflow: hidden;
  padding: 0 var(--space-08);
  color: var(--color-text-muted);
  background: var(--color-field);
  border: var(--house-line);
  border-radius: var(--house-radius);
  font: 500 var(--font-size-xs)/1.2 var(--font-mono);
  vertical-align: middle;
}
.house-chip[data-copy] { align-items: stretch; padding: 0; }
.house-chip-label { display: inline-flex; min-width: 0; align-items: center; overflow: hidden; padding: var(--space-03) var(--space-06); text-overflow: ellipsis; white-space: nowrap; }
.house-chip-kind { display: inline-flex; align-self: stretch; align-items: center; padding: var(--space-03) var(--space-05); color: var(--color-text-faint); background: var(--color-hover); border-right: var(--house-hairline); font-size: var(--font-size-2xs); text-transform: uppercase; }
.house-chip-copy { display: grid; flex: 0 0 auto; padding: 0 var(--space-06); place-items: center; color: var(--color-text-faint); background: transparent; border: 0; border-left: var(--house-hairline); }
.house-chip-copy:is(:hover, :focus-visible) { color: var(--color-text); background: var(--color-hover-strong); }

/* Tabs ------------------------------------------------------------------
   Mirrors views.css `.project-view-nav`: the selected tab is a ground. No
   underline, no edge bar, no active stripe (DESIGN selection law). */

.house-tabs { display: flex; min-height: var(--house-tab-height); align-items: center; gap: var(--space-04); }
.house-tab { padding: var(--space-05) var(--space-07); color: var(--color-text-faint); background: transparent; border: 0; border-radius: var(--house-radius); font-size: var(--font-size-sm); white-space: nowrap; }
.house-tab:hover { color: var(--color-text); background: var(--color-hover); }
.house-tab:is([aria-selected="true"], [aria-current="page"]) { color: var(--color-text); background: var(--color-selected); }

/* Table -----------------------------------------------------------------
   Mirrors primitives.css `.row` and views.css `.search-table`. One column
   template, named once on the table as `--house-columns` and inherited by the
   header and every row, so a column lines up down the whole page. Every row
   reserves its top hairline transparent and a run's first row colors it, so
   grouping costs no height. Selection is a ground and nothing else. */

.house-table { width: var(--house-layout-width); min-width: 0; margin-inline: auto; }
.house-table[data-wide] { width: var(--house-wide-width); }
/* Inside a surface the table takes the surface's own width: a wide surface
   already released the measure, and a table has nothing to center against. */
.house-surface .house-table { width: 100%; }
.house-table-head,
.house-row { display: grid; grid-template-columns: var(--house-columns); column-gap: var(--space-08); align-items: baseline; padding: var(--space-03) var(--space-09); }
.house-table-head { position: sticky; z-index: 2; top: 0; color: var(--color-text-faint); background: var(--house-ground); border-bottom: var(--house-hairline); font-size: var(--font-size-xs); }
.house-row { --house-row-ground: transparent; min-height: var(--house-row-min-height); background: var(--house-row-ground); border-top: 1px solid transparent; border-radius: var(--house-radius); text-align: left; }
.house-row[data-starts-run] { border-top-color: var(--color-border-soft); }
.house-row:first-of-type { border-top-color: transparent; }
.house-row:hover { --house-row-ground: var(--color-hover); }
.house-row[aria-selected="true"] { --house-row-ground: var(--color-selected); }
.house-row[data-current] { --house-row-ground: var(--color-hover-strong); }
/* Both at once is still ground: combine them rather than adding a shape. */
.house-row[data-current][aria-selected="true"] { --house-row-ground: color-mix(in srgb, var(--color-selected) 60%, var(--color-hover-strong)); }
.house-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.house-cell[data-numeric] { font-variant-numeric: tabular-nums; text-align: right; }
/* The reserved lead slot: empty at rest, a glyph or a check on the same
   pixels, so engaging selection moves no column (primitives `.row-lead`). */
.house-row-lead { display: inline-flex; width: var(--house-row-lead-width); height: var(--house-row-lead-width); align-items: center; justify-content: center; color: var(--color-text-faint); }

/* Figures ---------------------------------------------------------------
   Mirrors budget.css `.cost-headline`: a muted label and one large exact
   value on a shared baseline, tabular so a column of them lines up. A row of
   figures is a wrapping strip with no box around any of them — there is no
   card primitive, and a figure earns its ground from the page it sits on. The
   value keeps the UI face; the headline's alternate face is for money the
   machine wrote, not for a count (DESIGN typography). Units go in the label
   ("Cost, USD") or the note, never beside the number. */

.house-figures { display: flex; flex-wrap: wrap; gap: var(--space-12) var(--space-25); margin: 0; padding: 0 var(--space-12); }
.house-figure { display: grid; min-width: 0; flex: 0 1 auto; gap: var(--space-03); margin: 0; }
.house-figure-label { color: var(--color-text-muted); font-size: var(--font-size-sm); font-weight: 600; }
.house-figure-value { margin: 0; font-size: var(--font-size-heading); font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; }
.house-figure-note { margin: 0; color: var(--color-text-faint); font-size: var(--font-size-xs); }

/* Notice and failure ----------------------------------------------------
   Mirrors views.css `.job-action-message` and `.failure-block`. A failure
   serves two audiences: one human sentence saying what did not happen, what
   survived, and the next safe action; and one bounded, pasteable diagnostic
   of `label: value` lines in the alternate face. The outlined block IS the
   failed content — it occupies the slot it replaces, and a placement wrapper
   may position it but never adds another frame or inset around it. */

.house-notice { width: 100%; min-width: 0; padding: var(--space-06) var(--space-09); color: var(--color-warning); font-size: var(--font-size-sm); line-height: 1.4; }
.house-failure {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  align-self: stretch;
  background: var(--color-field);
  border: var(--house-line);
  border-radius: var(--house-radius);
  font-size: var(--font-size-body);
  line-height: 1.4;
}
.house-failure-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-06) var(--space-10); padding: var(--space-05) var(--space-07) var(--space-05) var(--space-09); }
/* The sentence shares the control height so head and actions sit on one line;
   a narrow host wraps the action group as a unit rather than shrinking it. */
.house-failure-head > p { display: flex; min-width: 0; min-height: var(--house-control-height); flex: 1 1 auto; align-items: center; color: var(--color-danger); }
.house-failure-actions { display: flex; max-width: 100%; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: var(--space-02); margin-left: auto; }
/* Details remains text: the diagnostic continues the same frame rather than
   opening a second surface. */
.house-failure details { border-top: var(--house-line); }
.house-failure summary { padding: var(--space-05) var(--space-09); color: var(--color-text-muted); font-size: var(--font-size-sm); cursor: pointer; }
.house-failure summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.house-failure-diagnostic {
  /* views.css states --failure-block-max-height as a token-less 176px literal;
     it is named here for the same reason, so it stays retunable in one place. */
  --house-diagnostic-max-height: 176px;
  display: block;
  width: 100%;
  max-height: var(--house-diagnostic-max-height);
  margin: 0;
  padding: var(--space-08) var(--space-09);
  overflow: auto;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-top: var(--house-line);
  font: var(--font-size-xs)/1.45 var(--font-mono);
  white-space: pre-wrap;
}
.house-failure > :last-child :is(.house-failure-diagnostic, pre, textarea) { border-bottom-right-radius: var(--house-radius); border-bottom-left-radius: var(--house-radius); }

/* Waiting ---------------------------------------------------------------
   No anonymous spinner: a read is a shaped placeholder or a named phase word.
   Mirrors viewer.css `.doc-composition-skeleton`, views.css
   `.job-composition-skeleton`, and primitives.css `.row-skeleton`. */

.house-skeleton { display: grid; gap: var(--space-05); padding: var(--space-12) var(--space-17); border: 1px solid var(--color-border-soft); border-radius: var(--house-radius); }
.house-skeleton i { display: block; width: 72%; height: var(--space-07); background: var(--color-border-soft); border-radius: var(--space-02); }
.house-skeleton i:last-child { width: 46%; }
/* One placeholder standing in a single row's cell, where a whole block would
   be a lie about the shape that is coming. */
.house-skeleton-line { display: block; width: var(--house-skeleton-width, 100%); height: var(--space-11); background: var(--color-hover-strong); border-radius: var(--space-02); }
.house-phase { color: var(--color-text-faint); font-size: var(--font-size-sm); }
/* A wait that resolves quickly paints content instead of flashing a word
   (views.css `.view-message`). Failures stay instant. */
.house-phase[data-deferred] { animation: house-waiting-reveal .2s ease-out .15s backwards; }
@keyframes house-waiting-reveal { from { opacity: 0; } }

/* Alternate face --------------------------------------------------------
   One UI face. This is reserved for content the machine authored verbatim and
   the surface quotes rather than narrates: tool text, file content, wire
   truth. Prose never takes it (DESIGN typography). */

.house-mono { color: var(--color-text-muted); font: var(--font-size-xs)/1.45 var(--font-mono); white-space: pre-wrap; }
pre.house-mono { margin: 0; padding: var(--space-15); overflow: auto; background: var(--color-field); border: var(--house-line); border-radius: var(--house-radius); }

/* Palette, typography and control behavior come from ../house, as in Workbench.
   Header placement mirrors Workbench's 7px frame inset, 4px top inset,
   32px rail header, and 12px BrandMark. Controls use House's existing
   Workbench header geometry and typography without overrides. */
body {
  min-height: 100svh;
  padding: var(--space-05) var(--space-09);
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--space-26);
  padding-inline: var(--space-06);
  gap: var(--space-07);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--house-radius);
}
h1 {
  display: flex;
  align-items: center;
  gap: var(--space-07);
  margin: 0;
  font: var(--house-control-font);
  white-space: nowrap;
}
.brand-slot { display: grid; width: var(--house-control-height); height: var(--house-control-height); place-items: center; }
/* BrandMark is 12px in the app, independent of the compact spacing ladder. */
.brand-mark { display: block; width: 12px; height: 12px; }
.brand-mark .on { fill: var(--color-accent); }
.brand-mark .off { fill: color-mix(in srgb, var(--color-text) 13%, transparent); }
nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-04);
}
nav .house-control {
  text-decoration: none;
}
[hidden] { display: none !important; }
button { cursor: pointer; }
#email-fallback {
  width: 100%;
  margin-top: var(--space-16);
  padding: var(--space-12);
  border: 1px solid var(--color-border);
  border-radius: var(--house-radius);
  background: var(--color-field);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
@media (forced-colors: active) {
  nav .house-control { border: 1px solid ButtonText; }
}
