/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-surface: #1e2a4a;
    --accent: #d4a843;
    --accent-glow: rgba(212, 168, 67, 0.3);
    --text-primary: #f0e6d3;
    --text-secondary: #a09882;
    --text-dim: #6b6353;
    --control-bg: #0f3460;
    --control-hover: #1a4a7a;
    --progress-bg: #2a2a4a;
    --progress-fill: #d4a843;
    --danger: #e74c3c;
    --success: #2ecc71;
    --border: rgba(212, 168, 67, 0.15);
    --tab-height: 60px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* === Splash (non-authenticated visitors) === */
.splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.splash-motd {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1rem;
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.splash-logo {
    width: 220px;
    height: 220px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 24px rgba(212, 168, 67, 0.2));
}

.splash p {
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

/* ============================================================
   App Shell
   ============================================================ */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 720px;
    margin: 0 auto;
}

/* === App Header === */
.app-header {
    text-align: center;
    padding: 0.75rem 1rem 0.25rem;
    position: relative;
    flex-shrink: 0;
}

.header-banner {
    width: clamp(160px, 50%, 280px);
    height: auto;
    filter: drop-shadow(0 2px 12px rgba(212, 168, 67, 0.15));
}

/* === Auth Bar === */
.auth-bar {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    font-size: 0.8rem;
}

.auth-greeting-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.15s;
}

.auth-greeting-link:hover {
    color: var(--accent);
}

.auth-login-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-login-link:hover {
    text-decoration: underline;
}

/* === MOTD Bar === */
.motd-bar {
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.4;
}

/* ============================================================
   Tab Bar
   ============================================================ */

.tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    height: var(--tab-height);
    flex-shrink: 0;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0.4rem 0;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tab svg {
    width: 22px;
    height: 22px;
}

.tab.active {
    color: var(--accent);
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active:hover {
    color: var(--accent);
}

/* ============================================================
   Panels
   ============================================================ */

.panels {
    flex: 1;
    overflow: hidden;
    padding-bottom: var(--tab-height);
}

.panel {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.panel-scroll {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.section-title {
    font-size: 0.9rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* ============================================================
   Now Playing (Player)
   ============================================================ */

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 1.5rem;
    max-width: 480px;
    margin: 0 auto;
}

/* Album Art */
.player-artwork {
    position: relative;
    width: 100%;
    max-width: min(280px, 75%, 40vh);
    aspect-ratio: 1;
    margin-bottom: 1.25rem;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.artwork-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}

.player-artwork--clickable {
    cursor: pointer;
}

.player-artwork--clickable:hover .artwork-img {
    transform: scale(1.03);
}

.artwork-img[src=""] { display: none; }

.artwork-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artwork-placeholder-logo {
    width: 70%;
    height: 70%;
    object-fit: contain;
    opacity: 0.6;
}

.artwork-img:not([src=""]) ~ .artwork-placeholder { display: none; }

/* Track Info */
.player-info {
    text-align: center;
    width: 100%;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.track-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-artist {
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 0.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-album {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Progress */
.player-progress {
    width: 100%;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--progress-bg);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s linear;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* Controls */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.controls-disabled {
    opacity: 0.35;
    pointer-events: none;
}

.player-signin-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.5rem;
}

.signin-link {
    color: var(--accent);
    text-decoration: none;
}

.signin-link:hover {
    text-decoration: underline;
}

.control-btn {
    background: var(--control-bg);
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.control-btn svg {
    width: 22px;
    height: 22px;
}

.control-btn:hover { background: var(--control-hover); }
.control-btn:active { transform: scale(0.93); }

.control-btn-main {
    width: 64px;
    height: 64px;
    background: var(--accent);
    color: var(--bg-dark);
    box-shadow: 0 0 16px var(--accent-glow);
}

.control-btn-main svg {
    width: 28px;
    height: 28px;
}

.control-btn-main:hover { background: #e0b54e; }

/* Status Bar */
.status-bar {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
}

.status-bar.error { color: var(--danger); }

#panel-drinks .panel-scroll {
    text-align: center;
}

/* ============================================================
   Playlist Panel
   ============================================================ */

/* Flex column: music-settings pinned at top, track list scrolls below */
#panel-playlist {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panel-playlist.hidden {
    display: none !important;
}

/* Track list area takes remaining space and scrolls */
.playlist-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.playlist-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.playlist-track {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.playlist-track:hover {
    background: var(--bg-surface);
}

.playlist-track--active {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
}

.track-thumb {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}

.track-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.track-details-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-details-artist {
    font-size: 0.75rem;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-details-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem 0;
    font-size: 0.9rem;
}

/* Shared blue header bar — used for Now Playing and Music Settings titles */
.panel-header-bar {
    background: var(--bg-surface);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.panel-header-bar .section-title {
    margin-bottom: 0;
}

/* Music Settings — now lives in the management panel as a management-section */

.settings-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.settings-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex: 1;
    min-width: 100px;
}

.select-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

/* ============================================================
   Drink Special Panel
   ============================================================ */

.drink-card {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.drink-image-wrap {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: inline-block; /* shrink-wrap the border-radius to the scaled image */
}

.drink-image {
    display: block;
    max-width: 100%;
    max-height: 45vh;
    width: auto;
    height: auto;
    transition: transform 0.2s;
}

.drink-image-wrap:hover .drink-image {
    transform: scale(1.03);
}

.drink-name {
    font-size: 1.3rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    font-family: Georgia, 'Times New Roman', serif;
}

.drink-ingredients {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Mobile: inline comma-separated */
.ingredients-list {
    list-style: none;
    padding: 0;
}

.ingredients-list li {
    display: inline;
}

.ingredients-list li:not(:last-child)::after {
    content: ', ';
}

.ingredient-qty {
    color: var(--accent);
    font-weight: 600;
}

/* Preparation Steps */
.drink-steps {
    margin-top: 1.25rem;
    text-align: left;
}

.drink-steps-title {
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-align: center;
}

.steps-list {
    padding-left: 1.5rem;
    margin: 0;
}

.steps-list li {
    display: list-item;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.7;
    padding-left: 0.25rem;
}

.steps-list li::marker {
    color: var(--accent);
    font-weight: 600;
}

/* Desktop: vertical bullet list */
@media (min-width: 768px) {
    .ingredients-list li {
        display: list-item;
        list-style: disc;
        margin-left: 1.5rem;
        line-height: 1.8;
    }

    .ingredients-list li:not(:last-child)::after {
        content: '';
    }
}

/* Dynamic Add/Remove Rows (ingredients, steps in forms) */
.dynamic-section {
    margin-bottom: 0.75rem;
}

.dynamic-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.dynamic-section-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.dynamic-row {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

.dynamic-row input[type="text"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

.dynamic-row input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.dynamic-row .ing-name {
    flex: 1 1 0%;
    min-width: 0;
    width: 0; /* let flex-grow own the width, not the input's intrinsic size */
}

/* Drink manager forms fill the available panel width */
#drink-manager .tavern-form {
    max-width: none;
}

.dynamic-row .step-inst {
    flex: 1;
    min-width: 0;
}

.dynamic-remove {
    background: none;
    border: 1px solid var(--border);
    color: var(--danger);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.dynamic-remove:hover {
    background: rgba(231, 76, 60, 0.15);
}

.drink-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 3rem 0;
    font-size: 0.9rem;
}

/* Manager drink controls */
.drink-manager-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.past-drinks-list {
    margin-top: 1rem;
}

.past-drink-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    background: var(--bg-card);
}

.past-drink-item--active {
    border-left: 3px solid var(--accent);
}

.past-drink-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.past-drink-info {
    flex: 1;
    min-width: 0;
}

.past-drink-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.badge-active {
    background: var(--accent);
    color: var(--bg-dark);
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    text-transform: uppercase;
}

.past-drink-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* Checkbox to toggle a drink as an active special */
.drink-active-label {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0 0.25rem;
}

.drink-active-cb {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Rotation dots — shown below drink card when multiple specials are active */
.drink-rotation-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.drink-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.25s, transform 0.25s;
}

.drink-dot--active {
    background: var(--accent);
    transform: scale(1.35);
}

/* Rotation delay slider row in manager controls */
.drink-delay-row {
    margin: 0.75rem 0 0.5rem;
}

.delay-slider {
    width: 100%;
    margin-top: 0.35rem;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ============================================================
   Modal Overlay
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-image-full {
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
}

.modal-image-full img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-accent {
    background: var(--accent);
    color: var(--bg-dark);
}

.btn-accent:hover { background: #e0b54e; }

.btn-secondary {
    background: var(--control-bg);
    color: var(--text-primary);
}

.btn-secondary:hover { background: var(--control-hover); }

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

.btn-danger:hover { background: #c0392b; }

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
}

/* ============================================================
   Forms
   ============================================================ */

.tavern-form {
    max-width: 380px;
    margin: 0 auto;
}

.tavern-form h3, .tavern-form h4 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.tavern-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tavern-form input[type="text"],
.tavern-form input[type="email"],
.tavern-form input[type="password"],
.tavern-form select,
.tavern-form textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 100%;
}

.tavern-form input:focus,
.tavern-form select:focus,
.tavern-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.tavern-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tavern-form input[type="file"] {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.form-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.form-success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.form-link {
    margin-top: 0.75rem;
    font-size: 0.8rem;
}

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

.form-link a:hover { text-decoration: underline; }

.required { color: var(--danger); }
.hint { color: var(--text-dim); font-size: 0.75rem; }
.text-muted { color: var(--text-dim); font-size: 0.85rem; }
.loading { color: var(--text-dim); text-align: center; padding: 2rem 0; }

/* Auth forms — side by side on desktop */
.auth-forms {
    max-width: 600px;
    margin: 0 auto;
}

.auth-divider {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin: 1.5rem 0;
    position: relative;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 1rem);
    height: 1px;
    background: var(--border);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ============================================================
   Admin — User Management
   ============================================================ */

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.admin-header h3 {
    color: var(--accent);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.admin-user-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.admin-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.admin-user-info { flex: 1; min-width: 0; }

.admin-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.15rem;
}

.admin-user-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-patron { background: var(--control-bg); color: var(--text-primary); }
.badge-manager { background: #1b6b3a; color: #7fefab; }
.badge-admin { background: #6b2a1b; color: #ef9a7f; }

/* Management panel sections */
.management-section {
    margin-bottom: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.management-section:first-child {
    border-top: none;
    padding-top: 0;
}

/* Profile sections */
.profile-section {
    margin-bottom: 2rem;
}

.profile-section h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ============================================================
   Zone Control Panel
   ============================================================ */

.zones-unavailable {
    color: var(--text-dim);
    text-align: center;
    padding: 3rem 0;
    font-size: 0.9rem;
}

/* Grid of zone cards — 1 col on mobile, 2 on wider screens */
.zone-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.zone-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    transition: border-color 0.2s;
}

.zone-card--on {
    border-color: var(--accent);
}

/* Card header: zone name + power button */
.zone-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.zone-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.zone-power-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.zone-power-btn--on {
    background: rgba(212, 168, 67, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.zone-power-btn:hover {
    background: rgba(212, 168, 67, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* Controls area — dimmed when zone is off */
.zone-card-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.zone-card-controls--off {
    opacity: 0.35;
    pointer-events: none;
}

/* Individual control rows */
.zone-control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zone-control-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: 3rem;
    flex-shrink: 0;
}

/* Source dropdown — matches existing select-input style */
.zone-source-select {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.82rem;
    min-width: 0;
}

.zone-source-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Volume row layout */
.zone-volume-row {
    gap: 0.4rem;
}

.zone-vol-step-btn {
    background: var(--control-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    border-radius: 5px;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.zone-vol-step-btn:hover:not(:disabled) {
    background: var(--control-hover);
}

.zone-vol-step-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Volume slider */
.zone-volume-slider {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
    height: 4px;
    cursor: pointer;
}

.zone-volume-slider:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.zone-vol-display {
    font-size: 0.78rem;
    color: var(--text-secondary);
    width: 2rem;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Two-column grid on desktop */
@media (min-width: 640px) {
    .zone-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   Responsive — Desktop (≥768px)
   ============================================================ */

@media (min-width: 768px) {
    :root {
        --tab-height: 0px; /* tabs become top bar on desktop */
    }

    .tab-bar {
        position: static;
        border-top: none;
        border-bottom: 1px solid var(--border);
        max-width: 720px;
        margin: 0 auto;
        height: auto;
        padding-bottom: 0;
    }

    .tab {
        flex-direction: row;
        gap: 0.4rem;
        padding: 0.65rem 0.5rem;
        font-size: 0.8rem;
    }

    .tab svg {
        width: 18px;
        height: 18px;
    }

    .panels {
        padding-bottom: 0;
    }

    .header-banner {
        width: clamp(160px, 30%, 240px);
    }

    .player-artwork {
        max-width: 300px;
    }

    /* Auth forms side by side */
    .auth-forms {
        display: flex;
        gap: 2rem;
        align-items: flex-start;
    }

    .auth-form-section {
        flex: 1;
    }

    .auth-divider {
        display: none;
    }
}

/* ============================================================
   Responsive — Wide Screen / 4K (≥1400px) — Multi-panel layout
   Up to 3 panels visible at once, toggled via tab clicks.
   ============================================================ */

@media (min-width: 1400px) {
    #app {
        max-width: 100%;
        height: 100%;
    }

    .app-header {
        max-width: 100%;
        padding: 0.75rem 2rem 0.25rem;
    }

    .motd-bar {
        max-width: 100%;
        padding: 0.4rem 2rem;
    }

    .tab-bar {
        max-width: 100%;
        padding: 0 1rem;
        justify-content: flex-start;
        gap: 0;
    }

    .tab {
        flex: 0 0 auto;
        padding: 0.65rem 1.25rem;
    }

    /* Grid layout: visible panels fill columns, hidden ones collapse */
    .panels {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
        overflow: hidden;
        gap: 0;
        align-items: stretch;
    }

    /* Visible panels shown as grid columns with separator */
    .panels .panel:not(.hidden) {
        border-right: 1px solid var(--border);
        overflow-y: auto;
    }

    /* Playlist panel: preserve flex-column layout for sticky selector */
    .panels #panel-playlist:not(.hidden) {
        overflow: hidden;
    }

    /* Panel content width unconstrained in wide mode */
    .panels .panel-scroll {
        max-width: 100%;
        width: 100%;
    }
}
