/*
 * Civgraph Elections. Tokens, base styles and the cg-* components come from /assets/ui/ (the
 * shell head and components.css); this sheet only lays out the app. Party colours are data
 * (set inline), never tokens.
 */
.el-main {
  max-width: var(--content-max, 72rem);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-12);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: var(--leading-normal, 1.5);
}
#el-view[aria-busy="true"] { opacity: 0.6; transition: opacity var(--transition-fast, 0.1s); }
.el-loading { color: var(--text-muted); }
.el-head h1 { margin: 0 0 var(--space-1); font-size: var(--text-3xl); line-height: var(--leading-tight); }
.el-lead { margin: 0 0 var(--space-4); color: var(--text-muted); }
.el-preview { max-width: 48rem; }
.el-muted { color: var(--text-muted); font-size: var(--text-sm); }
.el-crumbs { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--text-muted); }
.el-crumbs a { color: var(--link); }
.el-nav { display: flex; justify-content: space-between; gap: var(--space-4); font-size: var(--text-sm); }
.el-nav a { color: var(--link); }
h2 { margin: var(--space-8) 0 var(--space-3); font-size: var(--text-xl); }
.el-main .num, .el-main .cg-table th.num, .el-main .cg-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.el-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.el-search { display: flex; flex-direction: column; gap: var(--space-1); max-width: 36rem; margin: 0 0 var(--space-4); }
.el-search label { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.el-search input, .el-controls select, .el-controls input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.el-list { margin: 0 0 var(--space-4); padding-left: var(--space-5); }
.el-list li { margin: var(--space-1) 0; }
.el-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.el-cards .cg-card { display: flex; flex-direction: column; height: 100%; text-decoration: none; }

.el-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: var(--space-4); align-items: start; }
.el-seatchart svg { max-width: 30rem; margin: 0 auto; }
.el-arc text, .el-hbars text, .el-flow text { font-family: var(--font-sans); }
/* The SVGs are drawn at about 560 units wide: cap them so their text stays near body size. */
.cg-chart svg.el-hbars, .cg-chart svg.el-flow { max-width: 42rem; }
.el-gone { opacity: 0.75; }

.el-sheet-wrap { overflow-x: auto; }
.el-sheet td.num { white-space: nowrap; }
.el-sheet th.el-stage-head { white-space: normal; min-width: 6rem; max-width: 9rem; vertical-align: bottom; }
.el-nt-tip { position: relative; cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.el-nt-tip:hover::after, .el-nt-tip:focus-visible::after { content: attr(data-tip); position: absolute; inset-inline-start: 0; top: 100%; z-index: 5; width: max-content; max-width: 18rem; margin-top: var(--space-1); padding: var(--space-2); background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-weight: var(--weight-normal); white-space: normal; text-align: start; }
.el-values-switch { display: inline-flex; gap: var(--space-2); align-items: center; }
.el-sheet .el-transfer { display: block; font-size: var(--text-xs); line-height: 1.1; }
.el-sheet .el-done { color: var(--text-muted); }
.el-sheet .el-at-elected { box-shadow: inset 0 -3px 0 var(--success); font-weight: var(--weight-semibold); }
.el-sheet .el-at-excluded { box-shadow: inset 0 -3px 0 var(--danger); }
.el-sheet .el-nt th { font-weight: var(--weight-normal); color: var(--text-muted); }
.el-flow-stage { margin: 0 0 var(--space-3); }
.el-flow-stage summary { cursor: pointer; font-weight: var(--weight-medium); padding: var(--space-2) 0; }
.el-cites li { margin-bottom: var(--space-3); }
.el-check { margin-top: var(--space-1); font-size: var(--text-sm); }

.el-controls { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; margin: 0 0 var(--space-4); }
.el-controls label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.el-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.el-chip { padding: 2px var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface-sunken); font-size: var(--text-xs); }
.el-pivot-wrap { overflow: auto; max-height: 70vh; }
.el-map { width: 100%; height: 60vh; min-height: 22rem; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.el-multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-3); }
.el-multiples figure { margin: 0; }
.el-estimate { border-left-color: var(--warning); }
@media (max-width: 36rem) {
  .el-head h1 { font-size: var(--text-2xl); }
  .el-main { padding: var(--space-3) var(--space-3) var(--space-8); }
}

/* el-tables: the data behind each chart (lib/chart-data.js), the notes on worked-out figures
   (lib/methods.js) and the methods page (views/methods.js). */
.el-chart-data { margin: var(--space-2) 0 0; font-size: var(--text-sm); text-align: left; }
.el-chart-data > summary { cursor: pointer; color: var(--link); padding: var(--space-1) 0; width: fit-content; }
.el-chart-data > summary:focus-visible, .el-chart-data__wrap:focus-visible { outline: 2px solid var(--focus-ring, var(--link)); outline-offset: 2px; }
.el-chart-data__wrap { margin-top: var(--space-2); }
.el-chart-data caption { text-align: left; font-weight: var(--weight-semibold); padding-bottom: var(--space-1); }
.el-chart-data__csv { margin: var(--space-2) 0 0; }
.el-chart-data__csv a, .el-method-link { color: var(--link); }
.el-method { margin: var(--space-2) 0; }
.el-method--fact { display: block; margin: var(--space-1) 0 0; font-size: var(--text-xs); }
.el-compared time { white-space: nowrap; }
.el-method-section h2:focus { outline: none; }
.el-method-section p { max-width: 48rem; }

/* The results map (el-maps, 14 Nov 2026): the close-contests filter, the key, the list's sort buttons. */
.el-map-filter { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: end; margin: 0; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.el-map-filter legend { padding: 0 var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.el-map-filter input { width: 7rem; }
.el-map-key { margin-top: var(--space-2); }
.el-sort { padding: 0; border: 0; background: none; color: var(--link); font: inherit; font-weight: var(--weight-semibold); text-decoration: underline; cursor: pointer; }
th[aria-sort="ascending"] .el-sort::after { content: " \2191"; }
th[aria-sort="descending"] .el-sort::after { content: " \2193"; }
/* The palest step of a scale still shows its edge on a light page. */
.el-map-key .cg-legend__swatch:not(.cg-legend__swatch--none, .cg-legend__swatch--empty) { box-shadow: inset 0 0 0 1px var(--border); }
/* By-election tracker and council control (stream el-bodies). Party colours are data, set inline. */
.el-nowrap { white-space: nowrap; }
#be-form label, #cc-form label { max-width: 100%; }
#be-form select, #cc-form select { max-width: 100%; }
.el-be-form .el-be-stand select { min-width: min(14rem, 100%); }
.el-be-actions { display: flex; gap: var(--space-3); align-items: center; margin: 0; }
.el-be-summary span + span::before { content: " "; }
.el-be-winner { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; margin-right: var(--space-2); }
.el-be-departing { display: block; font-size: var(--text-xs); }
.el-notes { padding-left: var(--space-5); color: var(--text-muted); font-size: var(--text-sm); max-width: 48rem; }
.el-notes li { margin: var(--space-2) 0; }
.el-ctl-chart { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.el-ctl-row { display: grid; grid-template-columns: 3rem minmax(0, 1fr) minmax(8rem, 16rem); gap: var(--space-2); align-items: center; font-size: var(--text-sm); }
.el-ctl-year { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.el-ctl-track { position: relative; display: block; min-height: 1.25rem; }
.el-ctl-bar { position: relative; display: flex; height: 1.25rem; border-radius: var(--radius-sm); overflow: hidden; }
.el-ctl-row:not(.el-ctl-row--part) .el-ctl-bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; border-left: 2px solid var(--text); }
.el-ctl-row--part .el-ctl-bar { opacity: 0.55; }
.el-ctl-row--part .el-ctl-text { color: var(--text-muted); font-style: italic; }
.el-ctl-seg { display: block; min-width: 1px; }
.el-ctl-seg--missing { background: transparent; box-shadow: inset 0 0 0 1px var(--border-input); }
.el-ctl-key { display: inline-block; width: 1.5rem; height: 0.75rem; vertical-align: middle; border-radius: var(--radius-sm); background: var(--text-muted); }
.el-ctl-key--part { opacity: 0.55; }
.el-ctl-key--missing { background: transparent; box-shadow: inset 0 0 0 1px var(--border-input); }
.el-ctl-pred h2 { font-size: var(--text-lg); }
@media (max-width: 40rem) {
  .el-ctl-row { grid-template-columns: 2.75rem minmax(0, 1fr); }
  .el-ctl-text { grid-column: 2; }
}
/* el-stv (14 Nov 2026): readable STV counts (views/stv-contest.js, views/stv-election.js). */
.el-stv-h3 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-lg); }
.el-count-labels { margin: 0 0 var(--space-4); padding-left: var(--space-6); font-size: var(--text-sm); }
.el-count-labels li { margin: var(--space-1) 0; }
.el-narrow-only { display: none; }
.el-stack-count { margin: 0 0 var(--space-4); }
.el-stack-count h3, .el-stack-count h4 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-base); }
.el-share { display: block; font-size: var(--text-xs); }
.el-stepper__bar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0 0 var(--space-3); }
.el-stepper__pos { min-width: 8rem; text-align: center; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.el-stepper__now { min-height: 4.5rem; }
.el-stepper__now h3 { margin: 0 0 var(--space-1); font-size: var(--text-lg); }
.el-stepper__now p { margin: 0 0 var(--space-3); }
.el-step__track { position: relative; display: block; min-width: 7rem; height: 6px; margin-top: 4px; border-radius: var(--radius-full); background: var(--surface-sunken); }
.el-step__fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: inherit; }
.el-step__quota { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.el-step__q { display: block; font-size: var(--text-xs); }
.el-stepper__table tr.el-step--out { color: var(--text-muted); }
@media (prefers-reduced-motion: no-preference) {
  .el-step__fill { transition: width var(--transition-base); }
}
.el-sankey-wrap { overflow-x: auto; }
.el-sankey-wrap:focus-visible, .el-main .cg-table-wrap[tabindex]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* The flow keeps its natural size (12 px text) and scrolls on a phone; on a wide screen it may shrink to fit. */
.cg-chart .el-sankey { width: auto; max-width: none; color: var(--text); }
.el-sankey text { font-family: var(--font-sans); }
@media (min-width: 48rem) {
  .cg-chart .el-sankey { max-width: 100%; }
}
.el-closest li { margin: var(--space-1) 0; }
.el-stv-load summary, .el-model-load summary { padding: var(--space-2) 0; font-weight: var(--weight-medium); cursor: pointer; }
@media (max-width: 36rem) {
  .el-wide-only { display: none; }
  .el-narrow-only { display: block; }
  .el-sheet-wrap:has(~ .el-stacked) { display: none; }
}

/* el-fixes (14 Nov 2026): phones and keyboards. */
/* A scroll area in the tab order (lib/a11y.js) shows its focus. */
.el-main [data-scroll-area]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* The view's h1 takes focus after a route change (tabindex -1): no ring for a heading. */
.el-main h1[tabindex="-1"]:focus { outline: none; }
.el-ref-result { font-weight: var(--weight-medium); }
@media (max-width: 36rem) {
  /* The transfer flows and bar charts keep their 12-unit labels near 12px: the diagram scrolls
     sideways instead of shrinking to about 7px. */
  .el-main figure.cg-chart { overflow-x: auto; }
  .cg-chart svg.el-flow, .cg-chart svg.el-hbars { min-width: 35rem; }
  /* The swingometer's sliders fit a phone's table column. */
  .el-swing-parties input[type="range"] { width: 6.5rem; }
  /* Long election names in the pickers wrap the controls rather than widen the page. */
  .el-controls label, .el-controls select { max-width: 100%; min-width: 0; }
}

/* el-context (14 Nov 2026): the census context, "same votes, other systems" and the embed panel. */
.el-census-table th[scope="row"] .el-muted { font-weight: var(--weight-normal); }
.el-census-table td.num { white-space: nowrap; }
.el-systems details > summary, .el-embed details > summary { cursor: pointer; font-weight: var(--weight-medium); padding: var(--space-2) 0; }
.el-systems-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-3); }
.el-systems-bars p { margin: 0 0 var(--space-1); }
.el-systems-method ul { margin: var(--space-2) 0 0; padding-left: var(--space-5); }
.el-embed-label { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.el-embed-code {
  box-sizing: border-box;
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.el-embed-preview { width: 100%; max-width: 36rem; height: 30rem; border: 1px solid var(--border); border-radius: var(--radius-md); }

/* el-places (14 Nov 2026): search results, area pages, the members grid, the trend chart, the
   person page and the contest arrows. Layout only; the colours are tokens, party colours data. */
.el-results__group h2 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-lg); }
.el-results .cg-party { vertical-align: middle; }
.el-area-bodies .el-chips { margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.el-area-bodies a.el-chip { color: var(--link); text-decoration: none; }
.el-area-bodies a.el-chip[aria-current="page"] { font-weight: var(--weight-semibold); border-color: var(--link); }
.el-series { margin-top: var(--space-8); }
.el-series h3 { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-lg); }
.el-members td.el-member { min-width: 9rem; vertical-align: top; }
.el-members .el-member--empty { color: var(--text-muted); }
.el-members__by th, .el-members__by td { background: var(--surface-sunken); }
.el-area-contests td:last-child { min-width: 14rem; }
.el-trend { margin: 0; }
.el-trend-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin: 0 0 var(--space-2); padding: 0; list-style: none; font-size: var(--text-sm); }
.el-trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.el-trend .trend-grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.el-trend .trend-grid--baseline, .el-trend .trend-election-tick { stroke: var(--border-input); }
.el-trend .trend-axis { fill: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.el-trend .trend-line { fill: none; stroke: var(--trend-colour); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.el-trend .trend-hit, .el-trend .trend-crosshair, .el-trend .trend-marker { display: none; }
.el-trend .trend-dot { fill: var(--trend-colour); }
.el-trend .trend-gap { fill: none; stroke: var(--trend-colour); stroke-width: 1.25; stroke-dasharray: 2 4; opacity: 0.5; }
/* The direct labels name the party in the text colour, so they read in both themes; the line
   beside each keeps the party's colour. */
.el-trend .trend-label text { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.el-trend .trend-label__value { font-weight: var(--weight-semibold); }
.el-trend .trend-label-leader { stroke: var(--trend-colour); stroke-width: 1; opacity: 0.55; }
.el-career th[scope="row"] { font-weight: var(--weight-normal); }
.el-contest-nav { flex-wrap: wrap; margin: var(--space-2) 0 0; }
.el-party-link { text-decoration: none; color: inherit; }
.el-party-link:hover .cg-party, .el-party-link:focus-visible .cg-party { text-decoration: underline; }
.cg-table-wrap[tabindex="0"]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* w30 (29 Nov 2026): the phone layout. The tools fold behind one button (app.js), and the count
   sheet keeps its candidate column in view while the counts scroll sideways. */
.el-tools-toggle { display: none; }
@media (max-width: 36rem) {
  .el-tools-toggle:not([hidden]) { display: inline-flex; gap: var(--space-2); align-items: center; margin: 0 0 var(--space-3); }
  .el-tools-toggle__now { font-weight: var(--weight-semibold); }
  .el-tools-toggle:not([hidden]) + .cg-tabs__bar:not([data-open]) { display: none; }
  .el-tools-toggle:not([hidden]) + .cg-tabs__bar[data-open] { flex-direction: column; }
}
/* The transfers table and the flow, folded under their headings (views/stv-contest.js). */
.el-fold { margin: var(--space-6) 0 0; }
.el-fold > summary { cursor: pointer; list-style-position: outside; }
.el-fold > summary h2 { display: inline; margin: 0; }
.el-fold[open] > summary { margin-bottom: var(--space-3); }

/* The place lookup and the open data page (views/lookup.js, views/data.js; owner O-A and O-B, 29 Nov 2026). */
.el-lookup-form, .el-data-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-4) 0 var(--space-2); }
.el-lookup-form input[type="search"] { flex: 1 1 16rem; min-width: 0; }
.el-lookup-place td:first-child, [data-open-data-elections] td:first-child { white-space: nowrap; }
.el-lookup-body { margin-top: var(--space-6); }
.el-home-links { margin: var(--space-3) 0; }
/* Benchmark improvements (29 Nov 2026; tmp/reviews/elections-benchmark-2026-11-29.md section 4a). */
/* I-1 seat change, designations, seats changing hands. */
.cg-chart svg.el-changebars { max-width: 42rem; }
.el-changebars text, .el-columns text, .el-line text { font-family: var(--font-sans); }
.el-hands { margin: 0 0 var(--space-4); padding-left: var(--space-5); }
.el-hands li { margin: var(--space-1) 0; }
.el-basis { font-size: var(--text-sm); }
/* I-2 where each candidate's votes went. */
.el-went { margin: 0 0 var(--space-2); }
.el-went > summary { padding: var(--space-2) 0; cursor: pointer; font-weight: var(--weight-medium); }
.el-went-parties, .el-went-pooled { font-size: var(--text-sm); }
/* I-3 body story. */
.cg-chart svg.el-columns, .cg-chart svg.el-line { max-width: 48rem; }
.el-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: var(--space-2) 0; font-size: var(--text-sm); }
/* I-6 records. */
.el-inline-list { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.el-literature { margin: 0 0 var(--space-3); padding-left: var(--space-5); }
/* I-4 phones: the header's figures as a grid of tiles, two rows rather than one line each; the
   party of each candidate under their name in the count stacked a count at a time. */
.el-stats > div { display: contents; }
/* width 0 + min-width 100%: the chip never widens the name column; a long name is cut with an ellipsis. */
.el-party-line { display: block; width: 0; min-width: 100%; font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 40rem) {
  .cg-facts.el-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); margin: var(--space-3) 0 var(--space-4); }
  .cg-facts.el-stats > div { display: block; min-width: 0; }
  .cg-facts.el-stats > .el-stats__wide { grid-column: 1 / -1; }
  .cg-facts.el-stats dt { font-size: var(--text-xs); font-weight: var(--weight-medium); }
  .cg-facts.el-stats dd { margin: 0; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
  .cg-facts.el-stats > .el-stats__wide dd { font-weight: var(--weight-normal); }
  .cg-chart svg.el-changebars { min-width: 35rem; }
  .cg-chart svg.el-columns, .cg-chart svg.el-line { min-width: 30rem; }
}
.el-records th .el-muted, .el-governments th .el-muted { font-weight: var(--weight-normal); }
