:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface-1: #fcfcfb;
  --surface-2: #efeeea;
  --line: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-in: #2a78d6;      /* категориальный слот 1 */
  --series-out: #eb6834;     /* категориальный слот 2 */
  --tag: #e8f0fb;
  --tag-text: #1d4f8f;
  --ours: #fdf0e3;
  --ours-text: #8a4a12;
  --bad: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --line: #2f2f2c;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-in: #3987e5;
    --series-out: #d95926;
    --tag: #1c2c44;
    --tag-text: #a9c8f2;
    --ours: #3a2616;
    --ours-text: #f1c08e;
    --bad: #ff8a80;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface-1: #1a1a19; --surface-2: #242422; --line: #2f2f2c;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5; --series-in: #3987e5; --series-out: #d95926;
  --tag: #1c2c44; --tag-text: #a9c8f2; --ours: #3a2616; --ours-text: #f1c08e; --bad: #ff8a80;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--text-muted); }
.r { text-align: right; }

.top { background: var(--surface-1); border-bottom: 1px solid var(--line); padding: 18px 0 14px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 10px; color: var(--text-secondary); }
.chains { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  color: var(--text-secondary); border: 1px solid var(--line); white-space: nowrap;
}
.chip b { color: var(--text-primary); font-weight: 600; }
.chip.bad { color: var(--bad); border-color: currentColor; }

.tabs { display: flex; gap: 4px; margin: 16px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; margin-bottom: -1px;
  font: inherit; color: var(--text-secondary); cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters input[type=search], .filters select, .filters input[type=number] {
  font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px;
}
.filters input[type=search] { flex: 1 1 240px; min-width: 0; }
.filters input[type=number] { width: 64px; padding: 6px; }
.chk, .num { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); margin: 4px 0 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.in { background: var(--series-in); }
.dot.out { background: var(--series-out); }
.count { margin: 0 0 6px; color: var(--text-muted); font-size: 12px; }

.tablewrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary);
  font-weight: 600; font-size: 12px; text-align: left; white-space: nowrap;
}
.grid td { font-variant-numeric: tabular-nums; }
.grid tbody tr.tok { cursor: pointer; }
.grid tbody tr.tok:hover { background: var(--surface-2); }
.grid tbody tr.open { background: var(--surface-2); }
.sym { font-weight: 600; }
.sym img { width: 18px; height: 18px; border-radius: 50%; vertical-align: -4px; margin-right: 6px; }
.tname { color: var(--text-muted); font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--tag);
  color: var(--tag-text); margin-left: 6px; vertical-align: 1px; white-space: nowrap;
}
.badge.ours { background: var(--ours); color: var(--ours-text); }
.badge.base { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--line); }
.nowrap { white-space: nowrap; }

svg.strip { display: block; }
svg.strip .axis { stroke: var(--line); stroke-width: 1; }
svg.strip .tick { stroke: var(--line); stroke-width: 1; }
svg.strip circle, svg.strip path { stroke: var(--surface-1); stroke-width: 1; fill-opacity: .9; }
svg.strip .in { fill: var(--series-in); }
svg.strip .out { fill: var(--series-out); }
svg.strip path { stroke: none; }
svg.strip .hit { fill: transparent; stroke: none; cursor: default; }

tr.detail > td { padding: 0 0 12px; background: var(--surface-2); }
.detail-box { padding: 8px 12px 0; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px; }
.detail-meta b { color: var(--text-primary); }
table.sub { width: 100%; border-collapse: collapse; background: var(--surface-1); border-radius: 8px; overflow: hidden; }
table.sub th, table.sub td { padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
table.sub th { background: var(--surface-1); color: var(--text-muted); font-weight: 600; text-align: left; position: static; }
.topics { display: flex; flex-wrap: wrap; gap: 4px; }
.topics .badge { margin: 0; }
.copy { cursor: copy; }
.copy:hover { text-decoration: underline dotted; }
.side-in { color: var(--text-primary); }
.side-in::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--series-in); margin-right: 5px; }
.side-out::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--series-out); margin-right: 5px; }
.side-both::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(90deg, var(--series-in) 50%, var(--series-out) 50%); margin-right: 5px; }

.wtoks { display: flex; flex-wrap: wrap; gap: 4px; }
.wtoks .badge { margin: 0; cursor: pointer; }
.wtoks .badge small { opacity: .65; margin-left: 4px; font-size: 10px; }

.more {
  display: block; margin: 12px auto 32px; font: inherit; padding: 8px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-1); color: var(--text-primary); cursor: pointer;
}
.about { max-width: 760px; padding-bottom: 40px; }
.about h2 { font-size: 16px; margin: 20px 0 6px; }
.about p { margin: 0 0 10px; color: var(--text-secondary); }

.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 280px;
}
.tip .muted { font-size: 11.5px; }

@media (max-width: 640px) {
  h1 { font-size: 19px; }
  .grid th, .grid td { padding: 6px 8px; }
  .hide-sm { display: none; }
}
