/* PandaForecast: stock-terminal look. Dark (default) and Light themes; the
   Dark/Light switch in the header sets html[data-theme]. */
:root {
  --bg: #0b1220;
  --card: #111a2e;
  --card-2: #16213a;
  --line: #22304d;
  --grid: #1b2742;
  --ink: #e6ecf7;
  --ink-2: #a9b5cc;
  --mute: #7385a6;
  --up: #22c55e;
  --down: #ef4444;
  --fan: #38bdf8;
  --gold: #f5b942;
  --focus: #7dd3fc;
  --on-accent: #04121f;
  --err: #fca5a5;
  --tip-bg: #0a1020f2;
  --legend-bg: #0b1220d9;
  --shadow: rgba(0,0,0,.45);
  --logo-outline: drop-shadow(1px 0 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 1px 0 #fff) drop-shadow(0 -1px 0 #fff);
  --head: "Space Grotesk", system-ui, sans-serif;
  color-scheme: dark;
}
/* Light theme: same layout, paper-white cards, deeper accents so lines and
   text keep their contrast on white. */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --card: #ffffff;
  --card-2: #eef2f8;
  --line: #d3dbe8;
  --grid: #e6ebf3;
  --ink: #0f1a2e;
  --ink-2: #3b4963;
  --mute: #5f6e8a;
  --up: #15803d;
  --down: #dc2626;
  --fan: #0284c7;
  --gold: #b45309;
  --focus: #0369a1;
  --on-accent: #ffffff;
  --err: #b91c1c;
  --tip-bg: #fffffff5;
  --legend-bg: #ffffffd9;
  --shadow: rgba(15,26,46,.16);
  --logo-outline: none;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 14px 16px 40px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.top { display: flex; align-items: center; min-height: 52px; padding-right: 150px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img {
  height: 40px; width: auto; display: block;
  /* thin white die-cut outline so the black body reads on dark blue */
  filter: var(--logo-outline);
}
.brand-name { font: 600 21px/1 var(--head); letter-spacing: -0.01em; }

/* Dark / Light switch, top right of the header, always visible. */
.top { flex-wrap: wrap; gap: 8px 12px; }
.themeseg { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.themeseg-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.themeseg .opts { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.themeseg button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; cursor: pointer; background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: 14px;
}
.themeseg button svg { width: 16px; height: 16px; flex: none; }
.themeseg button[aria-checked="true"] { background: var(--fan); color: var(--on-accent); }
.themeseg button:hover:not([aria-checked="true"]) { color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 14px; }
.lede { margin: 0 0 12px; color: var(--ink-2); }
.idrow { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld label, .ctl-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
#idBox {
  width: 13ch; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); font: 600 20px/1 var(--head); letter-spacing: 0.06em;
}
#idBox::placeholder { color: var(--mute); font-weight: 500; letter-spacing: 0; font-size: 16px; }
.btn-primary {
  min-height: 44px; padding: 0 20px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--fan); color: var(--on-accent); font-weight: 700;
}
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--mute); }
.chip {
  margin-left: 4px; padding: 3px 10px; min-height: 28px; border-radius: 999px; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px;
}
.chip:hover { border-color: var(--fan); color: var(--ink); }
.status { margin: 10px 0 0; min-height: 1.5em; color: var(--ink-2); }
.status.err { color: var(--err); }
.status:empty { display: none; }

.who { margin-top: 22px; }
.who h1 { margin: 0; font: 600 28px/1.15 var(--head); letter-spacing: -0.015em; }
.meta { margin: 4px 0 0; color: var(--mute); font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }
.tile .v { font: 600 26px/1.15 var(--head); margin-top: 4px; }
.tile .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.ahead-title { grid-column: 1 / -1; margin: 6px 0 -2px; font: 600 16px/1.3 var(--head); color: var(--ink-2); }
.tile.mid .v { color: var(--fan); }

.chartcard { padding: 12px 12px 10px; }
.charthead { display: flex; justify-content: flex-start; margin-bottom: 8px; }
.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button {
  min-width: 46px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 14px;
}
.tabs button[aria-selected="true"] { background: var(--card-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.chartbox { position: relative; width: 100%; touch-action: pan-y; }
#chart { display: block; width: 100%; height: auto; overflow: visible; user-select: none; -webkit-user-select: none; }
.chartnote { margin: 8px 4px 0; font-size: 13px; color: var(--ink-2); }
.gold-note { color: var(--gold); }

.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px; max-width: 250px;
  background: var(--tip-bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px var(--shadow);
}
.tip .tv { font: 600 18px/1.2 var(--head); }
.tip .td { color: var(--mute); font-size: 12px; }
.tip .te { color: var(--ink-2); }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .key { width: 12px; height: 2px; border-radius: 1px; flex: none; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.ctl { min-width: 0; }
.ctl-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ctl-label output { font: 600 16px/1 var(--head); color: var(--ink); }
.ctl.is-off { opacity: 0.45; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--ink-2); font-weight: 600;
}
.seg button[aria-checked="true"] { background: var(--fan); color: var(--on-accent); }
input[type="range"] { width: 100%; height: 32px; accent-color: var(--fan); margin: 0; }
input[type="range"]:disabled { cursor: not-allowed; }
.switches { display: flex; flex-direction: column; }
.switches .hint { margin: 2px 0 12px 56px; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 40px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch input:checked + .track { background: var(--fan); }
#ashSw:checked + .track { background: var(--gold); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.sw-text { font-weight: 600; }

.tablecard summary { cursor: pointer; font-weight: 600; color: var(--ink-2); min-height: 32px; display: flex; align-items: center; }
.tablewrap { max-height: 420px; overflow: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--mute); font-weight: 600; position: sticky; top: 0; background: var(--card); }
.num { text-align: right; }
td.up { color: var(--up); }
td.down { color: var(--down); }

.foot { margin-top: 28px; color: var(--mute); font-size: 12px; }

/* SVG chart parts */
.ax text { fill: var(--mute); font-size: 11px; }
.ax line { stroke: var(--grid); stroke-width: 1; }
.ax .base { stroke: var(--line); }
.today-line { stroke: var(--mute); stroke-width: 1; stroke-dasharray: 3 4; }
.today-label { fill: var(--mute); font-size: 11px; }
.legend text { fill: var(--ink-2); font-size: 11px; }
.legend-bg { fill: var(--legend-bg); stroke: var(--line); }
.cross { stroke: var(--ink-2); stroke-width: 1; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles .tile:first-child { grid-column: 1 / -1; }
  .tiles-3 { grid-template-columns: repeat(3, 1fr); }
  .tiles-3 .tile:first-child { grid-column: auto; }
  .tiles-3 .tile { padding: 10px; }
  .tiles-3 .tile .v { font-size: 21px; }
  .controls { grid-template-columns: 1fr; }
  .who h1 { font-size: 23px; }
  .tile .v { font-size: 22px; }
}
@media (max-width: 560px) {
  /* The switch drops to its own full-width row under the logo on phones. */
  .themeseg { margin-left: 0; width: 100%; }
  .themeseg .opts { flex: 1; }
  .themeseg button { flex: 1; justify-content: center; }
}
@media (max-width: 420px) {
  .top { padding-right: 140px; }
  .themeseg { margin-right: -140px; width: calc(100% + 140px); }
  .brand-name { font-size: 18px; }
  .chartcard { padding: 10px 6px 8px; }
  .tabs button { min-width: 0; padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- 1.2.0: name search, info buttons, fold-out ---------- */
.fld { flex: 1 1 240px; max-width: 420px; min-width: 0; }
.combo { position: relative; }
#idBox { width: 100%; letter-spacing: 0.01em; font-size: 18px; }
.namelist {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  margin: 0; padding: 4px; list-style: none; max-height: min(60vh, 420px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 28px var(--shadow);
}
.namelist[hidden] { display: none; }
.nl-opt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.nl-opt[aria-selected="true"] { background: var(--card-2); box-shadow: inset 3px 0 0 var(--fan); }
.nl-name { font-weight: 600; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.nl-meta { flex: none; font-size: 12px; color: var(--mute); white-space: nowrap; }
.nl-meta strong { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.nl-note { padding: 8px 10px; font-size: 12px; color: var(--mute); }

/* The small circled "i": an 18px drawing inside a 44px tap area. */
.info {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; margin: -13px -12px -13px -8px; padding: 0;
  border: 0; background: transparent; color: var(--mute); cursor: pointer; vertical-align: middle;
  border-radius: 50%;
}
.info svg { width: 18px; height: 18px; display: block; opacity: 0.8; }
.info:hover svg, .info[aria-expanded="true"] svg { opacity: 1; }
.info:hover, .info[aria-expanded="true"] { color: var(--fan); }
.lbl-l { display: inline-flex; align-items: center; gap: 4px; }
.ctl-label .lbl-l label { font: inherit; color: inherit; }
.swrow { display: flex; align-items: center; gap: 2px; }
.charthead { align-items: center; gap: 10px; }
.ahead-title { display: flex; align-items: center; gap: 4px; }

.infopop {
  position: absolute; z-index: 30; padding: 10px 12px;
  background: var(--tip-bg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow); color: var(--ink-2); font-size: 13px; line-height: 1.5;
}
.infopop[hidden] { display: none; }
.infopop p { margin: 0; }
.infopop b { color: var(--ink); }

.howcard summary { cursor: pointer; font-weight: 600; color: var(--ink-2); min-height: 32px; display: flex; align-items: center; }
.howbody { font-size: 14px; line-height: 1.55; color: var(--ink-2); max-width: 70ch; }
.howbody b { color: var(--ink); }
.tile .s2 { color: var(--mute); }

/* 1.3.0: chance of getting there (milestone odds) and the saved-copy line */
.stale-note { font-size: 13px; }
.goalcard .ahead-title { margin: 0 0 8px; }
.goalrow { display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(60px, 1.2fr); gap: 4px 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.goalrow:first-child { border-top: 0; }
.g-name { font-size: 14px; }
.g-pct { font: 600 16px/1.2 var(--head); text-align: right; }
.g-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.g-bar i { display: block; height: 100%; width: 0; background: var(--fan); border-radius: 3px; }
.g-when { grid-column: 1 / -1; font-size: 12px; color: var(--mute); margin-top: -2px; }
.g-when:empty { display: none; }
.goalrow-mine { border-top: 1px solid var(--line); }
.goalrow-mine input { width: 6.5em; margin-left: 6px; font: inherit; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg, transparent); color: inherit; }
.goalnote { font-size: 13px; color: var(--ink-2); margin: 0 0 4px; }
