:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --border: #e3e2de;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --link: #9a9993;
  --accent: #2a78d6;
  --seq: 42, 120, 214; /* sequential blue, as r,g,b for alpha ramps */
  --block-bibi: #2a78d6;
  --block-left: #eb6834;
  --block-arab: #1baf7a;
  --block-haredi: #eda100;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9b9a92;
    --link: #77766f;
    --accent: #3987e5;
    --seq: 57, 135, 229;
    --warn-bg: #3a2d10;
    --warn-ink: #f3d79a;
    --shadow: none;
    --block-bibi: #3987e5;
    --block-left: #d95926;
    --block-arab: #199e70;
    --block-haredi: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --border: #33332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9b9a92;
  --link: #77766f;
  --accent: #3987e5;
  --seq: 57, 135, 229;
  --warn-bg: #3a2d10;
  --warn-ink: #f3d79a;
  --shadow: none;
  --block-bibi: #3987e5;
  --block-left: #d95926;
  --block-arab: #199e70;
  --block-haredi: #c98500;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", sans-serif;
  padding: 24px 16px 48px;
}
main, .page-head, .filters, .page-foot { max-width: 1200px; margin-inline: auto; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 22px 0 6px; }
.lede { margin: 0; color: var(--text-2); max-width: 70ch; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

.page-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.status { margin: 0; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-size: 13px; max-width: 420px; }
.status:empty { display: none; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.field.grow { flex: 1 1 260px; }
select, input[type="text"], input:not([type]) , input[list] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
.toggles { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.toggles legend { font-size: 13px; color: var(--text-2); padding: 0; margin-bottom: 4px; }
.toggles label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.card-head p { margin: 0; }
.hint { margin: 6px 0 4px; font-size: 13px; }

.chart-scroll { overflow-x: auto; }
#sankey { display: block; width: 100%; min-width: 680px; height: auto; }
#sankey .link { fill: none; stroke: var(--link); stroke-opacity: .32; transition: stroke-opacity .12s, stroke .12s; }
#sankey .link.dim { stroke-opacity: .06; }
#sankey .link.on { stroke-opacity: .78; }
#sankey .node rect { shape-rendering: crispEdges; }
#sankey .node { cursor: pointer; outline: none; }
#sankey .node:focus-visible rect { stroke: var(--text); stroke-width: 2px; }
#sankey .node.dim rect { opacity: .35; }
#sankey text { fill: var(--text); font-size: 12px; }
#sankey text .val { fill: var(--text-2); font-variant-numeric: tabular-nums; }
#sankey .col-head { fill: var(--text-2); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 13px; color: var(--text-2); background: transparent; border: 0;
  padding: 6px 12px; cursor: pointer; min-height: 32px;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.table-scroll { overflow-x: auto; margin-top: 8px; }
table { border-collapse: separate; border-spacing: 2px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
#matrix th, #matrix td { padding: 5px 7px; text-align: right; white-space: nowrap; border-radius: 4px; }
#matrix thead th { font-weight: 600; color: var(--text-2); vertical-align: bottom; text-align: center; max-width: 92px; white-space: normal; line-height: 1.2; }
#matrix tbody th { text-align: left; font-weight: 600; }
#matrix .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
#matrix td.dark { color: #fff; }
#matrix td.zero { color: var(--text-3); }
#matrix .total { color: var(--text-2); font-weight: 600; }

table.plain { font-size: 13px; }
table.plain th, table.plain td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border); }
table.plain th:first-child, table.plain td:first-child { text-align: left; }
table.plain tr.chosen td { font-weight: 650; }
table.plain .best { color: var(--accent); }

.prose { line-height: 1.6; }
.prose p, .prose li { max-width: 80ch; color: var(--text); }
.prose ul { padding-left: 20px; }
.prose code { font-size: 13px; }
.prose a { color: var(--accent); }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 300px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.tooltip .t-title { font-weight: 650; }
.tooltip .t-he { color: var(--text-2); }
.tooltip .t-num { font-variant-numeric: tabular-nums; }
.tooltip .t-rows { display: grid; grid-template-columns: auto 1fr auto; gap: 1px 8px; }
.tooltip .t-rows .t-num { text-align: right; }

@media (max-width: 640px) {
  body { padding: 16px 16px 32px; }
  h1 { font-size: 23px; }
}

.block-legend { margin: 10px 0 0; display: grid; gap: 4px; color: var(--text-2); }
.block-legend b { color: var(--text); font-weight: 600; }
.block-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }

.cross-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
.cross-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.cross-item h3 { margin: 0 0 2px; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cross-item .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.cross-item .sub { margin: 0 0 8px; color: var(--text-2); font-size: 12.5px; }
.cross-rows { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; font-size: 13px; }
.cross-rows .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.cross-rows .num.main { color: var(--text); }

.repo-link { margin: 8px 0 0; font-size: 14px; }
.repo-link a, .page-foot a { color: var(--accent); text-decoration: none; }
.repo-link a:hover, .page-foot a:hover { text-decoration: underline; }
.page-foot { padding: 8px 0 0; font-size: 13px; color: var(--text-2); }
