/* Design tokens. Sizes, radii, shadows, easings and fonts come from Open Props (vendor/open-props.css); the colours
   are ours. Everything else in this file uses these names. */
:root {
  --bg: #f3f3f0; --fg: #15171c; --muted: #6a6f78; --line: #e2e2dd; --card: #fff; --raise: #f8f8f6; --accent: #c8102e;
  --scroll: color-mix(in srgb, var(--fg) 22%, transparent); --scroll-hover: color-mix(in srgb, var(--fg) 40%, transparent);
  --radius: var(--radius-3); --radius-sm: var(--radius-2); --pane-rail: 44px;
  --font: var(--font-system-ui); --ease: var(--ease-3);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d0f13; --fg: #eceef2; --muted: #9399a4; --line: #262a32; --card: #15181e; --raise: #1b1f26; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
main, .top, footer { max-width: 960px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.1rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 40px 0 12px; letter-spacing: -.01em; }
h2 small, h3 small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.status { color: var(--muted); margin: 0; font-size: .85rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.live { background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* Scrollbars: thin, rounded, in the page's colours, everywhere (chat, tabs, lists, dialogs). */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
@supports not (scrollbar-color: red blue) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
}

/* Header: title and status, the race to the Moncloa, and the count. */
.top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 16px; }
.top > * { min-width: 0; }
.brand { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero { padding: 4px 0; }
#pm > h2 { margin: 6px 0 12px; }
.pm { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 10px; }
.hero-pair { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.hero-label { color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .07em; font-size: .68rem; font-weight: 600; white-space: nowrap; }
.hero-number { font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.hero-votes, .hero-turnout { font-size: clamp(1.1rem, 4vw, 1.4rem); }
.updated { font-variant-numeric: tabular-nums; margin-left: .7em; }
@media (max-width: 560px) { .hero-pair { grid-template-columns: repeat(3, minmax(0, auto)); } .hero-label { white-space: normal; line-height: 1.2; } }
.progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }

.bar-wrap { position: relative; }
.seatbar { position: relative; display: flex; height: 28px; border-radius: 4px; background: var(--line); cursor: pointer; touch-action: manipulation; }
.seatbar:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }
.seatbar > div { height: 100%; min-width: 0; box-shadow: inset -1px 0 0 var(--bg); transition: flex-basis .8s, opacity .15s, transform .15s, filter .15s; }
.seatbar > div:first-child { border-radius: 4px 0 0 4px; }
.seatbar > div:last-child { border-radius: 0 4px 4px 0; }
/* Same hover effect as the bloc bar: the picked party lifts and brightens, the rest dims. */
.seatbar.focus > div { opacity: .35; }
.seatbar.focus > div.on { opacity: 1; transform: scaleY(1.35); filter: brightness(1.12); position: relative; z-index: 1; border-radius: 3px; }
.seatbar::after { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 2px dashed var(--fg); }

table.parties { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.parties th, .parties td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.parties th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.num { text-align: right !important; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.seats { font-weight: 800; }

#filter { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; }
.provinces { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.prov { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.prov h3 { margin: 0 0 4px; font-size: .95rem; display: flex; justify-content: space-between; }
.prov h3 span { color: var(--muted); font-weight: 400; }
.prov .meta { color: var(--muted); font-size: .8rem; margin: 0 0 8px; }
.prov ul { list-style: none; margin: 0; padding: 0; font-size: .88rem; font-variant-numeric: tabular-nums; }
.prov li { display: flex; justify-content: space-between; padding: 2px 0; }
footer { color: var(--muted); font-size: .8rem; padding-top: 32px; padding-bottom: 40px; }

.more-row { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.more { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; }
.more:hover { color: var(--fg); }
.more:hover { border-color: var(--muted); }
.more[hidden] { display: none; }

/* Race for prime minister: two blocs pushing towards the 176 line from each end, decisivos in grey in between. */
.blocs { position: relative; margin-bottom: 18px; }
.bloc-heads { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.bloc-head { flex: 1 1 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.bloc-head.right { flex-direction: row-reverse; text-align: right; }
.bloc-head div { display: flex; flex-direction: column; line-height: 1.2; }
.bloc-head div span { color: var(--muted); font-size: .78rem; }
.bloc-total { font-size: 2rem; font-variant-numeric: tabular-nums; line-height: 1; }
.bloc-bar { position: relative; display: flex; height: 26px; background: var(--line); border-radius: 6px; cursor: pointer; touch-action: manipulation; }
.bloc-bar:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }
.bloc-group { display: flex; height: 100%; min-width: 0; }
.bloc-group.left .bloc-seg:first-child { border-radius: 6px 0 0 6px; }
.bloc-group.right .bloc-seg:last-child { border-radius: 0 6px 6px 0; }
.bloc-gap { flex: 1; display: flex; justify-content: center; min-width: 0; }
.bloc-seg { height: 100%; min-width: 0; box-shadow: inset -1px 0 0 var(--bg); transition: opacity .15s, transform .15s, filter .15s; }
/* A slice picked for the popup lifts and brightens; the rest of the bar dims. */
.bloc-bar.focus .bloc-seg { opacity: .35; }
.bloc-bar.focus .bloc-seg.on { opacity: 1; transform: scaleY(1.35); filter: brightness(1.12); position: relative; z-index: 1; border-radius: 3px; }
.bloc-line { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--fg); }
.bloc-176 { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); font-size: .72rem; font-weight: 700; }
.bloc-legend { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-top: 8px; font-size: .85rem; }
.bloc-legend > div { display: flex; flex-direction: column; min-width: 0; }
.bloc-legend { cursor: pointer; border-radius: 6px; }
.bloc-legend:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }
.bloc-legend > div > span { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.bloc-legend > div { transition: opacity .15s; }
.bloc-legend.focus > div { opacity: .45; }
.bloc-legend.focus > div.on { opacity: 1; }
.bloc-legend .mid { text-align: center; }
.bloc-legend .right { text-align: right; }
.bloc-legend em { font-style: normal; font-weight: 700; color: var(--accent); text-transform: uppercase; font-size: .75rem; letter-spacing: .04em; }
.bloc-note { margin: 10px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--card); font-size: .82rem; }
.bloc-note[hidden] { display: none; }
.bar-tip { position: absolute; z-index: 20; width: max-content; max-width: min(300px, 100%); padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--fg); box-shadow: 0 8px 24px rgb(0 0 0 / .25); font-size: .8rem; line-height: 1.35;
  pointer-events: none; opacity: 0; visibility: hidden; transform: translateY(6px) scale(.98); transform-origin: var(--arrow, 50%) 100%;
  transition: opacity .15s ease-out, transform .15s ease-out, visibility 0s linear .15s; }
.bar-tip.show { opacity: 1; visibility: visible; transform: none; transition: opacity .15s ease-out, transform .15s ease-out; pointer-events: auto; }
.bar-tip::after { content: ''; position: absolute; top: 100%; left: var(--arrow, 50%); margin-left: -6px; border: 6px solid transparent; border-top-color: var(--card); }
.bar-tip.below { transform-origin: var(--arrow, 50%) 0; }
.bar-tip.below:not(.show) { transform: translateY(-6px) scale(.98); }
.bar-tip.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--card); }
.bar-tip p { margin: 0 0 4px; }
.bar-tip .bt-head { display: flex; align-items: center; gap: 2px; font-size: .9rem; }
.bar-tip .bt-seats { margin-left: auto; padding-left: 12px; font-weight: 700; white-space: nowrap; }
.bar-tip .bt-name { color: var(--muted); font-size: .75rem; }
.bar-tip .bt-side { margin-top: 6px; }
.bar-tip ul { margin: 6px 0 0; padding: 6px 0 0; list-style: none; border-top: 1px solid var(--line); color: var(--muted); }
.bar-tip li b { color: var(--fg); }
@media (prefers-reduced-motion: reduce) {
  .bloc-seg, .seatbar > div, .bar-tip, .bar-tip.show { transition: none; }
  .bar-tip { transform: none; }
  .bloc-bar.focus .bloc-seg.on, .seatbar.focus > div.on { transform: none; }
}
.pm-cands { margin-top: 16px; }
.pm-cands[hidden] { display: none; }
.pm-sub { font-size: .85rem; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
.pm-rows { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pm-card { font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); text-align: center; }
.pm-card.lead { border-color: var(--fg); }
/* Portrait popping out of a circle: the image is taller than the circle and bottom-aligned; the mask keeps the part
   inside the circle plus a circle-wide column above its centre, so the head rises over the top edge. */
.pm-pic { --s: 56px; --pop: 1.45; position: relative; display: block; flex: none; width: var(--s); height: var(--s);
  margin-top: calc(var(--s) * (var(--pop) - 1)); }
.pm-pic::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 -6px 12px rgb(0 0 0 / .25); }
.pm-pic img { position: absolute; left: 50%; bottom: 0; width: calc(var(--s) * var(--pop)); height: calc(var(--s) * var(--pop));
  transform: translateX(-50%); object-fit: cover;
  --m: radial-gradient(circle calc(var(--s) / 2) at 50% calc(100% - var(--s) / 2), #000 99%, transparent 100%),
       linear-gradient(#000 0 0) 50% 0 / var(--s) calc(100% - var(--s) / 2) no-repeat;
  -webkit-mask: var(--m); mask: var(--m); }
.bloc-head .pm-pic { --s: 60px; }
#pm-credits a { color: inherit; }
.pm-who { display: flex; flex-direction: column; align-items: center; line-height: 1.2; min-width: 0; }
.pm-who span { color: var(--muted); font-size: .75rem; }
.pm-who em { font-style: normal; font-size: .65rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.pm-num { display: flex; align-items: baseline; gap: 4px; }
.pm-seats { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.pm-move { font-size: .75rem; font-weight: 700; }
.pm-move.up { color: #1a9a4b; }
.pm-move.down { color: var(--accent); }
.pm-note { margin: 8px 0 0; font-size: .75rem; color: var(--muted); }
@media (max-width: 560px) {
  .pm-rows { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bloc-total { font-size: 1.6rem; margin: 0 4px; }
  .bloc-head { gap: 8px; }
  .bloc-head div { display: none; }
  .bloc-head .pm-pic { --s: 46px; }
  .pm-card .pm-pic { --s: 46px; }
  .bloc-legend { grid-template-columns: 1fr 1fr; }
  .bloc-legend .mid { grid-column: 1 / -1; grid-row: 2; }
}
.map-tip li small { display: block; color: var(--muted); font-size: .72rem; margin-left: 18px; }
.map-tip li.tip-head { color: var(--muted); font-size: .75rem; margin-bottom: 2px; }

/* Map: provinces coloured by the leading party; lighter while the count is early. */
.map-wrap { --z: 1; position: relative; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.map-wrap.zoomed { touch-action: none; cursor: grab; }
.map-wrap.zoomed:active { cursor: grabbing; }
.map-zoom { position: absolute; right: 8px; top: 8px; z-index: 4; display: flex; flex-direction: column; gap: 4px; }
.map-zoom button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: 600 1.1rem/1 system-ui, sans-serif; cursor: pointer; box-shadow: 0 2px 8px rgb(0 0 0 / .12); }
.map-zoom button:disabled { opacity: .4; cursor: default; }
.map-zoom button[hidden] { display: none; }
.map { position: relative; z-index: 1; width: 100%; height: auto; display: block; }
/* Municipios: a canvas under the SVG (and one above it for the outline of the one under the pointer). */
.map-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.map-hl { z-index: 2; }
.map-prov.munis path { fill-opacity: 0; stroke: #000; stroke-opacity: .65; stroke-width: calc(.9px / var(--z)); }
.map-prov.munis.active path, .map-prov.munis:hover path { stroke: #000; stroke-opacity: 1; stroke-width: calc(1.8px / var(--z)); }
.map-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.map-level { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.map-level[hidden], .map-hint[hidden] { display: none; }
.map-level button { padding: 4px 12px; border: 0; background: var(--card); color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.map-level button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.map-hint { margin: -4px 0 8px; font-size: .78rem; color: var(--muted); }
.map-legend .map-note-li { color: var(--muted); font-size: .78rem; }
.map-prov path, .map-prov circle { fill: var(--fill, var(--line)); fill-opacity: var(--alpha, 1); stroke: var(--bg); stroke-width: calc(.8px / var(--z)); transition: fill .6s, fill-opacity .6s; cursor: pointer; }
.map-prov circle { stroke-width: calc(1.5px / var(--z)); }
.map-prov:hover path, .map-prov.active path, .map-prov:focus path, .map-prov.active circle { stroke: var(--fg); stroke-width: calc(1.6px / var(--z)); }
.map-prov:focus { outline: none; }
.seat-dots { pointer-events: none; }
.seat-dots circle { stroke: var(--bg); stroke-width: calc(.9px / var(--z)); }
.seat-dots circle.empty { fill: var(--card); stroke: var(--muted); stroke-width: calc(.7px / var(--z)); }
.map-frame { fill: none; stroke: var(--line); stroke-width: calc(1px / var(--z)); }
.map-tip { position: absolute; left: 8px; top: 8px; min-width: 190px; max-width: 260px; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / .15); font-size: .85rem; pointer-events: none; z-index: 3; }
.map-tip > span { color: var(--muted); font-size: .8rem; }
.map-tip p { margin: 2px 0 6px; color: var(--muted); font-size: .8rem; }
.map-tip ul { list-style: none; margin: 0; padding: 0; }
.map-tip li { display: flex; justify-content: space-between; gap: 8px; }
.map-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 0; padding: 0; font-size: .85rem; }
.map-legend b { color: var(--muted); font-weight: 600; margin-left: 2px; }
.map-note { margin: 4px 0 0; font-size: .75rem; color: var(--muted); }

/* Live chat (placeholder look). Inline section on narrow screens, fixed sidebar on wide ones. */
.chat { max-width: 960px; margin: 40px auto 0; padding: 0 16px; display: flex; flex-direction: column; }
.chat header { display: flex; justify-content: space-between; align-items: baseline; }
.chat h2 { margin: 0 0 8px; }
.chat header small { color: var(--muted); font-size: .8rem; }
.chat-list { list-style: none; margin: 0; padding: 8px; height: 320px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; overflow-wrap: anywhere; }
.chat-list li { padding: 3px 0; }
.chat-list time { color: var(--muted); font-size: .75rem; margin-right: 6px; font-variant-numeric: tabular-nums; }
.chat-list b { margin-right: 6px; }
.chat-form { display: grid; gap: 6px; margin-top: 8px; }
.chat-form input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; min-width: 0; }
.chat-row { display: flex; gap: 6px; }
.chat-row input { flex: 1; }
.chat-form button { padding: 0 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.chat-form button:disabled { opacity: .6; }
.chat-form.closed button[type="submit"] { opacity: .5; }
.chat-note { margin: 0; min-height: 1.2em; font-size: .8rem; color: var(--accent); }
/* Emotes: inline in messages, and a picker under the input. */
.emote { height: 28px; width: auto; vertical-align: middle; margin: -4px 1px; }
.chat-form .emote-toggle { padding: 0 10px; background: var(--card); color: var(--fg); border: 1px solid var(--line); font-size: 1.1rem; }
.chat-row { position: relative; }
.emote-picker { position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 30; width: min(340px, 100%); padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-3); box-shadow: var(--shadow-5); }
.emote-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.emote-head .emote-tabs { flex: 1; margin: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chat-form .emote-picker .emote-close { flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.emote-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.chat-form .emote-picker .emote-tabs button { padding: 3px 10px; background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; font-weight: 500; }
.chat-form .emote-picker .emote-tabs button[aria-selected="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.emote-grid { display: flex; flex-wrap: wrap; gap: 4px; max-height: 220px; overflow-y: auto; }
.chat-form .emote-picker .emote-grid .emoji { font-size: 1.35rem; line-height: 1; padding: 4px; color: inherit; }
.emote-grid .sticker img { height: 40px; } img.emote.sticker { height: 36px; margin: -6px 1px; }
.emote-picker[hidden] { display: none; }
.chat-form .emote-picker button { padding: 2px; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.emote-picker button:hover, .emote-picker button:focus-visible { background: var(--line); }
.emote-picker img { height: 28px; width: auto; display: block; }
/* Superchats: paid messages, pinned on top for a while (longer for bigger amounts), plus the night's ranking. */
.chat-list li.paid { background: color-mix(in srgb, var(--accent) 10%, var(--card)); border-left: 3px solid var(--accent); padding: 4px 6px; margin: 3px 0; border-radius: 4px; }
.paid-tag { display: inline-block; font-size: .7rem; font-weight: 600; color: var(--accent); margin-right: 6px; white-space: nowrap; }
.chat-top { margin-bottom: 4px; }
.chat-list li.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { background: color-mix(in srgb, var(--accent) 35%, var(--card)); } }
.chat-context { width: min(520px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); }
.chat-context::backdrop { background: rgb(0 0 0 / .5); }
.chat-context .chat-list { height: auto; max-height: 60vh; }
.chat-context li.target { outline: 2px solid var(--accent); border-radius: 4px; }
.chat-context > button { margin-top: 8px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; cursor: pointer; }
.verified { color: #1d7a46; font-weight: 700; margin: 0 6px 0 -3px; font-size: .8rem; }
.pay-reviewed { margin-left: 6px; padding: 3px 10px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.chat-login { display: grid; gap: 8px; justify-items: start; margin-top: 8px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; }
.chat-login[hidden], .chat-form[hidden], .chat-who[hidden], .sponsors[hidden] { display: none; }
.chat-login p { margin: 0; }
.chat-login small { color: var(--muted); font-size: .75rem; }
.google-btn { display: inline-flex; gap: 10px; align-items: center; padding: 9px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #1f1f1f; font-weight: 600; text-decoration: none; }
.google-btn:hover { border-color: var(--muted); }
button.link { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; text-decoration: underline; cursor: pointer; }
.chat-form button.link { color: var(--muted); font-weight: 400; }
.chat-as { margin: 0; font-size: .8rem; color: var(--muted); }
.chat-as[hidden] { display: none; }
.chat-as b { color: var(--fg); }
.chat-form .chat-as button.link { font-size: inherit; }
.chat-who { margin: 8px 0 0; font-size: .78rem; color: var(--muted); }
.chat-who a { color: inherit; }
/* "Anúnciate aquí": sponsor logos, and an empty spot with the contact address. */
.sponsors { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.sponsors-main { margin: 20px 0 0; }
.sponsors-label { flex-basis: 100%; margin: 0; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.sponsor { display: grid; place-items: center; width: 150px; height: 56px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; text-decoration: none; }
.sponsor img { max-width: 136px; max-height: 44px; }
.sponsor.empty { background: var(--card); border-style: dashed; color: var(--muted); text-align: center; line-height: 1.15; }
.sponsor.empty b { font-size: .82rem; color: var(--fg); } .sponsor.empty small { font-size: .66rem; }
.sponsor.empty:hover { border-color: var(--accent); }
.legal a { color: inherit; }
footer .legal { display: flex; flex-wrap: wrap; gap: 2px 14px; }
@media (min-width: 1320px) {
  body { padding-right: 340px; }
  .chat { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; margin: 0; padding: 16px; border-left: 1px solid var(--line); background: var(--bg); }
  .chat-list { flex: 1; height: auto; }
}

/* Shown whenever results.json has "simulated": true (replays, mock feed). Never in live mode. */
.sim-banner { position: sticky; top: 0; z-index: 50; grid-column: 1 / -1; margin: 0; padding: 8px 16px; text-align: center;
  background: repeating-linear-gradient(-45deg, #ffd400 0 14px, #ffe14d 14px 28px); color: #16181d; font-size: .9rem; border-bottom: 2px solid #16181d; }
.sim-banner b { letter-spacing: .08em; }
.sim-banner[hidden] { display: none; }

/* Candidate cards double as map selectors. */
.pm-card:hover { border-color: var(--muted); }
.pm-card:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.pm-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pm-sub small { font-weight: 400; }
.map-scale { display: flex; align-items: center; gap: 6px; }
.map-ramp { display: inline-block; width: 120px; height: 10px; border-radius: 5px;
  background: linear-gradient(to right, color-mix(in srgb, var(--k) 15%, var(--bg)), var(--k)); }
.map-reset { padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--fg); font: inherit; font-size: .8rem; cursor: pointer; }
.map-reset:hover { border-color: var(--muted); }
.map-tip .tip-sel { color: var(--fg); margin: 0 0 6px; }
/* Explanations and credits, at the end of the page. */
.notes { margin: 8px 0 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.notes h2 { font-size: .9rem; margin: 0 0 8px; }
.notes p { margin: 0 0 8px; font-size: .78rem; color: var(--muted); }
.notes a { color: inherit; }
@media (prefers-reduced-motion: reduce) { .pm-card { transition: none; } }

/* "Escaños" / "Provincias" / "Candidatos": a segmented control over one panel. */
.tabbed { margin-top: 32px; }
.tabs { display: flex; gap: 2px; padding: 3px; margin-bottom: 14px; background: var(--raise); border: 1px solid var(--line); border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] { flex: 1 0 auto; padding: 6px 12px; border: 0; border-radius: 999px; background: none;
  color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; transition: color .15s, background-color .15s, box-shadow .15s; }
.tabs [role="tab"]:hover { color: var(--fg); }
.tabs [role="tab"][aria-selected="true"] { color: var(--fg); background: var(--card); box-shadow: var(--shadow-2); }
[role="tabpanel"]:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
[role="tabpanel"][hidden] { display: none; }
.tab-sub { margin: 0 0 10px; font-size: .85rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .tabs [role="tab"] { transition: none; } }

/* Popup lists (bloc legend). */
.bar-tip .bt-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; margin: 6px 0 0; padding: 0; border: 0; color: var(--fg); }
.bar-tip .bt-list li { display: flex; align-items: center; gap: 2px; min-width: 0; }
.bar-tip .bt-list b { margin-left: auto; padding-left: 8px; }
/* Percentage and seats side by side (map popups, province cards), no separator: seats in bold. */
.ps { display: inline-flex; gap: 10px; }
.ps b { min-width: 1.4em; text-align: right; }
.sim-banner span { margin-left: 8px; }

/* "Cómo leer esta página" in a dialog (all sizes). */
.notes { width: min(640px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--fg); margin: auto; border-top: 1px solid var(--line); }
.notes::backdrop { background: rgb(0 0 0 / .55); }
.notes p { font-size: .85rem; }
.notes-close { margin-top: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font: inherit; cursor: pointer; }
footer .legal .link { font-size: inherit; color: inherit; }

/* Foldable panes (results on the left, chat on the right). On a phone they are sections that fold to their title;
   on the dashboard they fold to a thin rail at the side of the map. */
.pane { position: relative; }
.fold { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 2px; border: 0; background: none; color: var(--fg);
  font: inherit; font-size: 1.05rem; font-weight: 700; text-align: left; cursor: pointer; }
.fold-icon { width: 16px; height: 16px; margin-left: auto; color: var(--muted); transform: rotate(-90deg); transition: transform .2s var(--ease); }
.pane.folded .fold-icon { transform: rotate(90deg); }
.fold:hover .fold-icon { color: var(--fg); }
.fold-new { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.pane.folded .fold.has-new .fold-new { display: inline-block; }
.pane.folded > :not(.fold) { display: none !important; }
.chat > header h2 { display: none; }
@media (prefers-reduced-motion: reduce) { .fold-icon { transition: none; } }

/* Small shared buttons. */
.more, .map-reset, .notes-close, .chat-context > button { border-radius: 999px !important; transition: border-color .15s, color .15s; }
.map-zoom button { border-radius: var(--radius-sm); box-shadow: var(--shadow-2); }

/* Dashboard: on a big enough screen everything fits on one screen, like a control room. The race and the count are
   the header; results and chat are panes either side of the map, each folding to a rail. Each panel scrolls inside
   itself; the page doesn't. Smaller screens (phones, small laptops) keep the scrolling page above. */
@media (min-width: 1100px) and (min-height: 650px) {
  body {
    --lw: minmax(300px, 24vw); --rw: minmax(320px, 25vw);
    height: 100vh; height: 100dvh; overflow: hidden; padding: 10px 12px 6px !important;
    display: grid; gap: 10px;
    grid-template-columns: var(--lw) minmax(0, 1fr) var(--rw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "banner banner banner" "top top top" "tabs map chat" "foot foot spon";
  }
  body.fold-left { --lw: var(--pane-rail); }
  body.fold-right { --rw: var(--pane-rail); }
  main { display: contents; }
  .sim-banner { grid-area: banner; margin: -10px -12px 0; }

  /* Cards */
  .top, .tabbed, .map-section, .chat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); min-height: 0; min-width: 0; }
  h2 { margin: 0 0 8px; }

  /* Header: brand | race (the widest part) | count. */
  .top { grid-area: top; max-width: none; margin: 0; padding: 10px 18px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 28px; position: relative; z-index: 5; }
  .brand { flex-direction: column; align-items: flex-start; gap: 2px; }
  .top h1 { font-size: 1.15rem; }
  .status { font-size: .78rem; }
  .hero { padding: 0; }
  .hero-pair { gap: 20px; margin-bottom: 6px; }
  .hero-number { font-size: 1.35rem; }
  .hero-votes, .hero-turnout { font-size: 1.1rem; }

  #pm { background: none; border: 0; padding: 0; border-radius: 0; }
  /* Race: candidate | bar | candidate on one line, heading and 176 mark above the bar, groups below it. */
  #pm { min-width: 0; }
  #pm > h2 { margin: 0; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
  #pm > h2 small { margin-left: 4px; text-transform: none; letter-spacing: 0; }
  #pm .blocs { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "lh bar rh" "lh legend rh"; column-gap: 14px; row-gap: 3px; align-items: center; margin: 0; padding-top: 14px; margin-top: -14px; }
  #pm .bloc-heads { display: contents; }
  #pm .bloc-head.left { grid-area: lh; }
  #pm .bloc-head.right { grid-area: rh; }
  #pm .bloc-head { gap: 8px; }
  #pm .bloc-head div { font-size: .85rem; }
  #pm .bloc-head div span { display: none; }
  #pm .bloc-head .pm-pic { --s: 34px; }
  #pm .bloc-total { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
  #pm .bloc-bar { grid-area: bar; height: 14px; border-radius: 999px; }
  #pm .bloc-group.left .bloc-seg:first-child { border-radius: 999px 0 0 999px; }
  #pm .bloc-group.right .bloc-seg:last-child { border-radius: 0 999px 999px 0; }
  #pm .bloc-176 { top: -16px; font-size: .68rem; }
  #pm .bloc-line { top: -3px; bottom: -3px; }
  #pm .bloc-legend { grid-area: legend; margin: 0; font-size: .75rem; }
  #pm .bloc-note { grid-column: 1 / -1; margin-top: 6px; }

  .sponsors-main { grid-area: spon; margin: 0; justify-self: end; align-self: center; flex-wrap: nowrap; }
  .sponsors-main .sponsors-label { flex-basis: auto; margin-right: 4px; }
  .sponsors-main .sponsor { width: 110px; height: 30px; }
  .sponsors-main .sponsor img { max-height: 22px; max-width: 100px; }
  .sponsors-main .sponsor.empty { line-height: 1; }
  .sponsors-main .sponsor.empty b { font-size: .7rem; } .sponsors-main .sponsor.empty small { display: none; }

  /* Panes: the fold button sits in the top corner; folded, it becomes the whole rail with the title written sideways. */
  .pane .fold { position: absolute; top: 8px; z-index: 2; width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
  .pane .fold:hover { background: var(--raise); }
  .pane .fold-label { display: none; }
  .pane .fold-icon { margin: 0; transform: none; }
  #pane-left .fold { right: 8px; }
  #pane-right .fold { right: 8px; }
  .pane.folded { padding: 0 !important; }
  .pane.folded .fold { position: static; width: 100%; height: 100%; padding: 12px 0; flex-direction: column; justify-content: flex-start; gap: 10px; border-radius: inherit; }
  .pane.folded .fold-label { display: block; writing-mode: vertical-rl; font-size: .85rem; letter-spacing: .02em; }
  #pane-left.folded .fold-label { transform: rotate(180deg); }
  .pane.folded .fold-icon { order: -1; transform: rotate(180deg); }
  .pane.folded .fold-new { order: -1; }

  .tabbed { grid-area: tabs; margin: 0; padding: 8px 12px 0; display: flex; flex-direction: column; }
  .tabs { margin: 0 38px 10px 0; flex: none; }
  .tabs [role="tab"] { padding: 5px 10px; font-size: .85rem; }
  .tabbed [role="tabpanel"] { flex: 1; min-height: 0; overflow-y: auto; padding: 0 2px 10px; scrollbar-gutter: stable; }
  .provinces { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .parties th, .parties td { padding: 6px 4px; font-size: .85rem; }
  .parties thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
  .pm-cands { margin-top: 4px; }
  .pm-rows { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }

  /* The map takes whatever space is left, keeping its shape (800 x 640) and centred. */
  .map-section { grid-area: map; padding: 10px 14px; display: flex; flex-direction: column; }
  .map-head h2 { margin: 0; }
  .map-hint { margin: 2px 0 0; }
  .map-stage { flex: 1; min-height: 0; position: relative; container-type: size; display: grid; place-items: center; }
  .map-stage .map-wrap { width: min(100cqw, 125cqh); aspect-ratio: 800 / 640; }
  .map-stage .map { height: 100%; }
  .map-stage .map-legend { position: absolute; left: 0; bottom: 0; max-width: 55%; margin: 0; padding: 6px 10px; z-index: 3;
    background: color-mix(in srgb, var(--card) 88%, transparent); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .78rem; backdrop-filter: blur(6px); }

  /* Chat: the right pane, full height. */
  .chat { grid-area: chat; position: relative; width: auto; margin: 0; padding: 10px 12px; display: flex; flex-direction: column; overflow: hidden; }
  .chat > header { padding-right: 38px; min-height: 30px; align-items: center; margin-bottom: 6px; }
  .chat > header h2 { display: block; margin: 0; font-size: 1rem; }
  .chat-top { flex: none; }
  .chat-list { flex: 1; height: auto; min-height: 80px; }
  .chat .sponsors { display: none; }

  footer { grid-area: foot; max-width: none; margin: 0; padding: 0 4px; display: flex; flex-wrap: wrap; gap: 2px 16px; align-items: center; font-size: .72rem; }
  footer > p { margin: 0; }
}
@media (min-width: 1100px) and (min-height: 650px) and (max-width: 1360px) {
  .top { gap: 18px; padding: 10px 14px; }
  .brand { min-width: 0; } .top h1 { font-size: 1rem; }
  .status .updated { display: block; margin-left: 0; }
  .hero-pair { gap: 14px; }
}
@media (min-width: 1100px) and (min-height: 650px) and (max-height: 820px) {
  .chat-form input { padding: 7px 9px; }
}

/* Superchat colour tiers by amount, like YouTube's: header colour, body colour, text colour. */
.t1 { --sc-h: #1565c0; --sc-b: #1e88e5; --sc-fg: #fff; }
.t2 { --sc-h: #00b8d4; --sc-b: #00e5ff; --sc-fg: #0b1a1f; }
.t3 { --sc-h: #0f9d58; --sc-b: #1de9b6; --sc-fg: #0b1f17; }
.t4 { --sc-h: #ffb300; --sc-b: #ffca28; --sc-fg: #1f1700; }
.t5 { --sc-h: #e65100; --sc-b: #f57c00; --sc-fg: #fff; }
.t6 { --sc-h: #c2185b; --sc-b: #e91e63; --sc-fg: #fff; }
.t7 { --sc-h: #b71c1c; --sc-b: #e62117; --sc-fg: #fff; }

/* "Top superchats de la noche": a horizontal strip of cards, biggest first, scrolled sideways. */
.top-strip { display: flex; gap: 6px; margin: 0; padding: 2px 2px 6px; list-style: none; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.top-strip li { flex: none; scroll-snap-align: start; }
/* A chip: amount and name in the tier colour. A pinned one has a lighter bar that drains as its pinned time runs out. */
.top-card { position: relative; isolation: isolate; display: flex; align-items: center; gap: 6px; max-width: 170px; padding: 5px 11px 5px 9px; border: 0; border-radius: 999px;
  overflow: hidden; font: inherit; font-size: .8rem; line-height: 1.2; color: var(--sc-fg); background: var(--sc-h); cursor: pointer;
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease), box-shadow .15s; }
.top-card.pinned::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--sc-b); transform-origin: left;
  transform: scaleX(var(--from, 1)); animation: chip-drain var(--dur, 0s) linear forwards; }
@keyframes chip-drain { from { transform: scaleX(var(--from, 1)); } to { transform: scaleX(0); } }
.top-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-3); }
.top-card b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.top-amount { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }

/* The superchat button: gold, with a light sweeping across it and a twinkling star. */
.chat-super { display: block; }
.chat-super[hidden] { display: none; }
.chat-form .super-btn { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px 14px;
  border: 0; border-radius: 999px; color: #3b2300; font-size: .98rem; font-weight: 800; letter-spacing: .01em;
  background: linear-gradient(110deg, #f7b500 0%, #ffd84d 22%, #fff1a8 34%, #ffc21a 48%, #ff9800 72%, #ff5e3a 100%);
  background-size: 200% 100%; animation: super-bg 6s ease-in-out infinite;
  box-shadow: 0 0 0 1px rgb(255 200 60 / .6), 0 4px 18px rgb(255 160 0 / .45), inset 0 1px 0 rgb(255 255 255 / .6); text-shadow: 0 1px 0 rgb(255 255 255 / .45); }
.chat-form .super-btn small { font-size: .72rem; font-weight: 600; opacity: .8; }
.chat-form .super-btn:hover { box-shadow: 0 0 0 1px rgb(255 210 80 / .9), 0 6px 26px rgb(255 160 0 / .7), inset 0 1px 0 rgb(255 255 255 / .7); transform: translateY(-1px); }
.super-glint { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .85) 48%, transparent 60%) no-repeat; background-size: 60% 100%;
  animation: super-glint 2.6s ease-in-out infinite; }
.super-btn::before, .super-btn::after { content: ''; position: absolute; width: 6px; height: 6px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff 0 30%, transparent 70%); box-shadow: 0 0 6px 2px rgb(255 255 255 / .8); animation: super-twinkle 1.8s ease-in-out infinite; }
.super-btn::before { left: 14%; top: 22%; }
.super-btn::after { right: 12%; bottom: 24%; animation-delay: .9s; }
.super-star { display: inline-block; font-size: 1.1rem; animation: super-spin 3s linear infinite; }
@keyframes super-glint { 0% { background-position: -150% 0; } 55%, 100% { background-position: 250% 0; } }
@keyframes super-twinkle { 0%, 100% { opacity: 0; transform: scale(.3); } 50% { opacity: 1; transform: scale(1.3); } }
@keyframes super-spin { to { transform: rotate(360deg); } }
@keyframes super-bg { 50% { background-position: 100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .chat-form .super-btn, .super-glint, .super-btn::before, .super-btn::after, .super-star, .top-card.pinned::before { animation: none; }
  .top-card { transition: none; }
}

/* The superchat dialog. */
.super-dialog { width: min(440px, calc(100vw - 32px)); padding: 18px 20px 16px; border: 1px solid var(--line); border-radius: var(--radius-3);
  background: var(--card); color: var(--fg); box-shadow: var(--shadow-6); }
.super-dialog::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(2px); }
.super-dialog header { display: flex; align-items: center; justify-content: space-between; }
.super-dialog h2 { margin: 0; font-size: 1.15rem; }
.super-dialog h2 span { color: #ffb300; }
.super-x { width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.super-x:hover { background: var(--raise); color: var(--fg); }
.super-intro { margin: 6px 0 14px; font-size: .85rem; color: var(--muted); }
.super-field { display: grid; gap: 4px; margin-bottom: 10px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.super-field input, .super-field textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-2); background: var(--bg); color: var(--fg); font: inherit; font-size: .95rem; font-weight: 400; resize: vertical; }
.super-amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 10px; }
.super-amounts button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px; border: 0; border-radius: var(--radius-2);
  background: linear-gradient(var(--sc-h), var(--sc-b)); color: var(--sc-fg); font: inherit; cursor: pointer; box-shadow: var(--shadow-2); transition: transform .12s var(--ease), filter .12s; }
.super-amounts button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.super-amounts button:disabled, .super-other button:disabled { opacity: .5; cursor: wait; transform: none; }
.super-amounts b { font-size: 1.15rem; font-weight: 800; }
.super-amounts small { font-size: .68rem; opacity: .85; }
.super-other { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.super-other input { width: 5.5em; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-2); background: var(--bg); color: var(--fg); font: inherit; }
.super-other button { padding: 7px 14px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.super-dialog .chat-note { margin: 10px 0 0; }
.super-fine { margin: 6px 0 0; font-size: .72rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .super-amounts button { transition: none; } }
