:root {
  --bg: #f6f5fb;
  --card: #ffffff;
  --ink: #1b1830;
  --muted: #615d7c;
  --line: #e4e1f0;
  --accent: #6c5ce7;
  --accent-soft: #ece9ff;
  --price: #1b1830;
  --fair: #6c5ce7;
  --bottom: #10a37f;
  --top: #e5484d;
  --trend: #a59fc4;
  --good: #10a37f;
  --bad: #e5484d;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0d1a;
    --card: #191628;
    --ink: #ece9f8;
    --muted: #9a95b8;
    --line: #2b2742;
    --accent: #9d8fff;
    --accent-soft: #2a2450;
    --price: #ece9f8;
    --fair: #9d8fff;
    --bottom: #3ccf9f;
    --top: #ff6b6f;
    --trend: #5f5a80;
    --good: #3ccf9f;
    --bad: #ff6b6f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0d1a;
  --card: #191628;
  --ink: #ece9f8;
  --muted: #9a95b8;
  --line: #2b2742;
  --accent: #9d8fff;
  --accent-soft: #2a2450;
  --price: #ece9f8;
  --fair: #9d8fff;
  --bottom: #3ccf9f;
  --top: #ff6b6f;
  --trend: #5f5a80;
  --good: #3ccf9f;
  --bad: #ff6b6f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
h3 { margin: 1.4rem 0 .3rem; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { background: var(--accent-soft); padding: .05em .35em; border-radius: 5px; font-size: .9em; }

.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 56px; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
nav { display: flex; gap: 1rem; overflow-x: auto; }
nav a { color: var(--muted); text-decoration: none; font-size: .92rem; white-space: nowrap; }
nav a:hover { color: var(--ink); }

.card, .price-card, .gauge-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card { margin: 20px 0; }
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-top: 24px; }
.label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: .5rem; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live.on { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
.price { font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.verdict { font-size: 1.05rem; margin-bottom: 1rem; }
.verdict b.good { color: var(--good); }
.verdict b.bad { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; }
.stats div { border-top: 3px solid var(--line); padding-top: .5rem; }
.stats div:nth-child(1) { border-color: var(--bottom); }
.stats div:nth-child(2) { border-color: var(--fair); }
.stats div:nth-child(3) { border-color: var(--top); }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats dd.sub { font-weight: 400; font-size: .8rem; color: var(--muted); }

.gauge-card { display: flex; flex-direction: column; justify-content: center; }
.gauge { position: relative; height: 44px; margin: 1.6rem 0 .3rem; }
.gauge-track { position: absolute; inset: 16px 0; border-radius: 6px; background: linear-gradient(90deg, var(--bottom), var(--fair) 50%, var(--top)); }
.gauge-mark { position: absolute; top: 10px; bottom: 10px; width: 2px; background: var(--card); }
.gauge-pin { position: absolute; top: 4px; width: 4px; height: 36px; margin-left: -2px; border-radius: 2px; background: var(--ink); transition: left .6s ease; }
.gauge-pin span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .8rem; font-weight: 650; white-space: nowrap; padding-bottom: 2px; }
.gauge-labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; }
.controls { display: flex; gap: .6rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button, .toggles button {
  font: inherit; font-size: .85rem; border: 0; background: transparent; color: var(--muted); padding: .35rem .75rem; cursor: pointer;
}
.seg button.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.toggles { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 .2rem; }
.toggles button { border: 1px solid var(--line); border-radius: 999px; display: inline-flex; align-items: center; gap: .4rem; }
.toggles button i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.toggles button.off { opacity: .45; }
.toggles button.off i { background: transparent !important; outline: 1px solid var(--muted); }
.plot { width: 100%; height: 460px; }
.small-plot { height: 260px; }

.outlook { display: flex; align-items: center; gap: 1.2rem; margin: 1rem 0; }
.big { font-size: 2.8rem; font-weight: 750; letter-spacing: -.03em; min-width: 6ch; }

.dca-form { display: grid; grid-template-columns: repeat(4, auto); gap: .8rem 1.2rem; align-items: end; margin: .8rem 0; justify-content: start; }
.dca-form label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .25rem; }
.dca-form label.check { flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--ink); }
.dca-form input, .dca-form select {
  font: inherit; padding: .4rem .55rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.dca-out { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 1rem 0; }
.dca-out div { background: var(--bg); border-radius: 10px; padding: .7rem .9rem; }
.dca-out span { display: block; font-size: .8rem; color: var(--muted); }
.dca-out b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: right; padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .85rem; }

.prose { max-width: none; }
.prose p { max-width: 70ch; }
.disclaimer { text-align: center; color: var(--muted); font-size: .9rem; margin: 2rem 0 1rem; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .8rem; padding-bottom: 32px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  nav a:nth-child(n+4) { display: none; }
  .plot { height: 360px; }
  .dca-form { grid-template-columns: 1fr 1fr; }
  .dca-out { grid-template-columns: 1fr 1fr; }
  .outlook { flex-direction: column; align-items: flex-start; }
}

/* keep grid/flex children from being stretched by chart content */
.hero > *, .card, .stats > div, .dca-out > div, .dca-form > * { min-width: 0; }
.plot { overflow: hidden; }
@media (max-width: 760px) {
  .card, .price-card, .gauge-card { padding: 16px; }
  .stats { gap: 8px; }
  .stats dd { font-size: .95rem; }
  nav { gap: .8rem; }
}

/* ---- v2 additions ---- */
.nav-right { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.theme-btn {
  font: inherit; font-size: 1rem; line-height: 1; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); cursor: pointer;
}
.theme-btn:hover, .seg button:hover, .toggles button:hover { color: var(--ink); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.live-wrap { display: inline-flex; align-items: center; gap: .35rem; text-transform: none; letter-spacing: 0; font-size: .8rem; }
.streak { display: block; font-size: .85rem; color: var(--muted); margin-top: .1rem; }
.gauge-mark { left: 50%; }
.plot-error { color: var(--muted); padding: 2rem 0; text-align: center; }
.noscript { background: var(--accent-soft); padding: .8rem 1rem; border-radius: 10px; margin-top: 1rem; }
.prose ul { max-width: 70ch; padding-left: 1.2rem; }
.prose li { margin: .3rem 0; }
.tbl tbody th { font-weight: 400; text-align: left; }
#fc-growth { margin: 1rem 0 0; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live.on { animation: none; }
  .gauge-pin { transition: none; }
}
@media (max-width: 760px) {
  .nav-right { gap: .6rem; }
}
@media (max-width: 420px) {
  nav a:nth-child(n+3) { display: none; }
}

/* custom chart tooltip */
.plot-wrap { position: relative; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; font-size: .82rem; box-shadow: 0 6px 24px rgb(0 0 0 / .18);
  font-variant-numeric: tabular-nums;
}
.chart-tip[hidden] { display: none; }
.tip-date { font-weight: 650; margin-bottom: .3rem; }
.tip-row { display: flex; align-items: center; gap: .45rem; color: var(--muted); line-height: 1.6; }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tip-row b { margin-left: auto; padding-left: 1rem; color: var(--ink); font-weight: 600; }
.tip-note { margin-top: .3rem; padding-top: .3rem; border-top: 1px solid var(--line); color: var(--muted); }
.chart-cursor { position: absolute; width: 0; border-left: 1px dashed var(--muted); pointer-events: none; z-index: 4; }
.chart-cursor[hidden] { display: none; }

/* ---- v3: multi-page site ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 20; background: var(--card); padding: .4rem .8rem; border-radius: 8px; }
.skip:focus { left: 16px; }
.big.good { color: var(--good); }
.big.bad { color: var(--bad); }
.page h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); letter-spacing: -.02em; line-height: 1.15; margin: .4rem 0 .6rem; }
.lead { font-size: 1.12rem; max-width: 62ch; margin: 0 0 1.2rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-top: 22px; }
.crumbs a { color: var(--muted); }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 20px; }
.stat-cards > div { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--line); border-radius: 12px; padding: .8rem 1rem; min-width: 0; }
.stat-cards .c-bottom { border-top-color: var(--bottom); }
.stat-cards .c-fair { border-top-color: var(--fair); }
.stat-cards .c-top { border-top-color: var(--top); }
.stat-cards dt { color: var(--muted); font-size: .8rem; }
.stat-cards dd { margin: 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-cards dd.sub { font-size: .82rem; font-weight: 400; color: var(--muted); }
.pager { display: flex; justify-content: center; gap: 1.2rem; flex-wrap: wrap; margin: 1.5rem 0 0; }
.table-wrap.narrow { max-width: 360px; }
.tbl a { text-decoration: none; font-weight: 600; }

/* inline SVG charts on landing pages */
.svgchart { width: 100%; height: auto; display: block; }
.svgchart .grid { stroke: var(--line); stroke-width: 1; }
.svgchart .tick { fill: var(--muted); font: 12px system-ui, sans-serif; }
.svgchart .l-price { fill: none; stroke: var(--price); stroke-width: 1.4; stroke-linejoin: round; }
.svgchart .l-fair { stroke: var(--fair); stroke-width: 2.4; }
.svgchart .l-top { stroke: var(--top); stroke-width: 1.8; }
.svgchart .l-bottom { stroke: var(--bottom); stroke-width: 1.8; }
.svgchart .l-value { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.svgchart .l-ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.svgchart .now-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.svgchart .mark { stroke: var(--muted); stroke-dasharray: 3 4; }
.svgchart .mark-dot { fill: var(--fair); stroke: var(--card); stroke-width: 2.5; }
.svgchart .mark-label { fill: var(--ink); font: 600 14px system-ui, sans-serif; paint-order: stroke; stroke: var(--card); stroke-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .82rem; color: var(--muted); margin: .6rem 0 0; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: .4rem; vertical-align: middle; background: var(--muted); }
.legend .k-price::before { background: var(--price); }
.legend .k-fair::before { background: var(--fair); }
.legend .k-bottom::before { background: var(--bottom); }
.legend .k-top::before { background: var(--top); }
.legend .k-value::before { background: var(--accent); }
.legend .k-ref::before { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px); }

/* widgets page */
.code { position: relative; margin: .4rem 0 1rem; }
.code pre, pre.json { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 5.5rem .8rem .9rem; overflow-x: auto; font-size: .82rem; margin: 0; }
pre.json { padding-right: .9rem; max-height: 420px; }
.copy { position: absolute; top: .5rem; right: .5rem; font: inherit; font-size: .8rem; padding: .3rem .7rem; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.widget-demos { display: flex; flex-wrap: wrap; gap: 16px; margin: .6rem 0 1rem; }
details summary { cursor: pointer; color: var(--accent); margin: .6rem 0; }

.foot { flex-direction: column; }
.foot-links { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .4rem; }
.foot-links a { color: var(--muted); }

@media (max-width: 760px) {
  .stat-cards { grid-template-columns: 1fr; }
  nav a:nth-child(n+4) { display: none; }
}
.svgchart line, .svgchart polyline { vector-effect: non-scaling-stroke; }
@media (max-width: 560px) {
  .svgchart .tick { font-size: 24px; }
  .svgchart .mark-label { font-size: 28px; stroke-width: 6px; }
  .svgchart .now-dot, .svgchart .mark-dot { r: 9; }
}
