:root {
  color-scheme: light;
  --paper: #f5f7fa;
  --surface: #ffffff;
  --ink: #263444;
  --muted: #69788a;
  --line: #dbe2ea;
  --line-strong: #c8d2de;
  --blue: #2257c7;
  --blue-dark: #18449e;
  --blue-soft: #eaf0ff;
  --amber: #98651a;
  --amber-soft: #fff5dd;
  --red: #a43b3b;
  --red-soft: #fff0ef;
  --green: #28725c;
  --green-soft: #e5f4ee;
  --rail: #263444;
  font-family: "Segoe UI", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); }
a { color: var(--blue); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #7da6ff; outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: -5rem; left: 1rem; padding: .7rem 1rem; color: var(--ink); background: white; }
.skip-link:focus { top: 1rem; }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 1.35rem 1rem; color: white; background: var(--rail); }
.brand { display: flex; gap: .75rem; align-items: center; color: inherit; text-decoration: none; }
.brand > span:last-child, .brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -.01em; }
.brand small { margin-top: .05rem; color: #b7c3d0; font-size: .72rem; }
.brand-mark { position: relative; display: grid; align-content: center; gap: 3px; width: 2.35rem; height: 2.35rem; flex: none; padding: .52rem; border-radius: 6px; background: var(--blue); }
.brand-mark i { display: block; height: 3px; background: white; transform: skewX(-22deg); }
.brand-mark i:nth-child(1) { width: 100%; }
.brand-mark i:nth-child(2) { width: 72%; }
.brand-mark i:nth-child(3) { width: 45%; }
.rail nav { display: grid; gap: .25rem; margin-top: 2.8rem; }
.rail nav a { display: flex; gap: .65rem; align-items: center; min-height: 2.65rem; padding: .65rem .75rem; border-radius: 6px; color: #d8e0e8; text-decoration: none; font-size: .9rem; }
.rail nav a span { width: 1.1rem; color: #aab9c8; text-align: center; }
.rail nav a:hover, .rail nav a[aria-current="page"] { color: white; background: #34465a; }
.rail nav a[aria-current="page"] { box-shadow: inset 3px 0 var(--blue); }
.rail-foot { display: grid; gap: .9rem; margin-top: auto; }
.mode-pill { display: flex; gap: .5rem; align-items: center; margin: 0; color: #c7d2de; font-size: .72rem; }
.mode-pill > span { width: .5rem; height: .5rem; border-radius: 50%; background: #9db0c2; }
.mode-pill.live > span { background: #63c9a7; box-shadow: 0 0 0 3px rgba(99,201,167,.16); }
.user-block { display: flex; gap: .6rem; align-items: center; padding-top: .9rem; border-top: 1px solid #3e4e60; }
.user-block > span:last-child, .user-block strong, .user-block small { display: block; }
.user-block strong { font-size: .8rem; }
.user-block small { color: #aab9c8; font-size: .68rem; }
.avatar { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; color: var(--ink); background: #dce6f0; font-size: .76rem; font-weight: 750; }
.text-button { justify-self: start; padding: 0; border: 0; color: #b7c3d0; background: transparent; cursor: pointer; font-size: .74rem; }

.main { width: 100%; max-width: 1540px; padding: 2.35rem clamp(1.2rem, 3.2vw, 3.5rem) 5rem; }
.workspace-head, .page-head { display: flex; gap: 2rem; align-items: end; justify-content: space-between; margin-bottom: 1.6rem; }
.workspace-head h1, .page-head h1, .question-title h1 { margin: 0; font-size: clamp(1.8rem, 2.5vw, 2.6rem); line-height: 1.12; letter-spacing: -.035em; }
.workspace-head p, .page-head p, .question-title p { max-width: 66ch; margin: .5rem 0 0; color: var(--muted); }
.question-head { margin-bottom: 1rem; }
.question-topline { display: flex; align-items: center; justify-content: space-between; }
.back-link { display: inline-block; margin-bottom: .8rem; font-size: .82rem; text-decoration: none; }
.question-title { display: flex; gap: 2rem; align-items: start; justify-content: space-between; }
.question-title h1 { max-width: 34ch; }
.head-actions { display: flex; gap: .5rem; }
.button.compact { min-height: 2.2rem; padding: .4rem .7rem; font-size: .76rem; }
.queue-update { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin: -.45rem 0 1rem; padding: .7rem .8rem .7rem 1rem; border: 1px solid #b9caee; border-left: 4px solid var(--blue); border-radius: 6px; background: var(--blue-soft); }
.queue-update span, .queue-update strong, .queue-update small { display: block; }
.queue-update strong { color: var(--blue-dark); font-size: .82rem; }
.queue-update small { color: #526b8e; font-size: .68rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.65rem; padding: .58rem .95rem; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 650; text-decoration: none; }
.button:hover:not(:disabled) { filter: brightness(.96); }
.button:disabled { cursor: not-allowed; opacity: .52; }
.button.primary { color: white; background: var(--blue); }
.button.secondary { color: var(--blue); background: white; border-color: #aebfe5; }
.button.quiet { color: var(--ink); background: white; border-color: var(--line-strong); }
.button.danger { color: white; background: var(--red); }
.button.wide { width: 100%; }

.queue-tools { margin-bottom: 1rem; }
.search-box { display: flex; gap: .65rem; align-items: center; height: 3rem; padding: 0 .95rem; border: 1px solid var(--line-strong); border-radius: 7px; background: white; box-shadow: 0 1px 2px rgba(38,52,68,.04); }
.search-box > span { color: var(--muted); font-size: 1.2rem; }
.search-box input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: #8b98a7; }
.filter-tabs { display: flex; gap: .25rem; margin-top: .65rem; overflow-x: auto; }
.filter-tabs button { flex: none; min-height: 2.25rem; padding: .45rem .7rem; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: .78rem; }
.filter-tabs button span { margin-left: .25rem; padding: .05rem .32rem; border-radius: 99px; background: #e8edf3; font-variant-numeric: tabular-nums; }
.filter-tabs button:hover { background: #eaf0f7; }
.filter-tabs button[aria-pressed="true"] { color: var(--blue); background: var(--blue-soft); font-weight: 650; }
.filter-tabs button[aria-pressed="true"] span { color: white; background: var(--blue); }

.work-ledger { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 5px 22px rgba(38,52,68,.045); }
.ledger-heading { display: flex; align-items: baseline; justify-content: space-between; padding: .9rem 1.15rem; border-bottom: 1px solid var(--line); }
.ledger-heading h2 { margin: 0; font-size: .92rem; }
.ledger-heading span { color: var(--muted); font-size: .72rem; }
.ledger-row { position: relative; display: grid; grid-template-columns: 4px minmax(260px, 1fr) 95px 150px 118px; gap: 1rem; align-items: center; min-height: 5.25rem; padding: .8rem 1.15rem .8rem 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row:hover { background: #f9fbfd; }
.status-line { align-self: stretch; width: 4px; background: #aab6c3; }
.stage-draft_ready .status-line { background: var(--blue); }
.stage-generating .status-line { background: var(--amber); }
.response-answered .status-line { background: var(--green); }
.ledger-main strong, .ledger-main small, .ledger-id strong, .ledger-id small, .ledger-time small, .ledger-time span { display: block; }
.ledger-main strong { max-width: 72ch; line-height: 1.38; }
.ledger-main small { margin-top: .28rem; color: var(--muted); font-size: .73rem; }
.ledger-main .reply-origin { color: #4c6178; }
.ledger-id small { color: var(--muted); font-size: .65rem; }
.ledger-id strong { overflow: hidden; text-overflow: ellipsis; font-size: .82rem; font-variant-numeric: tabular-nums; }
.ledger-time { color: var(--muted); font-size: .68rem; }
.ledger-time span { margin-top: .15rem; }
.ledger-status { display: grid; justify-items: start; gap: .2rem; }
.ledger-status small { color: var(--muted); font-size: .64rem; }
.response-stack { display: grid; justify-items: end; gap: .2rem; }
.response-stack small { color: var(--muted); font-size: .68rem; }

.badge { display: inline-flex; width: max-content; align-items: center; min-height: 1.65rem; padding: .18rem .55rem; border-radius: 99px; color: var(--muted); background: #edf1f5; font-size: .7rem; white-space: nowrap; }
.badge.completed, .badge.draft_ready { color: var(--blue); background: var(--blue-soft); }
.badge.running, .badge.queued, .badge.generating { color: var(--amber); background: var(--amber-soft); }
.badge.failed { color: var(--red); background: var(--red-soft); }
.badge.observed, .badge.answered { color: var(--green); background: var(--green-soft); }
.badge.unanswered { color: #5d6c7e; background: #edf1f5; }

.system-details { margin-top: .8rem; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.72); }
.system-details > summary { display: flex; align-items: center; justify-content: space-between; min-height: 3rem; padding: .65rem 1rem; cursor: pointer; font-size: .8rem; font-weight: 650; }
.health-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); border-top: 1px solid var(--line); }
.health-grid article { min-width: 0; padding: 1rem; border-right: 1px solid var(--line); }
.health-grid article:last-child { border: 0; }
.health-grid h3 { margin: 0; font-size: .84rem; }
.health-grid article > p { overflow: hidden; margin: .25rem 0 .75rem; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.health-grid dl { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0; }
.health-grid dt { color: var(--muted); font-size: .62rem; }
.health-grid dd { margin: .1rem 0 0; font-size: .86rem; }
.health-grid .health-error { margin-top: .6rem; padding: .45rem; color: var(--red); background: var(--red-soft); white-space: normal; }
.job-list > div { display: grid; grid-template-columns: 90px 1fr auto; gap: 1rem; padding: .7rem 1rem; border-top: 1px solid var(--line); font-size: .78rem; }
.job-list small { color: var(--muted); }

.product-strip { display: grid; grid-template-columns: auto minmax(220px,1fr) auto auto; gap: 1rem 1.2rem; align-items: center; margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 7px; background: #edf2f7; }
.product-glyph { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border: 1px solid #c0cad5; border-radius: 5px; color: #627287; background: white; font-size: .72rem; font-weight: 800; }
.product-name small, .product-name strong, .product-name span { display: block; }
.product-name small { color: var(--muted); font-size: .64rem; }
.product-name strong { margin-top: .05rem; }
.product-name span { color: var(--muted); font-size: .72rem; }
.product-strip dl { display: flex; gap: 1.35rem; margin: 0; }
.product-strip dl div { min-width: 5rem; }
.product-strip dt { color: var(--muted); font-size: .62rem; }
.product-strip dd { max-width: 10rem; margin: .1rem 0 0; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; font-weight: 650; white-space: nowrap; }

.editor-card { margin-bottom: 1rem; padding: 1.25rem; border: 1px solid #b8c9ec; border-left: 4px solid var(--blue); border-radius: 7px; background: white; box-shadow: 0 7px 26px rgba(34,87,199,.07); }
.editor-head { display: flex; gap: 1rem; justify-content: space-between; }
.editor-head h2 { margin: 0; font-size: 1rem; }
.editor-head p { margin: .25rem 0 0; color: var(--muted); font-size: .76rem; }
.revision-chip { flex: none; padding: .2rem .55rem; border-radius: 4px; color: var(--blue); background: var(--blue-soft); font-size: .7rem; }
.editor-label { display: block; margin: 1rem 0 .35rem; color: var(--muted); font-size: .72rem; }
.editor-card textarea { width: 100%; min-height: 13rem; padding: .9rem 1rem; border: 1px solid #aebac8; border-radius: 6px; color: var(--ink); background: #fcfdff; resize: vertical; font-size: 1rem; line-height: 1.6; }
.editor-card textarea:focus { border-color: var(--blue); outline: 3px solid #dce7ff; }
.editor-meta { display: flex; justify-content: space-between; margin-top: .35rem; color: var(--muted); font-size: .67rem; }
.editor-actions { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.editor-actions > div { display: flex; gap: .5rem; flex-wrap: wrap; }
.disabled-reason { margin: .55rem 0 0; color: var(--muted); font-size: .7rem; text-align: right; }
.notice { margin-top: .9rem; padding: .65rem .75rem; border-radius: 5px; font-size: .78rem; }
.notice.info { color: #30557f; background: #edf5ff; }
.notice.danger { color: #7d2d2d; background: var(--red-soft); }

.version-tabs { display: flex; gap: .45rem; margin: 1rem 0; overflow-x: auto; }
.version-tabs a { min-width: 10rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: white; text-decoration: none; }
.version-tabs a[aria-current="page"] { border-color: var(--blue); background: var(--blue-soft); }
.version-tabs strong, .version-tabs span, .version-tabs small { display: block; }
.version-tabs span, .version-tabs small { color: var(--muted); font-size: .64rem; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.answer-pane { min-width: 0; min-height: 13rem; padding: 1.15rem; border: 1px solid var(--line); border-radius: 7px; background: white; }
.ai-pane { border-top: 3px solid #718296; }
.manager-pane { border-top: 3px solid var(--green); }
.pane-head { display: flex; gap: 1rem; align-items: start; justify-content: space-between; }
.pane-head h2 { margin: 0; font-size: .9rem; }
.pane-head small { display: block; margin-top: .12rem; color: var(--muted); font-size: .65rem; }
.answer-copy { max-width: 76ch; margin: 1.15rem 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.meta, .muted { color: var(--muted); font-size: .76rem; }
.padded { padding: 1rem; }
.attention { padding: .6rem .7rem; border-left: 3px solid var(--amber); color: #704d16; background: var(--amber-soft); font-size: .78rem; }
.warnings h3, .ai-evidence h3 { margin-bottom: .45rem; font-size: .78rem; }
.warnings { margin-top: .8rem; padding: .65rem .75rem; color: #704d16; background: var(--amber-soft); }
.warnings ul { margin: .3rem 0; padding-left: 1.2rem; }
.ai-evidence article { padding: .7rem 0; border-top: 1px solid var(--line); }
.ai-evidence strong, .ai-evidence blockquote { display: block; margin: .3rem 0; }
.ai-evidence blockquote { color: var(--muted); font-size: .78rem; }
.source-kind { color: var(--blue); font-size: .7rem; font-weight: 700; }
.run-meta { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .5rem; margin: 1rem 0 0; padding-top: .75rem; border-top: 1px solid var(--line); }
.run-meta dt { color: var(--muted); font-size: .62rem; }
.run-meta dd { margin: .1rem 0 0; overflow: hidden; text-overflow: ellipsis; font-size: .7rem; white-space: nowrap; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: white; }
.panel-head { display: flex; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: .9rem; }
.panel-head p { margin: .18rem 0 0; color: var(--muted); font-size: .7rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(290px,.7fr); gap: 1rem; align-items: start; }
.side-stack { display: grid; gap: 1rem; }
.evidence { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.evidence > div { display: flex; justify-content: space-between; color: var(--muted); font-size: .68rem; }
.evidence p { white-space: pre-wrap; overflow-wrap: anywhere; }
.evidence a { font-size: .75rem; }
.limitations { margin: .8rem; padding: .7rem; color: #704d16; background: var(--amber-soft); font-size: .75rem; }
.frozen-context { margin: .8rem; border: 1px solid var(--line); border-radius: 5px; }
.frozen-context summary { padding: .7rem .8rem; cursor: pointer; font-size: .76rem; font-weight: 650; }
.frozen-context pre { max-height: 32rem; margin: 0; padding: .9rem; overflow: auto; border-top: 1px solid var(--line); background: #f7f9fb; white-space: pre-wrap; overflow-wrap: anywhere; font: .7rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.comparison { padding: 1rem; border-bottom: 1px solid var(--line); font-size: .78rem; }
.difference-list article { margin-top: .65rem; padding: .65rem; background: #f6f8fa; }
.difference-list article > div { display: flex; justify-content: space-between; }
.difference-list p { margin: .3rem 0 0; }
.severity { color: var(--muted); font-size: .66rem; }
.severity.high { color: var(--red); }
.severity.medium { color: var(--amber); }
.comparison-list { margin-top: .7rem; }
.comparison-list ul { margin-top: .3rem; padding-left: 1.1rem; }
.feedback-history { padding: .8rem 1rem; }
.feedback-history h3 { font-size: .76rem; }
.feedback-history article { padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: .76rem; }
.feedback-history article:last-child { border: 0; }
.feedback-history p { margin: .35rem 0; }
.feedback-history small { color: var(--muted); }

.history-panel { margin-top: 1rem; }
.action-history article { position: relative; display: grid; grid-template-columns: 1rem 1fr; gap: .7rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.action-history article:last-child { border: 0; }
.history-dot { width: .55rem; height: .55rem; margin-top: .35rem; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.history-dot.publication { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.action-history strong { font-size: .78rem; }
.action-history p { max-width: 82ch; margin: .3rem 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .76rem; }
.action-history small { color: var(--muted); font-size: .66rem; }

form { display: grid; gap: .85rem; padding: 1.1rem; }
label { display: grid; gap: .3rem; color: var(--muted); font-size: .76rem; }
input, textarea, select { width: 100%; padding: .62rem .7rem; border: 1px solid #b9c5d2; border-radius: 5px; color: var(--ink); background: white; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; }
.check input { width: auto; }
.empty { padding: 2.5rem; text-align: center; }
.empty.small { padding: 2rem 0; }
.empty p { margin: .35rem 0 0; color: var(--muted); }
.prompt-layout { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(320px,.75fr); gap: 1rem; align-items: start; }
.prompt-list details { border-bottom: 1px solid var(--line); }
.prompt-list summary { display: flex; justify-content: space-between; padding: .9rem 1rem; cursor: pointer; }
.prompt-list summary strong, .prompt-list summary small { display: block; }
.prompt-list summary small { color: var(--muted); }
.prompt-list pre { max-height: 28rem; margin: 0; padding: 1rem; overflow: auto; border-top: 1px solid var(--line); white-space: pre-wrap; font: .75rem/1.55 ui-monospace, monospace; }

.publish-dialog { width: min(620px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; overflow: auto; border: 0; border-radius: 9px; color: var(--ink); box-shadow: 0 24px 80px rgba(17,29,43,.35); }
.publish-dialog::backdrop { background: rgba(24,35,49,.62); }
.publish-dialog > form { display: block; padding: 0; }
.dialog-close { position: absolute; top: .7rem; right: .8rem; width: 2rem; height: 2rem; border: 0; border-radius: 50%; color: var(--muted); background: #eef2f6; cursor: pointer; }
.dialog-body { padding: 1.5rem; }
.warning-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; color: #71490f; background: var(--amber-soft); font-weight: 800; }
.dialog-body h2 { margin: .8rem 0 0; font-size: 1.3rem; }
.dialog-body > p { color: var(--muted); }
.dialog-body dl { padding: .75rem; background: #f5f7fa; }
.dialog-body dl div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: .25rem 0; }
.dialog-body dt { color: var(--muted); font-size: .7rem; }
.dialog-body dd { margin: 0; font-size: .76rem; }
.final-copy { margin-top: 1rem; }
.final-copy > span { color: var(--muted); font-size: .7rem; }
.final-copy pre { max-height: 15rem; margin: .3rem 0; padding: .8rem; overflow: auto; border: 1px solid var(--line); border-radius: 5px; white-space: pre-wrap; font: .86rem/1.55 inherit; }
.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.form-error { margin: .7rem 0 0; padding: .55rem; color: var(--red); background: var(--red-soft); font-size: .76rem; }

.toast { position: fixed; z-index: 120; right: 1rem; bottom: 1rem; max-width: min(26rem,calc(100vw - 2rem)); padding: .75rem .9rem; border-radius: 6px; color: white; background: var(--ink); opacity: 0; transform: translateY(.7rem); pointer-events: none; transition: opacity .16s, transform .16s; }
.toast.visible { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

.login-page { min-height: 100vh; background: var(--rail); }
.login-shell { display: grid; grid-template-columns: minmax(280px,.8fr) minmax(360px,1fr); min-height: 100vh; }
.login-brand { display: flex; gap: 1rem; align-items: center; justify-content: center; padding: 3rem; color: white; background: linear-gradient(150deg,#263444 0%,#263444 70%,#2c4056 100%); }
.brand-mark.large { width: 3.5rem; height: 3.5rem; padding: .78rem; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 1.45rem; }
.login-brand div > span { color: #b9c6d3; font-size: .78rem; }
.login-card { align-self: center; width: min(28rem,calc(100% - 2rem)); margin: 1rem auto; padding: 2rem; border-radius: 10px; background: white; box-shadow: 0 20px 70px rgba(12,23,36,.25); }
.login-card h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.025em; }
.login-card > p { color: var(--muted); }
.login-card form { padding: .8rem 0 0; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; z-index: 20; flex-direction: row; align-items: center; height: auto; padding: .8rem 1rem; }
  .rail nav { display: flex; margin: 0 0 0 auto; }
  .rail-foot { display: flex; align-items: center; margin: 0 0 0 1rem; }
  .mode-pill, .user-block small, .text-button { display: none; }
  .user-block { padding: 0; border: 0; }
  .detail-grid, .prompt-layout { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .main { padding: 1.4rem .8rem 4rem; }
  .workspace-head, .page-head, .question-title { align-items: start; flex-direction: column; gap: .8rem; }
  .ledger-row { grid-template-columns: 4px minmax(0,1fr) auto; gap: .7rem; padding-right: .8rem; }
  .ledger-id, .ledger-time { display: none; }
  .product-strip { grid-template-columns: auto 1fr; }
  .product-strip dl, .product-strip > .button { grid-column: 1 / -1; }
  .product-strip dl { justify-content: space-between; }
  .editor-actions { align-items: stretch; flex-direction: column; }
  .editor-actions > div:last-child { justify-content: flex-end; }
  .review-grid { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .health-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .login-shell { grid-template-columns: 1fr; align-content: center; }
  .login-brand { padding: 2rem 1rem 0; background: transparent; }
  .login-card { align-self: start; }
}

@media (max-width: 560px) {
  .rail { align-items: start; flex-wrap: wrap; }
  .rail .brand { width: 100%; }
  .rail nav { width: 100%; margin: .65rem 0 0; overflow-x: auto; }
  .rail nav a { flex: none; min-height: 2.2rem; }
  .rail-foot { position: absolute; top: .95rem; right: .8rem; }
  .user-block strong { max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filter-tabs { margin-right: -.8rem; }
  .workspace-head h1, .question-title h1 { font-size: 1.65rem; }
  .product-strip dl { display: grid; grid-template-columns: repeat(3,1fr); gap: .5rem; }
  .product-strip dl div { min-width: 0; }
  .editor-card { padding: .9rem; }
  .editor-card textarea { min-height: 15rem; }
  .editor-actions > div { display: grid; grid-template-columns: 1fr; }
  .editor-actions .button { width: 100%; }
  .run-meta { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .dialog-body dl div { grid-template-columns: 1fr; gap: .1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
