:root {
    --bg: #0c0a08;
    --bg-raised: #16110d;
    --ink: #ead8b4;
    --muted: #9a8460;
    --gold: #c5a059;
    --gold-bright: #e0c37a;
    --tan: #d2b48c;
    --line: rgba(197, 160, 89, 0.28);
    --danger: #c45c3e;
    --glow: rgba(232, 176, 82, 0.35);
    --serif: "Libre Baskerville", Georgia, serif;
    --display: "Cinzel", "Times New Roman", serif;
}

* { box-sizing: border-box; }

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(197, 160, 89, 0.28);
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--serif);
}

body {
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(197, 160, 89, 0.08), transparent 42%),
        radial-gradient(ellipse at 80% 100%, rgba(80, 40, 10, 0.35), transparent 50%),
        var(--bg);
}

button, a, input, select, .tab, .track-card, .playlist-card, .chips button {
    touch-action: manipulation;
}

.grain {
    pointer-events: none;
    position: fixed;
    inset: 0;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
    z-index: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.screen {
    position: relative;
    z-index: 1;
    height: 100dvh;
    overflow: auto;
}

.screen.kiosk {
    overflow: hidden;
}

.splash {
    display: grid;
    place-items: center;
    padding: 2rem 1.25rem;
    overflow: auto;
}

.splash-frame {
    width: min(560px, 100%);
    text-align: center;
}

.sign {
    width: 100%;
    max-height: min(52dvh, 420px);
    object-fit: contain;
    border: 1px solid var(--gold);
    box-shadow: 0 0 40px var(--glow), inset 0 0 0 3px rgba(12, 10, 8, 0.6);
    background: #111;
}

.eyebrow, .panel-kicker, .brand-kicker {
    font-family: var(--display);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    font-size: 0.72rem;
    margin: 1.25rem 0 0.4rem;
}

.splash-status, .lede {
    color: var(--muted);
    line-height: 1.6;
}

.splash-error {
    color: var(--danger);
    background: rgba(196, 92, 62, 0.1);
    border: 1px solid rgba(196, 92, 62, 0.35);
    padding: 0.7rem 1rem;
}

.splash-actions, .row-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.row-actions { justify-content: flex-start; }
#btn-house-login { width: 100%; margin-top: 0.6rem; }
.row-actions.wrap { margin-bottom: 1rem; }

.fineprint {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.55;
    text-align: left;
}

code {
    color: var(--gold-bright);
}

.btn, .tab, .icon-btn, .transport button {
    font-family: var(--display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0.8rem 1.4rem;
    text-decoration: none;
    font-size: 0.92rem;
}

.btn.gold {
    background: linear-gradient(180deg, #d8b56a, #9a7433);
    color: #1a1208;
    border-color: #e0c37a;
}

.btn.ghost, .tab {
    background: rgba(22, 17, 13, 0.7);
}

.btn:hover, .tab:hover, .icon-btn:hover, .transport button:hover {
    filter: brightness(1.08);
}

.icon-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    background: var(--bg-raised);
}

.kiosk {
    padding:
        max(0.55rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(0.55rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.55rem;
    margin-bottom: 0.65rem;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.brand-mark {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border: 1px solid var(--gold);
}

.brand h1 {
    font-family: var(--display);
    margin: 0;
    font-size: 1.45rem;
    color: var(--gold-bright);
}

.brand-kicker { margin: 0 0 0.15rem; }

.top-meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chip {
    margin: 0;
    border: 1px solid var(--line);
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    color: var(--tan);
    background: var(--bg-raised);
}

.chip.dim { color: var(--muted); }

.kiosk-note {
    margin: 0 1.25rem 0.85rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--gold);
    color: var(--gold-bright);
    font-size: 0.88rem;
    line-height: 1.4;
    background: rgba(197, 160, 89, 0.08);
}

.kiosk-note .btn {
    display: inline-block;
    margin-top: 0.7rem;
}

.kiosk-body {
    display: grid;
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "now now"
        "queue browse";
    gap: 0.7rem;
    flex: 1;
    min-height: 0;
}

.now-panel {
    grid-area: now;
    position: relative;
}

.queue-block {
    grid-area: queue;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.browse {
    grid-area: browse;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.now-panel, .browse, .admin-panel, .queue-block {
    background: linear-gradient(180deg, rgba(36, 26, 16, 0.75), rgba(12, 10, 8, 0.9));
    border: 1px solid var(--line);
    padding: 0.75rem 0.85rem;
}

.now-main {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto;
    gap: 0.65rem 0.9rem;
    align-items: center;
}

.now-copy .panel-kicker {
    margin: 0 0 0.15rem;
    font-size: 0.62rem;
}

.now-copy .progress {
    margin-top: 0.4rem;
}

.now-copy .time {
    margin: 0.25rem 0 0;
}

.now-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 220px;
}

.art-glow {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: #111;
    box-shadow: 0 0 28px var(--glow);
    border: 1px solid var(--gold);
    margin: 0;
}

.art-glow img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#now-title {
    font-family: var(--display);
    font-size: 1.15rem;
    margin: 0 0 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#now-artist {
    margin: 0;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress {
    height: 6px;
    background: #2a2118;
    border: 1px solid var(--line);
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #8a5a1e, var(--gold-bright));
}

.time {
    color: var(--muted);
    font-size: 0.78rem;
}

.queue-list {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0;
}

.queue-list li {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(197, 160, 89, 0.12);
    font-size: 0.92rem;
    line-height: 1.35;
}

.queue-list .meta { color: var(--muted); font-size: 0.78rem; }
.queue-list .empty { color: var(--muted); }
.queue-list li div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    position: sticky;
    top: -0.75rem;
    z-index: 2;
    padding: 0.15rem 0 0.55rem;
    background: linear-gradient(180deg, rgba(22, 17, 13, 0.98), rgba(12, 10, 8, 0.92));
}

.tab {
    min-height: 52px;
    padding: 0 0.45rem;
    font-size: 0.82rem;
}

.tab.active {
    background: linear-gradient(180deg, #d8b56a, #9a7433);
    color: #1a1208;
}

.search-wrap input, .pin-form input, .settings input, .settings textarea, select {
    width: 100%;
    min-height: 52px;
    background: #120e0a;
    border: 1px solid var(--line);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    padding: 0 0.9rem;
}

.settings textarea {
    min-height: 7.5rem;
    padding: 0.7rem 0.9rem;
    resize: vertical;
    line-height: 1.45;
}

.admin-panel input, .admin-panel select {
    min-height: 44px;
}

.search-wrap { display: block; margin-bottom: 1rem; }

.track-grid, .playlist-grid {
    display: grid;
    gap: 0.65rem;
}

.track-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.playlist-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

.playlist-group {
    grid-column: 1 / -1;
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
}

.playlist-group:first-child {
    margin-top: 0;
}

.track-card, .playlist-card {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 0.7rem;
    align-items: center;
    text-align: left;
    background: #120e0a;
    border: 1px solid var(--line);
    color: inherit;
    padding: 0.55rem;
    font-family: var(--serif);
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    min-height: 80px;
}

.playlist-card {
    grid-template-columns: 1fr;
    min-height: 0;
}

.track-card img, .playlist-card img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    background: #1b1510;
}

.track-card > div,
.now-copy {
    min-width: 0;
}

.playlist-card img { width: 100%; height: auto; aspect-ratio: 1; }

.track-card strong, .playlist-card strong {
    display: block;
    font-family: var(--display);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-card span, .playlist-card span {
    color: var(--muted);
    font-size: 0.8rem;
}

.track-card .queue-hint {
    font-family: var(--display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    font-size: 0.72rem;
    border: 1px solid var(--line);
    padding: 0.35rem 0.55rem;
    white-space: nowrap;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.chips button {
    min-height: 48px;
    padding: 0 0.9rem;
    font-family: var(--display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #120e0a;
    border: 1px solid var(--line);
    color: var(--tan);
    cursor: pointer;
}

.chips button.active {
    background: var(--gold);
    color: #1a1208;
    border-color: var(--gold-bright);
}

.subhead {
    font-family: var(--display);
    color: var(--gold);
    margin: 0 0 0.8rem;
}

.text-btn {
    background: none;
    border: 0;
    color: var(--gold);
    font-family: var(--display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.4rem 0;
}

.text-btn.danger { color: var(--danger); }

.overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: rgba(6, 4, 3, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    overflow: auto;
}

.admin-panel {
    width: min(460px, 100%);
    max-height: calc(100dvh - 1.5rem);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 1rem 1.1rem 1.15rem;
}

.admin-panel h2 {
    margin: 0 0 0.4rem;
    padding-right: 2.5rem;
    font-family: var(--display);
    font-size: 1.35rem;
}

.admin-panel .close {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
}

.pin-form, .settings, .transport {
    display: grid;
    gap: 0.55rem;
    margin: 0.7rem 0;
}

.settings {
    grid-template-columns: 1fr 1fr;
}

.settings button,
.settings .playlist-links,
.settings .playlist-hint {
    grid-column: 1 / -1;
}

.playlist-hint {
    margin: 0;
}

.transport {
    grid-template-columns: repeat(4, 1fr);
}

.transport button { min-height: 44px; }

.guest-transport {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem;
    margin: 0;
}

.media-tabs {
    display: flex;
    gap: 0.4rem;
    margin: 0;
}

.media-tab {
    flex: 1;
    min-height: 48px;
    font-family: var(--display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid var(--line);
    background: #120e0a;
    color: var(--tan);
}

.media-tab.active {
    background: linear-gradient(180deg, #d8b56a, #9a7433);
    color: #1a1208;
    border-color: var(--gold-bright);
}

.lyrics-overlay {
    align-items: center;
    justify-content: center;
}

.lyrics-modal {
    width: min(640px, 100%);
    max-height: calc(100dvh - 1.5rem);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(36, 26, 16, 0.96), rgba(12, 10, 8, 0.98));
    border: 1px solid var(--gold);
    padding: 1rem 1.1rem 1.15rem;
    position: relative;
}

.lyrics-modal h2 {
    font-family: var(--display);
    margin: 0 0 0.2rem;
    padding-right: 2.5rem;
    color: var(--gold-bright);
    font-size: 1.25rem;
}

.lyrics-viewport {
    position: relative;
    flex: 1;
    min-height: 280px;
    max-height: min(62dvh, 520px);
    overflow: hidden;
    margin-top: 0.7rem;
    border: 1px solid var(--line);
    background: #120e0a;
}

.lyrics-viewport::before,
.lyrics-viewport::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3.2rem;
    z-index: 1;
    pointer-events: none;
}

.lyrics-viewport::before {
    top: 0;
    background: linear-gradient(#120e0a, transparent);
}

.lyrics-viewport::after {
    bottom: 0;
    background: linear-gradient(transparent, #120e0a);
}

.lyrics-stream {
    padding: 36% 1.1rem;
    will-change: transform;
    transition: transform 0.12s linear;
}

.lyrics-stream p {
    margin: 0.55rem 0;
    color: var(--muted);
    text-align: center;
    font-size: 1.15rem;
    line-height: 1.45;
}

.lyrics-stream p.now {
    color: var(--gold-bright);
    font-weight: 700;
    font-size: 1.35rem;
}

.video-box {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    width: min(420px, 46vw);
    z-index: 4;
    border: 1px solid var(--gold);
    background: #111;
    aspect-ratio: 16 / 9;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.video-box iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.guest-transport button {
    min-height: 48px;
    font-family: var(--display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid var(--gold);
    background: rgba(22, 17, 13, 0.7);
    color: var(--gold);
}

.volume {
    display: block;
    color: var(--muted);
    margin: 0.4rem 0 0.7rem;
}

#admin-volume {
    width: 100%;
    min-height: 0;
    height: 1.4rem;
    padding: 0;
    background: transparent;
    border: 0;
    accent-color: var(--gold);
}

#admin-volume::-webkit-slider-runnable-track {
    height: 6px;
    background: #2a2118;
    border: 1px solid var(--line);
}

#admin-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    background: var(--gold-bright);
    border: 1px solid #8a5a1e;
    border-radius: 50%;
}

#admin-volume::-moz-range-track {
    height: 6px;
    background: #2a2118;
    border: 1px solid var(--line);
}

#admin-volume::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--gold-bright);
    border: 1px solid #8a5a1e;
    border-radius: 50%;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: max(1.2rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 8;
    background: #1b1510;
    border: 1px solid var(--gold);
    color: var(--gold-bright);
    padding: 0.75rem 1.1rem;
    font-family: var(--display);
    letter-spacing: 0.05em;
    max-width: min(520px, 92vw);
}

.muted { color: var(--muted); }

body[data-mode="picker"] #device-chip {
    display: none;
}

@media (max-width: 1024px) and (orientation: landscape) {
    .brand-kicker { display: none; }
    .brand h1 { font-size: 1.2rem; }
    .brand-mark { width: 46px; height: 46px; }
    .now-copy .panel-kicker { display: none; }
}

@media (max-width: 960px), (orientation: portrait) {
    .kiosk-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
        grid-template-areas:
            "now"
            "queue"
            "browse";
    }

    .now-main {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .now-controls {
        grid-column: 1 / -1;
        min-width: 0;
        flex-direction: row;
        align-items: stretch;
    }

    .guest-transport,
    .media-tabs {
        flex: 1;
    }

    .art-glow {
        width: 72px;
        height: 72px;
    }

    .queue-block {
        max-height: 8.5rem;
    }

    .video-box {
        width: min(360px, calc(100vw - 1.5rem));
    }
}

@media (max-width: 560px) {
    .now-main { grid-template-columns: 64px minmax(0, 1fr); }
    .art-glow { width: 64px; height: 64px; }
    .brand h1 { font-size: 1.15rem; }
    .brand-kicker { display: none; }
    .transport { grid-template-columns: 1fr 1fr; }
    .settings { grid-template-columns: 1fr; }
    .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .now-controls { flex-direction: column; }
    .track-grid { grid-template-columns: 1fr; }
    .track-card .queue-hint { display: none; }
    .track-card { grid-template-columns: 56px minmax(0, 1fr); }
}
