/* ============================================================
   KiwiSaver Copilot — BNZ-elevated concept
   Brand anchors from bnz.co.nz: navy #002F6B, action blue
   #007DBC, CTA green #20882E, humanist headings.
   Light-first; dark via html[data-theme="dark"].
   ============================================================ */

:root {
  --page: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --ink: #1c2839;
  --ink-2: #46556c;
  --muted: #7d8a9e;
  --heading: #002f6b;
  --border: rgba(0, 47, 107, 0.10);
  --hairline: rgba(0, 47, 107, 0.08);
  --grid: #eceff4;
  --axis: #d5dbe4;
  --navy: #002f6b;
  --navy-2: #00255a;
  --navy-ink: #ffffff;
  --accent: #007dbc;
  --accent-deep: #00679a;
  --accent-soft: rgba(0, 125, 188, 0.09);
  --green: #20882e;
  --green-deep: #1a7326;
  --series-1: #007dbc;
  --series-base: #93a3b8;
  --neg: #cf4444;
  --pos: #007dbc;
  --good: #1e7c2c;
  --wash: rgba(0, 125, 188, 0.07);
  --tooltip-bg: #14213a;
  --tooltip-ink: #f2f5fa;
  --flash: rgba(0, 125, 188, 0.4);
  --shadow: 0 1px 2px rgba(0, 31, 75, 0.05), 0 10px 30px rgba(0, 31, 75, 0.07);
  --radius: 16px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --page: #0c1220;
  --surface: #151d2e;
  --surface-2: #1c2740;
  --ink: #e9edf4;
  --ink-2: #b3bdcd;
  --muted: #7f8ba0;
  --heading: #dbe6f7;
  --border: rgba(159, 186, 228, 0.16);
  --hairline: rgba(159, 186, 228, 0.11);
  --grid: #212c44;
  --axis: #33405c;
  --navy: #0a1730;
  --navy-2: #08122a;
  --navy-ink: #ffffff;
  --accent: #3aa0e0;
  --accent-deep: #66b6e8;
  --accent-soft: rgba(58, 160, 224, 0.14);
  --green: #2f9e3e;
  --green-deep: #38b049;
  --series-1: #3aa0e0;
  --series-base: #5f6f88;
  --neg: #e66767;
  --pos: #3aa0e0;
  --good: #57b380;
  --wash: rgba(58, 160, 224, 0.10);
  --tooltip-bg: #263553;
  --tooltip-ink: #edf1f8;
  --flash: rgba(58, 160, 224, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 34px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
  font-feature-settings: "cv05", "cv11";
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3, .hero-value, .brand-name {
  font-family: "Fira Sans", "Inter", -apple-system, sans-serif;
  color: var(--heading);
}

svg { display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }
a { color: var(--accent-deep); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.muted { color: var(--muted); font-weight: 400; }

::selection { background: rgba(0, 125, 188, 0.22); }

/* ---------- Top bar + hero band (one navy block) ---------- */

.masthead {
  background:
    radial-gradient(760px 360px at 82% -14%, rgba(0, 125, 188, 0.4), transparent 68%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
}
html[data-theme="dark"] .masthead {
  background:
    radial-gradient(760px 360px at 82% -14%, rgba(58, 160, 224, 0.17), transparent 68%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 28px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { width: 27px; height: 27px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-size: 15.5px; font-weight: 600; letter-spacing: -0.005em; color: #fff; }
.brand-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.62); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  transition: background 0.15s ease;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.12); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.persona {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 13px 5px 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #fff;
}
.persona-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
  flex: none;
}
.persona-text { display: flex; flex-direction: column; line-height: 1.25; }
.persona-name { font-size: 12.5px; font-weight: 600; }
.persona-meta { font-size: 11px; color: rgba(255, 255, 255, 0.62); }

.hero-band { padding-bottom: 84px; }
.hero-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-greeting {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.15;
}
.hero-context {
  margin-top: 7px;
  font-size: 14.5px;
  color: rgba(255, 255, 255, 0.78);
  max-width: 54ch;
}
.hero-context strong { color: #fff; font-weight: 600; }

.scenario-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 7px 14px;
  backdrop-filter: blur(4px);
}
.scenario-dot {
  flex: none;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6ec5f5;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(110, 197, 245, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(110, 197, 245, 0); }
}

/* ---------- Page frame ---------- */

.page {
  max-width: 1180px;
  margin: -64px auto 0;   /* cards overlap the navy band */
  padding: 0 28px 48px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  gap: 20px;
  align-items: start;
}

.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.card.flash { animation: cardFlash 1.6s ease; }
@keyframes cardFlash {
  0% { box-shadow: 0 0 0 2px var(--flash), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}

.kicker {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 6px;
}

.card-head { margin-bottom: 18px; }
.card-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 13px; color: var(--ink-2); margin-top: 5px; max-width: 58ch; }

.footnote { font-size: 12px; color: var(--muted); margin-top: 10px; max-width: 68ch; }

/* ---------- Balance card ---------- */

.balance-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 10px;
}

.hero-value {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin-top: 3px;
}

.hero-deltas { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.delta-chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  font-feature-settings: "tnum";
}
.delta-down { color: var(--neg); background: rgba(207, 68, 68, 0.09); }
.delta-up { color: var(--good); background: rgba(30, 124, 44, 0.10); }
html[data-theme="dark"] .delta-down { background: rgba(230, 103, 103, 0.14); }
html[data-theme="dark"] .delta-up { background: rgba(87, 179, 128, 0.14); }
.hero-asat { font-size: 11.5px; color: var(--muted); margin-top: 9px; }

/* ---------- Charts (shared) ---------- */

.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; }
.chart-wrap svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

.gridline { stroke: var(--grid); stroke-width: 1; }
.gridline-minor { opacity: 0.55; }
.axisline { stroke: var(--axis); stroke-width: 1; }
.tick-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: "Inter", sans-serif;
  font-feature-settings: "tnum";
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0, 10, 30, 0.3);
  z-index: 5;
  max-width: 240px;
}
.chart-tooltip .tt-date { color: rgba(242, 245, 250, 0.62); font-size: 11px; display: block; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.chart-tooltip .tt-key { width: 12px; height: 0; border-top: 2px solid; flex: none; }
.chart-tooltip .tt-val { font-weight: 650; font-feature-settings: "tnum"; }

.crosshair { stroke: var(--axis); stroke-width: 1; }
.hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.balance-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 1.5;
  stroke-linejoin: miter;
  stroke-miterlimit: 3;
}
.balance-area { fill: var(--wash); }

.milestone-dot { fill: var(--surface); stroke: var(--green); stroke-width: 1.8; }
.milestone-label { font-size: 10.5px; font-weight: 650; fill: var(--good); font-family: "Inter", sans-serif; font-feature-settings: "tnum"; }

.end-label { font-size: 11.5px; font-weight: 650; fill: var(--ink); font-family: "Inter", sans-serif; font-feature-settings: "tnum"; }
.end-label-sub { font-size: 10.5px; fill: var(--muted); font-family: "Inter", sans-serif; }

/* Annotation markers on the chart */
.anno-marker { cursor: pointer; }
.anno-marker circle.badge {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.4;
}
.anno-marker text {
  fill: var(--accent);
  font-size: 10.5px;
  font-weight: 650;
  font-family: "Inter", sans-serif;
}
.anno-marker line.stem { stroke: var(--accent); stroke-width: 1; opacity: 0.4; }
.anno-marker:hover circle.badge,
.anno-marker.is-active circle.badge { fill: var(--accent); }
.anno-marker:hover text,
.anno-marker.is-active text { fill: #fff; }
.anno-marker:focus-visible { outline: none; }
.anno-marker:focus-visible circle.badge { stroke-width: 2.6; }

/* Annotation cards below the chart */
.anno-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--hairline);
}
.anno-kicker {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-deep);
}
.anno-hint { font-size: 11.5px; color: var(--muted); text-align: right; }

.annotations {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 20px;
  margin-top: 6px;
}
.annotations li { min-width: 0; }
.anno-card {
  width: 100%;
  display: flex;
  gap: 11px;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  transition: background 0.15s ease;
}
.anno-card:hover { background: var(--surface-2); }
.anno-card.is-active { background: var(--accent-soft); }
.anno-num {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 1.4px solid var(--accent);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 650;
  margin-top: 1px;
  transition: background 0.15s ease, color 0.15s ease;
}
.anno-card.is-active .anno-num { background: var(--accent); color: #fff; }
.anno-body { min-width: 0; font-size: 12.5px; color: var(--ink-2); }
.anno-body strong { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 1px; letter-spacing: -0.005em; }

/* ---------- Details / disclosure (custom, no default triangle) ---------- */

details.table-view { margin-top: 16px; border-top: 1px solid var(--hairline); padding-top: 12px; }
details.table-view summary,
.judges-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  width: fit-content;
  padding: 5px 10px 5px 8px;
  margin-left: -8px;
  border-radius: 9px;
  transition: background 0.15s ease, color 0.15s ease;
  list-style: none;
}
details.table-view summary:hover, .judges-summary:hover { background: var(--surface-2); color: var(--ink); }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }

.chev {
  flex: none;
  width: 7px; height: 7px;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  transition: transform 0.22s cubic-bezier(0.3, 0.8, 0.4, 1);
  opacity: 0.75;
}
details[open] > summary .chev { transform: rotate(45deg) translate(-1px, -2px); }

details > *:not(summary) { animation: detailsIn 0.28s ease; }
@keyframes detailsIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.table-scroll { overflow-x: auto; margin-top: 10px; }

table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td {
  text-align: left;
  padding: 6px 14px 6px 0;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
th { font-weight: 600; color: var(--ink-2); font-size: 11.5px; }
td { font-feature-settings: "tnum"; color: var(--ink-2); }
td:first-child { color: var(--ink); }

.assumptions { font-size: 12.5px; color: var(--ink-2); margin-top: 10px; max-width: 66ch; }

/* ---------- Waterfall ---------- */

.wf-bar-pos { fill: var(--pos); }
.wf-bar-neg { fill: var(--neg); }
.wf-bar-total { fill: var(--series-base); }
.wf-label { font-size: 11px; font-weight: 600; fill: var(--ink-2); font-family: "Inter", sans-serif; font-feature-settings: "tnum"; }
.wf-cat { font-size: 11px; fill: var(--muted); font-family: "Inter", sans-serif; }

/* ---------- Planner ---------- */

.planner-controls { display: flex; flex-direction: column; gap: 18px; margin-bottom: 20px; }

.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.control-label strong { color: var(--heading); font-weight: 650; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  width: fit-content;
  background: var(--surface-2);
  gap: 2px;
}
.seg-btn {
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
  background: var(--surface);
  color: var(--heading);
  box-shadow: 0 1px 3px rgba(0, 31, 75, 0.12);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 71%), var(--grid) var(--fill, 71%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.7px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0, 31, 75, 0.22);
  cursor: grab;
  transition: transform 0.12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.7px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0, 31, 75, 0.22);
  cursor: grab;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  font-feature-settings: "tnum";
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-tile {
  border: 1px solid var(--hairline);
  border-radius: 13px;
  padding: 13px 15px 12px;
  transition: border-color 0.2s ease;
}
.stat-tile.accent { border-color: rgba(0, 125, 188, 0.35); background: var(--accent-soft); }
.stat-value { font-size: 21px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.15; color: var(--heading); font-feature-settings: "tnum"; }
.stat-label { font-size: 11px; line-height: 1.35; font-weight: 550; color: var(--ink-2); margin-top: 7px; min-height: 29.7px; }
.stat-sub { font-size: 10.5px; line-height: 1.35; color: var(--muted); margin-top: 2px; font-feature-settings: "tnum"; }
.stat-delta.up { color: var(--good); }
.stat-delta.down { color: var(--neg); }

.legend { display: flex; gap: 18px; margin-bottom: 6px; flex-wrap: wrap; }
.lg-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.lg-line { width: 14px; height: 0; border-top: 2px solid; flex: none; }
.lg-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.proj-line { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.proj-band { fill: var(--wash); }

.govt-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface-2);
  border-radius: 13px;
  padding: 14px 16px;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.govt-card strong { color: var(--ink); }
.govt-tick {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid; place-items: center;
  margin-top: 1px;
}

/* ---------- Fund fit ---------- */

.fit-factors { list-style: none; display: flex; flex-direction: column; }
.fit-factors li {
  display: flex;
  gap: 13px;
  padding: 13px 2px;
  font-size: 13px;
  color: var(--ink-2);
}
.fit-factors li + li { border-top: 1px solid var(--hairline); }
.fit-factors strong { color: var(--ink); font-weight: 600; }
.fit-icon {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid; place-items: center;
}
.fit-icon svg { width: 18px; height: 18px; }

.fit-boundary {
  margin-top: 14px;
  background: var(--surface-2);
  border-radius: 13px;
  padding: 16px 18px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}
.fit-boundary p { max-width: 52ch; }
.fit-boundary strong { color: var(--ink); }

.btn-primary {
  background: var(--green);
  color: #fff;
  font-size: 13.5px;
  font-weight: 650;
  padding: 11px 20px;
  border-radius: 10px;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  flex: none;
  box-shadow: 0 1px 3px rgba(0, 60, 20, 0.25);
}
.btn-primary:hover { background: var(--green-deep); box-shadow: 0 3px 9px rgba(0, 60, 20, 0.28); }
.btn-primary:active { transform: scale(0.98); }

/* ---------- Judges card + resources ---------- */

.judges-card { padding: 10px 28px 22px; }
.judges-summary { font-size: 13px; margin: 8px 0 0 -8px; }
.judges-body { padding: 14px 0 8px; }
.judges-lead { font-size: 13px; color: var(--ink-2); max-width: 68ch; }
.judges-lead strong { color: var(--ink); }

.arch {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 18px 0;
  flex-wrap: wrap;
}
.arch-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  min-width: 150px;
  color: var(--ink);
}
.arch-box small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.arch-tag {
  display: block;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 3px;
}
.arch-arrow { align-self: center; color: var(--muted); font-size: 15px; }
.arch-col { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 220px; }

.judges-list { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; color: var(--ink-2); max-width: 72ch; }
.judges-list strong { color: var(--ink); }

.resources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}
.resource-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.resource-link:hover {
  border-color: rgba(0, 125, 188, 0.4);
  box-shadow: 0 4px 14px rgba(0, 31, 75, 0.08);
  transform: translateY(-1px);
}
.resource-link strong { display: block; font-size: 13px; font-weight: 600; color: var(--heading); }
.resource-link small { color: var(--muted); }
.resource-icon {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid; place-items: center;
}
.resource-icon svg { width: 19px; height: 19px; }

/* ---------- Chat ---------- */

.col-chat {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  max-height: 780px;
  min-width: 0;
}

.chat-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 13px;
  border-bottom: 1px solid var(--hairline);
}
.chat-title {
  display: block;
  font-family: "Fira Sans", "Inter", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  color: var(--heading);
}
.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.status-dot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #35a852;
  box-shadow: 0 0 0 2.5px rgba(53, 168, 82, 0.18);
}
.chat-badge {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg { max-width: 88%; }
.msg-bot { align-self: flex-start; animation: msgIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.05); }
.msg-user { align-self: flex-end; animation: msgIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.05); }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.msg-bubble {
  border-radius: 15px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}
.msg-bot .msg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.msg-user .msg-bubble {
  background: var(--navy);
  color: var(--navy-ink);
  border-bottom-right-radius: 5px;
}
html[data-theme="dark"] .msg-user .msg-bubble { background: var(--accent); }
.msg-bubble strong { font-weight: 650; }

.msg-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip {
  font-size: 12px;
  font-weight: 550;
  color: var(--accent-deep);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  transition: background 0.15s ease, border-color 0.15s ease;
  animation: chipIn 0.35s ease backwards;
}
.chip:hover { background: var(--accent-soft); border-color: transparent; }
.chip:nth-child(2) { animation-delay: 0.06s; }
.chip:nth-child(3) { animation-delay: 0.12s; }
.chip:nth-child(4) { animation-delay: 0.18s; }
@keyframes chipIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 15px;
  border-bottom-left-radius: 5px;
  align-self: flex-start;
}
.typing span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingDot 1.1s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-inputrow {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
}
#chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease;
}
#chat-input::placeholder { color: var(--muted); }
#chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-send {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chat-send:hover { background: var(--accent-deep); }
html[data-theme="dark"] .chat-send:hover { background: var(--accent); filter: brightness(1.15); }
.chat-send:active { transform: scale(0.94); }

.chat-disclaimer {
  font-size: 10.5px;
  color: var(--muted);
  padding: 0 16px 12px;
  text-align: center;
}

/* ---------- Footer ---------- */

.footer {
  margin-top: 30px;
  font-size: 11.5px;
  color: var(--muted);
  max-width: 88ch;
  line-height: 1.6;
}
.footer strong { color: var(--ink-2); font-weight: 600; }
.footer-links { margin-top: 10px; display: flex; gap: 18px; }
.footer-links a { color: var(--accent-deep); font-weight: 550; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 10, 30, 0.35);
  z-index: 50;
  max-width: min(480px, calc(100vw - 40px));
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Motion ---------- */

.reveal { opacity: 0; transform: translateY(10px); transition: opacity 0.5s ease, transform 0.5s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

.balance-line.draw {
  stroke-dasharray: var(--path-len);
  stroke-dashoffset: var(--path-len);
  animation: lineDraw 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.15s forwards;
}
@keyframes lineDraw { to { stroke-dashoffset: 0; } }

.balance-area.draw { opacity: 0; animation: areaIn 0.7s ease 1.2s forwards; }
@keyframes areaIn { to { opacity: 1; } }

.anno-marker.pop { opacity: 0; animation: popIn 0.4s cubic-bezier(0.3, 1.4, 0.5, 1) forwards; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.4); transform-origin: center; transform-box: fill-box; }
  to { opacity: 1; transform: scale(1); transform-origin: center; transform-box: fill-box; }
}

.wf-anim rect { transform-origin: bottom; animation: wfGrow 0.5s cubic-bezier(0.3, 0.9, 0.4, 1) backwards; transform-box: fill-box; }
@keyframes wfGrow {
  from { opacity: 0; transform: scaleY(0.3); }
  to { opacity: 1; transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
  .balance-line.draw { stroke-dasharray: none; stroke-dashoffset: 0; }
  .balance-area.draw { opacity: 1; }
  .anno-marker.pop { opacity: 1; }
  .chat-log { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .col-chat { position: static; height: auto; max-height: none; }
  .chat-card { height: 560px; }
  .resources { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page { padding: 0 16px 40px; margin-top: -58px; }
  .topbar-inner { padding: 12px 16px 8px; }
  .hero-inner { padding: 22px 16px 0; }
  .hero-band { padding-bottom: 76px; }
  .hero-greeting { font-size: 25px; }
  .brand-sub { display: none; }
  .persona-text { display: none; }
  .persona { padding: 4px; border: none; }
  .card { padding: 20px 18px; }
  .judges-card { padding: 8px 18px 18px; }
  .hero-value { font-size: 33px; }
  .anno-hint { display: none; }
  .annotations { grid-template-columns: 1fr; }
  .stat-label { min-height: 0; }
  .fit-boundary { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; }
  .arch { flex-direction: column; }
  .arch-arrow { display: none; }
}
