/* ==========================================================================
   KTV Queue - stylesheet
   1. Tokens & base          5. Toasts & modal       9. Login & error pages
   2. Layout helpers         6. Guest page          10. Motion
   3. Buttons & forms        7. KTV display
   4. Cards & list items     8. Admin panel
   ========================================================================== */

/* 1. Tokens & base ------------------------------------------------------- */

:root {
    --bg: #08080f;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-solid: #12121d;
    --surface-raised: #191927;
    --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text: #f5f5fa;
    --text-muted: #a3a3bb;
    --text-dim: #6e6e88;

    --pink: #ff3d7f;
    --violet: #8b5cf6;
    --cyan: #22d3ee;
    --green: #34d399;
    --amber: #fbbf24;
    --red: #f43f5e;

    --gradient: linear-gradient(135deg, var(--pink) 0%, var(--violet) 100%);
    --glow: 0 12px 36px -12px rgba(255, 61, 127, 0.6);
    --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-full: 999px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1000px 600px at 10% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
        radial-gradient(900px 500px at 110% 0%, rgba(255, 61, 127, 0.14), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

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

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

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

kbd {
    display: inline-block;
    padding: 1px 7px;
    font-family: var(--font);
    font-size: 0.8em;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface);
}

.icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.2em;
}

.icon-inline {
    width: 1em;
    height: 1em;
}

.muted {
    color: var(--text-muted);
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* 2. Layout helpers ------------------------------------------------------ */

.center-screen {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--gradient);
    box-shadow: var(--glow);
    color: #fff;
}

.brand-mark .icon {
    width: 20px;
    height: 20px;
}

.brand-mark {
    transition: transform 0.2s var(--ease);
}

.brand:hover .brand-mark {
    transform: scale(1.06);
}

.brand-mark-lg {
    width: 64px;
    height: 64px;
    border-radius: 20px;
}

.brand-mark-lg .icon {
    width: 32px;
    height: 32px;
}

.live-indicator {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.22);
    border-radius: var(--radius-full);
    background: rgba(52, 211, 153, 0.07);
}

/* "Live" is reassurance, not news: the dot is what the eye needs to find */
.live-label {
    color: var(--text-muted);
}

.live-indicator.is-offline .live-label {
    color: inherit;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 0 currentColor;
    animation: pulse 2s infinite;
}

.live-indicator.is-offline {
    color: var(--amber);
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.08);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--pink);
}

.count-badge {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 24px;
    padding: 0 9px;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    background: var(--surface-hover);
    color: var(--text-muted);
}

/* 3. Buttons & forms ----------------------------------------------------- */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    cursor: pointer;
    transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s, opacity 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
    background: var(--surface-hover);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

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

.btn-primary {
    color: #fff;
    background: var(--gradient);
    box-shadow: var(--glow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gradient);
    box-shadow: 0 16px 40px -12px rgba(255, 61, 127, 0.75);
    filter: brightness(1.08);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
}

.btn-danger {
    color: #fff;
    background: var(--red);
}

.btn-danger:hover:not(:disabled) {
    background: #e11d48;
}

.btn-danger-ghost {
    color: #fda4af;
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.25);
}

.btn-danger-ghost:hover:not(:disabled) {
    background: rgba(244, 63, 94, 0.16);
}

.btn-sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    min-height: 54px;
    padding: 14px 24px;
    font-size: 1.05rem;
    border-radius: var(--radius);
}

.btn-block {
    width: 100%;
}

.btn.is-loading {
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text-muted);
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-hover);
}

.icon-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.icon-btn-danger:hover:not(:disabled) {
    color: var(--red);
    background: rgba(244, 63, 94, 0.12);
}

.icon-btn.is-loading .icon {
    animation: spin 0.8s linear infinite;
}

.form {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

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

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.input {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    font: inherit;
    /* 16px+ prevents iOS from zooming into inputs */
    font-size: 1rem;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-wrap .input {
    padding-left: 46px;
}

.input::placeholder {
    color: var(--text-dim);
}

.input:focus {
    outline: none;
    border-color: var(--pink);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 61, 127, 0.15);
}

.input[aria-invalid='true'] {
    border-color: var(--red);
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.12);
}

.input.has-action {
    padding-right: 84px;
}

.input-sm {
    min-height: 42px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.input-action {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    border: 0;
    border-radius: 10px;
    background: var(--surface-hover);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.input-action:hover {
    background: var(--border-strong);
}

/* Icon-only action (show / hide a password): a square button, not a label */
.input-action-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
}

.input-action-icon .icon {
    width: 19px;
    height: 19px;
    vertical-align: 0;
}

.input-action-icon[aria-pressed='true'] {
    color: var(--pink);
}

.field-error {
    min-height: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: #fb7185;
}

.field-error:empty {
    display: none;
}

.field-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--amber);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    cursor: pointer;
}

.checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--pink);
}

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    font-size: 0.92rem;
    border-radius: var(--radius-sm);
}

.alert-error {
    color: #fecdd3;
    border: 1px solid rgba(244, 63, 94, 0.3);
    background: rgba(244, 63, 94, 0.1);
}

/* 4. Cards & list items -------------------------------------------------- */

.card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.card-head .card-title {
    margin-bottom: 0;
}

.card-hint {
    margin-bottom: 12px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    background: var(--surface-hover);
}

.pill-playing {
    color: #fff;
    background: var(--gradient);
}

.pill-queued {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.14);
}

.pill-completed {
    color: var(--green);
    background: rgba(52, 211, 153, 0.12);
}

.pill-skipped {
    color: var(--amber);
    background: rgba(251, 191, 36, 0.12);
}

.pill-cancelled {
    color: var(--text-dim);
}

/* Animated "now playing" equalizer */
.eq {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.eq i {
    width: 3px;
    height: 100%;
    border-radius: 2px;
    background: currentColor;
    transform-origin: bottom;
    animation: eq 0.9s ease-in-out infinite;
}

.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.eq i:nth-child(4) { animation-delay: -0.15s; }

.eq.is-paused i,
.is-paused .eq i,
.is-idle .eq i,
.is-empty .eq i {
    animation: none;
    transform: scaleY(0.3);
}

.thumb-frame {
    position: relative;
    flex-shrink: 0;
    width: 64px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-raised);
}

.thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-lg {
    width: 112px;
    border-radius: 12px;
}

.thumb-xl {
    width: 100%;
    border-radius: var(--radius);
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 36px 16px;
    text-align: center;
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
    border-radius: 50%;
    color: var(--pink);
    background: rgba(255, 61, 127, 0.1);
}

.empty-state-icon .icon {
    width: 28px;
    height: 28px;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
}

.empty-state-text {
    color: var(--text-muted);
}

.skeleton-list {
    display: grid;
    gap: 10px;
}

.skeleton {
    height: 64px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hover) 50%, var(--surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

/* 5. Toasts & modal ------------------------------------------------------ */

.toast-stack {
    position: fixed;
    z-index: 100;
    top: 16px;
    right: 16px;
    left: 16px;
    display: grid;
    justify-items: end;
    gap: 10px;
    pointer-events: none;
}

/* On larger screens, keep toasts clear of the top navigation. */
@media (min-width: 768px) {
    .toast-stack {
        top: auto;
        bottom: 24px;
        left: auto;
        width: 380px;
    }
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: min(100%, 380px);
    padding: 14px 14px 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: rgba(22, 22, 36, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.toast.is-visible {
    opacity: 1;
    transform: none;
}

.toast-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.toast-success .toast-icon { color: var(--green); background: rgba(52, 211, 153, 0.14); }
.toast-error .toast-icon { color: var(--red); background: rgba(244, 63, 94, 0.14); }
.toast-warning .toast-icon { color: var(--amber); background: rgba(251, 191, 36, 0.14); }
.toast-info .toast-icon { color: var(--cyan); background: rgba(34, 211, 238, 0.14); }

.toast-body {
    display: grid;
    flex: 1;
    gap: 2px;
    padding-top: 3px;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.toast-body strong {
    color: var(--text);
}

.toast-close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--text-dim);
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.toast-close:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.modal-backdrop {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(4, 4, 10, 0.7);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-backdrop.is-visible {
    opacity: 1;
}

.modal {
    display: grid;
    gap: 14px;
    width: min(100%, 420px);
    padding: 24px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    transform: scale(0.96);
    transition: transform 0.2s var(--ease);
}

.modal-backdrop.is-visible .modal {
    transform: none;
}

.modal-title {
    font-size: 1.25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

/* 6. Guest page ---------------------------------------------------------- */

.guest {
    display: flex;
    flex-direction: column;
    width: min(100%, 560px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/*
 * Sticky: on a phone the singer scrolls through the queue, and the room they
 * are posting to - and whether the page is still live - should not scroll away
 * with it. The negative margin lets the blur reach the gutter on both sides.
 */
.guest-header {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 -16px 2px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 8, 15, 0.78);
    backdrop-filter: blur(14px);
}

.guest-main {
    display: grid;
    flex: 1;
    align-content: start;
    gap: 20px;
}

.add-title {
    font-size: 1.75rem;
    margin-bottom: 6px;
}

.add-intro {
    margin-bottom: 22px;
}

.link-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: var(--radius);
    background: rgba(52, 211, 153, 0.06);
    animation: rise 0.25s var(--ease);
}

.link-preview .thumb-frame {
    width: 96px;
}

.link-preview-body {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.link-preview-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--green);
}

.link-preview-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.92rem;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.yt-search {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-strong);
}

.yt-search-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.yt-search-label .icon {
    color: #ff4e45;
}

.yt-search-row {
    display: flex;
    gap: 8px;
}

.yt-search-row .btn {
    min-height: 42px;
}

.success-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    text-align: center;
    border-color: rgba(52, 211, 153, 0.3);
    animation: rise 0.35s var(--ease);
}

.success-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #34d399, #10b981);
    box-shadow: 0 12px 36px -10px rgba(52, 211, 153, 0.7);
    animation: pop 0.45s var(--ease);
}

.success-icon .icon {
    width: 36px;
    height: 36px;
    stroke-width: 3;
}

.success-title {
    font-size: 1.5rem;
}

.success-details {
    display: grid;
    gap: 12px;
    width: 100%;
    margin: 0;
}

.success-details div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    text-align: right;
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.success-details dt {
    color: var(--text-muted);
    text-align: left;
}

.success-details dd {
    margin: 0;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

#success-position {
    font-family: var(--font-display);
    font-size: 1.4rem;
    line-height: 1.1;
}

.queue-panel {
    display: grid;
    gap: 14px;
    margin-top: 6px;
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

.now-playing-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(255, 61, 127, 0.35);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(255, 61, 127, 0.14), rgba(139, 92, 246, 0.1));
    box-shadow: var(--glow);
}

.now-playing-body {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.now-playing-singer {
    font-family: var(--font-display);
    font-size: 1.35rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.now-playing-title,
.song-title {
    overflow: hidden;
    font-size: 0.88rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.song-list {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.song-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    animation: rise 0.3s var(--ease) both;
}

.song-row.is-mine,
.now-playing-card.is-mine {
    border-color: rgba(34, 211, 238, 0.45);
}

.song-num {
    width: 26px;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-dim);
    text-align: center;
}

.song-info {
    display: grid;
    min-width: 0;
}

.song-singer {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-wrap: anywhere;
}

.you-badge {
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cyan);
    border-radius: var(--radius-full);
    background: rgba(34, 211, 238, 0.12);
}

.queue-note {
    margin-top: 12px;
    padding: 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

.guest-footer {
    padding-top: 28px;
    text-align: center;
}

.guest-footer a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-dim);
    text-decoration: none;
}

.guest-footer a:hover {
    color: var(--text-muted);
}

/* 7. KTV display --------------------------------------------------------- */

.page-ktv {
    overflow: hidden;
    background: #05050a;
}

.ktv {
    --stage-pad: clamp(12px, 1.4vw, 28px);
    position: fixed;
    inset: 0;
    /*
     * One full-height row: the picture and the sidebar both run from the top
     * of the window to the bottom, so no strip of background is left over.
     */
    /*
     * The picture is 16:9, so its height is capped by the width it is given.
     * Hand the sidebar only what the picture cannot use: on a wide screen that
     * leaves the video at full height, and on a 16:9 screen the sidebar falls
     * back to its minimum so the video grows as tall as it can.
     */
    --video-height: calc(100vh - var(--stage-pad) * 2);
    --side-width: clamp(
        320px,
        calc(100vw - var(--video-height) * 16 / 9 - var(--stage-pad) * 3),
        520px
    );
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-width);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--stage-pad);
    padding: var(--stage-pad);
    background:
        radial-gradient(1200px 700px at 30% 110%, rgba(139, 92, 246, 0.2), transparent 60%),
        radial-gradient(900px 600px at 0% -10%, rgba(255, 61, 127, 0.16), transparent 60%),
        #05050a;
}

.ktv:not(.show-controls) {
    cursor: none;
}

.ktv-stage {
    display: grid;
    /* Fill the row's height, stay centred across its width. */
    place-items: stretch center;
    min-width: 0;
    min-height: 0;
}

/*
 * The card is never wider than a 16:9 picture of the window's height, and it
 * takes all of that height. Where the screen is too narrow for that width, the
 * card keeps the leftover height rather than leaving it empty above and below:
 * the player letterboxes the picture inside it and the idle screen fills it.
 */
.ktv-video {
    position: relative;
    width: min(100%, calc(var(--video-height) * 16 / 9));
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: #000;
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--border);
}

.ktv-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.ktv-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Idle screen (no songs) */
.ktv-idle {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: clamp(8px, 1vw, 16px);
    padding: 24px;
    text-align: center;
    background:
        radial-gradient(circle at 50% 35%, rgba(255, 61, 127, 0.22), transparent 55%),
        linear-gradient(160deg, #13101f, #07070d);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s;
}

.ktv.is-idle .ktv-idle {
    opacity: 1;
    visibility: visible;
}

.ktv-idle-mic {
    display: grid;
    place-items: center;
    width: clamp(80px, 9vw, 160px);
    height: clamp(80px, 9vw, 160px);
    margin-bottom: 1vw;
    border-radius: 50%;
    color: #fff;
    background: var(--gradient);
    box-shadow: 0 0 0 16px rgba(255, 61, 127, 0.08), 0 0 80px rgba(255, 61, 127, 0.5);
    animation: float 4s ease-in-out infinite;
}

.ktv-idle-mic .icon {
    width: 45%;
    height: 45%;
}

.ktv-idle-title {
    font-size: clamp(1.8rem, 3.4vw, 4rem);
}

.ktv-idle-text {
    font-size: clamp(1.1rem, 1.8vw, 2.2rem);
    color: var(--text-muted);
}

.ktv-idle-join {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 2vw;
    padding: 16px 24px 16px 16px;
    font: inherit;
    color: inherit;
    text-align: left;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.ktv-idle-join:hover,
.ktv-join:hover {
    border-color: rgba(255, 61, 127, 0.55);
    background: rgba(255, 61, 127, 0.1);
}

.ktv-idle-join:active,
.ktv-join:active {
    transform: scale(0.99);
}

.ktv-idle-join .qr {
    width: clamp(90px, 9vw, 170px);
}

.qr {
    flex-shrink: 0;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    image-rendering: pixelated;
}

.ktv-join-label {
    display: block;
    font-size: clamp(0.8rem, 1vw, 1.15rem);
    color: var(--text-muted);
}

.ktv-join-url {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 1.6vw, 2rem);
    line-height: 1.15;
    overflow-wrap: break-word;
}

.ktv-join-code {
    display: block;
    margin-top: 4px;
    font-size: clamp(0.9rem, 1.2vw, 1.4rem);
    color: var(--text-muted);
}

.ktv-join-code strong {
    font-family: var(--font-display);
    letter-spacing: 0.12em;
    color: var(--text);
}

/* "Now singing" splash when a song starts */
.ktv-splash {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.6vw;
    padding: 24px;
    text-align: center;
    background: radial-gradient(ellipse at center, rgba(8, 8, 15, 0.88) 0%, rgba(8, 8, 15, 0.55) 60%, transparent 100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.6s, visibility 0.6s;
}

.ktv-splash.is-visible {
    opacity: 1;
    visibility: visible;
}

.ktv-splash-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(0.9rem, 1.4vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--pink);
}

.ktv-splash-singer {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 10rem);
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 8px 40px rgba(255, 61, 127, 0.45));
}

.ktv-splash.is-visible .ktv-splash-singer {
    animation: splash-in 0.8s var(--ease) both;
}

.ktv-splash-title {
    max-width: 80%;
    font-size: clamp(1.1rem, 2vw, 2.6rem);
    color: var(--text);
}

/* "Get ready, up next" banner near the end of a song */
.ktv-banner {
    position: absolute;
    z-index: 4;
    top: clamp(12px, 1.5vw, 28px);
    left: 50%;
    display: flex;
    align-items: baseline;
    gap: 14px;
    max-width: 90%;
    padding: 12px 24px;
    white-space: nowrap;
    border: 1px solid rgba(255, 61, 127, 0.5);
    border-radius: var(--radius-full);
    background: rgba(12, 10, 22, 0.9);
    box-shadow: var(--glow);
    opacity: 0;
    transform: translate(-50%, -20px);
    transition: opacity 0.4s, transform 0.4s var(--ease);
    pointer-events: none;
}

.ktv-banner.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.ktv-banner-label {
    font-size: clamp(0.75rem, 1vw, 1.1rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pink);
}

.ktv-banner-singer {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 1.8vw, 2.2rem);
    text-transform: uppercase;
}

.ktv-banner-title {
    overflow: hidden;
    font-size: clamp(0.9rem, 1.2vw, 1.5rem);
    color: var(--text-muted);
    text-overflow: ellipsis;
}

.ktv-error,
.ktv-paused {
    position: absolute;
    z-index: 4;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    font-size: clamp(1rem, 1.3vw, 1.6rem);
    border-radius: var(--radius-lg);
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.ktv-error {
    bottom: clamp(16px, 3vw, 48px);
    max-width: 90%;
    color: #fecdd3;
    border: 1px solid rgba(244, 63, 94, 0.5);
    background: rgba(40, 8, 18, 0.92);
}

.ktv-error div {
    display: grid;
}

.ktv-error span {
    font-size: 0.8em;
    opacity: 0.8;
}

.ktv-error .icon {
    width: 1.6em;
    height: 1.6em;
    color: var(--red);
}

.ktv.has-error .ktv-error,
.ktv.is-paused .ktv-paused {
    opacity: 1;
    visibility: visible;
}

.ktv-paused {
    top: 50%;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border-strong);
    background: rgba(8, 8, 15, 0.85);
    transform: translate(-50%, -50%);
}

/* Side panel */
.ktv-side {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 1.6vw, 28px);
    min-height: 0;
}

/*
 * The sidebar is now as narrow as the picture leaves it, which the viewport
 * says nothing about. Where container queries exist, size its text from the
 * sidebar's own width so nothing has to wrap mid-word; the vw-based sizes
 * above stay as the fallback.
 */
@supports (container-type: inline-size) {
    .ktv-side {
        container-type: inline-size;
    }

    /*
     * Scoped to the sidebar: the idle screen has a join box of its own, which
     * is sized by the picture rather than by this container.
     */
    .ktv-side .ktv-now-singer {
        font-size: clamp(1.8rem, 15cqw, 4.6rem);
    }

    .ktv-side .ktv-now-title {
        font-size: clamp(0.95rem, 6cqw, 1.8rem);
    }

    .ktv-side .ktv-join-label {
        font-size: clamp(0.75rem, 4.5cqw, 1.15rem);
    }

    .ktv-side .ktv-join-url {
        font-size: clamp(0.95rem, 5.6cqw, 2rem);
    }

    .ktv-side .ktv-join-code {
        font-size: clamp(0.85rem, 5.5cqw, 1.4rem);
    }

    .ktv-side .ktv-join .qr {
        width: clamp(68px, 23cqw, 120px);
    }
}

.ktv-now {
    position: relative;
    display: grid;
    gap: 0.4vw;
    padding: clamp(16px, 1.6vw, 32px);
    overflow: hidden;
    border: 1px solid rgba(255, 61, 127, 0.35);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(255, 61, 127, 0.18), rgba(139, 92, 246, 0.12));
    box-shadow: var(--glow);
    /* Own stacking context, so the sheen below sits over the card's
       background but under the singer's name. */
    isolation: isolate;
    animation: now-breathe 4.5s ease-in-out infinite;
}

/* A light sweeping across the card, like a spotlight passing the stage. */
.ktv-now::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -60% -20%;
    background: linear-gradient(
        115deg,
        transparent 38%,
        rgba(255, 255, 255, 0.11) 50%,
        transparent 62%
    );
    animation: now-sheen 6s ease-in-out infinite;
}

/* Nobody singing: calm the card down instead of stopping it dead. */
.is-idle .ktv-now {
    animation-duration: 8s;
}

.is-idle .ktv-now::before {
    animation-duration: 9s;
    opacity: 0.5;
}

/* The bars stay near the floor, but keep a slow standby sway. */
.is-idle .ktv-now .eq i {
    animation: eq-idle 2.6s ease-in-out infinite;
    opacity: 0.6;
}

.ktv-now .eyebrow,
.ktv-next .eyebrow {
    font-size: clamp(0.75rem, 0.9vw, 1.1rem);
}

.ktv-now-singer {
    font-size: clamp(2rem, 3.4vw, 4.6rem);
    font-weight: 800;
    line-height: 1.05;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

/* The "-" placeholder breathes while we wait for a first song. */
.is-idle .ktv-now-singer {
    animation: now-wait 3s ease-in-out infinite;
}

/* A new song slides its name and title in. */
.ktv-now.is-swapping .ktv-now-singer {
    animation: now-swap 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.ktv-now.is-swapping .ktv-now-title {
    animation: now-swap 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) 0.09s both;
}

.ktv-now .eyebrow,
.ktv-next .eyebrow {
    font-size: clamp(0.75rem, 0.9vw, 1.1rem);
}

.ktv-now-singer {
    font-size: clamp(2rem, 3.4vw, 4.6rem);
    font-weight: 800;
    line-height: 1.05;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.ktv-now-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: clamp(1rem, 1.35vw, 1.8rem);
    color: var(--text-muted);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Waiting dots that count themselves up, without shifting the text. */
.is-idle .ktv-now-title::after {
    content: '...';
    display: inline-block;
    width: 0;
    overflow: hidden;
    vertical-align: bottom;
    animation: now-dots 1.8s steps(4, jump-none) infinite;
}

.ktv-next {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.ktv-next-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.ktv-next .eyebrow {
    color: var(--text-muted);
}

.ktv-next-list {
    display: grid;
    align-content: start;
    gap: clamp(6px, 0.6vw, 12px);
    margin: 0;
    padding: 0;
    overflow: hidden;
    list-style: none;
}

.ktv-next-item {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 20px);
    padding: clamp(10px, 0.9vw, 18px) clamp(12px, 1vw, 20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    animation: rise 0.4s var(--ease) both;
}

.ktv-next-item:first-child {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.1);
}

.ktv-next-num {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 1.6vw, 2.2rem);
    font-weight: 800;
    color: var(--violet);
}

.ktv-next-info {
    display: grid;
    min-width: 0;
}

.ktv-next-singer {
    overflow: hidden;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 1.5vw, 2rem);
    text-transform: uppercase;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ktv-next-title {
    overflow: hidden;
    font-size: clamp(0.85rem, 1vw, 1.3rem);
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ktv-next-empty,
.ktv-next-more {
    padding: 14px;
    font-size: clamp(0.9rem, 1vw, 1.3rem);
    color: var(--text-dim);
    text-align: center;
}

.ktv-next-empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

.ktv-join {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 14px;
    font: inherit;
    color: inherit;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

/*
 * Tapping a join box blows the QR code up in the middle of the screen: the
 * one in the side panel is too small to scan from across the room.
 */
.ktv-qr {
    position: fixed;
    z-index: 85;
    inset: 0;
    display: grid;
    /* A real column, so the card's max-width has the screen to measure against */
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    padding: 5vmin;
    background: rgba(4, 4, 10, 0.85);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.25s;
    cursor: pointer;
}

/* display: grid above would otherwise beat the hidden attribute */
.ktv-qr[hidden] {
    display: none;
}

.ktv-qr.is-visible {
    opacity: 1;
}

.ktv-qr-card {
    display: grid;
    justify-items: center;
    gap: clamp(8px, 1.4vmin, 16px);
    max-width: 100%;
    padding: clamp(20px, 3vmin, 40px);
    text-align: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    transform: scale(0.92);
    transition: transform 0.25s var(--ease);
}

.ktv-qr.is-visible .ktv-qr-card {
    transform: none;
}

/*
 * Drawn at roughly this size (about 600px), so the squares land on whole
 * pixels. A QR that has been scaled to an odd size still scans, but a crisp
 * one scans from further away.
 */
.ktv-qr-card .qr {
    width: min(58vmin, 620px);
    padding: clamp(8px, 1.2vmin, 16px);
}

/* A long join address must wrap rather than widen the card off a phone screen */
.ktv-qr-card .ktv-join-url {
    max-width: 100%;
    font-size: clamp(1.2rem, 2.6vmin, 2.2rem);
    overflow-wrap: anywhere;
}

.ktv-qr-card .ktv-join-code {
    font-size: clamp(1rem, 2vmin, 1.6rem);
}

.ktv-qr-hint {
    font-size: clamp(0.75rem, 1.5vmin, 1rem);
    color: var(--text-dim);
}

.ktv-join .qr {
    width: clamp(70px, 6vw, 120px);
}

/* The idle screen already shows the big join box */
.ktv.is-idle .ktv-join {
    display: none;
}

/* The host's YouTube link plays while the queue is empty: show the video, and the join box beside it */
.ktv.has-idle-video .ktv-idle {
    opacity: 0;
    visibility: hidden;
}

.ktv.is-idle.has-idle-video .ktv-join {
    display: flex;
}

/* Floating controls (appear on mouse move) */
.ktv-controls {
    position: fixed;
    z-index: 10;
    bottom: 24px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: rgba(14, 14, 24, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    opacity: 0;
    transform: translate(-50%, 20px);
    transition: opacity 0.3s, transform 0.3s var(--ease);
    pointer-events: none;
}

.ktv.show-controls .ktv-controls {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

.ktv-control {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: var(--text);
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.ktv-control:hover {
    background: var(--surface-hover);
}

.ktv-control:active {
    transform: scale(0.94);
}

.ktv-control .icon {
    width: 22px;
    height: 22px;
}

.ktv-control.is-off {
    color: var(--text-dim);
}

.ktv-control-main {
    width: 58px;
    height: 58px;
    color: #fff;
    background: var(--gradient);
    box-shadow: var(--glow);
}

.ktv-control-main:hover {
    background: var(--gradient);
    filter: brightness(1.1);
}

.ktv-controls-divider {
    width: 1px;
    height: 28px;
    margin: 0 4px;
    background: var(--border-strong);
}

/* Start overlay (needed so the browser allows sound) */
.ktv-start {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(5, 5, 10, 0.8);
    backdrop-filter: blur(14px);
    cursor: default;
    transition: opacity 0.4s, visibility 0.4s;
}

.ktv-start.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.ktv-start-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    max-width: 560px;
    padding: 40px 32px;
    text-align: center;
    border: 1px solid var(--border-strong);
    border-radius: 28px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
}

.ktv-start-title {
    font-size: 2.4rem;
}

.ktv-start-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

.ktv-start-keys {
    font-size: 0.85rem;
    line-height: 2;
    color: var(--text-dim);
}

/* Portrait screens / narrow windows: stack video over the queue */
@media (max-width: 600px), (max-aspect-ratio: 1/1) {
    .page-ktv {
        overflow: auto;
    }

    .ktv {
        position: static;
        grid-template-columns: 1fr;
        /* Stacked, each part is as tall as its own content */
        grid-template-rows: auto;
        align-content: start;
        gap: 0;
        min-height: 100vh;
        padding: 0;
    }

    .ktv-stage {
        place-items: center;
        padding: var(--stage-pad);
    }

    /* Nothing above or below to fill here, so the card keeps the picture's shape */
    .ktv-video {
        width: 100%;
        aspect-ratio: 16 / 9;
    }

    .ktv-side {
        padding: 0 var(--stage-pad) calc(var(--stage-pad) + 90px);
    }

    /* A 16:9 box is too short for the idle screen on a phone: let it grow to fit */
    .ktv.is-idle:not(.has-idle-video) .ktv-video {
        aspect-ratio: auto;
        min-height: 56.25vw;
    }

    .ktv.is-idle:not(.has-idle-video) .ktv-idle {
        position: relative;
    }
}

/* Phones */
@media (max-width: 480px) {
    .ktv-idle {
        padding: 28px 16px;
    }

    .ktv-idle-mic {
        width: 64px;
        height: 64px;
        margin-bottom: 8px;
        box-shadow: 0 0 0 10px rgba(255, 61, 127, 0.08), 0 0 50px rgba(255, 61, 127, 0.45);
    }

    .ktv-idle-title {
        font-size: 1.5rem;
    }

    .ktv-idle-text {
        font-size: 1rem;
    }

    .ktv-idle-join {
        gap: 14px;
        max-width: 100%;
        margin-top: 12px;
        padding: 12px;
    }

    .ktv-idle-join .qr {
        width: 84px;
    }

    /* Nine buttons have to fit in ~360px */
    .ktv-controls {
        bottom: 12px;
        gap: 0;
        padding: 6px;
        max-width: calc(100vw - 16px);
    }

    .ktv-control {
        width: 36px;
        height: 36px;
    }

    .ktv-control .icon {
        width: 18px;
        height: 18px;
    }

    .ktv-control-main {
        width: 44px;
        height: 44px;
    }

    .ktv-controls-divider {
        display: none;
    }

    .ktv-start-card {
        padding: 32px 20px;
    }

    .ktv-start-title {
        font-size: 1.9rem;
    }
}

/* Phones turned sideways: keep video and queue side by side, but compact */
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
    .ktv {
        --stage-pad: 8px;
        grid-template-columns: minmax(0, 1fr) clamp(220px, 32vw, 300px);
    }

    .ktv-idle {
        gap: 6px;
        padding: 12px;
    }

    .ktv-idle-mic {
        display: none;
    }

    .ktv-idle-title {
        font-size: 1.25rem;
    }

    .ktv-idle-text {
        font-size: 0.9rem;
    }

    .ktv-idle-join {
        gap: 10px;
        max-width: 100%;
        margin-top: 4px;
        padding: 8px 12px 8px 8px;
    }

    .ktv-idle-join .qr {
        width: 72px;
    }

    .ktv-join-url {
        font-size: 1rem;
    }

    .ktv-join-code {
        font-size: 0.85rem;
    }

    .ktv-splash-singer {
        font-size: 2.4rem;
    }

    .ktv-side {
        gap: 8px;
    }

    .ktv-now {
        gap: 2px;
        padding: 12px 14px;
    }

    .ktv-now-singer {
        font-size: 1.4rem;
    }

    .ktv-now-title {
        font-size: 0.85rem;
    }

    /* Too short to show every waiting song: let the list scroll */
    .ktv-next-list {
        overflow-y: auto;
    }

    .ktv-next-item {
        padding: 6px 10px;
    }

    .ktv-next-num {
        font-size: 1.1rem;
    }

    .ktv-next-singer {
        font-size: 0.95rem;
    }

    .ktv-next-title {
        font-size: 0.78rem;
    }

    .ktv-next-empty {
        padding: 8px;
        font-size: 0.85rem;
    }

    .ktv-join {
        gap: 10px;
        padding: 8px;
    }

    .ktv-join .qr {
        width: 56px;
    }

    .ktv-controls {
        bottom: 8px;
        gap: 2px;
        padding: 4px;
    }

    .ktv-control {
        width: 38px;
        height: 38px;
    }

    .ktv-control .icon {
        width: 18px;
        height: 18px;
    }

    .ktv-control-main {
        width: 44px;
        height: 44px;
    }

    .ktv-controls-divider {
        margin: 0 2px;
    }

    .ktv-start-card {
        gap: 10px;
        padding: 20px 24px;
    }

    .ktv-start-title {
        font-size: 1.6rem;
    }

    /* Keyboard shortcuts don't apply on a phone */
    .ktv-start-keys {
        display: none;
    }
}

/* 8. Admin panel --------------------------------------------------------- */

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px clamp(16px, 3vw, 32px);
    border-bottom: 1px solid var(--border);
    background: rgba(8, 8, 15, 0.8);
    backdrop-filter: blur(16px);
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-nav form {
    margin: 0;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
    gap: 24px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px clamp(16px, 3vw, 32px) 48px;
}

.admin-main,
.admin-side {
    display: grid;
    gap: 24px;
    min-width: 0;
}

.now-card {
    display: grid;
    grid-template-columns: minmax(180px, 300px) 1fr;
    align-items: center;
    gap: 28px;
    border-color: rgba(255, 61, 127, 0.3);
    background: linear-gradient(135deg, rgba(255, 61, 127, 0.14), rgba(139, 92, 246, 0.08));
}

.now-card.is-empty {
    border-color: var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
}

.now-card-media a {
    display: block;
    transition: transform 0.2s var(--ease);
}

.now-card-media a:hover {
    transform: scale(1.02);
}

.now-placeholder {
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    color: var(--text-dim);
    background: var(--surface);
}

.now-placeholder .icon {
    width: 48px;
    height: 48px;
}

.now-card-body {
    display: grid;
    gap: 8px;
    min-width: 0;
    container-type: inline-size;
}

.now-card.is-empty .eyebrow {
    color: var(--text-dim);
}

.now-card.is-paused .eyebrow {
    color: var(--amber);
}

.now-singer {
    font-size: clamp(1.8rem, 3.2vw, 2.6rem);
    overflow-wrap: anywhere;
}

.now-title {
    color: var(--text-muted);
}

.now-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

/* Not enough room for all four in a row: 2 x 2 (Play / Restart, Next / Skip) instead of a lone Skip */
@container (max-width: 480px) {
    .now-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

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

/* A long history scrolls inside its card instead of stretching the page */
.history-list {
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.queue-row {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: background 0.2s, border-color 0.2s, opacity 0.2s, transform 0.2s;
}

.queue-row:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.queue-row.is-dragging {
    opacity: 0.5;
    border-style: dashed;
    border-color: var(--pink);
}

.drag-handle {
    display: grid;
    place-items: center;
    width: 24px;
    height: 34px;
    color: var(--text-dim);
    cursor: grab;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.queue-num {
    width: 26px;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-dim);
    text-align: center;
}

.queue-info,
.history-info {
    display: grid;
    min-width: 0;
}

.queue-singer {
    overflow-wrap: anywhere;
}

.queue-title,
.history-title {
    overflow: hidden;
    font-size: 0.86rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.row-actions {
    display: flex;
    gap: 2px;
}

.list-empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

.list-note {
    padding: 12px 0;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.history-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.history-meta {
    display: grid;
    justify-items: end;
    gap: 4px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.stats-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 18px;
}

.stat {
    display: grid;
    justify-items: center;
    gap: 2px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat:first-child .stat-value {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

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

@media (max-width: 640px) {
    .hide-sm {
        display: none;
    }

    .card {
        padding: 18px;
    }

    .now-card {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .brand-name {
        white-space: nowrap;
    }

    /* Number | singer + title, with the row buttons on a second line so titles get the full width */
    .queue-row {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 4px 10px;
    }

    .queue-row .drag-handle,
    .queue-row .thumb-frame,
    .queue-row .pill {
        display: none;
    }

    .queue-row .row-actions {
        grid-column: 2;
        margin-left: -8px;
    }
}

@media (max-width: 430px) {
    /*
     * Three things share the header row and "Reconnecting..." is wide. Give up
     * the app's own name rather than the room: the singer scanned a QR code to
     * get here, and the room is the one thing they need to see - it says whose
     * queue their song is going into. The mark still says which app this is.
     */
    .guest-header .brand-name {
        display: none;
    }
}

@media (hover: none) {
    .hide-touch {
        display: none;
    }
}

/* Guest access code card */
.access-code {
    display: block;
    margin-bottom: 14px;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.18em;
    overflow-wrap: anywhere;
}

.access-form {
    display: flex;
    gap: 8px;
}

.access-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.input-code {
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.input-code::placeholder {
    text-transform: none;
    letter-spacing: normal;
}

/* Background music card */
.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 14px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.segmented-option {
    position: relative;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.segmented-option:hover {
    color: var(--text);
}

.segmented-option.is-active {
    color: var(--text);
    background: var(--surface-raised);
}

/* Green dot on the source the TV is using right now */
.segmented-option.is-live::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

.music-panel {
    display: grid;
    justify-items: start;
    gap: 10px;
}

.music-panel .access-form {
    width: 100%;
}

.track-list {
    display: grid;
    width: 100%;
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.track-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.track-name {
    overflow: hidden;
    font-size: 0.92rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Rooms: the picker at "/", the badge on a guest page, the link in the panel */
.room-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.room-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.room-link:hover,
.room-link:focus-visible {
    border-color: rgba(255, 61, 127, 0.4);
    background: var(--surface-hover);
    transform: translateY(-1px);
    box-shadow: 0 14px 30px -18px rgba(255, 61, 127, 0.8);
}

.room-link:active {
    transform: translateY(0);
}

/* The host's initial: one badge per room, so the rows are told apart at a glance */
.room-avatar {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    border-radius: 14px;
    background: var(--gradient);
    box-shadow: 0 8px 20px -10px rgba(255, 61, 127, 0.9);
}

.room-link-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.room-link-name {
    overflow: hidden;
    font-size: 1.02rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.room-link-hint {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.room-link-go {
    color: var(--text-dim);
    /* `translate` runs before `transform`, so the nudge stays horizontal */
    transform: rotate(-90deg);
    transition: color 0.2s, translate 0.2s var(--ease);
}

.room-link:hover .room-link-go,
.room-link:focus-visible .room-link-go {
    color: var(--pink);
    translate: 3px 0;
}

.room-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    max-width: min(45vw, 240px);
    padding: 5px 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.room-at {
    color: var(--text-dim);
}

.room-url {
    display: block;
    margin: 4px 0;
    overflow-wrap: anywhere;
}

/* Host menu in the top bar */
.menu {
    position: relative;
}

.menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.menu-trigger:hover,
.menu.is-open .menu-trigger {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.menu-avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
}

.menu-avatar .icon {
    width: 16px;
    height: 16px;
}

.menu-trigger-name {
    max-width: 12ch;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.menu-caret {
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    transition: transform 0.2s var(--ease);
}

.menu.is-open .menu-caret {
    transform: rotate(180deg);
}

.menu-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    display: grid;
    min-width: 268px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    box-shadow: var(--shadow);
    animation: rise 0.16s var(--ease);
}

.menu-panel form {
    display: grid;
    margin: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
    background: var(--surface-hover);
    outline: none;
}

.menu-item .icon {
    flex: none;
    color: var(--text-dim);
}

.menu-item-text {
    display: grid;
    min-width: 0;
    gap: 1px;
    font-weight: 600;
}

.menu-item-text small {
    overflow: hidden;
    font-size: 0.76rem;
    font-weight: 400;
    color: var(--text-dim);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.menu-item-danger:hover,
.menu-item-danger:focus-visible {
    background: rgba(244, 63, 94, 0.14);
    color: #ffe4e9;
}

.menu-item-danger:hover .icon,
.menu-item-danger:focus-visible .icon {
    color: var(--red);
}

.menu-separator {
    height: 1px;
    margin: 6px 4px;
    background: var(--border);
}

@media (max-width: 480px) {
    .menu-trigger-name {
        display: none;
    }

    .menu-panel {
        min-width: min(280px, calc(100vw - 32px));
    }
}

/* Account page: one readable column, the same cards as the panel */
.account-grid {
    display: grid;
    gap: 24px;
    align-content: start;
    max-width: 620px;
    margin: 0 auto;
    padding: 24px clamp(16px, 3vw, 32px) 48px;
}

.icon-back {
    transform: rotate(-90deg);
}

/* Your account & Hosts cards */
.account-card .form + .form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.account-card .form {
    gap: 12px;
}

.host-list {
    display: grid;
    width: 100%;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.host-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.host-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-dim);
}

.host-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.host-you,
.host-role {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.host-role,
.pill-owner {
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.host-row.is-owner .host-avatar {
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.host-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 9. Login & error pages ------------------------------------------------- */

/*
 * The card used to float on flat black in the middle of the window, where the
 * page's own corner glows never reach. Light it from behind instead, so the
 * card sits in the same pink/violet world as the rest of the app.
 */
.login-screen {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.login-screen::before {
    content: '';
    position: absolute;
    z-index: -1;
    top: 50%;
    left: 50%;
    width: min(150vw, 1100px);
    aspect-ratio: 1;
    background:
        radial-gradient(circle at 50% 42%, rgba(255, 61, 127, 0.22), transparent 55%),
        radial-gradient(circle at 62% 62%, rgba(139, 92, 246, 0.2), transparent 55%);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-shell {
    display: grid;
    gap: 18px;
    width: min(100%, 420px);
}

.login-card {
    position: relative;
    display: grid;
    gap: 22px;
    padding: 38px 30px 34px;
    overflow: hidden;
    border-color: var(--border-strong);
}

/* A lit top edge, so the card reads as raised rather than as a flat panel */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 12%;
    width: 76%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 61, 127, 0.7), rgba(139, 92, 246, 0.7), transparent);
}

.login-head {
    display: grid;
    justify-items: center;
    gap: 8px;
    text-align: center;
}

/* Halo behind the mic badge */
.login-mark {
    position: relative;
    display: grid;
    place-items: center;
    margin-bottom: 4px;
}

.login-mark::before {
    content: '';
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 61, 127, 0.35), transparent 65%);
}

.login-mark .brand-mark {
    position: relative;
}

.login-title {
    margin-top: 6px;
    font-size: 1.9rem;
}

.login-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
    /* Even lines instead of one long line and an orphan */
    text-wrap: balance;
}

.login-foot {
    display: grid;
    justify-items: center;
    gap: 10px;
    text-align: center;
}

.login-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.login-back:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.login-hint {
    max-width: 38ch;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-dim);
    text-wrap: balance;
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px 26px;
    }

    .login-title {
        font-size: 1.65rem;
    }
}

.error-card {
    display: grid;
    justify-items: center;
    gap: 14px;
    width: min(100%, 460px);
    text-align: center;
}

.error-code {
    font-family: var(--font-display);
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
}

.error-title {
    font-size: 1.5rem;
}

/* 10. Motion ------------------------------------------------------------- */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 currentColor; }
    70% { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes eq {
    0%, 100% { transform: scaleY(0.3); }
    50% { transform: scaleY(1); }
}

@keyframes shimmer {
    to { background-position: -200% 0; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes pop {
    0% { transform: scale(0.4); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes now-breathe {
    0%, 100% { box-shadow: var(--glow); border-color: rgba(255, 61, 127, 0.35); }
    50% { box-shadow: 0 0 46px rgba(255, 61, 127, 0.4); border-color: rgba(255, 61, 127, 0.62); }
}

@keyframes now-sheen {
    0% { transform: translateX(-115%); }
    55%, 100% { transform: translateX(115%); }
}

@keyframes now-swap {
    from { opacity: 0; transform: translateY(0.4em); filter: blur(5px); }
    to { opacity: 1; transform: none; filter: none; }
}

@keyframes now-wait {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.8; }
}

@keyframes now-dots {
    to { width: 1.1em; }
}

@keyframes eq-idle {
    0%, 100% { transform: scaleY(0.2); }
    50% { transform: scaleY(0.5); }
}

@keyframes splash-in {
    from { opacity: 0; transform: scale(0.85); letter-spacing: 0.2em; }
    to { opacity: 1; transform: none; letter-spacing: normal; }
}

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