:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --border: #e2e1da;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #75746f;
  --grid: #e8e7e1;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefb;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  --peer: #75746f;
  --pos: #2a78d6; --neg: #e34948; --mid: #f0efec;
  --pos-fill: rgba(42, 120, 214, 0.22); --neg-fill: rgba(227, 73, 72, 0.22);
  --warn-bg: #fff4dc; --warn-ink: #7a4b00; --warn-border: #f1d9a3;
  --err: #b42323;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33332f;
    --ink: #ffffff; --ink-2: #c3c2b7; --ink-3: #9a998f; --grid: #2b2b28;
    --accent: #3987e5; --accent-soft: #1d2b3d;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --peer: #9a998f;
    --pos: #3987e5; --neg: #e66767; --mid: #383835;
    --pos-fill: rgba(57, 135, 229, 0.28); --neg-fill: rgba(230, 103, 103, 0.28);
    --warn-bg: #33270f; --warn-ink: #f1c879; --warn-border: #5a4415;
    --err: #ff8a80;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33332f;
  --ink: #ffffff; --ink-2: #c3c2b7; --ink-3: #9a998f; --grid: #2b2b28;
  --accent: #3987e5; --accent-soft: #1d2b3d;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --peer: #9a998f;
  --pos: #3987e5; --neg: #e66767; --mid: #383835;
  --pos-fill: rgba(57, 135, 229, 0.28); --neg-fill: rgba(230, 103, 103, 0.28);
  --warn-bg: #33270f; --warn-ink: #f1c879; --warn-border: #5a4415;
  --err: #ff8a80;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); overflow-x: hidden; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.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; background: var(--surface); padding: 6px 10px; border-radius: 6px; z-index: 20; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 17px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); }
.back { color: var(--ink-2); text-decoration: none; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); }
.back:hover { color: var(--ink); }

main { max-width: 1280px; margin: 0 auto; padding: 0 16px 24px; }
.hero { padding: 8px 0 14px; max-width: 760px; }
.hero h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; margin: 6px 0 8px; letter-spacing: -0.01em; }
.hero p { margin: 0; color: var(--ink-2); }

.layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: 310px minmax(0, 1fr); align-items: start; }
  .panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
}
.panel, .results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 14px 0 8px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head h2 { margin-bottom: 2px; }
.card-head p { margin: 0; max-width: 640px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }

.samples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.sample { text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 44px; }
.sample strong { font-size: 14px; }
.sample span { font-size: 12px; color: var(--ink-2); }
.sample:hover { border-color: var(--accent); }
.sample[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.drop { border: 1.5px dashed var(--border); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.drop strong { color: var(--ink); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.linkish { color: var(--accent); text-decoration: underline; }
.row-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; font-size: 13px; text-decoration: underline; min-height: 32px; }
.link-btn.danger { color: var(--err); }
textarea { width: 100%; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 8px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; min-height: 38px; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--border); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); filter: none; }
.small-btn { padding: 4px 10px; font-size: 13px; min-height: 32px; }
#pasteLoad { margin-top: 8px; }
.msg { font-size: 13px; margin-top: 8px; }
.msg:empty { display: none; }
.msg .ok { color: var(--ink-2); }
.msg .bad { color: var(--err); }
.msg ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 600; min-height: 34px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink-3); background: transparent; }
.chip[aria-pressed="true"] { background: var(--surface-2); border-color: var(--ink-3); }
.chip[aria-pressed="false"] { color: var(--ink-2); font-weight: 500; }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 13px; min-height: 32px; min-width: 40px; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pill:disabled { opacity: .4; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; }

.datasets { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.datasets summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.ds-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.ds-table th { text-align: left; color: var(--ink-2); font-weight: 600; padding: 3px 4px; }
.ds-table td { padding: 3px 4px; border-top: 1px solid var(--border); vertical-align: middle; }
.ds-table input { width: 100%; min-width: 64px; max-width: 110px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 2px 5px; font-size: 12px; font-weight: 600; }
.ds-table .rm { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 4px 6px; }
.ds-table .rm:hover { color: var(--err); }

.empty p { margin: 0 0 12px; max-width: 640px; }
.banner { display: flex; align-items: center; gap: 8px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-border); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-bottom: 12px; }
.notes { margin: 0 0 12px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.notes:empty { display: none; }
.notes li { font-size: 13px; color: var(--ink-2); padding-left: 16px; position: relative; }
.notes li::before { content: "i"; position: absolute; left: 0; top: 1px; font-size: 10px; width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--ink-3); display: grid; place-items: center; font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tile .v { font-size: 22px; font-weight: 700; line-height: 1.25; margin-top: 2px; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }
.tile .d { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.tile .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.up { color: var(--ink); }
.pos-text { color: var(--pos); font-weight: 600; }
.neg-text { color: var(--neg); font-weight: 600; }
.results > .card + .card, #out > .card { margin-bottom: 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 4px; font-size: 13px; }
.legend button { background: none; border: 0; padding: 2px 0; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--ink); font-weight: 600; min-height: 28px; }
.legend button[aria-pressed="false"] { color: var(--ink-3); font-weight: 400; text-decoration: line-through; }
.legend .ln { width: 16px; height: 0; border-top: 2.5px solid; display: inline-block; }
.legend .ln.dashed { border-top-style: dashed; }
.chart { width: 100%; min-height: 120px; position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-svg .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-svg .tick { stroke: var(--ink-3); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .axis-label { fill: var(--ink-2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-svg .series { stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .series.muted { opacity: .18; }
.chart-svg .crosshair { stroke: var(--ink-3); stroke-width: 1; }
.chart-svg .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { cursor: crosshair; }

.multiples { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mult { border: 1px solid var(--border); border-radius: 10px; padding: 10px 10px 4px; min-width: 0; }
.mult-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mult-head .name { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.mult-head .name .sw { width: 10px; height: 10px; border-radius: 50%; }
.mult-head .stat { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mult .solo { font-size: 13px; color: var(--ink-2); padding: 18px 4px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
table.heat th { font-weight: 600; padding: 4px 6px; text-align: center; white-space: nowrap; }
table.heat th[scope="row"] { text-align: right; }
table.heat td { width: 58px; min-width: 52px; height: 36px; text-align: center; border-radius: 4px; color: var(--ink); }
table.heat td.strong { color: #ffffff; }
table.heat td.diag { color: var(--ink-3); background: var(--surface-2); }

table.sum { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.sum th { text-align: right; font-weight: 600; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
table.sum th button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
table.sum th[aria-sort] button::after { content: " \2193"; }
table.sum th[aria-sort="ascending"] button::after { content: " \2191"; }
table.sum td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.sum td .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
table.sum td.sym { font-weight: 700; }
table.sum td small { color: var(--ink-3); }

.faq dl { margin: 0; }
.faq dt { font-weight: 600; margin-top: 10px; }
.faq dd { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }

.foot { max-width: 1280px; margin: 0 auto; padding: 8px 16px 32px; color: var(--ink-2); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot p { margin: 0; }

.tip { position: absolute; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .14); min-width: 150px; max-width: 260px; }
.tip-date { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip-row .sw { width: 10px; height: 3px; border-top: 2px solid; flex: none; }
.tip-row .sw.dashed { border-top-style: dashed; height: 0; }
.tip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-val { font-weight: 600; }
.tip-spread { margin-top: 4px; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 60; }

@media (max-width: 480px) {
  .samples { grid-template-columns: 1fr; }
  .tile .v { font-size: 19px; }
  .card { padding: 12px; }
}
@media (forced-colors: active) {
  .chart-svg .series { stroke: CanvasText !important; }
}
