/* Politeion — "civic academia" design system. Institutional navy + citation gold,
   ink on parchment. System serif display + system sans body. Zero external deps. */
:root {
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* dark — deep ink / oak, warm parchment text */
  --bg: #16130d;
  --bg-elev: #1e1a12;
  --bg-elev2s: #272218;
  --bg-elev3: #322b1f;
  --fg: #efe8d9;
  --fg-dim: #b8ab93;
  --fg-faint: #877c67;
  --border: #352e21;
  --border-strong: #4a4130;
  --gold: #cba43f;        /* citation gold / brass */
  --accent: #6f9bde;      /* lapis (brightened for dark) */
  --accent-2: var(--gold);
  --pos: #e0925f;         /* terracotta — positive pole */
  --neg: #6f9bde;         /* lapis — negative pole */
  --good: #7cc194;
  --warn: #d9b45c;
  --bad: #db786e;
  --ring: color-mix(in srgb, var(--accent) 60%, transparent);

  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;
  --fs-xs: 0.75rem; --fs-sm: 0.875rem; --fs-base: 1rem; --fs-md: 1.0625rem;
  --fs-lg: 1.4rem; --fs-xl: 1.9rem;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 6px 20px -6px rgba(0,0,0,.5);
  --shadow-3: 0 16px 44px -14px rgba(0,0,0,.62);
  --maxw: 1060px;
  --t-fast: 120ms; --t: 190ms; --ease: cubic-bezier(.36,.03,.2,1);
}
:root[data-theme="light"] {
  --bg: #f4efe4;          /* parchment */
  --bg-elev: #fffdf6;     /* paper */
  --bg-elev2s: #ece4d3;
  --bg-elev3: #e2d8c3;
  --fg: #211b12;          /* ink */
  --fg-dim: #5a5142;
  --fg-faint: #867b67;
  --border: #d9cdb6;
  --border-strong: #c2b493;
  --gold: #9a6b12;        /* citation gold (darker for parchment contrast) */
  --accent: #1e3a5f;      /* institutional navy */
  --accent-2: var(--gold);
  --pos: #a8502a;         /* terracotta */
  --neg: #1e3a5f;         /* navy */
  --good: #2f7d54;
  --warn: #8a5f10;
  --bad: #b23b34;
  --shadow-1: 0 1px 2px rgba(40,30,12,.08);
  --shadow-2: 0 6px 20px -8px rgba(40,30,12,.16);
  --shadow-3: 0 16px 40px -14px rgba(40,30,12,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: var(--fs-base);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--gold) 35%, transparent); }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); }
section { margin: var(--s6) 0; }

/* Serif display type for headings + wordmark (the "inscriptional" voice) */
h1, h2, h3, h4, .brand, .arch-name, .hero h1 { font-family: var(--serif); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: 0; font-weight: 600; }
section > h2 { font-size: var(--fs-xl); margin: 0 0 var(--s3); position: relative; padding-bottom: var(--s2); }
section > h2::after { content: ""; position: absolute; left: 0; bottom: 0; width: 2.4rem; height: 2px; background: var(--gold); }
.muted { color: var(--fg-dim); }
.mono, code { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--bg-elev2s); padding: 0.08em 0.36em; border-radius: 5px; }
.eyebrow { font-family: var(--font); text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.72rem; font-weight: 600; color: var(--gold); }

/* Sticky header with a brass hairline */
[data-shell] {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--gold) 60%, transparent);
}
.site-header { display: flex; align-items: center; gap: var(--s4); max-width: var(--maxw); margin: 0 auto; padding: var(--s3) var(--s4); flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 1.15rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg); }
.brand:hover { text-decoration: none; color: var(--accent); }
.site-nav { display: flex; gap: var(--s1); flex-wrap: wrap; margin-right: auto; }
.site-nav a { color: var(--fg-dim); padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); min-height: 40px; display: inline-flex; align-items: center; font-size: var(--fs-sm); font-weight: 500; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.site-nav a:hover { background: var(--bg-elev2s); color: var(--fg); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--gold); }
.theme-toggle { min-width: 40px; min-height: 40px; border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); font-size: 1.05rem; cursor: pointer; display: inline-grid; place-items: center; }

/* Buttons */
button, .btn {
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  min-height: 44px; padding: 0.55rem 1.05rem; line-height: 1.2;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--fg); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
button:hover, .btn:hover { border-color: var(--gold); background: var(--bg-elev2s); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: var(--shadow-1); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; box-shadow: var(--shadow-2); }
a.btn { text-decoration: none; }
.btn-row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }

/* Cards — oak/paper surfaces */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s5); margin: var(--s4) 0; box-shadow: var(--shadow-1); }
.card h3 { margin-top: 0; }

/* Landing */
.hero { text-align: center; padding: var(--s7) var(--s4) var(--s5); }
.hero .eyebrow { display: block; margin-bottom: var(--s3); }
.hero h1 { font-size: clamp(2.6rem, 8vw, 4rem); font-weight: 600; letter-spacing: 0.02em; margin: 0.2rem 0; line-height: 1.02; }
.hero p { color: var(--fg-dim); max-width: 50ch; margin: var(--s3) auto var(--s5); font-size: var(--fs-md); font-style: italic; }
.rule-orn { width: 5rem; height: 1px; margin: var(--s4) auto; background: var(--gold); position: relative; }
.rule-orn::before { content: "◆"; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background: var(--bg); color: var(--gold); font-size: 0.6rem; padding: 0 0.4rem; }
.feature-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.feature-grid .card { margin: 0; transition: transform var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.feature-grid .card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow-2); }
.feature-grid .card h3 { font-size: var(--fs-md); }
.toggle-line { display: flex; align-items: center; gap: var(--s3); justify-content: center; margin: var(--s4) 0; }
.picker-label { font-family: var(--font); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-faint); margin: var(--s4) 0 0.3rem; }

/* segmented pickers (answer style / length) */
.mode-picker { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; margin: var(--s3) 0 var(--s4); }
.mode-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; min-width: 210px; text-align: left; padding: var(--s3) var(--s4); border-radius: var(--radius); }
.mode-opt b { font-family: var(--serif); font-size: var(--fs-md); font-weight: 600; }
.mode-opt span { font-size: var(--fs-xs); color: var(--fg-dim); }
.mode-opt.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg-elev)); box-shadow: inset 0 0 0 1px var(--accent); }

/* Test */
.test-stage { max-width: 640px; margin: var(--s6) auto; }
.progress { color: var(--fg-dim); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 500; letter-spacing: 0.02em; }
.progress-bar { height: 8px; background: var(--bg-elev3); box-shadow: inset 0 0 0 1px var(--border); border-radius: var(--radius-pill); overflow: hidden; margin: var(--s2) 0 var(--s5); }
.progress-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width var(--t) var(--ease); }
.q-text { font-family: var(--serif); font-size: clamp(1.4rem, 3.8vw, 1.85rem); font-weight: 500; line-height: 1.32; margin: var(--s4) 0 var(--s5); min-height: 2.8em; text-wrap: balance; }
.answers { display: grid; gap: var(--s2); }
.answers button { width: 100%; text-align: left; justify-content: space-between; font-weight: 500; padding: 0.78rem 1rem; }
.answers button .k { color: var(--fg-faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.answers button.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, var(--bg-elev)); box-shadow: inset 0 0 0 1px var(--accent); }
.test-nav { display: flex; justify-content: space-between; margin-top: var(--s5); }

/* Precision slider */
.slider-wrap { position: relative; padding: 2.4rem 0 0.5rem; }
.slider-readout { position: absolute; top: 0; left: 50%; transform: translateX(-50%); background: var(--bg-elev2s); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.25rem 0.65rem; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-1); transition: left 60ms linear; }
.slider-readout::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 9px; height: 9px; background: var(--bg-elev2s); border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); transform: translateX(-50%) rotate(45deg); }
.slider-readout b { color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="range"].slider { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--neg), var(--bg-elev3) 45%, var(--bg-elev3) 55%, var(--pos)); outline: none; margin: 0.4rem 0; }
input[type="range"].slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); border: 4px solid var(--bg); cursor: grab; box-shadow: var(--shadow-2), 0 0 0 1px var(--gold); transition: transform var(--t-fast) var(--ease); }
input[type="range"].slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }
input[type="range"].slider::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 4px solid var(--bg); cursor: grab; box-shadow: var(--shadow-2); }
input[type="range"].slider:focus-visible { box-shadow: 0 0 0 4px var(--ring); }
.slider-ends { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--fg-dim); margin-top: 0.3rem; font-weight: 500; }
.slider-ticks { position: relative; height: 1.5rem; margin-top: 0.3rem; }
.slider-ticks span { position: absolute; transform: translateX(-50%); font-size: 0.66rem; color: var(--fg-faint); white-space: nowrap; }
.slider-ticks span:first-child { transform: none; }
.slider-ticks span:last-child { transform: translateX(-100%); }
.slider-controls { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s4); }
.slider-controls #sl-num { width: 84px; min-height: 44px; padding: 0.4rem 0.55rem; background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.slider-controls #next-btn { margin-left: auto; }

/* Bar readout */
.bar-readout { display: grid; gap: var(--s3); }
.bar-row { border-bottom: 1px solid var(--border); padding-bottom: var(--s2); }
.bar-row:last-child { border-bottom: none; }
.bar-head { display: flex; align-items: baseline; gap: var(--s2); }
.bar-axis { font-weight: 600; font-size: var(--fs-sm); }
.bar-count { color: var(--fg-dim); font-size: var(--fs-xs); margin-left: auto; font-variant-numeric: tabular-nums; }
.bar-score { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.5ch; text-align: right; }
.bar-score.pos { color: var(--pos); } .bar-score.neg { color: var(--neg); }
.bar-track { display: grid; grid-template-columns: minmax(70px,1fr) 3fr minmax(70px,1fr); align-items: center; gap: var(--s2); margin-top: var(--s1); }
.bar-track .pole { font-size: var(--fs-xs); color: var(--fg-faint); }
.bar-track .pole.pos { text-align: right; }
.bar-svg { width: 100%; height: 12px; background: var(--bg-elev3); box-shadow: inset 0 0 0 1px var(--border); border-radius: var(--radius-pill); }
.bar-mid { stroke: var(--border-strong); stroke-width: 0.6; }
.bar-fill.pos { fill: var(--pos); } .bar-fill.neg { fill: var(--neg); }
.ci-line, .ci-cap { stroke: var(--fg); stroke-width: 1.2; opacity: 0.6; }
.bar-row.uncertain .bar-fill { opacity: 0.45; }
.bar-row.awaiting { opacity: 0.45; }
.bar-score.leans { font-weight: 600; font-size: var(--fs-xs); color: var(--fg-dim); }
.bar-score.leans .muted { font-weight: 400; }

/* Charts gallery */
.chart-gallery { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.chart-card { margin: 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); box-shadow: var(--shadow-1); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.chart-card:hover { border-color: var(--gold); box-shadow: var(--shadow-2); }
.chart-card figcaption { text-align: center; color: var(--fg-dim); font-size: var(--fs-sm); font-weight: 500; margin-top: var(--s2); font-family: var(--serif); font-style: italic; }
.quad-chart { width: 100%; height: auto; display: block; }
.quad-bg { fill: var(--bg-elev); }
.quad-frame { fill: none; stroke: var(--border-strong); stroke-width: 1; }
.quad-axis { stroke: var(--border-strong); stroke-width: 1; }
.quad.q-tr { fill: color-mix(in srgb, var(--pos) 12%, transparent); }
.quad.q-tl { fill: color-mix(in srgb, var(--neg) 12%, transparent); }
.quad.q-br { fill: color-mix(in srgb, var(--gold) 10%, transparent); }
.quad.q-bl { fill: color-mix(in srgb, var(--good) 9%, transparent); }
.you-dot { fill: var(--accent); }
.you-halo { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.55; }
.arch-dot { fill: var(--fg-dim); opacity: 0.5; }
.cloud-dot { fill: var(--accent); opacity: 0.2; }
.fig-dot { fill: var(--pos); stroke: var(--bg); stroke-width: 0.8; }
.fig-lbl { fill: var(--fg); font-size: 10px; font-weight: 600; }
.pole-lbl { fill: var(--fg-dim); font-size: 11px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
.axis-name { fill: var(--fg); font-size: 11px; font-weight: 700; }
.dot { cursor: pointer; }
.fig-lbl, .pole-lbl, .you-halo, .axl-arch, .axl-you-lbl, .axl-pole { pointer-events: none; }

/* zoomable charts + expand affordance */
.chart-card.zoomable { position: relative; }
.chart-card.zoomable svg.quad-chart { cursor: zoom-in; }
.chart-expand { position: absolute; top: 8px; right: 8px; min-height: 0; width: 30px; height: 30px; padding: 0; font-size: 1rem; border-radius: var(--radius-sm); opacity: 0; background: var(--bg-elev2s); }
.chart-card.zoomable:hover .chart-expand, .chart-expand:focus-visible { opacity: 1; }
@media (hover: none) { .chart-expand { opacity: 0.85; } }

/* chart tooltip */
.chart-tip { position: fixed; z-index: 400; pointer-events: none; background: var(--bg-elev2s); border: 1px solid var(--gold); color: var(--fg); padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); font-size: var(--fs-xs); box-shadow: var(--shadow-2); opacity: 0; transition: opacity 90ms var(--ease); max-width: 240px; }
.chart-tip.show { opacity: 1; }
.chart-tip b { font-family: var(--serif); display: block; }
.chart-tip span { color: var(--fg-dim); font-variant-numeric: tabular-nums; }

/* fullscreen chart lightbox */
.chart-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: color-mix(in srgb, #000 55%, transparent); backdrop-filter: blur(3px); padding: var(--s4); }
.chart-modal-inner { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); max-width: 96vw; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.chart-modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); font-family: var(--serif); font-size: var(--fs-md); }
.chart-modal-close { min-height: 0; width: 34px; height: 34px; padding: 0; }
.chart-modal-body { padding: var(--s4); overflow: auto; display: grid; place-items: center; }
.chart-modal-body svg { max-width: 100%; height: auto; }
.chart-modal-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); text-align: right; }
@media (max-width: 560px) { .chart-modal { padding: 0; } .chart-modal-inner { max-width: 100vw; max-height: 100vh; height: 100vh; width: 100vw; border-radius: 0; } }

/* Single-axis number line */
.axis-line { width: 100%; height: auto; display: block; }
.axl-axis { stroke: var(--border-strong); stroke-width: 1.5; }
.axl-zero { stroke: var(--fg-faint); stroke-width: 1; }
.axl-tick { stroke: var(--fg-dim); stroke-width: 1.5; opacity: 0.7; }
.axl-arch { fill: var(--fg-dim); font-size: 8.5px; text-anchor: middle; }
.axl-you { stroke: var(--accent); stroke-width: 2.5; }
.axl-you-dot { fill: var(--accent); }
.axl-you-lbl { fill: var(--accent); font-size: 10px; font-weight: 700; text-anchor: middle; }
.axl-pole { fill: var(--fg-faint); font-size: 10px; }
.axl-pole.neg { text-anchor: start; } .axl-pole.pos { text-anchor: end; }

/* Pickers / selects */
.picker { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
select {
  font-family: inherit; font-size: var(--fs-sm); min-height: 44px; padding: 0.4rem 2rem 0.4rem 0.7rem;
  background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-dim) 50%), linear-gradient(135deg, var(--fg-dim) 50%, transparent 50%);
  background-position: right 0.95rem center, right 0.65rem center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
select:hover { border-color: var(--gold); }

/* Archetype panel */
.arch-top { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.arch-name { font-size: var(--fs-lg); font-weight: 600; }
.tier { font-size: var(--fs-xs); font-weight: 600; padding: 0.15rem 0.55rem; border-radius: var(--radius-pill); border: 1px solid var(--border); font-family: var(--font); }
.tier.Strong { color: var(--good); border-color: color-mix(in srgb, var(--good) 60%, transparent); background: color-mix(in srgb, var(--good) 12%, transparent); }
.tier.Moderate { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tier.Weak { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.tier.None { color: var(--fg-dim); }
.arch-list { list-style: none; padding: 0; margin: var(--s2) 0; display: grid; gap: 0; }
.arch-list li { display: flex; justify-content: space-between; gap: var(--s4); padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.arch-list li:last-child { border-bottom: none; }
.sim { font-variant-numeric: tabular-nums; color: var(--fg-dim); font-weight: 600; white-space: nowrap; }

/* Data table */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
table.data { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
table.data th, table.data td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: center; }
table.data th { position: sticky; top: 0; background: var(--bg-elev2s); cursor: pointer; user-select: none; font-weight: 600; z-index: 1; box-shadow: inset 0 -1px 0 var(--border-strong); }
table.data th:hover { color: var(--accent); }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-elev2s) 45%, transparent); }
table.data tbody tr:hover { background: var(--bg-elev2s); }
table.data th.sorted-asc::after { content: " ▲"; font-size: 0.7em; } table.data th.sorted-desc::after { content: " ▼"; font-size: 0.7em; }
table.data td.q { text-align: left; white-space: normal; min-width: 260px; }
table.data td, table.data th { font-variant-numeric: tabular-nums; }
table.data td.w-pos { color: var(--pos); font-weight: 700; }
table.data td.w-neg { color: var(--neg); font-weight: 700; }
.validation-errors { border-color: var(--bad); }
.validation-errors summary { color: var(--bad); font-weight: 600; }
.validation-warnings summary { color: var(--warn); font-weight: 600; }
details.card summary { cursor: pointer; }

/* Summary grid */
.summary-grid { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.summary-cell { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s3); font-size: var(--fs-xs); }
.summary-cell b { display: block; font-size: var(--fs-sm); margin-bottom: 0.15rem; }
.summary-cell div { font-variant-numeric: tabular-nums; }
.flag { color: var(--bad); font-weight: 600; }

/* inline tags */
.tag { font-size: 0.68rem; font-weight: 600; padding: 0.06rem 0.42rem; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); margin-left: 0.3rem; white-space: nowrap; }
.tag.approx { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }

/* validity banners */
.banner-bad, .banner-warn, .banner-ok, .banner-info { border-left-width: 4px; }
.banner-bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg-elev)); }
.banner-warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--bg-elev)); }
.banner-ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--bg-elev)); }
.banner-info { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }

/* 3D */
#three-mount { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); position: relative; overflow: hidden; box-shadow: var(--shadow-1); }
.legend { display: grid; gap: 0.15rem; max-height: 40vh; overflow-y: auto; }
.legend label { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); padding: 0.15rem 0; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.controls-3d { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; margin: var(--s3) 0; }
.controls-3d label { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-sm); }

/* Toast */
.toast { position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%) translateY(8px); background: var(--bg-elev2s); border: 1px solid var(--gold); color: var(--fg); padding: 0.65rem 1.1rem; border-radius: var(--radius); font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-3); opacity: 0; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .wrap { padding: var(--s4) var(--s3) var(--s6); }
  .site-nav a { padding: 0.5rem 0.6rem; }
  .mode-opt { min-width: 0; flex: 1 1 45%; }
  section > h2 { font-size: var(--fs-lg); }
  .fig-lbl, .axl-arch { display: none; }
  .pole-lbl { font-size: 10px; }
}

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

/* ===== Analyzer ========================================================== */
.section-h { font-family: var(--serif); font-size: var(--fs-lg); margin: 1.4rem 0 .6rem; }
.analyze-card { display: flex; flex-direction: column; gap: .9rem; }
.fld { display: flex; flex-direction: column; gap: .35rem; font-size: var(--fs-sm); color: var(--fg-dim); }
.fld > span { font-weight: 600; color: var(--fg); }
.fld input, .fld textarea {
  width: 100%; box-sizing: border-box; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: .6rem .7rem; font: inherit; font-size: var(--fs-base);
}
.fld textarea { resize: vertical; font-family: var(--font); line-height: 1.5; }
.fld input:focus, .fld textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.fld-note { font-size: var(--fs-xs); margin: 0; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 560px) { .fld-row { grid-template-columns: 1fr; } }
.status, #status.err { color: var(--bad); }
#status.ok { color: var(--good); }
.stats-line { font-size: var(--fs-sm); font-family: var(--mono); line-height: 1.6; }

.disclaimer {
  font-size: var(--fs-sm); color: var(--fg-dim); border-left: 3px solid var(--gold);
  padding: .5rem .8rem; margin: 1rem 0; background: color-mix(in srgb, var(--gold) 8%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.disclaimer a { color: var(--gold); }

.analysis-head h1 { font-family: var(--serif); font-size: var(--fs-xl); margin: .5rem 0 .3rem; line-height: 1.15; }
.analysis-meta { font-size: var(--fs-sm); color: var(--fg-dim); margin: .2rem 0 .5rem; }
.analysis-meta a { color: var(--accent); }
.src-url { word-break: break-all; }
.analysis-summary { font-family: var(--serif); font-size: var(--fs-md); color: var(--fg); margin: .4rem 0; }

.genre-chip {
  display: inline-block; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: .18rem .5rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); color: var(--fg-dim); background: var(--bg);
}
.genre-chip.sm { font-size: .68rem; padding: .1rem .4rem; }
.genre-chip.genre-opinion { color: var(--pos); border-color: var(--pos); }
.genre-chip.genre-report  { color: var(--good); border-color: var(--good); }
.genre-chip.genre-analysis{ color: var(--accent); border-color: var(--accent); }
.genre-chip.genre-mixed   { color: var(--warn); border-color: var(--warn); }
.genre-chip.caution { color: var(--bad); border-color: var(--bad); }

.notice { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .7rem .9rem; margin: .8rem 0; font-size: var(--fs-sm); }
.notice-alert { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.notice-warn  { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.notice-ok    { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }

.ax-list { display: flex; flex-direction: column; gap: 1.1rem; margin: 1rem 0; }
.axrow-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.axrow-name { font-weight: 700; }
.axrow-pole { font-size: var(--fs-sm); }
.axrow-pole.pos { color: var(--pos); } .axrow-pole.neg { color: var(--neg); }
.axrow-score { font-family: var(--mono); font-weight: 700; margin-left: auto; }
.axrow-score.pos { color: var(--pos); } .axrow-score.neg { color: var(--neg); }
.axrow-conf { font-size: var(--fs-xs); }
.axrow-ev { font-family: var(--serif); font-style: italic; color: var(--fg-dim); margin: .4rem 0 0; padding-left: .8rem; border-left: 2px solid var(--gold); }

.quad-figure { margin: 1.1rem auto; max-width: 290px; }
.quad-row { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; margin: 1rem 0 1.2rem; }
.quad-mini { flex: 0 1 190px; max-width: 210px; margin: 0; }
.quad-mini figcaption, .quad-mini .chart-title { font-size: var(--fs-xs); }
.neutral-summary { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); padding: .8rem 1rem; margin: 1rem 0; }
.neutral-summary .ns-h { font-family: var(--serif); font-size: var(--fs-md); margin: 0 0 .4rem; }
.neutral-summary p { margin: .3rem 0; }
.neutral-summary .ns-note { font-size: var(--fs-xs); }
.rubric-stamp { font-family: var(--mono); font-size: var(--fs-xs); margin-top: 1.4rem; }

.article-list { display: flex; flex-direction: column; gap: .45rem; }
.article-card { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); text-decoration: none; color: var(--fg); }
.article-card:hover { border-color: var(--accent); }
.article-card-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rubric-pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.5; max-height: 460px; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; margin-top: .6rem; }

/* ===== Left–right barline ================================================ */
.lr { margin: 1.1rem 0 1.4rem; }
.lr-caption { font-size: var(--fs-sm); margin-bottom: .45rem; }
.lr-caption .lr-num { font-family: var(--mono); font-weight: 700; }
.lr-track {
  position: relative; height: 12px; border-radius: var(--radius-pill);
  background: linear-gradient(to right, #3b6fb0 0%, #8aa0b4 42%, #cbb9a0 50%, #c98a72 58%, #c0392b 100%);
  border: 1px solid var(--border-strong);
}
.lr-marker {
  position: absolute; top: 50%; width: 3px; height: 22px; transform: translate(-50%, -50%);
  background: var(--fg); border: 1px solid var(--bg); border-radius: 2px;
  box-shadow: 0 0 0 1px var(--fg);
}
.lr-scale { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--fg-dim); margin-top: .35rem; }
.lr-scale span:nth-child(2) { color: var(--fg-faint); }

/* ===== Methodology summary (rendered markdown) =========================== */
.md-body { margin-top: .6rem; }
.md-body h2 { font-family: var(--serif); font-size: var(--fs-lg); margin: 1.1rem 0 .5rem; }
.md-body h3, .md-body h4 { font-family: var(--serif); font-size: var(--fs-md); margin: .9rem 0 .4rem; }
.md-body p { margin: .5rem 0; }
.md-body ul { margin: .5rem 0 .5rem 1.1rem; }
.md-body li { margin: .25rem 0; }
.md-body code { font-family: var(--mono); font-size: .9em; background: var(--bg); padding: .05rem .3rem; border-radius: var(--radius-sm); }
.md-table { border-collapse: collapse; width: 100%; margin: .6rem 0; font-size: var(--fs-sm); }
.md-table th, .md-table td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; vertical-align: top; }
.md-table th { background: var(--bg); font-weight: 700; }

/* Compact left↔right indicator in list rows (right of an article title) */
.lr-mini {
  position: relative; flex: 0 0 auto; width: 72px; height: 8px; margin-left: auto;
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: linear-gradient(to right, #3b6fb0 0%, #8aa0b4 42%, #cbb9a0 50%, #c98a72 58%, #c0392b 100%);
}
.lr-mini-marker {
  position: absolute; top: 50%; width: 2px; height: 14px; transform: translate(-50%, -50%);
  background: var(--fg); border: 1px solid var(--bg); border-radius: 1px;
}

/* Recent-analyses list: show ~5 rows, scroll for the rest (page stays short) */
.recent-scroll {
  max-height: 17.5rem; overflow-y: auto; padding-right: .3rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem;
}
.recent-scroll .article-card { background: var(--bg); }
