:root {
    color-scheme: light;
    --bg: #f3f0ea;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #5b6472;
    --line: #d9dde3;
    --brand: #176b87;
    --brand-dark: #0f5166;
    --accent: #d66b2d;
    --success: #177245;
    --error: #b42318;
    --shadow: 0 24px 80px rgba(23, 38, 52, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(23, 107, 135, 0.16), rgba(214, 107, 45, 0.12)),
        var(--bg);
}

button,
input {
    font: inherit;
}

a {
    color: var(--brand-dark);
    font-weight: 700;
}

.page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.panel,
.results-shell,
.admin-shell {
    width: min(100%, 860px);
    background: var(--panel);
    border: 1px solid rgba(31, 41, 51, 0.08);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(28px, 6vw, 64px);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0 0 26px;
    font-size: clamp(2.1rem, 8vw, 4.5rem);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin: 0 0 20px;
    font-size: 1.25rem;
    line-height: 1.2;
}

.vote-form {
    display: grid;
    gap: 14px;
}

.choice-button,
.primary-button,
.secondary-button,
.danger-button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.choice-button {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 68px;
    gap: 16px;
    align-items: center;
    width: 100%;
    min-height: 82px;
    padding: 16px 20px;
    color: var(--ink);
    text-align: left;
    background: #f8fafc;
    border: 1px solid var(--line);
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.choice-button:hover,
.choice-button:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 12px 30px rgba(23, 107, 135, 0.16);
    transform: translateY(-1px);
    outline: none;
}

.choice-button.selected {
    color: #fff;
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.choice-button.selected .choice-number,
.choice-option:has(input:checked) .choice-number {
    color: var(--brand-dark);
    background: #fff;
}

.choice-option {
    position: relative;
}

.choice-option input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.choice-option:has(input:checked) {
    color: #fff;
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.choice-number {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    color: #fff;
    background: var(--brand);
}

.choice-text {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.choice-text small {
    color: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 0.8;
}

.choice-image {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    justify-self: end;
    border: 3px solid #fff;
    box-shadow: 0 4px 14px rgba(31, 41, 51, 0.18);
    pointer-events: none;
}

.notice {
    margin: 0 0 18px;
    padding: 13px 16px;
    border-radius: 8px;
    font-weight: 700;
}

.notice.success {
    color: var(--success);
    background: rgba(23, 114, 69, 0.1);
}

.notice.error {
    color: var(--error);
    background: rgba(180, 35, 24, 0.1);
}

.notice.neutral {
    color: var(--brand-dark);
    background: rgba(23, 107, 135, 0.1);
}

.vote-complete {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 68px;
    gap: 8px 16px;
    align-items: center;
    margin-bottom: 10px;
    padding: 26px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.vote-complete .checkmark {
    grid-column: 1;
    grid-row: 1;
}

.vote-complete .choice-image {
    grid-column: 3;
    grid-row: 1;
}

.current-vote-text {
    grid-column: 2;
    display: grid;
    gap: 4px;
    min-width: 0;
}

.current-vote-text p {
    display: block;
    margin: 0;
    color: var(--muted);
}

.current-vote-text strong {
    display: block;
    font-size: 1.5rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.change-link,
.cancel-link {
    color: var(--brand-dark);
    font-weight: 800;
}

.change-link-row {
    margin: 0 0 18px;
}

.change-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.save-vote-button {
    width: 100%;
}

.checkmark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: #fff;
    background: var(--success);
    border-radius: 50%;
    font-size: 1.7rem;
    font-weight: 800;
}

.results-shell,
.admin-shell {
    padding: clamp(22px, 4vw, 42px);
}

.results-page {
    min-height: 100svh;
    padding: 0;
    place-items: stretch;
}

.results-page .results-shell {
    width: 100%;
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.results-header,
.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: start;
    margin-bottom: 28px;
}

.results-header h1,
.admin-header h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 4rem);
}

.total {
    min-width: 142px;
    padding: 18px;
    text-align: center;
    border-radius: 8px;
    color: #fff;
    background: var(--brand);
    font-weight: 800;
}

.total span {
    display: block;
    font-size: 2.2rem;
    line-height: 1;
}

.results-list {
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 18px;
    min-height: 0;
}

.result-row {
    display: grid;
    align-content: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: baseline;
    margin-bottom: 12px;
}

.result-label {
    font-size: clamp(1.4rem, 3.2vw, 3.2rem);
}

.result-stats {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-size: clamp(1.1rem, 2vw, 2rem);
    font-weight: 800;
}

.meter {
    height: clamp(22px, 4.5vh, 54px);
    overflow: hidden;
    border-radius: 999px;
    background: #e4e8ee;
}

.meter-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    transition: width 360ms ease;
}

.updated {
    margin: 20px 0 0;
    color: var(--muted);
    text-align: right;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 22px;
    align-items: start;
}

.admin-form {
    display: grid;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.compact-form {
    width: min(100%, 480px);
}

.admin-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.admin-form input {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.switch-field {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    color: var(--ink);
    cursor: pointer;
}

.switch-field small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.3;
}

.switch-field input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-control {
    position: relative;
    width: 58px;
    height: 32px;
    border-radius: 999px;
    background: #b8c0cc;
    transition: background 160ms ease;
}

.switch-control::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(31, 41, 51, 0.22);
    transition: transform 160ms ease;
}

.switch-field input:checked + .switch-control {
    background: var(--success);
}

.switch-field input:checked + .switch-control::after {
    transform: translateX(26px);
}

.switch-field input:focus-visible + .switch-control {
    outline: 3px solid rgba(23, 107, 135, 0.22);
    outline-offset: 3px;
}

.admin-form input:focus {
    border-color: var(--brand);
    outline: 3px solid rgba(23, 107, 135, 0.18);
}

.primary-button,
.secondary-button,
.danger-button {
    min-height: 46px;
    padding: 11px 16px;
}

.primary-button {
    color: #fff;
    background: var(--brand);
}

.primary-button:hover,
.primary-button:focus-visible {
    background: var(--brand-dark);
}

.secondary-button {
    color: var(--ink);
    background: #e4e8ee;
}

.danger-button {
    width: 100%;
    color: #fff;
    background: var(--error);
}

.stat-box {
    display: grid;
    gap: 6px;
    padding: 18px;
    color: #fff;
    border-radius: 8px;
    background: var(--brand-dark);
}

.stat-box span {
    font-weight: 700;
}

.stat-box strong {
    font-size: 2.5rem;
    line-height: 1;
}

.admin-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

@media (max-width: 720px) {
    .page {
        padding: 14px;
        place-items: stretch;
    }

    .panel,
    .results-shell,
    .admin-shell {
        align-self: center;
    }

    .results-header,
    .admin-header,
    .result-meta {
        display: grid;
    }

    .total {
        width: 100%;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .choice-button {
        grid-template-columns: 38px minmax(0, 1fr) 58px;
        min-height: 72px;
        padding: 14px;
    }

    .choice-number {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 520px) {
    .vote-page {
        min-height: 100svh;
        padding: 0;
        place-items: stretch;
    }

    .vote-page .panel {
        width: 100%;
        min-height: 100svh;
        align-self: stretch;
        display: grid;
        align-content: center;
        padding: max(22px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .vote-page h1 {
        margin-bottom: 20px;
        font-size: clamp(2rem, 13vw, 3.4rem);
        line-height: 0.96;
    }

    .vote-form {
        gap: 12px;
    }

    .change-actions {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .cancel-link {
        min-height: 44px;
        display: grid;
        place-items: center;
    }

    .choice-button {
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 13px;
        min-height: 76px;
        padding: 15px;
        font-size: 1.05rem;
        line-height: 1.18;
    }

    .vote-form .choice-button {
        grid-template-columns: 42px minmax(0, 1fr) 58px;
    }

    .choice-button:hover {
        transform: none;
    }

    .choice-number {
        width: 42px;
        height: 42px;
    }

    .choice-image {
        width: 58px;
        height: 58px;
        border-width: 2px;
    }

    .notice {
        margin-bottom: 14px;
    }

    .vote-complete {
        grid-template-columns: 42px minmax(0, 1fr) 58px;
        gap: 8px 12px;
        align-items: center;
        padding: 15px;
    }

    .vote-complete .checkmark {
        width: 42px;
        height: 42px;
        font-size: 1.45rem;
    }

    .current-vote-text strong {
        font-size: 1.2rem;
        line-height: 1.18;
    }
}
