:root {
  --bg: #fff8f0;
  --bg-white: #ffffff;
  --border: #d56f3e;
  --border-light: #e4aa90;
  --text: #20242b;
  --muted: #59616d;
  --faint: #a5a29d;
  --info-light:rgba(33, 131, 123, 0.07); /* Teal is for shout outs and informative accents */
  --info: #1ab4a7;
  --info-dark: #0e7c7b;
  --touchme-light: #efe9f7; /* Purple is for interactive elements*/
  --touchme: #cdbce8; 
  --touchme-dark: #4a3a7a;
  --ks-pos: #e34948;
  --ks-neg: #2a78d6;
  /* --ks-pos:#d56f3e;
  --ks-neg:#6b4fa0; */
  --shadow-soft: 0 10px 30px rgba(31, 36, 48, 0.2);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-rounded: 999px;
  --page-max: 1180px;
  --sidebar-w: 272px;
  --danger: #c0392f;
  --danger-soft: #fdf1ef;
  --plots-rule: #eef1f4;
  --plots-rule-strong: #c6cdd4;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "PT Serif", serif;
  color: var(--text);
  background: var(--bg);
}
img, svg, canvas, iframe { max-width: 100%; }
button, input, select { font: inherit; }
a {
  color: var(--touchme-dark);
}

.dashboard-header, .dashboard-footer {
  padding: 1.5rem max(2rem, calc((100vw - var(--page-max)) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}
.dashboard-header h1, .dashboard-footer h1{
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.dashboard-footer {
  border-top: 1px solid var(--border);
}

.subtitle {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.main { padding: 1.5rem 0 3rem; }

.task {
  width: calc(100% - 2rem);
  max-width: var(--page-max);
  margin: 0 auto 2rem;
  padding: 2rem;
  /* overflow: hidden; */
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  box-shadow: var(--shadow-soft);
}
.introduction-task { padding: 0; }
.dashboard-section {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}
.task-header {
  max-width: 860px;
  margin-bottom: 1.75rem;
}
.task-header h2 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
}
.task-intro {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}
.task-intro strong {
  color: var(--text);
  font-weight: 650;
}
.task-caption {
  max-width: 760px;
  margin: 1rem 0 1.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}
.story-eyebrow {
  margin: 0 0 12px;
  color: var(--info-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.amanda-story {
  width: 100%;
  color: var(--text);
}
.story-hero {
  max-width: 900px;
  margin: 0 auto;
  padding: 56px 24px 40px;
  text-align: center;
}
.story-hero h2 {
  max-width: 800px;
  margin: 0 auto 20px;
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.story-introduction {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.75;
}
.story-section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 72px 24px;
  border-top: 1px solid var(--border-light);
}
.story-copy {
  max-width: 760px;
  margin-bottom: 28px;
}
.section-number {
  margin: 0 0 10px;
  color: var(--info-dark);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.story-copy h3,
.metro-transition h3 {
  margin: 0 0 18px;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.story-copy p {
  max-width: 720px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}
.interaction-prompt {
  max-width: 900px;
  margin: 22px 0 0 !important;
  padding: 16px 18px;
  border-left: 4px solid var(--info-dark);
  border-radius: 0 8px 8px 0;
  background: var(--info-light);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
}
.dashboard-prompt { margin: 1.25rem 0 1.75rem !important; }
.story-visual { margin: 30px 0 0; }
.line-chart-figure {
  max-width: 1000px;
  margin-right: auto;
  margin-left: auto;
}
.amanda-line-chart {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: var(--bg-white);
}
.full-width-visual { width: 100%; }
.amanda-map-frame,
.amanda-tile-frame {
  display: block;
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg-white);
  box-shadow: 0 12px 35px var(--shadow-soft);
}
.amanda-map-frame { height: 660px; }
.amanda-tile-frame { height: 560px; }
.story-visual figcaption {
  max-width: 850px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  text-align: center;
}
.metro-transition {
  max-width: 900px;
  margin: 30px auto 80px;
  padding: 48px 36px;
  border-radius: 18px;
  background: var(--bg);
  text-align: center;
  border: 1px solid var(--border-light);
}
.metro-transition p:not(.story-eyebrow) {
  max-width: 700px;
  margin: 0 auto 26px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.section-copy,
.visual-introduction {
  max-width: 760px;
  margin: 1.75rem 0;
}
.section-copy h3,
.visual-introduction h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
}
.section-copy p,
.visual-introduction p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}
.chart-heading {
  max-width: 800px;
  margin-bottom: 1rem;
}
.chart-heading h3 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.chart-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}
/* Small readout beside a chart (e.g. the selected year). */
.chart-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.chart-note strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Shown in a chart container when there is nothing to draw. */
.chart-placeholder {
  margin: 0;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-white);
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.chart-block {
  min-width: 0;
  margin-top: 2.5rem;
  margin-bottom: 3rem;
}
.chart-block + .chart-block {
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.chart {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  background: var(--bg-white);
}

.line {
  fill: none;
  stroke: var(--info-dark);
  stroke-width: 2;
}
.dot, .bar { fill: var(--info); }
.point {
  fill: var(--info);
  fill-opacity: 0.75;
  stroke: var(--bg-white);
  stroke-width: 1;
}
.axis text { font-size: 11px; }
.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.ks-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 1rem 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--muted);
  font-size: 0.82rem;
}
.ks-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.ks-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.ks-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  position: relative;
}
.ks-kpi-card {
  min-width: 0;
  min-height: 250px;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(bg-white);
  box-shadow: 0 4px 14px rgba(31, 36, 48, 0.04);
}
.ks-kpi-title {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}
.ks-kpi-chart {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  background: var(--bg-white);
}
.ks-bar { cursor: pointer; }
.ks-bar-hover { opacity: 0.8; }
.ks-grid line {
  stroke: var(--plots-rule);
  stroke-width: 1px;
  shape-rendering: crispEdges;
}
.ks-grid path { display: none; }
.ks-zero-line {
  stroke: var(--plots-rule-strong);
  stroke-width: 1px;
  shape-rendering: crispEdges;
}
.ks-axis text {
  fill: var(--muted);
  font-size: 9px;
}
.ks-axis path,
.ks-axis line { stroke: var(--border-light); }
.ks-empty {
  fill: var(--muted);
  font-size: 0.8rem;
}
.ks-tooltip {
  position: absolute;
  z-index: 10;
  opacity: 0;
  padding: 8px 10px;
  border: 1px solid var(--info-dark);
  border-radius: 6px;
  background: var(--bg-white);
  box-shadow: 0 2px 8px var(--shadow-soft);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.1s ease;
}
.ks-tt-title {
  margin-bottom: 3px;
  color: var(--text);
  font-weight: 600;
}
.ks-tt-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ks-tt-key {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 2px;
}
.ks-tt-value {
  color: var(--text);
  font-weight: 600;
}
.ks-tt-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}
.ks-compare-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.ks-compare-control select {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--touchme);
  border-radius: var(--radius-rounded);
  background: var(--touchme-light);
  color: var(--touchme-dark);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.ks-compare-control select:hover,
.ks-compare-control select:focus {
  border-color: var(--touchme-dark);
}
.ks-compare-swimlane {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

#state-comparison { overflow: hidden; }
/* #zk-vis {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}
#zk-vis .vega-embed {
  position: relative;
  display: flex;
  width: max-content;
  min-width: 100%;
  max-width: none;
}
#zk-vis .vega-embed > div { min-width: 0; }
#zk-vis .vega-embed details {
  position: absolute;
  top: 0;
  right: 0.25rem;
  z-index: 5;
}

#zk-vis svg,
#zk-vis canvas { display: block; } */
/*#zk-vis .vega-embed { display: flex; flex-direction: column; }
#zk-vis .vega-bindings {
  order: -1;
  margin: 0 0 16px 0;
  padding: 10px 12px;
  background: #f7f7f9;
  border: 1px solid #e1e1e6;
  border-radius: 6px;
}*/
/*
#zk-vis .vega-bindings label { font: 14px sans-serif; }
#zk-vis .vega-bindings input[type="number"] {
  padding: 4px 6px;
  font-size: 14px;
  width: 140px;
  margin-left: 6px;
}*/

#zk-vis .vega-embed {
  width: 100%;
  display: flex;
}

#zk-vis .vega-embed details,
#zk-vis .vega-embed details summary {
  position: relative;
}

/* ============================================================ *
 *  Market-drivers section
 *  (indexed trends, rolling correlation, year profile, raw summary)
 * ============================================================ */

/* ---- trends: shared line-chart chrome for both stacked panels ---- */
.tr-ref { stroke: var(--plots-rule); shape-rendering: crispEdges; }
.tr-ref-zero { stroke: var(--plots-rule-strong); stroke-width: 1.1; shape-rendering: crispEdges; }
.tr-line { fill: none; stroke-width: 3; opacity: 0.92; }
.tr-axis text { font-size: 10px; }
.tr-axis path, .tr-axis line { stroke: var(--border-light); }
.tr-panel-title { fill: var(--text); font-size: 12px; font-weight: 600; }
.tr-panel-sub   { fill: var(--muted); font-size: 11px; }
.tr-axis-title  { fill: var(--muted); font-size: 12px; }
.tr-hint { fill: var(--muted); font-size: 12px; }
.tr-rule { stroke: var(--touchme-dark); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: 0.8; pointer-events: none; }
.tr-rule-tag rect { fill: var(--touchme-dark); }
.tr-rule-tag text { fill: var(--touchme-light); font-size: 10px; font-variant-numeric: tabular-nums; }
.tr-dot { stroke: var(--bg-white); stroke-width: 1.4; pointer-events: none; }
.tr-handle { fill: transparent; cursor: ew-resize; }
.tr-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  margin-top: 0.6rem; padding: 0.6rem 0.8rem;
  border-radius: 8px; background: var(--bg-white);
  font-size: 0.8rem; color: var(--text);
}
.tr-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.tr-swatch { display: inline-block; width: 14px; height: 6px; border-radius: 2px; }

/* ---- year profile: vertical diverging bars ---- */
#cd-diverging-bar-chart { position: relative; }
.db-grid { stroke: var(--plots-rule); stroke-width: 1; shape-rendering: crispEdges; }
.db-zero { stroke: var(--plots-rule-strong); stroke-width: 1.1; shape-rendering: crispEdges; }
.db-toplabel { fill: var(--text); font-size: 10px; }
.db-axis text { font-size: 10px; }
.db-axis path, .db-axis line { stroke: var(--border-light); }
.db-axis-title { fill: var(--muted); font-size: 12px; }
.db-missing { fill: var(--muted); font-size: 10px; font-style: italic; }
.db-col-capture { fill: transparent; }
.db-arrow { stroke: var(--touchme-dark); stroke-width: 1.4; }
.db-arrowhead { fill: var(--touchme-dark); }
.db-annot-text { fill: var(--touchme-dark); font-size: 10px; }
.db-tooltip {
  position: absolute; opacity: 0; padding: 6px 9px;
  border: 1px solid var(--info-dark); border-radius: 6px; background: var(--bg-white);
  box-shadow: 0 2px 8px var(--shadow-soft);
  font-size: 12px; line-height: 1.35; pointer-events: none; white-space: nowrap;
  transition: opacity 0.1s ease;
}
.db-tt-title { margin-bottom: 1px; font-weight: 600; }
.db-tt-sub { margin-top: 1px; color: var(--muted); font-size: 11px; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.5rem 0;
}
.chart-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-white);
  box-shadow: 0 4px 14px var(--shadow-soft);
}
.chart-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.color-emphasis {
  color: var(--info-dark);
  font-style: italic;
}

/* ============================================================ *
 *  Market-drivers section — controls & two-column layout
 * ============================================================ */

/* factor filter (one control set drives all four components) */
.cd-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem;
  margin: 1.25rem 0 1.75rem;
}
.cd-controls-title {
  font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-right: 0.25rem;
}
#cd-factor-filter { display: flex; flex-wrap: wrap; gap: 0.45rem 0.5rem; }
.cd-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--touchme-dark);
  border-radius: var(--radius-rounded);
  background: var(--bg-white);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}
.cd-chip input { accent-color: var(--touchme-dark); margin: 0; }
.cd-chip-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.cd-chip:has(input:not(:checked)) { opacity: 0.4; }
.cd-chip-reset {
  border: 1px solid var(--touchme);
  border-radius: var(--radius-rounded);
  background: var(--touchme-light);
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--touchme-dark);
}
.cd-chip-reset:hover {
  color: var(--touchme-light);
  background: var(--touchme-dark);
  border-color: var(--touchme-dark);
}

.cd-chip {
  position: relative; /* anchor for the tooltip */
}

#target-chip {
  border-color: var(--info-dark);
  background: var(--info-light);
}

.cd-chip[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-white);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  text-align: left;
  z-index: 20;
  box-shadow: 0 4px 12px var(--shadow-soft);
  pointer-events: none;
}

.cd-chip[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--info-dark);
  z-index: 20;
  pointer-events: none;
}

/* two columns: left = trends stack, right = summary + profile */
.cd-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1.75rem;
  align-items: start;
}
.cd-col { min-width: 0; }
.cd-col .chart-block { margin-top: 0; margin-bottom: 0; }
.cd-col .chart-block + .chart-block {
  margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--border);
}

#cd-chart-3 {
  display: flex;
  flex-direction: column;

}
.cd-annot-toggle {
  align-self: flex-end;
  border: 1px solid var(--touchme);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--touchme-light);
  color: var(--touchme-dark);
  border-radius: var(--radius-rounded);
  margin-left: auto;
}

.cd-annot-toggle:hover {
  border-color: var(--touchme-dark);
  background: var(--touchme-dark);
  color: var(--touchme-light)
}

/* raw-value summary card */
#cd-raw-summary { min-width: 0; }
.rs-card {
  border: 1px solid var(--border-light); border-radius: 12px;
  background: var(--bg-white); padding: 1.1rem 1.25rem;
}
.rs-year {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin-bottom: 0.6rem; color: var(--text);
}
.rs-list { margin: 0; }
.rs-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem;
  padding: 0.2rem 0; border-top: 1px solid var(--border-light);
}
.rs-row:first-of-type { border-top: none; }
.rs-label { color: var(--muted); font-size: 0.9rem; }
.rs-value { text-align: right; }
.rs-num {
  font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text);
}
.rs-unit { display: block; font-size: 0.72rem; color: var(--muted); }
.rs-num.rs-missing { color: var(--faint); font-weight: 500; }
.rs-empty { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 900px) {
  .cd-grid { grid-template-columns: 1fr; }
  .cd-col .chart-block + .chart-block { margin-top: 2.5rem; }
}

/* Affordability definition equation */
.affordability-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  margin: 2.5rem auto;
  color: var(--text);
  font-size: clamp(1.05rem, 2.8vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.eq-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
}
.eq-numerator,
.eq-denominator {
  padding: 0 0.4em;
  white-space: nowrap;
}
.eq-rule {
  align-self: stretch;
  height: 0.14em;
  min-height: 3px;
  border-radius: 2px;
  background: var(--info-dark);
}
.eq-operator {
  color: var(--info-dark);
  font-size: 1.3em;
  font-weight: 600;
}
.eq-value {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
   SIDEBAR NAVIGATION
   Left rail: brand, state/metro selection, in-page section links.
   ========================================================================== */

.site-nav {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  background: var(--bg-white);
  box-shadow: var(--shadow-soft);
}
.site-nav-inner { padding: 1.5rem 1.15rem 2.5rem; }

.nav-brand {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.nav-brand-eyebrow {
  margin: 0 0 4px;
  color: var(--info-dark);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.nav-brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.nav-heading {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* --- area selection ------------------------------------------------------ */

.nav-region {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}
.nav-field { margin-bottom: 0.9rem; }
.nav-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}
.nav-combo { position: relative; }
.nav-input {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 2rem 0.45rem 0.6rem;
  border: 1px solid var(--touchme);
  border-radius: 8px;
  background: var(--touchme-light);
  color: var(--text);
  font-size: 0.9rem;
}
.nav-input::placeholder { color: var(--faint); }
.nav-input:focus {
  outline: 3px solid var(--shadow-soft);
  border-color: var(--touchme-dark);
}
.nav-combo-arrow {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}
.nav-combo-arrow::after {
  display: block;
  width: 7px;
  height: 7px;
  margin: 0 auto;
  transform: translateY(-2px) rotate(45deg);
  border-right: 2px solid var(--touchme);
  border-bottom: 2px solid var(--touchme-dark);
  content: "";
  transition: transform 0.15s ease;
}
.nav-combo-arrow:hover::after { border-color: var(--touchme-dark); }
.is-open .nav-combo-arrow::after { transform: translateY(2px) rotate(-135deg); }

/* dropdown */
.nav-options {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 264px;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  border: 1px solid var(--touchme-dark);
  border-radius: 8px;
  background: var(--bg-white);
  box-shadow: 0 12px 28px var(--shadow-soft);
  list-style: none;
}
.nav-options[hidden] { display: none; }
.nav-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.nav-option:hover,
.nav-option.is-active { background: var(--background); }
.nav-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-option-hint {
  flex: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
.nav-option-empty {
  padding: 0.45rem 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
}

/* validation states */
.nav-field.is-invalid .nav-input,
.nav-field.is-pending .nav-input {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.nav-field.is-invalid .nav-input:focus,
.nav-field.is-pending .nav-input:focus {
  outline-color: var(--danger);
}
.nav-field.is-shaking .nav-combo { animation: nav-jiggle 0.42s ease; }

@keyframes nav-jiggle {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  80% { transform: translateX(-2px); }
}

.nav-field-message {
  max-height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
  transition: opacity 0.18s ease, max-height 0.18s ease, margin 0.18s ease;
}
.nav-field-message.is-visible {
  max-height: 4rem;
  margin-top: 0.35rem;
  opacity: 1;
}
.nav-field-message.is-error { color: var(--danger); }

.nav-selection {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.6rem;
  border: 1px dashed var(--touchme-dark);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}
.nav-selection.is-set {
  border-style: solid;
  border-color: var(--info);
  background: var(--info-light);
  color: var(--text);
  font-weight: 600;
}
.nav-region-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.nav-clear {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--touchme);
  border-radius: var(--radius-rounded);
  background: var(--touchme-light);
  color: var(--touchme-dark);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}
.nav-clear:hover {
  border-color: var(--touchme-dark);
  background: var(--touchme-dark);
  color: var(--touchme-light);
}
.nav-region-status {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: right;
}
.nav-region-status.is-error { color: var(--danger); }

/* --- in-page links ------------------------------------------------------- */

.nav-sections { padding-top: 2rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border);}
.nav-list,
.nav-sublist {
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav-group + .nav-group { margin-top: 0.35rem; }
.nav-link {
  display: block;
  padding: 0.35rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
  text-decoration: none;
}
.nav-link-top {
  color: var(--text);
  font-weight: 600;
}
.nav-link:hover {
  background: var(--info-light);
  color: var(--text);
}
.nav-link.is-active {
  border-left-color: var(--info);
  background: var(--info-light);
  color: var(--info-dark);
  font-weight: 600;
}
.nav-sublist {
  margin: 0.15rem 0 0.35rem 0.65rem;
  border-left: 1px solid var(--touchme-dark);
}
.nav-sublist .nav-link {
  padding-left: 0.7rem;
  font-size: 0.8rem;
}
.nav-link:focus-visible {
  outline: 2px solid var(--info-dark);
  outline-offset: -2px;
}

/* team member credit */
.nav-team {
  padding-top: 2rem;
}

/* --- mobile drawer ------------------------------------------------------- */

.nav-toggle {
  position: fixed;
  z-index: 45;
  bottom: 1rem;
  left: 1rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--touchme-dark);
  border-radius: var(--radius-rounded);
  background: var(--bg-white);
  box-shadow: 0 8px 22px rgba(31, 36, 48, 0.16);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: var(--info-dark);
}
.nav-toggle-bars {
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  position: absolute;
  left: 0;
  content: "";
}
.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after { top: 5px; }

.nav-backdrop {
  position: fixed;
  z-index: 38;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  background: rgba(31, 36, 48, 0.4);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* --- page offset --------------------------------------------------------- */

@media (min-width: 1080px) {
  .page-shell { margin-left: var(--sidebar-w); }
  .dashboard-header, .dashboard-footer {
    padding-right: max(2rem, calc((100vw - var(--sidebar-w) - var(--page-max)) / 2));
    padding-left: max(2rem, calc((100vw - var(--sidebar-w) - var(--page-max)) / 2));
  }
}

@media (max-width: 1079px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    width: min(320px, 86vw);
    transform: translateX(-102%);
    box-shadow: 0 0 40px rgba(31, 36, 48, 0.18);
    transition: transform 0.24s ease;
  }
  body.nav-open .site-nav { transform: translateX(0); }
  body.nav-open .nav-backdrop {
    visibility: visible;
    opacity: 1;
  }
  body.nav-open { overflow: hidden; }
}

/* anchor targets clear the viewport edge (and the mobile toggle) */
.story-hero[id],
.story-section[id],
.dashboard-section[id],
.chart-block[id],
.visual-introduction[id],
.section-copy[id] { scroll-margin-top: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-nav,
  .nav-field-message,
  .nav-backdrop { transition: none; }
  .nav-field.is-shaking .nav-combo { animation: none; }
}

/* shared media */
@media (max-width: 900px) {
  .task-header h2 { font-size: 2.25rem; }
  .ks-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .dashboard-header, .dashboard-footer { padding: 1.25rem 1rem; }
  .main { padding-top: 1rem; }
  .task {
    width: calc(100% - 2rem);
    padding: 1.25rem;
    border-radius: 12px;
  }
  .introduction-task { padding: 0; }
  .dashboard-section {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }
  .task-header h2 { font-size: 2rem; }
  .story-hero { padding-top: 40px; }
  .story-section { padding: 52px 16px; }
  .amanda-map-frame { height: 540px; }
  .amanda-tile-frame { height: 500px; }
  .metro-transition {
    margin: 20px 16px 60px;
    padding: 38px 22px;
  }
  .ks-kpi-grid { grid-template-columns: 1fr; }
  #zk-vis { padding-bottom: 0.5rem; }
  .chart-grid { grid-template-columns: 1fr; }
}
