:root {
  /* dashboards and charts: neutral greys (slides override below) */
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-muted: #52514e;
  --border: #e1e0d9;
  --accent: #0b0b0b; /* neutral: blue is reserved for priority tiers */
}

* { box-sizing: border-box; }
input { accent-color: #52514e; }

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h1 { font-size: 18px; margin: 0; }

.toggle { display: flex; gap: 4px; }

.toggle button {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.toggle button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main { padding: 20px; }

.placeholder { color: var(--text-muted); }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  line-height: 1.4;
}

.tooltip .muted { color: var(--text-muted); }

/* ---- View 1 ---- */
.v1-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 4px; }
.panel .sub { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; }

#pipeline { width: 100%; height: auto; display: block; }
#pipeline .col-label { font-size: 12px; fill: var(--text-muted); font-weight: 600; }
#pipeline .node rect { stroke: none; }
#pipeline .node text { font-size: 12px; fill: var(--text); pointer-events: none; }
#pipeline .node .w { fill: var(--text-muted); font-size: 11px; }
#pipeline .link { fill: none; stroke-opacity: 0.35; }
#pipeline .dim { opacity: 0.12; }

#steps ol { padding-left: 20px; margin: 8px 0; font-size: 13px; line-height: 1.45; columns: 3 280px; column-gap: 28px; }
#steps li { break-inside: avoid; }
#steps li { margin-bottom: 8px; padding: 2px 4px; border-radius: 4px; }
#steps li.active { background: #f0efec; }
#steps code { font-size: 12px; }
#steps .note { font-size: 13px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 8px; }

#pipeline .tier-label { font-size: 12px; fill: var(--text); }
#pipeline .tier-axis text { font-size: 11px; fill: var(--text-muted); }
#pipeline .tier-axis line { stroke: var(--text-muted); }
#pipeline .tier-link { stroke-width: 3; stroke-opacity: 0.6; }
#pipeline .tier-marker line { stroke: var(--text); stroke-width: 3; }
#pipeline .tier-marker line.leader { stroke-width: 1; stroke-dasharray: 2 2; }
#pipeline .marker-label { font-size: 12px; font-weight: 600; fill: var(--text); }

/* What-if panel spans both grid columns */
#whatif { grid-column: 1 / -1; }
.wi-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.wi-load { font-size: 13px; color: var(--text-muted); }
.wi-load select { font: inherit; margin-left: 6px; padding: 3px 6px; max-width: 220px; }
.wi-result { font-size: 15px; margin: 8px 0 2px; }
#whatif-published { margin: 0 0 10px; min-height: 1em; }
#whatif-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px 16px;
}
.wi-row { border-left: 4px solid; padding: 2px 0 2px 8px; }
.wi-row label { display: block; font-size: 12px; color: var(--text-muted); }
.wi-ctl { display: flex; align-items: flex-start; gap: 8px; }
.wi-track { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wi-range { width: 100%; margin: 0; }
/* Inset by half the slider thumb so the histogram's 0 and max line up with the slider's. */
.wi-hist { width: calc(100% - 16px); margin: 0 8px; height: 30px; display: block; }
.wi-hist .wi-median { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.wi-hist .wi-marker { stroke-width: 3; vector-effect: non-scaling-stroke; }
.wi-numwrap { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text-muted); }
.wi-num { width: 62px; font: inherit; font-size: 13px; padding: 2px 4px; }
.wi-context { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- View 2 ---- */
.v2-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
}
.v2-grid .detail { grid-column: 1 / -1; }
@media (max-width: 900px) { .v2-grid { grid-template-columns: 1fr; } }

.v2-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.v2-controls .hint { color: var(--text-muted); font-size: 12px; }

#scatter, #heatmap { width: 100%; height: auto; display: block; }
.axis text { font-size: 11px; fill: var(--text-muted); }
.axis line, .axis path { stroke: var(--border); }
.axis-title { font-size: 12px; fill: var(--text-muted); }

.dot { stroke: var(--surface); stroke-width: 0.8; cursor: pointer; }
.dot.dim { opacity: 0.12; }
.dot.picked { stroke: var(--text); stroke-width: 2.5; }
.centre-label { font-size: 13px; font-weight: 700; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; pointer-events: none; }
.lasso { fill: rgba(11, 11, 11, 0.05); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }

.cell, .hm-label { cursor: pointer; }
.cell text { font-size: 13px; pointer-events: none; font-variant-numeric: tabular-nums; }
.cell text.hm-total { font-size: 10px; }
.cell rect.hm-hit { stroke: var(--text); stroke-width: 2.5; }
.hm-label { font-size: 12px; fill: var(--text); }
.hm-label:hover { text-decoration: underline; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.swatch.dotswatch { border-radius: 50%; }
.swatch.tick { width: 3px; height: 12px; }

.detail h2 { font-size: 16px; }
.detail h3 { font-size: 13px; margin: 0 0 6px; }
.facts { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.facts > div { display: flex; flex-direction: column; font-size: 13px; }
.facts .k { color: var(--text-muted); font-size: 12px; }
.facts .v { font-size: 16px; font-weight: 600; }
.btn { font: inherit; font-size: 13px; padding: 6px 12px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 6px; cursor: pointer; }
.btn:hover { background: #f0efec; }
.detail-row { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; }
.detail-profile .bg-hists { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
@media (max-width: 900px) { .detail-row { grid-template-columns: 1fr; } }
.split { margin-bottom: 14px; }
.split-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; }
.split-bar { background: #f0efec; border-radius: 3px; height: 12px; overflow: hidden; }
.split-bar > span { display: block; height: 100%; border-radius: 3px; }
.split-n { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---- View 2 pipeline controls ---- */
#ml-controls { grid-column: 1 / -1; }
.mlc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mlc-presets { display: flex; gap: 8px; }
.mlc-grid { display: grid; grid-template-columns: minmax(0, 3fr) repeat(3, minmax(160px, 1fr)); gap: 20px; margin-top: 10px; }
@media (max-width: 1000px) { .mlc-grid { grid-template-columns: 1fr 1fr; } }
.mlc-group h3 { font-size: 13px; margin: 0 0 6px; }
.mlc-group > label { display: block; font-size: 13px; margin: 3px 0; }
.mlc-group select { font: inherit; font-size: 13px; padding: 3px 6px; width: 100%; }
.mlc-group input[type="range"] { width: 100%; }
#ml-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 10px; }
.var-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; border-left: 3px solid; padding-left: 6px; cursor: pointer; }
.linkbtn { font: inherit; font-size: 12px; font-weight: 400; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0 0 0 6px; }
.mlc-msg { font-size: 12px; color: #d03b3b; margin: 6px 0 0; min-height: 1em; opacity: 0; transition: opacity 0.2s; }
.mlc-msg.show { opacity: 1; }

/* Instance detail: indicator histograms (same style as the what-if panel) */
.bg-hists { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 20px; margin-top: 6px; }
.bg-hist-label { font-size: 12px; color: var(--text); margin-bottom: 2px; }
.bg-hist svg { width: 100%; height: 34px; display: block; }
.bg-hist line { vector-effect: non-scaling-stroke; }
.bg-hist .m-self { stroke-width: 3; }
.bg-hist .m-cluster { stroke-width: 3; }
.bg-hist .m-median { stroke-width: 1; stroke-dasharray: 2 2; }
.bg-hist-context { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bg-hist.unused { opacity: 0.55; }
.swatch.tick.dashed { background: none !important; border-left: 2px dashed #52514e; width: 0; }

/* TEPI card at the end of the pipeline */
#pipeline .tepi-card { stroke: rgba(11, 11, 11, 0.15); stroke-width: 1; }
#pipeline .node text.tepi-title { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
#pipeline .node text.tepi-score { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
#pipeline .node text.tepi-tier { font-size: 12px; font-weight: 600; }
#pipeline .node text.tepi-note { font-size: 10px; opacity: 0.8; }

/* ---- Map page ---- */
.map-controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; font-size: 13px; margin-bottom: 16px; padding: 10px 16px; }
.ctl { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.ctl select { font: inherit; font-size: 13px; padding: 3px 6px; color: var(--text); }
.ctl label { color: var(--text); display: inline-flex; align-items: center; gap: 3px; }
.ctl.disabled { opacity: 0.4; }
#map-year { width: 110px; }
#map-year-out { font-variant-numeric: tabular-nums; color: var(--text); min-width: 3ch; }
.tools { gap: 4px; }
.tool { font: inherit; font-size: 13px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.tool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .map-grid { grid-template-columns: 1fr; } }
#map { width: 100%; display: block; cursor: grab; touch-action: none; }
#map.lasso-mode { cursor: crosshair; }
#map .map-bg { fill: var(--surface); }
#map .bg { stroke: var(--surface); stroke-width: 0.6; vector-effect: non-scaling-stroke; cursor: pointer; }
#map .bg.dim { opacity: 0.18; }
#map .bg.pickA { stroke: #e8710a; stroke-width: 2.5; opacity: 1; }
#map .bg.pickB { stroke: #1f1f1f; stroke-width: 2.5; stroke-dasharray: 4 2; opacity: 1; }
#map .bg:hover { stroke: var(--text); stroke-width: 1.2; }
#map-legend { margin-top: 8px; }
.legend-title { color: var(--text); font-weight: 600; }
.ramp { display: inline-block; width: 120px; height: 10px; border-radius: 2px; vertical-align: -1px; margin: 0 4px; }

#map-panel h2 { font-size: 16px; }
#map-panel .facts { gap: 18px; }
#map-panel h3 { font-size: 13px; margin: 14px 0 4px; border-top: 1px solid var(--border); padding-top: 10px; }
#map-panel .split-row { grid-template-columns: 100px 1fr 40px; }
.spark { width: 100%; max-width: 360px; display: block; margin-bottom: 8px; }
.spark-band { fill: #1b7f3b; fill-opacity: 0.15; }
.spark-line { fill: none; stroke: #1b7f3b; stroke-width: 2; }
.spark-dot { fill: #1b7f3b; stroke: var(--surface); stroke-width: 2; }
.spark-med { fill: none; stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

/* ---- Time curve ---- */
#tc { width: 100%; display: block; }
#tc .tc-frame { fill: none; stroke: var(--border); }
#tc .tc-seg { fill: none; stroke-width: 2.5; stroke-linecap: round; }
#tc .tc-seg-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: help; }
#tc .tc-seg-hit:hover { stroke: rgba(11, 11, 11, 0.08); }
#tc .tc-pt { stroke-width: 1.5; cursor: pointer; }
#tc .tc-pt:hover, #tc .tc-pt.picked { stroke-width: 3.5; }
#tc .tc-year { font-size: 11px; fill: var(--text-muted); text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; pointer-events: none; }
#tc .tc-label { font-size: 12px; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; pointer-events: none; }
#tc-curve-key svg { vertical-align: 0; margin-right: 4px; }
.tc-breakdown h3 { font-size: 13px; margin: 10px 0 4px; }
.tc-breakdown .split-row { grid-template-columns: 170px 1fr 40px; }
.tc-model { margin-top: 8px; font-size: 13px; }
.tc-model summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.tc-ctl { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 6px; }
.tc-ctl .sub { margin: 0; }
#tc-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 3px 10px; }
#tc-vars .var-chip { border-left: none; padding-left: 0; }
.pin-g { cursor: help; }
.pin-g:hover .legend-break { flex-basis: 100%; height: 0; }
.pin { fill: #fff; stroke: #0b0b0b; stroke-opacity: 0.35; stroke-width: 1; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.35)); }
.pin-g:hover .pin { stroke-opacity: 1; stroke-width: 1.5; }
.pin-emoji { font-size: 13px; text-anchor: middle; pointer-events: none; }
.bivar-legend { display: inline-grid; grid-template-columns: auto 54px; grid-template-rows: 54px auto; gap: 2px 4px; align-items: center; margin-right: 8px; }
.bivar-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; width: 54px; height: 54px; grid-column: 2; grid-row: 1; }
.bivar-y { grid-column: 1; grid-row: 1; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; text-align: center; }
.bivar-x { grid-column: 1 / -1; grid-row: 2; font-size: 11px; white-space: nowrap; text-align: right; }
.bivar-note { flex: 1 1 280px; display: inline; line-height: 1.5; }
[hidden] { display: none !important; }
.grp-btn.grp-a[aria-pressed="true"] { background: #e8710a; border-color: #e8710a; }
.grp-btn.grp-b[aria-pressed="true"] { background: #1f1f1f; border-color: #1f1f1f; }
.grp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.grp-col h3 { display: flex; align-items: center; gap: 6px; }
.grp-col .split-row { grid-template-columns: 90px 1fr 28px; }
.grp-col .facts { gap: 14px; }
.grp-key { display: inline-block; width: 16px; height: 0; border-top: 3px solid; }
#map-panel h4 { font-size: 12px; margin: 8px 0 4px; color: var(--text-muted); font-weight: 600; }
.tc-break-row { grid-template-columns: 150px 1fr 120px !important; }
.tc-break-row .split-n { font-size: 11px; }

/* ---- Similarity view ---- */
#dr { width: 100%; display: block; touch-action: none; cursor: crosshair; }
#dr .dr-frame { fill: transparent; stroke: var(--border); }
#dr .dr-pt { stroke: var(--surface); stroke-width: 0.6; cursor: pointer; vector-effect: non-scaling-stroke; }
#dr .dr-pt.dim { opacity: 0.2; }
#dr .dr-pt.pickA { stroke: #e8710a; stroke-width: 2.2; }
#dr .dr-pt.pickB { stroke: #1f1f1f; stroke-width: 2.2; stroke-dasharray: 2 1.5; }
#dr .dr-pt.hl, #dr .dr-pt:hover { stroke: var(--text); stroke-width: 2.5; opacity: 1; }
#dr .axis-title { font-size: 11px; }
.dr-status { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
#dr-perplexity, #dr-iterations, #dr-neighbors, #dr-mindist { width: 90px; }
#map .bg.hl { stroke: var(--text); stroke-width: 2.5; }

/* ==== One-screen dashboard layout (map | time curves over similarity | side) ==== */
#mapview .map-controls { margin-bottom: 10px; padding: 8px 14px; gap: 8px 18px; }
#mapview .map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px;
  height: calc(100vh - 150px);
  min-height: 620px;
  align-items: stretch;
}
#mapview .mid-col { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#mapview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#mapview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; height: auto; }
#mapview .side-col { overflow-y: auto; min-height: 0; padding: 10px 12px; }
.vhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.vhead h2 { font-size: 14px; margin: 0; }
.vhead-ctl { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.vhead-ctl select { font: inherit; font-size: 12px; padding: 2px 4px; }
.vhead-ctl .ctl { font-size: 12px; }
.vhead-ctl.seg label { display: inline-flex; gap: 3px; align-items: center; color: var(--text); }
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); font-size: 11px; color: var(--text-muted); cursor: help; }
#mapview .legend { margin-top: 4px; font-size: 11px; gap: 4px 10px; }
#dr-perplexity, #dr-iterations, #dr-neighbors, #dr-mindist { width: 56px; }
.vhead-ctl .ctl { gap: 3px; }
#tc-legend .legend-item svg { vertical-align: 0; }

/* group chips in the control bar */
.grp-chip { display: inline-flex; }
.grp-chip .grp-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.grp-chip .grp-clear { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; padding: 4px 7px; color: var(--text-muted); }
.grp-n { font-variant-numeric: tabular-nums; opacity: 0.85; }

/* model drawer: a dropdown over the view */
.model-drawer { position: relative; }
.model-drawer summary { cursor: pointer; list-style: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; background: var(--surface); }
.model-drawer summary::-webkit-details-marker { display: none; }
.model-drawer[open] summary { background: var(--accent); color: #fff; border-color: var(--accent); }
.drawer-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 460px; max-width: 80vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); font-size: 12px; }
.drawer-body #tc-vars { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* side column: comparison table, what changed, income trend */
#side h3 { font-size: 13px; margin: 12px 0 4px; }
#side h3:first-child { margin-top: 0; }
.cmp { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 3px 4px; text-align: right; border-bottom: 1px solid var(--border); }
.cmp th:first-child, .cmp td:first-child { text-align: left; color: var(--text-muted); font-weight: 400; }
.cmp thead th { font-weight: 600; color: var(--text); }
.cmp .key { display: inline-block; width: 12px; height: 0; border-top: 3px solid; vertical-align: 3px; margin-right: 3px; }
#side .tc-break-row { grid-template-columns: 105px 1fr 92px !important; font-size: 11px; }
#side .spark { max-width: none; }

/* lighter dimming so unselected areas stay readable */
#map .bg.dim { opacity: 0.45; }
#dr .dr-pt.dim { opacity: 0.35; }

/* narrower screens: stack, with fixed view heights */
@media (max-width: 1100px) {
  #mapview .map-grid { grid-template-columns: 1fr; height: auto; }
  #mapview .mid-col { grid-template-rows: auto auto; }
  #mapview .view-panel svg { flex: none; }
  #map { height: 460px !important; }
  #tc, #dr { height: 360px !important; }
  #side .spark { max-width: 420px; }
}
.tip-table { border-collapse: collapse; margin-top: 4px; font-size: 12px; }
.tip-table td { padding: 1px 8px 1px 0; white-space: nowrap; }

/* ---- Boundaries (working) page ---- */
.working-note { font-size: 11px; max-width: 560px; margin: 0; }
.dist-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 620px; align-items: stretch; }
.dist-right { display: grid; grid-template-rows: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#distview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#distview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#dmap { touch-action: none; cursor: grab; }
#dmap .bg { stroke: var(--surface); stroke-width: 0.4; vector-effect: non-scaling-stroke; }
#dmap .bg.dim { opacity: 0.25; }
#dmap .bg.hl { stroke: var(--text); stroke-width: 2; }
#dmap .district { fill: none; stroke: #1f1f1f; stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
#dmap .district.on { stroke: #e8710a; stroke-width: 3.5; }
#dmap .dlabel { font-size: 12px; font-weight: 700; fill: #1f1f1f; paint-order: stroke; stroke: #fff; stroke-width: 3px; text-anchor: middle; pointer-events: none; }
#dbars .row { cursor: pointer; }
#dbars .row:hover .row-bg, #dbars .row.on .row-bg { fill: #f0efec; }
#dbars .row.on .row-name { font-weight: 700; }
#dbars text { font-size: 11px; fill: var(--text); }
#dbars .muted { fill: var(--text-muted); }
@media (max-width: 1100px) {
  .dist-grid { grid-template-columns: 1fr; height: auto; }
  #distview .view-panel svg { flex: none; }
  #dmap { height: 460px; } #dbars, #dhist, #dtrend { height: 320px; }
}
.seg-btns { display: inline-flex; }
.seg-btns .tool { border-radius: 0; margin-left: -1px; }
.seg-btns .tool:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg-btns .tool:last-child { border-radius: 0 6px 6px 0; }

/* ---- Data & preprocessing page ---- */
.prep-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 640px; align-items: stretch; }
.prep-right { display: grid; grid-template-rows: minmax(0, 0.8fr) minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#prepview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#prepview .view-panel > svg { flex: 1 1 0; min-height: 0; width: 100%; }
#prep-sm .pt { stroke: none; }
#prep-sm .pt.hl { stroke: var(--text); stroke-width: 1.5; }
#prep-sm .panel-hit { fill: transparent; cursor: pointer; }
#prep-sm .sm-frame { fill: none; stroke: var(--border); }
#prep-sm .sm-frame.on { stroke: #c2410c; stroke-width: 2; }
#prep-sm text { font-size: 10px; fill: var(--text-muted); }
#prep-sm .sm-title { font-size: 11px; font-weight: 600; fill: var(--text); }
#prep-sm .sm-title.notacs { fill: #c2410c; }
#prep-heat .cell { cursor: pointer; }
#prep-heat .cell rect { stroke: var(--surface); stroke-width: 1.5; }
#prep-heat .cell.on rect { stroke: #c2410c; stroke-width: 2.5; }
#prep-heat text { font-size: 10px; fill: var(--text-muted); }
#prep-heat .cell text { text-anchor: middle; pointer-events: none; font-variant-numeric: tabular-nums; }
#prep-map .bg { stroke: var(--surface); stroke-width: 0.3; vector-effect: non-scaling-stroke; }
#prep-map .bg.hl { stroke: var(--text); stroke-width: 2; }
.prep-tepi-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; flex: 1 1 0; min-height: 0; }
.prep-tepi-body svg { width: 100%; height: 100%; }
.prep-findings { margin: 0; padding-left: 16px; font-size: 11px; line-height: 1.35; overflow-y: auto; }
.prep-findings li { margin-bottom: 3px; }
@media (max-width: 1100px) {
  .prep-grid { grid-template-columns: 1fr; height: auto; }
  #prepview .view-panel > svg { flex: none; }
  #prep-sm { height: 640px; } #prep-heat { height: 260px; } #prep-map { height: 360px; }
  .prep-tepi-body { grid-template-columns: 1fr; } .prep-tepi-body svg { height: 260px; }
}

/* ---- Spatial page: 2010 | 2020 swipe ---- */
.sp-slider-ctl { gap: 10px; }
#sp-swipe { width: 320px; }
.sp-panel { height: calc(100vh - 150px); min-height: 560px; display: flex; flex-direction: column; padding: 8px; }
.sp-panel svg { flex: 1 1 0; min-height: 0; width: 100%; touch-action: none; }
#sp-map .bg10 { fill: #e9e3d4; stroke: #8a6d3b; stroke-width: 0.7; vector-effect: non-scaling-stroke; }
#sp-map .bg20 { fill: #dde6ee; stroke: #2f6b9a; stroke-width: 0.7; vector-effect: non-scaling-stroke; }
#sp-map .bg10:hover, #sp-map .bg20:hover { stroke-width: 2; }
#sp-map .divider { stroke: #1f1f1f; stroke-width: 2; }
#sp-map .handle { fill: #fff; stroke: #1f1f1f; stroke-width: 1.5; cursor: ew-resize; }
#sp-map .side-label { font-size: 13px; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
@media (max-width: 1100px) { .sp-panel { height: 520px; } #sp-swipe { width: 180px; } }
#dhist .bar { cursor: default; }
#dhist .bar:hover { opacity: 0.8; }
#dhist text { font-size: 10px; fill: var(--text-muted); }
#dhist .hstat { font-size: 11px; fill: var(--text); }
#dhist .even { stroke: #52514e; stroke-dasharray: 4 3; }


/* ---- Previous / next page footer ---- */
.page-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.page-nav .btn { font-size: 14px; padding: 8px 16px; }
.page-nav .page-next { background: var(--accent); color: #fff; }
.page-nav .page-next:hover { background: #2b2b2b; }
.page-count { font-size: 12px; color: var(--text-muted); }

/* Title page */
.title-slide { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.1fr); gap: 40px; align-items: center;
  min-height: calc(100vh - 160px); padding: 24px 48px; }
.title-kicker { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 12px; }
.title-main { font-size: clamp(32px, 4.5vw, 56px); line-height: 1.05; margin: 0 0 16px; }
.title-sub { font-size: clamp(16px, 1.6vw, 21px); color: var(--text-muted); margin: 0 0 40px; max-width: 30em; }
.title-meta { font-size: 18px; line-height: 1.5; margin: 0; padding-top: 16px; border-top: 1px solid var(--border); }
.title-figure { margin: 0; }
#title-map { width: 100%; height: min(62vh, 560px); display: block; }
#title-legend { font-size: 12px; color: var(--text-muted); margin-top: 8px; text-align: center; }
.title-swatch { display: inline-block; width: 12px; height: 12px; margin: 0 4px 0 10px; vertical-align: -2px; border-radius: 2px; }
@media (max-width: 800px) { .title-slide { grid-template-columns: 1fr; padding: 16px; min-height: 0; } }
.title-key { white-space: nowrap; }
#dtrend text { font-size: 11px; fill: var(--text); }
#dtrend .muted { fill: var(--text-muted); }
#dtrend .col { cursor: pointer; }
#dtrend .col rect { fill: transparent; }
#dtrend .col:hover rect { fill: #f3f2ee; }
#dtrend .col.on rect { fill: #ecebe6; }
#dtrend .all { stroke: #8a8984; stroke-dasharray: 4 3; fill: none; }

/* Neighbours page */
.nb-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 620px; }
.nb-right { display: grid; grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#nbview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#nbview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#nbview [hidden] { display: none !important; }
#nb-map { touch-action: none; cursor: grab; }
#nb-map .bg { stroke: var(--surface); stroke-width: 0.4; vector-effect: non-scaling-stroke; }
#nb-map .bg.dim, #nb-map .node.dim { opacity: 0.2; }
#nb-map .bg.focus { stroke: var(--text); stroke-width: 2; }
#nb-map .edge { stroke: #9a9994; stroke-width: 0.6; vector-effect: non-scaling-stroke; pointer-events: none; }
#nb-map .edge.tree { stroke: #3d3c39; stroke-width: 1.1; }
#nb-map .edge.cut { stroke: #e8710a; stroke-width: 1.6; stroke-dasharray: 3 2; }
#nb-map .edge.focus { stroke: var(--text); stroke-width: 2; }
#nb-map .node { stroke: var(--surface); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
#nb-top text, #nb-bot text { font-size: 11px; fill: var(--text); }
#nb-top .muted, #nb-bot .muted { fill: var(--text-muted); }
#nb-top .pt { stroke: var(--surface); stroke-width: 0.5; }
#nb-top .pt.dim { opacity: 0.15; }
#nb-top .pt.focus { stroke: var(--text); stroke-width: 2; }
#nb-top .row, #nb-bot .col, #nb-bot .kpt { cursor: pointer; }
#nb-top .row:hover .row-bg, #nb-top .row.on .row-bg { fill: #f0efec; }
#nb-bot .col:hover .col-bg, #nb-bot .col.on .col-bg { fill: #f0efec; }
@media (max-width: 900px) {
  .nb-grid { grid-template-columns: 1fr; height: auto; }
  #nbview .view-panel svg { flex: none; }
  #nb-map { height: 460px; } #nb-top, #nb-bot { height: 320px; }
}

/* Slides: in the page sequence, not in the tab bar */
.toggle .slide-tab { display: none; }
h1 a { color: inherit; text-decoration: none; }
/* Moran's I slide */
.moran-slide { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr); gap: 48px; align-items: center; min-height: calc(100vh - 160px); padding: 24px 48px; }
.slide-h { font-size: clamp(30px, 4vw, 48px); margin: 0 0 8px; }
.moran-lead { font-size: clamp(18px, 1.8vw, 24px); margin: 0 0 20px; color: var(--text-muted); }
.moran-def { font-size: 16px; line-height: 1.6; margin: 0 0 24px; max-width: 32em; }
.formula { font-family: ui-serif, Georgia, serif; font-size: 16px; background: #f0efec; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
#toy-scale { width: 100%; height: 120px; display: block; margin-top: 20px; }
#toy-scale text { font-size: 13px; fill: var(--text); }
#toy-scale .muted { fill: var(--text-muted); }
#toy-map { width: 100%; height: min(70vh, 560px); display: block; }
#toy-map rect { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
@media (max-width: 900px) { .moran-slide { grid-template-columns: 1fr; padding: 16px; gap: 16px; } #toy-map { height: 360px; } }
#nb-map .bg.pickA, #nb-map .node.pickA { stroke: #e8710a; stroke-width: 2.5; opacity: 1; }
#nb-map .bg.pickB, #nb-map .node.pickB { stroke: #1f1f1f; stroke-width: 2.5; stroke-dasharray: 4 2; opacity: 1; }
#nb-map.lasso-mode { cursor: crosshair; }
#nb-top .pt.pickA { stroke: #e8710a; stroke-width: 2.2; opacity: 1; }
#nb-top .pt.pickB { stroke: #1f1f1f; stroke-width: 2.2; stroke-dasharray: 2 1.5; opacity: 1; }
#nb-top { cursor: crosshair; }
#nb-sel { margin: 4px 0 0; font-size: 12px; }

/* Text slides (questions, data, methods) */
.slide { padding: 28px 48px; min-height: calc(100vh - 160px); display: flex; flex-direction: column; gap: 16px; }
.slide-lead { font-size: clamp(16px, 1.5vw, 20px); color: var(--text-muted); margin: 0; max-width: 46em; }
.q-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 14px; }
.q-list li { display: grid; grid-template-columns: 190px 1fr; column-gap: 20px; row-gap: 2px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.q-tag { grid-row: span 2; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); align-self: center; }
.q-text { font-size: clamp(18px, 1.8vw, 24px); font-weight: 700; }
.q-how { font-size: 14px; color: var(--text-muted); }
.slide-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.src-list { margin: 0; }
.src-list dt { font-size: 18px; font-weight: 700; margin-top: 18px; }
.src-list dt:first-child { margin-top: 0; }
.src-meta { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.src-list dd { margin: 4px 0 0; font-size: 15px; line-height: 1.5; }
#release-timeline { width: 100%; height: 380px; display: block; }
#release-timeline text { font-size: 12px; fill: var(--text); }
#release-timeline .muted { fill: var(--text-muted); }
.method-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.method-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 8px 12px; border-bottom: 2px solid var(--border); }
.method-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.4; }
.method-table td:nth-child(4), .method-table td:nth-child(5) { white-space: nowrap; }
.cite { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; }
@media (max-width: 900px) {
  .slide { padding: 16px; }
  .slide-cols { grid-template-columns: 1fr; }
  .q-list li { grid-template-columns: 1fr; }
  .q-tag { grid-row: auto; }
  .method-table { font-size: 13px; }
}

/* SKATER slide */
.skater-steps { margin: 0 0 20px; padding-left: 22px; font-size: 16px; line-height: 1.55; max-width: 32em; }
.skater-steps li { color: var(--text-muted); transition: color 0.2s; }
.skater-steps li.on { color: var(--text); }
.sk-k { margin: 16px 0 6px; font-size: 15px; }
.sk-k.off { opacity: 0.35; }
#sk-map { width: 100%; height: min(70vh, 560px); display: block; }
#sk-map .cell { stroke: var(--surface); stroke-width: 2; }
#sk-map .link { stroke: #1f1f1f; stroke-linecap: round; }
#sk-map .cutmark { stroke: #e8710a; stroke-width: 3; stroke-linecap: round; }
@media (max-width: 900px) { #sk-map { height: 360px; } }

/* Finding walkthroughs */
.q-list li { grid-template-columns: 190px 1fr auto; }
.tour-btn { grid-row: span 2; grid-column: 3; align-self: center; white-space: nowrap; }
.tour-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; width: min(960px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #1f1f1f; color: #fff; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,0.25); }
.tour-bar[hidden] { display: none; }
.tour-title { font-weight: 700; white-space: nowrap; color: #f6b26b; }
.tour-caption { flex: 1; font-size: 15px; line-height: 1.4; }
.tour-count { font-size: 12px; color: #b9b8b2; white-space: nowrap; }
.tour-bar .btn { background: transparent; color: #fff; border-color: #6b6a66; }
.tour-bar .page-next { background: #fff; color: #1f1f1f; border-color: #fff; }
@media (max-width: 900px) { .q-list li { grid-template-columns: 1fr; } .tour-btn { grid-row: auto; grid-column: auto; justify-self: start; } }
.q-list .q-tag { grid-column: 1; grid-row: 1 / span 2; }
.q-list .q-text, .q-list .q-how { grid-column: 2; }
.q-list .tour-btn { grid-column: 3; grid-row: 1 / span 2; }
@media (max-width: 900px) { .q-list .q-tag, .q-list .q-text, .q-list .q-how, .q-list .tour-btn { grid-column: 1; grid-row: auto; } }

/* Random maps page */
.ens-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 600px; }
.ens-right { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#ensview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#ensview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#ens-map .bg { stroke: var(--surface); stroke-width: 0.4; }
#ens-map .hi { fill: #1f1f1f; fill-opacity: 0.55; pointer-events: none; }
#ens-box text, #ens-hist text { font-size: 11px; fill: var(--text); }
#ens-box .muted, #ens-hist .muted { fill: var(--text-muted); }
#ens-plan .tool { min-width: 28px; padding-left: 6px; padding-right: 6px; }
@media (max-width: 900px) { .ens-grid { grid-template-columns: 1fr; height: auto; } #ensview .view-panel svg { flex: none; } #ens-map { height: 420px; } #ens-box, #ens-hist { height: 300px; } }

/* Slide sorter */
header { position: relative; }
.sorter-btn { margin-left: auto; margin-right: 8px; white-space: nowrap; }
.sorter { position: fixed; inset: 0; z-index: 60; background: rgba(249, 249, 247, 0.97); overflow-y: auto; padding: 24px 40px 40px; }
.sorter[hidden] { display: none; }
.sorter-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 8px; }
.sorter-head h2 { margin: 0; font-size: 24px; }
.sorter-head .btn { margin-left: auto; }
.sorter-section { margin: 20px 0 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.sorter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.sorter-card { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; aspect-ratio: 16 / 9; padding: 12px 14px; text-align: left; font: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.sorter-card:hover { border-color: var(--text); }
.sorter-card.on { border: 2px solid #e8710a; }
.sorter-card .n { font-size: 12px; color: var(--text-muted); }
.sorter-card .t { font-size: 15px; font-weight: 700; line-height: 1.25; }
.sorter-card .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.sorter-card.dash { background: #f0efec; }
.sorter-card.find { border-style: dashed; }
#ens-map .dline { fill: none; stroke: #1f1f1f; stroke-width: 1.4; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }

/* AI reflection slide */
.ai-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ai-col { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; }
.ai-col.ai-me { border: 2px solid #e8710a; }
.ai-col h3 { margin: 0 0 6px; font-size: 18px; }
.ai-col ul { margin: 0; padding-left: 18px; font-size: 14.5px; line-height: 1.5; }
.ai-col li + li { margin-top: 6px; }
.ai-example { display: flex; align-items: stretch; gap: 14px; }
.ai-ex-title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); align-self: center; width: 110px; }
.ai-flow { flex: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: s; }
.ai-flow li { position: relative; background: #f0efec; border-radius: 8px; padding: 10px 14px; font-size: 14px; line-height: 1.4; }
.ai-flow li strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #b85a07; margin-bottom: 2px; }
.ai-flow li + li::before { content: "→"; position: absolute; left: -11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.ai-lessons { margin: 0; font-size: 15px; line-height: 1.5; max-width: 60em; }
@media (max-width: 900px) { .ai-cols, .ai-flow { grid-template-columns: 1fr; } .ai-example { flex-direction: column; } .ai-flow li + li::before { content: none; } }
/* Data slide: one type scale (headings, details, note) */
#dataview .src-list { max-width: 60em; }
#dataview .src-list dt { font-size: 22px; margin-top: 22px; }
#dataview .src-list dt:first-child { margin-top: 0; }
#dataview .src-meta { font-size: 15px; margin-left: 10px; }
#dataview .src-list dd { font-size: 17px; line-height: 1.5; margin-top: 4px; }
#dataview .slide-lead { font-size: 17px; margin-top: 12px; }
#dataview code { font-family: inherit; font-weight: 600; }
/* Data slide as bullets */
.src-bullets { margin: 0; padding-left: 24px; font-size: 20px; line-height: 1.45; max-width: 60em; }
.src-bullets > li { margin-top: 14px; }
.src-bullets > li:first-child { margin-top: 0; }
.src-bullets ul { margin: 4px 0 0; padding-left: 26px; font-size: 17px; list-style: circle; }
.src-bullets .src-meta { font-size: 15px; margin-left: 8px; }
#prepview .prep-grid { grid-template-columns: 1fr; }
#ppview .src-bullets { font-size: 19px; }
#ppview .src-bullets ul { font-size: 16px; }
#ppview .src-bullets > li { margin-top: 12px; }
#ppview .slide-lead { font-size: 17px; }
#ppview code { font-family: inherit; font-weight: 600; }
#methodview .src-bullets { font-size: 19px; }
#methodview .src-bullets ul { font-size: 16px; }
#methodview .src-bullets > li { margin-top: 12px; }
#methodview .slide-lead { font-size: 17px; }
#dr .load-title { font-size: 11px; font-weight: 700; fill: var(--text); }
#dr .load-label { font-size: 10px; fill: var(--text-muted); }
.tooltip { max-width: min(380px, calc(100vw - 16px)); }

/* Redistricting page, v2 */
.ens2-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 640px; }
.ens2-wide { grid-column: 1 / -1; }
#ensview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#ensview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#ens-map, #ens-contrast { touch-action: none; cursor: grab; }
#ens-map .bg, #ens-contrast .bg { stroke: var(--surface); stroke-width: 0.3; vector-effect: non-scaling-stroke; }
#ens-contrast .bg.sig { stroke: #1f1f1f; stroke-width: 1.2; }
#ens-map .dline, #ens-contrast .dline { fill: none; stroke: #1f1f1f; stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
#ens-map .dlabel { font-size: 12px; font-weight: 700; fill: #1f1f1f; paint-order: stroke; stroke: #fff; stroke-width: 3px; text-anchor: middle; pointer-events: none; }
#ens-hist text { font-size: 11px; fill: var(--text); }
#ens-hist .muted { fill: var(--text-muted); }
@media (max-width: 900px) { .ens2-grid { grid-template-columns: 1fr; grid-template-rows: none; height: auto; } #ensview .view-panel svg { flex: none; height: 380px; } }

/* Redistricting page, v3: three maps + one chart */
.ens3 { display: grid; grid-template-rows: minmax(0, 1.9fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 110px); min-height: 620px; }
.ens3-maps { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ens3-maps .ens3-cell { display: flex; flex-direction: column; min-height: 0; }
.ens3-maps h3 { margin: 2px 0 4px; font-size: 14px; }
.ens3-maps h3 .muted { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.ens3-maps svg { flex: 1 1 0; min-height: 0; width: 100%; touch-action: none; cursor: grab; }
.ens3-maps .bg { stroke: var(--surface); stroke-width: 0.3; vector-effect: non-scaling-stroke; }
.ens3-maps .dline { fill: none; stroke: #1f1f1f; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.ens3-maps .dlabel { font-size: 11px; font-weight: 700; fill: #1f1f1f; paint-order: stroke; stroke: #fff; stroke-width: 3px; text-anchor: middle; pointer-events: none; }
#ens-trend text { font-size: 12px; fill: var(--text); }
#ens-trend .muted { fill: var(--text-muted); }
@media (max-width: 900px) { .ens3 { grid-template-rows: none; height: auto; } .ens3-maps { grid-template-columns: 1fr; } .ens3-maps svg { flex: none; height: 320px; } #ens-trend { height: 260px; } }

/* Deck typography: bold titles, light body text on the slides */
h1, h2, h3, .slide-h, .title-main, .q-text, .src-bullets > li > strong { font-weight: 700; }
.slide, .title-slide, .moran-slide { font-weight: 300; }
.slide strong, .title-slide strong, .moran-slide strong { font-weight: 700; }
.slide-lead, .moran-lead, .title-sub { color: var(--text); font-weight: 300; }
input { accent-color: #52514e; }
svg text { font-family: "DM Sans", system-ui, sans-serif; }

/* Presentation slides only: deck style (Project 1 slides), navy #000FA1 on white */
#titleview, #qview, #dataview, #ppview, #methodview, #encview, #moranview, #aiview, #aireflectview, #redistview, #dpview, #dpmechview {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000fa1;
  --text-muted: #5a63b5;
  --border: #dcdff0;
  --accent: #000fa1;
  background: var(--bg);
  color: var(--text);
}
/* the page footer (Previous / Page k of N / Next) looks the same on every page */
#titleview .page-nav, #qview .page-nav, #dataview .page-nav, #ppview .page-nav,
#methodview .page-nav, #encview .page-nav, #moranview .page-nav, #aiview .page-nav, #aireflectview .page-nav, #redistview .page-nav, #dpview .page-nav, #dpmechview .page-nav {
  --text: #0b0b0b; --text-muted: #52514e; --border: #e1e0d9; --surface: #fcfcfb; --accent: #0b0b0b;
  color: var(--text);
}

/* Redistricting: network + dot strip */
.ens3 { grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); }
.ens3-bottom { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#ens-net { cursor: grab; }
#ens-net .nlink { stroke: #d9d8d2; stroke-width: 0.6; }
#ens-net .ncut { stroke: #b9b8b2; stroke-width: 1.4; }
#ens-net .ncut.odd { stroke: #d7191c; stroke-width: 2.4; }
#ens-net .node { stroke-width: 1.6; }
@media (max-width: 900px) { .ens3-bottom { grid-template-columns: 1fr; } #ens-net { height: 360px; } }
#ens-net .node { cursor: grab; } #ens-net .node:active { cursor: grabbing; }

/* Privacy page */
.priv-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 600px; }
.priv-right { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
#privview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#privview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#privview [hidden] { display: none !important; }
#priv-map .bg { vector-effect: non-scaling-stroke; }
#priv-matrix text, #priv-curve text { font-size: 11px; fill: var(--text); }
#priv-matrix .muted, #priv-curve .muted { fill: var(--text-muted); }
@media (max-width: 900px) { .priv-grid { grid-template-columns: 1fr; height: auto; } #privview .view-panel svg { flex: none; height: 340px; } }
#ens-net .vor-links line { stroke: #b9b8b2; stroke-width: 0.5; stroke-opacity: 0.6; }
#ens-net .vor-borders line { stroke: #1f1f1f; stroke-width: 1.6; stroke-linecap: round; }
#ens-net .vn { fill: #b9b8b2; }
#ens-net .vn.high { fill: #08306b; stroke: #fff; stroke-width: 0.8; }
#ens-net .vn.high.moved { stroke: #e8710a; stroke-width: 2.2; }

/* Redistricting dashboard: network + small multiples; slide with the three maps */
.ens4 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 165px); min-height: 600px; }
#ensview .view-panel { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#ensview .view-panel svg { flex: 1 1 0; min-height: 0; width: 100%; }
#redistview .slide { gap: 10px; }
#redistview .ens3-maps { height: calc(100vh - 330px); min-height: 360px; }
#redistview, #redistview .page-nav { }
#ens-sm text { font-size: 10px; fill: var(--text); }
#ens-sm .muted { fill: var(--text-muted); }
#ens-sm .sm-cell { cursor: pointer; }
#ens-sm .sm-cell:hover .sm-bg, #ens-sm .sm-cell.on .sm-bg { fill: #f0efec; }
#ens-net .vor-cells path.dim { fill-opacity: 0.08 !important; }
@media (max-width: 900px) { .ens4 { grid-template-columns: 1fr; height: auto; } #ensview .view-panel svg { flex: none; height: 420px; } }

/* Privacy page v2: four linked views */
.priv2-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 640px; }
#priv-net, #priv-pca { cursor: grab; }
#dpview .src-bullets { font-size: 19px; } #dpview .src-bullets ul { font-size: 16px; } #dpview .src-bullets > li { margin-top: 12px; }
@media (max-width: 900px) { .priv2-grid { grid-template-columns: 1fr; grid-template-rows: none; height: auto; } }
.ens3-maps .bg { stroke: #fff; stroke-width: 0.4; }
.ens3-maps .dline { stroke-width: 2.2; }
.ens3-maps .dline-old { fill: none; stroke: #8a8984; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#ens-net .vn.moved { stroke: #1f1f1f; stroke-width: 0.8; }
#ens-net .vn.focus { stroke: #e8710a; stroke-width: 2.4; }
#ens-net .vn.faded { opacity: 0.15; }
#ens-sm rect.seg { cursor: pointer; }
#ens-sm rect.seg:hover, #ens-sm rect.seg.hit { stroke: #e8710a; stroke-width: 2.5; }

/* Privacy page v3: Moran's I and PCA robustness */
.priv3-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; height: calc(100vh - 150px); min-height: 600px; }
.priv3-wide { grid-column: 1; grid-row: 1 / span 2; }
#priv-moran text, #priv-knn text { font-size: 11px; fill: var(--text); }
#priv-moran .muted, #priv-knn .muted { fill: var(--text-muted); }
@media (max-width: 900px) { .priv3-grid { grid-template-columns: 1fr; grid-template-rows: none; height: auto; } .priv3-wide { grid-column: auto; grid-row: auto; } }

/* "Finding" buttons: replay each task's analytical finding in the dashboard */
.finding-btns { margin-left: auto; display: inline-flex; gap: 6px; }
.finding-btn { background: #1f1f1f; color: #fff; border-color: #1f1f1f; font-weight: 600; white-space: nowrap; }
.finding-btn:hover { background: #3a3a3a; }

/* "How differential privacy works" slide */
#dpmechview .src-bullets { font-size: 19px; } #dpmechview .src-bullets ul { font-size: 16px; } #dpmechview .src-bullets > li { margin-top: 12px; }
.dp-cols { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.dp-eq { display: inline-block; margin-top: 4px; font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.dp-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 18px; margin-bottom: 6px; }
#dp-noise { width: 100%; height: 340px; display: block; }
.dp-note { font-size: 15px; margin: 6px 0 0; }

/* "Marks and channels" slide */
.enc-table { font-size: 14px; }
.enc-table td { padding: 6px 10px; }
.enc-table td:nth-child(4), .enc-table td:nth-child(5) { white-space: normal; }
.enc-table .enc-page { white-space: nowrap; font-weight: 700; }
#encview .slide-lead { font-size: 17px; }

/* Redistricting as a delta: old lines dashed, new lines solid, selected piece outlined */
#ens-net .vor-old line { stroke: #1f1f1f; stroke-width: 1.2; stroke-dasharray: 4 3; stroke-opacity: 0.75; pointer-events: none; }
#ens-net .vor-borders line, #ens-net .vor-links line { pointer-events: none; }
#ens-net .vor-borders line { stroke-width: 2.2; }
#ens-net .vor-piece line { stroke: #e8710a; stroke-width: 3.2; stroke-linecap: round; pointer-events: none; }
#ens-net .vor-cells path { cursor: pointer; }
#ens-sm .piece-row.on .piece-bg { fill: #fbe3cf; }
#ens-sm .piece-row:hover .piece-bg { fill: #f0efec; }
.ens-piece-note { font-size: 13px; min-height: 1.4em; margin: 4px 0 0; }

.dr-geo { font-size: 12px; font-weight: 600; color: var(--text); margin-left: 8px; }

/* AI slides */
.ai-split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.ai-split2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.ai-bar { display: grid; grid-template-columns: 11.5em minmax(0, 1fr) 2em; grid-template-rows: auto auto; column-gap: 8px; align-items: center; margin-top: 8px; font-size: 14px; }
.ai-bar-l { font-weight: 600; }
.ai-bar-track { height: 14px; background: #eceae4; border-radius: 3px; overflow: hidden; }
.ai-bar-fill { display: block; height: 100%; background: #e8710a; }
.ai-bar-n { font-weight: 700; text-align: right; }
.ai-bar-note { grid-column: 2 / 4; font-size: 12px; color: var(--text-muted); }
.ai-flow6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 900px) { .ai-split, .ai-split2, .ai-flow6 { grid-template-columns: 1fr; } }
