:root {
  color-scheme: light dark;
  --fg: #1a1a1a; --bg: #fff; --accent: #f7931a; --muted: #666; --line: #e2e2e2; --card: #f5f5f5;
  /* Single content measure: header, footer, charts and text all share it, so
     every page is one column rather than a wide frame around narrow content.
     Absolute units, not ch: ch is font-size relative, so the footer (0.85rem)
     resolved it ~15% narrower than main and sat visibly inset. Matches
     dividendpredictor.com, which uses the same measure. */
  --maxw: 860px;
}
/* Dark palette. Applied when the user picks dark (data-theme), or — for
   JS-disabled visitors, where no data-theme is set — when the OS prefers dark. */
:root[data-theme="dark"] {
  --fg: #eee; --bg: #111; --muted: #999; --line: #2a2a2a; --card: #1b1b1b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --fg: #eee; --bg: #111; --muted: #999; --line: #2a2a2a; --card: #1b1b1b; }
}

* { box-sizing: border-box; }
a { color: var(--accent); }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; color: var(--fg); background: var(--bg); }
main, .site-header, .site-footer { max-width: var(--maxw); margin: 0 auto; padding: 1rem; }

/* Header: brand left, nav right; wraps gracefully on narrow screens. */
.site-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 1.25rem; }
.site-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.site-header nav a { color: var(--muted); font-size: 15px; text-decoration: none; }
.site-header nav a:hover { color: var(--fg); }

/* Theme toggle: shows the moon in light mode (click → dark), sun in dark mode. */
.theme-toggle {
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
  padding: 4px 9px; font-size: 1rem; line-height: 1; color: var(--fg); border-radius: 8px;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-icon-dark { display: none; }
  :root:not([data-theme]) .theme-icon-light { display: inline; }
}

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
.movers { display: flex; gap: 2rem; flex-wrap: wrap; }
.movers > div { flex: 1; min-width: 240px; }
/* Text-like blocks share the prose measure; charts are the deliberate
   exception and fill the content column. */
.email-capture { position: relative; margin: 2rem 0; padding: 1.5rem; border: 1px solid var(--accent);
  border-radius: 8px; }
.capture-dismiss { position: absolute; top: .4rem; right: .5rem; padding: .2rem .45rem;
  background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.capture-dismiss:hover { color: var(--fg); }
/* The two states are mutually exclusive and chosen before first paint by the
   data-subscribe attribute the head script sets. */
.capture-strip { display: none; margin: 2rem 0; padding: 0; background: none; border: 0;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.capture-strip:hover { color: var(--accent); }
:root[data-subscribe="hidden"] .email-capture { display: none; }
:root[data-subscribe="hidden"] .capture-strip { display: block; }
.signup { display: flex; gap: .5rem; flex-wrap: wrap; }
.signup input { flex: 1; min-width: 200px; padding: .5rem; }
.signup button { padding: .5rem 1rem; background: var(--accent); border: 0; color: #fff; border-radius: 4px; cursor: pointer; }
.signup-note { font-size: 12px; color: var(--muted); margin: .6rem 0 0; }
.signup-note a { color: var(--muted); }
/* Visually hidden but available to screen readers — a placeholder is not a label. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.coin-list { columns: 4; list-style: none; padding: 0; }

/* ---- Homepage dashboard ---- */
.num { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.eyebrow { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.up { color: #3fb950; } .down { color: #e5534b; }

.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 2rem; align-items: end;
  padding: 1.25rem 0 1.75rem; border-bottom: 1px solid var(--line); }
.hero .price { font-size: clamp(38px, 8vw, 60px); font-weight: 600; line-height: 1; margin-top: .35rem;
  transition: color .5s ease-out; }
/* Each trade tints the price for a moment, then fades back — direction you can
   catch out of the corner of your eye, without the number ever jumping. */
.hero .price.tick-up { color: #3fb950; transition: none; }
.hero .price.tick-down { color: #e5534b; transition: none; }
@media (prefers-reduced-motion: reduce) {
  .hero .price, .hero .price.tick-up, .hero .price.tick-down { transition: none; color: inherit; }
}
.hero .chg { font-size: 15px; margin-top: .5rem; }
.hero .price-src { font-size: 12px; color: var(--muted); margin-top: .35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hero .cycle-note { font-size: 13px; color: var(--muted); margin-top: .5rem; }
.hero .cycle-link { display: inline-block; margin-top: .6rem; font-size: 13px;
  color: var(--accent); text-decoration: none; }
.hero .cycle-link:hover { text-decoration: underline; }

/* Segmented cycle meter — the signature device, echoing the brand mark. */
.meter { display: flex; gap: 2px; height: 26px; margin-top: .6rem; }
.meter i { flex: 1; background: var(--line); border-radius: 1px; }
.meter i.on { background: var(--accent); }
.meter i.now { background: var(--fg); }

.grouphead { display: flex; align-items: baseline; gap: .75rem; margin: 2rem 0 .6rem; }
.grouphead h2 { font-size: 14px; margin: 0; }
.grouphead .rule { flex: 1; height: 1px; background: var(--line); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); }
.tile { background: var(--bg); padding: .85rem 1rem; text-decoration: none; color: inherit; display: block; }
.tile:hover { background: var(--card); }
.tile .d { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 600; margin-top: .2rem; }
.tile .n { font-size: 11px; color: var(--muted); margin-top: .15rem; }

.asof { font-size: 12px; color: var(--muted); margin-top: 1rem; }

.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.cat { border: 1px solid var(--line); padding: .85rem 1rem; border-radius: 2px; }
.cat h3 { margin: 0 0 .2rem; font-size: 14px; }
.cat h3 a { color: var(--fg); text-decoration: none; }
.cat p { margin: 0; font-size: 12px; color: var(--muted); }
.cat .n { font-size: 11px; color: var(--accent); }

@media (max-width: 700px) { .hero { grid-template-columns: 1fr; gap: 1.5rem; } }
@media (max-width: 560px) {
  /* Nav takes its own full-width row rather than squeezing beside the brand. */
  .site-header { gap: 4px; }
  .site-header nav { width: 100%; gap: 6px 16px; }
}

/* uPlot legend ("Time / Close") is HTML — force theme colour so it stays
   readable in dark mode (uPlot doesn't set it, and it must not fall to #000). */
.u-legend, .u-legend th, .u-legend .u-value { color: var(--fg); }
.chart-note { color: var(--muted); font-size: .9rem; }
/* Reserve chart height so content below doesn't jump when uPlot mounts after
   its async data fetch (chart height + title/axis/legend overhead). */
/* Charts share the text measure so a content page is a single column. The
   chart JS sizes to its container, so capping the container caps the chart. */
#btc-chart { min-height: 484px; }
#btc-stats { margin: 1rem 0 1.25rem; }
#pl-chart { min-height: 524px; }
#metric-chart { min-height: 504px; }
#cycle-chart { min-height: 524px; }

/* Debt breakdown bar list */
.barlist { width: 100%; border-collapse: collapse; font-size: .9rem; }
.barlist th, .barlist td { padding: .35rem .6rem; border-bottom: 1px solid var(--line); text-align: right; }
.barlist tbody th { text-align: left; font-weight: 600; }
.barlist thead th { color: var(--muted); font-weight: 600; }
.barlist .bar-col { width: 45%; }
.barlist .bar { display: block; height: 10px; border-radius: 3px; background: var(--accent); }
@media (max-width: 620px) { .barlist .bar-col { display: none; } }

/* 4-year cycle progress bar */
.cycle-progress { margin: 1rem 0 1.5rem; }
.cycle-progress .bar { height: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.cycle-progress .fill { height: 100%; background: var(--accent); }
.method p { margin: 0 0 .6rem; }

/* Metrics hub list */
.muted { color: var(--muted); }
.metric-list { list-style: none; padding: 0; margin: .5rem 0 1.5rem; }
.metric-list li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.metric-list a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* Seasonality heatmap */
.table-scroll { overflow-x: auto; }
.heatmap { border-collapse: collapse; font-size: .8rem; white-space: nowrap; }
.heatmap th, .heatmap td { padding: .3rem .5rem; text-align: right; border: 1px solid var(--line); }
.heatmap thead th, .heatmap tbody th { text-align: center; color: var(--muted); font-weight: 600; }
.heatmap tr.avg th, .heatmap tr.avg td { font-weight: 700; border-top: 2px solid var(--muted); }

/* Footer: nav + copyright on one row, stacking cleanly on mobile. */
.site-footer { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 2rem; }
.site-footer .foot-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 20px; }
.foot-nav a { color: var(--muted); margin-right: 16px; white-space: nowrap; text-decoration: none; }
.foot-nav a:hover { color: var(--fg); }
.foot-nav a:last-child { margin-right: 0; }

@media (max-width: 620px) {
  h1 { font-size: 1.5rem; }
  .coin-list { columns: 2; }
  .site-footer .foot-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .foot-nav { display: flex; flex-direction: column; gap: 10px; }
  .foot-nav a { margin-right: 0; }
}

/* Long-form content pages */
.prose { max-width: 100%; }
.prose h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; }
.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.prose li { margin: .3rem 0; }
.prose a { color: var(--accent); }

/* Per-chart data download */
.download { font-size: .85rem; margin: .75rem 0 1.25rem; }
.download a { color: var(--accent); font-weight: 600; }

/* Fork comparison table */
.forks { width: 100%; border-collapse: collapse; font-size: .9rem; white-space: nowrap; }
.forks th, .forks td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); text-align: right; }
.forks thead th { color: var(--muted); font-weight: 600; text-align: right; }
.forks thead th:first-child, .forks tbody th { text-align: left; }
.forks tbody th { font-weight: 600; }
.forks .btc-row { background: var(--card); }
.forks .flag { color: var(--accent); cursor: help; }

/* Affiliate placement — visually distinct from editorial content so a reader
   can tell at a glance that it is a paid link, not a chart or a finding. */
.affiliate { border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 1rem 1.15rem; margin: 2rem 0; border-radius: 2px; }
.affiliate p { margin: 0 0 .5rem; }
.aff-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.affiliate a { color: var(--accent); font-weight: 600; }
/* Vendors wrap onto their own line on narrow screens rather than running together. */
.aff-links { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; }
.aff-note { font-size: 12px; color: var(--muted); margin: 0; }
.aff-note a { font-weight: 400; color: var(--muted); }
