:root {
    --white: #ffffff;
    --ink: #111111;
    --muted: #6b7280;
    --line: #e5e7eb;
    --soft: #f5f5f7;
    --blue: #2563eb;
    --red: #ff3b30;
    --green: #38d996;
    --yellow: #ffd93d;
    --pink: #ff9bce;
    --orange: #ffad33;
    --purple: #c4b5fd;
    --cyan: #67e8f9;
    --sans: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --baskerville: Baskerville, "Baskerville Old Face", "Libre Baskerville", "Iowan Old Style", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    background: var(--white);
    font-size: 20px;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background: var(--white);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--yellow);
}

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2 {
    font-weight: 800;
    letter-spacing: -0.05em;
}

h1 {
    margin-bottom: 0.8rem;
    font-size: clamp(2.7rem, 12vw, 3.9rem);
    line-height: 1;
}

h2 {
    margin-bottom: 0.25rem;
    font-size: 1.3rem;
    line-height: 1.15;
}

.title-image {
    display: block;
    width: clamp(230px, 80.5vw, 334px);
    height: auto;
    margin: -4px auto 0;
}

.question .intellectual {
    display: block;
    color: var(--red);
    font-family: var(--baskerville);
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.04em;
}

a {
    color: inherit;
    text-underline-offset: 3px;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.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;
}

.page-wrap {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    padding: 0 20px 40px;
    margin: 0 auto;
}

.flash-stack {
    display: grid;
    gap: 8px;
    padding-top: 16px;
}

.flash {
    padding: 10px 12px;
    margin: 0;
    background: var(--soft);
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.flash-success {
    background: #e2fbef;
}

.flash-info {
    background: #eaf1ff;
}

.flash-error {
    background: #ffe7e5;
}

.flash-warning {
    background: #fff5cc;
}

.lede {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert {
    padding: 10px 12px;
    margin-bottom: 16px;
    background: #ffe7e5;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Sign in */

.signin-hero {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(420px, 68vh, 560px);
}

.signin-hero__image {
    position: absolute;
    top: 0;
    z-index: 0;
    width: 50vw;
    height: clamp(420px, 68vh, 560px);
    background-position: center;
    background-size: cover;
}

.signin-hero__image--library {
    left: 0;
    background-image: url("signin-library.jpg");
}

.signin-hero__image--banana {
    left: 50vw;
    background-image: url("signin-banana.jpg");
}

.signin-hero__shade {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100vw;
    height: clamp(420px, 68vh, 560px);
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 58%),
        linear-gradient(180deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.58) 76%, #ffffff 100%);
}

.signin-hero__content {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 36px 20px 48px;
    text-align: center;
}

.signin-hero .question {
    margin: 0;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95), 0 0 12px rgba(255, 255, 255, 0.8);
}

.signin-hero .question-is {
    display: inline-block;
}

.js .signin-hero__image {
    opacity: 0;
    transition: opacity 500ms ease;
}

.js .signin-hero__image.is-ready {
    opacity: 1;
}

.js .signin-hero .question-is,
.js .signin-hero .title-image,
.js .signin-hero .intellectual,
.js .signin-hero + .guest-panel {
    opacity: 0;
}

.js .signin-hero.is-ready .question-is {
    animation: signin-arrive 420ms ease-out 500ms both;
}

.js .signin-hero.is-ready .title-image {
    animation: signin-blowup 650ms cubic-bezier(0.2, 0.8, 0.2, 1) 900ms both;
}

.js .signin-hero.is-ready .intellectual {
    animation: signin-arrive 480ms ease-out 1350ms both;
}

.signin-hero + .guest-panel {
    padding-top: 24px;
}

.js .signin-hero.is-ready + .guest-panel {
    animation: signin-arrive 560ms ease-out 1800ms both;
}

.guest-search-row {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.search {
    width: 100%;
}

.search input {
    width: 100%;
    padding: 10px 16px;
    color: var(--ink);
    background: var(--soft);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.85rem;
}

.search input::placeholder {
    color: var(--muted);
}

.search input:focus {
    background: var(--white);
    border-color: var(--ink);
    outline: none;
}

.guest-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 8px;
}

.guest-pick {
    margin: 0;
}

.guest-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 6px 2px 8px;
    text-align: center;
    background: transparent;
    border: 0;
    border-radius: 12px;
}

.guest-button:hover:not(:disabled),
.guest-button:focus-visible:not(:disabled) {
    background: var(--soft);
}

.avatar {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    color: var(--ink);
    background: var(--yellow);
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.guest-pick:nth-child(8n + 1) .avatar {
    background: #ff8c8c;
}

.guest-pick:nth-child(8n + 2) .avatar {
    background: var(--yellow);
}

.guest-pick:nth-child(8n + 3) .avatar {
    background: #7dc4ff;
}

.guest-pick:nth-child(8n + 4) .avatar {
    background: #8cf0c4;
}

.guest-pick:nth-child(8n + 5) .avatar {
    background: var(--pink);
}

.guest-pick:nth-child(8n + 6) .avatar {
    background: var(--purple);
}

.guest-pick:nth-child(8n + 7) .avatar {
    background: var(--orange);
}

.guest-pick:nth-child(8n) .avatar {
    background: var(--cyan);
}

.guest-name {
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.15;
}

.guest-status {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.guest-button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.guest-button:disabled .avatar {
    background: #d1d5db;
}

.guest-button:disabled .guest-name {
    text-decoration: line-through;
}

.empty-state {
    padding: 16px 0;
    color: var(--muted);
    text-align: center;
}

.guest-grid .empty-state {
    grid-column: 1 / -1;
}

.confirm-dialog {
    width: calc(100% - 40px);
    max-width: 400px;
    padding: 0;
    color: var(--ink);
    background: var(--white);
    border: 0;
    border-radius: 20px;
}

.confirm-dialog::backdrop {
    background: rgba(17, 17, 17, 0.52);
}

.confirm-dialog__body {
    padding: 24px 22px 22px;
}

.confirm-dialog h2 {
    margin-bottom: 12px;
    font-size: 1.35rem;
    line-height: 1.2;
}

.confirm-dialog__note {
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.confirm-dialog__actions {
    display: flex;
    gap: 8px;
}

.confirm-dialog__actions button {
    flex: 1;
    width: auto;
    padding: 12px 10px;
    margin: 0;
    border: 0;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.confirm-dialog__actions .secondary-button {
    color: var(--ink);
    background: var(--soft);
}

.confirm-dialog__actions .primary-button {
    color: var(--white);
    background: var(--ink);
}

.confirm-dialog__actions .primary-button:hover {
    background: var(--blue);
}

body:has(.confirm-dialog[open]) {
    overflow: hidden;
}

/* Vote */

.vote-body .page-wrap {
    max-width: none;
    padding: 0;
}

.vote-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 8px;
}

.vote-form {
    display: flex;
    flex: 1;
    min-height: 0;
}

.vote-choice-row {
    display: grid;
    flex: 1;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-height: 0;
}

.choice {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    color: var(--white);
    border: 0;
    border-radius: 14px;
    transition: filter 120ms ease;
}

.choice-yes {
    background: var(--blue);
}

.choice-no {
    background: var(--red);
}

.choice:hover {
    filter: brightness(1.08);
}

.choice:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: -6px;
}

.choice-label {
    color: var(--white);
    font-size: clamp(2.6rem, 14vw, 4.6rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
}

.comment-label {
    display: block;
    margin-bottom: 10px;
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.4;
}

.comment-box {
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.comment-box:focus-within {
    border-color: var(--ink);
}

.comment-input {
    display: block;
    width: 100%;
    min-height: 116px;
    padding: 14px 14px 6px;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: none;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

.comment-input::placeholder {
    color: var(--muted);
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 14px 10px;
}

.optional-tag {
    color: var(--muted);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.comment-count {
    color: var(--muted);
    font-size: 0.58rem;
    font-variant-numeric: tabular-nums;
}

.noscript-note {
    margin: 0;
    color: var(--red);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Confirmation */

.thanks-wrap {
    display: flex;
    justify-content: center;
    padding: 64px 0;
}

.thanks-panel {
    width: 100%;
    padding: 0;
    text-align: center;
}

.checkmark {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 22px;
    background: #dcfce9;
    border-radius: 50%;
}

.checkmark svg {
    width: 36px;
    height: 36px;
    fill: none;
    stroke: #15803d;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3.5;
}

.thanks-panel h1 {
    margin-bottom: 16px;
}

.thanks-panel .lede {
    max-width: 22rem;
    margin-right: auto;
    margin-left: auto;
}

.thanks-note {
    margin-top: 26px;
    text-align: left;
}

.fineprint {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 0.65rem;
}

/* Admin login */

.narrow-wrap {
    width: 100%;
    padding: 56px 0;
    text-align: center;
}

.admin-heading {
    margin-bottom: 24px;
}

.admin-panel {
    padding: 0;
    text-align: left;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.text-input {
    width: 100%;
    padding: 12px 14px;
    color: var(--ink);
    background: var(--soft);
    border: 1px solid transparent;
    border-radius: 10px;
}

.text-input:focus {
    background: var(--white);
    border-color: var(--ink);
    outline: none;
}

.primary-button {
    width: 100%;
    padding: 13px 18px;
    margin-top: 14px;
    color: var(--white);
    background: var(--ink);
    border: 0;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.primary-button:hover {
    background: var(--blue);
}

.back-link {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 0.7rem;
}

/* Admin navigation */

.admin-nav {
    display: flex;
    gap: 6px;
    padding-top: 20px;
}

.admin-nav a {
    padding: 7px 11px;
    color: var(--muted);
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-decoration: none;
    text-transform: uppercase;
}

.admin-nav a[aria-current="page"] {
    color: var(--ink);
    background: var(--soft);
}

/* Results */

.results-body .page-wrap {
    max-width: 1100px;
}

.results-screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: calc(100vh - 40px);
    min-height: calc(100dvh - 40px);
    padding: 20px 0 24px;
}

.results-score {
    display: grid;
    flex: 1;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    min-height: 220px;
}

.score {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 12px;
    color: var(--white);
    border-radius: 24px;
}

.score-yes {
    background: var(--blue);
}

.score-no {
    background: var(--red);
}

.score-label {
    font-size: clamp(0.8rem, 2.2vh, 1.1rem);
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.score-number {
    margin: 8px 0 4px;
    font-size: clamp(4.5rem, min(34vh, 22vw), 15rem);
    font-weight: 800;
    letter-spacing: -0.07em;
    line-height: 0.9;
}

.score-percent {
    font-size: clamp(0.9rem, 2.4vh, 1.4rem);
    font-weight: 700;
    opacity: 0.82;
}

.results-bottom {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-bar {
    display: flex;
    width: 100%;
    height: 22px;
    overflow: hidden;
    background: var(--soft);
    border-radius: 999px;
}

.bar-yes,
.bar-no {
    height: 100%;
    transition: width 500ms ease;
}

.bar-yes {
    background: var(--blue);
}

.bar-no {
    background: var(--red);
}

.results-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.62rem;
}

.connection {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 9px;
    margin-right: auto;
    color: var(--muted);
    background: var(--soft);
    border-radius: 999px;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.connection-dot {
    width: 7px;
    height: 7px;
    background: var(--muted);
    border-radius: 50%;
}

.connection[data-state="live"] {
    color: #047857;
    background: #e2fbef;
}

.connection[data-state="live"] .connection-dot {
    background: #10b981;
}

.connection[data-state="retrying"] {
    color: #b42318;
    background: #ffe7e5;
}

.connection[data-state="retrying"] .connection-dot {
    background: var(--red);
}

.meta-item strong {
    color: var(--ink);
    font-weight: 800;
}

@media (orientation: landscape) and (max-height: 600px) {
    .results-body .page-wrap {
        max-width: none;
        padding: 8px 12px;
    }

    .results-screen {
        min-height: calc(100vh - 16px);
        min-height: calc(100dvh - 16px);
        gap: 8px;
        padding: 0;
    }

    .results-body .admin-nav {
        display: none;
    }

    .results-score {
        gap: 8px;
        min-height: 0;
    }

    .score {
        padding: 8px;
        border-radius: 14px;
    }

    .score-label {
        font-size: 0.9rem;
    }

    .score-number {
        margin: 0;
        font-size: clamp(5rem, 36vh, 12rem);
    }

    .score-percent {
        font-size: 1rem;
    }

    .results-bottom {
        gap: 6px;
    }

    .result-bar {
        height: 14px;
    }

    .results-meta {
        font-size: 0.56rem;
    }

    .connection {
        padding: 3px 8px;
    }
}

/* Guest administration */

.guest-admin-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 0 24px;
    text-align: center;
}

.guest-admin-heading h1 {
    margin-bottom: 0;
    font-size: clamp(2.4rem, 11vw, 3.3rem);
}

.guest-admin-heading .lede {
    max-width: 24rem;
    margin-right: auto;
    margin-left: auto;
}

.guest-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--soft);
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.guest-summary strong {
    font-size: 1rem;
    font-weight: 800;
}

.summary-divider {
    width: 1px;
    height: 18px;
    background: var(--line);
}

.guest-admin-panel {
    padding: 0;
    margin-bottom: 24px;
}

.panel-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.panel-head p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.guest-table-wrap {
    width: 100%;
}

.guest-table,
.guest-table tbody {
    display: block;
    width: 100%;
}

.guest-table thead {
    display: none;
}

.guest-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.guest-row:last-child {
    border-bottom: 0;
}

.guest-table td {
    display: block;
    padding: 0;
    border: 0;
}

.guest-row td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.guest-row td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.guest-row td:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

.guest-table-name {
    font-size: 0.9rem;
    font-weight: 700;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-pill i {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

.status-voted {
    color: #047857;
    background: #e2fbef;
}

.status-open {
    color: var(--muted);
    background: var(--soft);
}

.status-time {
    margin-left: 6px;
    color: var(--muted);
    font-size: 0.58rem;
}

.action-column {
    width: auto;
    text-align: right;
}

.rescind-button {
    padding: 6px 10px;
    color: var(--white);
    background: var(--red);
    border: 0;
    border-radius: 999px;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.rescind-button:hover {
    background: #d92d20;
}

.action-dash {
    color: var(--muted);
    opacity: 0.5;
}

.table-empty {
    padding: 24px 0 !important;
    color: var(--muted);
    text-align: center;
}

.table-empty-search {
    padding-top: 16px;
    padding-bottom: 0;
}

@keyframes detail-in {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes signin-arrive {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes signin-blowup {
    from {
        opacity: 0;
        transform: scale(0.82);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (orientation: portrait) {
    .signin-hero .question {
        margin-top: 11rem;
    }

    .vote-choice-row {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .js .signin-hero__image {
        opacity: 1 !important;
        transition: none !important;
    }

    .signin-hero .question-is,
    .signin-hero .title-image,
    .signin-hero .intellectual,
    .signin-hero + .guest-panel {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }
}
