/* Colors are the validated reference chart palette (light + dark chrome,
   categorical slot 2 orange as the single series / brand accent). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #eb6834;
  --accent-wash: rgba(235, 104, 52, 0.10);
  --de-emph: #c3c2b7;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --hover: rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #d95926;
    --accent-wash: rgba(217, 89, 38, 0.10);
    --de-emph: #52514e;
    --good-text: #0ca30c;
    --hover: rgba(255, 255, 255, 0.05);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #d95926;
  --accent-wash: rgba(217, 89, 38, 0.10);
  --de-emph: #52514e;
  --good-text: #0ca30c;
  --hover: rgba(255, 255, 255, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}
a { color: inherit; text-underline-offset: 2px; }
a:hover { color: var(--ink-2); }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; display: grid; gap: 16px; }
main.wrap:focus { outline: none; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 16px; }
.brand-mark { width: 24px; height: 24px; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: #0b0b0b; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--hover); font-weight: 600; }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-btn:hover { background: var(--hover); }
.chip { font-family: var(--mono); font-size: 12px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; white-space: nowrap; }
.chip:hover { background: var(--hover); }

/* Cards and layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lede { color: var(--ink-2); max-width: 70ch; }

/* Hero figure */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; align-items: center; }
.hero-label { color: var(--ink-2); font-size: 14px; }
.hero-value { font-size: 52px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0; }
.hero-sub { color: var(--muted); font-size: 14px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 16px; --cols: 2; }
/* Rows split evenly (6 -> 6/3/2, 4 -> 4/2) so no tile is left alone. */
@media (min-width: 560px) { .tiles.six { --cols: 3; } }
@media (min-width: 1000px) { .tiles.six { --cols: 6; } }
@media (min-width: 760px) { .tiles.four { --cols: 4; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 22px; font-weight: 600; margin-top: 4px; overflow-wrap: anywhere; }
.tile-note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile .link-btn { margin-top: 6px; }

/* Forms */
.lookup { display: grid; gap: 8px; }
.lookup label { font-size: 14px; color: var(--ink-2); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > input { flex: 1 1 260px; min-width: 0; }
input, select {
  font: inherit; color: var(--ink); background: var(--page);
  border: 1px solid var(--axis); border-radius: 8px; padding: 9px 12px;
}
input.mono { font-family: var(--mono); font-size: 13px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
button.primary {
  font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--accent); color: #0b0b0b;
}
button.primary:hover { filter: brightness(1.08); }
button.secondary, .link-btn {
  font: inherit; font-size: 14px; border: 1px solid var(--border); background: transparent; color: var(--ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.link-btn { border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; color: var(--ink-2); font-size: 13px; }
button.secondary:hover { background: var(--hover); }
.form-error { color: var(--critical); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }

/* Segmented control (one filter row above a chart) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--hover); color: var(--ink); font-weight: 600; }

/* Charts */
.chart { position: relative; width: 100%; height: 240px; transition: opacity 0.2s; }
.chart.loading { opacity: 0.5; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.c-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.c-base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.c-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.c-area { fill: var(--accent-wash); }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-cross { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.c-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.c-empty { fill: var(--muted); font-size: 13px; font-family: var(--font); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); font-size: 12px; white-space: nowrap;
}
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; background: var(--accent); }
.tooltip strong { font-size: 14px; color: var(--ink); }
.tooltip .tt-sub { color: var(--ink-2); margin-top: 2px; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 12px; flex-wrap: wrap; }

/* Horizontal bars (sidechain comparison) */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; }
.bar-label { font-size: 14px; color: var(--ink-2); }
.bar-label.active { color: var(--ink); font-weight: 600; }
.bar-track { position: relative; display: flex; align-items: center; gap: 8px; height: 24px; }
.bar { height: 20px; border-radius: 0 4px 4px 0; background: var(--de-emph); min-width: 2px; }
.bar.active { background: var(--accent); }
.bar-row:hover .bar { filter: brightness(1.1); }
.bar-value { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-na { font-size: 13px; color: var(--muted); }
.bar-detail { grid-column: 2; margin-top: -8px; font-size: 12px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--hover); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.data-table { max-height: 260px; overflow-y: auto; margin-top: 12px; }

/* Status: icon + label, never color alone */
.status { display: inline-flex; align-items: center; gap: 6px; }
.status svg { width: 14px; height: 14px; flex: none; }
.status.good svg { color: var(--good); }
.status.warning svg { color: var(--warning); }
.status.critical svg { color: var(--critical); }
.status.idle svg { color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 8px; }
.tabs button { font: inherit; font-size: 14px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--ink-2); cursor: pointer; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* Code blocks */
.code { position: relative; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 12px 64px 12px 12px; overflow-x: auto; }
.code pre { margin: 0; font-family: var(--mono); font-size: 13px; white-space: pre; }
.code .copy { position: absolute; top: 8px; right: 8px; }
.steps { display: grid; gap: 16px; }
/* Grid children default to min-width: auto, which lets a long command line
   widen the page; let them shrink so the code box scrolls instead. */
.steps > * { min-width: 0; }
.prose { display: grid; gap: 10px; color: var(--ink-2); max-width: 75ch; }
.prose strong { color: var(--ink); }
.notice { border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 8px; padding: 10px 12px; color: var(--ink-2); font-size: 14px; }

.foot { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; padding-top: 24px; padding-bottom: 32px; border-top: 1px solid var(--border); }

@media (max-width: 760px) {
  .hero, .grid-2 { grid-template-columns: 1fr; }
  .hero-value { font-size: 44px; }
  /* Nav moves to its own full-width row so nothing is cut off. */
  .top-inner { height: auto; flex-wrap: wrap; gap: 0 12px; padding-top: 10px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; margin: 6px -10px 0; }
  #my-wallet { display: none; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Spacing utilities (the CSP forbids inline style attributes) */
.gap-8 { height: 8px; }
.gap-12 { height: 12px; }
.gap-16 { height: 16px; }
.mt-8 { margin-top: 8px; }
.mb-6 { margin-bottom: 6px; }
.addr { color: var(--ink-2); margin-top: 4px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
code.fp { overflow-wrap: anywhere; }
