:root {
  --bg: #ffffff;
  --card: #ffffff;
  --card-tint: #f4f7fe;
  --fg: #1c1d21;
  --muted: #5d6068;
  --line: #d9dce3;
  --accent: #0038b8;
  --accent-fg: #ffffff;
  --chip: #e9eefb;
  --focus: #0038b8;
  --radius: 12px;
  --gutter: 16px;

  /* Severity scale: distance only, never good/bad. Each is paired with an icon and a label. */
  --agree-bg: #d9f0e1; --agree-fg: #14532d;
  --minor-bg: #fbf0bf; --minor-fg: #5f4500;
  --major-bg: #fddcbc; --major-fg: #7a2e0e;
  --clash-bg: #f7c9c9; --clash-fg: #7f1d1d;
  --none-bg: #eceef1; --none-fg: #4b5563;
  --ref-bg: #e3eafb; --ref-fg: #0a2a7a;
  /* Missing data, not distance: neutral, with a dashed edge and the ⚠ icon. */
  --warn-bg: #f1f2f5; --warn-fg: #3d4048;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  padding-block-end: 24px;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin-block-start: 1.6em; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; margin-block-start: .8em; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-inline-size: 720px; margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* The shell waits for the first render (#45): the empty skeleton would paint, then everything would move (CLS). Hidden
   elements keep their layout and don't count as a shift. If app.js never runs (blocked, or an old browser), the
   animation shows the shell after 3s anyway: no blank page. */
html:not(.ready) :is(main, #footer, .topnav) { visibility: hidden; animation: shell-reveal 0s 3s forwards; }
@keyframes shell-reveal { to { visibility: visible; } }
.skip { position: absolute; inset-inline-start: 8px; inset-block-start: -40px; background: var(--card); padding: 6px 10px; z-index: 30; }
.skip:focus { inset-block-start: 8px; }




/* presets */

/* builder */
.icon-btn {
  min-inline-size: 44px; min-block-size: 44px; border: 0; border-radius: 8px; background: transparent;
  cursor: pointer; font-size: 1.1rem; display: inline-grid; place-items: center;
}
.link-btn { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 8px 4px; min-block-size: 44px; }
.note { background: var(--card); border-inline-start: 4px solid var(--accent); padding: 8px 12px; border-radius: 6px; margin-block: 8px; font-weight: 600; }


.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--chip); color: var(--fg); font-weight: 500; vertical-align: middle; }
.tag-red { background: var(--clash-bg); color: var(--clash-fg); }
/* A tag whose text can run to several lines (#31): a box with a small radius, not a pill. */
.tag-box { border-radius: 6px; padding: 3px 8px; line-height: 1.45; max-inline-size: 100%; }
.tag-src { background: var(--ref-bg); color: var(--ref-fg); }
.tag-warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px dashed var(--muted); white-space: normal; }
.tag-split { background: #ece4f5; color: #4c2a7a; }
/* The votes line (#30): each segment stays whole; lines break only between segments. */
.nw { white-space: nowrap; }
.note-soft { font-weight: 500; border-inline-start-color: var(--muted); font-size: .9rem; }
.footnote { margin-block-start: 12px; font-size: .85rem; color: var(--muted); }
.footnote p { margin: 0 0 .3em; }

/* severity badges */
.lv { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.lv-AGREE { background: var(--agree-bg); color: var(--agree-fg); }
.lv-MINOR { background: var(--minor-bg); color: var(--minor-fg); }
.lv-MAJOR { background: var(--major-bg); color: var(--major-fg); }
.lv-CLASH { background: var(--clash-bg); color: var(--clash-fg); }
.lv-NONE, .lv-NODATA, .lv-BASE_NULL { background: var(--none-bg); color: var(--none-fg); }
.lv-REF { background: var(--ref-bg); color: var(--ref-fg); }

/* results */
.results { outline: none; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); margin-block-start: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-block-start: 12px; }
.card h3 { margin-block-end: .6em; }
.list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.list li { display: block; }
.row-btn { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; inline-size: 100%; text-align: start; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; min-block-size: 44px; }
.row-btn:hover { border-color: var(--accent); }
.row-title { font-weight: 600; margin: 0; }
.btn { min-block-size: 44px; padding: 8px 16px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-fg); cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.btn-ghost { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.share-row { margin-block-start: 12px; }
.segs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.seg { display: grid; justify-items: center; padding: 6px 0 4px; border-radius: 6px; font-size: .95rem; }
.seg-label { font-size: .62rem; font-weight: 600; white-space: nowrap; hyphens: none; -webkit-hyphens: none; }

.pos-label { font-weight: 700; }
.pos-label.none { color: var(--none-fg); }
blockquote { margin: .4em 0 .6em; padding-inline-start: 12px; border-inline-start: 3px solid var(--line); color: var(--muted); }
.source { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .85rem; }
/* The links behind "every position has a source" (#43): a 44px hit area around the text, the layout unchanged. The
   pseudo-element is centered on the link (top = half its height minus 24px: 48px tall, so rounding never takes it under 44) and hit-tests as the link. */
.source a, .correction a, .recs-table td a { position: relative; }
.source a::after, .correction a::after, .recs-table td a::after { content: ''; position: absolute; inset-block: calc(50% - 24px); inset-inline: -6px; }

.pair-row { border-block-start: 1px solid var(--line); padding-block: 8px; }
.pair-row summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-block-size: 44px; }
.pair-row summary::-webkit-details-marker { display: none; }
.pair-topic { font-weight: 700; }
.pair-labels { display: grid; gap: 2px; inline-size: 100%; font-size: .85rem; color: var(--muted); }
.pair-detail { padding-block: 6px; }
.profile .card h3 { font-size: 1rem; }

/* matrix */
.table-wrap { overflow-x: auto; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
.matrix { border-collapse: separate; border-spacing: 1px 2px; inline-size: 100%; table-layout: fixed; }
.matrix th[scope="row"] { position: sticky; inset-inline-start: 0; background: var(--bg); z-index: 1; inline-size: 74px; text-align: start; }
.matrix thead td { inline-size: 74px; }
.party-btn { border: 0; background: none; font-size: .78rem; font-weight: 600; line-height: 1.2; text-align: start; padding: 4px 2px; cursor: pointer; min-block-size: 40px; inline-size: 100%; }
.topic-btn { border: 0; background: none; font-size: .66rem; font-weight: 700; letter-spacing: -.02em; padding: 4px 0; cursor: pointer; inline-size: 100%; min-block-size: 32px; }
.cell { position: relative; inline-size: 100%; min-inline-size: 30px; block-size: 44px; border: 0; border-radius: 6px; cursor: pointer; font-size: 1rem; font-weight: 700; }
.cell.lv-CLASH { box-shadow: inset 0 0 0 2px var(--clash-fg); }
.cell .flag { position: absolute; inset-block-start: 1px; inset-inline-end: 1px; font-size: .55rem; line-height: 1; }
.cell .split { position: absolute; inset-block-end: 1px; inset-inline-start: 2px; font-size: .6rem; line-height: 1; color: #4c2a7a; }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* bottom bar */

/* sheet */
.sheet {
  border: 0; padding: 0; margin: 0; margin-block-start: auto; inline-size: 100%; max-inline-size: 720px; margin-inline: auto;
  border-radius: 16px 16px 0 0; background: var(--card); color: var(--fg);
  /* Never taller than what is visible (#30). vh is the viewport with the browser's bars hidden, so 88vh alone can run
     under the address bar once the bars come back. 100% is the box the sheet is fixed in (the visible viewport on a
     phone); dvh and --vvh (visualViewport.height, kept by app.js while the sheet is open) follow the bars. Each line
     falls back to the one before it in older browsers. */
  --sheet-room: calc(16px + env(safe-area-inset-top, 0px));
  max-block-size: 88vh;
  max-block-size: min(88vh, calc(100% - var(--sheet-room)));
}
@supports (max-block-size: 1dvh) {
  .sheet { max-block-size: min(88dvh, calc(100% - var(--sheet-room)), calc(var(--vvh, 100dvh) - var(--sheet-room))); }
}
.sheet::backdrop { background: rgba(20, 22, 28, .45); }
.sheet-inner { padding: 8px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
.sheet h2 { margin-block-start: 0; }
/* Sticky bar on every sheet: back (when there is one) at the start, close at the end. */
.sheet-head { position: sticky; inset-block-start: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding-block: 6px; padding-inline: 8px; background: var(--card); border-block-end: 1px solid var(--line); }
.sheet-back { display: inline-flex; align-items: center; gap: 2px; text-align: start; padding-inline: 4px 8px; font-size: .95rem; min-inline-size: 0; }
.chev-back { inline-size: 18px; block-size: 18px; font-size: 1rem; }
[dir="rtl"] .chev-back { transform: scaleX(-1); }
.sheet-close { flex: none; margin-inline-start: auto; inline-size: 44px; block-size: 44px; min-inline-size: 44px; min-block-size: 44px; border: 0; border-radius: 50%; background: var(--chip); color: var(--fg); font-size: 1.1rem; cursor: pointer; display: grid; place-items: center; }
.sheet-close:hover { background: #dbe3f7; }
.sheet-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sheet .seat-src { font-size: .85rem; color: var(--muted); margin-block-end: 4px; }
.why { margin: .2em 0 .6em; padding-inline-start: 1.2em; }
/* "Why this color" (#30): the badge on its own line, the sentence under it. */
.why-row { margin: 0 0 .5em; }
.why-row .lv { display: inline-flex; margin-block-end: 4px; }
.why-row .why-text { display: block; }
.pair-detail .why-row { margin-block-end: .6em; }
.compare { display: grid; gap: 4px; margin-block: 8px 12px; font-weight: 600; }
.closest-open { text-align: start; }
.closest-partial { margin-block-start: 12px; }
.closest-toggle, .closest-only { text-align: start; font-weight: 600; }
.compare select { min-block-size: 44px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
/* Pair view (#23): two pickers stacked on a phone, side by side from 600px. */
.pair-pickers { display: grid; gap: 0 12px; }
.pair-pickers .compare { min-inline-size: 0; }
.pair-pickers select { inline-size: 100%; max-inline-size: 100%; }
.pair-share { display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 600px) {
  .pair-pickers { grid-template-columns: 1fr 1fr; }
}
.axis-list { padding-inline-start: 1.2em; }
.axis-list li { margin-block-end: .5em; }
.axis-parties { display: block; font-size: .85rem; font-weight: 600; color: var(--accent); }
.axis-seats { display: block; font-size: .85rem; color: var(--muted); }

.toast { position: fixed; inset-inline: var(--gutter); inset-block-end: 150px; z-index: 40; max-inline-size: 480px; margin-inline: auto; background: var(--fg); color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.toast[hidden] { display: none; }

/* methodology */
.method { margin-block-start: 32px; border-block-start: 1px solid var(--line); }
.method h3 { margin-block-start: 1.2em; }
.disclaimer { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
/* A rule set out as lists (#32). */
.rule-sub { font-size: .95rem; margin-block: .8em .3em; color: var(--fg); }
.rule-list, .rule-steps { margin-block: 0 .6em; padding-inline-start: 1.4em; }
.rule-list li, .rule-steps li { margin-block-end: .35em; }
.rule-order-intro { margin-block-end: .3em; }
.rule-after { margin-block-end: .3em; }
.level-rules { list-style: none; padding: 0; display: grid; gap: 6px; }
details.axis { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-block-end: 6px; }
details.axis summary { cursor: pointer; font-weight: 600; min-block-size: 32px; }
/* Method page: the five collapsed groups. The heading sits inline in the summary, beside the native marker (which points
   the right way in both directions). */
details.mgroup { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; margin-block: 10px; }
details.mgroup > summary { cursor: pointer; padding-block: 10px; min-block-size: 44px; box-sizing: border-box; }
details.mgroup > summary > .mgroup-title { display: inline; font-size: 1.15rem; margin: 0; }
details.mgroup[open] { padding-block-end: 12px; }
details.mgroup[open] > summary { border-block-end: 1px solid var(--line); margin-block-end: 12px; }
.method-end { margin-block-start: 20px; }
.coverage { border-collapse: collapse; inline-size: 100%; font-size: .85rem; }
.coverage th, .coverage td { border-block-end: 1px solid var(--line); padding: 6px 4px; text-align: start; font-variant-numeric: tabular-nums; }

.footer { margin-block-start: 32px; padding-block: 16px; border-block-start: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.footer p { margin: 0 0 .3em; }

@media (min-width: 600px) {
  .party-btn { font-size: .85rem; }
  .topic-btn { font-size: .8rem; }
  .matrix th[scope="row"], .matrix thead td { inline-size: 120px; }
}
/* Every animation and transition sits here, so none runs under prefers-reduced-motion: reduce (smoke runs that way). */
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: up .18s ease-out; }
  .chev { transition: transform .15s; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } }
}

/* ===== round 3: views, header, chips, bar ===== */
.view[hidden] { display: none; }
.topbar { border-block-end: 1px solid var(--line); background: var(--card); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-block-size: 52px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: -.01em; }
.navlink { color: var(--accent); font-size: .95rem; padding: 10px 4px; }
.topnav { display: inline-flex; align-items: center; gap: 10px; }
/* Language switch: its own element at the header's end, set off from the nav by a thin divider. */
.langswitch { display: inline-flex; align-items: center; gap: 6px; padding-inline-start: 10px; border-inline-start: 1px solid var(--line); font-size: .9rem; white-space: nowrap; }
.langswitch strong { color: var(--fg); font-weight: 700; }
.lang-sep { color: var(--muted); }
.lang-btn { border: 0; background: none; padding: 10px 8px; min-inline-size: 44px; min-block-size: 44px; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.lang-note { margin-block: 8px 0; color: var(--muted); font-size: .85rem; }
.lang-note[hidden] { display: none; }
.brand-name, .navlink { white-space: nowrap; }
/* At least 16px between the brand and the nav, in both directions. */
.topbar-in { gap: 16px; }
/* Phones: a slightly smaller brand so logo, nav and language switch fit on one line at 360; the overview's 8 topics as
   a 4×2 grid of whole words. (Matrix headers are vertical on phones in both languages: see below.) */
.nav-short { display: none; }
@media (max-width: 400px) {
  /* The header tightens with the screen (#36), from these sizes at 400px down to the tightest at 360px: brand and logo
     smaller, the nav's spacing closer. No script measures it, so nothing moves after the first paint. A device font
     wider than ours (Samsung's Hebrew font) still fits on one line at 360. The 16px between the brand and the nav stays. */
  .brand { font-size: clamp(1rem, calc(1rem + (100vw - 360px) * .04), 1.1rem); gap: clamp(5px, calc(5px + (100vw - 360px) * .075), 8px); }
  .brand .logo { inline-size: clamp(24px, calc(24px + (100vw - 360px) * .15), 30px); block-size: clamp(32px, calc(32px + (100vw - 360px) * .2), 40px); }
  .topnav { gap: clamp(6px, calc(6px + (100vw - 360px) * .1), 10px); }
  .langswitch { gap: clamp(4px, calc(4px + (100vw - 360px) * .05), 6px); padding-inline-start: clamp(6px, calc(6px + (100vw - 360px) * .1), 10px); }
  .navlink { padding-inline: clamp(2px, calc(2px + (100vw - 360px) * .05), 4px); }
  .nav-long { display: none; }
  .nav-short { display: inline; }
  .lang-note { font-size: .78rem; }
  .matrix th[scope="row"], .matrix thead td { inline-size: 80px; }
}
/* English above 400px has the longer "How it works" and little room left at 401-440px (#36): it tightens the same way,
   from the 400px sizes at 400 to the full ones at 440. Hebrew has room there and is unchanged. */
@media (min-width: 401px) and (max-width: 440px) {
  [dir="ltr"] .brand { font-size: clamp(1.1rem, calc(1.1rem + (100vw - 400px) * .06), 1.25rem); gap: clamp(5px, calc(5px + (100vw - 400px) * .075), 8px); }
  [dir="ltr"] .topnav { gap: clamp(6px, calc(6px + (100vw - 400px) * .1), 10px); }
  [dir="ltr"] .langswitch { gap: clamp(4px, calc(4px + (100vw - 400px) * .05), 6px); padding-inline-start: clamp(6px, calc(6px + (100vw - 400px) * .1), 10px); }
  [dir="ltr"] .navlink { padding-inline: clamp(2px, calc(2px + (100vw - 400px) * .05), 4px); }
}
/* Larger text: the header wraps (the nav drops to a second line) rather than pushing the page sideways (#35). */
.topbar-in { flex-wrap: wrap; row-gap: 0; }
@media (max-width: 600px) {
  .segs { grid-template-columns: repeat(4, 1fr); }
}
/* Overview tile labels at 12px on phones (#43), like the matrix headers (#11). A long English name breaks at its soft
   hyphens (Pales·tin·ian) rather than leave its tile. */
@media (max-width: 480px) {
  .seg-label { font-size: .75rem; white-space: normal; hyphens: manual; -webkit-hyphens: manual; text-align: center; line-height: 1.15; }
}
/* English link texts are longer; let them wrap rather than overflow a phone screen. */
[dir="ltr"] .seat-src a, [dir="ltr"] .voter-info a { white-space: normal; }
/* English pages show the required Hebrew poll sentence verbatim, on its own line, before the translation. */
.legal-he { display: block; margin-block-end: 2px; }
/* English short topic names carry soft hyphens (Judi·ciary): a matrix header breaks there, onto two or three lines. */
[dir="ltr"] .topic-btn { hyphens: manual; -webkit-hyphens: manual; line-height: 1.15; }
/* On phones the topic names are set vertically in both languages (#35), with the same head tilt: letter tops face the
   start of the table's columns (left), as on a book spine. English then reads bottom to top; Hebrew, which starts at
   the word's right end, reads top to bottom. In both the text sits at the end next to the cells. Horizontal Hebrew
   headers only fit while each word happened to fit its column, which a wider device font or larger text breaks. */
@media (max-width: 480px) {
  /* One card per column (#35): its physical width is the column's content width, like the cells under it, so the
     headers have the same gaps as the cells (vertical text: width is the block size, so it is set physically). */
  /* .matrix raises it above the later base rule (padding 4px 1px, min-block-size 30px), which in vertical text is a
     30px minimum width. */
  /* 12px (#11): the base rule's .62rem (about 10px) was too small to read. */
  .matrix .topic-btn { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; inline-size: auto; min-inline-size: 6.8em; width: 100%; min-block-size: 0; margin: 0; padding: 6px 0; font-size: .75rem; }
  /* After the rotation the bottom is the inline start in LTR and the inline end in RTL. */
  [dir="ltr"] .matrix .topic-btn { text-align: start; }
  [dir="rtl"] .matrix .topic-btn { text-align: end; letter-spacing: 0; }
}
.intro { font-size: 1.08rem; margin-block: 16px 4px; font-weight: 600; }
h2 { margin-block-start: 1.2em; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-block-end: 6px; }
.preset { min-block-size: 52px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--accent); background: var(--card); color: var(--accent); cursor: pointer; font-weight: 600; line-height: 1.25; }
.preset:hover { background: var(--chip); }

.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.im-ok { color: #14532d; } .im-clash { color: #991b1b; } .im-unk { color: #6b7280; }
.impact-legend { white-space: normal; }

/* sticky bottom bar (build view): constrained to the 720px column */
.bar { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 20; inline-size: 100%; max-inline-size: 720px; margin-inline: auto;
  background: var(--card); border: 1px solid var(--line); border-block-end: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(0,0,0,.07);
  display: flex; align-items: center; gap: 12px; padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom)); }
.bar[hidden] { display: none; }
.seats { flex: 1; min-inline-size: 0; }
.seats-line { margin: 0; font-size: .95rem; }
.meter { block-size: 5px; background: var(--chip); border-radius: 999px; overflow: hidden; margin-block: 4px; }
.meter span { display: block; block-size: 100%; background: var(--accent); }
.poll-btn { border: 0; background: none; padding: 2px 0; font-size: .75rem; color: var(--muted); cursor: pointer; text-align: start; }
.bar .btn { white-space: nowrap; }

/* results view */
.resbar { position: sticky; inset-block-start: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding-block: 8px; border-block-end: 1px solid var(--line); }
.back { color: var(--accent); font-weight: 700; text-decoration: none; padding: 10px 4px; display: inline-block; }
.btn-small { min-block-size: 44px; padding: 6px 16px; }
.card-title { margin: 0 0 .5em; font-size: 1.05rem; }
.breakdown-label { margin: 10px 0 -4px; }
.breakdown { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .88rem; font-weight: 600; }
.bd-ok { color: #14532d; } .bd-minor { color: #5f4500; } .bd-major { color: #7a2e0e; } .bd-clash { color: #7f1d1d; } .bd-none { color: #4b5563; }
.overall .seats-line { margin-block-start: 8px; }
.row-btn { display: block; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-block-start: 6px; }
.page-title { font-size: 1.5rem; margin-block-start: 8px; }

/* matrix: wrap long party names, boxed topic headers */
.matrix { border-spacing: 2px; }
.matrix th[scope="row"] { inline-size: 86px; padding-inline-end: 4px; }
.matrix thead td { inline-size: 86px; }
.party-btn { font-size: .72rem; line-height: 1.15; overflow-wrap: anywhere; word-break: break-word; hyphens: auto; display: block; padding: 2px; }
.topic-btn { background: var(--chip); border-radius: 6px; font-size: .62rem; padding: 4px 1px; min-block-size: 30px; }
.cell { min-inline-size: 28px; }

@media (min-width: 600px) {
  .matrix th[scope="row"], .matrix thead td { inline-size: 130px; }
  .topic-btn { font-size: .78rem; }
  .party-btn { font-size: .85rem; }
}


#view-method .method { margin-block-start: 0; border-block-start: 0; }
#view-method > p { margin: 0; }

/* add-impact pills: larger, higher contrast */
.im-ok { background: #bbf7d0; color: #052e16; }
.im-clash { background: #fecaca; color: #450a0a; }
.im-unk { background: #e5e7eb; color: #111827; }
.impact-legend .im-ok, .impact-legend .im-clash, .impact-legend .im-unk { padding: 0 6px; border-radius: 999px; font-weight: 800; }

/* sticky bar: seats + button on top, then the progress bar and the full poll sentence */
.poll-legal { margin: 4px 0 0; font-size: .95rem; line-height: 1.4; color: var(--fg); }
.poll-legal .poll-btn { font-size: .95rem; color: var(--accent); padding: 0 4px; }
.overall .poll-legal { margin-block-start: 6px; }
.coalition-line { margin: 10px 0 0; font-size: .95rem; font-weight: 600; }
/* The undo line (#29): in the flow above the coalition header, never floating; the text wraps, the buttons stay at the end. */
.undo-line { display: flex; align-items: center; gap: 4px; margin-block-start: 10px; padding-block: 0; padding-inline: 12px 2px; background: var(--chip); border-radius: 10px; }
.undo-text { flex: 1 1 auto; min-inline-size: 0; margin: 0; padding-block: 8px; font-size: .95rem; }
.undo-line .link-btn { flex: none; font-size: .95rem; padding-inline: 8px; }
.undo-close { flex: none; inline-size: 44px; block-size: 44px; border: 0; border-radius: 50%; background: none; color: var(--fg); font-size: 1rem; cursor: pointer; display: grid; place-items: center; }
.undo-close:hover { background: #dbe3f7; }
/* Parties outside the coalition: one neutral marker everywhere (dashed outline, no fill, no colour); the role is in the text. */
.outside { display: inline-block; max-inline-size: 100%; border: 1px dashed var(--muted); border-radius: 8px; padding: 0 .45em; overflow-wrap: anywhere; }
.coalition-outside { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-block-start: 6px; }
.outside-list { display: flex; flex-wrap: wrap; gap: 4px 6px; list-style: none; margin: 0; padding: 0; min-inline-size: 0; }
.outside-block { margin-block-start: 10px; padding-block-start: 8px; border-block-start: 1px dashed var(--muted); }
.outside-block h3 { margin: 0; font-size: .95rem; }
.minor-line { margin: 10px 0 0; font-weight: 600; }
.links { padding-inline-start: 1.2em; }
/* The poll-info sheet's two links (#63): a 44px hit area (#43), the layout unchanged. Vertical padding on an inline link
   grows its hit area without moving a line, and the two lines are 25px apart, so the areas meet midway: 3px into the
   gap between them, 24px outward (above the first, below the second). 18px of text + 27px = 45px each. */
.sheet .links a { padding-block: 3px; }
.sheet .links li:first-child a { padding-block-start: 24px; }
.sheet .links li:last-child a { padding-block-end: 24px; }


.purpose { margin: 0 0 8px; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.correction { margin-block-start: 16px; padding-block-start: 10px; border-block-start: 1px solid var(--line); font-size: .9rem; }

/* ===== round 5: Israeli look, seats box, footer ===== */
.topbar { border-block-end: 1px solid var(--line); }
/* One 4px accent stripe across the top (it was two stripes, 11px in all), above the header's 1px bottom border. */
.topbar::before { content: ""; display: block; block-size: 4px; background: var(--accent); }
h1, h2, h3 { color: var(--accent); }
.brand { color: var(--accent); }
.intro { color: var(--fg); }
.meter span { background: var(--accent); }
.meter { background: #dbe4fa; }

.preset { border-color: var(--accent); }

/* seats box above the chips */
.seats-box { background: var(--card-tint); border: 1px solid #c3cff0; border-radius: 10px; padding: 10px 14px; margin-block: 10px; }
.seats-box h3 { margin: 0 0 4px; font-size: 1rem; }
.seats-box .seats-line { font-size: 1.05rem; }
.seats-box .poll-legal, .overall .poll-legal { font-size: 1.05rem; }
.seats-line { white-space: nowrap; }
.seats-line { font-size: 1.05rem; }
.seats-line.muted { white-space: normal; }
.seats-line.vote-line { white-space: normal; }

/* sticky bar: party count + button only */
.bar { justify-content: space-between; }
.bar-count { font-weight: 700; color: var(--fg); }
/* Room for the fixed bar, only while it is shown (a party is selected). */
body[data-view="build"]:has(#bar:not([hidden])) { padding-block-end: 100px; }
.toast { inset-block-end: 100px; }

.why-box { background: var(--card-tint); border: 1px solid #c3cff0; border-radius: 12px; padding: 4px 16px 8px; margin-block: 12px 20px; scroll-margin-block-start: 12px; }
.why-box h2 { margin-block-start: .6em; }

/* footer */
.footer { text-align: center; color: var(--muted); }
.footer .f-by { font-weight: 700; font-size: .95rem; }
.footer .f-by a { color: var(--accent); }
.f-icons { display: flex; justify-content: center; gap: 8px; }
.f-icons a { display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px; color: var(--accent); border-radius: 50%; }
.f-icons svg { inline-size: 24px; block-size: 24px; }
.f-links a { display: inline-block; padding: 12px 2px; }
.f-meta { font-size: .8rem; }
.f-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; }
.logo { inline-size: 30px; block-size: 40px; }

/* ===== round 6: pair labels ===== */
.pair-sum { display: block; margin-block-start: 2px; font-size: .8rem; color: var(--muted); font-weight: 400; }
.pair-labels { gap: 8px; }
.pair-labels > span { color: var(--fg); }
.pair-sum { font-size: .78rem; color: var(--muted); }

/* ===== round 7: party list picker, gap cards, base control, quotes ===== */
.plist { list-style: none; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.prow { position: relative; border-block-end: 1px solid var(--line); background: #fff; }
.prow:last-child { border-block-end: 0; }
.prow.is-on { background: #eef3fd; }
.prow-main { display: flex; align-items: center; gap: 10px; inline-size: 100%; min-block-size: 56px; padding: 6px 12px; background: none; border: 0; text-align: start; cursor: pointer; color: var(--fg); }
.prow-main:hover { background: #f6f8fd; }
.cb { flex: none; inline-size: 24px; block-size: 24px; border: 2px solid #6b7280; border-radius: 6px; background: #fff; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem; line-height: 1; }
.prow.is-on .cb { background: var(--accent); border-color: var(--accent); }
.slip-tag { flex: none; min-inline-size: 42px; text-align: center; padding: 2px 6px; border: 1px solid #b7bcc8; border-radius: 4px; background: #fff; color: var(--fg); font-weight: 800; font-size: .95rem; line-height: 1.3; }
.prow-text { flex: 1; min-inline-size: 0; display: grid; gap: 1px; }
.prow-name { font-weight: 600; line-height: 1.25; }
.prow-sub { font-size: .78rem; color: var(--muted); }
.prow-end { flex: none; inline-size: 126px; display: flex; justify-content: flex-start; }
.pills { display: grid; grid-template-columns: repeat(3, 40px); gap: 3px; }
.pill { text-align: center; border-radius: 999px; font-weight: 800; font-size: .8rem; line-height: 1.5; font-variant-numeric: tabular-nums; }

.row-btn.gap-head, .row-btn.closest-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gap-main, .closest-main { display: grid; gap: 4px; flex: 1; min-inline-size: 0; }
[dir="ltr"] .closest-row .chev { transform: scaleX(-1); }
.closest-counts { gap: 2px 6px; }
.chev { flex: none; font-size: 1.7rem; line-height: 1; color: var(--accent); }
.gap.is-open .chev { transform: rotate(-90deg); }
/* The chevron points to the reading direction's end; open, it points down in both directions. */
[dir="ltr"] .gap:not(.is-open) .chev { transform: scaleX(-1); }
.pair-list { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 4px; }
.pair-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; inline-size: 100%; min-block-size: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: start; cursor: pointer; }
.pair-btn:hover { border-color: var(--accent); }

.colorby { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-block: 8px; }
.colorby-label { font-weight: 700; margin-inline-end: 2px; }
.seg-btn { min-block-size: 44px; padding: 4px 12px; border: 1px solid #9aa3b5; border-radius: 999px; background: #fff; color: var(--fg); font-size: .9rem; cursor: pointer; }
.seg-btn.is-on { background: #eef3fd; border: 2px solid var(--accent); font-weight: 700; padding: 3px 11px; }

blockquote { margin: .4em 0 .6em; }
blockquote p { margin: 0; }
.q-by { margin-block-start: 4px; font-size: .8rem; color: var(--muted); font-style: normal; }
.chev { inline-size: 24px; block-size: 24px; }

/* round 8 */
.prow-main:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.pair-list-head { margin: 8px 0 2px; font-weight: 700; font-size: .9rem; }
.q-trans { margin-block-start: 6px; }

/* round 9: voter info */
.voter-info { margin: 0 0 8px; padding: 8px 12px; background: var(--card-tint); border: 1px solid #c3cff0; border-radius: 8px; font-size: .95rem; font-weight: 600; line-height: 1.5; }
.voter-info a { white-space: nowrap; }
.anchor { scroll-margin-block-start: 12px; }
.anchor:focus { outline: none; }
/* round 10: legal sentence above the seat numbers */
.seats-box .poll-legal { margin: 0 0 8px; }
.overall .poll-legal { margin-block: 10px 6px; }
.overall .seats-line { margin-block-start: 0; }

/* Results mode */
.seat-src { margin: 0 0 8px; font-size: 1.05rem; line-height: 1.4; color: var(--fg); }
.seat-src a { white-space: nowrap; }
.overall .seat-src { margin-block: 10px 6px; }
/* The factions' recommendations to the President (#4): a line under the results line, and its sheet */
.positions-asof + .recs-line { margin-block-start: -8px; }
.recs-line { margin: 0 0 4px; }
.recs-line .link-btn { padding-inline: 0; text-align: start; font-size: .95rem; }
.recs-src { margin: 0 0 6px; font-size: .85rem; color: var(--muted); }
.recs-src a, .recs-table td a { white-space: nowrap; }
/* Rows at least 44px tall, so each date link's 44px hit area (#43) is not cut by the next row's. */
.recs-table td { block-size: 44px; }
.recs-mandate { margin: 0 0 6px; }
details.below { margin-block: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
details.below summary { cursor: pointer; font-weight: 600; padding-block: 10px; }
.below-list { list-style: none; margin: 0; padding: 0; }
.below-btn { display: flex; align-items: center; gap: 10px; inline-size: 100%; min-block-size: 48px; text-align: start; }
.below-btn .prow-name { flex: 1; }
.below-list li + li { margin-block-start: 6px; }

/* Party roles */
.roles { display: flex; gap: 4px; padding: 0 12px 6px; padding-inline-start: 50px; margin-block-start: -2px; }
/* 36px visual height; ::after extends the tap target to 44px. */
.role-btn { position: relative; flex: 1; min-block-size: 36px; padding: 2px 6px; border: 1px solid #9aa3b5; border-radius: 999px; background: #fff; color: var(--fg); font-size: .85rem; cursor: pointer; white-space: nowrap; }
.role-btn.is-on { background: #dbe5fa; border: 2px solid var(--accent); color: #0a2a7a; font-weight: 700; padding: 1px 5px; }
.role-btn::after { content: ""; position: absolute; inset: -7px 0; } /* from the padding box, inside the 1–2px border */
.role-btn.is-on::before { content: "✓ "; color: var(--accent); }
.role-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 360px) { .roles { padding-inline-start: 12px; } }
.verdict { margin: 2px 0 0; font-weight: 700; font-size: .95rem; }
.verdict.is-yes span { color: #166534; }
.verdict.is-no span { color: #b91c1c; }
.members-line { margin: 2px 0 0; font-size: .9rem; color: var(--fg); }
/* #H1: the compact seats line under the coalition header, and the seats card after the friction card. The lines
   wrap only between their kept-whole segments. */
.seats-compact { margin-block: 8px 0; }
.seats-compact .seats-line { white-space: normal; }
.seats-compact .poll-legal { margin-block: 0 6px; }
.src-short { font-size: .85rem; font-weight: 400; color: var(--muted); }
.src-line { margin: 0 0 6px; font-size: .85rem; color: var(--muted); }
/* #H3: the party sheet's main line (seats and recommendation, each with its short source) and its muted line. */
.party-main { margin: 0 0 4px; font-weight: 600; }
.party-meta { margin: 0 0 8px; }
.seats-card .seat-src, .seats-card .poll-legal { margin-block: 0 8px; }
.dep-summary { margin: 0 0 4px; font-weight: 600; }
details.dep { margin-block-start: 8px; border-block-start: 1px solid var(--line); }
details.dep > summary { cursor: pointer; font-weight: 600; color: var(--accent); padding-block: 10px; min-block-size: 44px; box-sizing: border-box; }
details.dep > p { margin: 0 0 6px; }
.dep-list { margin: 0; padding-inline-start: 1.2em; font-size: .92rem; }
.dep-list li { margin-block: 2px; }
.periphery .per-party + .per-party { margin-block-start: 10px; }
.periphery .pair-list { margin-block-start: 4px; }
.completions .list li + li { margin-block-start: 6px; }
.row-btn.completion { display: grid; gap: 2px; }
.completions .poll-legal { margin-block: 6px; }
.positions-asof { margin: -4px 0 8px; font-size: .85rem; color: var(--muted); }
.periphery-link { margin: 8px 0 0; }
.outside-block .periphery-link { margin: 0; }
.periphery-link .link-btn { font-size: .95rem; text-align: start; }
.scenario-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 10px; }
.scenario .preset { inline-size: 100%; text-align: start; }
.scen-src { margin: 4px 4px 0; font-size: .85rem; color: var(--muted); }
.vs-table td { font-variant-numeric: tabular-nums; }
/* Results view: the sticky header (.resbar) must not cover a scroll target; --resbar-h is measured in app.js. */
#view-results :is([id], h2, h3, .card) { scroll-margin-block-start: calc(var(--resbar-h, 64px) + 12px); }
.pair-btn .tag { white-space: nowrap; }

/* Task cards on the build view (#26): stacked on a phone, side by side from 720px. Each title is its control; in cards
   1 and 3 the control's ::after covers the whole card, so the tap target is the card (well over 44px). */
.tasks h2 { font-size: 1.1rem; margin-block: 16px 8px; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.task { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; min-inline-size: 0; }
.task:has(.task-go:hover) { background: var(--chip); }
.task-title { display: block; font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.task-go { display: flex; align-items: center; justify-content: space-between; gap: 8px; inline-size: 100%;
  padding: 0; border: 0; background: none; font: inherit; text-align: start; text-decoration: none; color: var(--accent); cursor: pointer; }
.task-go::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.task-go:focus-visible { outline: none; }
.task-go:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.task-go:hover .task-title { text-decoration: underline; }
.task-chev { flex: none; inline-size: 18px; block-size: 18px; }
.task-jump { flex: none; font-size: 1.15rem; font-weight: 700; line-height: 1; }
[dir="rtl"] .chev-fwd { transform: scaleX(-1); }
.task-select { display: block; margin-block-start: 8px; inline-size: 100%; max-inline-size: 100%; min-block-size: 44px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.task-line { margin: 2px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.4; }
@media (min-width: 720px) {
  .task-list { grid-auto-flow: column; grid-auto-columns: 1fr; }
}
.build-sec .tray-head h2 { scroll-margin-block-start: 12px; }
/* Scenarios / presets: collapsed in the builder section, so the party list stays near the top of it. */
details.start-from { margin-block: 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
details.start-from > summary { cursor: pointer; font-weight: 600; color: var(--accent); padding-block: 11px; }
details.start-from[open] { padding-block-end: 10px; }
.tasks + #source-mix { margin-block-start: 16px; }

/* The words behind a 🚩 (#49): set off from the summary by the red-line color at the inline start, plus a label. */
.redline-ev { border-inline-start: 3px solid var(--clash-fg); padding-inline-start: 10px; margin-block: 6px 10px; }
.redline-label { margin: 0; font-size: .85rem; font-weight: 600; }
.redline-ev blockquote { margin-block: 4px; }
.redline-ev .source { margin-block: 0; }
