/* Tokens. Dark values are declared twice on purpose: once for the system setting, once for the viewer's toggle,
   which has to win in both directions. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #121c26;
  --ink-2: #47545f;
  --ink-3: #6f7b87;
  --line: #dde2e7;
  --line-soft: #e9ecf0;
  --accepted: #2a78d6;
  --rejected: #eb6834;
  --loss: #c23434;
  --gain: #0a7d2c;
  --focus: #2a78d6;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 66ch;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e141b;
    --surface: #131a22;
    --ink: #f2f5f8;
    --ink-2: #b6c0ca;
    --ink-3: #8a97a4;
    --line: #27323e;
    --line-soft: #1c2530;
    --accepted: #3987e5;
    --rejected: #d95926;
    --loss: #f07a7a;
    --gain: #4cc46a;
    --focus: #6da7ec;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e141b;
  --surface: #131a22;
  --ink: #f2f5f8;
  --ink-2: #b6c0ca;
  --ink-3: #8a97a4;
  --line: #27323e;
  --line-soft: #1c2530;
  --accepted: #3987e5;
  --rejected: #d95926;
  --loss: #f07a7a;
  --gain: #4cc46a;
  --focus: #6da7ec;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  font-feature-settings: "kern", "calt";
}

h1, h2, h3, p, figure { margin: 0; }

a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: var(--gutter); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 30; background: var(--surface); padding: 8px 12px; }

/* ---------------------------------------------------------------- top bar */

.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.top__row { display: flex; align-items: center; gap: 20px; min-height: 56px; }

.brand { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; text-decoration: none; }

.top__nav { display: flex; gap: 18px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top__nav::-webkit-scrollbar { display: none; }
.top__nav a { color: var(--ink-2); text-decoration: none; font-size: 0.9375rem; white-space: nowrap; padding-block: 6px; }
.top__nav a:hover { color: var(--ink); }

.top__tools { display: flex; align-items: center; gap: 10px; }

.field { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--ink-2); }
.field select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
}

.btn {
  font: inherit; font-size: 0.875rem; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
}
.btn:hover { border-color: var(--ink-3); }
.btn--quiet { background: transparent; }

@media (max-width: 720px) {
  .top__row { flex-wrap: wrap; gap: 4px 14px; padding-block: 8px; }
  .top__nav { order: 3; flex-basis: 100%; }
  .top__tools { margin-left: auto; }
  .field__label { position: absolute; left: -9999px; }
  html { scroll-padding-top: 104px; }
}

/* ---------------------------------------------------------------- lead */

.lead { padding-block: clamp(36px, 7vw, 84px) clamp(28px, 5vw, 56px); }

.lead__verdict {
  font-size: clamp(1.75rem, 1.05rem + 3.1vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.028em;
  font-weight: 680;
  max-width: 22ch;
  text-wrap: balance;
}

.lead__intro {
  margin-top: clamp(16px, 2.4vw, 26px);
  max-width: var(--measure);
  color: var(--ink-2);
  font-size: clamp(1rem, 0.96rem + 0.25vw, 1.125rem);
}

.lead .figure { margin-top: clamp(28px, 5vw, 56px); }

/* ---------------------------------------------------------------- sections */

.section { padding-block: clamp(32px, 5vw, 60px); border-top: 1px solid var(--line); }

.section__head { display: grid; gap: 10px; margin-bottom: clamp(20px, 3vw, 32px); }

.section__head h2 {
  font-size: clamp(1.375rem, 1.1rem + 1.1vw, 2rem);
  line-height: 1.15; letter-spacing: -0.02em; font-weight: 660; max-width: 26ch; text-wrap: balance;
}

.section__head p { max-width: var(--measure); color: var(--ink-2); }

.sub { font-size: 1rem; font-weight: 640; margin: 34px 0 12px; }
.section__head + .sub { margin-top: 0; }

.figure__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 24px; margin-bottom: 18px; }

.figure__title { font-size: 1rem; font-weight: 640; line-height: 1.35; max-width: 46ch; }

.note { margin-top: 16px; max-width: var(--measure); color: var(--ink-3); font-size: 0.875rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.875rem; color: var(--ink-2); }
.legend__item { display: inline-flex; align-items: center; gap: 7px; }
.legend__key { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend__key--accepted { background: var(--accepted); }
.legend__key--rejected { background: var(--rejected); }

/* ---------------------------------------------------------------- block states */

.block { min-height: 48px; }

.state { color: var(--ink-3); font-size: 0.9375rem; padding-block: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.state--error { color: var(--ink-2); }

.scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- paired bars */

.bars { display: grid; gap: 18px; }

.bars__row { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 14px; }

.bars__name { font-size: 1.0625rem; font-weight: 640; font-variant-numeric: tabular-nums; }

.bars__pair { display: grid; gap: 2px; border-left: 1px solid var(--line); }

.bar { display: flex; align-items: center; gap: 10px; min-height: 22px; }

.bar__fill { height: 18px; border-radius: 0 4px 4px 0; flex: none; }
.bar__fill--accepted { background: var(--accepted); }
.bar__fill--rejected { background: var(--rejected); }

.bar__label { font-size: 0.875rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar__label strong { color: var(--ink); font-weight: 640; }

@media (max-width: 520px) {
  .bars__row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}

/* ---------------------------------------------------------------- figures (portfolio) */

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }

.figures__item { padding: 18px 20px 4px 0; }
.figures__item + .figures__item { padding-left: 20px; border-left: 1px solid var(--line); }

.figures__label { font-size: 0.875rem; color: var(--ink-2); }
.figures__value { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.15; font-weight: 660; letter-spacing: -0.02em; margin-top: 4px; }
.figures__hint { font-size: 0.875rem; color: var(--ink-3); margin-top: 2px; }

.is-loss { color: var(--loss); }
.is-gain { color: var(--gain); }

@media (max-width: 760px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures__item { padding: 16px 12px 12px 0; }
  .figures__item + .figures__item { padding-left: 0; border-left: 0; }
  .figures__item:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
  .figures__item:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* ---------------------------------------------------------------- segmented control */

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); }
.seg button {
  font: inherit; font-size: 0.875rem; color: var(--ink-2); background: transparent; border: 0; cursor: pointer;
  padding: 5px 12px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------------------------------------------------------------- line chart */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--line-soft); stroke-width: 1; }
.chart__axis { stroke: var(--line); stroke-width: 1; }
.chart__tick { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--accepted { stroke: var(--accepted); }
.chart__line--rejected { stroke: var(--rejected); }
.chart__dot { stroke: var(--bg); stroke-width: 2; }
.chart__dot--accepted { fill: var(--accepted); }
.chart__dot--rejected { fill: var(--rejected); }
.chart__end { fill: var(--ink); font-size: 12.5px; font-weight: 640; font-variant-numeric: tabular-nums; }
.chart__cross { stroke: var(--ink-3); stroke-width: 1; }
.chart__hit { fill: transparent; }

.tableview { margin-top: 14px; font-size: 0.875rem; color: var(--ink-2); }
.tableview summary { cursor: pointer; width: fit-content; }
.tableview[open] summary { margin-bottom: 10px; }

/* ---------------------------------------------------------------- tooltip */

.tip {
  position: fixed; z-index: 40; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--bg); border-radius: 8px; padding: 9px 11px;
  font-size: 0.8125rem; line-height: 1.4; font-variant-numeric: tabular-nums;
}
.tip__title { font-weight: 640; margin-bottom: 4px; }
.tip__row { display: flex; align-items: center; gap: 7px; }
.tip__key { width: 9px; height: 9px; border-radius: 2px; flex: none; }

/* ---------------------------------------------------------------- tables */

table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }

th, td { text-align: left; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--line-soft); vertical-align: baseline; white-space: nowrap; }
th:last-child, td:last-child { padding-right: 0; }

thead th { font-weight: 560; font-size: 0.8125rem; color: var(--ink-3); border-bottom-color: var(--line); vertical-align: bottom; white-space: normal; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody th { font-weight: 560; }

.muted { color: var(--ink-3); }

.token { display: grid; gap: 1px; min-width: 9.5rem; max-width: 20rem; white-space: normal; }
.token__symbol { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token__meta { font-size: 0.8125rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flag { font-size: 0.8125rem; color: var(--ink-3); }

.more { margin-top: 16px; }

.inline-bar { display: inline-block; height: 8px; border-radius: 0 3px 3px 0; background: var(--accepted); vertical-align: middle; margin-right: 8px; min-width: 1px; }

/* ---------------------------------------------------------------- footer */

.foot { border-top: 1px solid var(--line); margin-top: clamp(24px, 4vw, 48px); padding-block: 28px 44px; color: var(--ink-3); font-size: 0.875rem; }
.foot__row { display: grid; gap: 10px; }
.foot__row p { max-width: var(--measure); }
.foot__status { color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .top, .tip, .more, #theme-toggle { display: none; }
}

[hidden] { display: none !important; }
