:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #0f1420;
  --line: #1e2740;
  --ink: #e7ecf5;
  --muted: #8a97b1;
  --accent: #f59e0b;
  --strong: #22c55e;
  --weak: #ef4444;
  --neutral: #64748b;
  --radius: 12px;
  --chart-tick: #5b6884;
  --chart-grid: rgba(30, 39, 64, 0.6);
  --body-glow: radial-gradient(1200px 600px at 80% -10%, #16203a 0%, transparent 60%);
  font-synthesis: none;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --line: #dde5f0;
  --ink: #0f172a;
  --muted: #5a6b86;
  --chart-tick: #7c8aa5;
  --chart-grid: rgba(148, 163, 184, 0.28);
  --body-glow: radial-gradient(1200px 600px at 80% -10%, #e6eefc 0%, transparent 60%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--body-glow), var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── top bar ─────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.brand { font-weight: 800; letter-spacing: .3px; font-size: 18px; }
.logo { color: var(--accent); margin-right: 6px; letter-spacing: -2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 12.5px; }
.market { font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.market.open { color: var(--strong); border-color: #1e5233; }
.market.closed { color: var(--muted); }
.updated { color: var(--muted); }

/* ── layout ──────────────────────────────────────────── */
main { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 10px; letter-spacing: -.5px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.intro p, .about p { color: #c7d0e2; max-width: 70ch; }
.hint { color: var(--muted); font-size: 13.5px; max-width: 70ch; }

/* ── grid ────────────────────────────────────────────── */
.grid-wrap {
  margin: 26px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.grid-head h2 { margin-bottom: 4px; }
.grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 68px repeat(3, 1fr);
  gap: 8px;
}
.gcell { min-width: 0; }
.ghead {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 4px 2px;
  text-align: center;
}
.ghead.rowlabel { text-align: left; }
.ccy {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}
.ccy .rank { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 5px; }
.ccy.metal { color: var(--accent); }

.bar {
  position: relative;
  height: 34px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}
.bar .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 8px 0 0 8px;
  opacity: .28;
  transition: width .4s ease;
}
.bar .score { position: relative; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.bar .arrow { position: relative; font-size: 12px; color: var(--muted); }
.bar .arrow.up { color: var(--strong); }
.bar .arrow.down { color: var(--weak); }

/* row highlight when aligned across all timeframes */
.rowlabel.aligned-strong { color: var(--strong); }
.rowlabel.aligned-weak { color: var(--weak); }

.legend { margin-top: 16px; color: var(--muted); font-size: 12.5px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-right: 4px; }
.chip.strong { background: rgba(34,197,94,.15); color: var(--strong); }
.chip.neutral { background: rgba(100,116,139,.18); color: #9fb0cc; }
.chip.weak { background: rgba(239,68,68,.15); color: var(--weak); }
.loading { color: var(--muted); }

/* ── refresh button ──────────────────────────────────── */
.refresh {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.refresh:hover { border-color: var(--accent); color: var(--accent); }
.refresh.spinning { animation: spin .7s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── risk sentiment ──────────────────────────────────── */
.risk {
  margin: 26px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.risk-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.risk-label { font-weight: 800; font-size: 13px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.risk-label.on { color: var(--strong); border-color: #1e5233; }
.risk-label.off { color: var(--weak); border-color: #5a2330; }
.risk-gauge { margin: 18px 0 6px; }
.risk-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #64748b 50%, #22c55e);
}
.risk-needle {
  position: absolute; top: -4px; left: 50%;
  width: 4px; height: 20px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--panel);
  transform: translateX(-50%);
  transition: left .5s ease;
}
.risk-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 9px; }
.risk-context { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.rchip { background: var(--panel-2); border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 700; }
.rchip.on { border-left-color: var(--strong); }
.rchip.off { border-left-color: var(--weak); }
.rchip span { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 5px; }

/* ── trade ideas ─────────────────────────────────────── */
.ideas { margin: 26px 0; }
.ideas-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tf-toggle { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tf-toggle button {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.tf-toggle button:hover { color: var(--ink); }
.tf-toggle button.active { background: var(--accent); color: #1a1200; }
.ideas-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.idea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 12px 14px;
}
.idea.buy { border-left-color: var(--strong); }
.idea.sell { border-left-color: var(--weak); }
.idea-top { display: flex; align-items: center; justify-content: space-between; }
.idea-pair { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.idea-dir { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.idea-dir.buy { background: rgba(34,197,94,.16); color: var(--strong); }
.idea-dir.sell { background: rgba(239,68,68,.16); color: var(--weak); }
.idea-detail { margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.idea-detail .s-strong { color: var(--strong); font-weight: 700; }
.idea-detail .s-weak { color: var(--weak); font-weight: 700; }
.idea-gap { margin-top: 9px; height: 5px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.idea-gap span { display: block; height: 100%; background: var(--accent); }
.idea-gaptext { font-size: 11px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) { .ideas-list { grid-template-columns: 1fr; } }

/* ── charts ──────────────────────────────────────────── */
.charts { margin: 26px 0; }
.charts-head h2 { margin-bottom: 4px; }
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.chart-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.chart-date { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 4px; }
.chart-box { position: relative; height: 240px; }
.chart-box.big { height: 380px; }
@media (max-width: 700px) { .chart-grid { grid-template-columns: 1fr; } .chart-box.big { height: 300px; } }

/* Light-theme surface overrides (vars handle most; these have baked colours) */
[data-theme="light"] .topbar { background: rgba(246, 248, 252, 0.85); }
[data-theme="light"] .capture {
  background: linear-gradient(180deg, #eaf1ff, #ffffff);
  border-color: #cbdcfb;
}
[data-theme="light"] .capture p { color: #33415a; }
[data-theme="light"] .intro p,
[data-theme="light"] .about p { color: #33415a; }

/* ── capture ─────────────────────────────────────────── */
.capture {
  margin: 30px 0;
  background: linear-gradient(180deg, #14203a, var(--panel));
  border: 1px solid #24345a;
  border-radius: var(--radius);
  padding: 22px;
}
.capture h2 { font-size: 20px; }
.capture p { color: #c7d0e2; max-width: 60ch; }
.capture-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.capture-form input {
  flex: 1;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
}
.capture-form input:focus { outline: none; border-color: var(--accent); }
.capture-form button {
  background: var(--accent);
  color: #1a1200;
  font-weight: 800;
  border: 0;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  cursor: pointer;
}
.capture-form button:hover { filter: brightness(1.06); }
.capture-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ── about / footer ──────────────────────────────────── */
.about { margin-top: 30px; }
.about h2 { margin-top: 20px; }
.foot { border-top: 1px solid var(--line); padding: 22px 20px; max-width: 920px; margin: 0 auto; }
.disclaimer { color: var(--muted); font-size: 12px; max-width: 80ch; }
.src { color: #4a5878; font-size: 11px; }

@media (max-width: 560px) {
  .grid { grid-template-columns: 52px repeat(3, 1fr); gap: 6px; }
  .bar { height: 30px; padding: 0 6px; }
  .ghead { font-size: 10px; }
}
