:root {
  color-scheme: light;

  /* palette — matches ideitas.online's main site tokens */
  --bg: #f5ebe0;        /* linen */
  --paper: #edede9;     /* parchment */
  --fg: #14213d;        /* prussian-blue */
  --accent: #d5bdaf;    /* almond-silk */
  --accent-strong: #b8860b;

  --muted: color-mix(in srgb, var(--fg) 55%, transparent);
  --text-2: color-mix(in srgb, var(--fg) 76%, transparent);
  --border-fade: color-mix(in srgb, var(--fg) 16%, transparent);
  --grid: color-mix(in srgb, var(--fg) 9%, transparent);
  --axis: color-mix(in srgb, var(--fg) 24%, transparent);
  --focus: var(--accent-strong);

  --surface: var(--paper);
  --history: #2a6f97;
  --forecast: var(--accent-strong);
  --forecast-band: color-mix(in srgb, var(--accent-strong) 16%, transparent);
  --good: #2f6e44;
  --bad: #a3402f;

  --font-display: "Instrument Serif", "Times New Roman", serif;
  --font-mono: "Courier Prime", "Courier New", monospace;
  --font-rules: "Archivo", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14213d;       /* prussian-blue */
    --paper: #000000;
    --fg: #e5e5e5;       /* alabaster-grey */
    --accent: #fca311;   /* orange */
    --accent-strong: #fca311;

    --muted: color-mix(in srgb, var(--fg) 55%, transparent);
    --text-2: color-mix(in srgb, var(--fg) 78%, transparent);
    --border-fade: color-mix(in srgb, var(--fg) 15%, transparent);
    --grid: color-mix(in srgb, var(--fg) 10%, transparent);
    --axis: color-mix(in srgb, var(--fg) 26%, transparent);

    --history: #5fa8d3;
    --forecast-band: color-mix(in srgb, var(--accent-strong) 22%, transparent);
    --good: #6fcf8f;
    --bad: #e2735a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}
body {
  background:
    radial-gradient(circle at 50% -10%, color-mix(in srgb, var(--accent-strong) 12%, transparent), transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-rules);
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.home-link {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s ease;
}
.home-link:hover { color: var(--accent-strong); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border-fade);
  border-radius: 999px;
  overflow: hidden;
}
.lang-switch button {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-switch button.active { background: var(--fg); color: var(--bg); }
.lang-switch button:not(.active):hover { color: var(--fg); }

header.hero {
  margin-bottom: 30px;
}
header.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  line-height: 1;
  letter-spacing: 0.005em;
  margin: 0 0 12px;
}
header.hero h1 .hl {
  font-style: italic;
  color: var(--accent-strong);
}
header.hero p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 56ch;
}
header.hero .model-tag {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--border-fade);
  border-radius: 999px;
  padding: 5px 14px;
}

form.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  background: var(--paper);
  border: 1px solid var(--border-fade);
  border-radius: 4px;
  padding: 18px;
  margin-bottom: 22px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field[hidden] { display: none; } /* .field's own `display: flex` above would otherwise beat the UA [hidden] rule */
.field label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.field input, .field select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border-fade);
  border-radius: 3px;
  padding: 9px 11px;
  min-width: 0;
  max-width: 100%;
}
.field input#ticker {
  width: 130px;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.field input:focus, .field select:focus, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
button.go {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 999px;
  padding: 11px 26px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
button.go:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--bg); transform: translateY(-1px); }
button.go:disabled { opacity: 0.5; cursor: default; transform: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--border-fade);
  border-radius: 4px;
  padding: 14px 16px;
  transition: border-color 0.18s ease;
}
.stat:hover { border-color: var(--accent-strong); }
.stat .label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.stat .value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat .value.good { color: var(--good); }
.stat .value.bad { color: var(--bad); }
.stat .value.value-text {
  font-family: var(--font-rules);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0;
  line-height: 1.35;
}
.stat .sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 4px;
}

.chart-card {
  background: var(--paper);
  border: 1px solid var(--border-fade);
  border-radius: 4px;
  padding: 18px 18px 10px;
  margin-bottom: 16px;
}
.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-bottom: 6px;
}
.legend .item { display: flex; align-items: center; gap: 7px; }
.legend .swatch { width: 16px; height: 2px; display: inline-block; }
.legend .swatch.history { background: var(--history); }
.legend .swatch.forecast { background: var(--forecast); }
.legend .band { width: 12px; height: 10px; display: inline-block; background: var(--forecast-band); }

svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis-text { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.line-history { fill: none; stroke: var(--history); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-forecast { fill: none; stroke: var(--forecast); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.band-forecast { fill: var(--forecast-band); }
.divider { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.crosshair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.hover-dot { pointer-events: none; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--paper);
  border: 1px solid var(--border-fade);
  border-radius: 4px;
  padding: 9px 11px;
  font-size: 0.78rem;
  color: var(--text-2);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--fg) 18%, transparent);
  transform: translate(-50%, -110%);
  white-space: nowrap;
  visibility: hidden;
  z-index: 5;
}
.tooltip .date { font-family: var(--font-mono); color: var(--muted); font-size: 0.68rem; margin-bottom: 5px; }
.tooltip .row { display: flex; align-items: center; gap: 6px; }
.tooltip .row + .row { margin-top: 2px; }
.tooltip .key { width: 10px; height: 2px; display: inline-block; }
.tooltip .val { font-family: var(--font-mono); font-weight: 700; color: var(--fg); font-variant-numeric: tabular-nums; }

.chart-wrap { position: relative; }

.toggle-table {
  background: none;
  border: none;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 4px;
}
.table-wrap { overflow-x: auto; display: none; margin-top: 6px; }
.table-wrap.open { display: block; }
table.forecast-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
table.forecast-table th, table.forecast-table td {
  text-align: right;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.forecast-table th:first-child, table.forecast-table td:first-child { text-align: left; }
table.forecast-table th { color: var(--muted); font-weight: 700; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }

.status {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 26px 4px;
}
.status.error { color: var(--bad); }

footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
  border-top: 1px solid var(--border-fade);
  padding-top: 18px;
}
footer strong {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--text-2);
}
footer a { color: inherit; }

@media (max-width: 480px) {
  .field input#ticker { width: 100px; }
  header.hero h1 { font-size: 1.9rem; }
}
