:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --on-accent: #ffffff;
}

* { box-sizing: border-box; }

body {
    /* Derived here (not in :root) so they follow the theme class on <body>. */
    --input-border: color-mix(in srgb, var(--border) 82%, var(--text) 18%);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
    margin: 0;
    font-family: var(--font, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    background: var(--page-bg, var(--bg));
    color: var(--text);
    color-scheme: var(--scheme, light);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 4rem;
}

/* Wide data pages (audit log): the header follows so the brand and menu stay aligned with the content. */
body.page-wide main,
body.page-wide .site-header-inner { max-width: 1280px; }

/* --- Top bar: brand on the left, account + language on the right --- */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.site-header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.site-header-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem 0.6rem;
    margin-left: auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-name span { color: var(--accent); }

.brand-text { line-height: 1.2; }

.brand-suffix {
    color: var(--muted);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 0;
    white-space: nowrap;
}

.brand-logo {
    display: block;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    transition: transform 0.2s ease;
}

.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }

.admin-nav {
    font-size: 0.85rem;
    color: var(--muted);
}

/* --- Header dropdowns: account menu + language menu --- */
.header-menu { position: relative; }

.header-menu-toggle {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 2.4rem;
    padding: 0 0.7rem 0 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lang-menu .header-menu-toggle { padding-left: 0.7rem; }

.header-menu-toggle::-webkit-details-marker { display: none; }

.header-menu-toggle:hover,
.header-menu[open] > .header-menu-toggle {
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
    border-color: var(--input-border);
}

.header-menu-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

.header-menu-caret {
    width: 0.45rem;
    height: 0.45rem;
    margin: -0.2rem 0.1rem 0 0.1rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.header-menu[open] .header-menu-caret { margin-top: 0.2rem; transform: rotate(-135deg); }

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.user-menu-name {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lang-globe { font-size: 1rem; line-height: 1; }

.header-menu-panel {
    position: absolute;
    right: 0;
    z-index: 50;
    min-width: 15rem;
    margin-top: 0.4rem;
    padding: 0.35rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(16, 24, 40, 0.12));
}

.lang-menu .header-menu-panel { min-width: 11rem; }

.header-menu-head {
    display: flex;
    flex-direction: column;
    padding: 0.45rem 0.65rem 0.55rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.35;
}

.header-menu-head span { color: var(--muted); }

.header-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    margin: 0;
    padding: 0.45rem 0.65rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    color: var(--text);
    background: none;
    border: none;
    border-radius: 6px;
    box-shadow: none;
    text-decoration: none;
    cursor: pointer;
}

.header-menu-item:hover,
.header-menu-item:focus-visible {
    background: color-mix(in srgb, var(--accent) 8%, var(--card));
    color: var(--text);
    text-decoration: none;
    outline: none;
}

.header-menu-item.is-current { font-weight: 700; }

.header-menu-item.is-current::after {
    content: "✓";
    margin-left: auto;
    color: var(--accent);
}

.header-menu-item .plan-lock { margin-left: auto; }

.header-menu-icon {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.lang-code {
    width: 1.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.03em;
}

.header-menu-sep {
    height: 1px;
    margin: 0.3rem 0.2rem;
    background: var(--border);
}

.header-menu-item:disabled,
.header-menu-item:disabled:hover { color: var(--muted); background: none; cursor: not-allowed; }

/* "+ Add new question": a primary button that only opens the ways of adding. */
.action-menu-toggle {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1rem 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--on-accent);
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: calc(8px * var(--radius-scale, 1));
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.action-menu-toggle::-webkit-details-marker { display: none; }

.action-menu-toggle:hover,
.action-menu[open] > .action-menu-toggle { background: var(--accent-dark); }

.action-menu-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

.action-menu-toggle .header-menu-caret { border-color: currentColor; }

.action-menu .header-menu-panel { min-width: 14rem; }

.impersonation-badge {
    display: inline-flex;
    align-items: center;
    height: 1.9rem;
    padding: 0 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 999px;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .user-menu-name { display: none; }
    .user-menu .header-menu-toggle { padding-right: 0.55rem; }
}

.site-header .admin-nav .link-button { font-size: 0.85rem; }

.inline-form { display: inline; }

.link-button {
    background: none;
    border: none;
    box-shadow: none;
    color: var(--accent);
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.link-button:hover { background: none; color: var(--accent-dark); text-decoration: underline; }

.delete-button {
    background: #dc2626;
    color: #fff;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    margin: 0;
}

.delete-button:hover { background: #b91c1c; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.section-head h2,
.section-head h1 { margin: 0.5rem 0; }

/* Collapsible section title (partials/section_toggle). */
.section-toggle {
    all: unset;
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    cursor: pointer;
    border-radius: 6px;
}

.section-toggle:focus-visible { outline: 2px solid var(--ring, var(--accent)); outline-offset: 2px; }

.section-toggle-icon {
    display: inline-block;
    font-size: 0.8em;
    transition: transform 0.15s ease;
}

.section-toggle[aria-expanded="true"] .section-toggle-icon { transform: rotate(90deg); }

.section-count { font-weight: 400; font-size: 0.85em; }

/* Placeholder row of a collapsed section: the whole row opens it. */
.section-collapsed-hint {
    display: block;
    width: 100%;
    margin: 0.5rem 0 0;
    padding: 0.7rem 1rem;
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font: inherit;
    text-align: center;
    cursor: pointer;
}

.section-collapsed-hint[hidden] { display: none; }

.section-collapsed-hint:hover {
    color: var(--text);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
}

.section-collapsed-hint-action { color: var(--accent); font-weight: 600; }

/* Poll topic kept on screen while scrolling (polls.show_topic). */
.topic-sticky {
    position: sticky;
    top: 0;
    z-index: 7;
    flex-wrap: nowrap;
    margin: 0 -1.25rem 0.75rem;
    padding: 0.25rem 1.25rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.topic-sticky h1 {
    font-size: 1.5rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.section-actions button { margin-right: 0; }

a.button {
    display: inline-block;
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid transparent;
    border-radius: calc(8px * var(--radius-scale, 1));
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

a.button:hover { background: var(--accent-dark); text-decoration: none; }

button.button-secondary,
a.button.button-secondary {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--input-border);
    font-size: 0.95rem;
    margin: 0;
}

button.button-secondary:hover,
a.button.button-secondary:hover {
    background: color-mix(in srgb, var(--text) 4%, var(--card));
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
    color: var(--text);
}

a.icon-button,
button.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    margin: 0;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: calc(8px * var(--radius-scale, 1));
}

a.button.icon-button {
    background: var(--card);
    border: 1px solid var(--input-border);
}

a.button.icon-button:hover {
    background: color-mix(in srgb, var(--accent) 8%, var(--card));
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border));
}

/* Pulsing "live" dot: votes have arrived (results icon / tab). */
.live-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: live-pulse 1.6s ease-out infinite;
}

@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70%, 100% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
}

a.icon-button { position: relative; }

/* Results / Edit switch on a poll's admin pages. */
.poll-nav {
    display: inline-flex;
    border: 1px solid var(--input-border);
    border-radius: calc(10px * var(--radius-scale, 1));
    overflow: hidden;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.poll-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.poll-nav a + a { border-left: 1px solid var(--input-border); }

.poll-nav a:hover {
    background: color-mix(in srgb, var(--accent) 7%, var(--card));
    text-decoration: none;
}

.poll-nav a.active {
    background: var(--accent);
    color: var(--on-accent);
}

.poll-nav .live-dot { top: 5px; right: 5px; }

button.delete-button.icon-button {
    background: var(--card);
    color: #dc2626;
    border: 1px solid color-mix(in srgb, #dc2626 35%, var(--input-border));
}

button.delete-button.icon-button:hover { background: #fef2f2; border-color: #dc2626; }

h1 { margin-top: 0; }

h1, h2, h3 {
    font-family: var(--heading-font, inherit);
    text-transform: var(--heading-transform, none);
    text-shadow: var(--heading-shadow, none);
    line-height: 1.25;
    letter-spacing: -0.015em;
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 600; }

h1::before { content: var(--title-icon, none); }

/* Decorative theme strip on top of the page (zero height without a theme). */
main::before {
    content: "";
    display: block;
    height: var(--strip-h, 0);
    margin-bottom: var(--strip-gap, 0);
    border-radius: 4px;
    background: var(--strip, none);
    border: var(--strip-border, none);
}

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

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale, 1));
    padding: 1.4rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-card);
}

.muted {
    color: var(--muted);
    font-size: 0.875rem;
}

.errors,
.notices {
    border: 1px solid;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.925rem;
}

.errors p,
.notices p { margin: 0.2rem 0; }

.errors {
    background: #fef2f2;
    border-color: #fecaca;
    border-left-color: #dc2626;
    color: #991b1b;
}

.notices {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left-color: #16a34a;
    color: #166534;
}

textarea {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    font-size: 0.95rem;
    font-weight: 400;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

.invite-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
}

.invite-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.invite-list li:last-child { border-bottom: none; }

.invite-actions {
    display: inline-flex;
    gap: 0.4rem;
    margin-left: 0.5rem;
}

.invite-actions button {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    margin: 0;
}

form label {
    display: block;
    margin-bottom: 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
input[type="datetime-local"],
.gdpr-settings input[type="number"] {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    font-size: 0.95rem;
    font-weight: 400;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="datetime-local"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

button:focus-visible,
a.button:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* --- Auth pages (login, signup, password): one centered narrow card --- */
.auth-page {
    max-width: 420px;
    margin: 1.5rem auto 0;
}

.auth-back {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.auth-card { padding: 2rem 2rem 1.5rem; }

.auth-head {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-head h1 { margin: 0; font-size: 1.6rem; }
.auth-head p { margin: 0.4rem 0 0; }

.auth-form label { margin-bottom: 1rem; }

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    margin-bottom: 0;
    font-size: 1rem;
    padding: 0.65rem 0.8rem;
}

.auth-form .auth-hint {
    display: block;
    margin-top: 0.35rem;
    font-weight: 400;
}

.auth-form .checkbox-label {
    align-items: flex-start;
    line-height: 1.4;
}

.auth-form .checkbox-label input { margin-top: 0.2rem; flex-shrink: 0; }

.auth-form button[type="submit"] {
    display: block;
    width: 100%;
    margin: 0.5rem 0 0;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
}

.auth-fieldset {
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

.auth-fieldset:disabled label,
.auth-fieldset:disabled button { opacity: 0.55; }
.auth-fieldset:disabled button { cursor: not-allowed; }
.auth-fieldset:disabled button:hover { background: var(--accent); }

.auth-notice {
    margin-bottom: 1.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 7%, var(--card));
    font-size: 0.925rem;
}

.auth-notice p { margin: 0.3rem 0 0; }

.auth-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.9rem;
}

.auth-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.15rem;
}

.auth-footer p { margin: 0; }

@media (max-width: 480px) {
    .auth-page { margin-top: 0.25rem; }
    .auth-card { padding: 1.5rem 1.15rem 1.15rem; }
    .auth-head h1 { font-size: 1.4rem; }
}

input[readonly] {
    background: color-mix(in srgb, var(--text) 6%, var(--card));
    color: var(--muted);
}

.form-card {
    max-width: 480px;
}

.form-card .form-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
}

.form-card .form-actions button {
    margin: 0;
}

.rename-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    max-width: 480px;
}

.rename-form input {
    margin: 0;
}

.rename-form button {
    margin: 0;
    white-space: nowrap;
}

.invite-table td .inline-form {
    display: inline-block;
    margin-right: 0.25rem;
}

.invite-table td.actions-cell {
    white-space: nowrap;
}

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

select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    font-size: 0.95rem;
    font-weight: 400;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 0 0 0.85rem;
}

.method-box {
    background: color-mix(in srgb, var(--text) 2%, var(--card));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem 1rem;
}

.method-box legend {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0.1rem 0.6rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.zip-box {
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
    border-color: color-mix(in srgb, var(--accent) 35%, var(--card));
}

.or-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.or-divider::before,
.or-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

button {
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid transparent;
    border-radius: calc(8px * var(--radius-scale, 1));
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    margin-right: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover { background: var(--accent-dark); }

button#add-option,
button#add-batch,
button.add-dashed {
    background: var(--card);
    color: var(--accent);
    border: 1px dashed color-mix(in srgb, var(--accent) 60%, var(--card));
    box-shadow: none;
    margin-top: 0.5rem;
}

button#add-option:hover,
button#add-batch:hover,
button.add-dashed:hover { background: color-mix(in srgb, var(--accent) 6%, var(--card)); }

.option-add-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.poll-list {
    list-style: none;
    padding: 0;
}

.poll-list li {
    position: relative;
    margin-bottom: 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.poll-list li:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

/* Stretch the poll link over the whole card so the card itself is clickable. */
.poll-list li a.poll-link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.poll-list li a.poll-link {
    display: block;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.poll-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.poll-card-info { min-width: 0; }

/* Above the stretched card link. */
.poll-card-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.poll-card-actions .inline-form { margin: 0; }

.template-grid {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: 1rem;
}

.template-card {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.template-card h2 { margin: 0 0 0.25rem; font-size: 1.15rem; }

.template-card .template-type { margin: 0 0 0.5rem; font-size: 0.85rem; }

.template-card form { margin-top: auto; }

.template-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-actions button { white-space: nowrap; }

.option {
    display: block;
    font-weight: 400;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.option:last-of-type { border-bottom: none; }

.option-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.option-row:last-child { border-bottom: none; }

.existing-option-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.existing-option-row input[type="text"] {
    flex: 1;
    margin: 0;
}

.new-option-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.new-option-row input[type="text"] {
    flex: 1;
    margin: 0;
}

.existing-option-row .muted { white-space: nowrap; }

/* --- Question type dependent form fields --- */
.poll-form[data-poll-type="tokens"] .quiz-only,
.poll-form:not([data-poll-type="tokens"]) .ranking-only {
    display: none !important;
}

.quiz-option-fields {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.existing-option-row:has(.quiz-option-fields),
.new-option-row:has(.quiz-option-fields) {
    flex-wrap: wrap;
}

.existing-option-row input[type="text"],
.new-option-row input[type="text"] {
    min-width: 10rem;
}

form label.correct-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    font-weight: 400;
    font-size: 0.875rem;
    cursor: pointer;
}

.points-input {
    width: 4.5rem;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

/* --- Quiz 'match' pair editor: one row per pair + distractor list --- */
.match-editor .table-wrap { margin: 0.5rem 0 0; background: var(--card); }

.match-pairs {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.match-pairs th,
.match-pairs td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.match-pairs th {
    background: color-mix(in srgb, var(--text) 3%, var(--card));
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.match-pairs tbody tr:last-child td { border-bottom: none; }

.match-pairs .match-arrow {
    width: 1.5rem;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
    color: var(--muted);
    font-size: 1.1rem;
}

.match-pairs .match-points { width: 5.5rem; }

.match-pairs .match-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.match-pairs .match-actions .muted { margin-right: 0.4rem; }

.match-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.match-item input[type="text"] {
    flex: 1;
    min-width: 6rem;
    height: 2.4rem;
    margin: 0;
}

.match-editor .points-input { height: 2.4rem; }

.match-pairs .match-points .muted { display: none; }

.match-item .edit-thumb {
    display: block;
    width: 2.4rem;
    height: 2.4rem;
    object-fit: cover;
    margin: 0;
    border: 1px solid var(--border);
}

.match-thumb {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.match-thumb[hidden] { display: none; }

.match-thumb-media { display: flex; }

button.match-image-remove {
    position: absolute;
    top: -0.4rem;
    right: -0.4rem;
    width: 1.1rem;
    height: 1.1rem;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    font-size: 0.6rem;
    line-height: 1;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--input-border);
    box-shadow: var(--shadow-sm);
}

button.match-image-remove:hover { background: #fef2f2; border-color: #dc2626; }

.match-item button.icon-button { flex-shrink: 0; }

.match-distractor-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.match-distractor-row:last-child { border-bottom: none; }

.match-distractor-row .match-item { flex: 1; }

@media (max-width: 640px) {
    .match-pairs thead { display: none; }

    .match-pairs,
    .match-pairs tbody,
    .match-pairs tr,
    .match-pairs td { display: block; width: 100%; }

    .match-pairs tr {
        position: relative;
        padding: 0.6rem 3.6rem 0.6rem 0.6rem;
        border-bottom: 1px solid var(--border);
    }

    .match-pairs tbody tr:last-child { border-bottom: none; }

    .match-pairs td,
    .match-pairs tbody tr:last-child td { padding: 0; border: none; }

    .match-pairs td.match-arrow {
        width: auto;
        padding: 0.15rem 0 0.15rem 0.6rem;
        font-size: 0;
    }

    .match-pairs td.match-arrow::before { content: "↓"; font-size: 1rem; }

    .match-pairs td.match-points {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        width: auto;
        margin-top: 0.4rem;
    }

    .match-pairs td.match-points::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.8rem;
    }

    .match-pairs td.match-actions {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        width: auto;
    }

    .match-pairs td.match-actions .muted { display: none; }
}

/* --- Schedule (time slot) questions: editor rows, voter slots, helper calendar / timeline, results --- */
:root {
    --sched-yes: #16a34a;
    --sched-maybe: #d97706;
    --sched-no: #64748b;
}

.schedule-option-fields {
    display: grid;
    grid-template-columns: minmax(9.5rem, 1.4fr) minmax(6.5rem, 1fr) auto minmax(6.5rem, 1fr) 5.5rem;
    align-items: end;
    gap: 0 0.5rem;
    flex: 1;
    min-width: 0;
}

form label.schedule-field {
    margin: 0;
    min-width: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.schedule-field-caption {
    display: block;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.schedule-field input {
    display: block;
    width: 100%;
    height: 2.4rem;
    margin: 0;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    box-shadow: var(--shadow-sm);
}

.schedule-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.schedule-field-sep {
    line-height: 2.4rem;
    color: var(--muted);
}

.schedule-all-day-badge {
    align-self: end;
    justify-self: start;
    margin-bottom: 0.45rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, var(--card));
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    visibility: hidden;
}

.schedule-option-fields.is-all-day .schedule-all-day-badge { visibility: visible; }

.schedule-option-fields.is-all-day .schedule-field-end,
.schedule-option-fields.is-all-day .schedule-field-sep { opacity: 0.45; }

.option-row:has(.schedule-option-fields) { align-items: flex-end; }

/* Column captions only above the first row of each list. */
.option-row:not(:first-of-type) .schedule-field-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.poll-form[data-poll-type="schedule"] .options-label-hint { display: none; }

.schedule-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 0.75rem 0 0.25rem;
}

.schedule-progress {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.schedule-progress.is-complete { color: var(--sched-yes); }

.schedule-progress.is-complete::before { content: "✓ "; }

button.schedule-none-button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.schedule-day {
    margin-top: 0.85rem;
    border-radius: calc(10px * var(--radius-scale, 1));
}

.schedule-day.is-flash { animation: schedule-flash 1.4s ease; }

@keyframes schedule-flash {
    0%, 45% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
    100% { box-shadow: 0 0 0 4px transparent; }
}

.schedule-day-label {
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
    padding: 0.5rem 0.55rem 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: calc(10px * var(--radius-scale, 1));
    background: var(--card);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.schedule-slot[data-state="yes"] { border-left-color: var(--sched-yes); background: color-mix(in srgb, var(--sched-yes) 6%, var(--card)); }
.schedule-slot[data-state="maybe"] { border-left-color: var(--sched-maybe); background: color-mix(in srgb, var(--sched-maybe) 6%, var(--card)); }
.schedule-slot[data-state="no"] { border-left-color: var(--sched-no); background: color-mix(in srgb, var(--sched-no) 5%, var(--card)); }

.schedule-slot-time {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.schedule-choices {
    display: inline-flex;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--input-border);
    border-radius: 999px;
    background: var(--card);
}

form label.schedule-choice,
.schedule-choice {
    position: relative;
    display: flex;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

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

.schedule-choice-face {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.45rem 0.85rem;
    color: var(--muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.schedule-choice + .schedule-choice .schedule-choice-face { border-left: 1px solid var(--input-border); }

.schedule-choice:hover .schedule-choice-face {
    background: color-mix(in srgb, var(--text) 5%, var(--card));
    color: var(--text);
}

.schedule-choice input:focus-visible + .schedule-choice-face { box-shadow: inset 0 0 0 2px var(--accent); }

.schedule-choice-yes input:checked + .schedule-choice-face { background: var(--sched-yes); color: #fff; }
.schedule-choice-maybe input:checked + .schedule-choice-face { background: var(--sched-maybe); color: #fff; }
.schedule-choice-no input:checked + .schedule-choice-face { background: var(--sched-no); color: #fff; }

/* Helper calendar (month grids) and timeline */
.schedule-calendar,
.schedule-timeline {
    margin: 0.5rem 0 0.25rem;
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale, 1));
    background: color-mix(in srgb, var(--text) 2%, var(--card));
}

.schedule-calendar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 19rem));
    justify-content: start;
    gap: 0.85rem 2rem;
    padding: 0.85rem 1rem 1rem;
}

.cal-month-title {
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    font-weight: 700;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-wd {
    padding-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
}

.cal-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 2.3rem;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.cal-past { opacity: 0.5; }

.cal-today .cal-num {
    color: var(--text);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 2px;
}

button.cal-day,
button.tl-point {
    margin: 0;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--card));
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: none;
    cursor: pointer;
}

button.cal-day:hover,
button.tl-point:hover { background: color-mix(in srgb, var(--accent) 18%, var(--card)); }

.cal-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-width: 90%;
}

.cal-dot {
    width: 7px;
    height: 7px;
    border: 1.5px solid color-mix(in srgb, var(--accent) 60%, var(--border));
    border-radius: 50%;
    background: var(--card);
}

.cal-dot[data-state="yes"] { border-color: var(--sched-yes); background: var(--sched-yes); }
.cal-dot[data-state="maybe"] { border-color: var(--sched-maybe); background: var(--sched-maybe); }
.cal-dot[data-state="no"] { border-color: var(--sched-no); background: var(--sched-no); }

.is-results button.cal-day,
.is-results button.tl-point {
    border-color: color-mix(in srgb, var(--sched-yes) calc(20% + var(--heat, 0) * 60%), var(--border));
    background: color-mix(in srgb, var(--sched-yes) calc(var(--heat, 0) * 45%), var(--card));
}

.is-results .cal-dot {
    border-color: var(--sched-yes);
    background: color-mix(in srgb, var(--sched-yes) calc(var(--heat, 0) * 100%), var(--card));
}

.cal-best::after,
.cal-final::after {
    position: absolute;
    top: -0.45rem;
    right: -0.35rem;
    font-size: 0.7rem;
    line-height: 1;
}

.cal-best::after { content: "⭐"; }
.cal-final::after { content: "📌"; }

.schedule-timeline { padding: 1.9rem 1.5rem 1.7rem; }

.tl-track {
    position: relative;
    height: 2.4rem;
}

.tl-line {
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: 3px;
    border-radius: 3px;
    background: var(--border);
    transform: translateY(-50%);
}

.tl-tick {
    position: absolute;
    top: 50%;
    width: 1px;
    height: 1.4rem;
    background: color-mix(in srgb, var(--text) 25%, var(--border));
    transform: translate(-50%, -50%);
}

.tl-tick-label {
    position: absolute;
    bottom: calc(100% + 0.2rem);
    left: 0;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

button.tl-point {
    position: absolute;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 1.3rem;
    padding: 0.3rem 0.25rem;
    border-radius: 999px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
    transform: translate(-50%, -50%);
}

button.tl-point:hover { z-index: 2; }

.tl-point .cal-dots { flex-direction: column; }

.tl-point-label {
    position: absolute;
    top: calc(100% + 0.25rem);
    color: var(--muted);
    font-size: 0.68rem;
}

.tl-point.cal-best::after,
.tl-point.cal-final::after { top: -0.7rem; right: -0.5rem; }

/* Results: banner, slot rows, finalize overlay, participant matrix */
.date-tile {
    display: inline-flex;
    flex-direction: column;
    flex-shrink: 0;
    align-items: center;
    width: 4.2rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
    line-height: 1.15;
    text-align: center;
}

.date-tile-month {
    width: 100%;
    padding: 0.15rem 0;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.date-tile-day {
    padding-top: 0.15rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.date-tile-weekday {
    padding-bottom: 0.3rem;
    color: var(--muted);
    font-size: 0.64rem;
}

.schedule-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 0.5rem 0 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale, 1));
    background: var(--card);
}

.schedule-banner.is-final {
    border-color: color-mix(in srgb, var(--sched-yes) 45%, var(--border));
    background: color-mix(in srgb, var(--sched-yes) 7%, var(--card));
}

.schedule-banner.is-suggested {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
}

.schedule-banner-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 12rem;
}

.schedule-banner-kicker {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.schedule-banner-when { font-size: 1.05rem; }

.schedule-banner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.schedule-banner-actions .inline-form,
.schedule-banner-actions button,
.schedule-banner-actions .button { margin: 0; }

.final-slots .schedule-banner:last-child { margin-bottom: 0; }

.schedule-result-row {
    display: grid;
    grid-template-columns: minmax(8rem, 12rem) minmax(6rem, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale, 1));
    background: var(--card);
}

.schedule-result-row.has-action { grid-template-columns: minmax(8rem, 12rem) minmax(6rem, 1fr) auto 9.5rem; }

.schedule-result-row.is-best { border-color: color-mix(in srgb, #f59e0b 60%, var(--border)); }

.schedule-result-row.is-final {
    border-color: var(--sched-yes);
    background: color-mix(in srgb, var(--sched-yes) 6%, var(--card));
}

.schedule-result-row .schedule-slot-time {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.schedule-badge {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.schedule-badge.is-best { background: #fef3c7; color: #92400e; }
.schedule-badge.is-final { background: #dcfce7; color: #166534; }

.schedule-place {
    min-width: 1.6rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
}

.schedule-ranking-hint { margin: 0 0 0.5rem; }

.schedule-bar {
    display: flex;
    height: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--text) 7%, var(--card)) 0 4px, var(--card) 4px 8px);
}

.schedule-bar-yes { background: var(--sched-yes); }
.schedule-bar-maybe { background: var(--sched-maybe); }
.schedule-bar-no { background: color-mix(in srgb, var(--sched-no) 45%, var(--card)); }

.schedule-counts {
    display: inline-flex;
    gap: 0.65rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.schedule-count { font-weight: 700; }
.schedule-count-yes { color: var(--sched-yes); }
.schedule-count-maybe { color: #b45309; }
.schedule-count-no { color: var(--sched-no); }
.schedule-count-none { color: var(--muted); }

.schedule-result-action { justify-self: end; }

button.schedule-finalize-button {
    margin: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.schedule-finalize-slot {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin: 0.25rem 0 0.85rem;
}

.schedule-finalize-names {
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.schedule-finalize-names details {
    padding: 0.45rem 0;
    border-top: 1px solid var(--border);
}

.schedule-finalize-names summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.schedule-finalize-names p {
    margin: 0.3rem 0 0;
    font-size: 0.875rem;
}

.schedule-matrix-title {
    margin: 1.25rem 0 0.25rem;
    font-size: 0.95rem;
}

.schedule-matrix-wrap { margin-top: 0.5rem; }

.schedule-matrix {
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.schedule-matrix th,
.schedule-matrix td {
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    text-align: center;
    white-space: nowrap;
}

.schedule-matrix thead th {
    background: color-mix(in srgb, var(--text) 3%, var(--card));
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.schedule-matrix-day {
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.schedule-matrix .day-start { border-left: 1px solid var(--border); }

.schedule-matrix .schedule-matrix-name {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 1%;
    border-right: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    text-align: left;
}

.schedule-matrix thead .schedule-matrix-name { z-index: 2; }

.schedule-matrix .is-best { background: color-mix(in srgb, #f59e0b 9%, var(--card)); }
.schedule-matrix .is-final { background: color-mix(in srgb, var(--sched-yes) 10%, var(--card)); }

.schedule-matrix tfoot th,
.schedule-matrix tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
}

.schedule-matrix tfoot .schedule-count { display: block; font-size: 0.78rem; }

.schedule-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
}

.schedule-cell-yes { background: color-mix(in srgb, var(--sched-yes) 16%, var(--card)); color: var(--sched-yes); }
.schedule-cell-maybe { background: color-mix(in srgb, var(--sched-maybe) 16%, var(--card)); color: #b45309; }
.schedule-cell-no { background: color-mix(in srgb, var(--sched-no) 12%, var(--card)); color: var(--sched-no); }
.schedule-cell-none { color: var(--muted); }

@media (max-width: 600px) {
    .schedule-option-fields { grid-template-columns: 1fr 1fr; gap: 0.4rem 0.5rem; }

    .schedule-field-date { grid-column: 1 / -1; }

    .schedule-field-sep { display: none; }

    .schedule-slot { flex-wrap: wrap; }

    .schedule-choices { width: 100%; }

    .schedule-choice { flex: 1; }

    .schedule-result-row,
    .schedule-result-row.has-action { grid-template-columns: 1fr auto; }

    .schedule-result-row .schedule-bar { grid-column: 1 / -1; grid-row: 2; }

    .schedule-result-action { grid-column: 1 / -1; justify-self: stretch; }

    .schedule-result-action button { width: 100%; }
}

.points-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 12%, var(--card));
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.result-card.correct {
    border-color: #16a34a;
    background: linear-gradient(135deg, color-mix(in srgb, #16a34a 12%, var(--card)), var(--card));
}

/* --- Multi-question polls --- */
.question-block + .question-block,
.question-results + .question-results {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--border);
}

.question-heading {
    margin: 0 0 0.5rem;
}

.question-image {
    display: block;
    max-width: 100%;
    max-height: 50vh;
    width: auto;
    height: auto;
    margin: 0.25rem 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale, 1));
    cursor: zoom-in;
}

.question-image-field {
    margin-bottom: 0.75rem;
}

.question-image-current {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.question-image-current[hidden] { display: none; }

.question-image-preview {
    max-width: 240px;
    max-height: 160px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.question-results .result-list {
    margin-top: 0.5rem;
}

.question-table details summary {
    cursor: pointer;
    color: var(--accent);
}

.question-details {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.875rem;
}

.votes-detail-question {
    margin: 0.6rem 0 0.2rem;
    font-weight: 600;
}

.edit-thumb {
    max-width: 60px;
    max-height: 60px;
    border-radius: 6px;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.edit-link {
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.image-label {
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--muted);
}

.image-label input[type="file"] {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

/* --- Picture source: upload a file or paste a link (partials/media_source) --- */
.media-source {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin: 0.25rem 0 0.5rem;
}

.media-source-caption { font-weight: 600; }

.media-source-tabs {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 4%, var(--card));
}

button.media-source-tab {
    margin: 0;
    padding: 0.3rem 0.95rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    box-shadow: none;
}

button.media-source-tab:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }

button.media-source-tab[aria-pressed="true"] {
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.media-source-pane { width: 100%; }

.media-source-pane[hidden] { display: none; }

.media-source-pane input[type="file"] { font-size: 0.875rem; margin: 0; }

.media-source-link {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 34rem;
}

.media-source-link input[type="url"] { flex: 1; min-width: 0; margin: 0; }

.media-source-link button { margin: 0; flex-shrink: 0; }

.media-source-hint { display: block; margin-top: 0.3rem; font-size: 0.8rem; }

/* Editor thumbnails of a linked video: its thumbnail (or a placeholder) with a small ▶ badge. */
.media-thumb {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
    line-height: 0;
}

.media-thumb .media-video-play { width: 1.5rem; height: 1.5rem; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }

.media-thumb .media-video-play::after { border-width: 0.3rem 0 0.3rem 0.5rem; }

.option-row > .media-thumb { margin-right: 0.5rem; }

.option-row > .media-thumb .edit-thumb { margin-right: 0; }

.edit-thumb.media-video-placeholder { display: block; width: 60px; border-radius: 6px; }

.match-item .edit-thumb.media-video-placeholder { width: 2.4rem; }

.question-image-preview.media-video-placeholder { width: 240px; border-radius: 6px; }

.question-image-current .media-thumb .media-video-play { width: 2.6rem; height: 2.6rem; }

.question-image-current .media-thumb .media-video-play::after { border-width: 0.5rem 0 0.5rem 0.8rem; }

.zip-label {
    display: block;
    margin: 0.5rem 0 0.75rem;
    font-weight: 600;
}

.zip-label .muted {
    display: block;
    font-weight: 400;
}

.zip-label input[type="file"] {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.option-image {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 0.4rem;
}

/* --- Vote cards --- */
.vote-hint {
    font-weight: 600;
    color: var(--accent);
}

.vote-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.vote-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 3px solid var(--border);
    border-radius: calc(14px * var(--radius-scale, 1));
    overflow: hidden;
    cursor: pointer;
    background: var(--card);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    font-weight: 400;
    margin-bottom: 0;
}

.vote-card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--card));
}

.vote-card input[type="radio"],
.vote-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.vote-card:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent), 0 10px 24px rgba(0, 0, 0, 0.12);
}

.vote-image {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
    background: color-mix(in srgb, var(--text) 3%, transparent);
    display: block;
}

.vote-caption {
    padding: 0.6rem 0.75rem;
    font-weight: 600;
    text-align: center;
    min-height: 1.5rem;
}

.vote-check {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.vote-chosen {
    display: none;
    background: var(--accent);
    color: var(--on-accent);
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.35rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* --- Pagination --- */
.page-hidden { display: none !important; }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 1rem;
}

.pager button {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    margin: 0;
    min-width: 2.4rem;
}

.pager button:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 12%, var(--card));
    border-color: var(--accent);
}

.pager button:disabled {
    color: var(--muted);
    cursor: default;
    opacity: 0.5;
}

.pager button.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
    opacity: 1;
    cursor: default;
}

.pager-ellipsis {
    color: var(--muted);
    padding: 0 0.2rem;
}

.pager-status {
    text-align: center;
    margin: 0.4rem 0 0;
}

.vote-card:has(input:checked) .vote-check { display: flex; }
.vote-card:has(input:checked) .vote-chosen { display: block; }

.vote-submit {
    display: block;
    width: 100%;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0.8rem;
    border-radius: calc(10px * var(--radius-scale, 1));
}

.vote-submit::before { content: var(--submit-icon, none); }

.vote-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Token voting --- */
.token-bank {
    position: sticky;
    top: calc(var(--topic-header-h, 0px) + 0.5rem);
    z-index: 6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.75rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    border: 2px dashed var(--accent);
    border-radius: calc(12px * var(--radius-scale, 1));
    background: var(--card);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.token-bank-label {
    font-weight: 700;
}

.token-bank-icons {
    font-size: 1.35rem;
    letter-spacing: 0.15rem;
    line-height: 1;
}

.token-bank-icons .token-spent {
    opacity: 0.25;
    filter: grayscale(1);
}

.token-bank-text {
    color: var(--muted);
    font-size: 0.95rem;
}

.token-bank.token-bank-done {
    border-style: solid;
    border-color: #16a34a;
}

.token-bank.token-bank-done .token-bank-text {
    color: #16a34a;
    font-weight: 700;
}

.token-chips {
    min-height: 1.7rem;
    padding: 0 0.4rem 0.15rem;
    text-align: center;
    font-size: 1.3rem;
    letter-spacing: 0.12rem;
    line-height: 1.3;
}

.token-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding: 0.55rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--text) 3%, var(--card));
}

.token-stepper button {
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}

button.token-minus {
    background: var(--card);
    color: #b91c1c;
    border: 2px solid #fecaca;
}

button.token-minus:hover:not(:disabled) {
    background: #fee2e2;
}

button.token-plus {
    background: var(--accent);
    color: var(--on-accent);
    border: 2px solid var(--accent);
}

.token-stepper button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

input.token-count {
    width: 3.2rem;
    margin: 0;
    padding: 0.2rem;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 800;
    -moz-appearance: textfield;
    appearance: textfield;
}

input.token-count::-webkit-outer-spin-button,
input.token-count::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.vote-card.has-tokens {
    border-color: var(--accent);
    background: color-mix(in srgb, #22c55e 18%, var(--card));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent), 0 10px 24px rgba(0, 0, 0, 0.12);
}

.vote-card.has-tokens .token-stepper {
    background: color-mix(in srgb, #22c55e 32%, var(--card));
    border-top-color: color-mix(in srgb, #22c55e 50%, var(--card));
}

/* --- Ranked results --- */
.result-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-card {
    display: grid;
    grid-template-columns: 3rem 96px 1fr auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--border);
    border-radius: calc(12px * var(--radius-scale, 1));
    background: var(--card);
}

.result-card:not(:has(img)) {
    grid-template-columns: 3rem 1fr auto;
}

/* Live, interim and survey results list the options without a rank badge. */
.result-card:not(:has(.rank-badge)) { grid-template-columns: 96px 1fr auto; }

.result-card:not(:has(.rank-badge)):not(:has(img)) { grid-template-columns: 1fr auto; }

.result-card.winner {
    border-color: #f59e0b;
    background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 12%, var(--card)), var(--card));
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}

.rank-badge {
    font-size: 1.6rem;
    text-align: center;
    filter: var(--badge-filter, none);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.result-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-pct {
    font-size: 1.3rem;
    font-weight: 800;
    text-align: right;
    color: var(--accent);
    line-height: 1.1;
}

.result-pct small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted);
}

@keyframes grow-bar {
    from { width: 0; }
}

.result-card .bar {
    animation: grow-bar 1s ease-out;
}

/* --- Theme runner riding on the tip of the result bars --- */
.result-card .bar-track {
    position: relative;
    overflow: visible;
    /* The runner sticks out ~11px to the left of the bar at 0%;
       this margin keeps it clear of the option image. */
    margin-left: var(--runner-gap, 0);
}

.result-card .bar {
    position: relative;
}

.result-card .bar::after {
    content: var(--runner, none);
    position: absolute;
    right: -0.6rem;
    top: 50%;
    translate: 0 -52%;
    transform: var(--runner-transform, none);
    font-size: 1.1rem;
}

.result-card.winner .bar::after { content: var(--runner-winner, var(--runner, none)); }

.result-image {
    width: 96px;
    height: 72px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: contain;
    cursor: zoom-in;
}

/* --- Static option gallery (visitors) --- */
.vote-card.static {
    cursor: default;
}

.vote-card.static:hover {
    box-shadow: none;
    border-color: var(--border);
}

/* --- Admin voter info --- */
.info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--on-accent);
    padding: 0;
    margin: 0 0 0 0.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1;
}

.info-button:hover { background: var(--accent-dark); }

.voter-list {
    font-size: 0.82rem;
    background: color-mix(in srgb, var(--text) 5%, transparent);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
}

.voter-list ul,
.voter-list ol {
    margin: 0.2rem 0 0;
    padding-left: 1.1rem;
}

/* --- Admin invitee table --- */
.table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.invite-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.invite-table th,
.invite-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.invite-table th {
    background: color-mix(in srgb, var(--text) 3%, var(--card));
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.invite-table tbody tr:last-child td { border-bottom: none; }

.invite-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--card)); }

/* --- Poll base data: read-only summary + type cards in the overlay --- */
.summary-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.25rem;
    margin: 0.5rem 0 0;
}

.summary-list dt {
    color: var(--muted);
    font-size: 0.9rem;
}

.summary-list dd {
    margin: 0;
    font-weight: 600;
}

.status-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.status-waiting { background: #fef3c7; color: #92400e; }

.status-badge.status-open { background: #dcfce7; color: #166534; }

.poll-mode-settings { display: flex; flex-direction: column; gap: 0.5rem; }

.advanced-settings { border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.8rem; margin: 0.75rem 0; }

.advanced-settings > summary { cursor: pointer; font-weight: 600; }

.advanced-settings[open] > summary { margin-bottom: 0.6rem; }

.advanced-settings[hidden] { display: none; }

/* New poll overlay, team mode: the teams typed in right away (emblem popover + name + remove). */
.team-list-field {
    margin: 0.25rem 0 0.75rem;
    padding: 0.75rem 0.8rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 4%, var(--card));
}

.team-list-field[hidden] { display: none; }

.team-list-title { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 600; }

.team-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }

.team-row { position: relative; display: flex; align-items: center; gap: 0.5rem; }

.team-row input[type="text"] { flex: 1; min-width: 0; margin: 0; }

.team-row button.icon-button { flex-shrink: 0; }

.team-emoji > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.35rem;
    line-height: 1;
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    background: var(--card);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.team-emoji > summary::-webkit-details-marker { display: none; }

.team-emoji > summary:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border)); }

.team-emoji[open] > summary,
.team-emoji > summary:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.team-emoji-pop {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
}

button.team-emoji-option {
    height: 2.4rem;
    padding: 0;
    margin: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: inherit;
    background: transparent;
    border: 2px solid transparent;
    box-shadow: none;
}

button.team-emoji-option:hover { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }

button.team-emoji-option[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }

button.team-add { margin: 0.6rem 0 0.5rem; }

button.team-add:disabled { opacity: 0.45; cursor: not-allowed; }

.poll-base-modal-card { width: min(560px, 94vw); }

.warning-modal-card { width: min(440px, 92vw); }

.warning-modal-card .modal-actions { flex-wrap: wrap; align-items: center; }

.delete-confirm:disabled { opacity: 0.45; cursor: not-allowed; }

.delete-code-preview { border-color: #dc2626; background: #fef2f2; }

.delete-code-preview .pin-code { color: #b91c1c; letter-spacing: 0.2em; }

.poll-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.6rem;
}

.poll-type-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.7rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 400;
    margin: 0;
}

.poll-type-card input { position: absolute; opacity: 0; pointer-events: none; }

.poll-type-card:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--card));
}

.poll-type-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.poll-type-name { font-weight: 700; }

.poll-category-cards { grid-template-columns: 1fr 1fr; }

/* Questionnaire sub-kinds: a tinted panel pointing up at the Questionnaire card (2nd column, always). */
.survey-kind-panel {
    position: relative;
    margin-top: 0.75rem;
    padding: 0.6rem 0.7rem 0.7rem;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 5%, var(--card));
}

.survey-kind-panel::before {
    content: '';
    position: absolute;
    top: -7px;
    left: calc(75% + 0.15rem - 6px);
    width: 12px;
    height: 12px;
    background: inherit;
    border-left: inherit;
    border-top: inherit;
    transform: rotate(45deg);
}

.survey-kind-panel[hidden] { display: none; }

.survey-kind-title {
    margin: 0 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.survey-kind-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.survey-kind-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    font-weight: 400;
    cursor: pointer;
}

.survey-kind-option input { flex: none; margin: 0.2rem 0 0; accent-color: var(--accent); }

.survey-kind-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.survey-kind-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.survey-kind-option:has(input:disabled:not(:checked)) { opacity: 0.55; cursor: not-allowed; }

.survey-kind-name { display: block; font-size: 0.9rem; font-weight: 600; }

.survey-kind-option .muted { display: block; margin-top: 0.1rem; font-size: 0.8rem; line-height: 1.35; }

.survey-kind-locked { margin: 0.5rem 0 0; font-size: 0.85rem; }

.poll-type-card:has(input:disabled:not(:checked)) { opacity: 0.55; cursor: not-allowed; }

.poll-type-fixed { margin: 0.25rem 0; }

/* --- Invitations: server-side sorted/paginated list, empty state, PIN, overlay --- */
.invite-table td.nowrap { white-space: nowrap; }

.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link .sort-arrow { opacity: 0.4; }
.sort-link.active .sort-arrow { opacity: 1; }
.sort-link:hover { color: var(--accent); }

.pager a,
.pager span.pager-arrow {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    min-width: 2.4rem;
    text-align: center;
    text-decoration: none;
}

.pager a:hover { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border-color: var(--accent); }

.pager a.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

.pager span.pager-arrow.disabled { color: var(--muted); opacity: 0.5; }

.pin-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.pin-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0.25rem;
    padding: 0.7rem 0.9rem;
    border: 2px dashed var(--accent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
    font-weight: 600;
}

.pin-code-lg {
    font-size: 1.4rem;
    color: var(--accent);
}

.invite-modal-card { width: min(560px, 94vw); }

.invite-pane { margin: 0 0 0.5rem 1.6rem; }

.empty-state {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 0.5rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 4%, var(--card));
}

.empty-state-icon { font-size: 2.6rem; line-height: 1; }

.empty-state h3 { margin: 0.5rem 0 0.25rem; }

.empty-state-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem auto 1rem;
    max-width: 560px;
    text-align: left;
}

.empty-state-list li {
    display: flex;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

.empty-state-list li:last-child { border-bottom: none; }

.gate-card .pin-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.3rem;
    letter-spacing: 0.15em;
    max-width: 14rem;
}

.gate-card .pin-rest {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gate-card .pin-rest .pin-code { font-size: 1.3rem; letter-spacing: 0.15em; }

.gate-card .pin-input-rest { max-width: 5.5rem; }

.votes-modal-card {
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 1rem 1.4rem;
    max-width: 92vw;
    max-height: 80vh;
    overflow: auto;
}

.votes-modal-card ul {
    margin: 0.4rem 0 0;
    padding-left: 0;
    list-style: none;
}

.votes-modal-card li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.votes-modal-card li:last-child { border-bottom: none; }

.votes-detail-thumb {
    width: 84px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
    justify-content: center;
}

.lightbox[hidden] { display: none; }

.lightbox img {
    max-width: 94vw;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.lightbox-caption {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    max-width: 90vw;
}

.lightbox-place {
    margin: 0;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    background: #ffd700;
    color: #222;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    max-width: 90vw;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Linked videos: thumbnail + play button; the player opens in an overlay (partials/video_player) --- */
.media-video {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    max-width: 100%;
    cursor: pointer;
    line-height: 0;
}

.media-video-vote-image, .media-video-question-image { display: block; }

.media-video-question-image { width: fit-content; }

.media-video img { cursor: pointer; }

.media-video-placeholder {
    display: block;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #2b2f3a, #11131a);
}

.question-image.media-video-placeholder { width: 480px; max-width: 100%; height: auto; }

.vote-image.media-video-placeholder { max-height: none; }

.live-option .media-video-placeholder { width: 3.5rem; height: 3.5rem; aspect-ratio: auto; border-radius: calc(6px * var(--radius-scale, 1)); }

body.live-screen-body .live-option .media-video-placeholder { width: 5rem; height: 5rem; }

.media-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3.4rem;
    height: 3.4rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.62);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: background 0.15s, transform 0.15s;
    pointer-events: none;
}

.media-video-play::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 0.6rem 0 0.6rem 1rem;
    border-color: transparent transparent transparent #fff;
}

.media-video:hover .media-video-play, .media-video:focus-visible .media-video-play {
    background: var(--accent);
    transform: translate(-50%, -50%) scale(1.08);
}

.media-video:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.media-video-result-image .media-video-play, .live-option .media-video-play {
    width: 1.9rem;
    height: 1.9rem;
}

.media-video-result-image .media-video-play::after, .live-option .media-video-play::after {
    border-width: 0.35rem 0 0.35rem 0.6rem;
}

.result-image.media-video-placeholder { aspect-ratio: auto; }

.video-player-frame {
    width: min(94vw, calc(85vh * 16 / 9));
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.video-player-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- Poll form modals (add option / add options in batch) --- */
.form-modal {
    background: rgba(0, 0, 0, 0.55);
}

.form-modal-card {
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 1.2rem 1.4rem;
    width: min(480px, 92vw);
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.form-modal-card h3 { margin-top: 0; }

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.modal-actions .modal-cancel {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.modal-actions .modal-cancel:hover {
    background: color-mix(in srgb, var(--text) 6%, var(--card));
    color: var(--text);
}

.modal-errors { margin-top: 0.75rem; }

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin: 0.6rem 0 0.3rem;
}

.radio-label input[type="radio"] { margin: 0; }

.batch-pane {
    margin: 0 0 0.5rem 1.6rem;
}

.voted-note { font-weight: 600; }

/* --- Mobile --- */
@media (max-width: 600px) {
    main {
        padding: 1rem 0.75rem 5.5rem;
    }

    .site-header-inner { padding: 0.6rem 0.75rem; }

    .brand { font-size: 1.15rem; }

    .brand-suffix { font-size: 0.95rem; }

    .poll-nav-label { display: none; }

    .topic-sticky {
        margin: 0 -0.75rem 0.75rem;
        padding: 0.25rem 0.75rem;
    }

    .card {
        padding: 1rem 0.85rem;
    }

    h1 { font-size: 1.4rem; }

    .vote-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .vote-image {
        max-height: 45vh;
    }

    .vote-submit {
        position: sticky;
        bottom: 0.75rem;
        z-index: 5;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    }

    .result-card {
        grid-template-columns: 2.2rem 56px 1fr auto;
        gap: 0.5rem;
        padding: 0.55rem 0.6rem;
    }

    .result-card:not(:has(img)) {
        grid-template-columns: 2.2rem 1fr auto;
    }

    .result-card:not(:has(.rank-badge)) { grid-template-columns: 56px 1fr auto; }

    .result-card:not(:has(.rank-badge)):not(:has(img)) { grid-template-columns: 1fr auto; }

    .rank-badge { font-size: 1.25rem; }

    .result-image {
        width: 56px;
        height: 44px;
    }

    .result-name {
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        overflow-wrap: anywhere;
    }

    .result-pct { font-size: 1.1rem; }

    .result-card .bar::after { font-size: 0.95rem; }
}

.result-row {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    background: var(--bg);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.bar {
    background: var(--bar, var(--accent));
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

.result-count {
    font-size: 0.875rem;
    color: var(--muted);
    white-space: nowrap;
}

/* --- Theme picker (poll form): every swatch / the preview carries its own theme class --- */
.theme-current {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.theme-current .button-secondary {
    padding: 0.35rem 0.8rem;
    font-size: 0.9rem;
}

/* --- Invitation QR code page --- */
.qr-card {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
}

.qr-code svg {
    display: block;
    width: min(320px, 80vw);
    height: auto;
    margin: 1rem auto;
}

.short-url {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.short-url code {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
}

.full-url { margin-top: 1rem; font-size: 0.85rem; }
.full-url code { overflow-wrap: anywhere; }

/* --- Test visual: the voters' screen of the poll in an overlay (iframe) --- */
.test-visual-card {
    display: flex;
    flex-direction: column;
    width: min(1100px, 96vw);
    height: 92vh;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.test-visual-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: #fef3c7;
    color: #78350f;
    border-bottom: 1px solid #fcd34d;
}

.test-visual-bar p { margin: 0; font-size: 0.92rem; }

.test-visual-close {
    flex-shrink: 0;
    margin: 0;
    padding: 0.4rem 0.85rem;
    background: #78350f;
    color: #fff;
}

.test-visual-close:hover { background: #92400e; }

.test-visual-frame {
    flex: 1;
    width: 100%;
    border: 0;
    background: #fff;
}

.form-modal-card.theme-modal-card {
    display: flex;
    flex-direction: column;
    width: min(1040px, 96vw);
    max-height: 90vh;
    overflow: hidden;
}

/* Only the picker scrolls, so the title and the action buttons stay on screen. */
.theme-modal-card .theme-picker-layout {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.25rem 0.25rem 0.75rem;
}

.theme-modal-card .modal-actions {
    flex-shrink: 0;
    margin-top: 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

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

.theme-group-title {
    margin: 0.6rem 0 0.4rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
}

form label.theme-swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    padding: 0 0 0.55rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: var(--page-bg);
    color: var(--text);
    color-scheme: var(--scheme);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.theme-swatch:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.theme-swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-swatch:has(input:checked) {
    box-shadow: 0 0 0 3px var(--accent), 0 6px 14px rgba(0, 0, 0, 0.15);
}

.theme-swatch:has(input:checked)::after {
    content: "✓";
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.75rem;
}

.theme-swatch:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.swatch-strip {
    display: block;
    height: 8px;
    background: var(--accent);
}

.swatch-strip::before {
    content: "";
    display: block;
    height: 100%;
    background: var(--strip);
}

.swatch-name {
    padding: 0 0.6rem;
    font-family: var(--heading-font);
    line-height: 1.25;
}

.swatch-sample {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0.6rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: calc(6px * var(--radius-scale));
    background: var(--card);
}

.swatch-token::before,
.preview-token::before { content: var(--token); }

.swatch-bar {
    flex: 1;
    height: 8px;
    margin-right: 0.5rem;
    border-radius: 999px;
    background: var(--bg);
}

.swatch-bar span {
    position: relative;
    display: block;
    width: 70%;
    height: 100%;
    border-radius: 999px;
    background: var(--bar);
}

.swatch-bar span::after {
    content: var(--runner);
    position: absolute;
    right: -0.5rem;
    top: 50%;
    translate: 0 -55%;
    transform: var(--runner-transform);
    font-size: 0.8rem;
}

.theme-preview-wrap {
    position: sticky;
    top: 1rem;
}

.theme-preview {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--page-bg);
    color: var(--text);
    color-scheme: var(--scheme);
    font-family: var(--font);
    font-weight: 400;
}

.preview-strip {
    height: var(--strip-h);
    margin-bottom: calc(var(--strip-gap) * 0.6);
    border-radius: 4px;
    background: var(--strip);
    border: var(--strip-border);
}

.preview-title {
    margin: 0 0 0.6rem;
    font-family: var(--heading-font);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: var(--heading-transform);
    text-shadow: var(--heading-shadow);
}

.preview-title::before { content: var(--title-icon); }

.theme-preview .card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0;
    padding: 0.75rem;
}

.theme-preview .token-bank {
    position: static;
    margin: 0;
    padding: 0.4rem 0.6rem;
    box-shadow: none;
}

.theme-preview .result-list { gap: 0.4rem; }

.theme-preview .result-card {
    grid-template-columns: 2rem 1fr auto;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
}

.theme-preview .rank-badge { font-size: 1.2rem; }
.theme-preview .result-pct { font-size: 1rem; }

.theme-preview .token-stepper button {
    width: 2rem;
    height: 2rem;
    font-size: 1.1rem;
}

.preview-count {
    width: 2.5rem;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 800;
}

.theme-preview .vote-submit {
    margin: 0;
    padding: 0.6rem;
    font-size: 1rem;
}

@media (max-width: 800px) {
    .theme-picker-layout { grid-template-columns: 1fr; }
    .theme-preview-wrap { position: static; order: -1; }
}

/* Phones: every swatch already shows its own look, the big preview would only push them down. */
@media (max-width: 600px) {
    .theme-preview-wrap { display: none; }
}

/* Survey question types (questionnaire): admin form groups + voter-facing text/scale inputs. */
.qf-group {
    margin-bottom: 1rem;
}

.optional-badge {
    margin: 0 0 0.5rem;
}

.text-answer {
    width: 100%;
    font: inherit;
    padding: 0.6rem;
    border: 1px solid var(--input-border, #ccc);
    border-radius: var(--radius, 6px);
    resize: vertical;
}

.scale-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.scale-options {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.scale-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border: 1px solid var(--input-border, #ccc);
    border-radius: var(--radius, 6px);
    cursor: pointer;
    font-weight: 600;
}

.scale-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.scale-option:has(input:checked) {
    background: var(--accent, #4f46e5);
    color: var(--on-accent, #fff);
    border-color: var(--accent, #4f46e5);
}

.scale-caption {
    font-size: 0.85rem;
}

/* Question groups (edit.php question list) and teams (invitation list): header row + indented member rows. */
.question-group-header td,
.team-group-header td {
    background: color-mix(in srgb, var(--accent) 8%, var(--card));
    font-weight: 600;
}

.question-grouped-row td:nth-child(2),
.team-grouped-row td:first-child {
    padding-left: 1.5rem;
}

.team-pager-row td {
    padding-left: 1.5rem;
}

.team-pager-row .pager {
    display: inline-flex;
    margin: 0 0.75rem 0 0;
    vertical-align: middle;
}

/* Drag & drop reordering (partials/drag_sort_script): handle, dragged element, drop line. */
.drag-handle {
    display: inline-block;
    margin-right: 0.4rem;
    padding: 0 0.15rem;
    color: var(--muted);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.drag-handle:hover {
    color: var(--accent);
}

body.drag-active,
body.drag-active * {
    cursor: grabbing !important;
    user-select: none;
}

.dragging td {
    opacity: 0.4;
}

.drop-indicator {
    position: absolute;
    z-index: 50;
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
    pointer-events: none;
}

.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    align-items: baseline;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 8px;
    background: var(--card-bg, #f4f4f4);
}

.word-cloud-word {
    font-weight: 600;
    line-height: 1.2;
}

body.live-screen-body {
    background: #10131a;
    color: #fff;
}

body.live-screen-body main,
body.live-screen-body .live-presenter-card {
    max-width: none;
}

body.live-screen-body .card {
    background: transparent;
    border: none;
    box-shadow: none;
    text-align: center;
}

body.live-screen-body .question-heading {
    font-size: 2.2rem;
}

body.live-screen-body .word-cloud {
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
}

body.live-screen-body .result-card {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-align: left;
}

body.live-screen-body .result-name { font-size: 1.5rem; }

body.live-screen-body .result-pct { color: #a5b4fc; font-size: 2rem; }

body.live-screen-body .result-card .bar-track { height: 16px; background: rgba(255, 255, 255, 0.15); }

body.live-screen-body .result-card .bar { background: var(--bar, color-mix(in srgb, var(--accent) 65%, #fff)); }

body.live-screen-body .muted { color: #94a3b8; }

.live-leaderboard ol {
    text-align: left;
    display: inline-block;
}

/* --- Home page: "enter the code" box (visitors) --- */
.join-card {
    max-width: 560px;
    margin: 1rem auto 1.25rem;
    text-align: center;
}

.join-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.join-form input[type="text"] {
    flex: 1;
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
}

.join-form input::placeholder {
    font-weight: 400;
    letter-spacing: 0.08em;
    opacity: 0.45;
}

.join-form button { margin: 0; font-size: 1.05rem; }

/* --- Viral loop: "create your own" card + "powered by" footer --- */
.cta-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    background: color-mix(in srgb, var(--accent) 6%, var(--card));
}

.join-card + .cta-card { max-width: 560px; margin-left: auto; margin-right: auto; }

.cta-text h2 { margin: 0 0 0.25rem; }
.cta-text p { margin: 0; }

.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1.25rem 2rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.powered-by-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-weight: 600;
}

/* --- New account: getting-started checklist --- */
.onboarding-card {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.onboarding-steps { margin: 0.5rem 0 0; padding-left: 1.4rem; }
.onboarding-steps li { margin: 0.35rem 0; }
.onboarding-steps .link-button { font-size: inherit; }

/* Spam trap of the signup form: invisible to people, filled in by bots. */
.hp-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Live lobby: how the audience joins (QR + host + code) --- */
.live-join {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    margin: 1rem 0;
}

.live-join .qr-code svg {
    width: min(260px, 70vw);
    margin: 0;
    background: #fff;
    padding: 8px;
    border-radius: 8px;
}

.live-join-text p { margin: 0.2rem 0; }

.live-join-host,
.live-join-code {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.live-join-code { color: var(--accent); letter-spacing: 0.12em; }

.live-join-strip {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.live-join-strip strong { color: var(--text); letter-spacing: 0.1em; }

body.live-screen-body .live-join-host,
body.live-screen-body .live-join-code { font-size: 3.2rem; }

body.live-screen-body .live-join-code { color: #a5b4fc; }

body.live-screen-body .live-join-strip,
body.live-screen-body .live-join-strip strong { color: #cbd5e1; font-size: 1.2rem; }

body.live-screen-body .powered-by,
body.live-screen-body .powered-by a { color: #94a3b8; }

body.live-screen-body .site-footer { display: none; }

/* --- Privacy: site footer, legal pages, GDPR card, account deletion --- */
.site-footer {
    text-align: center;
    margin: 0 auto 1.5rem;
    font-size: 0.85rem;
}

.site-footer a { color: var(--muted); }

.legal-text h2 { font-size: 1.1rem; margin-top: 1.5rem; }

.legal-text li { margin-bottom: 0.35rem; }

.gdpr-card h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }

.gdpr-inline,
.inline-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.gdpr-inline select,
.gdpr-inline input[type="search"] { flex: 1 1 16rem; width: auto; margin: 0; }

.inline-controls select { flex: 1 1 7rem; min-width: 0; width: auto; margin: 0; }
.inline-controls button { margin: 0; }

.gdpr-settings input[type="number"] { width: 8rem; }

.gate-privacy { font-size: 0.85rem; }

.danger-card { border-color: #fca5a5; }

.danger-card h2 { color: #b91c1c; }


/* --- Results export menu + print / PDF --- */
.export-bar {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.export-menu { position: relative; }

.export-menu > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: calc(8px * var(--radius-scale, 1));
    box-shadow: var(--shadow-sm);
}

.export-menu > summary::-webkit-details-marker { display: none; }

.export-menu-items {
    position: absolute;
    right: 0;
    z-index: 5;
    min-width: 16rem;
    margin-top: 0.35rem;
    padding: 0.4rem 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(16, 24, 40, 0.12));
}

.export-menu-items a {
    display: block;
    padding: 0.45rem 0.9rem;
    color: var(--text);
    text-decoration: none;
}

.export-menu-items a:hover { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }

.export-menu-items p { margin: 0.4rem 0.9rem; font-size: 0.85rem; }

.finalize-slot {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.finalize-slot p { margin: 0 0 0.5rem; }

.finalize-slot-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 1rem;
}

.finalize-slot-form label { margin: 0; }

/* --- Team mode: lobby tiles per team --- */
.live-team-joins {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.live-team-join {
    text-align: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.live-team-join h3 { margin: 0 0 0.5rem; }

.live-team-join p { margin: 0.25rem 0; }

.live-team-join .qr-code svg {
    width: min(160px, 60vw);
    margin: 0 auto;
    background: #fff;
    padding: 6px;
    border-radius: 8px;
}

.live-team-join .live-join-code { font-size: 1.6rem; }

body.live-screen-body .live-team-join { border-color: #475569; }

body.live-screen-body .live-team-join .live-join-code { font-size: 2.2rem; }

/* --- Self-paced polls: invitations on screen (edit card next step, filter, projector) --- */
.next-step {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.925rem;
}

.next-step p { margin: 0; flex: 1 1 18rem; }

.next-step .button,
.next-step button { margin: 0; }

/* --- Edit page: launch panel (readiness, start / project, test run, theme) --- */
.launch-panel {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    border-left: 5px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 5%, var(--card));
}

.launch-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }

.launch-head h2 { margin: 0; font-size: 1.35rem; }

.launch-mode {
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
}

.launch-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 1rem 0; padding: 0; }

.launch-steps li { display: flex; align-items: center; gap: 0.5rem; }

.launch-step-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2px solid var(--input-border);
    color: var(--muted);
    background: var(--card);
}

.launch-steps .is-done .launch-step-mark { border-color: #16a34a; background: #16a34a; color: #fff; }

.launch-step-label { font-weight: 600; }

.launch-panel .next-step { margin-bottom: 1rem; }

.launch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

.launch-actions form { margin: 0; }

.launch-actions button,
.launch-actions .button { margin: 0; }

/* The panel's main action: a calm "go" green, normal size. */
.launch-actions .launch-primary {
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    font-weight: 700;
    background: #16a34a;
    color: #fff;
    box-shadow: 0 3px 10px rgba(22, 163, 74, 0.28);
}

.launch-actions a.launch-primary:hover { background: #15803d; color: #fff; }

.launch-actions .launch-primary:disabled { background: #16a34a; box-shadow: none; }

.launch-primary:disabled,
.launch-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.launch-hint { margin: 0.75rem 0 0; }

.launch-theme { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); }

.launch-actions button.launch-primary:hover:not(:disabled) { background: #15803d; }

/* --- Edit pages: Build › Test › Run sub-navigation (under the Results / Edit switch) --- */
.stage-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    margin: 0 0 1.25rem;
}

.stage-steps ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    gap: 0.15rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale, 1));
    box-shadow: var(--shadow-sm);
}

.stage-step { display: flex; align-items: center; }

.stage-step + .stage-step::before { content: '›'; padding: 0 0.2rem; color: var(--muted); font-size: 1.2rem; line-height: 1; }

.stage-step a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.95rem 0.4rem 0.5rem;
    border-radius: calc(9px * var(--radius-scale, 1));
    color: var(--text);
    text-decoration: none;
}

.stage-step a:hover { background: color-mix(in srgb, var(--accent) 7%, var(--card)); text-decoration: none; }

.stage-step-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    border: 2px solid var(--input-border);
    background: var(--card);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.stage-step.is-done .stage-step-mark { border-color: #16a34a; background: #16a34a; color: #fff; }

.stage-step.is-now .stage-step-mark {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.stage-step-text { display: flex; flex-direction: column; line-height: 1.2; }

.stage-step-name { font-weight: 700; font-size: 0.95rem; }

.stage-step-hint { color: var(--muted); font-size: 0.75rem; }

.stage-step.is-now .stage-step-hint { color: var(--accent); font-weight: 600; }

.stage-step.is-active a { background: var(--accent); color: var(--on-accent); }

.stage-step.is-active .stage-step-hint { color: color-mix(in srgb, var(--on-accent) 80%, transparent); }

.stage-step.is-active .stage-step-mark { border-color: var(--on-accent); background: var(--on-accent); color: var(--accent); box-shadow: none; }

.stage-step.is-active.is-done .stage-step-mark { color: #16a34a; }

.stage-steps-status { font-size: 0.9rem; }

.status-badge.status-build { background: #e0e7ff; color: #3730a3; }

.status-badge.status-test { background: #f3e8ff; color: #6b21a8; }

/* Bottom of Build / Test: on to the next step. */
.step-next {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    border-style: dashed;
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.step-next h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }

.step-next p { margin: 0; }

.step-next form,
.step-next .button,
.step-next button { margin: 0; }

/* Run step: launch form, status, timing, close / undo. */
.run-launch-form { margin-top: 0.5rem; }

.run-panel .next-step { margin: 0 0 1rem; }

.run-schedule { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.25rem 1rem; max-width: 34rem; }

.run-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.9rem 0; }

.run-status .status-badge { margin-left: 0; padding: 0.15rem 0.7rem; font-size: 0.85rem; }

.run-schedule-form,
.run-danger { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); }

.run-schedule-form h3 { margin: 0 0 0.5rem; font-size: 1rem; }

.run-danger { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.run-danger form,
.run-danger button { margin: 0; }

/* New poll overlay: starting from a template is the secondary way in. */
.template-start {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    margin: -0.25rem 0 1rem;
    font-size: 0.9rem;
}

.template-start-link { font-weight: 600; white-space: nowrap; }

/* --- Test run: banner + live controls --- */
.test-run-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.6rem 1.25rem;
    background: #fef3c7;
    border-bottom: 2px solid #d97706;
    color: #78350f;
}

.test-run-text { margin: 0; font-size: 0.95rem; }

.test-run-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.test-run-actions form { margin: 0; }

.test-run-actions button,
.test-run-actions .button { margin: 0; }

.test-run-live {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: 1px dashed #d97706;
    border-radius: 10px;
    background: #fffbeb;
    color: #78350f;
}

.test-run-live p { margin: 0 0 0.5rem; }

.test-run-live form { margin: 0; }

.test-run-result { font-weight: 700; }

.test-run-result.is-correct { color: #166534; }

/* Inside the edit page's test overlay the overlay bar starts over / closes; the page keeps only what the run needs. */
.in-test-frame .test-run-hide-in-frame { display: none; }

.in-test-frame .test-run-bar { justify-content: flex-end; padding: 0.4rem 0.9rem; }

.test-run-modal-actions { display: flex; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

.test-run-modal-actions .test-visual-close { background: transparent; color: #78350f; border: 1px solid #b45309; }

.test-run-modal-actions .test-visual-close:hover { background: #fde68a; }

.test-run-modal-actions .test-run-modal-close { background: #78350f; color: #fff; border-color: #78350f; }

.test-run-modal-actions .test-run-modal-close:hover { background: #92400e; }

.showcase-card { text-align: center; }

/* Tiles of a row line up their QR codes and join codes, with or without a subtitle. */
.showcase-card .live-team-join { display: flex; flex-direction: column; align-items: center; }

.showcase-card .live-team-join .qr-code { margin-top: auto; padding-top: 0.5rem; }

.showcase-hint,
.showcase-single-heading { margin: 0.25rem 0 0; }

.showcase-filter-list { list-style: none; margin: 0 0 0.75rem; padding: 0; }

.showcase-filter-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }

.showcase-filter-list li:last-child { border-bottom: none; }

.showcase-filter-list .checkbox-label { margin: 0; align-items: flex-start; }

.showcase-filter-list .checkbox-label input { margin-top: 0.2rem; }

.showcase-filter-name { display: block; font-weight: 600; }

body.live-screen-body .showcase-screen-title { font-size: 2.6rem; margin: 0.5rem 0 1rem; }

body.live-screen-body .showcase-hint { color: #cbd5e1; font-size: 1.4rem; }

body.live-screen-body .live-team-join .muted { color: #94a3b8; }

/* Presenter / invitations page: back link + projector and phone links. */
.page-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 0 0 1rem;
}

.page-tools-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

a.button.button-secondary.tool-link,
button.button-secondary.tool-link {
    padding: 0.45rem 0.9rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--accent-dark);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--input-border));
    background: color-mix(in srgb, var(--accent) 7%, var(--card));
}

a.button.button-secondary.tool-link:hover,
button.button-secondary.tool-link:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--card));
}

/* --- Live: the open question's answer choices (presenter + projector) --- */
.live-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.6rem;
    margin: 1rem 0;
    padding: 0;
    list-style: none;
}

.live-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale, 1));
    background: var(--card);
    font-weight: 600;
    text-align: left;
    overflow-wrap: anywhere;
}

.live-option img {
    flex-shrink: 0;
    width: 3.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: calc(6px * var(--radius-scale, 1));
}

.live-match { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1.5rem; margin: 1rem 0; }

.live-match .live-options { grid-template-columns: 1fr; margin: 0; }

.live-scale { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0.5rem 1rem; margin: 1rem 0; }

.live-scale strong { font-size: 1.4rem; }

body.live-screen-body .live-option {
    padding: 1rem 1.25rem;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.5rem;
}

body.live-screen-body .live-option img { width: 5rem; height: 5rem; }

body.live-screen-body .live-options { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }

body.live-screen-body .live-scale { font-size: 1.5rem; }

body.live-screen-body .live-scale strong { font-size: 2.2rem; }

/* --- Live: question countdown --- */
.live-timer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.live-timer-seconds {
    min-width: 2.6em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent, #fff);
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.live-timer-track {
    flex: 1;
    height: 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    overflow: hidden;
}

.live-timer-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s linear;
}

.live-timer-urgent .live-timer-seconds,
.live-timer-urgent .live-timer-bar { background: #dc2626; }

.live-timer-urgent .live-timer-seconds { animation: live-timer-pulse 1s ease-in-out infinite; }

@keyframes live-timer-pulse {
    50% { transform: scale(1.12); }
}

body.live-screen-body .live-timer-seconds { font-size: 2.6rem; }

body.live-screen-body .live-timer-track { height: 1rem; background: rgba(255, 255, 255, 0.15); }

/* --- Live: podium at the end (3rd, then 2nd, then 1st rises) --- */
.podium { margin: 1.5rem 0 1rem; text-align: center; }

.podium-stands {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.75rem;
    min-height: 16rem;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(11rem, 30vw);
    opacity: 0;
    animation: podium-rise 0.8s cubic-bezier(0.2, 0.8, 0.3, 1.2) forwards;
}

.podium-place-3 { animation-delay: 0.3s; }
.podium-place-2 { animation-delay: 1.3s; }
.podium-place-1 { animation-delay: 2.3s; }

.podium-medal { font-size: 2.4rem; line-height: 1; }

.podium-name {
    margin: 0.3rem 0 0.2rem;
    font-weight: 700;
    overflow-wrap: break-word;
    max-width: 100%;
}

.podium-score { color: var(--muted, #64748b); font-variant-numeric: tabular-nums; }

.podium-block {
    width: 100%;
    margin-top: 0.4rem;
    border-radius: 10px 10px 0 0;
    background: var(--accent);
    color: var(--on-accent, #fff);
    font-size: 2rem;
    font-weight: 800;
    padding-top: 0.4rem;
}

.podium-place-1 .podium-block { height: 9rem; }
.podium-place-2 .podium-block { height: 6.5rem; opacity: 0.85; }
.podium-place-3 .podium-block { height: 4.5rem; opacity: 0.7; }

.podium-place-1 .podium-medal { animation: podium-bounce 1s ease-in-out 3.1s 2; }

@keyframes podium-rise {
    from { opacity: 0; transform: translateY(3rem); }
    to { opacity: 1; transform: none; }
}

@keyframes podium-bounce {
    50% { transform: translateY(-0.6rem) scale(1.15); }
}

body.live-screen-body .podium-name { font-size: clamp(1rem, 4vw, 1.8rem); }

body.live-screen-body .podium-score { color: #cbd5e1; }

.live-my-place {
    font-size: 1.2rem;
    font-weight: 700;
}

.live-sound-toggle {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
}

/* --- Live: audience Q&A --- */
.qna-card h2 { margin-top: 0; }

.qna-ask-form textarea { width: 100%; resize: vertical; }

.qna-ask-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.qna-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.qna-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
}

.qna-item:first-child { border-top: none; }

.qna-item form { margin: 0; }

.qna-body { display: block; overflow-wrap: anywhere; }

.qna-meta { display: block; font-size: 0.85rem; }

.qna-mine .qna-item { opacity: 0.75; }

.qna-upvote { white-space: nowrap; font-variant-numeric: tabular-nums; }

.qna-upvote.is-upvoted {
    background: var(--accent);
    color: var(--on-accent, #fff);
    border-color: var(--accent);
}

.qna-votes { white-space: nowrap; color: var(--muted); }

.qna-answered { margin-top: 0.75rem; }

.qna-presenter-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.qna-presenter-head form { margin: 0; }

.qna-status { margin-top: 1rem; }

.qna-status h3 { margin: 0 0 0.25rem; font-size: 1rem; }

.qna-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; }

.qna-actions button { padding: 0.25rem 0.55rem; font-size: 0.85rem; }

.qna-item.is-projected { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.qna-projected {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.qna-projected form { margin: 0; }

/* Projector: on a Q&A item the projected question or the Q&A wall replaces the poll. */
body.live-screen-body:has(#qna-root[data-wall="1"]) #live-root { display: none; }

#qna-root[hidden] { display: none; }

.qna-screen { text-align: center; padding: 2rem 1rem; }

.qna-highlight-label { font-size: 1.4rem; opacity: 0.8; }

.qna-highlight-body {
    font-size: clamp(1.8rem, 5vw, 3.4rem);
    font-weight: 700;
    line-height: 1.25;
    margin: 1rem auto;
    max-width: 60rem;
    overflow-wrap: anywhere;
}

.qna-highlight-meta,
.qna-screen .qna-meta { color: #cbd5e1; font-size: 1.2rem; }

.qna-wall {
    max-width: 56rem;
    margin: 1rem auto;
    padding-left: 2rem;
    text-align: left;
    font-size: clamp(1.1rem, 2.6vw, 1.8rem);
}

.qna-wall li { margin: 0.8rem 0; }

@media (prefers-reduced-motion: reduce) {
    .podium-place { animation: none; opacity: 1; }
    .podium-place-1 .podium-medal,
    .live-timer-urgent .live-timer-seconds { animation: none; }
    .live-timer-bar { transition: none; }
}

/* Usage dashboard (G19) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.kpi-grid .card { margin: 0; }

.kpi { display: flex; flex-direction: column; gap: 0.2rem; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--accent); }
.kpi-label { font-weight: 600; }

.bar-chart { margin: 0 0 1.5rem; }
.bar-chart:last-child { margin-bottom: 0; }
.bar-chart figcaption { font-weight: 600; margin-bottom: 0.4rem; }
.bar-chart svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--accent); }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-value, .chart-label { font-size: 11px; fill: var(--muted); }
.chart-value { fill: var(--text); font-weight: 600; }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.2rem 0; }

.funnel-table th[scope="row"] { text-align: left; white-space: nowrap; }

/* Referrals: one row per referring account, the accounts it brought in as wrapping chips */
.referral-table th.num, .referral-table td.num { width: 1%; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.referral-table td { vertical-align: top; }
.referral-referrer { font-weight: 600; white-space: nowrap; }
.referral-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.referral-chips li {
    display: inline-flex; align-items: baseline; gap: 0.4rem; padding: 0.15rem 0.6rem;
    border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--text) 2%, var(--card));
    font-size: 0.85rem; line-height: 1.5;
}
.referral-chips li a { text-decoration: none; font-weight: 600; }
.referral-chips li .muted { font-size: 0.75rem; font-variant-numeric: tabular-nums; }

/* Own branding (G18) */
.site-header-brands { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.org-logo { display: block; max-height: 52px; max-width: 220px; width: auto; height: auto; }
.brand-secondary { opacity: 0.85; }
.brand-secondary .brand-name { font-size: 1rem; }
.screen-brand { text-align: center; padding: 1rem 0 0; }
.screen-brand img { max-height: 80px; max-width: 320px; }
.brand-form { display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start; }
.brand-logo-field { display: flex; flex-direction: column; gap: 0.5rem; }
.brand-logo-field label { display: flex; flex-direction: column; gap: 0.35rem; margin: 0; }
.brand-logo-field label .muted { font-weight: 400; }
.brand-logo-field .media-source { margin: 0; }
.brand-logo-field > .muted { margin: -0.2rem 0 0; }
.brand-logo-preview { max-height: 64px; max-width: 240px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.brand-color-field input[type="color"] { width: 4rem; height: 2.4rem; padding: 2px; margin-left: 0.5rem; vertical-align: middle; }

/* Question import (G12) */
.import-help { margin: 0.5rem 0; }
.import-help ul { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.9rem; }
.import-help li { margin-bottom: 0.3rem; }

/* Question bank (G14): a toolbar of equal-height controls above the list */
.bank-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: color-mix(in srgb, var(--text) 2%, var(--card));
    border: 1px solid var(--border);
    border-radius: 10px;
}
.bank-filters label { flex: 1 1 10rem; margin: 0; font-size: 0.85rem; }
.bank-filters label.bank-filter-search { flex: 2 1 14rem; }
.bank-filters input[type="search"],
.bank-filters select { box-sizing: border-box; height: 2.5rem; margin-bottom: 0; }
.bank-filter-actions { display: flex; align-items: center; gap: 0.75rem; height: 2.5rem; white-space: nowrap; }
.bank-filter-actions button { margin: 0; }
.bank-filter-actions a { font-size: 0.875rem; }
.bank-preview { margin-top: 0.3rem; }
.bank-preview ol { margin: 0.4rem 0 0; padding-left: 1.3rem; font-size: 0.9rem; }
.bank-table td { vertical-align: top; }
.bank-table td.actions-cell { width: 1%; text-align: right; }
.bank-table td.actions-cell button { margin: 0; }

/* Audit log: the bank's filter toolbar laid out as an even grid, a dense log table */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); align-items: end; }
.audit-filters label { min-width: 0; }
.audit-filters .audit-filter-actions { grid-column: span 2; }
.audit-filters input[type="date"],
.audit-filters input[type="text"],
.audit-filters input[type="search"] {
    display: block; width: 100%; box-sizing: border-box; height: 2.5rem; margin: 0.3rem 0 0;
    padding: 0.45rem 0.75rem; border: 1px solid var(--input-border); border-radius: calc(8px * var(--radius-scale, 1));
    font: inherit; font-size: 0.95rem; font-weight: 400; background: var(--card); color: var(--text); box-shadow: var(--shadow-sm);
}
.audit-filters input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.audit-filters select { margin-top: 0.3rem; }
.audit-count { margin: 0; }
.audit-empty { margin: 0; }
.audit-table { min-width: 1040px; }
.audit-table td { vertical-align: top; }
.audit-table th.num, .audit-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-time span { display: block; }
.audit-account { min-width: 7rem; }
.audit-table-name { font-size: 0.8rem; white-space: nowrap; }
.audit-op, .audit-actor-type {
    display: inline-block; padding: 0.05rem 0.55rem; border-radius: 999px; white-space: nowrap;
    font-size: 0.75rem; font-weight: 600; line-height: 1.6;
}
.audit-op-insert { background: #dcfce7; color: #166534; }
.audit-op-update { background: #fef3c7; color: #92400e; }
.audit-op-delete { background: #fee2e2; color: #b91c1c; }
.audit-actor-type { background: color-mix(in srgb, var(--text) 6%, var(--card)); color: var(--text); }
.audit-actor { min-width: 12rem; max-width: 16rem; overflow-wrap: anywhere; }
.audit-actor > span { display: block; }
.audit-actor-email { font-size: 0.8rem; }
.audit-impersonating { font-size: 0.75rem; color: #92400e; }
.audit-changes-cell { width: 34%; min-width: 18rem; }
.audit-changes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; }
.audit-changes li { overflow-wrap: anywhere; }
.audit-changes code { font-size: 0.78rem; color: var(--muted); }
.audit-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.15rem 0.75rem; }
.audit-fields li { display: contents; }
.audit-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.audit-null { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); font-style: italic; }
.audit-arrow { color: var(--muted); }
.audit-row-details > summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); }
.audit-row-details[open] > summary { margin-bottom: 0.35rem; }

/* Drag & drop answers: order + match (G13) */
.dnd-hint { margin: 0.25rem 0 0.6rem; font-size: 0.9rem; }
.dnd-order { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dnd-item {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem;
    background: var(--card, #fff); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.06));
}
.dnd-item:focus-visible { outline: 3px solid var(--ring, var(--accent)); outline-offset: 2px; }
.dnd-item.dnd-dragging { opacity: 0.85; border-color: var(--accent); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18); }
.dnd-handle { cursor: grab; touch-action: none; user-select: none; font-size: 1.3rem; color: var(--muted); padding: 0.2rem 0.3rem; }
.dnd-dragging .dnd-handle { cursor: grabbing; }
.dnd-rank { font-weight: 700; color: var(--accent); min-width: 1.8rem; }
.dnd-body { flex: 1; display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.dnd-body .vote-image, .dnd-chip .vote-image { max-height: 56px; max-width: 80px; object-fit: contain; pointer-events: none; }
.dnd-move { display: flex; gap: 0.25rem; }
.dnd-move .icon-button { padding: 0.15rem 0.45rem; font-size: 0.8rem; }
.dnd-order .dnd-item:first-child .dnd-up, .dnd-order .dnd-item:last-child .dnd-down { visibility: hidden; }
.dnd-confirm { margin-top: 0.6rem; }

.dnd-match-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.dnd-match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0.75rem; align-items: center; }
.dnd-match-row .match-left { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.dnd-slot {
    min-height: 2.8rem; display: flex; align-items: center; padding: 0.25rem;
    border: 2px dashed var(--border); border-radius: 10px; background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.dnd-slot:empty::before { content: attr(data-empty-text); color: var(--muted); font-size: 0.85rem; padding: 0 0.5rem; }
.dnd-slot.dnd-slot-filled { border-style: solid; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dnd-picking .dnd-slot, .dnd-picking .dnd-pool { border-color: var(--accent); }
.dnd-over { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); }
.dnd-slot:focus-visible, .dnd-pool:focus-visible { outline: 3px solid var(--ring, var(--accent)); outline-offset: 2px; }
.dnd-pool {
    display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; padding: 0.6rem; min-height: 3.2rem;
    border: 2px dashed var(--border); border-radius: 10px;
}
.dnd-pool.dnd-pool-empty { min-height: 1.2rem; padding: 0.3rem; }
.dnd-chip {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.75rem; touch-action: none; user-select: none;
    background: var(--card, #fff); color: var(--text); border: 1px solid var(--border); border-radius: 999px; cursor: grab;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.06)); font: inherit;
}
.dnd-slot .dnd-chip { width: 100%; border-radius: 8px; }
.dnd-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.dnd-chip.dnd-dragging { position: relative; z-index: 20; cursor: grabbing; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2); }
@media (max-width: 560px) {
    .dnd-match-row { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* Content slides, presenter notes, phone remote (G10) */
.content-slide { font-size: 1.05rem; line-height: 1.6; }
.content-slide p { margin: 0 0 0.8rem; }
.live-screen-body .content-slide { font-size: 1.6rem; max-width: 60rem; margin: 0 auto; }
.content-video { position: relative; width: 100%; max-width: 960px; aspect-ratio: 16 / 9; margin: 0.75rem auto; }
.content-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 10px; background: #000; }
.presenter-notes {
    margin-top: 1rem; padding: 0.75rem 1rem; border-left: 4px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 0 8px 8px 0;
}
.presenter-notes h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.presenter-notes p { margin: 0; white-space: normal; }
.live-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.live-controls form { margin: 0; }
.live-controls button { margin: 0; }
.live-controls .live-abort-form { margin-left: auto; }
button.button-secondary.button-danger-outline { color: #b91c1c; border-color: #fca5a5; }
button.button-secondary.button-danger-outline:hover { background: #fef2f2; border-color: #dc2626; color: #991b1b; }
.remote-qr-card .qr-code { max-width: 260px; margin: 0.5rem auto; }
.remote-qr-link { text-align: center; word-break: break-all; }
.remote-body main { max-width: 480px; margin: 0 auto; padding: 0.75rem; }
.remote-poll { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.remote-status { margin: 0 0 0.5rem; }
.remote-current { font-size: 1.3rem; margin: 0.25rem 0 0.75rem; }
.remote-controls { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
.remote-controls form { margin: 0; }
.remote-button { width: 100%; padding: 1.1rem 1rem; font-size: 1.25rem; }
.remote-next { margin-top: 1rem; }
.remote-footer { text-align: center; margin-top: 1.5rem; }

/* Live identity: nicknames, avatars, roster + moderation (G25) */
.avatar-picker { border: 0; padding: 0; margin: 0.5rem 0 1rem; }
.avatar-picker legend { padding: 0; margin-bottom: 0.4rem; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.8rem, 1fr)); gap: 0.35rem; }
.avatar-choice { position: relative; display: block; margin: 0; cursor: pointer; }
.avatar-choice input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-choice span {
    display: flex; align-items: center; justify-content: center; height: 2.8rem; font-size: 1.6rem;
    border: 2px solid var(--input-border); border-radius: 10px; background: var(--card);
}
.avatar-choice input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.avatar-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.nickname-row { display: flex; gap: 0.5rem; align-items: center; }
.nickname-row input { flex: 1; }
.live-me-name { margin: 0 0 0.75rem; font-weight: 600; }
.roster-bubbles { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; padding: 0; margin: 1rem auto; max-width: 70rem; }
.roster-bubble {
    padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 1.15rem;
    background: color-mix(in srgb, var(--accent) 14%, var(--card)); animation: roster-pop 0.35s ease-out;
}
body.live-screen-body .roster-bubble { background: rgba(255, 255, 255, 0.12); color: #f1f5f9; font-size: 1.4rem; }
.roster-more { font-weight: 600; }
@keyframes roster-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .roster-bubble { animation: none; } }
.roster-card summary { cursor: pointer; font-weight: 600; }
.roster-list { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.roster-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-top: 1px solid var(--input-border); }
.roster-who { flex: 1 1 12rem; }
.roster-row form { display: flex; gap: 0.35rem; margin: 0; }
.roster-rename input { width: 10rem; margin: 0; }

/* Plans: locked controls, the super admin's plan card and matrix, the proof-of-work check */
.plan-lock { cursor: help; font-size: 0.9em; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: contents; }
.export-menu-items .export-locked { display: block; padding: 0.45rem 0.9rem; color: var(--muted); }
.plan-badge {
    display: inline-block; margin-left: 0.4rem; padding: 0.15rem 0.65rem; border-radius: 999px; vertical-align: middle;
    font-size: 0.8rem; font-weight: 600; letter-spacing: 0;
    background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--accent);
}
.plan-badge-trial { margin-left: 0.25rem; background: #fef3c7; color: #92400e; }
.plan-card h3 { margin: 1.5rem 0 0.6rem; }
.plan-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.plan-setting {
    padding: 0.9rem 1rem;
    background: color-mix(in srgb, var(--text) 2%, var(--card));
    border: 1px solid var(--border);
    border-radius: 10px;
}
.plan-card .plan-setting h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.plan-setting .muted { margin: 0.6rem 0 0; }
.plan-trial-status { flex: 1 1 12rem; font-size: 0.9rem; }
.plan-usage th.num, .plan-usage td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-cell { display: inline-flex; align-items: center; gap: 0.6rem; }
.usage-cell b { min-width: 4ch; font-weight: inherit; text-align: right; }
.usage-meter { display: inline-block; width: 6rem; height: 6px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--text) 10%, var(--card)); }
.usage-meter span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.plan-usage tr.is-high .usage-meter span { background: #d97706; }
.plan-usage tr.is-over .usage-meter span { background: #dc2626; }
.plan-usage tr.is-over td { color: #b91c1c; font-weight: 600; }
.plan-feature-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem 1.5rem; }
.plan-feature-groups h4 { margin: 0 0 0.35rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.plan-features { list-style: none; padding: 0; margin: 0; }
.plan-features li { padding: 0.15rem 0; font-size: 0.9rem; }
.plan-features li span { font-size: 0.85em; }
.plan-features li.is-off { color: var(--muted); }
.plan-matrix td:not(:first-child), .plan-matrix th:not(:first-child) { width: 8rem; text-align: center; }
.plan-matrix tr.plan-matrix-group th {
    padding-top: 0.9rem; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--muted); background: color-mix(in srgb, var(--text) 2%, var(--card));
}
.plan-key { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--muted); }
.challenge-box { margin: 0.5rem 0; }
.challenge-card { max-width: 32rem; }

/* Integrations: API tokens, copyable values, MCP config snippets */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.copy-row code, .config-snippet pre, .token-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    background: color-mix(in srgb, var(--text) 4%, var(--card));
    border: 1px solid var(--border);
    border-radius: 6px;
}
.copy-row code { padding: 0.35rem 0.6rem; overflow-wrap: anywhere; }
.copy-row button, .config-snippet-body > button { margin: 0; padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.new-token-box {
    margin: 0 0 1rem;
    padding: 0.9rem 1rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
}
.new-token-box p { margin: 0.5rem 0 0; font-size: 0.9rem; color: #166534; }
.new-token-box .copy-row { margin-top: 0.5rem; }
.token-value { padding: 0.4rem 0.7rem; font-weight: 600; overflow-wrap: anywhere; }
.integration-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1rem; align-items: center; margin: 1rem 0 0; }
.integration-facts dt { font-weight: 600; font-size: 0.9rem; }
.integration-facts dd { margin: 0; min-width: 0; }
.config-snippet { margin-top: 0.6rem; border: 1px solid var(--border); border-radius: 10px; }
.config-snippet > summary { padding: 0.6rem 0.9rem; font-weight: 600; cursor: pointer; }
.config-snippet-body { padding: 0 0.9rem 0.9rem; }
.config-snippet-body p { margin: 0 0 0.5rem; font-size: 0.9rem; }
.config-snippet pre { margin: 0 0 0.6rem; padding: 0.7rem 0.9rem; overflow-x: auto; }
@media (max-width: 640px) {
    .integration-facts { grid-template-columns: 1fr; }
}

/* Integrations: the AI provider of the account (or the install-wide default). */
.ai-integration .section-head .status-badge { margin-left: 0; }
.ai-integration .status-badge.status-inherited { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.ai-integration .method-box { margin: 0; }
.ai-integration-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; margin-top: 1rem; }
.ai-integration-fields[hidden] { display: none; }
.ai-integration-fields select { display: block; width: 100%; margin-top: 0.3rem; }
.ai-integration-fields .checkbox-label { grid-column: 1 / -1; }
.field-hint { display: block; margin-top: -0.2rem; font-size: 0.8rem; font-weight: 400; }
.ai-integration-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 1rem; }
.ai-integration-actions button { margin: 0; }
.ai-integration-meta { margin-left: auto; font-size: 0.8rem; }
@media (max-width: 600px) {
    .ai-integration-fields { grid-template-columns: 1fr; }
    .ai-integration-meta { flex-basis: 100%; margin-left: 0; }
}

.stage-step > span {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.95rem 0.4rem 0.5rem;
    border-radius: calc(9px * var(--radius-scale, 1));
}

.stage-step.is-active > span { background: var(--accent); color: var(--on-accent); }

/* --- AI builder: entry buttons, wizard, chat --- */
a.button.button-ai,
button.button-ai {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 55%, #db2777 120%);
    color: #fff;
    border: 0;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.28);
}

a.button.button-ai:hover,
button.button-ai:hover { filter: brightness(1.07); color: #fff; text-decoration: none; }

a.button.ai-icon-button { background: linear-gradient(135deg, #f5f3ff, #fdf2f8); }

.ai-spark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
    font-size: 1.6rem;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.18);
}

.ai-notice {
    margin: 0.75rem 0;
    padding: 0.7rem 1rem;
    border: 1px solid #fde68a;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.925rem;
}

.ai-wizard { max-width: 760px; margin: 0 auto; }

.ai-hero { text-align: center; margin: 0.5rem 0 1.5rem; }

.ai-hero h1 { margin: 0.75rem 0 0.35rem; }

.ai-hero p { max-width: 36rem; margin: 0 auto; }

.ai-wizard-card { padding: 1.5rem 1.75rem; }

.ai-wizard-progress { display: none; }

.ai-wizard-card.is-stepped .ai-wizard-progress {
    display: flex;
    justify-content: space-between;
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.ai-wizard-progress li {
    position: relative;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

/* The line between two dots. */
.ai-wizard-progress li + li::before {
    content: '';
    position: absolute;
    top: 0.85rem;
    right: 50%;
    left: -50%;
    height: 2px;
    background: var(--border);
}

.ai-wizard-progress li.is-done + li::before { background: var(--accent); }

.ai-progress-dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    border: 2px solid var(--input-border);
    background: var(--card);
}

.ai-wizard-progress .is-done .ai-progress-dot { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.ai-wizard-progress .is-current { color: var(--text); }

.ai-wizard-progress .is-current .ai-progress-dot { border-color: var(--accent); color: var(--accent); box-shadow: var(--ring); }

.ai-step h2 { margin: 0 0 1rem; font-size: 1.3rem; text-align: center; }

.ai-step + .ai-step { margin-top: 1.5rem; }

.ai-wizard-card.is-stepped .ai-step + .ai-step { margin-top: 0; }

.ai-step textarea { min-height: 6rem; }

.ai-wizard-nav {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.ai-wizard-nav #ai-back { margin-right: auto; }

.ai-wizard-nav button { margin: 0; }

.ai-theme-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }

.ai-theme-suggest[hidden] { display: none; }

.ai-theme-suggest-label { font-weight: 700; }

.ai-theme-suggest-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

button.ai-theme-chip {
    margin: 0;
    padding: 0.35rem 0.85rem;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: var(--page-bg, var(--bg));
    color: var(--text);
    font-size: 0.875rem;
    box-shadow: none;
}

button.ai-theme-chip.is-picked { background: var(--accent); color: var(--on-accent); }

.ai-wizard .theme-picker-groups { max-height: 26rem; overflow-y: auto; padding-right: 0.35rem; }

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

.ai-side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1rem; }

.ai-poll-card { margin: 0; padding: 1rem 1.1rem; }

.ai-poll-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.ai-poll-card-head h2 { margin: 0; font-size: 1rem; }

.ai-poll-card-head .icon-button { margin: 0; }

.ai-poll-card .summary-list { gap: 0.3rem 0.9rem; font-size: 0.9rem; }

.ai-poll-card .summary-list dt { font-size: 0.8rem; }

.ai-poll-card .status-badge { margin-left: 0; }

.ai-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.ai-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.9rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow-card);
}

.ai-stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--accent); }

.ai-stat-value.is-bumped { animation: ai-bump 0.6s ease; }

@keyframes ai-bump {
    40% { transform: scale(1.35); color: #db2777; }
}

.ai-stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-align: center; }

.ai-side-actions { display: flex; flex-direction: column; gap: 0.5rem; }

.ai-side-actions button,
.ai-side-actions .button { width: 100%; margin: 0; justify-content: center; text-align: center; }

.ai-side-hint { margin: 0; font-size: 0.8rem; text-align: center; }

.ai-chat {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    height: calc(100vh - 15rem);
    min-height: 32rem;
    overflow: hidden;
}

.ai-thread {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    overflow-y: auto;
}

.ai-empty { margin: auto; max-width: 34rem; text-align: center; }

.ai-empty[hidden] { display: none; }

.ai-empty h2 { margin: 0.9rem 0 0.35rem; }

.ai-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1.25rem; }

button.ai-suggestion {
    margin: 0;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

button.ai-suggestion:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }

.ai-msg { display: flex; align-items: flex-start; gap: 0.6rem; max-width: 85%; }

.ai-msg[hidden] { display: none; }

.ai-msg-user { align-self: flex-end; }

.ai-avatar {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #ede9fe, #fce7f3);
}

.ai-bubble {
    min-width: 0;
    padding: 0.7rem 1rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
    background: color-mix(in srgb, var(--accent) 5%, var(--card));
    overflow-wrap: anywhere;
}

.ai-msg-user .ai-bubble { border-color: var(--accent); border-bottom-right-radius: 4px; background: var(--accent); color: var(--on-accent); }

.ai-msg-assistant .ai-bubble { border-top-left-radius: 4px; }

.ai-msg.is-error .ai-bubble { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.ai-bubble p { margin: 0; }

.ai-text p + p,
.ai-text p + ul,
.ai-text ul + p,
.ai-text p + ol,
.ai-text ol + p { margin-top: 0.5rem; }

.ai-text ul,
.ai-text ol { margin: 0.25rem 0 0; padding-left: 1.25rem; }

.ai-files { list-style: none; margin: 0.4rem 0 0; padding: 0; font-size: 0.85rem; opacity: 0.9; }

.ai-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0.6rem 0 0; padding: 0; }

.ai-chip {
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 0.8rem;
    font-weight: 600;
}

.ai-card {
    margin: 0.75rem 0 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
}

.ai-card p { margin: 0 0 0.6rem; }

.ai-card.is-done { border-color: #bbf7d0; background: #f0fdf4; }

.ai-card button,
.ai-card .button { margin: 0; }

.ai-link-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.ai-card .ai-link-join { margin: 0.75rem 0 0; font-size: 0.9rem; overflow-wrap: anywhere; }

.ai-link-code { font-size: 1.05rem; letter-spacing: 0.05em; }

.ai-dots { display: inline-flex; gap: 3px; vertical-align: middle; }

.ai-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: ai-dot 1.2s infinite ease-in-out;
}

.ai-dots span:nth-child(2) { animation-delay: 0.15s; }

.ai-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-dot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-dots span,
    .ai-stat-value.is-bumped { animation: none; }
}

.ai-chat .ai-notice { margin: 0 1.5rem 0.75rem; }

.ai-composer { padding: 0.75rem 1rem 0.6rem; border-top: 1px solid var(--border); background: var(--card); }

.ai-attachments { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }

.ai-attachments:not(:empty) { margin-bottom: 0.5rem; }

.ai-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.3rem 0.2rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.8rem;
}

.ai-attachment.is-uploading { padding-right: 0.65rem; opacity: 0.55; }

button.ai-attachment-remove {
    margin: 0;
    padding: 0 0.35rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-size: 0.75rem;
}

.ai-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.35rem;
    border: 1px solid var(--input-border);
    border-radius: 14px;
    background: var(--card);
}

.ai-composer-row:focus-within { border-color: var(--accent); box-shadow: var(--ring); }

.ai-composer-row textarea {
    flex: 1;
    min-height: 2.5rem;
    margin: 0;
    padding: 0.55rem 0.4rem;
    border: 0;
    resize: none;
    background: transparent;
    box-shadow: none;
    font: inherit;
}

.ai-composer-row textarea:focus { outline: none; box-shadow: none; }

.ai-attach {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.15rem;
}

.ai-attach:hover { background: var(--bg); }

.ai-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; }

button.ai-send {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border-radius: 10px;
    font-size: 1rem;
}

.ai-composer-hint { margin: 0.4rem 0.25rem 0; font-size: 0.75rem; }

/* Wizard topic step: files for the AI to read before the first answer. */
.ai-start-files { margin: 0 0 0.75rem; }

.ai-file-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--input-border);
    border-radius: 10px;
    background: var(--bg);
    font-weight: 400;
    cursor: pointer;
}

.ai-file-drop:hover,
.ai-file-drop:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--card)); }

.ai-file-drop:focus-within { box-shadow: var(--ring); }

.ai-file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.ai-file-drop-icon { flex: none; font-size: 1.3rem; }

.ai-file-drop-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; font-size: 0.9rem; }

.ai-file-drop-text .muted { font-size: 0.8rem; }

.ai-start-files .ai-attachments { margin: 0.5rem 0 0; }

.ai-start-files .ai-attachments[hidden] { display: none; }

.ai-start-files .ai-attachment { padding-right: 0.65rem; }

/* --- Question drafting with AI: chat + the proposals waiting for the organizer --- */
.page-back-form { margin: 0 0 1rem; }

.page-back-form .link-button { font-size: 0.95rem; }

.ai-questions-head h1 { margin: 0 0 0.25rem; }

.ai-questions-head p { margin: 0 0 1.25rem; }

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

.ai-questions-layout .ai-chat { height: calc(100vh - 17rem); }

.ai-drafts {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 1rem 1.1rem;
    max-height: max(32rem, calc(100vh - 17rem));
    overflow: hidden;
}

.ai-drafts > form:not([hidden]) { display: flex; flex-direction: column; min-height: 0; }

.ai-drafts-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.ai-drafts-head h2 { margin: 0; font-size: 1.05rem; }

.ai-drafts-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--border);
    color: var(--muted);
    font-weight: 800;
}

.ai-drafts-count.has-drafts { background: var(--accent); color: var(--on-accent); }

.ai-drafts-count.is-bumped { animation: ai-bump 0.6s ease; }

.ai-drafts-empty { margin: 0.75rem 0 0; font-size: 0.9rem; }

.ai-drafts-summary { margin: 0.6rem 0 0.75rem; font-weight: 600; }

.ai-draft-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;
    margin: 0;
    padding: 0 0.2rem 0 0;
    list-style: none;
    overflow-y: auto;
}

.ai-draft {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.6rem 0.7rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ai-draft:has(.ai-draft-pick:checked) {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 4%, var(--card));
}

.ai-draft-pick { flex: none; width: 1.1rem; height: 1.1rem; margin: 0.15rem 0 0; accent-color: var(--accent); }

.ai-draft-body { display: flex; flex: 1; flex-direction: column; gap: 0.3rem; min-width: 0; cursor: pointer; font-weight: 400; }

.ai-draft-type { color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.ai-draft-title { font-size: 0.95rem; line-height: 1.35; overflow-wrap: anywhere; }

.ai-draft-media-wrap { display: block; }

.ai-draft-media { display: block; max-width: 100%; max-height: 7rem; border-radius: 6px; object-fit: cover; }

span.ai-draft-media.media-video-placeholder { width: 10rem; height: 5.6rem; }

.ai-draft-text { color: var(--muted); font-size: 0.85rem; white-space: pre-line; }

.ai-draft-options { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.ai-draft-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    max-width: 100%;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.ai-draft-option.is-correct { border-color: #86efac; background: #f0fdf4; color: #166534; }

.ai-draft-correct { font-weight: 800; }

.ai-draft-option-media { width: 1.5rem; height: 1.5rem; border-radius: 4px; object-fit: cover; }

button.ai-draft-drop { flex: none; width: 2rem; height: 2rem; margin: 0; padding: 0; font-size: 0.85rem; }

.ai-drafts-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; }

.ai-drafts-actions button { width: 100%; margin: 0; }

.ai-drafts-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 1100px) {
    .ai-questions-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 860px) {
    .ai-questions-layout { grid-template-columns: 1fr; }
    .ai-questions-layout .ai-chat { height: 60vh; min-height: 24rem; }
    .ai-drafts { position: static; max-height: none; }
}

@media (max-width: 860px) {
    .ai-layout { grid-template-columns: 1fr; }
    .ai-side { position: static; }
    .ai-chat { height: 75vh; }
}

/* AI pages on phones: a slim bar (counts, test, the side panel as a bottom sheet) and the chat filling the screen. */
.ai-mobile-bar,
.ai-sheet-backdrop { display: none; }

@media (max-width: 600px) {
    .ai-mobile-bar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0 -0.75rem 0.5rem;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid var(--border);
        background: var(--card);
        box-shadow: var(--shadow-sm);
    }
    .ai-mobile-bar button { margin: 0; padding: 0.55rem 0.8rem; font-size: 0.875rem; white-space: nowrap; }
    .ai-mobile-bar .ai-mobile-test { margin-left: auto; }
    .ai-mobile-stat {
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.3rem 0.65rem;
        border-radius: 999px;
        background: var(--bg);
        font-size: 0.9rem;
        font-weight: 700;
    }
    .ai-mobile-title { flex: 1; min-width: 0; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
    .ai-mobile-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.5rem;
        height: 1.5rem;
        padding: 0 0.4rem;
        border-radius: 999px;
        background: var(--border);
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 800;
    }
    .ai-mobile-badge.has-drafts { background: var(--on-accent); color: var(--accent); }
    .ai-mobile-badge.is-bumped { animation: ai-bump 0.6s ease; }

    .ai-sheet {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 60;
        max-height: 85dvh;
        margin: 0;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        background: var(--card);
        box-shadow: 0 -8px 30px rgb(15 23 42 / 0.2);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }
    .ai-sheet.is-open { transform: none; visibility: visible; transition: transform 0.25s ease; }
    .ai-drafts.ai-sheet { position: fixed; max-height: 85dvh; overflow: hidden; }
    .ai-sheet-backdrop { position: fixed; inset: 0; z-index: 59; display: block; background: rgb(15 23 42 / 0.45); }
    .ai-sheet-backdrop[hidden] { display: none; }

    .ai-questions-head { display: none; }
    .ai-layout,
    .ai-questions-layout { gap: 0; }
    .ai-chat,
    .ai-questions-layout .ai-chat { height: calc(100dvh - 4rem); min-height: 22rem; }
    .ai-thread { gap: 0.75rem; padding: 0.75rem; }
    .ai-msg { max-width: 100%; gap: 0.45rem; }
    .ai-msg-user { max-width: 88%; }
    .ai-avatar { width: 1.6rem; height: 1.6rem; font-size: 0.8rem; }
    .ai-bubble { padding: 0.6rem 0.8rem; }
    .ai-empty h2 { font-size: 1.15rem; }
    .ai-chat .ai-notice { margin: 0 0.75rem 0.5rem; }
    .ai-composer { padding: 0.5rem; }
    .ai-composer-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-sheet,
    .ai-sheet.is-open { transition: none; }
}

/* --- Phones: touch-sized controls, nothing wider than the screen. Desktop is untouched (all inside max-width queries). --- */
@media (max-width: 600px) {
    /* 16px fields: iOS Safari zooms into smaller ones on focus. */
    input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"], input[type="url"],
    input[type="number"]:not(.token-count), input[type="date"], input[type="time"], input[type="datetime-local"],
    select, textarea { font-size: 1rem; }

    /* ~44px touch targets */
    button, a.button { padding-top: 0.75rem; padding-bottom: 0.75rem; }
    a.icon-button, button.icon-button { width: 2.75rem; height: 2.75rem; }
    .header-menu-toggle { height: 2.75rem; }
    .action-menu-toggle { padding-top: 0.75rem; padding-bottom: 0.75rem; }
    .action-menu .header-menu-panel { left: 0; right: auto; }
    .action-menu .header-menu-item { min-height: 2.75rem; }

    /* Build › Test › Run: three equal steps across the screen, without their hints. */
    .stage-steps ol { width: 100%; flex-wrap: nowrap; }
    .stage-step { flex: 1 1 0; min-width: 0; }
    .stage-step a,
    .stage-step > span { flex: 1; justify-content: center; padding: 0.55rem 0.4rem; }
    .stage-step-hint { display: none; }
    .header-menu-panel { max-width: calc(100vw - 1.5rem); }
    .pager button, .pager a, .pager span.pager-arrow { min-width: 2.75rem; min-height: 2.75rem; }
    .token-stepper button { width: 2.75rem; height: 2.75rem; }
    .scale-option { min-width: 2.75rem; height: 2.75rem; }
    .schedule-choice-face { min-height: 2.75rem; }
    .drag-handle { padding: 0.6rem 0.45rem; margin: -0.6rem 0.15rem -0.6rem -0.45rem; }
    .theme-current .button-secondary,
    .delete-button:not(.icon-button),
    button.schedule-finalize-button { padding-top: 0.75rem; padding-bottom: 0.75rem; }
    .info-button { width: 1.75rem; height: 1.75rem; }
    .section-toggle { padding: 0.55rem 0; }

    .section-actions { flex: 1 1 100%; flex-wrap: wrap; margin-left: 0; }
    .modal-actions { flex-wrap: wrap; }
    .export-menu-items { max-width: calc(100vw - 1.5rem); }
    .gdpr-inline select { flex-basis: 100%; min-width: 0; }

    .existing-option-row,
    .new-option-row { flex-wrap: wrap; }
    .existing-option-row input[type="text"],
    .new-option-row input[type="text"] { min-width: 0; flex-basis: 8rem; }

    /* Question list: every question (and group header) becomes a card row. */
    .question-table thead { display: none; }
    .question-table,
    .question-table tbody,
    .question-table td { display: block; }
    .question-table td { padding: 0; border: 0; }
    .question-table tr[data-drag-item],
    .question-table tbody > tr:not(.question-group-header) {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 0.35rem 0.6rem;
        align-items: baseline;
        padding: 0.75rem 0.85rem;
        border-bottom: 1px solid var(--border);
    }
    .question-table td:nth-child(3) { grid-column: 2; }
    .question-table td.actions-cell {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.4rem;
    }
    .question-table .question-grouped-row { padding-left: 1.75rem; }
    .question-table .question-grouped-row td:nth-child(2) { padding-left: 0; }
    .question-table tr.question-group-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.4rem 0.6rem;
        padding: 0.6rem 0.85rem;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--accent) 8%, var(--card));
    }
    .question-table tr.question-group-header td { background: none; }
    .question-table tr.question-group-header td.actions-cell { display: flex; gap: 0.4rem; margin-left: auto; }

    /* Invitations: one card per invitation, labelled fields. */
    .invitation-table thead { display: none; }
    .invitation-table,
    .invitation-table tbody,
    .invitation-table td { display: block; }
    .invitation-table td { padding: 0; border: 0; white-space: normal; }
    .invitation-table tbody > tr:not(.team-group-header):not(.team-pager-row) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "type type" "pin link" "created required" "actions actions";
        gap: 0.6rem 0.75rem;
        padding: 0.85rem;
        border-bottom: 1px solid var(--border);
    }
    .invitation-table td:nth-child(1) { grid-area: created; }
    .invitation-table td:nth-child(2) { grid-area: pin; }
    .invitation-table td:nth-child(3) { grid-area: type; font-weight: 600; }
    .invitation-table td:nth-child(4) { grid-area: required; }
    .invitation-table td:nth-child(5) { grid-area: link; }
    .invitation-table td.actions-cell { grid-area: actions; display: flex; justify-content: flex-end; gap: 0.4rem; }
    .invitation-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--muted);
    }
    .invitation-table td:nth-child(3)::before { display: none; }
    .invitation-table .team-grouped-row td:first-child { padding-left: 0; }
    .invitation-table tr.team-group-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.4rem 0.6rem;
        padding: 0.6rem 0.85rem;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--accent) 8%, var(--card));
    }
    .invitation-table tr.team-group-header td { background: none; }
    .invitation-table tr.team-group-header td.actions-cell { display: flex; gap: 0.4rem; margin-left: auto; }
    .invitation-table tr.team-pager-row { display: block; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); }
    .invitation-table tr.team-pager-row td { padding-left: 0; }

    .team-emoji > summary { width: 2.75rem; height: 2.75rem; }
    .launch-actions > *, .launch-actions form button { flex: 1 1 100%; width: 100%; }
    .page-tools-links { width: 100%; }
    .page-tools-links .tool-link { flex: 1 1 auto; text-align: center; }
    .live-match { grid-template-columns: 1fr; }
    .test-run-bar { padding: 0.5rem 0.75rem; }
    .test-run-actions { width: 100%; }
    .test-run-actions > * { flex: 1 1 auto; }
    .test-run-actions button, .test-run-actions .button { width: 100%; }
    .in-test-frame .test-run-actions { width: auto; }
    .test-visual-bar:has(.test-run-modal-actions) { flex-wrap: wrap; }
    .test-run-modal-actions { width: 100%; }
    .test-run-modal-actions .test-visual-close { flex: 1 1 auto; }
    button.team-emoji-option { height: 2.75rem; }
}

@media (max-width: 480px) {
    .brand-suffix { display: none; }
    .brand-logo { width: 40px; height: 40px; }

    /* Poll list: the action icons go under the title instead of squeezing it. */
    .poll-card { flex-wrap: wrap; }
    .poll-card-info { flex: 1 1 100%; }
}

@media print {
    body { background: #fff !important; }
    .site-header, .site-footer, .powered-by, .poll-nav, .export-bar, .pager, .pager-status, .info-button,
    .votes-link, .sort-arrow, .cta-card, form, button { display: none !important; }
    main { max-width: none; padding: 0; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .question-results, .result-card, tr { break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
    .table-wrap { overflow: visible; }
}
