/* Components: plain CSS on the tokens. Load tokens.css first, then this file.
   Every class starts with ui- so it can live beside the old app.css while pages move over.
   Values come from tokens.css; nothing here declares a colour of its own. */

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; }
:root, [data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; font-family: var(--font-sans); font-size: 15px; line-height: 22px; color: var(--ink); background: var(--ground); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--ink); }
.ui-num { font-variant-numeric: tabular-nums; }
.ui-hidden-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ui-icon--sm { width: 16px; height: 16px; }
.ui-sep::before { content: "·"; margin: 0 6px; color: var(--ink-faint); }

/* ---------- frame: shell, sidebar, nav, sheet ---------- */
.ui-shell { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); gap: var(--space-2); min-height: 100vh; padding: var(--space-2); box-sizing: border-box; background: var(--ground); }
.ui-side { position: sticky; top: var(--space-2); height: calc(100vh - 2 * var(--space-2)); box-sizing: border-box; display: flex; flex-direction: column; gap: 20px; padding: var(--space-2) 6px; overflow-y: auto; }
.ui-sheet { min-width: 0; box-sizing: border-box; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-10) clamp(20px, 4vw, var(--space-12)) var(--space-16); }
.ui-sheet-inner { max-width: var(--content-max); margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-8); }

.ui-switcher { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px var(--space-2); border: 0; border-radius: var(--radius-md); background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.ui-switcher:hover { background: var(--sheet); }
.ui-switcher-text { flex: 1; min-width: 0; }
.ui-switcher-name { display: block; font-weight: 600; font-size: 14px; line-height: 18px; overflow-wrap: anywhere; }
.ui-switcher-sub { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.ui-company-mark { width: 30px; height: 30px; flex: none; border-radius: 7px; background: var(--ink); color: var(--ground); display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }

.ui-nav { display: flex; flex-direction: column; gap: 2px; }
.ui-nav-item { display: flex; align-items: center; gap: 10px; min-height: var(--control-md); padding: 0 10px; border-radius: var(--radius-md); color: var(--ink-muted); font-size: 14.5px; font-weight: 500; text-decoration: none; }
.ui-nav-item:hover { color: var(--ink); background: color-mix(in srgb, var(--sheet) 60%, transparent); }
.ui-nav-item[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--sheet); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); }
.ui-nav-label { flex: 1; min-width: 0; }
.ui-nav-sep { height: 1px; background: var(--line); margin: 10px; }
.ui-nav-staff { font-size: 12px; font-weight: 500; color: var(--ink-faint); padding: 10px 10px 2px; }

.ui-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.ui-sync { display: flex; gap: var(--space-2); align-items: flex-start; padding: 0 10px; font-size: 12.5px; line-height: 17px; color: var(--ink-muted); }
.ui-sync::before { content: ""; width: 7px; height: 7px; margin-top: 5px; flex: none; border-radius: 50%; background: var(--positive); }
.ui-sync[data-state="working"]::before { background: var(--accent); }
.ui-sync[data-state="problem"]::before { background: var(--danger); }

@media (max-width: 860px) {
  .ui-shell { grid-template-columns: minmax(0, 1fr); }
  .ui-side { position: static; height: auto; gap: 12px; }
  .ui-nav { flex-direction: row; flex-wrap: wrap; }
  .ui-nav-sep, .ui-nav-staff { display: none; }
  .ui-side-foot { margin-top: 0; }
  .ui-sheet { padding: var(--space-6) var(--space-4) var(--space-12); }
}

/* ---------- page header ---------- */
.ui-page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: var(--space-3) var(--space-6); }
.ui-page-head-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; max-width: var(--measure); }
.ui-eyebrow { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.ui-page-title { margin: 0; font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.ui-page-title--record { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; line-height: 36px; }
.ui-lede { margin: var(--space-1) 0 0; color: var(--ink-muted); }
.ui-page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.ui-back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-muted); text-decoration: none; margin-bottom: var(--space-2); }
.ui-back:hover { color: var(--ink); }
.ui-section { display: flex; flex-direction: column; gap: var(--space-3); }
.ui-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; }
.ui-section-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- product wordmark and monogram (the name is a slot) ---------- */
.ui-wordmark { font-family: var(--font-serif); font-weight: 600; font-size: 22px; line-height: 1; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.ui-wordmark--lg { font-size: 40px; }
.ui-monogram { position: relative; width: 32px; height: 32px; flex: none; border-radius: var(--radius-md); background: var(--map-stage); color: var(--map-ink); display: inline-grid; place-items: center; font-family: var(--font-serif); font-weight: 600; font-size: 19px; line-height: 1; box-shadow: inset 0 0 0 1px var(--map-hair); }
.ui-monogram::after { content: ""; position: absolute; right: 5px; top: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--map-accent); }
.ui-monogram--sm { width: 24px; height: 24px; border-radius: var(--radius-sm); font-size: 15px; }
.ui-monogram--sm::after { right: 3px; top: 3px; width: 4px; height: 4px; }

/* ---------- buttons ---------- */
.ui-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-md); padding: 0 var(--space-4); box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--sheet); color: var(--ink); font: inherit; font-size: 14.5px; line-height: 1; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
.ui-button:hover { background: var(--raised); color: var(--ink); }
.ui-button--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.ui-button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.ui-button--quiet { background: transparent; border-color: transparent; color: var(--accent-text); padding: 0 var(--space-3); }
.ui-button--quiet:hover { background: var(--raised); color: var(--ink); }
.ui-button--danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); font-weight: 600; }
.ui-button--danger:hover { filter: brightness(1.06); color: var(--on-danger); }
.ui-button--sm { height: var(--control-sm); padding: 0 var(--space-3); font-size: 13.5px; border-radius: var(--radius-sm); }
.ui-button--lg { height: var(--control-lg); padding: 0 var(--space-6); font-size: 16px; }
.ui-button[disabled], .ui-button[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.ui-button[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; box-sizing: border-box; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ui-spin 0.8s linear infinite; }
.ui-button-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---------- menu ---------- */
.ui-menu { min-width: 220px; max-width: 320px; padding: 6px; box-sizing: border-box; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 2px; }
.ui-menu-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.ui-menu-item:hover, .ui-menu-item:focus-visible { background: var(--raised); outline: none; }
.ui-menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent-text); font-weight: 600; }
.ui-menu-item--danger { color: var(--danger); }
.ui-menu-label { padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ink-muted); }
.ui-menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- a fact's standing ---------- */
.ui-standing { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.ui-standing::before { content: ""; width: 8px; height: 8px; flex: none; box-sizing: border-box; border-radius: 50%; background: currentColor; }
.ui-standing[data-standing="confirmed"] { color: var(--confirmed); }
.ui-standing[data-standing="checked"] { color: var(--checked); }
.ui-standing[data-standing="unchecked"] { color: var(--unchecked); }
.ui-standing[data-standing="unchecked"]::before { background: transparent; border: 1.5px solid currentColor; }
.ui-standing[data-standing="in-question"] { color: var(--in-question); }
.ui-standing[data-standing="retired"] { color: var(--retired); }

/* ---------- badges ---------- */
.ui-badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; box-sizing: border-box; border-radius: var(--radius-full); background: var(--raised); color: var(--ink-muted); font-size: 12px; line-height: 1; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-badge--count { min-width: 20px; height: 20px; padding: 0 6px; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.ui-badge--accent { background: var(--accent-soft); color: var(--accent-text); }
.ui-badge--positive { background: var(--positive-soft); color: var(--positive); }
.ui-badge--warning { background: var(--in-question-soft); color: var(--in-question); }
.ui-badge--danger { background: var(--danger-soft); color: var(--danger); }
.ui-badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- notices ---------- */
.ui-notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: 14px var(--space-4); border-radius: var(--radius-lg); background: var(--accent-soft); color: var(--ink); }
.ui-notice > .ui-icon { margin-top: 2px; color: var(--accent-text); }
.ui-notice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ui-notice-title { font-weight: 600; }
.ui-notice-text { margin: 0; color: var(--ink-muted); font-size: 14px; line-height: 20px; }
.ui-notice--positive { background: var(--positive-soft); }
.ui-notice--positive > .ui-icon { color: var(--positive); }
.ui-notice--warning { background: var(--in-question-soft); }
.ui-notice--warning > .ui-icon { color: var(--in-question); }
.ui-notice--danger { background: var(--danger-soft); }
.ui-notice--danger > .ui-icon { color: var(--danger); }

/* ---------- toast ---------- */
.ui-toast { display: inline-flex; align-items: center; gap: var(--space-4); max-width: min(560px, calc(100vw - 32px)); padding: 12px 12px 12px var(--space-4); box-sizing: border-box; border-radius: var(--radius-lg); background: var(--ink); color: var(--sheet); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 20px; }
.ui-toast-text { flex: 1; min-width: 0; }
.ui-toast-action { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.ui-toast-region { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); z-index: 50; }

/* ---------- facts ---------- */
.ui-fact { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5) 0; border-bottom: 1px solid var(--line); }
.ui-fact-statement { margin: 0; font-family: var(--font-serif); font-size: 17px; line-height: 26px; font-weight: 500; color: var(--ink); text-wrap: pretty; max-width: var(--measure); }
.ui-fact-source { margin: 0; font-size: 13px; line-height: 19px; font-weight: 400; color: var(--ink-muted); }
.ui-fact-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-left: calc(-1 * var(--space-3)); }
.ui-fact--retired .ui-fact-statement { color: var(--retired); text-decoration: line-through; text-decoration-thickness: 1px; }
.ui-fact-row { display: flex; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.ui-fact-row::before { content: ""; width: 8px; height: 8px; margin-top: 8px; flex: none; box-sizing: border-box; border-radius: 50%; background: var(--unchecked); }
.ui-fact-row[data-standing="confirmed"]::before { background: var(--confirmed); }
.ui-fact-row[data-standing="checked"]::before { background: var(--checked); }
.ui-fact-row[data-standing="unchecked"]::before { background: transparent; border: 1.5px solid var(--unchecked); }
.ui-fact-row[data-standing="in-question"]::before { background: var(--in-question); }
.ui-fact-row[data-standing="retired"]::before { background: var(--retired); }
.ui-fact-row-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ui-fact-row-statement { font-family: var(--font-serif); font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); }
.ui-fact-row[data-standing="retired"] .ui-fact-row-statement { color: var(--retired); text-decoration: line-through; }
.ui-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

/* ---------- conversation and answers ---------- */
.ui-convo { display: flex; flex-direction: column; gap: var(--space-8); max-width: 760px; }
.ui-turn { display: flex; flex-direction: column; gap: var(--space-3); }
.ui-turn-question { display: flex; gap: var(--space-3); align-items: flex-start; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--ink); }
.ui-answer { margin: 0; font-family: var(--font-serif); font-size: 19px; line-height: 30px; font-weight: 400; color: var(--ink); max-width: var(--measure); text-wrap: pretty; }
.ui-answer p { margin: 0 0 14px; }
.ui-answer p:last-child { margin-bottom: 0; }
.ui-answer-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.ui-answer-meta { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.ui-answer--unknown { font-style: italic; color: var(--ink-muted); }
.ui-offer { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding: var(--space-3) var(--space-4); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); font-size: 14px; }

/* ---------- citations and quotes ---------- */
.ui-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 1px; box-sizing: border-box; border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent-text); font-family: var(--font-sans); font-size: 11px; line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; vertical-align: 3px; text-decoration: none; }
.ui-cite:hover, .ui-cite[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
.ui-sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.ui-source { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--space-2) var(--space-3); align-items: start; }
.ui-source > .ui-cite { margin-top: 3px; vertical-align: 0; }
.ui-source-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-source-fact { font-family: var(--font-serif); font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); text-decoration: none; }
.ui-source-fact:hover { text-decoration: underline; }
.ui-quote { margin: 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--raised); font-family: var(--font-serif); font-size: 16px; line-height: 26px; color: var(--ink); overflow-wrap: anywhere; max-width: var(--measure); }
.ui-quote mark { background: var(--accent-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; box-shadow: inset 0 -2px 0 var(--accent); }
.ui-quote-source { display: block; margin-top: 8px; font-family: var(--font-sans); font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.ui-proposal { color: var(--in-question); font-weight: 600; }

/* ---------- history ---------- */
.ui-history { list-style: none; margin: 0; padding: 0; position: relative; }
.ui-history::before { content: ""; position: absolute; left: 11px; top: 12px; bottom: 12px; width: 1px; background: var(--line); }
.ui-event { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 2px var(--space-3); padding: var(--space-3) 0; align-items: start; }
.ui-event-marker { grid-row: span 3; width: 24px; height: 24px; box-sizing: border-box; border-radius: 50%; background: var(--sheet); border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: var(--ink-muted); }
.ui-event-marker::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ui-event[data-kind="confirmed"] .ui-event-marker { border-color: var(--confirmed); color: var(--confirmed); }
.ui-event[data-kind="checked"] .ui-event-marker { border-color: var(--checked); color: var(--checked); }
.ui-event[data-kind="in-question"] .ui-event-marker { border-color: var(--in-question); color: var(--in-question); }
.ui-event[data-kind="retired"] .ui-event-marker { border-color: var(--retired); color: var(--retired); }
.ui-event[data-kind="undone"] .ui-event-marker { border-style: dashed; }
.ui-event-title { font-size: 14.5px; line-height: 22px; font-weight: 600; color: var(--ink); }
.ui-event-time { font-size: 13px; line-height: 22px; color: var(--ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-event-detail { grid-column: 2 / 4; margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.ui-event-detail .ui-value { font-family: var(--font-serif); font-weight: 500; color: var(--ink); }
.ui-event-detail .ui-value--old { color: var(--retired); text-decoration: line-through; }
.ui-event-actions { grid-column: 2 / 4; display: flex; gap: var(--space-1); flex-wrap: wrap; margin-left: calc(-1 * var(--space-3)); }
.ui-via { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--ink-muted); }

/* ---------- disagreement ---------- */
.ui-disagreement { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--sheet); }
.ui-disagreement-head { display: flex; flex-direction: column; gap: 4px; padding: 14px var(--space-4); background: var(--in-question-soft); }
.ui-disagreement--settled .ui-disagreement-head { background: var(--raised); }
.ui-disagreement-head .ui-fact-statement { font-size: 16px; line-height: 24px; }
.ui-versions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ui-version { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border-top: 1px solid var(--line); min-width: 0; }
.ui-version + .ui-version { border-left: 1px solid var(--line); }
.ui-version-role { font-size: 12px; font-weight: 600; color: var(--ink-muted); }
.ui-version-value { font-family: var(--font-serif); font-size: 20px; line-height: 28px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.ui-version--held .ui-version-role { color: var(--accent-text); }
.ui-version--set-aside .ui-version-value { color: var(--retired); text-decoration: line-through; text-decoration-thickness: 1px; }
.ui-disagreement-foot { padding: 12px var(--space-4); border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-muted); }

/* ---------- questions (the Resolve page) ---------- */
.ui-question { display: flex; flex-direction: column; gap: 10px; padding: var(--space-5) 0; border-bottom: 1px solid var(--line); }
.ui-question-text { margin: 0; font-family: var(--font-serif); font-size: 18px; line-height: 27px; font-weight: 500; color: var(--ink); text-wrap: pretty; max-width: var(--measure); }
.ui-question-evidence { margin: 0; font-size: 13px; line-height: 19px; color: var(--ink-muted); }
.ui-question-for { margin-left: auto; }
.ui-question-top { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- forms ---------- */
.ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-label { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink); }
.ui-hint { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.ui-input, .ui-select, .ui-textarea { width: 100%; max-width: 480px; box-sizing: border-box; min-height: var(--control-md); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--sheet); color: var(--ink); font: inherit; font-size: 15px; }
.ui-textarea { max-width: none; padding: 10px 12px; min-height: 96px; line-height: 22px; resize: vertical; }
.ui-select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.ui-input::placeholder, .ui-textarea::placeholder { color: var(--ink-faint); }
.ui-input:focus-visible, .ui-select:focus-visible, .ui-textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.ui-field--error .ui-input, .ui-field--error .ui-select, .ui-field--error .ui-textarea { border-color: var(--danger); }
.ui-error { display: flex; gap: 6px; align-items: flex-start; margin: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--danger); }
.ui-form { display: flex; flex-direction: column; gap: 20px; }

/* ---------- choice cards ---------- */
.ui-choices { display: grid; gap: var(--space-2); }
.ui-choices--row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ui-choice { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 14px var(--space-4) 14px 46px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--sheet); cursor: pointer; transition: border-color 120ms ease; }
.ui-choice:hover { border-color: var(--line-strong); }
.ui-choice input { position: absolute; left: 16px; top: 16px; margin: 0; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.ui-choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ui-choice:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.ui-choice input:focus-visible { outline: none; }
.ui-choice-title { font-weight: 600; color: var(--ink); }
.ui-choice-title--record { font-family: var(--font-serif); font-size: 17px; line-height: 26px; font-weight: 500; }
.ui-choice-desc { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.ui-choice-guess { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--accent-text); }
.ui-choice[aria-disabled="true"] { opacity: 0.55; cursor: default; }

/* ---------- checkbox and switch ---------- */
.ui-check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; line-height: 22px; }
.ui-check input { flex: none; margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.ui-switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-size: 15px; }
.ui-switch input { flex: none; margin: 0; width: 36px; height: 22px; appearance: none; border-radius: var(--radius-full); background: var(--line-strong); position: relative; cursor: pointer; transition: background-color 150ms ease; }
.ui-switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--sheet); transition: transform 150ms ease; }
.ui-switch input:checked { background: var(--accent); }
.ui-switch input:checked::after { transform: translateX(14px); }

/* ---------- ask bar ---------- */
.ui-askbar { display: flex; align-items: center; gap: var(--space-2); max-width: 880px; padding: 5px 5px 5px 14px; box-sizing: border-box; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--sheet); }
.ui-askbar:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.ui-askbar > .ui-icon { color: var(--ink-muted); }
.ui-askbar-input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; outline: none; }
.ui-askbar-input::placeholder { color: var(--ink-faint); }
.ui-askbar-model { height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-muted); font: inherit; font-size: 13px; font-weight: 500; padding: 0 8px; cursor: pointer; }
.ui-askbar-model:hover { background: var(--raised); color: var(--ink); }
.ui-askbar--lg { padding: 6px 6px 6px 16px; }
.ui-askbar--lg .ui-askbar-input { height: 44px; font-size: 17px; }

/* ---------- drop zone ---------- */
.ui-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--space-8) var(--space-6); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--raised); text-align: center; cursor: pointer; }
.ui-drop:hover, .ui-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.ui-drop.is-chosen { border-style: solid; border-color: var(--accent); }
.ui-drop-title { font-weight: 600; overflow-wrap: anywhere; }
.ui-drop-hint { font-size: 13px; color: var(--ink-muted); }
.ui-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* ---------- table ---------- */
.ui-table-wrap { overflow-x: auto; }
.ui-table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 20px; }
.ui-table th { text-align: left; padding: 10px var(--space-3); font-size: 13px; font-weight: 500; color: var(--ink-muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.ui-table td { padding: var(--space-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.ui-table tbody tr:hover { background: var(--raised); }
.ui-table .ui-num, .ui-table td.is-num, .ui-table th.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.ui-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ui-person-name { font-weight: 600; color: var(--ink); }
.ui-person-sub { font-size: 13px; color: var(--ink-muted); overflow-wrap: anywhere; }

/* ---------- tabs ---------- */
.ui-tabs { display: flex; gap: var(--space-6); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ui-tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 0 11px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-muted); font-size: 14.5px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.ui-tab:hover { color: var(--ink); }
.ui-tab[aria-current="true"], .ui-tab[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.ui-tab-count { font-size: 12px; font-weight: 600; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

/* ---------- figures ---------- */
.ui-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-6); }
.ui-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ui-stat-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.ui-stat-value { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.ui-stat-sub { font-size: 13px; line-height: 18px; color: var(--ink-muted); }

.ui-meter { display: flex; flex-direction: column; gap: 6px; }
.ui-meter-head { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 14px; }
.ui-meter-label { font-weight: 600; }
.ui-meter-figure { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ui-meter-track { height: 6px; border-radius: var(--radius-full); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.ui-meter-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--accent); }
.ui-meter--warning .ui-meter-fill { background: var(--in-question); }
.ui-meter--over .ui-meter-fill { background: var(--danger); }

/* ---------- progress: an import or the map building ---------- */
.ui-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ui-step { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 2px var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); align-items: start; }
.ui-step:last-child { border-bottom: 0; }
.ui-step-marker { grid-row: span 2; width: 22px; height: 22px; margin-top: 1px; box-sizing: border-box; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.ui-step-title { font-weight: 600; color: var(--ink); }
.ui-step-figure { font-size: 13px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-step-detail { grid-column: 2 / 4; margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.ui-step[data-state="waiting"] .ui-step-title { color: var(--ink-muted); font-weight: 500; }
.ui-step[data-state="done"] .ui-step-marker { border-color: var(--positive); background: var(--positive); color: var(--sheet); }
.ui-step[data-state="done"] .ui-step-marker::after { content: "✓"; }
.ui-step[data-state="now"] .ui-step-marker { border-color: var(--accent); border-right-color: transparent; animation: ui-spin 1s linear infinite; }
.ui-step[data-state="failed"] .ui-step-marker { border-color: var(--danger); background: var(--danger); color: var(--sheet); }
.ui-step[data-state="failed"] .ui-step-marker::after { content: "!"; }
.ui-progress { height: 4px; border-radius: var(--radius-full); background: var(--raised); overflow: hidden; }
.ui-progress-fill { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width 400ms ease; }
.ui-progress--busy .ui-progress-fill { width: 30%; animation: ui-slide 1.6s ease-in-out infinite; }
@keyframes ui-slide { from { transform: translateX(-110%); } to { transform: translateX(360%); } }
.ui-spinner { display: inline-block; width: 14px; height: 14px; box-sizing: border-box; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: ui-spin 0.8s linear infinite; vertical-align: -2px; }

/* ---------- empty states ---------- */
.ui-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); padding: var(--space-8) var(--space-6); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); }
.ui-empty-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.ui-empty-text { margin: 0 0 var(--space-2); color: var(--ink-muted); max-width: var(--measure); }

/* ---------- avatars ---------- */
.ui-avatar { width: 32px; height: 32px; flex: none; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent-text); display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: 0.01em; }
.ui-avatar--sm { width: 24px; height: 24px; font-size: 10.5px; }
.ui-avatar--lg { width: 40px; height: 40px; font-size: 14px; }
.ui-avatar--system { background: var(--map-stage); color: var(--map-accent); box-shadow: inset 0 0 0 1px var(--map-hair); font-family: var(--font-serif); font-size: 15px; }

/* ---------- dialog ---------- */
.ui-scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: var(--space-4); z-index: 40; }
.ui-dialog { width: min(480px, 100%); box-sizing: border-box; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-6); border-radius: var(--radius-lg); background: var(--sheet); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.ui-dialog-title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.ui-dialog-text { margin: 0; color: var(--ink-muted); }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }

/* ---------- the map's stage ---------- */
.ui-map-stage { position: relative; min-height: 320px; border-radius: var(--radius-lg); overflow: hidden; background: radial-gradient(ellipse at 50% 46%, var(--map-glow) 0%, var(--map-stage) 62%); color: var(--map-ink); }
.ui-map-stage::before, .ui-map-stage::after { content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; z-index: 2; }
.ui-map-stage::before { left: 12px; top: 12px; border-left: 1px solid var(--map-accent); border-top: 1px solid var(--map-accent); }
.ui-map-stage::after { right: 12px; bottom: 12px; border-right: 1px solid var(--map-accent); border-bottom: 1px solid var(--map-accent); }
.ui-map-stage > .ui-map-frame { position: absolute; inset: 0; }
.ui-map-caption { position: absolute; left: 20px; bottom: 16px; z-index: 2; font-size: 13px; color: var(--map-ink-muted); }
.ui-map-caption b { color: var(--map-ink); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .ui-button[aria-busy="true"]::before, .ui-step[data-state="now"] .ui-step-marker, .ui-spinner { animation-duration: 3s; }
  .ui-progress--busy .ui-progress-fill { animation: none; width: 100%; opacity: 0.4; }
  * { transition: none !important; }
}
