:root {
  --bg: #0B1220; --card: #121B2E; --line: #22304A; --edge: #2A3A58;
  --text: #E7ECF5; --soft: #C9D4E8; --muted: #9AA8C0; --chip: #1B2740; --pill: #162238;
  --accent: #6EA8FF; --amber: #F5B84A; --on-amber: #1A1204; --bad: #FF8A7A;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4rem; background: var(--bg); }
body {
  margin: 0 auto; max-width: 560px; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--sans);
  padding: 0 calc(14px + env(safe-area-inset-right)) env(safe-area-inset-bottom) calc(14px + env(safe-area-inset-left));
}
[hidden] { display: none !important; }
a { color: #8DB8FF; }
.muted { color: var(--muted); font-size: 12px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.brand > div { display: flex; flex-direction: column; color: var(--text); }
.bar h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; margin: 0; }
.bar-right { display: flex; align-items: center; gap: 8px; }
.notice { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
footer.notice { padding: 24px 12px 32px; text-align: center; }

button.ghost {
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--edge);
  background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer;
}
button.ghost.icon { width: 44px; padding: 0; color: var(--muted); display: flex; align-items: center; justify-content: center; }
button.primary {
  background: var(--accent); color: var(--bg); border: 0; border-radius: 10px;
  padding: 0 16px; font-weight: 600; min-height: 44px; cursor: pointer;
}
button.link { background: none; border: 0; color: #8DB8FF; font-weight: 600; cursor: pointer; }

.gate { margin: 18vh auto 0; text-align: center; }

.tabs {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto;
  margin: 12px -14px 0; padding: 8px 14px; background: var(--bg); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; min-height: 36px; display: flex; align-items: center; padding: 0 14px;
  border-radius: 999px; background: var(--pill); color: var(--soft); font-size: 13px; text-decoration: none;
}
.tabs a:hover, .tabs a:active { background: var(--accent); color: var(--bg); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat-n { font: 600 24px/1.1 var(--mono); }
.stat-l { font-size: 12px; color: var(--muted); margin-top: 4px; }

section {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  margin-top: 16px; padding: 4px 14px 10px;
}
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 0 8px; }
.head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.stale { color: var(--bad); }
.empty { color: var(--soft); margin: 4px 0 8px; }

.row, .crow { border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; padding: 14px 0; }
.row > div:last-child { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.crow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; align-items: baseline; }
.score {
  height: 52px; border-radius: 12px; background: var(--chip); color: var(--soft);
  display: flex; align-items: center; justify-content: center; font: 600 20px var(--mono);
}
.score.hot { background: var(--amber); color: var(--on-amber); }
.score.warm { background: none; border: 1.5px solid var(--amber); color: var(--amber); }
.row-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.ticker { font: 600 16px var(--mono); }
.crow .ticker { font-size: 15px; }
.company { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.headline { overflow-wrap: anywhere; }
.figure { font: 600 15px var(--mono); text-align: right; white-space: nowrap; }
.subscore { font: 500 12px var(--mono); color: var(--muted); text-align: right; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--soft); white-space: nowrap; }
.badge.multi { background: var(--accent); color: var(--bg); font-weight: 600; }
.badge.watch { background: none; box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.more { display: block; width: 100%; min-height: 44px; border-top: 1px solid var(--line) !important; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { display: inline-flex; align-items: center; background: var(--chip); border-radius: 999px; padding-left: 12px; font: 600 14px var(--mono); }
.chip button { background: none; border: 0; padding: 0 12px; min-height: 36px; cursor: pointer; color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input, textarea { background: var(--bg); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input { width: 9.5rem; text-transform: uppercase; font-family: var(--mono); }
input::placeholder { text-transform: none; font-family: var(--sans); color: var(--muted); }
textarea { width: 100%; font: 12px/1.45 var(--mono); margin: 8px 0; }
details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.error { color: var(--bad); margin: 8px 0 0; }

dialog#help {
  width: min(640px, 100vw); max-width: 100vw; max-height: 100dvh; margin: auto; padding: 0;
  border: 1px solid var(--edge); border-radius: 16px; background: var(--card); color: var(--text);
}
dialog#help::backdrop { background: rgba(4, 8, 16, 0.7); }
@media (max-width: 640px) { dialog#help { height: 100dvh; border-radius: 0; border: 0; } }
.help-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--card); border-bottom: 1px solid var(--line);
}
.help-head h2 { margin: 0; font-size: 16px; }
.help-head button { min-height: 44px; }
.help-body { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
.help-body h3 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); margin: 22px 0 8px; }
.help-body p { margin: 0 0 8px; }
.legend { list-style: none; padding: 0; margin: 0 0 8px; }
.legend li { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.legend .score { width: 52px; flex: none; }
.terms { margin: 0; }
.terms dt { margin-top: 12px; font-weight: 600; }
.terms dd { margin: 2px 0 0; color: var(--muted); }
.weights { width: 100%; border-collapse: collapse; }
.weights td { padding: 8px 0; border-top: 1px solid var(--line); }
.weights td:last-child { text-align: right; font: 600 14px var(--mono); white-space: nowrap; }

/* Tap-to-explain */
button.tappable, button.score, button.info { font-family: inherit; cursor: pointer; }
button.badge { border: 0; min-height: 26px; text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--muted); }
button.badge.multi, button.badge.watch { text-decoration: none; }
button.score { border: 0; width: 100%; font: 600 20px var(--mono); }
button.score.warm { border: 1.5px solid var(--amber); }
button.figure, button.subscore { background: none; border: 0; padding: 0; color: inherit; }
button.figure { font: 600 15px var(--mono); }
button.subscore { font: 500 12px var(--mono); color: var(--muted); min-height: 26px; }
button.info {
  width: 26px; height: 26px; margin-left: 4px; border-radius: 50%; border: 1px solid var(--edge);
  background: none; color: var(--muted); font: 600 13px var(--sans); vertical-align: middle;
  text-transform: none; letter-spacing: 0;
}
a.ticker { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.ticker.none { color: var(--muted); font-family: var(--sans); font-size: 13px; font-weight: 500; }
a.source { font-size: 12px; white-space: nowrap; }
dialog#term {
  width: min(520px, calc(100vw - 20px)); max-height: 85dvh; margin: auto auto 10px; padding: 0;
  border: 1px solid var(--edge); border-radius: 16px; background: var(--card); color: var(--text);
}
@media (min-width: 641px) { dialog#term { margin: auto; } }
dialog#term::backdrop { background: rgba(4, 8, 16, 0.7); }
dialog#term .help-body { padding-top: 12px; }
dialog#term strong { color: var(--soft); }
.glossary { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.term-link { min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--chip) !important; color: var(--soft) !important; font-weight: 500 !important; font-size: 13px; }
