/* edgeterm dashboard. Palette and chart chrome follow the validated reference palette
   (categorical slots 1-4 pass the six checks in both modes; see the dataviz skill). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --band: rgba(42, 120, 214, 0.06);
  --series-1: #2a78d6; /* trend strategy */
  --series-2: #eb6834; /* holding BTC */
  --series-3: #1baf7a; /* 100-day average filter */
  --series-4: #eda100; /* holding all coins */
  --neutral-line: #52514e;
  --good: #006300;
  --bad: #d03b3b;
  --good-wash: rgba(12, 163, 12, 0.10);
  --bad-wash: rgba(208, 59, 59, 0.10);
  --focus: #2a78d6;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #222220;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --band: rgba(57, 135, 229, 0.08);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --neutral-line: #c3c2b7;
    --good: #0ca30c;
    --bad: #e66767;
    --good-wash: rgba(12, 163, 12, 0.14);
    --bad-wash: rgba(230, 103, 103, 0.14);
    --focus: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --band: rgba(57, 135, 229, 0.08);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --neutral-line: #c3c2b7;
  --good: #0ca30c;
  --bad: #e66767;
  --good-wash: rgba(12, 163, 12, 0.14);
  --bad-wash: rgba(230, 103, 103, 0.14);
  --focus: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--series-1); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- frame ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 32px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 12px; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.brand .mark { color: var(--series-1); }
.brand .tag { font-weight: 400; font-size: 13px; color: var(--text-muted); }
.status { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; color: var(--text-secondary);
  background: var(--surface-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip.good .dot { background: var(--good); }
.chip.bad .dot { background: var(--bad); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 8px; width: 34px; height: 30px; cursor: pointer; font-size: 15px;
}

nav.tabs {
  display: flex; gap: 4px; padding: 0 32px;
  border-bottom: 1px solid var(--border); background: var(--page);
  overflow-x: auto;
}
nav.tabs a {
  padding: 12px 14px 11px; color: var(--text-secondary); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14.5px;
}
nav.tabs a:hover { color: var(--text-primary); }
nav.tabs a[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--series-1); font-weight: 600; }

main { max-width: 1240px; margin: 0 auto; padding: 28px 32px 64px; }
footer.foot { max-width: 1240px; margin: 0 auto; padding: 0 32px 40px; color: var(--text-muted); font-size: 13px; }

/* ---------- typography ---------- */
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 650; }
h2 { font-size: 18px; letter-spacing: -0.01em; margin: 40px 0 4px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.lede { color: var(--text-secondary); font-size: 16px; max-width: 780px; margin: 0 0 22px; }
.note { color: var(--text-muted); font-size: 13px; margin: 8px 0 0; max-width: 820px; }
.section-intro { color: var(--text-secondary); margin: 0 0 14px; max-width: 820px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.neutral { color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }

/* glossary term with a tooltip (hover or keyboard focus) */
.term { border-bottom: 1px dotted var(--text-muted); cursor: help; position: relative; }
.term:hover::after, .term:focus::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 20;
  width: 300px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px; font-weight: 400; line-height: 1.45; white-space: normal; text-transform: none;
}

/* ---------- cards & tiles ---------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.summary { border-left: 3px solid var(--series-1); }
.summary ul { margin: 6px 0 0; padding-left: 18px; }
.summary li { margin: 6px 0; color: var(--text-secondary); }
.summary li strong { color: var(--text-primary); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 0 0 18px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 2px 0 2px; }
.tile .sub { font-size: 12.5px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } main { padding: 20px 16px 48px; } .topbar, nav.tabs { padding-left: 16px; padding-right: 16px; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12.5px;
  padding: 8px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
table.data td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data tr.detail td { background: var(--surface-2); color: var(--text-secondary); font-size: 13.5px; }
table.data td.strong { font-weight: 600; }
.caret { color: var(--text-muted); display: inline-block; width: 14px; transition: transform .15s; }
tr[aria-expanded="true"] .caret { transform: rotate(90deg); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 22px; margin-top: 10px; }
.detail-grid div span { display: block; font-size: 12px; color: var(--text-muted); }
.detail-grid div b { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* trend-strength pips and the holding meter */
.pips { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 8px; }
.pips i { width: 6px; height: 12px; border-radius: 2px; background: var(--grid); }
.pips i.on { background: var(--series-1); }
.meter { display: inline-block; width: 48px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--series-1) 18%, transparent); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

/* segmented control (one filter row above the content it scopes) */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--text-secondary); padding: 6px 12px; border-radius: 6px;
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
select, input[type="number"] {
  font: inherit; font-size: 14px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-row input { width: 120px; }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart-plot { position: relative; width: 100%; }
.chart-plot svg { display: block; overflow: visible; }
.chart-plot svg:focus { outline: none; }
.chart-plot svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.chart text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.chart text.tick { fill: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart text.end-label { fill: var(--text-secondary); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart text.band-label { fill: var(--text-muted); font-size: 11.5px; }
.chart text.row-label { fill: var(--text-primary); font-size: 13.5px; }
.chart text.row-value { fill: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 2px 0;
  font: inherit; font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.legend-item.static { cursor: default; }
.legend-item[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
.key-line { width: 16px; height: 2px; border-radius: 1px; background: var(--key); display: inline-block; }
.key-tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; display: inline-block; }
.key-tri.up { border-bottom: 9px solid var(--key); }
.key-tri.down { border-top: 9px solid var(--key); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); padding: 8px 10px; font-size: 12.5px;
}
.tip-date { color: var(--text-muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row strong { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text-primary); }
.tip-label { color: var(--text-secondary); }
.tip-note { color: var(--text-secondary); margin-top: 4px; }
.chart-tools { display: flex; justify-content: flex-end; margin-top: 4px; }
.chart-table { margin-top: 10px; max-height: 360px; overflow: auto; }
button.link { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 12.5px; cursor: pointer; padding: 2px 0; }
button.link:hover { color: var(--text-primary); text-decoration: underline; }
.chart-card h3 + .note { margin-top: 0; margin-bottom: 12px; }

/* break-even meter on the calculator */
.be-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); margin: 26px 0 30px; }
.be-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.be-fill.good { background: var(--good); opacity: .55; }
.be-fill.bad { background: var(--bad); opacity: .55; }
.be-mark { position: absolute; top: -6px; width: 2px; height: 22px; background: var(--text-primary); }
.be-mark span { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: var(--text-secondary); }
.be-mark.you span { top: -22px; }
.hero { font-size: 44px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.good { background: var(--good-wash); color: var(--good); }
.pill.bad { background: var(--bad-wash); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--text-secondary); }

/* long-form "how it works" */
.prose { max-width: 820px; }
.prose h1 { font-size: 24px; margin-top: 0; }
.prose h2 { font-size: 19px; margin-top: 34px; }
.prose p, .prose li { color: var(--text-secondary); }
.prose strong { color: var(--text-primary); }
.prose hr { border: 0; border-top: 1px solid var(--grid); margin: 30px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.prose th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--grid); padding: 8px 10px; }
.prose td { border-bottom: 1px solid var(--grid); padding: 9px 10px; color: var(--text-secondary); vertical-align: top; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
dl.glossary { display: grid; grid-template-columns: 200px 1fr; gap: 10px 20px; margin: 0; }
dl.glossary dt { font-weight: 600; }
dl.glossary dd { margin: 0; color: var(--text-secondary); }

.empty { text-align: left; }
.empty ol { color: var(--text-secondary); }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.loading { color: var(--text-muted); }
.stale { opacity: .55; transition: opacity .2s; }

.spacer { height: 16px; }
.hero-sm { font-size: 28px; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .brand .tag { display: none; }
  .status { order: 3; width: 100%; margin-left: 0; gap: 6px; }
  .chip { font-size: 12px; padding: 2px 8px; }
  #theme { margin-left: auto; }
  h1 { font-size: 22px; }
  .lede { font-size: 15px; }
  .tile .value { font-size: 24px; }
  .hero { font-size: 36px; }
  .card { padding: 16px; }
  dl.glossary { grid-template-columns: 1fr; gap: 2px 0; }
  dl.glossary dd { margin-bottom: 10px; }
}

table.data td:first-child, table.data th:first-child { white-space: nowrap; }
table.data td { white-space: nowrap; }
table.data tr.detail td { white-space: normal; }
