/* Fear & Greed charts: tokens per the dataviz reference palette; both dark
   scopes declared so an OS setting or a future toggle both win correctly. */

.viz-root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  /* diverging fear<->greed bands (red arm, gray mid, blue arm) */
  --band-ef: #c93635;
  --band-f:  #ee9d9c;
  --band-n:  #f0efec;
  --band-g:  #9ec5f4;
  --band-eg: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --band-ef: #e66767;
    --band-f:  #7e4341;
    --band-n:  #383835;
    --band-g:  #2a5a8f;
    --band-eg: #3987e5;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --band-ef: #e66767;
  --band-f:  #7e4341;
  --band-n:  #383835;
  --band-g:  #2a5a8f;
  --band-eg: #3987e5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding: 0 1rem;
}
.page-head, main, footer { max-width: 72rem; margin: 0 auto; }
.page-head { padding-top: 2rem; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.src { color: var(--ink-2); margin: 0.25rem 0 0; font-size: 0.85rem; }
.src a { color: var(--series-1); }
.loading { color: var(--muted); padding: 3rem 0; }

/* cards */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem 0.8rem;
  margin-top: 1rem;
}
.card h2 { margin: 0; font-size: 1rem; }
.card .sub { margin: 0.1rem 0 0.4rem; color: var(--muted); font-size: 0.8rem; }

/* hero: dial + history tiles */
.hero { display: grid; gap: 1rem; margin-top: 1rem; }
@media (min-width: 52rem) { .hero { grid-template-columns: 22rem 1fr; } }
.hero .card { margin-top: 0; }
.dial-wrap { text-align: center; }
.dial-score { font-size: 2.6rem; font-weight: 700; line-height: 1.1; margin-top: -0.4rem; }
.dial-rating { color: var(--ink-2); font-size: 1.05rem; }
.hist-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-top: 0.8rem; }
.tile { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.7rem; }
.tile .k { color: var(--muted); font-size: 0.78rem; }
.tile .v { font-weight: 700; font-size: 1.15rem; }
.tile .r { color: var(--ink-2); font-size: 0.8rem; }

/* indicator grid */
.grid { display: grid; gap: 1rem; margin-top: 1rem; }
@media (min-width: 52rem) { .grid { grid-template-columns: 1fr 1fr; } }

.scorechip { color: var(--ink-2); font-size: 0.85rem; margin: 0.15rem 0 0.3rem; }
.scorechip b { color: var(--ink); }

/* chart svg */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--muted); }
.chart .endlabel { font-size: 11px; fill: var(--ink-2); font-weight: 600; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--baseline); stroke-width: 1; }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crosshair { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }

/* legend */
.legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--ink-2); margin: 0.2rem 0 0.2rem; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* tooltip */
.tip {
  position: absolute; pointer-events: none; display: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0.55rem; font-size: 0.78rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12); white-space: nowrap; z-index: 2;
}
.tip .d { color: var(--muted); }

/* data table (accessibility channel) */
details { margin-top: 0.4rem; font-size: 0.8rem; color: var(--ink-2); }
details table { border-collapse: collapse; margin-top: 0.4rem; max-height: 14rem; }
details .scroll { max-height: 14rem; overflow: auto; }
details td, details th { padding: 0.15rem 0.7rem 0.15rem 0; text-align: left; font-variant-numeric: tabular-nums; }

footer { padding: 2rem 0 3rem; color: var(--muted); font-size: 0.8rem; }
.error { color: var(--ink); background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-top: 1.5rem; }
