:root {
  font-family: Aptos, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  color: #172b24;
  background: #f9f6f6;
  --center: #114838;
  --mint: #e0e9e6;
  --muted: #52665e;
  --line: #e0e8e3;
  --red: #ad384d;
  --yellow: #fab833;
  --green: #21765b;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select, label.filter { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid #235ec0;
  outline-offset: 2px;
}
h1, h2, h3, p, dl, dd { margin: 0; }
.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

.page-heading { padding-block: 49px 30px; }
.page-heading h1 {
  color: var(--center);
  font-size: clamp(2.55rem, 6vw, 4.5rem);
  letter-spacing: -.054em;
  line-height: 1;
  margin-bottom: 12px;
}
.page-heading p { font-size: clamp(1rem, 2vw, 1.16rem); color: var(--muted); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(294px, 325px);
  grid-template-areas: "ballot result";
  align-items: start;
  gap: 22px;
}

.result {
  grid-area: result;
  position: sticky;
  top: 20px;
  padding: 23px;
  background: var(--center);
  color: #fff;
  border-radius: 16px;
}
.tally-heading { margin: 10px 0 15px; }
.tally-heading p {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: var(--mint);
  font-size: .88rem;
}
.tally-heading strong {
  color: #fff;
  font-size: 3.6rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.075em;
  line-height: 1;
}
.result-bar {
  display: flex;
  height: 8px;
  overflow: hidden;
  margin-bottom: 17px;
  border-radius: 6px;
  background: rgba(224, 233, 230, .26);
}
#bar-red { background: #f294a4; }
#bar-yellow { background: var(--yellow); }
#bar-green { background: #83c7a1; }
.result-bar span { transition: width .16s ease-out; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.metric {
  --metric-color: #bacfc5;
  min-width: 0;
  background: rgba(255, 255, 255, .08);
  border-radius: 8px;
  padding: 9px 10px 8px;
}
.metric.red { --metric-color: #f8a9b6; }
.metric.yellow { --metric-color: #ffd46c; }
.metric.green { --metric-color: #a7dfbe; }
.metric dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--mint);
  white-space: nowrap;
  font-size: .79rem;
}
.metric dt::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--metric-color);
}
.metric dd {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.metric dd strong { font-size: 1.57rem; line-height: 1.3; }
.metric dd span { color: var(--mint); font-size: .76rem; }
.result-note { margin-top: 13px; font-size: .77rem; color: var(--mint); }

.ballot {
  grid-area: ballot;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.ballot-heading { padding: 19px 20px 13px; }
.ballot-heading h2 { color: var(--center); font-size: 1.27rem; letter-spacing: -.018em; }
.ballot-heading p { margin-top: 3px; font-size: .86rem; color: var(--muted); }
.ballot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 13px;
  padding: 5px 20px;
  background: #f3f7f5;
  border-block: 1px solid var(--line);
  font-size: .83rem;
}
.filter, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.filter { min-height: 32px; }
.filter input { accent-color: var(--center); width: 15px; height: 15px; margin: 0; }
.toolbar-actions { gap: 13px; }
.action {
  padding: 5px 0;
  background: none;
  border: 0;
  color: var(--center);
  font-weight: 650;
  text-underline-offset: 3px;
}
.action:hover { text-decoration: underline; }
.empty { padding: 16px 20px; color: var(--muted); }

.group + .group { border-top: 1px solid var(--line); }
.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 7px 16px 7px 20px;
}
.group-info h3 { font-size: .94rem; font-weight: 700; }
.mandates { display: block; color: var(--muted); font-size: .78rem; }
.split-counts { font-weight: 650; }
.group-actions {
  display: grid;
  grid-template-columns: auto 39px;
  align-items: center;
  gap: 9px;
}
.vote-buttons { display: grid; grid-template-columns: repeat(3, 56px) 31px; gap: 4px; }
.vote {
  padding: 3px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 680;
  font-size: .79rem;
}
.vote.red { --fill: #f9e4e8; --ink: #8d2f40; }
.vote.yellow { --fill: #fff1cb; --ink: #735007; }
.vote.green { --fill: #dceee4; --ink: #155740; }
.vote.unset { --fill: #eef2ef; --ink: #586a61; }
.vote:hover, .vote[aria-pressed="true"] { background: var(--fill); }
.vote[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 .5px var(--ink);
}
.split-button {
  border: 0;
  padding: 2px 0;
  min-height: 34px;
  background: none;
  color: var(--center);
  font-size: .79rem;
  font-weight: 700;
  text-underline-offset: 3px;
}
.split-button:hover, .split-button[aria-expanded="true"] { text-decoration: underline; }
.split-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 16px 10px 20px;
  padding: 9px 12px 11px;
  border-radius: 8px;
  background: #f3f7f5;
}
.split-editor label { display: grid; gap: 2px; font-size: .78rem; color: var(--muted); }
.split-editor select {
  color: #172b24;
  padding: 4px;
  border: 1px solid #aebfb6;
  border-radius: 5px;
  background: #fff;
  font-size: .94rem;
}
.page-footer { padding: 16px 0 30px; font-size: .83rem; color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 870px) {
  .shell { width: min(720px, calc(100% - 36px)); }
  .page-heading { padding-block: 32px 21px; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "result" "ballot";
    gap: 14px;
  }
  .result { z-index: 1; top: 0; padding: 14px 16px; }
  .tally-heading { margin: 4px 0 8px; }
  .tally-heading strong { font-size: 2.2rem; }
  .result-bar { height: 5px; margin-bottom: 8px; }
  .results-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .metric { padding: 5px 7px; }
  .metric dd strong { font-size: 1.22rem; }
  .metric dd span { font-size: .69rem; }
  .result-note { margin-top: 6px; font-size: .71rem; }
  .ballot button, .ballot select, .ballot input { scroll-margin-top: 200px; }
}

@media (max-width: 540px) {
  .shell { width: calc(100% - 28px); }
  .page-heading { padding-top: 29px; }
  .ballot-heading { padding-inline: 13px; }
  .ballot-toolbar { padding-inline: 13px; column-gap: 8px; }
  .toolbar-actions { gap: 8px; }
  .group-row { grid-template-columns: 1fr; gap: 5px; padding: 9px 13px; }
  .group-actions { grid-template-columns: minmax(0, 1fr) 38px; gap: 5px; }
  .vote-buttons { grid-template-columns: repeat(3, minmax(0, 1fr)) 34px; }
  .vote { height: 36px; }
  .split-editor { margin-inline: 13px; }
}

@media (max-height: 510px) and (max-width: 870px) {
  .result { position: static; }
  .ballot button, .ballot select, .ballot input { scroll-margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .result-bar span { transition: none; }
}

.page-heading .vote-context {
  margin-top: 9px;
  max-width: 700px;
  font-size: .87rem;
}

.vote-context a, .source-body a, .page-footer a {
  color: var(--center);
  text-underline-offset: 3px;
}

#scenario-mode {
  color: var(--mint);
  font-size: .76rem;
  text-align: right;
}

.guess-note {
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .81rem;
}

.group-sources:not(:empty) { margin: -4px 16px 9px 20px; }
.sources { color: var(--muted); font-size: .76rem; }
.sources summary {
  width: fit-content;
  min-height: 22px;
  padding: 2px 0;
  color: var(--center);
  cursor: pointer;
  font-weight: 700;
  text-underline-offset: 3px;
}
.sources summary:hover { text-decoration: underline; }
.sources summary:focus-visible { outline: 2px solid #235ec0; outline-offset: 2px; }
.source-body {
  margin-top: 5px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #f3f7f5;
  font-size: .83rem;
}
.source-body ul { list-style: none; margin: 0; padding: 0; }
.source-body li + li { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.source-body li strong { color: #172b24; }
.source-body li p { margin-top: 2px; }
.source-body li a { display: inline-block; margin-top: 3px; font-weight: 650; }
.page-footer p + p { margin-top: 3px; }

@media (max-width: 540px) {
  .guess-note { padding-inline: 13px; }
  .group-sources:not(:empty) { margin: -1px 13px 8px; }
}
