:root,
:root[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-2: #0f141c;
  --panel: #131923;
  --panel-2: #1a212d;
  --panel-3: #232c3b;
  --border: #232c3b;
  --border-2: #2c3647;
  --text: #e7ecf3;
  --text-dim: #a9b3c4;
  --muted: #6b7689;
  --accent: #f7931a;
  --accent-dim: rgba(247, 147, 26, 0.15);
  --accent-glow: rgba(247, 147, 26, 0.35);
  --green: #16c784;
  --green-dim: rgba(22, 199, 132, 0.14);
  --red: #ea3943;
  --red-dim: rgba(234, 57, 67, 0.14);
  --blue: #4f8cff;
  --topbar-bg: rgba(11, 14, 19, 0.85);
  --grid-line: rgba(255, 255, 255, 0.04);
  --tooltip-bg: rgba(15, 20, 28, 0.95);
  --bg-radial-1: rgba(247, 147, 26, 0.07);
  --bg-radial-2: rgba(79, 140, 255, 0.05);
  --shadow-card: 0 0 0 transparent;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg: #f5f6fa;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f3f5f9;
  --panel-3: #e9edf4;
  --border: #e3e7ee;
  --border-2: #d2d8e3;
  --text: #131722;
  --text-dim: #4b5568;
  --muted: #7a8499;
  --accent: #f7931a;
  --accent-dim: rgba(247, 147, 26, 0.12);
  --accent-glow: rgba(247, 147, 26, 0.25);
  --green: #0fa674;
  --green-dim: rgba(15, 166, 116, 0.12);
  --red: #d72c3a;
  --red-dim: rgba(215, 44, 58, 0.10);
  --blue: #2f6ff0;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --grid-line: rgba(19, 23, 34, 0.06);
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --bg-radial-1: rgba(247, 147, 26, 0.10);
  --bg-radial-2: rgba(47, 111, 240, 0.06);
  --shadow-card: 0 1px 2px rgba(19, 23, 34, 0.04), 0 4px 16px rgba(19, 23, 34, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, var(--bg-radial-1), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, var(--bg-radial-2), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ───── Top bar ─────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f7931a 0%, #ffb14a 100%);
  color: #1a1208;
  font-weight: 800;
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px var(--accent-glow);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: -0.1px; font-size: 15px; }
.brand-tag { font-size: 11px; color: var(--muted); letter-spacing: 0.3px; text-transform: uppercase; }

.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.topnav a:hover { color: var(--text); background: var(--panel-2); }
.topnav a.active { color: var(--accent); background: var(--accent-dim); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ───── API key pill in topbar ──────────────────────────────────── */

.key-anchor { position: relative; display: inline-flex; }
.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.key-pill:hover { color: var(--text); border-color: var(--border-2); }
.key-pill .key-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.key-pill.has-key .key-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.key-pill.has-key { color: var(--green); border-color: rgba(22,199,132,0.4); background: var(--green-dim); }
.key-pill .key-label { font-variant-numeric: tabular-nums; }

.key-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  padding: 12px;
  z-index: 70;
}
.key-pop[hidden] { display: none; }
.key-pop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.key-pop p { margin: 0 0 10px; }
.key-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 10px;
}
.key-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.key-pop-actions { display: flex; gap: 8px; justify-content: flex-end; }
.key-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}
.key-btn:hover { border-color: var(--accent); color: var(--accent); }
.key-btn.primary {
  background: var(--accent);
  color: #1a1208;
  border-color: var(--accent);
}
.key-btn.primary:hover { color: #1a1208; filter: brightness(1.05); }

.auth-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--red-dim);
  color: var(--red);
  border-bottom: 1px solid var(--red);
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.auth-banner a { color: var(--red); text-decoration: underline; }
.auth-banner.warn {
  background: var(--accent-dim);
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.auth-banner.warn a { color: var(--accent); }

/* ───── API docs page ───────────────────────────────────────────── */

.docs {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.docs .card { padding: 26px 30px; }
.docs-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.docs-lede {
  font-size: 14.5px;
  color: var(--text-dim);
  line-height: 1.65;
  margin: 0 0 18px;
}
.docs-h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.15px;
}
.docs-h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.docs p { line-height: 1.65; margin: 0 0 14px; }
.docs code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}
.docs pre {
  margin: 4px 0 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.docs pre code { all: unset; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; }
.docs-list { line-height: 1.7; padding-left: 18px; margin: 0; }
.docs-list li { margin-bottom: 4px; }
.docs-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 14px;
  background: var(--panel-2);
}
.docs-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 0;
}
.docs-details summary:hover { color: var(--text); }
.docs-details pre { margin-top: 6px; }

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.docs-fact {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.docs-fact-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.docs-fact-value {
  background: transparent;
  padding: 0;
  border: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.4px;
}
.method.get  { background: rgba(79,140,255,0.12); color: var(--blue);  border: 1px solid rgba(79,140,255,0.35); }
.method.post { background: var(--green-dim);      color: var(--green); border: 1px solid rgba(22,199,132,0.35); }

.scope-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}
.scope-row {
  display: grid;
  grid-template-columns: 0.9fr 1fr 1fr 1fr 0.8fr;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}
.scope-row:last-child { border-bottom: 0; }
.scope-row.scope-head {
  background: var(--panel-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.scope-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.scope-read    { background: rgba(79,140,255,0.14);  color: var(--blue);   border: 1px solid rgba(79,140,255,0.4); }
.scope-predict { background: rgba(200,121,255,0.14); color: #c879ff;       border: 1px solid rgba(200,121,255,0.45); }
.scope-write   { background: var(--green-dim);       color: var(--green);  border: 1px solid rgba(22,199,132,0.4); }
.scope-admin   { background: var(--accent-dim);      color: var(--accent); border: 1px solid var(--accent); }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  margin: 4px 0 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
}
.callout strong { color: var(--accent); }
.callout code { background: var(--panel); }

@media (max-width: 640px) {
  .docs { padding: 18px 14px 40px; }
  .docs .card { padding: 18px 18px; }
  .scope-row { grid-template-columns: 1fr 1fr; row-gap: 4px; }
  .scope-row.scope-head { display: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-left: 4px;
}
.theme-toggle button {
  background: transparent;
  border: 0;
  width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.theme-toggle button svg { width: 14px; height: 14px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(0,0,0,0);
  transition: background 0.2s, box-shadow 0.2s;
}
.status-pill.live .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.status-pill.stale .status-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-pill.offline .status-dot { background: var(--red); box-shadow: 0 0 8px var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 199, 132, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(22, 199, 132, 0); }
}

/* ───── Layout ──────────────────────────────────────────────────── */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.card-head h2 {
  font-size: 13px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

/* ───── Hero ────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}
@media (max-width: 980px) { .hero { grid-template-columns: 1fr; } }

.hero-left,
.hero-right {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-card);
}

.symbol-row { display: flex; align-items: center; gap: 14px; }
.symbol-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7931a 0%, #ffb14a 100%);
  color: #1a1208;
  font-size: 24px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.symbol-meta h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.1px; }
.symbol-meta h2 .muted { font-weight: 500; }

.price-row { display: flex; flex-direction: column; gap: 6px; }
.price-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.price {
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
.change-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.change-pill.pos { color: var(--green); background: var(--green-dim); border-color: rgba(22,199,132,0.3); }
.change-pill.neg { color: var(--red); background: var(--red-dim); border-color: rgba(234,57,67,0.3); }
.updated { font-variant-numeric: tabular-nums; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: auto;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ───── Chart panel ─────────────────────────────────────────────── */

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.range-buttons {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.range-buttons button {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.range-buttons button:hover { color: var(--text); }
.range-buttons button.active { background: var(--accent-dim); color: var(--accent); }

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 260px;
}
#price-chart { width: 100% !important; height: 100% !important; }

/* ───── Tables ──────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td { font-size: 13px; }
td .mono, td.num { font-family: var(--font-mono); }
td.num { text-align: right; }
th.num { text-align: right; }

td.empty, .empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  font-size: 13px;
}

.rank {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-dim);
}
.rank.r1 { color: #f5c518; }
.rank.r2 { color: #c0c5cf; }
.rank.r3 { color: #cd7f32; }

.model-cell { display: inline-flex; align-items: center; gap: 8px; }
.model-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}
.value-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-3);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  letter-spacing: 0.3px;
  text-transform: lowercase;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  color: var(--text-dim);
}
.badge.pending { color: var(--blue); border-color: rgba(79,140,255,0.35); background: rgba(79,140,255,0.12); }
.badge.graded  { color: var(--green); border-color: rgba(22,199,132,0.35); background: var(--green-dim); }
.badge.expired { color: var(--muted); }

/* ───── News — window selector toolbar ─────────────────────────── */

#news .card-head {
  align-items: center;
  flex-wrap: wrap;
}
.news-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.news-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.news-toolbar label {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 11px;
}
.window-selector {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 6px 28px 6px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  max-width: 360px;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s;
}
.window-selector:hover { border-color: var(--accent); }
.window-selector:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.jump-latest {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.jump-latest:hover { background: var(--accent); color: #1a1208; }
.jump-latest:active { transform: translateY(1px); }
.jump-latest[hidden] { display: none; }

/* Prev/next stepper flanking the selector. */
.window-stepper {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border-radius: 8px;
}
.window-stepper .select-wrap { display: inline-flex; }
.stepper-btn {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  width: 28px;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.stepper-btn:first-child { border-radius: 8px 0 0 8px; border-right: 0; }
.stepper-btn:last-child  { border-radius: 0 8px 8px 0; border-left: 0; }
.window-stepper .window-selector { border-radius: 0; }
.stepper-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--accent); border-color: var(--accent); }
.stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Quantitative-value chip on items that report one. */
.quant-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(247,147,26,0.35);
  font-variant-numeric: tabular-nums;
}

/* ───── Mini calendar popover ───────────────────────────────────── */

.cal-anchor { position: relative; display: inline-flex; }
.cal-toggle {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cal-toggle:hover,
.cal-toggle[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.cal-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  padding: 12px;
  font-family: var(--font-sans);
}
.cal-pop[hidden] { display: none; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-nav {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-dim);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cal-nav:hover { color: var(--accent); border-color: var(--accent); }
.cal-month {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-weekdays {
  margin-bottom: 4px;
}
.cal-weekdays span {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.cal-cell {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  min-height: 32px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cal-cell.cal-empty { visibility: hidden; }
.cal-cell.cal-empty-day { color: var(--muted); cursor: not-allowed; opacity: 0.5; }
.cal-cell.cal-has-data { color: var(--text); border-color: var(--border); }
.cal-cell.cal-has-data:hover { background: var(--panel-2); border-color: var(--accent); }
.cal-cell.cal-today .cal-num { color: var(--accent); font-weight: 700; }
.cal-cell.cal-selected { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.cal-cell:disabled { cursor: not-allowed; }
.cal-num { line-height: 1; font-variant-numeric: tabular-nums; }
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.cal-dot-bull    { background: var(--green); box-shadow: 0 0 4px var(--green); }
.cal-dot-bear    { background: var(--red);   box-shadow: 0 0 4px var(--red); }
.cal-dot-neutral { background: var(--blue);  }
.cal-dot-quiet   { background: var(--muted); }

.cal-hours {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cal-hours-head { margin-bottom: 6px; }
.cal-hours-empty { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.cal-hour-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.cal-hour {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cal-hour:hover  { border-color: var(--accent); color: var(--accent); }
.cal-hour.active { background: var(--accent); color: #1a1208; border-color: var(--accent); }
.cal-hour.cal-hour-bull    { box-shadow: inset 3px 0 0 var(--green); }
.cal-hour.cal-hour-bear    { box-shadow: inset 3px 0 0 var(--red); }
.cal-hour.cal-hour-neutral { box-shadow: inset 3px 0 0 var(--blue); }
.cal-hour.cal-hour-quiet   { box-shadow: inset 3px 0 0 var(--muted); opacity: 0.85; }

.cal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.cal-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Inline item filter chips inside the featured card. */
.item-filters {
  display: flex;
  gap: 6px;
  padding: 12px 18px 0;
  flex-wrap: wrap;
  align-items: center;
}
.filter-chip {
  background: var(--panel);
  border: 1px solid var(--border-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-chip:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}
.filter-chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.filter-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.filter-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.filter-chip.active .filter-count {
  background: var(--accent);
  color: #1a1208;
}

/* ───── News — featured window card ─────────────────────────────── */

.latest-window { margin-bottom: 0; }
.latest-card {
  border: 1px solid var(--border-2);
  border-radius: 14px;
  background:
    linear-gradient(180deg, var(--accent-dim) 0%, transparent 30%),
    var(--panel-2);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--accent-glow) inset, 0 8px 24px rgba(0,0,0,0.15);
}
.latest-card.is-historical {
  background: var(--panel-2);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.latest-card.is-historical .latest-badge.historical {
  background: var(--blue);
  color: #fff;
}
.latest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.latest-title { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.latest-badge {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--accent);
  color: #1a1208;
}
.latest-badge.recent { background: var(--blue); color: #fff; }
.latest-badge.stale  { background: var(--muted); color: var(--bg); }
.latest-when {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.latest-age {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--panel);
}
.latest-age.fresh  { color: var(--green); border-color: rgba(22,199,132,0.4); background: var(--green-dim); }
.latest-age.recent { color: var(--blue); border-color: rgba(79,140,255,0.4); background: rgba(79,140,255,0.10); }
.latest-flags { display: inline-flex; gap: 6px; align-items: center; }

.latest-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.latest-metrics .metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.latest-metrics .stat-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 500;
}
.latest-metrics .metric-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.latest-metrics .metric-value.pos { color: var(--green); }
.latest-metrics .metric-value.neg { color: var(--red); }
.latest-metrics .bull-bear { font-size: 16px; }

.latest-items {
  padding: 6px 18px 16px;
  display: flex;
  flex-direction: column;
}
.flags { display: inline-flex; gap: 6px; align-items: center; }
.flag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.flag.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* News items — single source of truth for padding so the sentiment
   bar sits cleanly to the left of the text without clipping characters. */
.item {
  position: relative;
  padding: 14px 10px 14px 16px;
  border-top: 1px dashed var(--border);
}
.item:first-child { border-top: none; padding-top: 14px; }
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--border-2);
}
.item.sent-bull::before { background: var(--green); }
.item.sent-bear::before { background: var(--red); }
.item.sent-neutral::before { background: var(--border-2); }

.item.high-impact {
  background: linear-gradient(90deg, var(--accent-dim) 0%, transparent 70%);
  border-radius: 8px;
}
.impact-star {
  color: var(--accent);
  margin-left: 6px;
  font-size: 13px;
}
.item .headline { font-weight: 600; font-size: 14px; line-height: 1.4; }
.item .headline a { color: var(--text); text-decoration: none; }
.item .headline a:hover { color: var(--accent); }
.item .meta {
  color: var(--muted);
  font-size: 11.5px;
  margin: 6px 0 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.item .summary { color: var(--text-dim); font-size: 13px; line-height: 1.55; }

.sent-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1px solid var(--border-2);
  background: var(--panel);
  color: var(--text-dim);
}
.sent-pill.sent-bull { color: var(--green); border-color: rgba(22,199,132,0.4); background: var(--green-dim); }
.sent-pill.sent-bear { color: var(--red); border-color: rgba(234,57,67,0.4); background: var(--red-dim); }
.sent-pill.sent-neutral { color: var(--text-dim); }

.chip {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--panel);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
/* Category palette — consistent across previews & items. */
.chip.cat-reg      { color: #ff8a3d; border-color: rgba(255,138,61,0.45); background: rgba(255,138,61,0.12); }
.chip.cat-macro    { color: #c879ff; border-color: rgba(200,121,255,0.45); background: rgba(200,121,255,0.12); }
.chip.cat-inst     { color: #4f8cff; border-color: rgba(79,140,255,0.45); background: rgba(79,140,255,0.12); }
.chip.cat-onchain  { color: #22c5d8; border-color: rgba(34,197,216,0.45); background: rgba(34,197,216,0.12); }
.chip.cat-exchange { color: #ea3943; border-color: rgba(234,57,67,0.45); background: var(--red-dim); }
.chip.cat-tech     { color: #16c784; border-color: rgba(22,199,132,0.45); background: var(--green-dim); }
.chip.cat-sent     { color: #f5c518; border-color: rgba(245,197,24,0.45); background: rgba(245,197,24,0.12); }
.chip.cat-deriv    { color: #ff7d60; border-color: rgba(255,125,96,0.45); background: rgba(255,125,96,0.12); }
.chip.cat-default  { color: var(--text-dim); }

/* ───── Footer ──────────────────────────────────────────────────── */

footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 28px 36px;
}
code {
  background: var(--panel-2);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ───── Forecast quality panel ──────────────────────────────────── */

.forecast-quality {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 16px;
}
.forecast-quality .empty { padding: 22px 8px; }

.model-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.model-block-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.band-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.band-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.band-swatch {
  display: inline-block;
  width: 22px;
  height: 8px;
  border-radius: 4px;
}
.band-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0.3px;
}
.band-target {
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.band-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.band-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.band-metric .stat-label { font-family: var(--font-inter, inherit); }
.band-metric .cov-pct {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.band-metric .cov-pct.pos { color: var(--green); }
.band-metric .cov-pct.neg { color: var(--red); }
.band-count { font-weight: 500; letter-spacing: 0.2px; }
.band-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 12px;
}
.strip-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
}
.strip-dot.hit { background: var(--green); border-color: var(--green); }
.strip-dot.miss { background: var(--red); border-color: var(--red); }

.band-latest {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.band-latest-range {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

@media (max-width: 540px) {
  .band-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ───── Responsive tweaks ───────────────────────────────────────── */

@media (max-width: 760px) {
  main { padding: 16px 14px 8px; }
  .topbar { padding: 12px 14px; gap: 14px; }
  .topnav { display: none; }
  .price { font-size: 30px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .hero-left, .hero-right { padding: 16px; border-radius: 14px; }
  .chart-wrap { min-height: 220px; }
  .latest-metrics { grid-template-columns: repeat(2, 1fr); padding: 12px 14px; }
  .latest-head { padding: 12px 14px; }
  .latest-items { padding: 4px 14px 14px; }
  .news-toolbar { margin-left: 0; margin-top: 6px; width: 100%; }
  .window-selector { max-width: 100%; flex: 1; }
}
