/* MauiBloom design system — implements docs/ux/brand-directions/design_handoff_skin/README.md.
   One hand-written stylesheet, no framework, no imagery. Colour is wayfinding: each pipeline phase
   owns one hue and keeps it everywhere it appears, and orange is reserved for moments when money is
   at stake. Every text token holds WCAG 2.2 AA contrast against the surfaces it sits on — the
   handoff's §3.3 reconciliation supersedes the mockups where they disagree, so each hue carries two
   variants: the base for borders/fills/large text, the -strong for small text and white-on-fill. */

/* ---- Fonts (self-hosted; no third-party font request, §4.1) ---- */

@font-face {
    font-family: "Space Grotesk";
    src: url("fonts/space-grotesk-var.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("fonts/ibm-plex-mono-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ---- Tokens (§3.5) ----

   Every token is declared once as light-dark(light, dark), so the ladder has a single source and
   the two themes can never drift apart. Which half applies is decided entirely by `color-scheme`:
   `light dark` on :root follows the operating system, and the [data-theme] attribute the server
   writes on <html> pins it (studio conventions rule 3). Dark values follow §3.4 — each hue lifted
   until it clears 4.5:1 on the dark panel, ladder order intact. */

:root {
    color-scheme: light dark;
}

/* The MauiBloom tokens. Also declared on [data-brand="bloom"] so the /brands board can show the
   MauiBloom look beside the other brand styles (wwwroot/brands/*.css), and so MauiBloom still
   renders where a deployment made another style its default. */
:root,
[data-brand="bloom"] {
    --font-ui: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-machine: "IBM Plex Mono", ui-monospace, SFMono-Regular, "Cascadia Mono", monospace;

    --phase-research: light-dark(#3b4fe0, #93a2ff);
    --phase-research-strong: light-dark(#3341c9, #b3beff);
    --phase-plan: light-dark(#7c3aed, #b795f8);
    --phase-plan-strong: light-dark(#6d2fd4, #cbb0ff);
    --phase-implement: light-dark(#0e8f8c, #2ba8a4);
    --phase-implement-strong: light-dark(#0b6b68, #4fd1cd);
    --phase-review: light-dark(#d6336c, #ff8fb4);
    --phase-review-strong: light-dark(#c22557, #ffabc7);
    --money: light-dark(#e2521f, #f0703d);
    --money-text: light-dark(#b23a10, #ff9468);
    --money-rule: light-dark(#f2d3c5, #4a3128);

    --ink: light-dark(#10131a, #e8ebf1);
    --ink-body: light-dark(#2b313b, #d5dae3);
    --ink-soft: light-dark(#525b69, #aab2bf);
    --ink-faint: light-dark(#727d8e, #7d8697);    /* non-text only: rules and glyphs */
    --ink-mute: light-dark(#98a1b0, #6b7482);     /* disabled and skipped states only */

    --line: light-dark(#ccd3de, #3a414d);
    --line-soft: light-dark(#e4e8ee, #2b313b);
    --track: light-dark(#dfe4ea, #2e343e);
    --panel: light-dark(#ffffff, #1b1f27);
    --ground: light-dark(#eef1f5, #14171d);
    --rail: light-dark(#f4f6f8, #191d24);
    --inset: light-dark(#f7f8fb, #22262f);

    --radius: 0;
    --shadow-sheet: 0 8px 30px rgba(16, 19, 26, .10);
    --focus: var(--phase-research);

    /* Tints derive from the hues so a phase-tinted background never drifts out of step. */
    --tint-research: light-dark(rgba(59, 79, 224, .08), rgba(147, 162, 255, .12));
    --tint-plan: light-dark(rgba(124, 58, 237, .08), rgba(183, 149, 248, .12));
    --tint-implement: light-dark(rgba(14, 143, 140, .08), rgba(43, 168, 164, .14));
    --tint-review: light-dark(rgba(214, 51, 108, .08), rgba(255, 143, 180, .12));
    --tint-money: light-dark(rgba(226, 82, 31, .08), rgba(240, 112, 61, .12));
    --rail-hover: light-dark(#e8ecf1, #232833);

    /* The blueprint ground's rules — the only gradient in the product (§5.2). */
    --blueprint-line: light-dark(rgba(59, 79, 224, .07), rgba(147, 162, 255, .09));
    --blueprint-rule: light-dark(rgba(59, 79, 224, .08), rgba(147, 162, 255, .10));

    /* White on a filled hue in light, near-black on the lifted hue in dark. */
    --on-hue: light-dark(#ffffff, #10131a);
    --primary-hover: light-dark(#2a3ab0, #b3beff);
    --affirm-hover: light-dark(#0a5f5d, #7fe3e0);
}

/* The override the theme form writes, applied to <html> server-side so the choice is in the first
   paint and nothing flashes. Absent attribute = follow the system. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }


/* ---- Base ---- */

*,
*::before,
*::after {
    box-sizing: border-box;
    border-radius: var(--radius);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-ui);
    font-size: 0.9375rem;
    line-height: 1.6;
    background: var(--ground);
    color: var(--ink-body);
    -webkit-font-smoothing: antialiased;
}

/* The page column — and the application shell around it — grow to the viewport so the rail's edge
   and the footer land where the eye expects them on a short screen. */
body > main.page,
body > .app-shell {
    flex: 1 0 auto;
}

/* The public page column is a flex item with auto side margins, which sizes it to its content
   instead of the viewport, so one wide table (the rate card) widened the whole page on a phone.
   A definite width keeps the column inside the viewport and lets .table-scroll scroll the table. */
body > main.page {
    width: 100%;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-ui);
    color: var(--ink);
    text-wrap: pretty;
    margin: 0 0 0.6rem;
}

h1 {
    font-size: 1.6875rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.3125rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 1.75rem;
}

h3 {
    font-size: 1rem;
    line-height: 1.2;
    font-weight: 600;
    margin-top: 1.25rem;
}

p {
    margin: 0 0 0.85rem;
    text-wrap: pretty;
}

/* Prose measure — body copy never runs wider than the eye can track (§4.2). */
main.page > p,
.prose {
    max-width: 37.5rem;
}

/* A single centred column narrower than prose measure (verify email, §6.5). */
.centered-sheet {
    max-width: 32.5rem;
    margin: 0 auto;
    text-align: center;
}

.centered-sheet .inset {
    text-align: left;
    margin: 1.375rem 0;
}

a {
    color: var(--phase-research);
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--phase-research-strong);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line-soft);
    margin: 1.5rem 0;
}

code,
kbd,
samp,
pre {
    font-family: var(--font-machine);
}

/* ---- Utilities ---- */

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

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--panel);
    color: var(--phase-research);
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--phase-research);
    z-index: 40;
}

.skip-link:focus-visible {
    left: 0.5rem;
    top: 0.5rem;
}

/* Machine-emitted strings: ids, file names, counts, timings, stage names, currency (§4). */
.mono {
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    line-height: 1.4;
}

/* The uppercase mono noun that titles a region (§9). */
.label {
    display: block;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 0 0 0.6rem;
}

.label.research { color: var(--phase-research); }
.label.plan { color: var(--phase-plan); }
.label.implement { color: var(--phase-implement-strong); }
.label.review { color: var(--phase-review-strong); }
.label.money { color: var(--money-text); }

.inset {
    background: var(--inset);
    border: 1px solid var(--line-soft);
    padding: 0.85rem 1rem;
}

.inset.mono-block {
    font-family: var(--font-machine);
    font-size: 0.84375rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.muted {
    color: var(--ink-soft);
}

.small {
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* Margin resets. Classes rather than style attributes: the site's Content-Security-Policy has no
   style-src 'unsafe-inline', so an inline style attribute is blocked before it ever applies. */
.flush { margin-bottom: 0; }
.flush-top { margin-top: 0; }
.flush-all { margin: 0; }

/* A decorative text glyph — always paired with a word, always hidden from AT (§5.11). */
.glyph {
    font-family: var(--font-machine);
    color: var(--ink-faint);
}

/* Blueprint ground — the landing hero, the intake canvas, the run canvas, nowhere else (§5.2).
   The grid is the page's ground, not a panel texture: it paints as a fixed, full-viewport layer
   behind the content, so it reaches every edge and stays put while the page scrolls. */
.blueprint {
    position: relative;
}

.blueprint::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(var(--blueprint-line) 1px, transparent 1px) 0 0 / 100% 28px;
}

.blueprint.ruled::before {
    background:
        linear-gradient(var(--blueprint-line) 1px, transparent 1px) 0 0 / 100% 28px,
        linear-gradient(90deg, var(--blueprint-rule) 1px, transparent 1px) 0 0 / 28px 100%;
}

/* The intake conversation sits on its own blueprint canvas, padded like a panel region. */
.blueprint.canvas {
    padding: 1.25rem 1.5rem;
}

/* ---- Logotype (§5.3): four phase bars and the wordmark, as markup, never an image ---- */

.logotype {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--ink);
}

.logotype-bars {
    display: flex;
    gap: 2px;
}

.logotype-bars span {
    width: 5px;
    height: 15px;
}

.logotype-bars span:nth-child(1) { background: var(--phase-research); }
.logotype-bars span:nth-child(2) { background: var(--phase-plan); }
.logotype-bars span:nth-child(3) { background: var(--phase-implement); }
.logotype-bars span:nth-child(4) { background: var(--phase-review); }

.logotype-word {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: -0.02em;
    color: inherit;
}

/* ---- Buttons (§5.4) ---- */

.btn,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.875rem 1.5rem;
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    border: 1.5px solid transparent;
    background: var(--phase-research);
    color: var(--on-hue);
    transition: background-color 120ms linear, color 120ms linear, border-color 120ms linear;
}

.btn:hover,
.button-link:hover {
    background: var(--primary-hover);
    color: var(--on-hue);
}

.btn.compact {
    padding: 0.75rem 1.25rem;
    font-size: 0.84375rem;
}

.btn.small {
    min-height: 32px;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
}

/* Approve / add funds. The only affirm-green in the product, and it appears twice (§5.4). */
.btn.affirm {
    background: var(--phase-implement-strong);
    color: var(--on-hue);
}

.btn.affirm:hover {
    background: var(--affirm-hover);
    color: var(--on-hue);
}

.btn.secondary,
.button-link.secondary {
    background: var(--panel);
    color: var(--phase-research);
    border-color: var(--phase-research);
}

.btn.secondary:hover,
.button-link.secondary:hover {
    background: var(--tint-research);
    color: var(--phase-research);
}

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

.btn.neutral:hover {
    background: var(--panel);
    color: var(--ink);
    border-color: var(--ink);
}

.btn.destructive {
    background: var(--panel);
    color: var(--phase-review);
    border-color: var(--phase-review);
}

.btn.destructive:hover {
    background: var(--tint-review);
    color: var(--phase-review);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    background: var(--panel);
    color: var(--ink-mute);
    border-color: var(--line);
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: var(--panel);
    color: var(--ink-mute);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5625rem;
    align-items: center;
    margin: 1rem 0;
}

/* Icon-only row actions (credentials table): a 44px target with the glyph as the visible cue and
   the accessible name on the button itself (aria-label), so the row never repeats the provider. */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    border-color: var(--ink-soft);
    background: var(--tint-implement);
}

.icon-btn.destructive:hover,
.icon-btn.destructive:focus-visible {
    color: var(--phase-review);
    border-color: var(--phase-review);
}

.icon-btn[disabled] {
    opacity: 0.5;
    cursor: default;
}

.credential-table td.actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.key-safety {
    margin: 0;
    padding-left: 1rem;
}

.key-safety li + li {
    margin-top: 0.5rem;
}

/* Work-in-progress notice carried in every title bar: visible on every page, not colour-only. */
.wip-banner {
    font-family: var(--font-machine);
    font-size: 0.6875rem;
    line-height: 1.3;
    letter-spacing: 0.02em;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--phase-review);
    border-radius: 3px;
    color: var(--phase-review);
    max-width: 40rem;
}

/* A control that reads as prose but behaves as a button. */
.link-button {
    background: none;
    border: 0;
    padding: 0;
    min-height: 24px;
    font: inherit;
    color: var(--phase-research);
    text-decoration: underline;
    cursor: pointer;
}

/* ---- Status badge (§5.5): never filled, never a pill ---- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: 1.5px solid var(--phase-research);
    color: var(--phase-research);
    background: none;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge.ok,
.badge.implement {
    border-color: var(--phase-implement);
    color: var(--phase-implement-strong);
}

.badge.alert,
.badge.money {
    border-color: var(--money);
    color: var(--money-text);
}

.badge.plan {
    border-color: var(--phase-plan);
    color: var(--phase-plan);
}

.badge.review {
    border-color: var(--phase-review);
    color: var(--phase-review-strong);
}

.badge.neutral {
    border-color: var(--line);
    color: var(--ink-soft);
}

/* ---- Panels and cards (§5.1) ---- */

.panel,
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1.125rem 1.25rem;
}

.panel.pad-lg,
.card.pad-lg {
    padding: 1.625rem 1.75rem;
}

/* Phase membership is a 3px coloured left border on an otherwise plain white panel. */
.panel.research { border-left: 3px solid var(--phase-research); }
.panel.plan { border-left: 3px solid var(--phase-plan); }
.panel.implement { border-left: 3px solid var(--phase-implement); }
.panel.review { border-left: 3px solid var(--phase-review); }
.panel.money { border-left: 3px solid var(--money); }

.panel.emphasis-implement { border: 1.5px solid var(--phase-implement-strong); }
.panel.emphasis-money { border: 1.5px solid var(--money); }
.panel.emphasis-research { border: 1.5px solid var(--phase-research); }
.panel.emphasis-review { border: 2px solid var(--phase-review); }

.card.accent-top { border-top: 3px solid var(--phase-research); }
.card.ok-top { border-top: 3px solid var(--phase-implement); }
.card.plan-top { border-top: 3px solid var(--phase-plan); }
.card.money-top { border-top: 3px solid var(--money); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.875rem;
    margin: 1rem 0;
}

.card-grid.three {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

/* A callout takes a 4px accent where a panel takes 3px. */
.callout {
    background: var(--inset);
    border: 1px solid var(--line-soft);
    border-left: 4px solid var(--phase-research);
    padding: 0.875rem 1.0625rem;
    margin: 1rem 0;
}

.callout.plan { border-left-color: var(--phase-plan); }
.callout.implement { border-left-color: var(--phase-implement); }
.callout.review { border-left-color: var(--phase-review); }
.callout.money { border-left-color: var(--money); }

.notice-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.85rem 1.0625rem;
    background: var(--inset);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--money);
    margin: 1rem 0;
}

.placeholder-note {
    padding: 0.85rem 1.0625rem;
    background: var(--inset);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--phase-plan);
    color: var(--ink-body);
    margin: 1rem 0;
}

/* A panel's own label paired with a badge on the same line (LIVE SKETCH, ON THIS PATH, etc.). */
.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.panel-head .label {
    margin: 0;
}

/* ---- Stage row (§5.7): the workhorse of the app ---- */

.stage-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stage-row {
    display: flex;
    align-items: baseline;
    gap: 0.875rem;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--phase-research);
    padding: 0.75rem 0.9375rem;
}

.stage-row.plan { border-left-color: var(--phase-plan); }
.stage-row.implement { border-left-color: var(--phase-implement); }
.stage-row.review { border-left-color: var(--phase-review); }

/* A stage's own tier/provider/model pickers sit inline in the row, not at the full-width form-control size. */
.stage-row select,
.stage-row input.stage-model {
    width: auto;
    min-height: 34px;
    padding: 0.25rem 0.4rem;
    font-family: var(--font-machine);
    font-size: 0.71875rem;
}

.stage-row .stage-tier {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

.stage-row input.stage-model {
    max-width: 14rem;
}

.stage-row .stage-name {
    flex: 0 0 8rem;
    font-family: var(--font-machine);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink);
}

.stage-row .stage-desc {
    flex: 1 1 12rem;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

.stage-row .stage-status {
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--phase-research);
}

.stage-row.plan .stage-status { color: var(--phase-plan); }
.stage-row.implement .stage-status { color: var(--phase-implement-strong); }
.stage-row.review .stage-status { color: var(--phase-review-strong); }

.stage-row .stage-tier {
    flex: 0 0 3.5rem;
    text-align: right;
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    color: var(--ink-soft);
}

.stage-row .stage-cost {
    flex: 0 0 2.75rem;
    text-align: right;
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--money-text);
}

/* Queued or held: dashed, inset, everything muted, no phase border. */
.stage-row.queued {
    border: 1px dashed var(--line);
    background: var(--inset);
}

.stage-row.queued .stage-name,
.stage-row.queued .stage-desc,
.stage-row.queued .stage-status,
.stage-row.queued .stage-tier,
.stage-row.queued .stage-cost {
    /* A skipped stage is still information the customer reads (which stage, how to re-enable it),
       so it keeps the body-soft ink: --ink-mute is for disabled controls only and fails WCAG AA
       contrast on the inset background. The dashed inset border and plain text carry the state. */
    color: var(--ink-soft);
}

/* In progress: a full 2px hue border instead of the left rule. */
.stage-row.active { border: 2px solid var(--phase-research); }
.stage-row.active.plan { border-color: var(--phase-plan); }
.stage-row.active.implement { border-color: var(--phase-implement); }
.stage-row.active.review { border-color: var(--phase-review); }

/* Completed in preview: still legible, visibly settled. */
.stage-row.done-earlier {
    background: var(--inset);
    opacity: .75;
}

/* ---- Progress strip (§5.6): never a single rounded bar, never animated ---- */

.progress-strip {
    display: flex;
    gap: 2px;
    height: 8px;
    margin: 0 0 0.4rem;
    padding: 0;
    list-style: none;
}

.progress-strip li,
.progress-strip > span {
    display: block;
    flex: 1 1 0;
    background: var(--track);
}

.progress-strip .done.research { background: var(--phase-research); }
.progress-strip .done.plan { background: var(--phase-plan); }
.progress-strip .done.implement { background: var(--phase-implement); }
.progress-strip .done.review { background: var(--phase-review); }
.progress-strip .current { background: var(--money); }

.progress-labels {
    display: flex;
    gap: 2px;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.progress-labels li {
    flex: 1 1 0;
}

.progress-labels .current { color: var(--money-text); }
.progress-labels .research { color: var(--phase-research); }
.progress-labels .plan { color: var(--phase-plan); }
.progress-labels .implement { color: var(--phase-implement-strong); }
.progress-labels .review { color: var(--phase-review-strong); }

/* ---- Gate card (§5.8): the most important component in the product ---- */

.gate-card {
    border: 2px solid var(--money);
    background: var(--panel);
    padding: 1.5rem 1.625rem;
    margin: 1.25rem 0;
}

.gate-card > header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-family: var(--font-machine);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--money-text);
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--money-rule);
}

.gate-card > header .gate-state {
    font-weight: 400;
    letter-spacing: 0.1em;
    color: var(--ink-soft);
}

/* The gate's name is a real heading; the header's own type carries the styling. */
.gate-card > header h2 {
    margin: 0;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.gate-card > header .glyph {
    color: inherit;
}

.gate-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 19.5rem);
    gap: 1.875rem;
    padding-top: 1.25rem;
}

.gate-body > .gate-evidence {
    border-left: 1px solid var(--money-rule);
    padding-left: 1.875rem;
}

.gate-question {
    font-size: 1.5rem;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 0 0 1rem;
}

.gate-actions {
    display: flex;
    gap: 0.5625rem;
    flex-wrap: wrap;
    margin-top: 1.125rem;
}

/* balance now → after / run cap · not reached (§5.8). */
.balance-maths {
    background: var(--inset);
    border: 1px solid var(--line-soft);
    padding: 0.75rem 0.875rem;
    margin: 0.875rem 0;
    font-family: var(--font-machine);
    font-size: 0.84375rem;
    line-height: 1.7;
    color: var(--ink-body);
}

/* ---- Money (§5.9) ---- */

.money-figure {
    font-family: var(--font-machine);
    font-size: 0.8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--money-text);
    white-space: nowrap;
}

.money-figure.large {
    font-family: var(--font-ui);
    font-size: 1.75rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--money);
}

.money-figure.range {
    font-family: var(--font-ui);
    font-size: 1.875rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--money);
}

.money-figure.range .to {
    font-size: 1.1875rem;
    font-weight: 400;
    color: var(--ink-soft);
}

.figure-large {
    font-family: var(--font-ui);
    font-size: 1.75rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

/* Spend against a cap. Never animated. */
.spend-bar {
    display: block;
    height: 7px;
    background: var(--track);
    margin: 0.625rem 0 0.4rem;
}

.spend-bar > span {
    display: block;
    height: 100%;
    background: var(--money);
}

/* ---- Tables (§5.10): semantic tables, never CSS grid ---- */

.table-scroll {
    overflow-x: auto;
    min-width: 0;
    /* Positioned, so the visually hidden text inside a table (absolutely positioned) is clipped
       with the table. Otherwise a hidden label in a column scrolled out of view still widens the
       page. */
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 0.84375rem;
}

table caption {
    text-align: left;
    padding: 0 0 0.5rem;
    font-family: var(--font-machine);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

table th,
table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 0.75rem;
    text-align: left;
    color: var(--ink-body);
}

table th[scope="col"] {
    font-family: var(--font-machine);
    font-size: 0.625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--phase-research);
    background: var(--tint-research);
}

table th[scope="row"] {
    font-weight: 600;
    color: var(--ink);
}

table td.amount,
table th.amount {
    text-align: right;
    font-family: var(--font-machine);
    font-variant-numeric: tabular-nums;
    color: var(--money-text);
    white-space: nowrap;
}

table th.amount[scope="col"] {
    color: var(--phase-research);
}

table tr.total th,
table tr.total td {
    font-weight: 700;
    font-size: 0.875rem;
    border-top: 1px solid var(--line);
}

table.plain th[scope="col"] {
    color: var(--phase-plan);
    background: var(--tint-plan);
}

table td.mono-cell {
    font-family: var(--font-machine);
    font-size: 0.78125rem;
}

/* ---- Forms (§8: real labels; a placeholder is not a label) ---- */

button,
input,
select,
textarea {
    font: inherit;
    color: var(--ink);
}

.field {
    display: block;
    margin: 0 0 1rem;
    max-width: 35rem;
}

.field > label,
.field-label {
    display: block;
    margin: 0 0 0.4rem;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.75rem;
    background: var(--panel);
    border: 1.5px solid var(--line);
    color: var(--ink);
}

textarea {
    min-height: 5.5rem;
    line-height: 1.55;
}

/* A file input's intrinsic width (button + "No file chosen") exceeds a 320px column; bound it so
   the page reflows instead of scrolling sideways (WCAG 1.4.10). */
input[type="file"] {
    max-width: 100%;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    border-color: var(--phase-research);
}

.field .hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--ink-soft);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.875rem;
    max-width: 35rem;
}

/* An input flush against its submit button — one bordered unit, no gap (§6.3, §6.6). */
.composer {
    display: flex;
    border: 1.5px solid var(--phase-research);
    background: var(--panel);
    max-width: 42rem;
}

.composer input,
.composer textarea {
    flex: 1 1 auto;
    min-height: 44px;
    border: 0;
    background: none;
    padding: 0.75rem 0.875rem;
}

/* The chat box: tall enough to draft a real answer, and the customer can pull it taller. */
.composer textarea {
    min-height: 7.5rem;
    resize: vertical;
    line-height: 1.5;
}

.composer input:focus-visible,
.composer textarea:focus-visible {
    outline-offset: -3px;
}

.composer .btn {
    border: 0;
    flex: 0 0 auto;
}

/* While a reply is in flight the send button becomes a stop control: same slot, a block glyph. */
.composer .btn.stop {
    min-width: 4rem;
    font-size: 1.125rem;
    line-height: 1;
}

/* Waiting state under the transcript: worded, with an animated ellipsis (§6.6). */
.thinking {
    margin: 0.75rem 0 0;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    color: var(--phase-research);
}

.thinking .ellipsis span {
    display: inline-block;
    opacity: 0;
    animation: ellipsis 1.4s infinite;
}

.thinking .ellipsis span:nth-child(2) { animation-delay: 0.2s; }
.thinking .ellipsis span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ellipsis {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

.composer-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: 42rem;
    margin-top: 0.5rem;
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    color: var(--ink-soft);
}

.composer-meta .progress {
    color: var(--phase-research);
}

fieldset {
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 1rem 1.125rem;
    margin: 0 0 1.25rem;
}

legend {
    padding: 0 0.4rem;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* ---- Wallet: preset amounts to add (one radio per amount) ----
   Each label is the whole target (44px tall, WCAG 2.5.8), so the small native radio never has to
   be hit; the chosen amount is marked by the money colour on its border as well as by the radio. */

fieldset.amount-picker {
    border: 0;
    background: none;
    padding: 0;
    margin: 0 0 0.875rem;
}

fieldset.amount-picker legend {
    padding: 0;
    margin: 0 0 0.5rem;
}

.amount-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.625rem;
}

.amount-choices label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.375rem 0.875rem;
    background: var(--panel);
    border: 1.5px solid var(--line);
    font-family: var(--font-machine);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    cursor: pointer;
}

.amount-choices input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    accent-color: var(--money);
}

.amount-choices label:has(input:checked) {
    border-color: var(--money);
}

.amount-choices label:has(input:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* ---- Tabs (§6.7, §6.12) ---- */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    border-bottom: 1px solid var(--line);
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
}

.tabs button,
.tabs a {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 0.625rem 0.125rem;
    min-height: 44px;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    color: var(--ink-soft);
    text-decoration: none;
    cursor: pointer;
}

.tabs [aria-selected="true"],
.tabs [aria-pressed="true"],
.tabs [aria-current="page"],
.tabs [aria-current="true"] {
    border-bottom-color: var(--phase-research);
    color: var(--phase-research);
    font-weight: 500;
}

.tabs.implement [aria-selected="true"],
.tabs.implement [aria-pressed="true"] {
    border-bottom-color: var(--phase-implement);
    background: var(--tint-implement);
    color: var(--phase-implement-strong);
    padding-inline: 0.75rem;
}

/* ---- Chip rows (artifacts so far, finished items) ---- */

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4375rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3125rem 0.5rem;
    border: 1px solid var(--line);
    background: var(--panel);
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    color: var(--ink-body);
    text-decoration: none;
}

/* An auto-fixed item is shown, never silent (§6.9). */
.chip.fixed {
    border: 1.5px solid var(--money-text);
    color: var(--money-text);
}

/* ---- Row and route lists (settings, retention, "three ways forward") ---- */

.row-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.row-list > li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.9375rem 0.125rem;
    border-bottom: 1px solid var(--line-soft);
}

/* A destructive row is still body-sized text, so it takes the -strong variant, not the border hue. */
.row-list > li.destructive,
.row-list > li.destructive a {
    color: var(--phase-review-strong);
}

.route-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.route-list > li {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    padding: 0.875rem 1rem;
}

.route-list > li.research { border-left-color: var(--phase-research); }
.route-list > li.plan { border-left-color: var(--phase-plan); }
.route-list > li.implement { border-left-color: var(--phase-implement); }
.route-list > li.review { border-left-color: var(--phase-review); }
.route-list > li.money { border-left-color: var(--money); }

.route-list .route-title {
    font-weight: 600;
    color: var(--ink);
}

.route-list .consequence {
    display: block;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

/* Receipts and fact lists. */
.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    margin: 0.75rem 0 0;
    font-size: 0.84375rem;
}

.facts dt {
    color: var(--ink-soft);
}

.facts dd {
    margin: 0;
    font-family: var(--font-machine);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.feature-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.84375rem;
}

.feature-list li::before {
    /* The tick is decorative and paired with the word it marks, so it carries an empty text
       alternative — assistive technology reads the item, never the glyph (§5.11). */
    content: "\2713\0020" / "";
    font-family: var(--font-machine);
    font-weight: 600;
    color: var(--phase-implement-strong);
}

/* A list where each row leads with its own glyph (done/current/deferred), not a fixed checkmark. */
.glyph-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4375rem;
    font-size: 0.8125rem;
}

.glyph-list li {
    display: flex;
    align-items: baseline;
    gap: 0.5625rem;
}

/* Per-field connection results (§6.7). */
.check-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.check-list li {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.84375rem;
}

.check-list .mark {
    font-family: var(--font-machine);
    font-weight: 600;
}

.check-list .pass .mark { color: var(--phase-implement-strong); }
.check-list .fail .mark { color: var(--phase-review-strong); }

.check-list .check-field {
    flex: 0 0 7.5rem;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    color: var(--ink);
}

/* ---- Layout ---- */

/* Page width: wide enough for the application tables (credentials, stages) to breathe on a
   desktop display; narrower screens simply fill the viewport. */
main.page {
    max-width: 100rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.layout-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
    gap: 1.75rem;
    align-items: start;
}

.layout-side.wide-aside {
    grid-template-columns: minmax(0, 1fr) minmax(0, 21.875rem);
}

.layout-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1.75rem;
    align-items: start;
}

.sidebar > section,
.sidebar > .panel,
.sidebar > .card {
    margin-bottom: 0.875rem;
}

/* An aside that follows the reader down a long column (the intake Continue panel): sticky inside
   the grid row, so the next action stays in view without scrolling back up. */
.sidebar.follow {
    position: sticky;
    top: 1.25rem;
}

/* Confirm / not-yet controls the guide's confirmation question offers (intake). */
.confirm-row {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    margin: 0.75rem 0 0;
}

.composer-hint {
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    color: var(--ink-soft);
}

/* ---- Run status 1.3: summary, progress bar, step table, feed, work items, terminal ---- */

/* Full-width run screen: no sidebar; the table and progress bar span the page. */
.run-screen { max-width: none; }

.run-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
    margin: 1rem 0 0.75rem;
}

.run-tabs [role="tab"] {
    background: none;
    border: 1px solid transparent;
    border-bottom: 0;
    padding: 0.5rem 0.9rem;
    font-family: var(--font-machine);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
}

.run-tabs [role="tab"][aria-selected="true"] {
    color: var(--ink);
    border-color: var(--line);
    background: var(--panel);
    margin-bottom: -1px;
}

.run-tabs .tab-count {
    margin-left: 0.4rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

/* Fixed headers: the wrapper scrolls, the head stays. */
.table-scroll.sticky-head {
    max-height: 60vh;
    overflow: auto;
}

.table-scroll.sticky-head thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
    box-shadow: 0 1px 0 var(--line);
}

.costs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 56rem) {
    .costs-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Work items: an accordion per row inside the grid. */
.wi-grid { border: 1px solid var(--line); background: var(--panel); }
.wi-head, .wi-row summary {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr) 7rem 9rem 7rem;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0.875rem;
}
.wi-head {
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--panel);
}
.wi-row { border-bottom: 1px solid var(--line); }
.wi-row summary { cursor: pointer; list-style: none; }
.wi-row summary::-webkit-details-marker { display: none; }
.wi-row[open] summary { background: color-mix(in srgb, var(--phase-plan) 8%, transparent); }
.wi-body { padding: 0.5rem 0.875rem 0.875rem 6.875rem; }
.wi-body ul { margin: 0.25rem 0 0.75rem 1.25rem; padding: 0; }
.wi-steps { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.25rem 0 0.75rem; }
.wi-steps .badge { text-transform: none; letter-spacing: 0; }

/* Artifact tree. */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 1.25rem; border-left: 1px dashed var(--line); margin-left: 0.4rem; }
.tree details > summary { cursor: pointer; padding: 0.15rem 0; }
.tree li { padding: 0.1rem 0; }
.tree .folder { font-weight: 600; }
.tree .file a { text-decoration: none; }
.tree .size { color: var(--ink-soft); margin-left: 0.4rem; }

/* Artifacts tab: tree beside a preview. */
.artifact-split {
    display: grid;
    grid-template-columns: minmax(14rem, 1fr) minmax(0, 2.2fr);
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 56rem) { .artifact-split { grid-template-columns: minmax(0, 1fr); } }
.artifact-preview { border: 1px solid var(--line); background: var(--panel); padding: 0.75rem 1rem; min-height: 12rem; }
.artifact-frame { width: 100%; height: 70vh; border: 1px solid var(--line); background: #fff; }
.artifact-image { max-width: 100%; height: auto; }
.artifact-md { max-width: 48rem; }
.tree .linkish { background: none; border: 0; padding: 0; color: var(--phase-research); cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em; font: inherit; }
.tree .file.selected .linkish { color: var(--ink); font-weight: 600; }
.tree .file a { text-decoration: underline; text-underline-offset: 0.15em; }
.tree .file a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tree li.file { border-left: 3px solid transparent; padding-left: 0.4rem; }
.tree li.file.research { border-left-color: var(--phase-research); }
.tree li.file.plan { border-left-color: var(--phase-plan); }
.tree li.file.implement { border-left-color: var(--phase-implement); }
.tree li.file.review { border-left-color: var(--phase-review); }

/* Run picker on the storyboard and artifact screens. */
.run-picker { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.run-picker select { max-width: 28rem; }

/* Storyboard screens: every mockup in its own sandboxed frame. */
.mockup-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 1.25rem;
    margin: 0.5rem 0 1.5rem;
}
.mockup-card { margin: 0; border: 1px solid var(--line); background: var(--panel); }
.mockup-card figcaption { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
.mockup-frame { width: 100%; height: 40rem; border: 0; background: #fff; display: block; }
.storyboard-doc { margin-top: 1rem; }
.summary-grid .money-figure { color: var(--money-text); }

/* Terminal overlay. */
.terminal-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 40;
    font-family: var(--font-machine);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.55rem 0.9rem;
    background: #0e1116;
    color: #d5dbe5;
    border: 1px solid var(--line);
    cursor: pointer;
}

.terminal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(8, 10, 14, 0.88);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
}

.terminal-overlay .terminal-controls { color: #d5dbe5; }
.terminal-overlay .terminal { flex: 1 1 auto; max-height: none; }
.terminal-overlay .terminal-close { margin-left: auto; }

.summary-panel { margin-top: 1rem; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
    gap: 0.75rem 1rem;
    margin: 0 0 0.875rem;
}

.summary-grid dt {
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.summary-grid dd { margin: 0.2rem 0 0; }

.summary-grid .figure {
    font-family: var(--font-machine);
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    height: 0.75rem;
    background: var(--inset);
    border: 1px solid var(--line);
    overflow: hidden;
}

.progress-bar-fill {
    display: block;
    width: 100%;
    height: 100%;
    color: var(--phase-implement);
}

.progress-caption { margin: 0.4rem 0 0; }

.step-table th[scope="row"] { white-space: nowrap; }
.step-table td { white-space: nowrap; }
.step-table .step-note { white-space: normal; display: block; }

.step-status { font-family: var(--font-machine); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.step-status.running { color: var(--phase-implement); }
.step-status.completed { color: var(--phase-plan); }
.step-status.failed { color: var(--phase-review); }
.step-status.notstarted, .step-status.skipped { color: var(--ink-soft); }
.step-status.awaitingapproval { color: var(--money); }

.step-row.active th, .step-row.active td { background: color-mix(in srgb, var(--phase-implement) 8%, transparent); }
.step-row.queued th, .step-row.queued td { color: var(--ink-soft); }

.feed {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    max-height: 22rem;
    overflow: auto;
    border: 1px solid var(--line);
    background: var(--panel);
}

.feed-line {
    display: flex;
    gap: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.875rem;
}

.feed-line.stage-started .feed-text { color: var(--phase-implement); }
.feed-line.stage-failed .feed-text { color: var(--phase-review); }
.feed-line.stage-awaitingapproval .feed-text { color: var(--money); }
.feed-time { flex: 0 0 auto; }

.work-item { border: 1px solid var(--line); background: var(--panel); margin: 0 0 0.5rem; }
.work-item summary { padding: 0.6rem 0.875rem; cursor: pointer; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.work-item-body { padding: 0 0.875rem 0.875rem; }
.work-item-body ul { margin: 0.25rem 0 0.75rem 1.25rem; padding: 0; }

.artifact-list { list-style: none; margin: 0.5rem 0 0; padding: 0; columns: 2; column-gap: 1.5rem; }
.artifact-list li { break-inside: avoid; padding: 0.15rem 0; }

.terminal-controls { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 0.75rem 0; }
.terminal-controls input[type="text"] { min-width: 16rem; }

.terminal {
    background: #0e1116;
    color: #d5dbe5;
    border: 1px solid var(--line);
    padding: 0.75rem 1rem;
    max-height: 70vh;
    overflow: auto;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.term-line { display: block; }
.term-time { color: #7a8494; }
.term-level { color: #9fb3c8; }
.term-cat { color: #8ab4f8; }
.term-line.warning .term-level { color: #f0c674; }
.term-line.error .term-level, .term-line.critical .term-level { color: #ff7b72; }

/* Upload a requirements document at intake (label above the native file input). */
.upload-row {
    margin-top: 1rem;
    max-width: 42rem;
}

.upload-row label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--ink-soft);
}

.section-block {
    margin-top: 2rem;
}

/* ---- Signed-in home: one card per app, the phase strip, state-matched next step ---- */

.home-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.home-head h1 { margin-bottom: 0.25rem; }

.home-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.home-empty { max-width: 40rem; margin-top: 1rem; }

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
    gap: 0.875rem;
    margin: 1rem 0;
    padding: 0;
    list-style: none;
}

.app-grid > li { display: flex; }

/* The card stretches to its row so the next step sits on one line across the grid. */
.app-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.app-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    margin: 0;
    font-size: 1.0625rem;
    overflow-wrap: anywhere;
}

.app-card h3 .app-icon { width: 28px; height: 28px; }
.app-card h3 a { min-width: 0; text-decoration: none; }
.app-card h3 a:hover, .app-card h3 a:focus-visible { text-decoration: underline; }

.app-card .progress-strip { margin-top: 0.5rem; }
.app-card .progress-strip .current.failed { background: var(--phase-review); }

.app-card .app-phase {
    margin-top: 0;
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.app-card-actions {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-wrap: wrap;
    margin: auto 0 0;
    padding-top: 0.5rem;
}

/* ---- Design page (P06): asset cards, option cards, palette swatches ---- */

/* The skip action is a secondary strip under the status line (disclaimer left, button right), not a
   third path beside the two tabs; its armed confirm takes the full width. */
.skip-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.5rem;
}

.skip-action h2 {
    margin: 0 0 0.25rem;
}

.skip-action p,
.skip-action .btn-row {
    margin: 0;
}

.skip-action .callout {
    flex-basis: 100%;
    margin: 0;
}

.asset-grid {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 0.75rem;
}

.asset-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--phase-plan);
    padding: 0.75rem 0.9375rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.asset-card h3 { margin: 0; }
.asset-card .facts { margin: 0; }

/* Thumbnails sit on a checkerboard so a transparent background reads as transparent. */
.asset-thumb {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border: 1px solid var(--line);
    background: repeating-conic-gradient(rgba(127, 127, 127, 0.18) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
}

.option-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.option-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--phase-plan);
    padding: 0.875rem 1.0625rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.option-card:hover { border-color: var(--phase-plan); }

/* The chosen card: a thick plan-coloured frame, a tinted surface and a badge in its head — the
   selection must read at a glance, not from a radio button somewhere below. */
.option-card.selected {
    border-color: var(--phase-plan-strong);
    border-left-width: 6px;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--phase-plan) 35%, transparent);
    background: color-mix(in srgb, var(--phase-plan) 7%, var(--panel));
}

.option-card h4 { margin: 0 0 0.35rem; }

.option-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.option-select {
    width: 100%;
    margin-top: 0.75rem;
}

.swatch-row {
    list-style: none;
    margin: 0.25rem 0 0.5rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.swatch-row li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    color: var(--ink-soft);
}

.swatch {
    display: block;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    border-radius: 2px;
}

.option-preview {
    display: block;
    width: 256px;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    margin-top: 0.5rem;
}

.stage-row .stage-note {
    display: block;
    margin-top: 0.25rem;
}

/* ---- Shared chrome: public header and footer (§6.1) ---- */

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.site-header .bar {
    max-width: 100rem;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
}

.site-nav a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.84375rem;
    font-weight: 500;
}

.site-nav a:hover {
    color: var(--phase-research);
}

.account-chrome {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.account-chrome > a:not(.btn) {
    font-size: 0.84375rem;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
}

.account-chrome > a:not(.btn):hover {
    color: var(--phase-research);
}

.account-email {
    font-family: var(--font-machine);
    font-size: 0.71875rem;
    color: var(--ink-soft);
}

.sign-out button {
    background: none;
    border: 0;
    padding: 0.4rem 0;
    min-height: 24px;
    font-family: var(--font-ui);
    font-size: 0.84375rem;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
}

.sign-out button:hover {
    color: var(--phase-research);
}

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--panel);
    margin-top: 2rem;
}

.site-footer .bar {
    max-width: 100rem;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
    color: var(--ink-soft);
    font-size: 0.8125rem;
}

.site-footer a {
    color: var(--ink-soft);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--phase-research);
}

/* The company credit sits inside a sentence ("Created by …"), so its link carries an underline:
   a link in running text must not rely on colour alone to stand out from the words around it. */
.publisher-credit a {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* Light/dark override (studio conventions rule 3). Three real submit buttons, no script, no
   dropdown: the choice is one click and the current one says so in text, not by colour alone. */
.theme-choice {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    flex-wrap: wrap;
}

.theme-choice .label {
    margin: 0;
}

.theme-choice button {
    min-height: 32px;
    padding: 0.375rem 0.625rem;
    background: var(--panel);
    border: 1px solid var(--line);
    font-family: var(--font-machine);
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
}

.theme-choice button:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.theme-choice button[aria-pressed="true"] {
    border-color: var(--phase-research);
    color: var(--phase-research);
    font-weight: 600;
}

/* ---- Application chrome: dark header, phase rail (§6.1) ---- */

.app-header {
    background: #10131a;
    padding: 0.6875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-wrap: wrap;
}

.app-header .logotype,
.app-header .logotype-word,
.app-header .run-name {
    color: #ffffff;
}

.app-header .label {
    margin: 0;
    color: #8a93a3;
}

.app-header a:not(.logotype) {
    color: #c3c9d4;
    font-size: 0.84375rem;
    text-decoration: none;
}

.app-header a:not(.logotype):hover {
    color: #ffffff;
}

.app-header .run-name {
    font-size: 0.875rem;
    font-weight: 700;
}

.app-header .account-email {
    margin-left: auto;
    color: #8a93a3;
}

.app-header .wip-banner {
    color: #f0b35a;
    border-color: #f0b35a;
}

.app-header .sign-out button {
    color: #c3c9d4;
}

.app-header-progress {
    height: 3px;
    background: var(--line);
}

.app-header-progress > span {
    display: block;
    height: 100%;
    background: var(--phase-research);
}

/* The 3px strip under the dark bar. It carries run progress once a run is in view; with no run in
   context it is the rule that separates the bar from the shell. */
.app-header-rule {
    height: 3px;
    background: var(--line);
}

/* Rail beside the page column. The rail stretches the full height of the shell so its right edge
   reads as a wall, not a stub. */
.app-shell {
    display: flex;
    align-items: stretch;
}

.app-shell > main.page {
    flex: 1 1 auto;
    min-width: 0;
}

.app-rail {
    flex: 0 0 13.25rem;
    align-self: stretch;
    background: var(--rail);
    border-right: 1px solid var(--line);
    padding: 1rem 0 2rem;
}

.app-rail .rail-group:first-of-type {
    margin-top: 0;
}

.app-rail .rail-group {
    margin: 1.125rem 0 0.4rem;
    padding: 0 1rem;
    font-family: var(--font-machine);
    font-size: 0.59375rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.app-rail ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-rail a {
    display: block;
    padding: 0.5rem 1rem;
    border-left: 3px solid transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
}

.app-rail a.research { border-left-color: var(--phase-research); }
.app-rail a.plan { border-left-color: var(--phase-plan); }
.app-rail a.implement { border-left-color: var(--phase-implement); }
.app-rail a.review { border-left-color: var(--phase-review); }
.app-rail a.money { border-left-color: var(--money); }

.app-rail a:hover {
    background: var(--rail-hover);
}

.app-rail a[aria-current="page"] {
    background: var(--inset);
    font-weight: 600;
}

/* The top action sits above the groups, styled as a quiet primary: the one thing the rail asks
   you to do when you have nothing in flight. */
.app-rail .rail-top {
    padding: 0 1rem 0.25rem;
}

.app-rail .rail-action {
    border: 1px solid var(--line);
    border-left-width: 3px;
    background: var(--panel);
    padding: 0.5rem 0.75rem;
}

.app-rail .rail-empty {
    margin: 0;
    padding: 0.25rem 1rem 0.5rem;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

/* Each app is a native disclosure (no script): the server opens the one the page belongs to. The
   summary carries only the icon and the name, because browsers expose a summary as a button. The
   caret conveys open state together with the native open attribute, never colour alone. */
.app-rail details.rail-app > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}

.app-rail details.rail-app > summary::-webkit-details-marker {
    display: none;
}

.app-rail details.rail-app > summary::before {
    content: "";
    flex: 0 0 auto;
    width: 0.375rem;
    height: 0.375rem;
    border-right: 1.5px solid var(--ink-soft);
    border-bottom: 1.5px solid var(--ink-soft);
    transform: rotate(-45deg);
    transition: transform 120ms ease;
}

.app-rail details.rail-app[open] > summary::before {
    transform: rotate(45deg);
}

.app-rail details.rail-app > summary:hover {
    background: var(--rail-hover);
}

.app-rail details.rail-app > summary:focus-visible {
    outline: 2px solid var(--phase-research);
    outline-offset: -2px;
}

.app-rail .rail-icon {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    border: 1px solid var(--line);
    background: var(--panel);
    object-fit: cover;
}

.app-rail .rail-app-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Leaves indent under their app; the phase border stays the wayfinding cue. */
.app-rail details.rail-app > ul a {
    padding-left: 2.5rem;
}

/* ---- Landing (§6.2) ---- */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 2.5rem;
    align-items: start;
    padding: 1.5rem 0 2.875rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.04;
    letter-spacing: -0.035em;
    margin: 1rem 0 0;
}

.hero .accent {
    color: var(--phase-research);
}

.hero .lead {
    max-width: 29.375rem;
    margin-top: 0.875rem;
    font-size: 1rem;
    line-height: 1.6;
}

.hero .reassurance {
    margin-top: 1rem;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    color: var(--ink-soft);
}

/* Four butted segments in phase order, white micro-type on the -strong fills. */
.stage-strip {
    display: inline-flex;
    flex-wrap: wrap;
    margin: 0;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.stage-strip span {
    padding: 0.375rem 0.625rem;
    color: var(--on-hue);
}

.stage-strip .research { background: var(--phase-research-strong); }
.stage-strip .plan { background: var(--phase-plan-strong); }
.stage-strip .implement { background: var(--phase-implement-strong); }
.stage-strip .review { background: var(--phase-review-strong); }

.cta-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* The one decorative offset in the product: a hard block, never a blur (§6.2). */
.demo-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 8px 8px 0 rgba(59, 79, 224, .10);
}

.demo-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--line);
}

.demo-steps {
    list-style: none;
    margin: 0;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.demo-steps li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.6875rem;
    border-left: 3px solid var(--phase-research);
    background: var(--tint-research);
    font-family: var(--font-machine);
    font-size: 0.75rem;
    color: var(--ink-body);
}

.demo-steps li.plan-stage {
    border-left-color: var(--phase-plan);
    background: var(--tint-plan);
}

.demo-steps li.implement-stage {
    border-left-color: var(--phase-implement);
    background: var(--tint-implement);
}

.demo-steps li.deliver-stage {
    border-left-color: var(--phase-review);
    background: var(--tint-review);
}

.demo-steps li.gate {
    background: none;
    border: 1.5px solid var(--money);
    color: var(--money-text);
    font-weight: 600;
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.demo-steps .artifact {
    color: var(--ink-soft);
}

.demo-panel > .panel-foot {
    margin: 0;
    padding: 0 1.1rem 1.1rem;
}

/* ---- Transcript (§6.6) ---- */

.transcript {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 46rem;
}

.transcript .q {
    max-width: 37.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--phase-research);
    padding: 0.875rem 1.0625rem;
    font-size: 0.96875rem;
}

/* Guide replies are rendered markdown (ChatMarkdown): tight block spacing inside the bubble. */
.transcript .q .md > :first-child { margin-top: 0; }
.transcript .q .md > :last-child { margin-bottom: 0; }

.transcript .q .md p,
.transcript .q .md ul,
.transcript .q .md ol,
.transcript .q .md blockquote,
.transcript .q .md pre {
    margin: 0 0 0.7rem;
}

.transcript .q .md ul,
.transcript .q .md ol {
    padding-left: 1.35rem;
}

.transcript .q .md li { margin: 0.2rem 0; }

.transcript .q .md h1,
.transcript .q .md h2,
.transcript .q .md h3,
.transcript .q .md h4,
.transcript .q .md h5,
.transcript .q .md h6 {
    font-size: 1rem;
    line-height: 1.35;
    margin: 0.7rem 0 0.35rem;
}

.transcript .q .md code {
    font-family: var(--font-machine);
    font-size: 0.85em;
    padding: 0.05em 0.3em;
    background: var(--inset, rgba(127, 127, 127, 0.12));
}

.transcript .q .md pre {
    overflow-x: auto;
    padding: 0.75rem 0.875rem;
    background: var(--inset, rgba(127, 127, 127, 0.12));
}

.transcript .q .md pre code {
    padding: 0;
    background: none;
}

.transcript .q .md blockquote {
    border-left: 3px solid var(--line);
    padding-left: 0.8rem;
    color: var(--ink-soft);
}

.transcript .q .md hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 0.7rem 0;
}

.transcript .q .who,
.transcript .a .who {
    display: block;
    margin-bottom: 0.45rem;
    font-family: var(--font-machine);
    font-size: 0.65625rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.transcript .q .who {
    color: var(--phase-research);
}

.transcript .a {
    align-self: flex-end;
    max-width: 32.5rem;
    background: var(--phase-research);
    color: var(--on-hue);
    padding: 0.8125rem 1.0625rem;
    white-space: pre-wrap;
}

.transcript .a .who {
    color: var(--on-hue);
    opacity: .82;
}

/* ---- Pricing (§6.4) ---- */

.price-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.price {
    font-size: 2.375rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.price-caption {
    font-size: 0.875rem;
    color: var(--ink-soft);
}

.worked-example {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1.5rem 1.625rem;
    margin: 1.25rem 0;
}

.worked-example > header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.spread-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.875rem;
    margin-top: 1.25rem;
}

.spread-cards .figure {
    display: block;
    margin: 0.5rem 0;
    font-family: var(--font-machine);
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--money-text);
}

/* ---- Artifact browser (§6.12) ---- */

.artifact-layout {
    display: grid;
    grid-template-columns: 14.375rem minmax(0, 1fr);
    gap: 1.625rem;
    margin-top: 1.5rem;
    align-items: start;
}

.artifact-layout.with-aside {
    grid-template-columns: 14.375rem minmax(0, 1fr) 14.375rem;
}

.artifact-nav ul {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.artifact-nav a,
.artifact-nav .static-item {
    display: block;
    padding: 0.25rem 0.625rem;
    border-left: 3px solid var(--line);
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    line-height: 1.95;
    color: var(--ink-body);
    text-decoration: none;
}

.artifact-nav a.research { border-left-color: var(--phase-research); }
.artifact-nav a.plan { border-left-color: var(--phase-plan); }
.artifact-nav a.implement { border-left-color: var(--phase-implement); }
.artifact-nav a.review { border-left-color: var(--phase-review); }

.artifact-nav a:hover {
    color: var(--phase-research);
}

.artifact-nav a[aria-current="page"] {
    background: var(--tint-research);
    color: var(--phase-research);
    font-weight: 500;
}

.artifact-nav .nested {
    padding-left: 1.375rem;
}

.artifact-nav .static-item {
    /* Present but not browsable — still read by a sighted user, so it takes the text floor
       (--ink-soft), never the disabled tone. */
    color: var(--ink-soft);
}

pre.code-block {
    background: var(--inset);
    border: 1px solid var(--line-soft);
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.78125rem;
    line-height: 1.9;
    color: var(--ink-body);
}

/* The building screen's streaming artifact (§6.9). */
.stream-block {
    background: var(--inset);
    border: 1px solid var(--line-soft);
    padding: 0.875rem 1rem;
    font-family: var(--font-machine);
    font-size: 0.78125rem;
    line-height: 1.9;
    white-space: pre-wrap;
    color: var(--ink-body);
}

.stream-block .cursor {
    color: var(--money);
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    to { visibility: hidden; }
}

/* ---- Responsive (§7): sidebars stack, the rail scrolls, gates go single-column ---- */

@media (max-width: 56rem) {
    /* minmax(0, 1fr) rather than 1fr: a bare 1fr floors at the column's min-content width, which
       lets a wide table or code block push the whole document sideways at 320px. */
    .hero,
    .layout-side,
    .layout-side.wide-aside,
    .artifact-layout,
    .artifact-layout.with-aside,
    .gate-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .gate-body > .gate-evidence {
        border-left: 0;
        border-top: 1px solid var(--money-rule);
        padding-left: 0;
        padding-top: 1.25rem;
    }

    .hero {
        padding: 1rem 0 2rem;
    }

    .app-shell {
        display: block;
    }

    /* Below the collapse point the rail stacks above the page (§7). The Apps tree keeps its vertical
       shape with only the current app open, so a narrow screen never carries a horizontal strip of
       nested links; the Account leaves wrap into one row. Targets grow to the 44px floor. */
    .app-rail {
        display: block;
        max-width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 0.5rem 0 0.75rem;
    }

    .app-rail .rail-group {
        margin: 0.75rem 0 0.25rem;
    }

    .app-rail ul.rail-account {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 0.5rem;
        padding: 0 1rem;
    }

    .app-rail ul.rail-account a {
        border-left: 0;
        border-bottom: 3px solid transparent;
        padding: 0.625rem 0.5rem;
    }

    .app-rail ul.rail-account a.implement { border-bottom-color: var(--phase-implement); }
    .app-rail ul.rail-account a.money { border-bottom-color: var(--money); }
    .app-rail ul.rail-account a.review { border-bottom-color: var(--phase-review); }

    .app-rail a,
    .app-rail details.rail-app > summary {
        min-height: 2.75rem;
        display: flex;
        align-items: center;
    }

    .app-rail a {
        white-space: nowrap;
    }
}

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

    .stream-block .cursor {
        animation: none;
    }

    .thinking .ellipsis span {
        animation: none;
        opacity: 1;
    }
}

/* Keys mode: the stage dropdown highlights the recommended pick; a row without a key is greyed by the browser (disabled). */
.stage-row .stage-tier select.recommended { border-color: var(--accent, #512bd4); box-shadow: 0 0 0 2px rgba(81, 43, 212, 0.18); }
.stage-row .stage-tier option.recommended { font-weight: 600; }
.stage-row .stage-rec { display: block; margin-top: 0.25rem; color: var(--accent, #512bd4); }

/* ---- App pages: app heading and the latest pages' provenance line ---- */
.app-icon { flex: none; width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--line); background: var(--panel); }
.app-heading h1 { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.app-heading .app-icon { width: 32px; height: 32px; }
.app-rename { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.app-rename input { max-width: 20rem; }
.provenance { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 1rem; }


/* ---- Brand-style previews (Theme/BrandStyle.cs, wwwroot/brands/*.css) ---- */

/* The second half of the wordmark; inherits in the default look, so "MauiBloom" reads as before. */
.logotype-tail {
    color: inherit;
}

/* The style switch sits beside the theme switch in the footer. */
.theme-choice.brand-choice {
    margin-left: 0;
}

.theme-choice.brand-choice a.label {
    color: var(--ink-soft);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.force-light { color-scheme: light; }
.force-dark { color-scheme: dark; }

.brand-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 0.75rem 0 1.75rem;
}

.brand-board {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 1.125rem;
    background: var(--ground);
    color: var(--ink-body);
    font-family: var(--font-ui);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-width: 0;
}

.brand-board > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.brand-board .logotype-word {
    font-size: 1.25rem;
}

.brand-board .brand-idea {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ink-soft);
}

.brand-specimen {
    padding: 1rem;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}

.brand-specimen .brand-h {
    margin: 0.75rem 0 0.5rem;
    font-family: var(--font-display, var(--font-ui));
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.brand-specimen .accent {
    color: var(--phase-research);
}

.brand-specimen .cta-row {
    margin-top: 0.875rem;
}

.brand-specimen .btn {
    pointer-events: none;
}

.swatches {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
    gap: 0.375rem;
}

.swatches li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-family: var(--font-machine);
    font-size: 0.625rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.swatches li::before {
    content: "";
    display: block;
    height: 1.75rem;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) / 2);
}

.swatches .sw-research::before { background: var(--phase-research); }
.swatches .sw-plan::before { background: var(--phase-plan); }
.swatches .sw-implement::before { background: var(--phase-implement); }
.swatches .sw-review::before { background: var(--phase-review); }
.swatches .sw-money::before { background: var(--money); }
.swatches .sw-ink::before { background: var(--ink); }
.swatches .sw-panel::before { background: var(--panel); }
.swatches .sw-ground::before { background: var(--ground); }

.brand-board .specimen-type {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--ink-soft);
}

.brand-board .specimen-type strong {
    font-family: var(--font-display, var(--font-ui));
    font-size: 1.375rem;
    color: var(--ink);
    margin-right: 0.5rem;
}

.brand-board .brand-actions {
    margin-top: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.brand-board .brand-actions form {
    margin: 0;
}

@media (max-width: 56rem) {
    .brand-row {
        grid-template-columns: minmax(0, 1fr);
    }
}
