/* Direction A: one shell for empty, running and loaded. Score track navigates, stage shows, rail explains. */
:root {
  --paper: #f4f3ee;
  --surface: #fffefa;
  --ink: #1a303a;
  --muted: #5f6f70;
  --faint: #8a9696;
  --line: #dedfd7;
  --line-soft: #e8ebe3;
  --subtle: #edf0eb;
  --accent: #1d807f;
  --accent-ink: #145f5e;
  --aqua: #e4f1ea;
  --amber: #8a6230;
  --amber-bg: #fdf6e7;
  --danger: #98533f;
  --danger-bg: #fff0e8;
  --stage: #e9ebe4;
  --radius: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
:is(button, a, input, select, summary, [tabindex]):focus-visible { outline: 3px solid #379da3; outline-offset: 2px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p, figure, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; }
svg { display: block; }
summary { cursor: pointer; }
.sr-only { 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; top: -100px; left: 16px; background: var(--ink); color: #fff; padding: 10px 16px; z-index: 100; border-radius: 4px; }
.skip-link:focus { top: 10px; }

.eyebrow, .micro-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.3px; color: var(--muted); text-transform: uppercase; }
.small-tag, .availability { font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px; padding: 2px 6px; border-radius: 4px; border: 1px solid #d4ddd0; background: #e7ece3; color: #55664f; white-space: nowrap; }
.availability.ready { background: #dcece3; border-color: #bfd9cb; color: #24704f; }
.availability.offline { background: var(--amber-bg); border-color: #e8ddc4; color: var(--amber); }
.small-tag.agent-failed { border-color: #e9d1c4; background: var(--danger-bg); color: var(--danger); }
.field-help, .rail-help { font-size: 12px; color: var(--muted); line-height: 1.6; }
.icon-button { border: 0; background: none; font-size: 22px; line-height: 1; width: 36px; height: 36px; border-radius: 6px; color: var(--muted); }
.icon-button:hover { background: var(--subtle); color: var(--ink); }
.link-button { border: 0; background: none; padding: 0; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; padding: 7px 13px; min-height: 38px; border: 1px solid #d6dccf; border-radius: 6px; background: var(--surface); white-space: nowrap; }
.secondary-button:not(:disabled):hover { background: var(--subtle); }
.primary { border: 0; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600; border-radius: 6px; min-height: 40px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary:not(:disabled):hover { background: var(--accent-ink); }
.tool-button { min-width: 28px; height: 26px; padding: 0 7px; border: 1px solid #d6dccf; border-radius: 5px; background: var(--surface); font-size: 13px; color: var(--muted); }
.tool-button:not(:disabled):hover { background: var(--subtle); color: var(--ink); }
.alert { margin: 12px 24px 0; padding: 11px 15px; background: var(--danger-bg); color: var(--danger); border: 1px solid #e9d1c4; border-radius: 6px; font-size: 13px; }
.spinner { width: 15px; height: 15px; border: 2px solid #ffffff55; border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-sm { width: 10px; height: 10px; border: 1.5px solid #c9d6cf; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.wide-label { display: inline; }
.narrow-label { display: none; }

/* Top bar */
.topbar { min-height: 60px; display: flex; align-items: center; gap: 10px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-size: 13px; font-weight: 700; letter-spacing: 1.4px; white-space: nowrap; margin-right: 6px; }
.file-chip { display: flex; align-items: center; gap: 8px; min-height: 38px; max-width: 330px; padding: 4px 13px; border: 1px solid var(--line); border-radius: 19px; background: transparent; font-size: 12.5px; color: var(--muted); text-align: left; }
.file-chip.has-file { color: var(--ink); background: var(--surface); padding-left: 4px; }
.file-chip:hover { border-color: #c5ccc2; }
.file-chip-thumb { width: 30px; height: 30px; border-radius: 4px; overflow: hidden; flex: none; background: var(--subtle); }
.file-chip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-chip-text { min-width: 0; display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.file-chip-text strong { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.file-chip-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
#file-chip-config { display: none; }
.file-chip-change { font-size: 12px; color: var(--ink); margin-left: 2px; }
.config-chip { display: flex; align-items: center; gap: 5px; min-height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); font-size: 12.5px; white-space: nowrap; }
.config-chip:hover { border-color: #c5ccc2; }
.config-chip u { text-underline-offset: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.guide-button { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 0 14px; font-size: 12.5px; white-space: nowrap; }
.guide-button:hover { background: var(--subtle); }

/* Page shell */
.page { width: min(1232px, calc(100% - 48px)); margin: 0 auto 20px; }
.question { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: center; padding: 16px 0 12px; }
.question-copy { min-width: 0; }
.question h1 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.15; letter-spacing: -.4px; margin-top: 6px; }

/* Answer box */
.answer { border: 1px dashed #d9d9cd; border-radius: 6px; padding: 11px 15px; min-height: 54px; display: flex; flex-direction: column; justify-content: center; }
.answer-title { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.answer-detail { font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 2px; }
.answer-detail:empty { display: none; }
.answer[data-tone="info"] { background: var(--aqua); border: 1px solid transparent; border-left: 3px solid var(--accent); padding-left: 14px; }
.answer[data-tone="info"] .answer-title { color: var(--ink); font-size: 13px; font-weight: 600; }
.answer[data-tone="info"] .answer-detail { color: #3c5b56; }
.answer[data-tone="warn"] { background: var(--amber-bg); border: 1px solid transparent; border-left: 3px solid #b8892f; padding-left: 14px; }
.answer[data-tone="warn"] .answer-title { color: #7a5a20; font-size: 13.5px; font-weight: 600; }
.answer[data-tone="warn"] .answer-detail { color: #7a5a20; }
.answer[data-tone="danger"] { background: var(--danger-bg); border: 1px solid transparent; border-left: 3px solid var(--danger); padding-left: 14px; }
.answer[data-tone="danger"] .answer-title { color: var(--danger); font-size: 13.5px; font-weight: 600; }
.answer[data-tone="danger"] .answer-detail { color: #7d4636; }

/* Score track */
.track-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.track-row.has-regional { grid-template-columns: minmax(0, 1fr) 200px; }
.track-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 11px 20px 10px; min-width: 0; }
.track-card > * { transition: opacity .2s; }
.track-card.is-dimmed > * { opacity: .52; }
.track-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.track-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; }
.track-hint { margin-left: 8px; letter-spacing: 1.1px; }
.track-hint:empty { display: none; }
.track-counts { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.track-counts strong { font-weight: 600; color: #3e5257; }
.track-chart { height: 96px; margin-top: 5px; }
.track-chart svg { width: 100%; height: 96px; overflow: visible; }
.track-stops { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: start; }
.stop { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; width: 100%; color: var(--ink); }
.stop:disabled { cursor: default; opacity: 1; }
.stop-thumb { width: 58px; height: 50px; border-radius: 4px; border: 1px solid var(--line); background: #faf9f3; overflow: hidden; display: grid; place-items: center; }
.stop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stop-thumb.placeholder { border-style: dashed; border-color: #d5d6cc; background: transparent; }
.stop.selected .stop-thumb { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stop:not(:disabled):hover .stop-thumb { border-color: #9dbfb4; }
.stop-score { font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .2px; display: flex; align-items: center; gap: 5px; min-height: 18px; }
.stop.pending .stop-score, .stop.slot .stop-score { font-family: var(--sans); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.stop-label { font-size: 11.5px; color: var(--muted); display: flex; align-items: baseline; gap: 4px; justify-content: center; flex-wrap: wrap; text-align: center; }
.stop-dims { font-size: 11px; }
.stop-change { color: #8a6230; font-style: italic; font-size: 11px; }
.stop-dot { display: none; }

/* Separate regional check */
.regional-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 13px 16px 14px; display: flex; flex-direction: column; gap: 2px; min-height: 100%; }
.regional-sub { font-size: 11.5px; color: var(--muted); margin-bottom: auto; }
.regional-select { margin-top: 14px; border: 1px solid transparent; background: none; border-radius: 6px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.regional-select:hover { background: #faf9f3; }
.regional-select.selected { border-color: #c9d8cd; background: #f7faf4; }
.regional-thumb { width: 74px; height: 68px; border-radius: 4px; overflow: hidden; background: var(--stage); display: grid; place-items: center; }
.regional-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.regional-name { font-size: 13px; font-weight: 600; }
.regional-meta { font-size: 11.5px; color: var(--muted); }

/* Stage */
.stage-row { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; margin-top: 16px; align-items: start; }
.stage-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px 14px; display: flex; flex-direction: column; min-width: 0; }
#stage[data-mode="empty"] { border: 0; background: none; padding: 0; }
#stage[data-mode="empty"] .stage-head { display: none; }
.stage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 30px; }
.stage-head h2 { font-size: 13px; font-weight: 600; white-space: nowrap; }
.stage-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.stage-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.stage-hint:not(:empty) + .stage-tools { margin-left: 0; }
.view-switch { display: flex; gap: 2px; padding: 3px; background: var(--subtle); border-radius: 6px; }
.view-switch button { border: 0; background: none; padding: 4px 11px; border-radius: 4px; font-size: 12px; color: var(--muted); min-height: 26px; }
.view-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px #1a303a2a; }
.zoom-tools { display: flex; gap: 3px; }
.zoom-level { min-width: 66px; font-size: 11px; font-family: var(--mono); }
.diff-tools { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.diff-tools select { width: auto; min-height: 28px; padding: 0 6px; font-size: 11.5px; }
.stage-body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 9px; height: 220px; min-height: 0; --split: 50%; }
.stage-figure { position: relative; min-width: 0; min-height: 220px; border-radius: 4px; overflow: hidden; background: var(--stage); margin: 0; }
.image-stage { position: absolute; inset: 0; overflow: hidden; touch-action: pan-y; background: var(--stage); }
.image-stage.zoomed { cursor: grab; touch-action: none; }
.image-stage.panning { cursor: grabbing; }
.zoom-layer { position: absolute; inset: 0; transform-origin: 50% 50%; transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1)); }
.zoom-layer img, .zoom-layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage-body[data-view="side"] .zoom-layer img { object-fit: cover; }
.pixelated .zoom-layer img, .pixelated .zoom-layer canvas { image-rendering: pixelated; }
.stage-chip { display: none; position: absolute; z-index: 3; top: 8px; left: 8px; background: #1a303ad9; color: #fff; font-size: 11px; line-height: 1; padding: 6px 9px; border-radius: 4px; }
#result-figure .stage-chip { left: auto; right: 8px; }
.stage-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 16px; color: var(--muted); z-index: 1; }
.stage-placeholder svg { width: 38px; height: 38px; fill: none; stroke: #9aa59e; stroke-width: 1.3; margin-bottom: 8px; }
.stage-placeholder span { font-size: 13px; color: var(--ink); }
.stage-placeholder small { font-size: 11.5px; }
.stage-body[data-mode="ready"] #result-empty { inset: 12px; border: 1px dashed #cfd4c9; border-radius: 4px; }
.stage-body[data-mode="single"] { grid-template-columns: minmax(0, 1fr); }
.stage-body[data-mode="single"] #result-figure { display: none; }
.stage-body[data-mode="empty"] { display: block; min-height: 0; height: auto; }
.stage-body[data-mode="empty"] .stage-figure { display: none; }
.stage-map-legend { position: absolute; z-index: 3; bottom: 10px; left: 10px; max-width: calc(50% - 18px); background: #1a303ad9; color: #fff; font-size: 10.5px; line-height: 1.4; padding: 5px 8px; border-radius: 4px; }
.stage-map-legend-end { left: calc(50% + 10px); }
.stage-body[data-mode="regional"] .stage-figure { background: #f2f1ec; }

/* Dropzone */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 344px; border: 1.5px dashed #9fbdb2; border-radius: 6px; background: #fbfaf5; cursor: pointer; text-align: center; padding: 24px; transition: border-color .15s, background-color .15s; }
.dropzone:hover, .dropzone.dragover, .dropzone:focus-within { border-color: var(--accent); background: #f3f8f2; }
.dropzone .upload-icon { width: 42px; height: 42px; stroke: var(--accent); stroke-width: 1.3; margin-bottom: 10px; }
.dropzone strong { font-size: 15px; font-weight: 600; }
.dropzone > span { font-size: 12.5px; color: var(--muted); }
.dropzone u { text-underline-offset: 3px; color: var(--accent-ink); }
.dropzone small { font-size: 11.5px; color: var(--faint); margin-top: 6px; }
.dropzone.small { min-height: 92px; padding: 14px; gap: 2px; }
.dropzone.small .upload-icon { width: 30px; height: 30px; margin-bottom: 4px; }
.dropzone.small strong { font-size: 13px; }
.is-busy .dropzone { cursor: wait; }

/* Slider and diff views */
.stage-body[data-view="slider"] { grid-template-columns: minmax(0, 1fr); }
.stage-body[data-view="slider"] .stage-figure { grid-area: 1 / 1; }
.stage-body[data-view="slider"] #result-figure { background: transparent; pointer-events: none; }
.stage-body[data-view="slider"] #result-figure .image-stage { clip-path: inset(0 0 0 var(--split, 50%)); }
.stage-body[data-view="slider"] #result-empty { display: none; }
.split-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; z-index: 5; cursor: ew-resize; }
.split-handle { position: absolute; z-index: 4; top: 0; bottom: 0; left: var(--split, 50%); width: 2px; transform: translateX(-1px); background: #ffffff; box-shadow: 0 0 0 1px #1a303a3d; pointer-events: none; }
.split-handle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; color: #1a303a; font-size: 13px; letter-spacing: 2px; box-shadow: 0 1px 5px #1a303a40; }
.stage-body[data-view="diff"] { grid-template-columns: minmax(0, 1fr); }
.stage-body[data-view="diff"] #original-figure { display: none; }
.stage-body[data-view="diff"] #result-stage { background: #0f1f26; }
.stage-body[data-view="diff"] .stage-chip { display: none; }

/* Rail */
.rail { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 15px 18px 14px; display: flex; flex-direction: column; min-width: 0; }
.rail-heading { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.22; letter-spacing: -.2px; margin: 5px 0 8px; }
.rail-body { font-size: 12.7px; line-height: 1.55; color: #33484f; }
.rail-body p { margin-bottom: 7px; }
.rail-body p:last-child { margin-bottom: 0; }
.rail-body strong { font-size: 12.8px; color: var(--ink); }
.rail-body ul { padding-left: 18px; margin: 6px 0 9px; font-size: 12.3px; }
.rail-body li { margin-bottom: 4px; }
.rail-body .mono { font-family: var(--mono); font-size: 11.5px; }
.rail-detail { font-family: var(--mono); font-size: 11px; color: var(--muted); border-top: 1px solid var(--line-soft); margin-top: 9px; padding-top: 8px; }
.rail-note { font-size: 11.5px; line-height: 1.55; color: var(--muted); margin-top: 16px; }
.rail-steps { list-style: none; display: flex; flex-direction: column; gap: 13px; margin: 12px 0 4px; }
.rail-steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 9px; font-size: 12.5px; line-height: 1.55; color: #3b4f55; }
.rail-steps .step-number { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: var(--aqua); color: var(--accent-ink); font-family: var(--mono); font-size: 10.5px; }
.rail-steps strong { font-weight: 600; color: var(--ink); }
.rail-progress { list-style: none; margin: 14px 0 0; border-top: 1px solid var(--line-soft); }
.rail-progress li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.rail-progress li:last-child { border-bottom: 0; }
.rail-progress .progress-mark { width: 15px; height: 15px; border-radius: 50%; border: 1px solid #cfd6ca; display: grid; place-items: center; font-size: 9px; color: var(--surface); }
.rail-progress li.done .progress-mark { background: var(--accent); border-color: var(--accent); }
.rail-progress li.current .progress-mark { border-color: var(--accent); }
.rail-progress .progress-label { color: #3b4f55; }
.rail-progress .progress-label strong { font-weight: 600; color: var(--ink); }
.rail-progress .progress-value { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.rail-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 12px; }
.rail-back { flex: 0 0 96px; }
.rail-next { margin-left: auto; min-width: 108px; }
.rail-cancel { margin-top: auto; width: 100%; }
.rail-run { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 18px; }
.rail-run .primary { width: 100%; min-height: 44px; }
.rail-run .primary:disabled { background: #e7ece3; color: #7b8b80; opacity: 1; }
.rail-example { text-align: center; font-size: 12.5px; padding: 6px 0; }
.rail-help { text-align: center; }

/* Technical row */
.technical-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.followups { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.followups .eyebrow { margin-right: 4px; white-space: nowrap; }
.chip { min-height: 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 0 13px; font-size: 12px; white-space: nowrap; }
.chip:not(:disabled):hover { border-color: #bccfc2; background: #fbfaf5; }
.chip span { color: var(--accent); }
.technical-links { display: flex; align-items: center; gap: 13px; font-size: 12px; color: var(--muted); }
.technical-links .link-button { font-size: 12px; color: var(--muted); }

/* Dialogs */
.dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px #1a303a40; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: #1a303a59; }
.dialog-head { flex: none; position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.dialog-head h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; }
.dialog-body { flex: 1 1 auto; min-height: 0; padding: 4px 20px 20px; overflow-y: auto; }
.dialog-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line-soft); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-heading h3 { font-size: 13.5px; font-weight: 650; }
.control-section { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.control-section:last-child { border-bottom: 0; }
.source-section .dropzone { margin-bottom: 10px; }
.file-detail { display: flex; align-items: center; gap: 10px; padding: 8px 4px 8px 10px; border: 1px solid var(--line-soft); border-radius: 6px; }
.file-detail > div { flex: 1; min-width: 0; }
.file-detail strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-detail span { font-size: 12px; color: var(--muted); }
.file-icon { color: var(--accent); font-size: 18px; }
#settings-clear { margin-top: 10px; font-size: 12px; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin: 0; border: 0; background: var(--subtle); border-radius: 7px; }
.mode-tabs label, .segmented label { position: relative; }
.mode-tabs input, .segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-tabs span, .segmented span { display: block; text-align: center; padding: 7px 6px; border-radius: 5px; font-size: 13px; color: var(--muted); }
.mode-tabs input:checked + span, .segmented input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px #1a303a1f; }
.mode-tabs input:focus-visible + span, .segmented input:focus-visible + span { outline: 3px solid #379da3; outline-offset: 1px; }
.mode-tab-help { margin-top: 8px; }
.workflow-section:has(input[value="fixed"]:checked) .mode-tab-help[data-mode="adaptive"],
.workflow-section:has(input[value="adaptive"]:checked) .mode-tab-help[data-mode="fixed"] { display: none; }
.field-label, .field-row label, .mode-field legend { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
select { width: 100%; min-height: 38px; padding: 0 10px; border: 1px solid #d3d9cd; border-radius: 6px; background: var(--surface); }
.slider-field { margin-top: 14px; }
.field-row { display: flex; justify-content: space-between; align-items: center; }
.field-row label { margin: 0; }
.field-row output { font-family: var(--mono); font-size: 12px; background: var(--subtle); padding: 2px 8px; border-radius: 4px; }
input[type=range] { accent-color: var(--accent); width: 100%; margin: 8px 0 0; cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.disabled-field { opacity: .4; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mode-field { border: 0; padding: 0; margin: 14px 0 0; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; background: var(--subtle); border-radius: 7px; }
#mode-help { margin-top: 8px; }
.advanced { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.advanced summary { display: flex; justify-content: space-between; color: var(--muted); }
.advanced summary span { font-family: var(--mono); font-size: 12px; }
.protocol-preview { margin-top: 12px; padding: 10px 12px; background: var(--subtle); border-radius: 6px; }
.protocol-preview p { font-family: var(--mono); font-size: 13px; margin: 4px 0 2px; }
.protocol-preview small { font-size: 12px; color: var(--muted); }
.planner-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.budget-label { margin-top: 12px; }
#budget-help { margin-top: 6px; }
.checkbox-field { display: flex; gap: 8px; margin-top: 12px; font-size: 13px; }
.checkbox-field input { accent-color: var(--accent); margin-top: 3px; }
.checkbox-field small { display: block; font-size: 12px; color: var(--muted); }
.model-status { display: grid; gap: 10px; }
.model-status strong { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.model-status p { font-size: 11.5px; color: var(--muted); line-height: 1.55; margin-top: 3px; }

/* Technical dialog */
.technical-section { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.technical-section:last-child { border-bottom: 0; }
.technical-section h4 { font-size: 13px; font-weight: 600; }
.ledger-subtitle { margin: 14px 0 8px; font-size: 13px; }
.record-config { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.dialog-exports { display: flex; justify-content: flex-end; gap: 12px; padding: 10px 0 2px; }
.exports { display: flex; gap: 10px; }
.exports a { font-size: 12px; color: var(--accent-ink); }
.table-scroll { overflow-x: auto; margin: 0 -20px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th { text-align: left; font-weight: 550; color: var(--muted); padding: 8px 10px; background: #fafbf7; }
td { padding: 6px 10px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 12px; }
th:first-child, td:first-child { padding-left: 20px; }
tbody tr.selected { background: #eaf3ec; }
.row-variant-button { border: 0; background: none; padding: 4px 0; font-family: var(--sans); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #b9c8bc; }
.score-cell { color: var(--accent-ink); font-weight: 600; }
.table-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.run-limits { margin-top: 10px; font-size: 12px; color: var(--amber); }
.run-limits ul, .regional-warnings, .agent-limits ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.6; }
.provenance { margin-top: 10px; font-size: 12px; color: var(--muted); }
.provenance dl { margin: 8px 0; }
.provenance dl > div { display: flex; gap: 10px; padding: 3px 0; }
.provenance dt { min-width: 130px; }
.provenance dd { font-family: var(--mono); font-size: 11px; color: var(--ink); overflow-wrap: anywhere; }
.regional-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.regional-images figure { border: 1px solid var(--line-soft); border-radius: 6px; overflow: hidden; background: var(--stage); }
.regional-images img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.regional-images figcaption { padding: 6px 8px; font-size: 12px; background: var(--surface); }
.regional-images figcaption small { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 2px; }
.regional-result-text { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.regional-warnings { font-size: 12px; color: var(--amber); }
.regional-caution { margin-top: 10px; font-size: 12px; color: var(--muted); }
.agent-current { font-size: 12.5px; color: var(--muted); }
.agent-counts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.agent-counts strong { font-family: var(--mono); font-weight: 500; color: var(--ink); margin-right: 3px; }
.agent-conclusion { margin-top: 12px; padding: 12px; background: #f1f6ef; border: 1px solid #dbe7d9; border-radius: 6px; }
.agent-conclusion h4 { font-family: var(--serif); font-weight: 400; font-size: 17px; margin: 2px 0 6px; }
.agent-conclusion p { font-size: 13px; line-height: 1.6; margin-bottom: 4px; }
.agent-stop { color: var(--muted); }
.agent-limits { font-size: 12px; color: var(--amber); margin-top: 6px; }
.agent-error { margin-top: 12px; padding: 10px 12px; background: var(--danger-bg); color: var(--danger); border: 1px solid #e9d1c4; border-radius: 6px; font-size: 13px; }
.agent-empty { font-size: 12px; color: var(--muted); }
.evidence-card { border: 1px solid #dfe6d9; background: #fcfdf8; border-radius: 6px; padding: 12px; margin-bottom: 8px; scroll-margin-top: 16px; }
.evidence-card.selected { border-color: #91b49a; background: #f1f7ee; }
.evidence-card-heading { display: flex; align-items: flex-start; gap: 8px; }
.evidence-id { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--ink); color: #fff; }
.evidence-card h4, .decision-card h4 { font-size: 13px; font-weight: 550; color: #3f5d47; overflow-wrap: anywhere; }
.evidence-reading { display: flex; gap: 8px; align-items: baseline; margin: 8px 0 4px; flex-wrap: wrap; }
.evidence-reading strong { font-family: var(--mono); font-weight: 400; font-size: 22px; color: #2b7466; }
.evidence-reading span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.evidence-change, .evidence-detail, .evidence-error, .decision-context { font-size: 12px; line-height: 1.6; }
.evidence-change { color: #567a55; }
.evidence-change.changed { color: var(--amber); font-weight: 550; }
.evidence-detail, .decision-context { color: var(--muted); }
.evidence-error { color: var(--danger); }
.evidence-preview { margin-top: 6px; border: 0; background: none; padding: 0; font-size: 12px; color: var(--accent-ink); text-decoration: underline; }
.evidence-links { display: inline-flex; gap: 4px; margin-left: 6px; flex-wrap: wrap; }
.evidence-links a { font-family: var(--mono); font-size: 11px; padding: 0 5px; color: #3e7765; border: 1px solid #c9dbca; background: #fbfdf7; border-radius: 3px; }
.evidence-links a:hover { background: #e1eedf; }
.decision-card { padding: 0 0 14px 16px; border-left: 1px solid #dbe4d3; position: relative; margin-left: 4px; }
.decision-card::before { content: ""; position: absolute; left: -4px; top: 4px; height: 7px; width: 7px; border-radius: 50%; background: #a1b59a; box-shadow: 0 0 0 3px var(--surface); }
.decision-card h4 { margin: 4px 0 6px; }
.decision-options { font-size: 12px; color: var(--muted); margin-top: 4px; }
.decision-options ul { margin: 4px 0 0; padding-left: 18px; }
.agent-maps { margin-top: 14px; }

/* Guide dialog */
.guide { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px #1a303a40; }
.guide::backdrop { background: #1a303a59; }
.guide-header { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.guide-header h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; }
.guide-body { padding: 4px 20px 20px; }
.guide-body section { padding: 12px 0; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 80px; }
.guide-body section.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--aqua); } 100% { background: transparent; } }
.guide-body h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.guide-body p { font-size: 13px; line-height: 1.65; color: #3d5258; }
.guide-sources { margin-top: 14px; font-size: 12px; }
.guide-sources a { color: var(--accent-ink); text-decoration: underline; }

/* Phone bar, hidden above 760px */
.phone-bar { display: none; }

@media (max-width: 1120px) {
  .question { grid-template-columns: minmax(0, 1fr) 340px; }
  .stage-row { grid-template-columns: minmax(0, 1fr) 320px; }
  .track-row.has-regional { grid-template-columns: minmax(0, 1fr) 180px; }
  .brand { font-size: 12.5px; letter-spacing: 1.1px; }
  .file-chip-text strong { max-width: 160px; }
}

@media (max-width: 900px) {
  .page { width: calc(100% - 36px); }
  .question { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .question h1 { font-size: 29px; }
  .stage-row { grid-template-columns: minmax(0, 1fr); }
  .track-row.has-regional { grid-template-columns: minmax(0, 1fr); }
  .regional-card { flex-direction: row; align-items: center; gap: 12px; }
  .regional-sub { margin-bottom: 0; }
  .regional-select { margin: 0 0 0 auto; flex-direction: row; width: auto; }
  .rail { min-height: 0; }
  .rail-actions, .rail-run, .rail-cancel { margin-top: 16px; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 52px; padding: 6px 12px; gap: 8px; }
  .brand, .guide-button, .config-chip { display: none; }
  .file-chip { flex: 1; min-width: 0; border: 0; padding: 2px 0; border-radius: 0; background: transparent; gap: 8px; }
  .file-chip.has-file { background: transparent; }
  .file-chip-thumb { width: 28px; height: 28px; }
  .file-chip-text { display: block; }
  .file-chip-text strong { display: block; max-width: calc(100vw - 190px); font-size: 12.5px; }
  #file-chip-meta, .file-chip-change { display: none !important; }
  #file-chip-config { display: block; font-size: 11px; color: var(--muted); }
  .topbar-actions { margin-left: 0; }
  .wide-label { display: none; }
  .narrow-label { display: inline; }
  #other-file { min-height: 34px; padding: 0 11px; font-size: 12px; }
  .alert { margin: 8px 12px 0; }
  .page { width: calc(100% - 24px); margin-bottom: 20px; }
  .question { display: block; padding: 10px 0 12px; }
  .question-copy { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .answer { padding: 9px 12px; }
  .answer-title { font-size: 12.5px; }
  .answer-detail { font-size: 11.5px; }
  .track-card { padding: 10px 12px 9px; }
  .track-head { display: block; }
  .track-hint, .track-counts { display: none; }
  .track-chart { height: 54px; margin-top: 2px; }
  .track-chart svg { height: 54px; }
  .track-stops { gap: 2px; }
  .stop { gap: 4px; }
  .stop-thumb { width: 40px; height: 40px; }
  .stop-score { order: -1; font-size: 11.5px; min-height: 15px; }
  .stop-label { font-size: 10.5px; gap: 2px; flex-direction: column; }
  .stop-dims { font-size: 9.5px; }
  .stop-change { font-size: 10px; }
  .stage-row { margin-top: 12px; gap: 0; }
  .stage-card { border: 0; background: transparent; padding: 0; }
  .stage-head { display: none; }
  .stage-body { margin-top: 0; min-height: 0; height: auto; aspect-ratio: 1 / 1; }
  .stage-figure { min-height: 0; border-radius: 8px; }
  .stage-chip { display: inline-block; }
  .stage-map-legend { max-width: calc(50% - 16px); font-size: 9.5px; }
  .stage-map-legend-end { left: calc(50% + 8px); }
  .stage-body[data-mode="empty"] .dropzone { min-height: 300px; }
  .rail { border: 0; background: transparent; padding: 14px 2px 0; }
  .rail-heading { font-size: 20px; margin: 5px 0 8px; }
  .rail-body { font-size: 12.8px; }
  .rail-detail { margin-top: 8px; padding-top: 8px; }
  .rail-actions { display: none; }
  .rail-run { margin-top: 14px; }
  .rail-cancel { margin-top: 14px; }
  .technical-row { margin-top: 14px; display: block; }
  .followups { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .followups::-webkit-scrollbar { display: none; }
  .followups .eyebrow { position: sticky; left: 0; background: var(--paper); padding-right: 4px; }
  .technical-links { margin-top: 12px; justify-content: space-between; }
  .phone-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
  .phone-bar[hidden] { display: none; }
  .phone-back { flex: 0 0 48px; min-height: 40px; font-size: 16px; }
  .phone-next { flex: 1; min-height: 40px; }
  .regional-card { padding: 12px; }
  .dialog { width: 100vw; max-width: 100vw; max-height: calc(100vh - 12px); border-radius: 14px 14px 0 0; margin: auto 0 0; }
  .dialog-body { padding-inline: 14px; }
  .table-scroll { margin-inline: -14px; }
  .guide { width: calc(100vw - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .guide-body section.flash { animation: none; }
}

.page-intro { max-width: 1440px; margin: 0 auto; padding: 30px 30px 24px; }
.page-intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.7px; line-height: 1.18; margin: 7px 0 10px; }
.page-intro > p:last-child { color: var(--muted); font-size: 15px; max-width: 720px; }
body { height: auto; overflow: visible; display: block; }
.topbar { padding-inline: 30px; }
.stepper { display: none; }
.topbar-actions { margin-left: auto; }
.topbar .model-chip { display: none; }
.workbench { width: calc(100% - 60px); max-width: 1380px; margin: 0 auto 40px; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.pane { overflow: visible; }
.pane-controls { grid-row: span 2; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pane-controls form { display: block; }
.pane-viewer { grid-column: 2; padding: 0; gap: 14px; }
.pane-evidence { grid-column: 2; border: 1px solid var(--line); padding: 0; border-radius: 10px; display: block; background: var(--surface); }
.pane-evidence > summary { padding: 16px 18px; font-weight: 600; }
.pane-evidence > summary span, .settings-disclosure > summary span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin: 4px 0 0 18px; }
.research-content { display: grid; gap: 14px; padding: 0 16px 16px; }
.research-content > .panel { border-color: var(--line-soft); }
.settings-disclosure { border-top: 1px solid var(--line-soft); }
.settings-disclosure > summary { padding: 14px 18px; font-size: 13px; font-weight: 550; }
.settings-disclosure > .model-note { margin: 8px 18px; }
.run-controls { position: static; margin: 0; padding-top: 16px; border: 0; }
.upload-promise { font-size: 12px; line-height: 1.6; color: var(--muted); padding: 0 18px 18px; }
.source-section { border-bottom: 0; padding-bottom: 0; }
.example-button { border: 0; background: transparent; padding-inline: 0; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }
.example-button:not(:disabled):hover { background: transparent; }
.investigation-guide { background: var(--surface); border: 1px solid #c8d9cf; border-radius: 12px; padding: 20px 22px; box-shadow: 0 4px 16px #1a303a05; }
.narrator-heading { display: flex; align-items: center; gap: 10px; }
.narrator-avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--surface); background: var(--accent); font-size: 24px; }
.narrator-heading strong { display: block; font-size: 14px; }
.narrator-heading > div:nth-child(2) > span { display: block; font-size: 11px; color: var(--muted); }
.guide-origin { margin-left: auto; max-width: 190px; text-align: right; color: var(--muted); font-size: 11px; }
.guide-stages { display: flex; gap: 6px; padding: 0; margin: 16px 0; list-style: none; flex-wrap: wrap; }
.guide-stages button { min-height: 32px; padding: 5px 10px; border: 1px solid var(--line-soft); background: transparent; border-radius: 99px; font-size: 12px; color: var(--muted); }
.guide-stages button[aria-current="step"] { color: var(--accent-ink); background: var(--aqua); border-color: #bad4c5; font-weight: 600; }
.guide-narration h2, .guide-finding h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(22px, 2.2vw, 28px); line-height: 1.25; margin: 5px 0 10px; }
.guide-narration > p:last-child, .guide-finding p { color: #425b5d; font-size: 14px; line-height: 1.7; max-width: 860px; }
.guide-score-comparison { display: grid; grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr); align-items: center; gap: 12px; padding: 14px 16px; margin-top: 16px; background: #f4f7f1; border: 1px solid #e1e8dc; border-radius: 8px; }
.guide-score-comparison > div { min-width: 0; }
.guide-score-comparison span:not(.score-arrow) { display: block; color: var(--muted); font-size: 12px; }
.guide-score-comparison strong { display: block; color: var(--accent-ink); font-family: var(--mono); font-size: 27px; font-weight: 400; margin-top: 2px; overflow-wrap: anywhere; }
#guide-current-score { font-size: 23px; }
.guide-score-comparison p { grid-column: 1 / -1; color: var(--muted); font-size: 11px; line-height: 1.5; }
.score-arrow { color: var(--accent); font-size: 24px; }
.guide-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.guide-actions > div { display: flex; gap: 7px; }
.guide-actions > .info-link { font-size: 12px; }
.guide-next { padding: 8px 14px; min-height: 36px; border: 0; border-radius: 6px; color: #fff; background: var(--accent); font-weight: 550; font-size: 12px; }
.guide-next:not(:disabled):hover { background: var(--accent-ink); }
.guide-footnote { margin-top: 12px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.guide-highlight { outline: 2px solid var(--accent); outline-offset: 4px; transition: outline-color .2s; }
.guide-finding { padding: 10px 12px; background: #f1f6ef; border-radius: 7px; }
.guide-regional { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.guide-regional figure { min-width: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.guide-regional img { display: block; width: 100%; max-height: 230px; object-fit: contain; background: var(--stage); }
.guide-regional figcaption { padding: 7px 10px; font-size: 11px; color: var(--muted); }
#agent-overview { margin: 16px 0 0; border: 0; border-top: 1px solid var(--line-soft); padding: 12px 0 0; background: transparent; }
#agent-overview > .panel-header { margin-bottom: 8px; align-items: center; }
#agent-overview > .panel-header > div { display: none; }
#agent-overview .agent-progress { background: transparent; border: 0; padding: 0; }
#agent-overview .agent-progress > div { min-width: 0; }
#agent-overview .agent-progress p { color: var(--muted); font-size: 12px; }
.guide-run-details { margin-top: 12px; color: var(--muted); font-size: 12px; }
.guide-run-details .agent-conclusion { background: transparent; border: 0; padding: 0; }
.viewer-options { position: relative; font-size: 12px; color: var(--muted); }
.viewer-options > summary { padding: 7px 0; }
.viewer-options .viewer-tools { padding: 8px 0; }
.viewer-toolbar { padding: 2px 0; }
.viewer-title h2 { font-size: 17px; }
.viewer-title .small-tag { display: none; }
.viewer-stage { flex: none; min-height: 300px; }
.image-stage { min-height: 240px; }
.viewer-foot { font-size: 12px; }
@media (max-width: 1000px) {
  .workbench { grid-template-columns: 240px minmax(0, 1fr); gap: 16px; width: calc(100% - 36px); }
  .page-intro { padding: 24px 18px 20px; }
  .topbar { padding-inline: 18px; }
  .investigation-guide { padding: 17px; }
  .guide-origin { max-width: 120px; }
  .guide-stages { gap: 5px; }
  .guide-stages button { padding-inline: 8px; font-size: 11px; }
}
@media (max-width: 760px) {
  .workbench { grid-template-columns: minmax(0, 1fr); width: calc(100% - 28px); gap: 18px; }
  .pane-controls { grid-row: auto; }
  .pane-viewer, .pane-evidence { grid-column: 1; }
  .page-intro { padding: 24px 14px 20px; }
  .page-intro > p:last-child { font-size: 14px; }
  .topbar { padding-inline: 14px; }
  .topbar .brand-caption { display: none; }
  .guide-button { padding-inline: 8px; font-size: 11px; }
  .investigation-guide { padding: 16px; }
  .narrator-heading { flex-wrap: wrap; }
  .guide-origin { max-width: none; margin-left: 46px; text-align: left; }
  .guide-stages { margin-block: 13px; }
  .guide-narration > p:last-child, .guide-finding p { font-size: 13px; }
  .guide-score-comparison { padding: 12px; gap: 9px; }
  .guide-score-comparison strong { font-size: 23px; }
  #guide-current-score { font-size: 18px; }
  .guide-score-comparison span:not(.score-arrow) { font-size: 11px; }
  .viewer-stage { min-height: 0; }
  .image-stage { min-height: 0; }
  .viewer-title { width: 100%; }
  .guide-regional { grid-template-columns: minmax(0, 1fr); }
  .research-content { padding-inline: 10px; }
  .guide-actions { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) { .guide-highlight { transition: none; } }

#source-controls { display: block; }
#source-controls > summary { padding: 14px 18px; font-size: 13px; font-weight: 600; }
#source-controls > summary span { display: block; margin: 3px 0 0 18px; font-size: 11px; font-weight: 400; color: var(--muted); }
.has-guide-result #source-controls > summary { padding-block: 11px; }
.has-guide-result #source-controls:not([open]) > summary span { display: inline; margin-left: 12px; }
@media (min-width: 900px) {
  .has-guide-result .page-intro { padding-top: 20px; padding-bottom: 18px; }
  .has-guide-result .page-intro h1 { font-size: 32px; }
  .has-guide-result .workbench { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .has-guide-result #source-controls { grid-column: 1; grid-row: auto; }
  .has-guide-result #source-controls[open] form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(200px, 1fr) minmax(240px, 1fr); align-items: start; }
  .has-guide-result #source-controls[open] .source-section { grid-row: span 2; padding-bottom: 18px; }
  .has-guide-result #source-controls[open] .settings-disclosure { grid-column: 3; grid-row: 1 / span 2; border-top: 0; border-left: 1px solid var(--line-soft); }
  .has-guide-result #source-controls[open] .upload-promise { grid-column: 2; }
  .has-guide-result .pane-viewer { grid-column: 1; display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: auto auto 1fr; gap: 12px 20px; align-items: start; }
  .has-guide-result .investigation-guide { grid-column: 2; grid-row: 1 / span 3; padding: 17px; }
  .has-guide-result .viewer-toolbar { grid-column: 1; grid-row: 1; }
  .has-guide-result .viewer-stage { grid-column: 1; grid-row: 2; min-height: 340px; }
  .has-guide-result .viewer-foot { grid-column: 1; grid-row: 3; align-self: start; }
  .has-guide-result .pane-evidence { grid-column: 1; }
  .has-guide-result .narrator-heading { flex-wrap: wrap; }
  .has-guide-result .guide-origin { max-width: none; margin-left: 46px; text-align: left; }
  .has-guide-result .guide-stages { margin-block: 12px; }
  .has-guide-result .guide-narration h2, .has-guide-result .guide-finding h3 { font-size: 23px; }
  .has-guide-result .guide-narration > p:last-child, .has-guide-result .guide-finding p { font-size: 13px; line-height: 1.6; }
  .has-guide-result .guide-score-comparison { padding: 11px; gap: 9px; }
  .has-guide-result .guide-score-comparison strong { font-size: 23px; }
  .has-guide-result #guide-current-score { font-size: 18px; }
  .has-guide-result .guide-score-comparison span:not(.score-arrow) { font-size: 11px; }
  .has-guide-result .guide-actions { gap: 10px; margin-top: 14px; }
  .has-guide-result .guide-regional { grid-template-columns: minmax(0, 1fr); }
  .has-guide-result .guide-regional img { max-height: 180px; }
}
@media (max-width: 899px) {
  .has-guide-result .workbench { grid-template-columns: minmax(0, 1fr); }
  .has-guide-result #source-controls { grid-column: 1; grid-row: auto; }
  .has-guide-result .pane-viewer, .has-guide-result .pane-evidence { grid-column: 1; }
  .has-guide-result #source-controls:not([open]) > summary span { display: block; margin-left: 18px; }
}

.guide-actions { margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.guide-actions > div { display: flex; width: 100%; align-items: stretch; }
.guide-actions > div > button { white-space: normal; }
.guide-actions .guide-next { flex: 1; min-width: 0; }
.guide-actions > .info-link { font-size: 11px; }
.guide-stages { gap: 5px; }
.guide-stages button { font-size: 11px; padding: 4px 8px; min-height: 29px; }
.guide-flow { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 14px 0; }
.guide-flow li { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--accent-ink); padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--subtle); }
.guide-flow li:not(:first-child)::before { content: "→"; color: var(--muted); }
.guide-model { font-size: 12px; line-height: 1.5; border-left: 2px solid #c0d4c8; padding-left: 10px; margin: 14px 0; }
.guide-model strong { font-size: 12px; font-weight: 650; }
.guide-model p { color: var(--muted); margin-top: 3px; }
.guide-lesson { display: grid; gap: 13px; margin: 14px 0; }
.guide-lesson > div { min-width: 0; }
.guide-lesson dt { color: var(--muted); font-size: 11px; margin: 0 0 3px; }
.guide-lesson dd { font-size: 13px; color: var(--ink); line-height: 1.55; margin: 0; }
.guide-lesson .lesson-meaning { padding: 10px 11px; border-radius: 6px; background: #edf5ed; border-left: 2px solid var(--accent); }
.guide-lesson .lesson-meaning dd { color: var(--accent-ink); }
.guide-transformation { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 7px; align-items: center; margin: 14px 0; padding: 12px 10px; border: 1px solid var(--line); border-radius: 7px; text-align: center; }
.guide-transformation span { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.guide-transformation strong { font-size: 11px; font-weight: 550; max-width: 90px; color: var(--accent-ink); }
.guide-transformation strong::before { content: "→ "; }
.guide-transformation strong::after { content: " →"; }
.guide-transformation p { grid-column: 1 / -1; font-size: 11px; color: var(--muted); line-height: 1.5; }
.guide-score-comparison small { display: block; margin-top: 3px; font-size: 11px; color: var(--accent-ink); }
.guide-scale { margin: 12px 0; font-size: 11px; color: var(--muted); }
.guide-scale > p:first-child { color: var(--ink); font-weight: 550; margin-bottom: 8px; }
.guide-scale-labels { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.guide-scale-track { height: 9px; position: relative; border-radius: 99px; background: linear-gradient(90deg, #dfe5dd, #7bab96); margin: 12px 6px; }
.guide-threshold-marker { position: absolute; width: 2px; height: 21px; top: -6px; background: #697b72; transform: translateX(-50%); }
.guide-score-marker { position: absolute; width: 13px; height: 13px; top: -2px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent-ink); transform: translateX(-50%); }
#guide-scale-note { line-height: 1.5; }
.guide-map-legends { margin: 10px 0; padding-left: 18px; font-size: 11px; line-height: 1.5; color: var(--muted); }
#viewer:is([data-lesson-kind="overview"], [data-lesson-kind="baseline"], [data-lesson-kind="regional"]) .viewer-stage { grid-template-columns: minmax(0, 1fr); }
#viewer:is([data-lesson-kind="overview"], [data-lesson-kind="baseline"], [data-lesson-kind="regional"]) #original-figure { display: flex; grid-area: 1 / 1; }
#viewer:is([data-lesson-kind="overview"], [data-lesson-kind="baseline"], [data-lesson-kind="regional"]) #result-figure,
#viewer:is([data-lesson-kind="overview"], [data-lesson-kind="baseline"], [data-lesson-kind="regional"]) #split-range { display: none; }
.image-figure figcaption > span:first-child { min-width: 0; }
#result-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 900px) {
  .has-guide-result .guide-stages button { font-size: 11px; width: auto; height: auto; min-height: 29px; padding: 4px 7px; }
  .has-guide-result .guide-actions { margin-top: 0; gap: 8px; }
}

.viewer-evidence { display: grid; gap: 10px; min-width: 0; }
.viewer-evidence .guide-transformation, .viewer-evidence .guide-score-comparison { margin: 0; }
.viewer-evidence .guide-transformation { padding: 9px 12px; }
.viewer-evidence .guide-transformation > p { margin-top: 4px; }
.viewer-evidence .guide-score-comparison { padding: 10px 14px; gap: 7px 12px; }
.viewer-evidence .guide-score-comparison p { margin: 0; }
.viewer-evidence .guide-scale { margin: 0; padding: 0 6px 4px; }
@media (min-width: 900px) {
  .has-guide-result .pane-viewer { grid-template-rows: auto auto auto 1fr; }
  .has-guide-result .investigation-guide { grid-row: 1 / span 4; }
  .has-guide-result .viewer-evidence { grid-column: 1; grid-row: 2; }
  .has-guide-result .viewer-stage { grid-row: 3; }
  .has-guide-result .viewer-foot { grid-row: 4; }
  .has-guide-result .page-intro { padding-top: 14px; padding-bottom: 14px; }
  .has-guide-result .page-intro h1 { font-size: 29px; margin-block: 5px 7px; }
}
