/* The demo portal's one stylesheet. Design tokens first; every component reads them. */
:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-muted: #f0f2f4;
  --ink: #1f2429;
  --muted: #56606b;
  --line: #d9dee3;
  --accent: #2a5d84;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef5;
  --publisher: #2d6a4f;
  --publisher-soft: #e5f1ea;
  --processing: #2a5d84;
  --processing-soft: #e6eef5;
  --experimental: #8a5512;
  --experimental-soft: #fbefdc;
  --danger: #9b2c2c;
  --danger-soft: #fbe9e9;
  --focus: #f2b134;
  --radius: 10px;
  --radius-small: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --measure: 72ch;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-3); }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: var(--space-4); }
p { margin: 0 0 var(--space-3); max-width: var(--measure); }
ul { padding-left: 1.2em; }
small { color: var(--muted); }

.skip-link { position: absolute; left: var(--space-3); top: -60px; padding: var(--space-2) var(--space-3);
  background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius-small); z-index: 10; }
.skip-link:focus { top: var(--space-3); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Shell */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header-inner, .site-footer-inner, .page { max-width: 1120px; margin: 0 auto; padding: 0 var(--space-5); }
.site-header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); min-height: 64px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; display: flex; flex-direction: column; line-height: 1.1; }
.brand-note { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.site-nav { flex: 1 1 auto; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; }
.site-nav a { display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-small); color: var(--ink); text-decoration: none; }
.site-nav a:hover { background: var(--surface-muted); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.locale-switch { display: flex; align-items: center; gap: var(--space-2); font-size: 0.95rem; }
.locale-current { font-weight: 600; }
.locale-switch-form { margin: 0; display: inline; }
.locale-other { font: inherit; color: var(--accent); background: none; border: 0; padding: var(--space-1) var(--space-2); cursor: pointer; text-decoration: underline; border-radius: var(--radius-small); }
.page { padding-top: var(--space-6); padding-bottom: var(--space-7); }
.page:focus { outline: none; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.9rem; }
.site-footer-inner { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.legal-links { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-4); padding: 0; margin: 0; }

/* Building blocks */
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; font-weight: 600; color: var(--accent); margin-bottom: var(--space-2); }
.lead { font-size: 1.12rem; color: var(--muted); }
.hero { padding: var(--space-5) 0 var(--space-6); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); margin-bottom: var(--space-5); }
.panel > p { color: var(--muted); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-5); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); }
.panel .card { background: var(--surface-muted); border-color: transparent; }
.card-link { display: flex; flex-direction: column; gap: var(--space-2); color: var(--ink); text-decoration: none; }
.card-link strong { color: var(--accent); }
.card-link:hover { border-color: var(--accent); }

.button, button.primary, button.secondary { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-small); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; border: 1px solid transparent; }
.button.primary, button.primary { background: var(--accent); color: var(--accent-ink); }
.button.secondary, button.secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
button:disabled, button[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-4); }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; padding: 2px var(--space-2); border-radius: 999px; border: 1px solid currentColor; margin-bottom: var(--space-2); }
.badge-publisher { color: var(--publisher); background: var(--publisher-soft); }
.badge-processing { color: var(--processing); background: var(--processing-soft); }
.badge-experimental { color: var(--experimental); background: var(--experimental-soft); }
.state { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 1px var(--space-2); border-radius: var(--radius-small); background: var(--surface-muted); }
.state-ok { color: var(--publisher); background: var(--publisher-soft); }
.state-warn { color: var(--experimental); background: var(--experimental-soft); }
.state-error { color: var(--danger); background: var(--danger-soft); }

.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-small); border-left: 4px solid var(--accent); background: var(--accent-soft); max-width: none; }
.notice-warn { border-color: var(--experimental); background: var(--experimental-soft); }
.notice-error { border-color: var(--danger); background: var(--danger-soft); }

/* Publisher and catalog material, unchanged: a dotted underline inline, monospace in blocks. */
.source-text { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
pre.source-text { font-family: var(--mono); font-size: 0.9em; background: var(--surface-muted); border-radius: 3px; text-decoration: none; display: block; padding: var(--space-3); overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 28rem; }
.raw-panel { margin-top: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-2); }
.raw-panel summary { cursor: pointer; font-weight: 600; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; }
.raw-panel summary small { font-weight: 400; }

/* Forms */
label, legend { font-weight: 600; }
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.field small { font-weight: 400; }
input[type="text"], input[type="search"], input[type="date"], textarea, select { font: inherit; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); color: var(--ink); min-height: 44px; width: 100%; max-width: 40rem; }
textarea { min-height: 6rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-small); padding: var(--space-3); margin: 0 0 var(--space-3); }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.checks label { font-weight: 400; display: inline-flex; gap: var(--space-2); align-items: center; min-height: 32px; }
.inline-form { display: inline; margin: 0; }

/* Journey */
.journey { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-5); align-items: start; }
.scope-summary { position: sticky; top: var(--space-4); }
.scope-summary dl { margin: 0; }
.scope-summary dt { font-weight: 600; font-size: 0.85rem; color: var(--muted); margin-top: var(--space-3); }
.scope-summary dd { margin: 0; }
.stage { counter-increment: stage; }
.stage-header { display: grid; grid-template-columns: 2rem 1fr auto; column-gap: var(--space-3); align-items: center; cursor: pointer; list-style: none; }
.stage-header::-webkit-details-marker { display: none; }
.stage-header h2 { margin: 0; }
.stage-header::after { content: ""; width: 0.6rem; height: 0.6rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 var(--space-2) var(--space-1); transition: transform .15s; }
.stage[open] > .stage-header::after { transform: rotate(-135deg); margin-bottom: 0; }
.stage-explain { grid-column: 2 / 4; color: var(--muted); margin-top: var(--space-1); max-width: var(--measure); }
.stage:not([open]) { padding-top: var(--space-3); padding-bottom: var(--space-3); margin-bottom: var(--space-3); }
.stage:not([open]) .stage-explain { display: none; }
.stage[open] > .stage-header { margin-bottom: var(--space-4); }
.stage { scroll-margin-top: var(--space-4); }
.stage-number { flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.stage[data-state="locked"] { background: var(--surface-muted); }
.candidate-list { list-style: none; padding: 0; display: grid; gap: var(--space-2); }
.candidate-list button { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-small); padding: var(--space-3); font: inherit; cursor: pointer; }
.candidate-list button:hover { border-color: var(--accent); }
.source-list { list-style: none; padding: 0; display: grid; gap: var(--space-3); }
.source-item { border: 1px solid var(--line); border-radius: var(--radius-small); padding: var(--space-3); background: var(--surface); }
.source-item header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: 0.88rem; color: var(--muted); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.pagination { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-4); }
.progress-list { list-style: none; padding: 0; display: grid; gap: var(--space-1); }
.progress-list li { display: flex; justify-content: space-between; gap: var(--space-3); border-bottom: 1px solid var(--line); padding: var(--space-1) 0; }
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.evidence-card { border: 1px solid var(--line); border-radius: var(--radius-small); padding: var(--space-4); background: var(--surface); min-width: 0; }
.evidence-card ul { margin: var(--space-2) 0; }
.answer { border-left: 4px solid var(--experimental); padding-left: var(--space-4); }
.answer table { border-collapse: collapse; }
.answer th, .answer td { border-bottom: 1px solid var(--line); padding: var(--space-1) var(--space-2); text-align: left; }
.citation { font-weight: 600; text-decoration: none; }

/* Map */
.map-wrap { margin: var(--space-3) 0; }
.interactive-map { position: relative; width: 100%; height: 260px; border-radius: var(--radius-small); overflow: hidden; background: #dfe6ea; touch-action: none; cursor: grab; }
.map-tiles { position: absolute; inset: 0; }
.map-tiles img { position: absolute; width: 256px; height: 256px; }
.map-fallback { display: none; position: absolute; inset: 0; place-items: center; color: var(--muted); font-size: 0.85rem; }
.map-fallback.visible { display: grid; }
.map-marker { position: absolute; z-index: 2; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); padding: 0; }
.map-marker.selected-place { width: 26px; height: 26px; background: var(--danger); }
.map-controls { position: absolute; z-index: 3; top: var(--space-2); right: var(--space-2); display: grid; }
.map-controls button { width: 36px; height: 36px; font-size: 1.2rem; background: var(--surface); border: 1px solid var(--line); }
.map-popup { position: absolute; z-index: 4; left: var(--space-2); right: var(--space-2); bottom: var(--space-2); background: var(--surface); padding: var(--space-3); border-radius: var(--radius-small); box-shadow: 0 2px 10px rgba(0,0,0,.2); font-size: 0.9rem; }
.map-popup strong, .map-popup span, .map-popup a { display: block; }
.map-attribution { font-size: 0.8rem; color: var(--muted); }

/* Tool hosts */
.tool-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); }
/* A tool with a fixed layout width: wider than the text column up to that width, centred,
   and scaled down by portal.js below it, so it is shown whole rather than cut off. */
.tool-fit[data-layout-width="1280"] { --layout-width: 1280px; }
.tool-fit { --fit-width: min(calc(var(--layout-width) + 2px), calc(100vw - 2 * var(--space-5)));
  width: var(--fit-width); margin-left: calc((100% - var(--fit-width)) / 2); height: 75vh; min-height: 480px;
  overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); }
.tool-fit .tool-frame { display: block; width: var(--layout-width); height: calc(100% / var(--fit-scale, 1)); min-height: 0;
  border: 0; border-radius: 0; transform: scale(var(--fit-scale, 1)); transform-origin: 0 0; }
.tool-fit.is-scaled { overflow: hidden; }
.tool-unavailable { border: 1px dashed var(--line); border-radius: var(--radius-small); padding: var(--space-4); }
code, kbd { font-family: var(--mono); font-size: 0.92em; }
.command { display: block; font-family: var(--mono); background: var(--surface-muted); padding: var(--space-3); border-radius: var(--radius-small); overflow-x: auto; white-space: pre; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { text-align: left; vertical-align: top; padding: var(--space-2); border-bottom: 1px solid var(--line); }
dl.facts { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
dl.facts dt { font-weight: 600; color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .journey { grid-template-columns: 1fr; }
  .scope-summary { position: static; order: -1; }
}
@media (max-width: 600px) {
  .site-header-inner, .site-footer-inner, .page { padding-left: var(--space-4); padding-right: var(--space-4); }
  .panel { padding: var(--space-4); }
  dl.facts { grid-template-columns: 1fr; }
  .site-nav a { padding: var(--space-2); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

.tool-frame { width: 100%; min-height: 38rem; border: 1px solid var(--line); border-radius: .5rem; }

/* Operator console (`oda.ops`): a separate process whose plain markup reads the same tokens. */
.ops-console main > table, .ops-console section > table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-bottom: var(--space-5); background: var(--surface); }
.ops-console th, .ops-console td { text-align: left; vertical-align: top; padding: var(--space-2); border-bottom: 1px solid var(--line); }
.ops-console td code { overflow-wrap: anywhere; }
@media (max-width: 760px) { .ops-console main > table { display: block; overflow-x: auto; } .ops-console th, .ops-console td { white-space: nowrap; } .ops-console td:has(code) { white-space: normal; min-width: 30rem; } }
.ops-console pre { font-family: var(--mono); font-size: 0.9em; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-small); padding: var(--space-3); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.ops-console pre.untrusted { background: var(--experimental-soft); border-color: var(--experimental); }
.ops-console .untrusted-label { font-size: 0.85rem; font-weight: 600; color: var(--experimental); margin-bottom: var(--space-1); }
.ops-console h1 { overflow-wrap: anywhere; }
.ops-console h2 { margin-top: var(--space-6); }
.ops-console form { margin: var(--space-4) 0; display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; }
.ops-console label { display: flex; flex-direction: column; gap: var(--space-1); }
.ops-console input[type="password"] { font: inherit; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); color: var(--ink); min-height: 44px; min-width: 20rem; max-width: 100%; }
.ops-console button { font: inherit; font-weight: 600; min-height: 44px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-small); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.ops-console .nowrap { white-space: nowrap; }

/* Tool consoles */
.console { margin-block: 1.5rem; }
.console-op { margin-block: 0.75rem; }
.console-op > label, .console label { display: block; margin-block: 0.5rem 0.25rem; font-weight: 600; }
.console-input { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 0.9em; }
.console select { min-width: 12rem; }
.console button { margin-block: 0.5rem; }
.console-output { font-family: var(--mono); font-size: 0.9em; background: var(--surface-muted); border-radius: 3px; padding: var(--space-3); max-height: 28rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console-output:empty { display: none; }
.console-status { font-weight: 600; margin-block-end: 0.25rem; }
