:root {
    color-scheme: light;
    --bg: oklch(0.982 0.006 95);
    --surface: oklch(0.996 0.004 95);
    --panel: oklch(0.955 0.007 100);
    --panel-strong: oklch(0.925 0.01 105);
    --text: oklch(0.235 0.018 125);
    --muted: oklch(0.46 0.018 125);
    --faint: oklch(0.66 0.016 125);
    --line: oklch(0.86 0.012 110);
    --accent: oklch(0.48 0.13 170);
    --accent-hover: oklch(0.42 0.14 170);
    --accent-soft: oklch(0.91 0.045 170);
    --danger: oklch(0.52 0.16 28);
    --success: oklch(0.48 0.12 150);
    --warning: oklch(0.62 0.13 75);
    --shadow: 0 18px 45px oklch(0.38 0.018 125 / 0.12);
    --radius: 8px;
    --radius-small: 6px;
    --focus: 0 0 0 3px oklch(0.73 0.11 170 / 0.45);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 10;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-small);
    background: var(--text);
    color: var(--surface);
}

.skip-link:focus {
    top: 1rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.25rem;
    padding: 0.75rem clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid var(--line);
    background: oklch(0.982 0.006 95 / 0.94);
}

.brand,
.topnav {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.brand {
    min-width: 0;
    color: var(--text);
    font-weight: 750;
}

.brand-mark {
    display: inline-grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: var(--radius-small);
    background: var(--text);
    color: var(--surface);
    font-size: 0.82rem;
}

.topnav {
    flex-wrap: wrap;
    justify-content: flex-end;
    color: var(--muted);
    font-size: 0.95rem;
}

.topnav form {
    margin: 0;
}

.text-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent);
}

.text-button:hover {
    color: var(--accent-hover);
}

.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: clamp(1.5rem, 5vw, 4rem) 0 4rem;
}

.page-head,
.vote-head {
    max-width: 760px;
    margin-bottom: 1.8rem;
}

.vote-head {
    margin-bottom: 1.35rem;
}

.page-head.compact {
    margin-bottom: 1.25rem;
}

.eyebrow {
    margin: 0 0 0.55rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0.65rem;
    font-size: 2.05rem;
    line-height: 1.08;
}

h2 {
    margin-bottom: 0.8rem;
    font-size: 1.25rem;
    line-height: 1.2;
}

h3 {
    margin-bottom: 0.55rem;
    font-size: 1.05rem;
}

p {
    max-width: 72ch;
    color: var(--muted);
    line-height: 1.6;
}

code {
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: var(--panel);
    color: var(--text);
}

.back-link {
    display: inline-flex;
    margin-bottom: 1.2rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.flash {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.flash-success {
    border-color: oklch(0.78 0.09 150);
    background: oklch(0.94 0.035 150);
}

.flash-error {
    border-color: oklch(0.76 0.1 28);
    background: oklch(0.94 0.035 28);
}

.flash-info {
    border-color: oklch(0.78 0.07 220);
    background: oklch(0.94 0.025 220);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.65rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
}

.button:hover {
    border-color: var(--faint);
    color: var(--text);
}

.button-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: oklch(0.985 0.006 170);
}

.button-primary:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: oklch(0.985 0.006 170);
}

.button-danger {
    border-color: oklch(0.72 0.09 28);
    background: oklch(0.96 0.025 28);
    color: var(--danger);
}

.button-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.button.small {
    min-height: 2.1rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.88rem;
}

.campaign-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1rem;
}

.campaign-card,
.empty-state,
.auth-panel,
.work-panel,
.side-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.campaign-card {
    display: grid;
    gap: 1.2rem;
    align-content: space-between;
    min-height: 240px;
    padding: 1.2rem;
}

.meta-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.meta-row div,
.variant-stats div {
    min-width: 0;
}

dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

dd {
    margin: 0.2rem 0 0;
    color: var(--text);
    font-weight: 760;
}

.empty-state {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(1.5rem, 5vw, 3rem);
    text-align: center;
}

.empty-state.align-left {
    max-width: none;
    margin: 0;
    text-align: left;
}

.auth-panel {
    width: min(440px, 100%);
    margin: clamp(1rem, 7vw, 4rem) auto 0;
    padding: clamp(1.2rem, 4vw, 2rem);
}

.stack-form,
.grid-form {
    display: grid;
    gap: 1rem;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form .wide {
    grid-column: 1 / -1;
}

.autosave-status {
    align-self: center;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.autosave-status[data-state="saving"],
.autosave-status[data-state="dirty"] {
    color: var(--warning);
}

.autosave-status[data-state="saved"] {
    color: var(--success);
}

.autosave-status[data-state="error"] {
    color: var(--danger);
}

label {
    display: grid;
    gap: 0.4rem;
}

label > span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: oklch(0.99 0.004 95);
    color: var(--text);
    padding: 0.72rem 0.8rem;
}

textarea {
    resize: vertical;
}

input[type="file"] {
    padding: 0.65rem;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.check-line input {
    width: 1rem;
    height: 1rem;
}

.vote-form {
    margin-top: 1.4rem;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(1rem, 3vw, 1.75rem);
}

.choice-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 1rem;
    min-height: clamp(390px, 58vh, 680px);
    padding: clamp(0.85rem, 2.2vw, 1.15rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out;
}

.choice-card:hover,
.choice-card:focus-visible {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 22px 52px oklch(0.38 0.018 125 / 0.16);
}

.choice-card.is-submitting {
    opacity: 0.72;
    pointer-events: none;
}

.choice-image {
    display: grid;
    width: 100%;
    height: clamp(300px, 46vh, 500px);
    place-items: center;
    padding: clamp(1.25rem, 4vw, 3rem);
    border-radius: var(--radius-small);
    background: rgb(255 255 255);
}

.choice-image img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
}

.choice-title {
    align-self: end;
    min-height: 2.2rem;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 760;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.choice-grid-no-title .choice-card {
    align-content: center;
}

.finish-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.2rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--accent-soft);
}

.finish-band p {
    margin: 0.2rem 0 0;
}

.ranking-list {
    display: grid;
    gap: 0.75rem;
}

.rank-row {
    display: grid;
    grid-template-columns: 2.2rem 5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.rank-number {
    display: inline-grid;
    width: 2.1rem;
    height: 2.1rem;
    place-items: center;
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-weight: 760;
}

.rank-row img,
.variant-preview > img {
    width: 5rem;
    height: 3.75rem;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
}

.variant-preview {
    position: relative;
    display: inline-flex;
    width: 5rem;
    height: 3.75rem;
}

.variant-preview-large {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.75rem);
    z-index: 20;
    display: grid;
    width: min(28rem, 64vw);
    height: min(20rem, 46vw);
    place-items: center;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgb(255 255 255);
    box-shadow: 0 24px 70px oklch(0.38 0.018 125 / 0.22);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(0.35rem) scale(0.98);
    transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.variant-preview-large img {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: none;
    object-fit: contain;
}

.variant-preview:hover .variant-preview-large,
.variant-preview:focus-visible .variant-preview-large {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.rank-main h2 {
    margin: 0 0 0.15rem;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.rank-main p {
    margin: 0;
    font-size: 0.92rem;
}

.rank-score {
    display: grid;
    justify-items: end;
    min-width: 7rem;
}

.rank-score strong {
    font-size: 1.25rem;
}

.rank-score span {
    color: var(--muted);
    font-size: 0.88rem;
}

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

.admin-main {
    display: grid;
    gap: 1rem;
}

.side-panel,
.work-panel {
    padding: 1.1rem;
}

.side-panel {
    position: sticky;
    top: 5.25rem;
}

.side-note {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.section-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-line h2 {
    margin-bottom: 0;
}

.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.data-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.85rem 0.95rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 760;
    text-transform: uppercase;
}

.data-table td span {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.variant-list {
    display: grid;
    gap: 0.75rem;
}

.variant-row {
    display: grid;
    grid-template-columns: 2.2rem 5rem minmax(11rem, 1fr) minmax(13rem, 1fr) auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: oklch(0.99 0.004 95);
}

.variant-row-deleted {
    opacity: 0.68;
}

.variant-actions {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 0.75rem;
    margin: -0.35rem 0 0.55rem 7.75rem;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.variant-actions form {
    display: flex;
    align-items: end;
    gap: 0.65rem;
    margin: 0;
}

.variant-actions input[type="file"] {
    max-width: 19rem;
    background: var(--surface);
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 760;
}

.pill-muted {
    background: var(--panel-strong);
    color: var(--muted);
}

.variant-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    margin: 0;
}

@media (max-width: 900px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .side-panel {
        position: static;
    }

    .variant-row {
        grid-template-columns: 2.2rem 5rem minmax(0, 1fr);
    }

    .variant-actions {
        align-items: stretch;
        flex-direction: column;
        margin-left: 0;
    }

    .variant-actions form {
        align-items: stretch;
        flex-direction: column;
    }

    .variant-row .variant-stats,
    .variant-row .check-line,
    .variant-row .autosave-status,
    .variant-row .pill {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-shell {
        width: min(100% - 1rem, 1180px);
        padding-top: 1rem;
    }

    h1 {
        font-size: 1.65rem;
    }

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

    .choice-card {
        min-height: 260px;
    }

    .choice-image {
        min-height: 190px;
    }

    .finish-band,
    .section-line {
        align-items: stretch;
        flex-direction: column;
    }

    .rank-row {
        grid-template-columns: 2.2rem 4.2rem minmax(0, 1fr);
    }

    .rank-row img,
    .variant-preview,
    .variant-preview > img {
        width: 4.2rem;
        height: 3.2rem;
    }

    .rank-score {
        grid-column: 3;
        justify-items: start;
        min-width: 0;
    }

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

/* Rating-Info-Trigger (öffnet Erklär-Modal) */
.info-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.info-trigger:hover {
    color: var(--accent);
}

.info-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 999px;
    background: var(--panel-strong);
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: none;
    line-height: 1;
}

.info-trigger:hover .info-badge {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.info-trigger:focus-visible {
    outline: none;
    border-radius: var(--radius-small);
    box-shadow: var(--focus);
}

/* Teilnahme-Auswertung */
.participation-summary {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 1.1rem;
}

.day-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.day-bar-track {
    position: relative;
    flex: 1 1 auto;
    min-width: 60px;
    max-width: 240px;
    height: 0.55rem;
    background: var(--panel-strong);
    border-radius: 999px;
    overflow: hidden;
}

.day-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    height: 100%;
    min-width: 3px;
    background: var(--accent);
    border-radius: 999px;
}

.day-bar-value {
    color: var(--text);
    font-weight: 760;
    font-variant-numeric: tabular-nums;
}

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

/* Modal */
body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: oklch(0.235 0.018 125 / 0.5);
    backdrop-filter: blur(2px);
}

.modal-dialog {
    position: relative;
    width: min(560px, 100%);
    max-height: min(85vh, 760px);
    overflow-y: auto;
    padding: 1.6rem clamp(1.25rem, 4vw, 2rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-dialog:focus {
    outline: none;
}

.modal-dialog h2 {
    margin: 0.2rem 0 0.9rem;
}

.modal-dialog p {
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--panel-strong);
    color: var(--text);
}

.modal-close:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.modal-list {
    display: grid;
    gap: 0.55rem;
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    line-height: 1.55;
}

.modal-formula {
    display: block;
    margin-top: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 0.9rem;
}

.modal-example {
    margin: 0 0 1rem;
    padding: 0.9rem 1rem;
    background: var(--accent-soft);
    border-radius: var(--radius-small);
    line-height: 1.55;
}

.modal-example .modal-formula {
    background: var(--surface);
}

.modal-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.55;
}
