/* © 2026 Natchaya Luangphairin · Water Quality Explorer · CC BY-NC 4.0 (see LICENSE.md) */
/* Water Quality Explorer. Colors follow the main site (styles.css) with a dark mode. */
:root {
  color-scheme: light;
  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-2: #f5f8fd;
  --border: rgba(1, 32, 96, 0.14);
  --text: #012060;
  --muted: #52607a;
  --accent: #003cb9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 60, 185, 0.08);
  --error: #c00000;
  --good: #1a7f37;
  --warn: #9a6700;
  --shadow: 0 12px 40px rgba(1, 32, 96, 0.08);
  --radius: 14px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', var(--font);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c111b;
    --surface: #141a26;
    --surface-2: #1b2231;
    --border: rgba(232, 237, 247, 0.12);
    --text: #e8edf7;
    --muted: #a9b4c8;
    --accent: #6d9cf2;
    --accent-ink: #0c111b;
    --accent-soft: rgba(109, 156, 242, 0.14);
    --error: #ff8a80;
  --good: #6fdd8b;
  --warn: #f2cc60;
    --good: #6fdd8b;
    --warn: #f2cc60;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c111b;
  --surface: #141a26;
  --surface-2: #1b2231;
  --border: rgba(232, 237, 247, 0.12);
  --text: #e8edf7;
  --muted: #a9b4c8;
  --accent: #6d9cf2;
  --accent-ink: #0c111b;
  --accent-soft: rgba(109, 156, 242, 0.14);
  --error: #ff8a80;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
[hidden] { display: none !important; }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.back { font-weight: 600; text-decoration: none; white-space: nowrap; font-size: 14px; }
.home-logo { display: inline-flex; flex: none; border-radius: 10px; transition: transform 0.15s ease; }
.home-logo img { display: block; width: 52px; height: 52px; border-radius: 10px; background: #ffffff; }
.home-logo:hover, .home-logo:focus-visible { transform: scale(1.05); }
@media (max-width: 600px) { .home-logo img { width: 40px; height: 40px; } }
.title-block { flex: 1; min-width: 0; }
.title-block h1 { font-size: 22px; line-height: 1.2; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ready .status-dot { background: #1baf7a; }
.status.busy .status-dot { background: var(--accent); animation: pulse 1s infinite alternate; }
.status.error .status-dot { background: var(--error); }
@keyframes pulse { to { opacity: 0.3; } }

/* Loading screen */
.loading { display: grid; place-items: center; min-height: 70vh; padding: 16px; }
.loading-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; max-width: 460px; width: 100%; box-shadow: var(--shadow); }
.loading-card h2 { font-size: 20px; margin-bottom: 8px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 16px 0; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.hint, .help { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* Layout */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; padding: 20px 24px 48px; max-width: 1600px; margin: 0 auto; }
.sidebar { display: flex; flex-direction: column; gap: 12px; align-self: start; position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel-title { font-size: 14px; letter-spacing: 0.02em; margin-bottom: 10px; }
.card h3 { font-size: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.field > span, .filter-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; font-weight: 500; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.filter { margin-bottom: 12px; }
.filter-label { display: block; margin-bottom: 4px; }
.upload summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent); }
.upload input[type="file"] { font-size: 13px; margin-top: 4px; width: 100%; }

/* Picker */
.picker { position: relative; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-chips:not(:empty) { margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; font-weight: 600; max-width: 100%; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 50%; }
.chip button:hover { color: var(--text); background: var(--border); }
.picker-input-row { display: flex; gap: 6px; }
.picker-clear { border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.picker-list li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.picker-list li:hover, .picker-list li.active { background: var(--accent-soft); }
.picker-check { width: 14px; height: 14px; border: 1.5px solid var(--muted); border-radius: 4px; flex: none; }
li[aria-selected="true"] .picker-check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface); }
.picker-label { flex: 1; min-width: 0; }
.picker-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.picker-more { color: var(--muted); font-size: 12px; cursor: default !important; }

/* Buttons */
.btn { font: inherit; font-weight: 700; font-size: 14px; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: none; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.load-tip { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 8px; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--muted); }
.load-tip svg { flex: none; margin-top: 2px; color: var(--accent); }
.load-tip p { margin: 0; font-size: 12.5px; line-height: 1.45; }
.load-tip strong { color: var(--text); }
.slow-note { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; gap: 12px; align-items: center; width: min(560px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font-size: 13px; }
.slow-note p { margin: 0; line-height: 1.45; }
.slow-note strong { color: var(--text); }
.slow-spinner { flex: none; width: 18px; height: 18px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: slow-spin 0.9s linear infinite; }
@keyframes slow-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .slow-spinner { animation: none; } }
.sidebar-actions { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }
.sidebar-actions .primary { flex: 1; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 0; border-bottom: 1px solid var(--border); }
.tab-group { display: flex; flex-direction: column; padding: 0 10px; border-left: 1px solid var(--border); }
.tab-group:first-child { border-left: 0; padding-left: 0; }
.tab-group-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 2px 14px 0; }
.tab-group-items { display: flex; flex-wrap: wrap; }
@media (max-width: 700px) { .tab-group { border-left: 0; padding: 0; } }
.guide-tabs dt { font-weight: 700; margin-top: 10px; }
.guide-tabs dd { margin: 2px 0 0 0; }
.tab { font: inherit; font-weight: 700; font-size: 14px; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chart { width: 100%; min-height: 380px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.note:empty { display: none; }
.lede { margin: 0 0 12px; color: var(--muted); }
.error { color: var(--error); font-weight: 600; margin: 10px 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; margin: 12px 0 4px; }
.detail-grid div { display: flex; flex-direction: column; font-size: 14px; }
.detail-grid span:first-child { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.facility { border-top: 1px solid var(--border); padding: 10px 0; }
.facility h4 { margin: 0 0 4px; font-size: 14px; }
.facility p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.selected { background: var(--accent-soft); }
.flow-wrap { overflow-x: auto; margin: 12px 0 8px; }
.flow { width: 100%; min-width: 860px; height: auto; display: block; font-family: var(--font); }
.flow-box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.flow-box.accent { stroke: var(--accent); }
.flow-box.dashed { stroke-dasharray: 5 4; }
.flow-head { fill: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; }
.flow-title { fill: var(--text); font-size: 13px; font-weight: 700; }
.flow-text { fill: var(--muted); font-size: 11.5px; }
.flow-arrow { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.flow-arrow.dashed { stroke-dasharray: 5 4; }
.flow-arrowhead { fill: var(--muted); }
#db-sql { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.data-table td.mono, .data-table th.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.colors-panel summary { cursor: pointer; margin-bottom: 0; }
.colors-panel[open] summary { margin-bottom: 10px; }
.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 6px 0 10px; }
.color-grid input[type="color"] { width: 100%; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); cursor: pointer; }
.color-grid input:disabled { opacity: 0.45; cursor: not-allowed; }
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-row img { max-height: 44px; max-width: 160px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: #ffffff; }
.logo-row input[type="file"] { font-size: 13px; }
.feedback-btn { white-space: nowrap; }
.feedback-dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.feedback-dialog::backdrop { background: rgba(1, 32, 96, 0.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.dialog-head h2 { font-size: 20px; }
.feedback-thanks h3 { font-size: 18px; margin-bottom: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app-footer { max-width: 1600px; margin: 0 auto; padding: 4px 24px 32px; color: var(--muted); font-size: 13px; text-align: center; }
.footer-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 0; margin: 0 auto 12px; padding: 10px 0 12px; border-top: 1px solid var(--border); max-width: 760px; }
.footer-meta > div { display: flex; flex-direction: column; align-items: center; padding: 0 22px; }
.footer-meta > div + div { border-left: 1px solid var(--border); }
.footer-meta dt { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.footer-meta dd { margin: 2px 0 0; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .footer-meta > div { padding: 0 12px; } .footer-meta > div:last-child { border-left: 0; flex-basis: 100%; } }
.citation { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; }
.code-controls { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(200px, 1fr) auto; gap: 0 12px; align-items: end; }
.code-controls .actions { margin-bottom: 10px; }
.table-wrap.tall { max-height: 70vh; }
.code-type { color: var(--muted); font-size: 12px; }
.btn.tiny { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
@media (max-width: 700px) { .code-controls { grid-template-columns: 1fr; } }
.ref-figure { margin: 12px 0 18px; }
.ref-figure img { display: block; width: 100%; height: auto; border-radius: 8px; background: #ffffff; border: 1px solid var(--border); }
.ref-figure.narrow { max-width: 460px; }
.ref-figure figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.reg-note { font-size: 12px; color: var(--muted); max-width: 420px; }
.tl-list { max-width: 640px; line-height: 1.5; }
.tl-list em { color: var(--muted); }
.tl-list mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.tl-added { display: inline-block; margin-top: 2px; font-size: 11px; color: var(--accent); }
.tl-notes { margin-top: 10px; font-size: 13px; color: var(--muted); }
.tl-notes summary { cursor: pointer; color: var(--text); }
.tl-notes ol { margin: 8px 0 0; padding-left: 22px; }
.summary-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 12px; }
.data-table.pivot th[scope="row"] { position: static; text-align: left; color: var(--text); font-weight: 600; background: none; white-space: normal; }
.data-table.pivot .total { font-weight: 700; }
.data-table.pivot tr.total-row td, .data-table.pivot tr.total-row th { border-top: 2px solid var(--border); font-weight: 700; }
.intervention-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; align-items: end; }
.interpretation h3 { margin-bottom: 8px; }
.interpretation ul, .notes, .prose ul { margin: 0; padding-left: 20px; }
.interpretation li, .notes li, .prose li { margin: 6px 0; }
.prose h3 { margin: 16px 0 6px; }
.prose h3:first-child { margin-top: 0; }
.sig { font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table caption { text-align: left; font-weight: 700; font-size: 14px; padding: 12px 0 6px; font-family: var(--font-display); }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; }
.data-table .left { text-align: left; white-space: normal; }
.data-table tbody tr:hover { background: var(--accent-soft); }
.sql { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; }

/* Report preview */
.report-preview { background: #ffffff; color: #1a1a1a; border-radius: var(--radius); border: 1px solid var(--border); }
.report-preview:empty { display: none; }
.report-preview iframe { width: 100%; height: 80vh; border: 0; border-radius: var(--radius); }

/* Visibility by dataset kind and design */
body:not(.kind-occurrence) .occurrence-only,
body:not(.kind-violation) .violation-only,
body:not(.stat-threshold) .threshold-only,
body:not(.stat-count) .count-only,
body:not(.design-did) .did-only { display: none !important; }
/* Intervention tab: iv-trend (pre/post or DiD) and/or iv-survival, from the Analysis choice */
body:not(.iv-survival) .survival-only { display: none !important; }
body:not(.iv-trend) .trend-only { display: none !important; }
body:not(.iv-trend) .did-only { display: none !important; }
/* Survival compares treatment and control systems with the DiD control-group controls */
body.iv-survival.sv-treatment .did-controls { display: block !important; }
body.iv-survival:not(.design-did) .did-controls .did-mode { display: none; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; max-height: none; overflow: visible; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; }
  .title-block { order: 3; flex-basis: 100%; }
}
.callout { padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }

.corr-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; align-items: end; }
@media (max-width: 900px) { .corr-controls { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .corr-controls { grid-template-columns: 1fr; } }
.corr-controls .span-all { grid-column: 1 / -1; }
/* Multilevel model: verdicts carry a symbol and a word, never color alone */
.chk { font-weight: 700; white-space: nowrap; }
.chk-good { color: var(--good); }
.chk-check { color: var(--warn); }
.chk-problem { color: var(--error); }
.mlm-steps { margin: 6px 0 10px; padding-left: 20px; }
.mlm-steps li { margin: 3px 0; }
.upload-columns { margin-top: 10px; }
.upload-columns summary { cursor: pointer; font-size: 13px; }
.column-names { padding-left: 18px; margin: 6px 0; }
.column-names li { margin: 4px 0; }
.report-sections { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px 4px; margin: 12px 0; }
.report-sections legend { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }
.report-section-list { list-style: none; margin: 0; padding: 0; max-width: 520px; }
.report-section { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.report-section:last-child { border-bottom: 0; }
.report-section .check { margin: 6px 0; }
.report-section .move { display: inline-flex; gap: 4px; flex: none; }
.report-section .check { flex: 1; }
.report-section .section-state { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.report-section-list { max-width: 680px; }
.status-badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status-badge.ok { color: #12784f; background: rgba(27, 175, 122, 0.14); }
.status-badge.missing { color: #9a5b00; background: rgba(237, 161, 0, 0.16); }
:root[data-theme="dark"] .status-badge.ok { color: #6fdcaf; }
:root[data-theme="dark"] .status-badge.missing { color: #f2c46b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status-badge.ok { color: #6fdcaf; } :root:not([data-theme="light"]) .status-badge.missing { color: #f2c46b; } }
.section-state { font-size: 12px; color: var(--muted); }
.rhi-params summary { cursor: pointer; list-style: none; }
.rhi-params summary h3 { display: inline; }
.rhi-params summary::before { content: '▸ '; color: var(--muted); }
.rhi-params[open] summary::before { content: '▾ '; }
.rhi-param-input { width: 100%; min-width: 70px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.rhi-param-input.name { min-width: 150px; }
.rhi-columns { margin-top: 8px; }
.rhi-intro { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 20px; align-items: start; }
.rhi-intro-figure { margin: 0; }
.rhi-intro-figure img { display: block; width: 100%; height: auto; border-radius: 10px; background: #ffffff; }
.rhi-intro .refs { font-size: 13px; color: var(--muted); }
@media (max-width: 760px) { .rhi-intro { grid-template-columns: 1fr; } }
.field.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.field.inline span { margin: 0; }
.cup-row { display: flex; flex-wrap: wrap; gap: 18px 22px; align-items: flex-end; padding: 8px 0; }
.cup { margin: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.cup figcaption { font-size: 12px; color: var(--muted); max-width: 120px; line-height: 1.3; margin-top: 4px; }
.cup figcaption strong { display: block; color: var(--text); font-weight: 600; }
.cup figcaption span { display: block; }
.cup-map { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; max-width: 900px; margin: 8px 0; }
.cup-tile .cup svg { width: 100%; height: auto; max-width: 64px; }
.cup-tile .cup figcaption { font-size: 11px; }
.cup-tile .cup figcaption span { display: none; }
.cup-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 6px 0 0; font-size: 13px; }
.cup-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.share-link { display: flex; gap: 8px; margin: 10px 0; }
.share-link input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.share-buttons a { text-decoration: none; }
#panel-svi h3 { margin: 16px 0 8px; }
#panel-svi .card > h3:first-of-type { margin-top: 8px; }
.about-author { display: flex; gap: 14px; align-items: flex-start; }
.about-author img { flex: none; border-radius: 10px; background: #ffffff; }
.about-author p { margin: 0; }
.rhi-intro-figure figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.howto { margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--accent-soft); }
.howto summary { cursor: pointer; font-weight: 700; }
.howto ol { margin: 8px 0 2px; padding-left: 20px; }
.howto li { margin: 5px 0; line-height: 1.5; }
.lab-link { display: block; margin-top: 12px; text-decoration: none; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.lab-link img { display: block; width: 100%; height: auto; }
.lab-link span { display: block; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.lab-link:hover, .lab-link:focus-visible { transform: translateY(-1px); box-shadow: var(--shadow); }
.caution { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 10px 14px; border: 1px solid #e0a100; border-left-width: 4px; border-radius: 0 10px 10px 0; background: rgba(237, 161, 0, 0.1); }
.caution p { margin: 0; line-height: 1.5; }
.caution.small { margin: 12px 0 0; font-size: 13px; }
.caution-icon { flex: none; color: #c98500; margin-top: 1px; }
.rhi-findings { display: grid; grid-template-columns: 1fr minmax(300px, 420px); gap: 20px; align-items: start; }
@media (max-width: 860px) { .rhi-findings { grid-template-columns: 1fr; } }
.cup-tip { position: fixed; z-index: 50; pointer-events: none; max-width: 380px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-size: 12px; }
.cup-tip-body { display: flex; gap: 12px; align-items: flex-start; }
.cup-tip-body > div { flex: 1; min-width: 0; }
.cup-tip .cup figcaption { max-width: 90px; }
.cup-tip-total { margin: 0 0 2px; }
.cup-tip-meta { margin: 2px 0; color: var(--muted); font-size: 11px; }
.cup-tip-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 3px; }
.cup-tip-list li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 6px; align-items: center; }
.cup-tip-list .swatch { width: 10px; height: 10px; border-radius: 3px; }
.cup-tip-list .name { line-height: 1.25; }
.cup-tip-list .value, .cup-tip-list .share { font-variant-numeric: tabular-nums; text-align: right; }
.cup-tip-list .share { color: var(--muted); min-width: 40px; }
.map-tip { width: 340px; }
.map-tip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.map-tip-head span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.map-tip-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.map-tip-list.compact { gap: 3px; }
.map-tip-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.map-tip-row .swatch { width: 10px; height: 10px; border-radius: 3px; }
.map-tip-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-tip-list.compact .map-tip-row .name { font-weight: 500; }
.map-tip-list.compact .map-tip-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.map-tip-row .value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.map-tip .spark { display: block; }
.map-tip li.detailed .spark { margin: 4px 0 2px 16px; }
.map-tip li.detailed .cup-tip-meta { margin-left: 16px; }
#tl-table tr.tl-hit td { background: var(--accent-soft); animation: tl-flash 1.6s ease-out; }
#tl-table tr.tl-hit td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
@keyframes tl-flash { from { background: rgba(0, 60, 185, 0.28); } }
@media (prefers-reduced-motion: reduce) { #tl-table tr.tl-hit td { animation: none; } }
#reg-timeline-chart .scatterlayer .point { cursor: pointer; }
.rhi-row-actions { white-space: nowrap; }
.rhi-row-actions .btn + .btn { margin-left: 4px; }
.rhi-lookup { margin: 10px 0 0; padding: 10px 14px 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--surface-2); }
.rhi-lookup-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.rhi-lookup-kind { margin: 6px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.rhi-lookup-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
.rhi-lookup-list li { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.rhi-lookup-list .act { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.rhi-lookup-list .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.rhi-lookup-list .src { color: var(--muted); }
.rhi-lookup-diff { color: var(--text); border-left: 3px solid var(--accent); padding-left: 8px; }
.rhi-sources { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.rhi-sources ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
@media (max-width: 640px) { .rhi-lookup-list li { grid-template-columns: 1fr auto; } .rhi-lookup-list .src { grid-column: 1 / -1; } }
.rhi-steps { margin: 6px 0 12px; padding-left: 20px; display: grid; gap: 4px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.rhi-steps strong { color: var(--text); }
.rhi-find { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 4px 0 4px; }
.rhi-find .field { flex: 1 1 320px; max-width: 520px; }
.eq-block { display: grid; grid-template-columns: minmax(0, auto) minmax(220px, 1fr); gap: 12px 28px; align-items: center; margin: 10px 0 14px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.eq-math { display: grid; gap: 10px; justify-items: start; }
.eq-math math { margin: 0; font-size: 1.15em; color: var(--text); }
/* Single-letter symbols as plain letters in italics: the math-italic characters browsers use by default are missing from many fonts */
.eq-math mi.var { font-style: italic; }
.eq-legend { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; color: var(--muted); }
.eq-legend dt { font-weight: 600; color: var(--text); }
.eq-legend dd { margin: 0; }
@media (max-width: 760px) { .eq-block { grid-template-columns: 1fr; } }
.eq-block.eq-stack { grid-template-columns: 1fr; }
.eq-stack .eq-math { overflow-x: auto; max-width: 100%; }
/* MathML Core ignores columnalign; align the equation's lines with CSS */
.eq-stack mtd { text-align: left; padding: 1px 0; }
.eq-stack mtd:first-child { text-align: right; padding-right: 4px; }
.rhi-sort-bar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 4px 0 12px; }
.rhi-sort-bar .help { margin: 0; }
.gv-checks { border: 0; padding: 0; margin: 0; min-width: 0; }
.gv-checks legend { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: 4px; }
.gv-checks .check { display: flex; gap: 6px; align-items: center; font-size: 13px; margin: 2px 0; }
.gv-check { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 11px; background: rgba(237, 161, 0, 0.16); color: var(--text); }
.field.wide { flex: 1 1 100%; }
.gv-results { margin: 6px 0 10px; font-size: 14px; }
.ml-tree { overflow-x: auto; padding: 6px 0; }
.ml-tree svg { display: block; max-width: none; }
.mlm-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 360px); gap: 18px; align-items: start; }
.mlm-figure { margin: 0; }
.mlm-figure img { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.mlm-figure figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 760px) { .mlm-intro { grid-template-columns: 1fr; } }
.big-cup { display: flex; gap: 16px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.big-cup .cup figcaption { max-width: 150px; }
.big-cup > div { flex: 1; min-width: 0; }
.big-cup-title { margin: 0 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.big-cup-legend { list-style: none; margin: 0; padding: 0; }
.big-cup-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) 54px; align-items: start; grid-template-areas: "sw name share" ". bar value"; gap: 2px 8px; align-items: center; margin: 0 0 8px; font-size: 13px; }
.big-cup-legend .swatch { grid-area: sw; width: 12px; height: 12px; border-radius: 3px; }
.big-cup-legend .name { grid-area: name; font-weight: 600; line-height: 1.3; }
.big-cup-legend .share { grid-area: share; text-align: right; font-weight: 700; }
.big-cup-legend .bar { grid-area: bar; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.big-cup-legend .bar span { display: block; height: 100%; border-radius: 3px; }
.big-cup-legend .value { grid-area: value; text-align: right; font-size: 11px; color: var(--muted); }
.big-cup-total { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.cup-liquid.rise { animation: cup-rise 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes cup-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .cup-liquid.rise { animation: none; } }
.howto-demo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 2px; font-size: 13px; color: var(--muted); }
.howto-demo .btn { flex: none; }
.demo-row { display: flex; gap: 8px; align-items: flex-start; }
.demo-row .btn { flex: none; }
.template-link a { font-weight: 600; }
.report-style { margin: 10px 0 4px; }
.report-style summary { cursor: pointer; font-weight: 600; }
.rs-heading-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 6px; }
.rs-heading-row input[type="color"] { width: 40px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
.selection-note { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.selection-note:empty { display: none; }
.selection-note strong { color: var(--text); }
.selection-note.card-note { padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 12px; }
.selection-label { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-right: 4px; }
