/* theballotopia — civic, readable, restrained. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-sunken: #f1f1ee;
  --border: #dedcd6;
  --border-strong: #c3c0b8;
  --text: #1c1b19;
  --text-muted: #5f5c55;
  --text-faint: #86827a;
  --accent: #1f5f8b;
  --accent-hover: #17496b;
  --accent-soft: #e6eff5;
  --success: #2f6b46;
  --success-soft: #e4f0e9;
  --warning: #8a5a12;
  --warning-soft: #f7eddb;
  --danger: #9b2c2c;
  --danger-soft: #f7e5e5;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.06), 0 2px 8px rgba(28, 27, 25, 0.04);
  --measure: 68ch;
  --font-sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #1f2123;
    --surface-sunken: #26282b;
    --border: #343739;
    --border-strong: #4a4d50;
    --text: #ececea;
    --text-muted: #a8a7a3;
    --text-faint: #85847f;
    --accent: #6fb2dc;
    --accent-hover: #8cc4e8;
    --accent-soft: #1d3444;
    --success: #7cc79b;
    --success-soft: #1e3227;
    --warning: #ddb271;
    --warning-soft: #352a19;
    --danger: #e08585;
    --danger-soft: #3a2222;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; margin: 0 0 0.5em; font-weight: 600; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
small { font-size: 0.85rem; }

/* ---- Layout ---- */
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }
main { padding: 2rem 0 4rem; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.split { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; gap: 1.5rem; } }

/* ---- Header ---- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 62px; flex-wrap: wrap; }
.brand { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.925rem; }
.site-nav a:hover, .site-nav a.is-active { color: var(--text); text-decoration: underline; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.card-link:hover { border-color: var(--border-strong); color: inherit; transform: translateY(-1px); }
.card h3 { margin-bottom: 0.25rem; }
.card-muted { background: var(--surface-sunken); box-shadow: none; }

/* ---- Meta and badges ---- */
.meta { color: var(--text-muted); font-size: 0.875rem; }
.meta-dot::before { content: "·"; margin: 0 0.45em; color: var(--text-faint); }
.badge {
  display: inline-block; padding: 0.15em 0.6em; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
  background: var(--surface-sunken); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-open { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-closed { background: var(--surface-sunken); color: var(--text-faint); }
.badge-draft { background: var(--warning-soft); color: var(--warning); border-color: transparent; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; justify-content: center;
  padding: 0.55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-size: 0.925rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-sunken); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.825rem; }
.btn-block { width: 100%; }
/* .site-nav a is more specific than .btn, so buttons in the nav need this. */
.site-nav a.btn, .site-nav a.btn:hover { color: #fff; }
.site-nav a.btn-secondary, .site-nav a.btn-secondary:hover { color: var(--text); }
@media (prefers-color-scheme: dark) {
  .btn, .btn:hover, .site-nav a.btn, .site-nav a.btn:hover { color: #10171c; }
  .btn-secondary, .btn-secondary:hover,
  .site-nav a.btn-secondary, .site-nav a.btn-secondary:hover { color: var(--text); }
  .btn-danger, .btn-danger:hover { color: var(--danger); }
}

/* ---- Forms ---- */
form .field { margin-bottom: 1.1rem; }
label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.3rem; }
.input, input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="number"], select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 5rem; }
.checkbox-field { display: flex; gap: 0.5rem; align-items: flex-start; }
.checkbox-field input { width: auto; margin-top: 0.35rem; }
.checkbox-field label { margin: 0; font-weight: 400; }
.helptext { display: block; color: var(--text-muted); font-size: 0.825rem; margin-top: 0.25rem; }
.errorlist { list-style: none; margin: 0.35rem 0 0; padding: 0; color: var(--danger); font-size: 0.85rem; }
.form-error { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }

/* ---- Messages ---- */
.messages { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.messages li {
  padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 0.5rem;
  border: 1px solid var(--border); background: var(--surface); font-size: 0.925rem;
}
.messages .success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.messages .error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.messages .warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.messages .info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---- Prose (sanitized rich text) ---- */
.prose { max-width: var(--measure); }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose h2, .prose h3, .prose h4 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li + li { margin-top: 0.25em; }
.prose blockquote {
  margin: 1em 0; padding: 0.25em 0 0.25em 1em;
  border-left: 3px solid var(--border-strong); color: var(--text-muted);
}
.prose code { background: var(--surface-sunken); padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.9em; }
.prose pre { background: var(--surface-sunken); padding: 0.9em; border-radius: var(--radius-sm); overflow-x: auto; }

/* ---- Page header ---- */
.page-head { border-bottom: 1px solid var(--border); padding-bottom: 1.25rem; margin-bottom: 2rem; }
.page-head h1 { margin-bottom: 0.35rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span { margin: 0 0.4em; color: var(--text-faint); }

/* ---- Candidate ---- */
.candidate-head { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.avatar {
  width: 112px; height: 112px; border-radius: var(--radius); object-fit: cover;
  background: var(--surface-sunken); border: 1px solid var(--border); flex-shrink: 0;
}
.avatar-sm { width: 52px; height: 52px; border-radius: var(--radius-sm); }
.avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 2rem; color: var(--text-faint);
}
.avatar-placeholder.avatar-sm { font-size: 1.1rem; }

/* ---- Lists ---- */
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-divided { list-style: none; margin: 0; padding: 0; }
.list-divided > li { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.list-divided > li:last-child { border-bottom: 0; }
.list-divided > li:first-child { padding-top: 0; }

/* ---- Resume ---- */
.resume-entry { padding-left: 1rem; border-left: 2px solid var(--border); }
.resume-entry h4 { margin-bottom: 0.1rem; }
.resume-relevance {
  margin-top: 0.75rem; padding: 0.75rem 0.9rem;
  background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 0.925rem;
}
.resume-relevance strong { display: block; font-size: 0.775rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 0.2rem; }

/* ---- Discussion ---- */
.post { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.35rem; }
.post-author { font-weight: 600; font-size: 0.95rem; }
.post-body { white-space: pre-wrap; margin: 0; }
.post-replies { margin: 0.75rem 0 0 1.25rem; padding-left: 1rem; border-left: 2px solid var(--border); }
.post-actions { margin-top: 0.4rem; display: flex; gap: 0.75rem; }
.post-actions button, .post-actions a {
  background: none; border: 0; padding: 0; font: inherit; font-size: 0.825rem;
  color: var(--text-muted); cursor: pointer; text-decoration: underline;
}
.post-actions button:hover, .post-actions a:hover { color: var(--text); }

/* ---- Polls ---- */
.poll-option { margin-bottom: 0.6rem; }
.poll-choice { display: flex; gap: 0.6rem; align-items: center; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.poll-choice:hover { border-color: var(--border-strong); background: var(--surface-sunken); }
.poll-choice input { width: auto; margin: 0; }
.poll-choice.is-mine { border-color: var(--accent); background: var(--accent-soft); }
.result-row { margin-bottom: 0.85rem; }
.result-label { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; margin-bottom: 0.25rem; }
.result-label .result-count { color: var(--text-muted); white-space: nowrap; }
.result-bar { height: 9px; background: var(--surface-sunken); border-radius: 99px; overflow: hidden; }
.result-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.result-row.is-mine .result-bar span { background: var(--success); }
.result-row.is-mine .result-label { font-weight: 600; }

/* ---- Dashboard ---- */
.dash { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
@media (max-width: 800px) { .dash { grid-template-columns: 1fr; gap: 1.5rem; } }
.dash-nav { position: sticky; top: 80px; }
.dash-nav ul { list-style: none; margin: 0; padding: 0; }
.dash-nav li { margin-bottom: 2px; }
.dash-nav a {
  display: block; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 0.925rem;
}
.dash-nav a:hover { background: var(--surface-sunken); color: var(--text); }
.dash-nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dash-nav .nav-heading {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); padding: 1rem 0.75rem 0.35rem; font-weight: 600;
}
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-value { font-family: var(--font-serif); font-size: 1.9rem; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ---- Rich text editor ---- */
.richtext-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.richtext-wrap:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.richtext-toolbar {
  display: flex; gap: 2px; flex-wrap: wrap; padding: 0.35rem;
  border-bottom: 1px solid var(--border); background: var(--surface-sunken);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.richtext-toolbar button {
  min-width: 30px; height: 28px; padding: 0 0.45rem; font: inherit; font-size: 0.85rem;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--text-muted); cursor: pointer;
}
.richtext-toolbar button:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.richtext-toolbar .sep { width: 1px; background: var(--border); margin: 3px 4px; }
.richtext-editor {
  min-height: 11rem; max-height: 32rem; overflow-y: auto; padding: 0.7rem 0.8rem;
  font-size: 0.95rem; line-height: 1.65;
}
.richtext-editor:focus { outline: none; }
.richtext-editor > *:first-child { margin-top: 0; }
.richtext-editor[data-empty="true"]::before {
  content: attr(data-placeholder); color: var(--text-faint); pointer-events: none;
}
.richtext-hint { font-size: 0.8rem; color: var(--text-faint); padding: 0.3rem 0.8rem 0.5rem; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.75rem 0; color: var(--text-muted); font-size: 0.875rem;
}

/* ---- Utilities ---- */
.empty { color: var(--text-muted); font-style: italic; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.notice { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.85rem 1rem; font-size: 0.925rem; }
.notice-warn { background: var(--warning-soft); color: var(--warning); }
.credential { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; word-break: break-all; font-size: 0.9rem; }

/* ---- Suggested name block on signup ---- */
.suggested-name {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem 0.4rem;
  margin-bottom: 1.1rem;
}
.suggested-name > .row-between { margin-bottom: 0.25rem; }
.suggested-name .meta { margin-bottom: 0.8rem; }

/* ---- Disabled buttons ---- */
.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:disabled:hover,
.btn[disabled]:hover {
  background: var(--accent);
}
.btn-secondary:disabled:hover,
.btn-secondary[disabled]:hover {
  background: var(--surface);
}

/* ---- Share my page ---- */
.share-url {
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem;
}
.share-url code {
  flex: 1; min-width: 14rem; word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.925rem;
}
.qr-row { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.qr-preview {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.75rem; line-height: 0; flex-shrink: 0;
}
.qr-preview svg { width: 168px; height: 168px; display: block; }

/* ---- Landing hero: the next election, in full ---- */
.hero {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  margin-bottom: 2.5rem;
}
.hero-eyebrow {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  font-size: 0.775rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 0.6rem;
}
.hero-countdown {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 0.1em 0.7em;
  letter-spacing: 0.02em; text-transform: none; font-size: 0.8rem;
  color: var(--text-muted);
}
.hero-countdown-today { background: var(--success-soft); color: var(--success); border-color: transparent; }
.hero-title { font-size: 2.6rem; margin: 0 0 0.35rem; letter-spacing: -0.02em; }
.hero-title a { color: var(--text); text-decoration: none; }
.hero-title a:hover { text-decoration: underline; }
.hero-where { color: var(--text-muted); margin: 0 0 1rem; font-size: 0.95rem; }
.hero-summary { font-size: 1.15rem; line-height: 1.55; max-width: 54ch; margin: 0 0 1.5rem; }
.hero-stats {
  display: flex; gap: 2.5rem; flex-wrap: wrap; margin: 0 0 1.75rem;
  padding: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.hero-stats div { margin: 0; }
.hero-stats dt {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 0.15rem;
}
.hero-stats dd { margin: 0; font-family: var(--font-serif); font-size: 1.75rem; line-height: 1; }

@media (max-width: 640px) {
  .hero { padding: 1.5rem 1.25rem; }
  .hero-title { font-size: 1.9rem; }
  .hero-summary { font-size: 1.05rem; }
  .hero-stats { gap: 1.5rem; }
}

/* Exactly two columns, collapsing to one on narrow screens. */
.tile-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .tile-grid { grid-template-columns: 1fr; } }

/* ---- Issue ranking ---- */
.rank-instructions {
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: 1rem 1.15rem; margin-bottom: 1.5rem;
}
.rank-instructions p { margin: 0 0 0.4rem; }
.rank-instructions p:last-child { margin-bottom: 0; }
.rank-list { list-style: none; margin: 0 0 1.5rem; padding: 0; counter-reset: rank; }
.rank-item {
  display: flex; gap: 0.9rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.85rem 1rem; margin-bottom: 0.6rem;
}
.rank-item.is-dragging { opacity: 0.4; border-style: dashed; }
[data-rank-list][data-enhanced="true"] .rank-item { cursor: grab; }
[data-rank-list][data-enhanced="true"] .rank-item:active { cursor: grabbing; }
.rank-number {
  flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem;
}
.rank-body { flex: 1; min-width: 0; }
.rank-body h3 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.rank-controls { display: flex; flex-direction: column; gap: 0.25rem; flex-shrink: 0; }
.rank-controls button {
  width: 2rem; height: 1.6rem; padding: 0; line-height: 1;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 4px; color: var(--text-muted); cursor: pointer; font-size: 0.8rem;
}
.rank-controls button:hover { background: var(--surface-sunken); color: var(--text); }
.rank-grip { flex-shrink: 0; color: var(--text-faint); cursor: grab; line-height: 1.4; user-select: none; }
[data-rank-list]:not([data-enhanced="true"]) .rank-grip { display: none; }
.rank-unsaved {
  background: var(--warning-soft); color: var(--warning);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem;
  font-size: 0.9rem; margin-bottom: 1rem;
}

/* ---- Overall ranking on the election dashboard ---- */
.rank-chart { list-style: none; margin: 0; padding: 0; }
.rank-chart li { padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.rank-chart li:last-child { border-bottom: 0; }
.rank-row-head { display: flex; gap: 0.75rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.rank-score { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.rank-meter { height: 8px; background: var(--surface-sunken); border-radius: 99px; margin-top: 0.45rem; overflow: hidden; }
.rank-meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---- Candidate portraits: a uniform 1 : 1.4 frame everywhere ---- */
.portrait {
  aspect-ratio: 1 / 1.4;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); color: var(--text-faint); font-size: 2.2rem;
}
.portrait-sm { width: 64px; }
.portrait-md { width: 128px; }

/* ---- Pan control ---- */
.pan-frame {
  position: relative; width: 210px; aspect-ratio: 1 / 1.4;
  overflow: hidden; border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong); background: var(--surface-sunken);
  cursor: grab; touch-action: none; user-select: none;
}
.pan-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pan-frame.is-panning { cursor: grabbing; }
.pan-frame img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.pan-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.pan-row { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.pan-hint { font-size: 0.875rem; color: var(--text-muted); max-width: 30ch; }
.pan-numbers { display: flex; gap: 0.75rem; }
.pan-numbers .field { margin-bottom: 0.5rem; }
.pan-numbers input { width: 6rem; }
[data-pan][data-enhanced="true"] ~ * .pan-numbers { opacity: 0.75; }

/* ---- Candidate carousel ---- */
.carousel { margin-bottom: 2rem; }
.carousel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.carousel-window { overflow: hidden; max-width: 100%; }
.carousel-track {
  display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0;
  transition: transform 0.45s ease;
}
/* Without the script the row simply scrolls, and nothing is hidden. */
[data-carousel]:not([data-enhanced="true"]) .carousel-window { overflow-x: auto; }
[data-carousel]:not([data-enhanced="true"]) .carousel-track { transform: none !important; }
@media (prefers-reduced-motion: reduce) { .carousel-track { transition: none; } }

.carousel-item { flex: 0 0 132px; }
.carousel-item a { display: block; text-decoration: none; color: inherit; }
.carousel-item a:hover .portrait { border-color: var(--accent); }
.carousel-item a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }
.carousel-name { margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.carousel-role { color: var(--text-muted); font-size: 0.8rem; }
.carousel-controls { display: flex; gap: 0.35rem; align-items: center; }
.carousel-controls button {
  width: 2rem; height: 2rem; border-radius: 50%; padding: 0; line-height: 1;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-muted); cursor: pointer;
}
.carousel-controls button:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
.carousel-controls button:disabled { opacity: 0.35; cursor: default; }
.carousel-dots { display: flex; gap: 0.3rem; margin: 0 0.4rem; }
.carousel-dot {
  width: 7px; height: 7px; padding: 0; border-radius: 50%;
  border: 0; background: var(--border-strong); cursor: pointer;
}
.carousel-dot[aria-current="true"] { background: var(--accent); }
@media (max-width: 480px) { .carousel-item { flex: 0 0 116px; } }

/* ---- Administrator actions on public pages ---- */
.admin-bar {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  background: var(--warning-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; margin-bottom: 1.25rem;
}
.admin-bar-tag {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--warning); margin-right: 0.15rem;
}
.admin-bar-note { color: var(--text-muted); font-size: 0.85rem; }
.admin-bar .btn { white-space: nowrap; }

/* ---- Long URLs must not push a card wider than its column ---- */
.hero-summary, .post-body, .meta, .prose, .rank-body, .card p {
  overflow-wrap: anywhere;
}
/* Links produced by linkify sit inside prose; keep them visually consistent. */
.post-body a, .hero-summary a, .meta a { text-decoration: underline; text-underline-offset: 2px; }

/* ---- Inline edit control for administrators ---- */
.edit-link {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; font-weight: 600; text-decoration: none;
  color: var(--warning); background: var(--warning-soft);
  border: 1px solid transparent; border-radius: 99px;
  padding: 0.1em 0.6em; vertical-align: middle; white-space: nowrap;
}
.edit-link:hover { color: var(--warning); border-color: var(--warning); }
.edit-link-text { letter-spacing: 0.02em; }

/* The whole portrait becomes an edit target for administrators. */
.portrait-editable { position: relative; display: block; text-decoration: none; }
.portrait-editable .portrait { transition: border-color 0.15s; }
.portrait-editable:hover .portrait { border-color: var(--warning); }
.portrait-editable::after {
  content: "Edit"; position: absolute; left: 50%; bottom: 0.5rem;
  transform: translateX(-50%);
  background: var(--warning); color: #fff;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.15em 0.6em; border-radius: 99px;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.portrait-editable:hover::after, .portrait-editable:focus-visible::after { opacity: 1; }

/* A heading an administrator can click to edit what it names. */
.editable-heading { color: inherit; text-decoration: none; }
.editable-heading:hover { color: inherit; text-decoration: underline; text-decoration-color: var(--warning); }
.editable-mark {
  font-size: 0.5em; vertical-align: super; margin-left: 0.35em;
  color: var(--warning); opacity: 0.55;
}
.editable-heading:hover .editable-mark { opacity: 1; }

/* Small edit control beside an item in a list, for administrators. */
.edit-chip {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none;
  color: var(--warning); background: var(--warning-soft);
  border-radius: 99px; padding: 0.1em 0.55em; vertical-align: middle;
  margin-left: 0.3rem;
}
.edit-chip:hover { color: #fff; background: var(--warning); }

/* ---- Where to go after reading a platform ---- */
.next-block { margin-top: 2.5rem; padding-top: 1.75rem; border-top: 1px solid var(--border); }
.next-title { font-size: 1.15rem; margin-bottom: 1rem; }
.next-grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 620px) { .next-grid { grid-template-columns: 1fr; } }
.next-card {
  display: flex; flex-direction: column; gap: 0.2rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.next-card:hover { border-color: var(--accent); color: inherit; transform: translateY(-1px); }
.next-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.next-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--accent);
}
.next-lead { font-weight: 600; font-size: 1rem; line-height: 1.3; }
.next-note { color: var(--text-muted); font-size: 0.85rem; }

/* ---- Feature tiles: what the site is for ---- */
:root {
  --feat-rank-bg:    #e8eff7;  --feat-rank-ink:    #1c4a6e;
  --feat-talk-bg:    #e3f0e8;  --feat-talk-ink:    #23573b;
  --feat-stand-bg:   #ece8f5;  --feat-stand-ink:   #443a6b;
  --feat-poll-bg:    #f7eedd;  --feat-poll-ink:    #77521a;
  --feat-ask-bg:     #f6e6ea;  --feat-ask-ink:     #7a2e45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --feat-rank-bg:  #17293a;  --feat-rank-ink:    #9cc6e6;
    --feat-talk-bg:  #162c20;  --feat-talk-ink:    #93cdaa;
    --feat-stand-bg: #241f39;  --feat-stand-ink:   #b6a9e0;
    --feat-poll-bg:  #332a19;  --feat-poll-ink:    #dcb87b;
    --feat-ask-bg:   #351a22;  --feat-ask-ink:     #e3a3b5;
  }
}
:root[data-theme="dark"] {
  --feat-rank-bg:    #17293a;  --feat-rank-ink:    #9cc6e6;
  --feat-talk-bg:    #162c20;  --feat-talk-ink:    #93cdaa;
  --feat-stand-bg:   #241f39;  --feat-stand-ink:   #b6a9e0;
  --feat-poll-bg:    #332a19;  --feat-poll-ink:    #dcb87b;
  --feat-ask-bg:     #351a22;  --feat-ask-ink:     #e3a3b5;
}

.features { margin-bottom: 2.5rem; }
.features-lead { color: var(--text-muted); margin: 0 0 1.25rem; max-width: 60ch; }
.feature-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.feature-tile {
  display: flex; flex-direction: column; gap: 0.45rem;
  border-radius: var(--radius); padding: 1.35rem 1.4rem;
  border: 1px solid transparent; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
a.feature-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
a.feature-tile:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.feature-tile h3 { margin: 0; font-size: 1.1rem; color: inherit; }
.feature-tile p { margin: 0; font-size: 0.9rem; line-height: 1.55; color: inherit; opacity: 0.85; }
.feature-kicker {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; opacity: 0.75;
}
/* Pushed to the bottom so the four links sit on one line regardless of how
   much text each tile carries. */
.feature-go { margin-top: auto; padding-top: 0.6rem; font-size: 0.85rem; font-weight: 600; opacity: 0.9; }

.feature-rank  { background: var(--feat-rank-bg);  color: var(--feat-rank-ink); }
.feature-talk  { background: var(--feat-talk-bg);  color: var(--feat-talk-ink); }
.feature-stand { background: var(--feat-stand-bg); color: var(--feat-stand-ink); }
.feature-poll  { background: var(--feat-poll-bg);  color: var(--feat-poll-ink); }
.feature-ask   { background: var(--feat-ask-bg);   color: var(--feat-ask-ink); }

/* ---- Video tiles ---- */
.video-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.video-tile {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.video-thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-sunken);
  overflow: hidden;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb-pending {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 0.875rem;
}
.video-duration {
  position: absolute; right: 0.5rem; bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.75); color: #fff;
  font-size: 0.72rem; font-weight: 600; padding: 0.1em 0.45em; border-radius: 4px;
}
.video-body { padding: 0.85rem 1rem; flex: 1; }
.video-body h3 { margin: 0 0 0.25rem; font-size: 1rem; }
/* A candidate's transcript, folded under the tile; a long one scrolls in place
   rather than stretching its row of the grid. */
.video-transcript { margin-top: 0.5rem; }
.video-transcript summary { cursor: pointer; font-weight: 600; font-size: 0.875rem; }
.video-transcript .prose { max-height: 24rem; overflow-y: auto; margin-top: 0.4rem; font-size: 0.9rem; }
.video-actions { display: flex; gap: 0.5rem; padding: 0 1rem 1rem; }
.video-actions form { margin: 0; }

/* A tile that opens the player. */
.video-play { position: relative; display: block; text-decoration: none; color: inherit; }
.video-play::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.12); opacity: 0; transition: opacity 0.15s;
}
.video-play:hover::after, .video-play:focus-visible::after { opacity: 1; }
.video-play-mark {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); color: #1c1b19;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; padding-left: 3px; z-index: 1;
}
.video-player { aspect-ratio: 16 / 9; width: 100%; border: 0; border-radius: var(--radius); }
.video-player-wrap { margin-bottom: 0.75rem; }

/* A forum's recording: one player, sized to how it was filmed. A phone held
   upright would otherwise fill a desktop screen top to bottom. */
.forum-video { max-width: 720px; margin: 0.75rem 0; }
.forum-video.is-portrait { max-width: min(360px, 100%); }
.forum-video .video-thumb { border-radius: var(--radius); }
.forum-video .video-player-wrap { margin-bottom: 0.4rem; }
.forum-video-links { margin-top: 0.4rem; }
.forum-video-title { margin-bottom: 0.4rem; }
.forum-video-item + .forum-video-item { border-top: 1px solid var(--border); padding-top: 1rem; }
.upload-tip { margin-top: 0.5rem; }
.upload-tip summary { cursor: pointer; font-weight: 600; }
.upload-tip ol { margin: 0.5rem 0; padding-left: 1.3rem; }
.upload-tip li { margin-bottom: 0.25rem; }

.upload-bar { height: 8px; background: var(--surface-sunken); border-radius: 99px; overflow: hidden; margin-bottom: 0.4rem; }
.upload-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.2s; }

/* ---- Advice attached to a field ---- */
.username-warning { margin: -0.6rem 0 1.1rem; font-size: 0.9rem; line-height: 1.5; }
.username-warning strong { display: block; margin-bottom: 0.15rem; }

/* ---- Start-an-election call to action ---- */
.start-cta {
  display: flex; gap: 1.75rem; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 2.5rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 1.5rem 1.75rem;
}
.start-cta-title { margin: 0 0 0.3rem; font-size: 1.3rem; }
.start-cta-lead { margin: 0; color: var(--text-muted); max-width: 58ch; font-size: 0.95rem; line-height: 1.6; }
.start-cta-action { display: flex; flex-direction: column; gap: 0.4rem; align-items: stretch; }
.start-cta-price { margin: 0; font-size: 0.82rem; color: var(--text-muted); text-align: center; }
@media (max-width: 680px) { .start-cta-action { width: 100%; } }

.page-menu { margin-top: 1rem; }

/* Local-names checker under a transcript box. */
/* display:flex would otherwise beat the hidden attribute and leave an empty
   bar sitting under every transcript box. */
.spellcheck-strip[hidden] { display: none; }
.spellcheck-strip {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-top: 0.6rem; padding: 0.6rem 0.75rem;
  background: var(--warning-soft); border-radius: 6px;
}
.spellcheck-label { font-size: 0.85rem; color: var(--warning); font-weight: 600; }
.spellcheck-fix {
  font: inherit; font-size: 0.85rem; cursor: pointer;
  padding: 0.2rem 0.6rem; border: 1px solid var(--warning);
  background: var(--surface, #fff); color: var(--text); border-radius: 999px;
}
.spellcheck-fix:hover { background: var(--warning); color: var(--bg, #fff); }

/* Correction controls under a transcript box. */
.spellcheck-controls {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
  margin-top: 0.6rem; font-size: 0.85rem; color: var(--text-muted);
}
.spellcheck-controls label { margin: 0; font-weight: 500; cursor: pointer; }
.spellcheck-note { color: var(--success); font-weight: 600; }
.spellcheck-help summary { cursor: pointer; color: var(--accent); }
.spellcheck-shortcuts {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  margin-top: 0.4rem; padding: 0.5rem 0.75rem;
  background: var(--surface-sunken); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem;
}

/* Autosave state above a transcript box. */
.autosave-status {
  margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--text-faint);
}
.autosave-status[data-state="saved"] { color: var(--success); }
.autosave-status[data-state="saving"] { color: var(--text-muted); }
.autosave-status[data-state="failed"] { color: var(--danger); font-weight: 600; }

/* Live transcript on a forum block. */
.forum-live { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.85rem; }
.forum-live label { margin: 0; font-weight: 500; cursor: pointer; color: var(--text-muted); }
.forum-live-state { font-size: 0.8rem; color: var(--text-faint); }
.forum-live-state[data-state="live"] { color: var(--success); font-weight: 600; }
.forum-live-state[data-state="failed"] { color: var(--danger); }
/* The pale wash marks which forum is being followed, at a glance. */
.forum[data-live] {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: -0.25rem -1rem;
}
.forum-transcript {
  margin-top: 0.6rem; padding: 0.6rem 0.8rem;
  background: var(--surface); border-radius: var(--radius-sm);
  font-size: 0.9rem; line-height: 1.5;
  /* A running log rather than a peephole: a burst lands whole and what came
     before it stays there to scroll back through. */
  max-height: 20rem; overflow-y: auto; overscroll-behavior: contain;
}
.forum-transcript p { margin: 0 0 0.25rem; }
.forum-transcript p:last-child { margin-bottom: 0; }
.forum-transcript-empty { color: var(--text-faint); font-style: italic; }
