/* Neutral civic palette: no party reds or blues anywhere. */
:root {
  --ink: #1d2730;
  --ink-2: #4a5864;
  --muted: #6d7a85;
  --line: #d9d4c7;
  --paper: #fbf8f1;
  --card: #ffffff;
  --bg: #efebe2;
  --accent: #1f3a4d;
  --accent-2: #2f5a73;
  --accent-soft: #e3ecf1;
  --ok: #2e6b4f;
  --ok-soft: #e2f0e8;
  --warn: #8a5a12;
  --warn-soft: #f6ecd9;
  --bad: #8c2f2f;
  --bad-soft: #f5e1df;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ecef; --ink-2: #c2cbd2; --muted: #93a0aa; --line: #3a444c;
    --paper: #1f262c; --card: #232b32; --bg: #161b20;
    --accent: #8fb8d1; --accent-2: #a9cbe0; --accent-soft: #263743;
    --ok: #8fcfae; --ok-soft: #1f3329; --warn: #e2bb76; --warn-soft: #3a2f1c;
    --bad: #e7a19b; --bad-soft: #3a2422;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8ecef; --ink-2: #c2cbd2; --muted: #93a0aa; --line: #3a444c;
  --paper: #1f262c; --card: #232b32; --bg: #161b20;
  --accent: #8fb8d1; --accent-2: #a9cbe0; --accent-soft: #263743;
  --ok: #8fcfae; --ok-soft: #1f3329; --warn: #e2bb76; --warn-soft: #3a2f1c;
  --bad: #e7a19b; --bad-soft: #3a2422;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.5em; margin: 8px 0 0; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.fineprint { font-size: 12.5px; color: var(--muted); }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--accent-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--card); }
.btn.wide { width: 100%; }
.icon-btn { font-size: 20px; width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); padding: 32px 28px; border-radius: var(--radius);
  box-shadow: var(--shadow); display: grid; gap: 10px; text-align: center; }
.login-card h1 { font-family: var(--serif); margin: 4px 0 0; font-size: 28px; }
.login-card label { text-align: left; font-weight: 600; margin-top: 12px; }
.login-card input { font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.seal { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--card); display: grid;
  place-items: center; font-size: 26px; margin: 0 auto; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.titles { flex: 1; min-width: 0; }
.progress-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#style-select { font: inherit; font-size: 14px; max-width: 42vw; padding: 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); }
.progress { height: 4px; background: var(--line); }
#progress-bar { height: 100%; width: 0; background: var(--accent-2); transition: width .3s; }

/* layout: one calm column; the chat slides in when asked */
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; display: grid; gap: 16px; }
.page-note { margin: 0; }

/* ballot card: modeled on the printed Florida ballot */
.ballot-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.section-band { background: var(--accent); color: var(--card); padding: 8px 20px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  display: flex; justify-content: space-between; gap: 12px; }
.card-body { padding: 20px 24px 16px; }
.contest-title { font-family: var(--serif); font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
.vote-for { font-weight: 700; font-size: 14px; color: var(--ink-2); margin-bottom: 14px; }
.options { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.option { display: flex; align-items: center; gap: 14px; padding: 12px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.option:hover { background: var(--accent-soft); }
.oval { flex: none; width: 34px; height: 20px; border: 2px solid var(--ink); border-radius: 50%; }
.option[aria-checked="true"] .oval { background: var(--ink); }
.opt-name { flex: 1; font-size: 18px; font-weight: 600; min-width: 0; }
.opt-name small { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.opt-party { font-size: 13px; font-weight: 700; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; background: var(--card); }
.writein .opt-name { font-weight: 400; color: var(--muted); font-style: italic; }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 24px 16px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* brief: tabs, then one section at a time made of bordered blocks */
.brief { display: grid; gap: 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; font: inherit; font-size: 14.5px; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--card); }
.panel { display: grid; gap: 12px; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.block h3 { margin: 0 0 8px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.block.lead { border-left: 4px solid var(--accent-2); }
.block.lead .pts li { font-size: 17px; }
.pts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pts li { position: relative; padding-left: 16px; line-height: 1.45; }
.pts li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.pts .empty { color: var(--muted); font-style: italic; padding-left: 0; }
.pts .empty::before { display: none; }
.cites { white-space: nowrap; }
.cite { font-size: 11px; font-weight: 700; vertical-align: super; color: var(--accent-2); text-decoration: none; padding: 0 1px; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.block.yes { border-top: 4px solid var(--ok); }
.block.no { border-top: 4px solid var(--ink-2); }
.who { font-weight: 700; }
.args .who { display: block; font-size: 14px; }

/* compare: one block per issue, a row per candidate */
.stance { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.stance:first-of-type { border-top: 0; padding-top: 2px; }
.stance .name { font-weight: 700; font-size: 14.5px; }
.stance .none { color: var(--muted); font-style: italic; }
.note { font-size: 14px; color: var(--ink-2); background: var(--paper); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }

/* candidate picker */
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 8px 12px; cursor: pointer; text-align: left; }
.pick-btn small { display: block; color: var(--muted); font-size: 12px; }
.pick-btn[aria-pressed="true"] { border-color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent-2); background: var(--accent-soft); }
.profile-head .nm { font-family: var(--serif); font-size: 22px; font-weight: 700; }
.profile-head .role { color: var(--ink-2); }

/* timeline: why it's on the ballot */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 0 0 14px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .when { font-weight: 700; font-size: 13.5px; color: var(--accent-2); padding-top: 1px; }
.timeline .what { border-left: 2px solid var(--line); padding-left: 14px; }

/* exact ballot wording */
.ballot-summary { font-family: var(--serif); font-size: 17px; line-height: 1.6; white-space: pre-line; margin: 0; }

/* sources */
.src { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--line); }
.src:first-of-type { border-top: 0; }
.src a { word-break: break-word; }
.tier { flex: none; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.tier.t1 { background: var(--ok-soft); color: var(--ok); }
.tier.t2 { background: var(--accent-soft); color: var(--accent-2); }
.tier.t3 { background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); }
.tier.t4, .tier.t5 { background: var(--warn-soft); color: var(--warn); }
.src.flash { background: var(--accent-soft); border-radius: 6px; }
.checked-line { display: flex; flex-wrap: wrap; gap: 6px; }

.stepper { display: flex; gap: 10px; justify-content: space-between; }
.stepper .btn { flex: 1; max-width: 220px; }

/* ask button + chat drawer */
.ask-fab { position: fixed; right: 20px; bottom: 20px; z-index: 15; font: inherit; font-weight: 700; border: 0; border-radius: 999px;
  padding: 14px 20px; background: var(--accent); color: var(--card); box-shadow: var(--shadow); cursor: pointer; }
.chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 20; display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .25s; visibility: hidden; }
.chat.open { transform: none; visibility: visible; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-topic { font-weight: 700; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; background: var(--bg); }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--card); padding: 10px 14px; border-radius: 14px 14px 4px 14px; max-width: 85%; }
.msg.bot { display: grid; gap: 10px; }
.msg.bot .block { padding: 12px 14px; }
.lead-line { font-size: 16.5px; font-weight: 600; line-height: 1.45; margin: 0; }
.working { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.empty-chat { color: var(--ink-2); font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0; }
.steps { list-style: none; padding: 0; margin: 0; font-size: 14px; display: grid; gap: 6px; }
.steps li { display: flex; gap: 8px; align-items: baseline; color: var(--muted); }
.steps li.running { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--ok); }
.steps .dot { width: 16px; flex: none; text-align: center; }
.trail { font-size: 12.5px; color: var(--muted); margin: 6px 0 0 24px; max-height: 120px; overflow: auto; word-break: break-all; }
.spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.checks { font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.checks summary { cursor: pointer; font-weight: 600; color: var(--accent-2); }
.checks h4 { margin: 12px 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.claim { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.claim q { display: block; font-style: italic; color: var(--ink-2); margin-top: 4px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); }
.chip { flex: none; font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 7px 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent-2); }
.ask-form { display: flex; gap: 8px; padding: 0 16px 6px; }
.ask-form textarea { flex: 1; font: inherit; resize: none; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.chat-note { padding: 0 16px 12px; margin: 0; }

/* table of contents */
.toc { width: min(560px, calc(100vw - 32px)); max-height: 85dvh; border: 0; border-radius: var(--radius); padding: 0; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.toc::backdrop { background: rgba(0,0,0,.35); }
.toc-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.toc-head h2 { margin: 0; font-family: var(--serif); }
.toc ol { margin: 0; padding: 8px 10px; list-style: none; }
.toc li button { width: 100%; text-align: left; font: inherit; background: none; border: 0; color: var(--ink); padding: 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; }
.toc li button:hover, .toc li button[aria-current="true"] { background: var(--accent-soft); }
.toc .num { color: var(--muted); width: 28px; flex: none; }
.toc .sec { display: block; font-size: 12px; color: var(--muted); }
.toc .mark { margin-left: auto; color: var(--ok); }
.toc #review-btn { margin: 4px 18px 18px; width: calc(100% - 36px); }

/* review page */
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.review-list .pick { font-weight: 700; text-align: right; }
.review-list .none { color: var(--muted); font-weight: 400; font-style: italic; }

@media (max-width: 640px) {
  .contest-title { font-size: 22px; }
  .topbar .eyebrow { display: none; }
  #style-select { max-width: 40vw; }
  .card-body { padding: 16px 16px 12px; }
  .card-foot { padding: 10px 16px 14px; }
  .two-up { grid-template-columns: 1fr; }
  .stance { grid-template-columns: 1fr; gap: 2px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .timeline .what { border-left: 0; padding-left: 0; }
  .chat { top: auto; height: 92dvh; width: 100vw; border-left: 0; border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .ask-fab { right: 16px; bottom: 16px; }
  .stepper .btn { padding: 10px 8px; }
}
@media print {
  .topbar, .progress, .stepper, .chat, .ask-fab, .brief, .fineprint { display: none !important; }
  body { background: #fff; }
}
