:root {
  --ink: #1f2933;
  --muted: #66727d;
  --paper: #f5f1e9;
  --panel: #fffdf8;
  --line: #d9d1c3;
  --accent: #a7442e;
  --accent-dark: #7f3021;
  --soft: #e9eee9;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
.masthead { max-width: 1100px; margin: 0 auto; padding: 58px 24px 38px; }
.masthead h1 { margin: 6px 0 10px; font: 700 clamp(2.7rem, 7vw, 5.8rem)/.94 Georgia, serif; letter-spacing: -.055em; }
.masthead p { max-width: 570px; color: var(--muted); font-size: 1.08rem; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 800; }
main { max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 12px 30px #5f493014; }
.lookup { display: grid; gap: 22px; }
h2, h3, h4 { font-family: Georgia, serif; }
h2 { margin: 5px 0; font-size: 2rem; }
h3 { font-size: 1.6rem; margin: 0; }
h4 { margin: 0 0 7px; font-size: 1.1rem; }
.muted { color: var(--muted); }
label { display: block; font-size: .86rem; font-weight: 700; margin-bottom: 8px; }
.lookup-row { display: flex; gap: 10px; }
input { border: 1px solid var(--line); background: white; border-radius: 9px; padding: 13px 14px; font: inherit; flex: 1; min-width: 0; }
select { appearance: none; border: 1px solid var(--line); background-color: white; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2366727d' d='M4 6l4 4 4-4z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; border-radius: 9px; padding: 13px 42px 13px 14px; font: inherit; width: 100%; }
button { border: 0; border-radius: 9px; background: var(--accent); color: white; padding: 13px 18px; font: 700 .9rem inherit; cursor: pointer; }
button:hover { background: var(--accent-dark); }
.status { min-height: 20px; color: var(--muted); }
.status.error { color: var(--accent-dark); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.authority-row { display: flex; align-items: end; gap: 10px; }
.authority-row > div { flex: 1; }
.authority-help { padding: 14px 16px; border-left: 4px solid var(--accent); background: #f4f0e7; color: var(--muted); font-size: .9rem; }
.authority-help strong { color: var(--ink); }
.saved-ballots { display: grid; gap: 10px; }
.saved-ballots h4 { margin: 0; }
.saved-ballot-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 13px; background: #fff; }
.saved-ballot-card p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.saved-ballot-card button { flex: none; }
.saved-warning { color: var(--muted); font-size: .86rem; margin: 0; }
.hidden { display: none !important; }
#election-picker { margin-top: 24px; }
.election-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 18px; }
.election-card { background: var(--soft); color: var(--ink); text-align: left; min-height: 90px; }
.election-card:hover { background: #dce7df; }
.election-card strong, .election-card span { display: block; }
.election-card span { color: var(--muted); margin-top: 7px; font-weight: 500; }
#ballot { margin-top: 24px; }
.ballot-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.action-footer { justify-content: center; border-top: 1px solid var(--line); padding-top: 28px; margin-top: 8px; }
.action-primary { background: var(--accent); box-shadow: none; font-size: .9rem; padding: 13px 18px; }
.action-primary:hover { background: var(--accent-dark); }
.secondary { background: #e5e0d7; color: var(--ink); }
.secondary:hover { background: #d7d0c4; }
.contest { border-bottom: 1px solid var(--line); padding: 28px 0; }
.contest:last-child { border-bottom: 0; }
.contest-meta { color: var(--muted); font-size: .85rem; margin: 5px 0 18px; }
.choices { display: grid; gap: 9px; }
.choice { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.choice:has(input:checked) { border-color: var(--accent); background: #fff5f0; }
.choice input { flex: none; margin-top: 3px; accent-color: var(--accent); }
.choice small { color: var(--muted); display: block; margin-top: 3px; }
.research { background: #f4f0e7; border-radius: 12px; padding: 18px; margin: 16px 0; }
.candidate-loading { color: var(--muted); }
.candidate-loading .spinner { border-color: var(--line); border-top-color: var(--accent); }
.measure-loading { color: var(--muted); }
.measure-loading .spinner { border-color: var(--line); border-top-color: var(--accent); }
.measure-text { margin: 16px 0; padding: 14px 16px; border-left: 3px solid var(--line); background: #fff; }
.measure-text p { margin: 8px 0 0; white-space: pre-wrap; }
.decision-summary { margin-top: 28px; padding: 20px; border: 2px solid var(--accent); border-radius: 14px; background: #fffaf2; }
.decision-summary h3 { margin: 4px 0 14px; }
.summary-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; border-top: 1px solid var(--line); padding: 10px 0; }
.summary-row span { font-weight: 800; text-align: right; }
.issue-report { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 20px; }
.issue-report h4 { margin-bottom: 4px; }
.issue-report textarea { display: block; width: 100%; min-height: 80px; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 12px; font: inherit; margin: 10px 0; }
.issue-report form { display: flex; align-items: start; gap: 10px; flex-wrap: wrap; }
.issue-report textarea { flex-basis: 100%; }
.research ul { margin: 7px 0 14px; padding-left: 20px; }
.tag { display: inline-block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-dark); margin-top: 9px; }
.party-tag { display: inline-block; margin-left: 8px; padding: 4px 8px; border-radius: 999px; letter-spacing: .06em; font-size: .65rem; }
.party-tag.democrat { color: #1555a5; background: #dceaff; }
.party-tag.republican { color: #a32929; background: #ffe1e1; }
.sources { font-size: .82rem; }
.sources a { color: var(--accent-dark); }
.followup { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.followup-form { display: flex; gap: 8px; margin-top: 8px; }
.followup-form input { padding: 10px 12px; }
.followup-form button { padding: 10px 14px; }
.followup-form button:disabled { opacity: .75; cursor: wait; }
.spinner { display: inline-block; width: .85em; height: .85em; margin-right: .35em; border: 2px solid #ffffff80; border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
.followup-answer { color: var(--ink); font-size: .9rem; }
.followup-answer.error { color: var(--accent-dark); }
.notice { padding: 14px; border-left: 4px solid var(--accent); background: #fff5f0; color: var(--muted); font-size: .9rem; }
@media (max-width: 640px) {
  .masthead { padding-top: 35px; }
  .panel { padding: 20px; border-radius: 14px; }
  .lookup-row, .ballot-header { display: grid; }
  .lookup-row button { width: 100%; }
  .actions { justify-content: flex-start; }
  .saved-ballot-card { display: grid; }
}
@media print {
  body { background: white; }
  .masthead { padding: 20px 0; }
  .lookup, #election-picker, .actions, .notice, .issue-report { display: none !important; }
  main { padding: 0; }
  #ballot { display: block !important; margin: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .contest { break-inside: avoid; }
}
