/* ==========================================================================
   Vector Vote — base styles
   ========================================================================== */

:root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --surface-2: #f0f0f7;
    --text: #1b1b2f;
    --text-muted: #5d5d78;
    --border: #e2e2ee;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-text: #ffffff;
    --accent: #0d9488;
    --ok: #15803d;
    --fail: #b91c1c;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgb(20 20 50 / 6%), 0 4px 16px rgb(20 20 50 / 6%);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --maxw: 960px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11111c;
        --surface: #1a1a29;
        --surface-2: #232336;
        --text: #ececf6;
        --text-muted: #a3a3bd;
        --border: #2e2e46;
        --primary: #7c74ff;
        --primary-hover: #948dff;
        --primary-text: #0c0c18;
        --accent: #2dd4bf;
        --ok: #4ade80;
        --fail: #f87171;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.55;
}

a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--text-muted); }

/* ---- Layout ---- */

.site-header,
.site-main,
.site-footer {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
}

.site-header { padding-top: 18px; padding-bottom: 18px; }
.site-main { flex: 1; padding-bottom: 48px; }
.site-footer { padding-top: 24px; padding-bottom: 32px; color: var(--text-muted); font-size: .9rem; text-align: center; }
.site-footer p { margin: 0; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -.01em;
}
.brand-mark { width: 32px; height: 32px; color: var(--primary); }

/* ---- Components ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.card.narrow { max-width: 560px; margin: 32px auto; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;              /* comfortable tap target */
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-lg { min-height: 52px; padding: 12px 28px; font-size: 1.1rem; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .75rem;
    font-style: normal;
    font-weight: 600;
    vertical-align: middle;
}

/* ---- Home page ---- */

.hero { text-align: center; padding: 48px 0 40px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); letter-spacing: -.02em; }
.hero .accent { color: var(--primary); }
.lede { max-width: 560px; margin: 0 auto 28px; color: var(--text-muted); font-size: 1.1rem; }

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.step h2 { font-size: 1.15rem; }
.step p { color: var(--text-muted); margin: 0; }
.step-num {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-bottom: 10px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-text);
    font-weight: 700;
}

.method-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.method span { display: block; color: var(--text-muted); }
.method.is-soon strong { color: var(--text-muted); }

/* ---- Setup check ---- */

.check-list { list-style: none; padding: 0; margin: 0 0 16px; }
.check-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-list small { display: block; color: var(--text-muted); }
.check-icon { font-weight: 700; width: 1.2em; }
.check-list .ok .check-icon { color: var(--ok); }
.check-list .fail .check-icon { color: var(--fail); }

/* ---- Forms ---- */

.form-card { max-width: 640px; margin: 16px auto; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

.field { margin: 0 0 24px; padding: 0; border: 0; min-width: 0; }
.field > label,
.field > legend { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; }
.optional { color: var(--text-muted); font-weight: 400; }
.hint { margin: 4px 0 8px; color: var(--text-muted); font-size: .9rem; }

input[type="text"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }

.has-error input[type="text"], .has-error textarea { border-color: var(--fail); }
.field-error { margin: 6px 0 0; color: var(--fail); font-size: .9rem; font-weight: 600; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 600; }
.alert-error { background: color-mix(in srgb, var(--fail) 12%, transparent); color: var(--fail); }

/* Honeypot: off-screen, not display:none (some bots skip hidden fields) */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.option-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.option-row { display: flex; gap: 8px; }
.option-row input { flex: 1; }

.btn-icon { width: 44px; padding: 0; font-size: 1.4rem; line-height: 1; color: var(--text-muted); }
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }
.btn-ghost { background: transparent; border-style: dashed; }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

.choice-group { display: grid; gap: 8px; }
.choice,
.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.check { border: 0; padding: 6px 0; }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.choice input[type="radio"], .check input[type="checkbox"] { margin-top: 5px; accent-color: var(--primary); width: 18px; height: 18px; flex: none; }
.choice > span { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choice select, .choice input[type="datetime-local"] { width: auto; flex: 1; min-width: 180px; }
.check small { display: block; }

/* ---- Links page ---- */

.link-box { margin: 24px 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.link-box h2 { font-size: 1.05rem; margin-bottom: 2px; }
.link-box-private { border-color: color-mix(in srgb, var(--fail) 35%, var(--border)); }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.share-btn { margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- Utilities ---- */

[hidden] { display: none !important; }
.small { font-size: .85rem; }
.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; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--primary); font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; }

.alert-success { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.alert-info { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text); font-weight: 500; }

/* ---- Ballot ---- */

.ballot-card { max-width: 880px; margin: 16px auto; }
.ballot-description { color: var(--text); white-space: normal; }
.ballot-meta { margin-bottom: 20px; }
.ballot-instructions { margin-bottom: 16px; }

.ballot-grid { display: grid; gap: 20px; margin-bottom: 20px; }
/* Phones: ranking on top, options below. Wider screens: options left → ranking right. */
@media (min-width: 720px) {
    .ballot-grid { grid-template-columns: 1fr 1fr; align-items: start; }
    .pool-col { order: 1; }
    .ranking-col { order: 2; }
}

.ballot-col { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.col-head h2 { font-size: 1rem; margin: 0; }
.empty-state { margin: 4px 0; color: var(--text-muted); font-size: .95rem; }

.pool, .ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.pool-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, transform .05s, box-shadow .15s;
}
.pool-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.pool-item:active { transform: scale(.99); }
.pool-item:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.pool-plus {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    color: var(--text-muted);
    font-weight: 700;
}
.pool-item:hover .pool-plus { border-color: var(--primary); color: var(--primary); }
.pool-label { overflow-wrap: anywhere; }

.rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 6px 6px 6px 10px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.rank-item.is-new { animation: rank-in .18s ease-out; }
.rank-num {
    flex: none;
    min-width: 40px;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--primary);
    color: var(--primary-text);
    font-weight: 700;
    font-size: .85rem;
    text-align: center;
}
.rank-item:first-child .rank-num { background: var(--accent); }
.rank-label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.rank-actions { display: flex; gap: 4px; flex: none; }
.rank-actions .btn-icon { width: 38px; min-height: 38px; font-size: 1.05rem; }

@keyframes rank-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .rank-item.is-new { animation: none; }
}

.ballot-name { margin-top: 4px; }
@media (max-width: 420px) {
    .rank-item { gap: 8px; padding-left: 8px; }
    .rank-num { min-width: 34px; }
    .rank-actions { gap: 2px; }
    .rank-actions .btn-icon { width: 34px; min-height: 40px; }
}

/* ---- Shared bits (Phase 4) ---- */

.center { text-align: center; }
.flash { max-width: 880px; margin: 0 auto 16px; }
.btn-danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); border-color: var(--fail); }

.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.status-open { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-closed { background: var(--surface-2); color: var(--text-muted); }
.status-draft { background: var(--surface-2); color: var(--text-muted); }

/* ---- Organizer page ---- */

.manage-card { max-width: 880px; margin: 16px auto; }
.manage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.stat-wide { grid-column: span 2; }
@media (max-width: 420px) { .stat-wide { grid-column: span 1; } }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .85rem; }
.stat-time { font-weight: 700; }
.close-now { margin-top: 16px; }

.manage-section { border-top: 1px solid var(--border); padding: 12px 0; }
.manage-section > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.manage-section[open] > summary { margin-bottom: 12px; }
.danger-zone > summary { color: var(--fail); }
.name-list { columns: 2 180px; margin: 0; padding-left: 20px; }

/* ---- Results ---- */

.results-card { max-width: 880px; margin: 16px auto; }
.result-hero { margin: 16px 0 24px; padding: 20px; border-radius: var(--radius); text-align: center;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); }
.result-hero.is-tie { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.result-empty { background: var(--surface-2); border-color: var(--border); }
.result-kicker { margin: 0; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; }
.result-title { margin: 4px 0; font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.result-sub { margin: 0; font-size: .9rem; }

.rounds-heading { font-size: 1.05rem; margin-top: 8px; }
.round { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface); }
.round > summary { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 12px 14px; cursor: pointer; }
.round-num { font-weight: 700; }
.round-summary { font-size: .9rem; }
.round[open] > summary { border-bottom: 1px solid var(--border); }
.round-note { margin: 0 14px 12px; font-size: .9rem; }
.tie-note { color: var(--primary); }

.bars { list-style: none; margin: 0; padding: 14px; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 28%) 1fr auto; gap: 10px; align-items: center; }
@media (max-width: 520px) {
    .bar-row { grid-template-columns: 1fr auto; }
    .bar-label { grid-column: 1 / -1; margin-bottom: -6px; }
}
.bar-label { font-weight: 600; overflow-wrap: anywhere; }
.bar-track { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--primary); min-width: 2px; }
.bar-majority { position: absolute; top: -2px; bottom: -2px; left: 50%; border-left: 2px dashed var(--text-muted); opacity: .6; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.bar-value small { color: var(--text-muted); font-weight: 400; }
.bar-row.is-winner .bar-fill { background: var(--accent); }
.bar-row.is-eliminated .bar-fill { background: var(--text-muted); opacity: .45; }
.bar-row.is-eliminated .bar-label { text-decoration: line-through; color: var(--text-muted); }

.explainer { margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.explainer > summary { cursor: pointer; font-weight: 600; }
.explainer p { margin: 10px 0 0; color: var(--text-muted); }

/* ---- Phase 5 polish ---- */

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 10; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--primary); color: var(--primary-text); font-weight: 700; }
.skip-link:focus { top: 8px; }
.site-main:focus { outline: none; }

.relative-time { color: var(--text-muted); white-space: nowrap; }
.results-share { margin: 16px 0 0; }

/* Submitted, waiting for the server */
.btn.is-busy { opacity: .7; cursor: progress; pointer-events: none; }

/* ---- Approval ballot ---- */

.approval-col { margin-bottom: 20px; }
.approval-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.approval-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.approval-item:hover { border-color: var(--primary); }
.approval-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }   /* visually replaced by .approval-box */
.approval-item:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.approval-box {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--border);
    color: transparent;
    font-weight: 800;
    transition: background .15s, border-color .15s, color .15s;
}
.approval-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.approval-tag { flex: none; color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.approval-item:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.approval-item:has(input:checked) .approval-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.approval-item:has(input:checked) .approval-label { font-weight: 600; }
.approval-item:has(input:checked) .approval-tag { color: var(--accent); }
.approval-item.is-locked { opacity: .5; cursor: not-allowed; }
.approval-item.is-locked:hover { border-color: var(--border); }

/* ---- Create form additions ---- */

.inline-number { display: flex; align-items: center; gap: 10px; }
.inline-number input { width: 90px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.customize-wording > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.customize-wording[open] > summary { margin-bottom: 8px; }

.label-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.label-field { display: flex; flex-direction: column; gap: 4px; }
.label-name { font-weight: 600; font-size: .9rem; }
.label-hint { color: var(--text-muted); font-size: .8rem; }

.manage-method { margin-top: -4px; }

/* ---- Drag to reorder (Ranked Choice) ---- */

.rank-handle {
    display: grid;
    place-items: center;
    flex: none;
    width: 26px;
    min-height: 40px;
    margin-left: -4px;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: grab;
    touch-action: none;      /* dragging the handle on a phone must not scroll the page */
}
.rank-handle svg { fill: currentColor; }
.rank-handle:hover { background: var(--surface-2); color: var(--text); }
.ranking.is-sorting, .ranking.is-sorting .rank-handle { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.rank-item { position: relative; transition: box-shadow .15s, border-color .15s; }
.rank-item.is-dragging {
    z-index: 2;
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgb(20 20 50 / 22%), 0 2px 6px rgb(20 20 50 / 10%);
    will-change: transform;
}
.rank-item.is-dragging .rank-handle { color: var(--accent); background: var(--surface-2); }
@media (max-width: 420px) {
    .rank-handle { width: 22px; margin-left: -6px; }
}

/* ---- "How important is this?" level picker ---- */

.level-picker legend { display: flex; align-items: center; gap: 8px; }
.level-custom { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.level-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.level-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.level-card:hover { border-color: var(--primary); }
.level-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.level-card:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.level-card:has(input:checked) { border: 2px solid var(--primary); padding: 11px 13px; background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.level-name { font-weight: 700; }
.level-blurb { color: var(--text-muted); font-size: .85rem; line-height: 1.35; }

/* ---- Settings sections (create form + organizer page) ---- */

.settings-sections { margin: 0 0 24px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.settings-section + .settings-section { border-top: 1px solid var(--border); }
.settings-section > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 12px;
    padding: 14px 40px 14px 16px;
    position: relative;
    cursor: pointer;
    list-style: none;
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary::after {
    content: '›';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.3rem;
    transition: transform .15s;
}
.settings-section[open] > summary::after { transform: translateY(-50%) rotate(90deg); }
.settings-section > summary:hover { background: var(--surface-2); }
.section-title { font-weight: 700; min-width: 130px; }
.section-summary { flex: 1; min-width: 0; color: var(--text-muted); font-size: .9rem; overflow-wrap: anywhere; }
.section-body { padding: 4px 16px 16px; }
.section-body > .field:last-child, .section-body > .check:last-child { margin-bottom: 0; }
.danger-zone .section-title { color: var(--fail); }

.choice.is-soon { opacity: .6; cursor: not-allowed; }

.settings-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.settings-head h2 { margin: 0; }
.setting-list { margin: 0 0 8px; padding-left: 20px; }
.setting-list li { margin: 2px 0; }
.locked-note { margin-top: 8px; }

/* ---- One-final-ballot notes on the ballot page ---- */

.final-note { margin: 0 0 12px; text-align: center; }
.ballot-locked { padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; font-weight: 600; }

/* ---- Closing rule sub-fields ---- */

.close-sub { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.close-sub-title { margin: 0 0 8px; font-weight: 700; font-size: .85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.close-sub .hint { margin-bottom: 0; }
.check.is-locked { opacity: .75; cursor: not-allowed; }

/* ---- Individual ballots ---- */

.alert-warning { background: color-mix(in srgb, #d97706 14%, transparent); color: var(--text); font-weight: 500; }
.visibility-notice { margin-bottom: 16px; }

.individual-ballots { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.individual-ballots h2 { font-size: 1.05rem; }
.named-ballots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.named-ballot { display: grid; grid-template-columns: minmax(100px, 24%) 1fr; gap: 6px 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
@media (max-width: 520px) { .named-ballot { grid-template-columns: 1fr; } }
.named-ballot-name { font-weight: 700; overflow-wrap: anywhere; }
.named-ballot-marks { display: flex; flex-wrap: wrap; gap: 6px; }
.mark-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--surface-2); font-size: .9rem; }
.mark-chip:not(:has(.mark-rank)) { padding-left: 10px; }
.mark-rank { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: var(--primary-text); font-size: .75rem; font-weight: 700; }

/* Links inside user-written descriptions */
.ballot-description a { overflow-wrap: anywhere; text-underline-offset: 2px; }

/* ==========================================================================
   Vector Voting
   ========================================================================== */

:root { --against: #d85a30; --low: #d97706; }
@media (prefers-color-scheme: dark) { :root { --against: #f0997b; --low: #fbbf24; } }

/* ---- Sticky top: influence gauge, summary line, scale labels ---- */

.vector-top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 16px;
    align-items: center;
    margin: 0 -12px 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.vector-meter { display: flex; align-items: center; gap: 10px; }
.vector-meter.is-unlimited { align-self: center; }
.vector-gauge {
    display: flex;
    align-items: flex-end;
    width: 14px;
    height: 56px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
}
.vector-gauge-fill { width: 100%; height: 100%; border-radius: 6px; background: var(--accent); transition: height .12s, background .2s; }
.vector-meter.is-low .vector-gauge-fill { background: var(--low); }
.vector-meter.is-empty .vector-gauge-fill { background: var(--fail); }
.vector-left { display: flex; flex-direction: column; line-height: 1.1; }
.vector-left-num { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.vector-meter.is-empty .vector-left-num { color: var(--fail); }
.vector-left-label { color: var(--text-muted); font-size: .8rem; }
.vector-meter.is-shaking { animation: vv-shake .35s; }
@keyframes vv-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}
@media (prefers-reduced-motion: reduce) { .vector-meter.is-shaking { animation: none; } }

.vector-overview { min-width: 0; }
.vector-map { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); }
.vector-map-center { position: absolute; left: 50%; top: 3px; bottom: 3px; border-left: 2px dashed var(--border); }
.vector-dot {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--text-muted);
    transition: left .08s;
}
.vector-dot.is-for { background: var(--accent); }
.vector-dot.is-against { background: var(--against); }
.vector-axis, .vector-results-axis {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .75rem;
    line-height: 1.2;
}
.vector-axis span:nth-child(2), .vector-results-axis span:nth-child(2) { text-align: center; }
.vector-axis span:nth-child(3), .vector-results-axis span:nth-child(3) { text-align: right; }
.vector-out { grid-column: 1 / -1; margin: 0; color: var(--fail); font-size: .85rem; font-weight: 600; }

/* ---- One row per option: a slider whose fill grows out from the Neutral line ---- */

.vector-rows { list-style: none; margin: 0 0 16px; padding: 0; }
.vector-row { padding: 10px 0 4px; border-top: 1px solid var(--border); }
.vector-row:first-child { border-top: 0; }
.vector-head { display: flex; align-items: baseline; gap: 8px; }
.vector-label { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.vector-cost { color: var(--text-muted); font-size: .8rem; white-space: nowrap; }
.vector-val { min-width: 44px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.vector-row.is-for .vector-val { color: var(--accent); }
.vector-row.is-against .vector-val { color: var(--against); }

/* Slider sizes. On touchscreens the circle is bigger, because it's the only part that can be grabbed. */
.vector-track { --thumb: 26px; position: relative; height: 36px; }
@media (pointer: coarse) { .vector-track { --thumb: 30px; } }

/* The rail is inset by half the thumb width so the fill lines up exactly with the thumb's center. */
.vector-rail { position: absolute; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); top: 50%; height: 8px; margin-top: -4px; border-radius: 4px; background: var(--surface-2); }
.vector-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.vector-row.is-against .vector-fill { background: var(--against); }
.vector-center { position: absolute; left: 50%; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-muted); opacity: .5; }

/*
 * Only the circle (thumb) can be grabbed. The rest of the slider ignores touches, so swiping
 * there scrolls the page, and tapping the line doesn't make the circle jump. Vertical swipes
 * that start on the circle still scroll the page (touch-action: pan-y); sideways drags move it.
 */
.vector-track input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 36px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    touch-action: pan-y;
    -webkit-appearance: none;
    appearance: none;
}
.vector-track input[type="range"]:focus { outline: none; }
.vector-track input[type="range"]::-webkit-slider-runnable-track { height: 36px; background: transparent; }
.vector-track input[type="range"]::-moz-range-track { height: 36px; background: transparent; }
.vector-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    box-sizing: border-box;
    width: var(--thumb);
    height: var(--thumb);
    margin-top: calc((36px - var(--thumb)) / 2);
    border: 3px solid var(--text-muted);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 4px rgb(0 0 0 / 20%);
    pointer-events: auto;
    cursor: grab;
}
.vector-track input[type="range"]::-moz-range-thumb {
    box-sizing: border-box;
    width: var(--thumb);
    height: var(--thumb);
    border: 3px solid var(--text-muted);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 4px rgb(0 0 0 / 20%);
    pointer-events: auto;
    cursor: grab;
}
.vector-track input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
.vector-track input[type="range"]:active::-moz-range-thumb { cursor: grabbing; }
.vector-row.is-for input[type="range"]::-webkit-slider-thumb { border-color: var(--accent); }
.vector-row.is-for input[type="range"]::-moz-range-thumb { border-color: var(--accent); }
.vector-row.is-against input[type="range"]::-webkit-slider-thumb { border-color: var(--against); }
.vector-row.is-against input[type="range"]::-moz-range-thumb { border-color: var(--against); }
.vector-track input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 40%, transparent); }
.vector-track input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 40%, transparent); }

/* ---- Results: bars growing out from the Neutral line ---- */

.vector-results-axis { margin: 0 0 6px; }
.vector-results { list-style: none; margin: 0; padding: 0; }
.vector-result { padding: 8px 0; border-top: 1px solid var(--border); }
.vector-result-head { display: flex; justify-content: space-between; gap: 10px; }
.vector-result-net { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.vector-result-net.is-for { color: var(--accent); }
.vector-result-net.is-against { color: var(--against); }
.vector-result-track { position: relative; height: 14px; margin: 4px 0; border-radius: 7px; background: var(--surface-2); }
.vector-result-bar { position: absolute; top: 0; bottom: 0; border-radius: 7px; }
.vector-result-bar.is-for { background: var(--accent); }
.vector-result-bar.is-against { background: var(--against); }
.vector-result-detail { margin: 0; color: var(--text-muted); font-size: .8rem; }

/* Named Vector ballots */
.mark-chip.is-for { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.mark-chip.is-against { background: color-mix(in srgb, var(--against) 14%, transparent); }
.mark-chip.is-for, .mark-chip.is-against { padding-left: 10px; }
.mark-score { font-weight: 800; font-variant-numeric: tabular-nums; }

/* Phones: gauge + number on one line, summary line and scale labels full width (lined up with the sliders). */
@media (max-width: 560px) {
    .vector-top { grid-template-columns: 1fr; gap: 8px; }
    .vector-gauge { height: 44px; }
    .vector-left { flex-direction: row; align-items: baseline; gap: 8px; }
    .vector-left-num { font-size: 1.7rem; }
    .vector-overview { padding: 0 13px; }
}

/* ---- "About the maths" (Vector Voting) ---- */

.vector-math { margin-top: 12px; }
.vector-math-lede { font-weight: 600; color: var(--text) !important; }
.vector-math-body { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: start; margin-top: 10px; }
@media (max-width: 520px) { .vector-math-body { grid-template-columns: 1fr; justify-items: center; } }
.vector-math-diagram { width: 150px; height: 150px; }
.vm-axis { stroke: var(--border); stroke-width: 1.5; }
.vm-budget { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.vm-vector { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; fill: none; }
.vm-vector.vm-muted { stroke: var(--text-muted); stroke-width: 2; opacity: .6; }
.vm-origin { fill: var(--text); }
.vm-label { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }
.vm-strong { fill: var(--accent); font-weight: 700; }
.vector-math-points { margin: 0; padding-left: 20px; color: var(--text-muted); }
.vector-math-points li { margin-bottom: 8px; }
.vector-math-points strong { color: var(--text); }
.vector-math-credit strong { color: var(--text); }

/* ---- Taglines ---- */

.hero-eyebrow { margin-bottom: 10px; }
.method-featured { padding: 14px; border: 2px solid var(--primary); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.method .method-tagline { margin: 2px 0 4px; color: var(--primary); font-style: italic; font-weight: 600; }
.badge-accent { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }

/* ---- Several winners ---- */

.winners-note { margin: -8px 0 16px; font-weight: 600; }
.winner-list { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0; padding: 0; list-style: none; counter-reset: winner; }
.winner-list li {
    counter-increment: winner;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    font-weight: 700;
}
.winner-list li::before { content: counter(winner) ". "; color: var(--text-muted); font-weight: 600; }
.winner-note { margin-left: 6px; color: var(--text-muted); font-size: .75rem; font-weight: 500; }
.winner-tie { margin: 8px 0 4px; }

.cutoff-line { display: flex; align-items: center; gap: 10px; margin: 6px 0; color: var(--accent); font-size: .8rem; font-weight: 700; list-style: none; }
.cutoff-line::before, .cutoff-line::after { content: ''; flex: 1; border-top: 2px dashed currentColor; opacity: .6; }
.bar-row.is-tied .bar-fill, .vector-result.is-tied .vector-result-bar { opacity: .7; outline: 2px dashed var(--primary); outline-offset: 1px; }

/* "About the maths" on the ballot: a quiet footnote-style link, not a highlighted box. */
.vector-math.is-subtle { margin-top: 20px; padding: 0; background: none; text-align: center; font-size: .85rem; }
.vector-math.is-subtle > summary { display: inline; color: var(--text-muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.vector-math.is-subtle > summary::-webkit-details-marker { display: none; }
.vector-math.is-subtle[open] { text-align: left; }
.vector-math.is-subtle[open] > summary { display: block; text-align: center; margin-bottom: 8px; }

/* ---- Ballot: "How to vote" box and the fine print under the options ---- */

.voting-help { margin: 0 0 12px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.voting-help > summary { padding: 10px 0; cursor: pointer; }
.voting-help-title { font-weight: 700; }
.voting-help-teaser { color: var(--text-muted); font-size: .9rem; }
.voting-help p { margin: 0 0 10px; color: var(--text-muted); font-size: .95rem; }
.voting-help p:last-child { margin-bottom: 14px; }
.voting-help strong, .voting-help em { color: var(--text); }

.ballot-details { margin: 4px 0 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.ballot-details .ballot-meta { margin: 0 0 6px; color: var(--text-muted); font-size: .92rem; }
.ballot-details .visibility-notice { margin: 10px 0 0; }
.ballot-locked + .ballot-details { border-top: 0; }

/* ==========================================================================
   Images: thumbnails, the full-size viewer, and the upload pickers
   ========================================================================== */

/* ---- Thumbnails (open the viewer) ---- */

.thumb-btn {
    flex: none;
    display: inline-block;
    width: 72px;
    height: 72px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: zoom-in;
    vertical-align: middle;
}
.thumb-btn img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-btn:hover { border-color: var(--primary); }
.thumb-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.thumb-btn.thumb-sm { width: 40px; height: 40px; border-radius: 6px; }
.thumb-btn.thumb-xs { width: 28px; height: 28px; margin-right: 8px; border-radius: 5px; }

.image-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }

/* Option thumbnails sit beside (never inside) each ballot control. */
.pool-row, .approval-row { display: flex; align-items: center; gap: 8px; }
.pool-row .pool-item, .approval-row .approval-item { flex: 1; min-width: 0; }
.vector-head .thumb-btn { align-self: center; margin-right: 2px; }
.rank-item .thumb-btn { margin-left: -2px; }
.bar-label { display: flex; align-items: center; min-width: 0; }

/* ---- Full-size viewer ---- */

html.viewer-open { overflow: hidden; }
.viewer {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgb(10 10 20 / 96%);
    color: #fff;
}
.viewer::backdrop { background: rgb(10 10 20 / 60%); }
.viewer-stage { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 56px 12px; }
.viewer-figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; touch-action: pan-y; }
.viewer-img { display: block; max-width: min(100%, 1600px); max-height: calc(100dvh - 150px); object-fit: contain; border-radius: 6px; background: #222; }
.viewer-caption { margin-top: 10px; max-width: 60ch; text-align: center; font-size: .95rem; color: #e8e8f0; }
.viewer-counter { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); margin: 0; font-size: .85rem; color: #c8c8d8; font-variant-numeric: tabular-nums; }
.viewer-btn {
    position: absolute;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / 14%);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.viewer-btn:hover { background: rgb(255 255 255 / 26%); }
.viewer-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.viewer-close { top: 10px; right: 10px; }
.viewer-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.viewer-next { right: 10px; top: 50%; transform: translateY(-50%); }
@media (max-width: 560px) {
    .viewer-prev, .viewer-next { top: auto; bottom: 14px; transform: none; }
}

/* ---- Details image picker (create form + organizer page) ---- */

.field-label { display: block; margin-bottom: 6px; font-weight: 600; }
.image-picker { margin-top: 12px; }
.image-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 10px; }
.image-tiles:empty { display: none; }
.image-tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.image-tile .thumb-btn { width: 100%; height: 96px; }
.image-tile .image-alt { min-height: 36px; padding: 6px 8px; font-size: .85rem; }
.image-remove, .option-image-remove {
    position: absolute;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.image-remove { top: 2px; right: 2px; }
.image-remove:hover, .option-image-remove:hover { border-color: var(--fail); color: var(--fail); }

.image-progress { display: none; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.image-progress > span { display: block; width: 0; height: 100%; background: var(--primary); transition: width .15s; }
.is-uploading .image-progress { display: block; }
.image-tile.is-uploading .thumb-btn { opacity: .5; }

/* ---- One image per option ---- */

.option-image { position: relative; flex: none; display: inline-flex; }
.option-image-pick {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    overflow: hidden;
    border: 1px dashed var(--text-muted);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}
.option-image-pick:hover { border-color: var(--primary); color: var(--primary); }
.option-image-pick img { display: none; width: 100%; height: 100%; object-fit: cover; }
.option-image-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.option-image.has-image .option-image-pick { border-style: solid; border-color: var(--border); }
.option-image.has-image .option-image-pick img { display: block; }
.option-image.has-image .option-image-icon { display: none; }
.option-image-remove { display: none; top: -8px; right: -8px; width: 22px; height: 22px; font-size: .85rem; }
.option-image.has-image .option-image-remove { display: grid; }
.option-image .image-progress { position: absolute; left: 4px; right: 4px; bottom: 4px; }
.option-image.is-uploading .option-image-pick { opacity: .7; }

.option-row { align-items: center; }
.option-image-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.option-image-list li { display: flex; align-items: center; gap: 12px; }
