/* ==========================================================================
   Beulah Choir Portal — Dark Studio Theme (spec revision)
   Palette:  #121212 canvas / #1e1e1e surfaces
   Accents:  #00E676 primary, #3F51B5 secondary
   Motion:   cubic-bezier(0.4, 0, 0.2, 1)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Design Tokens
   -------------------------------------------------------------------------- */
:root {
    --bg-body:      #121212;
    --bg-surface:   #1e1e1e;
    --bg-elevated:  #242424;
    --bg-input:     #181818;

    --accent:        #00E676;
    --accent-soft:   rgba(0, 230, 118, 0.14);
    --accent-border: rgba(0, 230, 118, 0.38);

    --indigo:        #3F51B5;
    --indigo-hover:  #5c6bc0;
    --indigo-soft:   rgba(63, 81, 181, 0.18);

    --text-primary:   #ececee;
    --text-secondary: #9e9ea6;
    --text-muted:     #6e6e78;

    --danger:  #ef5350;
    --warning: #ffb74d;
    --success: #66bb6a;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.3, 0.4, 1);

    --header-h: 64px;
    --dock-h:   168px;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

html.lock-viewport,
html.lock-viewport body {
    height: 100vh;
    height: 100dvh;        /* mobile browsers: excludes collapsing URL bar */
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a         { color: var(--accent); text-decoration: none; transition: color 200ms var(--ease); }
a:hover   { color: #4dff9c; }
button    { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* --------------------------------------------------------------------------
   2. App Shell — 100vh grid: header / main / dock
   -------------------------------------------------------------------------- */
#app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "header"
        "main";
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    width: 100%;
    background: var(--bg-body);
}
#app-shell > * { min-width: 0; }

/* ---- Header ---- */
#app-header {
    grid-area: header;
    background: var(--bg-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 20;
}

.app-header-row {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 0 1.1rem;
    height: var(--header-h);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.02em;
}
.app-logo:hover { color: var(--text-primary); }

.app-logo-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--indigo));
    color: #0d0d0d;
    font-size: 1.05rem;
}

.app-logo-text { font-size: 1.05rem; }

/* View toggles */
.view-toggles {
    display: flex;
    gap: 0.35rem;
    margin-left: 0.5rem;
}

.view-toggle {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    border: 1px solid transparent;
    transition: all 220ms var(--ease);
}
.view-toggle:hover { color: var(--text-primary); background: var(--bg-elevated); }
.view-toggle.is-active {
    color: #0d0d0d;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-border), 0 4px 14px rgba(0, 230, 118, 0.22);
}

.app-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: right;
    font-size: 0.9rem;
}
.user-badge small {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.logout-link {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
}
.logout-link:hover { color: var(--danger); background: rgba(239, 83, 80, 0.1); }

/* Schedule bar */
.schedule-bar {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 1.1rem;
    background: linear-gradient(90deg, rgba(63, 81, 181, 0.16), rgba(0, 230, 118, 0.08));
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: nowrap;
}

.schedule-icon { font-size: 1rem; }
.schedule-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
}
.schedule-date { color: var(--text-primary); font-weight: 600; }

.schedule-chip {
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: all 200ms var(--ease);
}
.schedule-chip:hover {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
}
.schedule-notes { color: var(--warning); font-style: italic; }
.schedule-empty { color: var(--text-muted); }

/* ---- Main content ---- */
#main-content {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    /** Reserve room so content never hides behind the fixed mixer dock. */
    padding: 1.2rem 1.2rem calc(var(--dock-h) + 1.4rem + env(safe-area-inset-bottom));
    scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   3. Auth pages
   -------------------------------------------------------------------------- */
.auth-shell {
    min-height: calc(100vh - var(--header-h));
    min-height: calc(100dvh - var(--header-h));
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(60% 40% at 50% 0%, rgba(0, 230, 118, 0.07), transparent 60%),
        radial-gradient(50% 40% at 80% 100%, rgba(63, 81, 181, 0.09), transparent 60%),
        var(--bg-body);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-lg);
    padding: 2.2rem 2rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    animation: rise-in 500ms var(--ease) both;
}

@keyframes rise-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 1rem;
    border-radius: 14px;
    font-size: 1.5rem;
    color: #0d0d0d;
    background: linear-gradient(135deg, var(--accent), var(--indigo));
}

.auth-title { text-align: center; font-size: 1.35rem; }
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0.2rem 0 1.6rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
}

.field input,
.search-input,
.schedule-input,
.role-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.field input:focus,
.search-input:focus,
.schedule-input:focus,
.role-select:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------------------------------------------------------
   4. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 200ms var(--ease);
}

.btn-primary {
    background: var(--accent);
    color: #0d0d0d;
    box-shadow: 0 4px 14px rgba(0, 230, 118, 0.25);
}
.btn-primary:hover {
    background: #33f08c;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 230, 118, 0.32);
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.btn-danger {
    background: rgba(239, 83, 80, 0.12);
    color: var(--danger);
    border: 1px solid rgba(239, 83, 80, 0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-block { width: 100%; }
.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.75rem; }

/* --------------------------------------------------------------------------
   5. Panels & repertoire
   -------------------------------------------------------------------------- */
.page-panel {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    animation: rise-in 400ms var(--ease) both;
}

.panel-head {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.panel-title { font-size: 1.2rem; }
.panel-count { color: var(--text-muted); font-size: 0.82rem; }

.search-input { margin-bottom: 1.4rem; }

.song-group { margin-bottom: 1.6rem; }
.song-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    margin-bottom: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.song-group-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
}

.song-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.7rem;
}

.song-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 220ms var(--ease);
}
.song-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
    background: linear-gradient(160deg, var(--bg-elevated), rgba(0, 230, 118, 0.05));
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.song-hymn {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.08em;
}
.song-title { font-weight: 600; font-size: 0.95rem; }
.song-meta { font-size: 0.75rem; color: var(--text-muted); }

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.9rem;
}
.empty-state code { color: var(--accent); background: var(--bg-elevated); padding: 0.1rem 0.4rem; border-radius: 4px; }

/* --------------------------------------------------------------------------
   6. Split-screen music viewer (lyrics | PDF)
   -------------------------------------------------------------------------- */
.split-panel { padding: 1.1rem; }

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

.split-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}
.song-hymn-lg {
    font-size: 0.8rem;
    font-weight: 800;
    color: #0d0d0d;
    background: var(--accent);
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    letter-spacing: 0.05em;
}
.split-title { font-size: 1.25rem; }
.split-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-elevated);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.split-body {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) minmax(320px, 3fr);
    gap: 1rem;
    height: calc(100vh - var(--header-h) - var(--dock-h) - 10.5rem);
    height: calc(100dvh - var(--header-h) - var(--dock-h) - 10.5rem);
    min-height: 320px;
}

.split-lyrics {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    overflow-y: auto;
}

.lyric-line {
    margin-bottom: 0.9rem;
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--text-primary);
    font-weight: 500;
}

.split-score {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
}

.score-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #2b2b2b;
}

.score-empty {
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 2.4rem;
}
.score-empty p { font-size: 0.9rem; }

/* --------------------------------------------------------------------------
   7. Admin roster
   -------------------------------------------------------------------------- */
.admin-panel { max-width: 1100px; }

.table-wrap { overflow-x: auto; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: var(--radius-md); }

.roster-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

.roster-table th {
    text-align: left;
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.roster-table td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.roster-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.row-unverified td { background: rgba(255, 183, 77, 0.04); }
.td-name { font-weight: 600; }
.td-actions { white-space: nowrap; }

.inline-form { display: inline-block; margin-right: 0.35rem; }

.role-select { width: auto; padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.04em;
}
.badge-ok   { color: #0d0d0d; background: var(--accent); }
.badge-warn { color: #1c1405; background: var(--warning); }

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

.admin-section { margin-top: 1.8rem; }

.schedule-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
    align-items: center;
}
.schedule-input { width: auto; min-width: 150px; }

.upcoming-list {
    list-style: none;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.9rem;
}
.upcoming-list li {
    padding: 0.6rem 0.9rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--indigo);
}
.upcoming-list em { color: var(--warning); font-size: 0.8rem; margin-left: 0.5rem; }

/* --------------------------------------------------------------------------
   8. Flash messages
   -------------------------------------------------------------------------- */
.flash-bar {
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: rise-in 300ms var(--ease) both;
}
.flash-success { background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--accent); }
.flash-info    { background: var(--indigo-soft); border: 1px solid rgba(63, 81, 181, 0.4); color: #9fb0ff; }
.flash-warning { background: rgba(255, 183, 77, 0.12); border: 1px solid rgba(255, 183, 77, 0.35); color: var(--warning); }
.flash-danger  { background: rgba(239, 83, 80, 0.12); border: 1px solid rgba(239, 83, 80, 0.35); color: var(--danger); }

.flash-close { color: inherit; opacity: 0.6; font-size: 1.1rem; line-height: 1; }
.flash-close:hover { opacity: 1; }

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

/* --------------------------------------------------------------------------
   9. Studio Mixer Dock
   -------------------------------------------------------------------------- */
#studio-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 0.9rem;
    align-items: center;
    padding: 0.7rem 1.1rem calc(0.7rem + env(safe-area-inset-bottom));
    min-height: var(--dock-h);
    z-index: 40;
    transform: translateY(0);
    transition: transform 280ms var(--ease), visibility 280ms;
    will-change: transform;
}
/* Auto-hide: slide the dock below the screen after a few idle seconds
   (re-shown on any interaction — see :root.dock-hidden in app.js). */
html.dock-hidden #studio-dock {
    transform: translateY(calc(100% + env(safe-area-inset-bottom) + 10px));
    visibility: hidden;
    pointer-events: none;
}

/* Dock is fixed/out-of-flow, so each panel gets an expand affordance. */
.split-lyrics, .split-score { position: relative; }

.panel-expand {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}
.panel-expand svg { width: 17px; height: 17px; }
.panel-expand:hover, .panel-expand:focus-visible { opacity: 1; color: var(--accent); border-color: var(--accent-border); }
.split-lyrics:hover .panel-expand,
.split-score:hover .panel-expand { opacity: 1; }
@media (hover: none) {
    .panel-expand { opacity: 0.85; }
}

/* Slim trace bar shown while the dock is hidden */
#dock-peek {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 39;
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem calc(0.4rem + env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    animation: rise-in 200ms var(--ease) both;
}
html.dock-hidden #dock-peek { display: flex; }

.peek-title {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.peek-btn, .peek-play {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.95rem;
    transition: all 180ms var(--ease);
}
.peek-btn:hover { color: var(--accent); border-color: var(--accent-border); }
.peek-play {
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #0d0d0d;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(0, 230, 118, 0.3);
}
.peek-play:hover { background: #33f08c; }

/* Track info */
#dock-track-info { display: flex; flex-direction: column; min-width: 0; }
#dockTitle {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#dockMeta { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Transport */
#dock-transport { display: flex; align-items: center; gap: 0.5rem; }

.dock-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
    transition: all 200ms var(--ease);
}
.dock-btn:hover { border-color: var(--accent-border); color: var(--accent); }
.dock-btn.is-active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

.dock-play-btn {
    width: 54px;
    height: 54px;
    background: var(--accent);
    color: #0d0d0d;
    font-size: 1.15rem;
    box-shadow: 0 6px 20px rgba(0, 230, 118, 0.35);
}
.dock-play-btn:hover { background: #33f08c; color: #0d0d0d; transform: scale(1.05); }

/* Timeline */
#dock-timeline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 220px;
}
.dock-time { font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

#dockProgress {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 5px;
    border-radius: 4px;
    background: var(--bg-elevated);
    outline: none;
}
#dockProgress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.5);
}

/* Fader rack */
#dock-faders {
    display: flex;
    gap: 0.55rem;
    align-items: flex-end;
}

.dock-channel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all 220ms var(--ease);
}
.dock-channel:hover { background: var(--bg-elevated); border-color: rgba(255, 255, 255, 0.06); }
.dock-channel.is-missing { opacity: 0.35; }
.dock-channel.is-missing .dock-fader { opacity: 0.4; }

.dock-channel-value {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.dock-fader {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    width: 26px;
    height: 96px;
    background: var(--bg-input);
    border-radius: 6px;
    outline: none;
    transition: all 200ms var(--ease);
}
.dock-fader:hover { box-shadow: 0 0 0 2px var(--accent-soft); }

.dock-channel-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   10. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    #studio-dock {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "info transport"
            "timeline timeline"
            "faders faders";
    }
    #dock-track-info { grid-area: info; }
    #dock-transport  { grid-area: transport; }
    #dock-timeline   { grid-area: timeline; }
    #dock-faders     { grid-area: faders; justify-content: center; }
}

@media (max-width: 760px) {
    :root { --header-h: 58px; --dock-h: 190px; }

    .app-header-row { flex-wrap: wrap; height: auto; padding: 0.55rem 0.8rem; gap: 0.5rem; }
    .app-logo-text { display: none; }
    .view-toggles { order: 3; width: 100%; justify-content: center; margin-left: 0; }
    .user-badge { display: none; }

    .schedule-bar { padding: 0.4rem 0.8rem; }

    #main-content { padding: 0.8rem 0.8rem calc(var(--dock-h) + 1.2rem + env(safe-area-inset-bottom)); }

    .split-body {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .split-lyrics { max-height: 40vh; max-height: 40dvh; }
    .split-score { height: 55vh; height: 55dvh; }

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

    .schedule-form { flex-direction: column; align-items: stretch; }
    .schedule-input { width: 100%; }

    #studio-dock { padding: 0.6rem 0.7rem calc(0.6rem + env(safe-area-inset-bottom)); }
    #dock-peek { padding: 0.4rem 0.7rem calc(0.4rem + env(safe-area-inset-bottom)); }
    .dock-fader { height: 72px; width: 22px; }
    #dock-timeline { min-width: 0; }

    /* iOS standalone: keep content clear of the notch & home indicator */
    #app-header {
        padding-top: env(safe-area-inset-top);
    }
    #studio-dock {
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
    }
    #main-content {
        padding-bottom: calc(var(--dock-h) + 1.2rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 420px) {
    :root { --dock-h: 174px; }
    .dock-fader { height: 56px; }
    #dock-transport .dock-btn { padding: 0.35rem 0.5rem; font-size: 0.9rem; }
    #dockProgress { min-width: 0; }
}

/* --------------------------------------------------------------------------
   11. Enterprise auth (v2)
   -------------------------------------------------------------------------- */
.standalone-auth { background: var(--bg-body); }
.auth-card-wide { max-width: 460px; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 1.2rem 0 0.9rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: #ffffff;
    color: #202124;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-google:hover { background: #f1f3f4; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }

.auth-links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-links a { color: var(--accent); }
.auth-sep { opacity: 0.4; }

.dev-token-box {
    margin-top: 0.8rem;
    padding: 0.8rem 1rem;
    border: 1px dashed rgba(0, 230, 118, 0.4);
    border-radius: var(--radius-sm);
    background: rgba(0, 230, 118, 0.05);
    font-size: 0.82rem;
    line-height: 1.6;
    display: grid;
    gap: 0.3rem;
}
.dev-token-box a { color: var(--accent); font-weight: 700; word-break: break-all; }
.dev-token-box code {
    color: var(--text-muted);
    font-size: 0.72rem;
    word-break: break-all;
}

/* --------------------------------------------------------------------------
   12. Admin Suite (v2) — AI, uploader/trimmer, activity matrix
   -------------------------------------------------------------------------- */
.admin-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0.2rem 0 0.6rem;
}

/* ---- AI recommender ---- */
.ai-results { margin-top: 0.9rem; display: grid; gap: 0.7rem; }
.ai-engine { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.ai-card {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    animation: rise-in 300ms var(--ease) both;
}
.ai-card-head { display: flex; align-items: center; gap: 0.8rem; }
.ai-card-head .song-hymn-lg { font-size: 1.2rem; min-width: 2.6rem; }
.ai-card-title { flex: 1; min-width: 0; }
.ai-card-title a { color: var(--text-bright); font-weight: 700; font-size: 0.95rem; text-decoration: none; }
.ai-card-title a:hover { text-decoration: underline; }
.ai-card-title small { display: block; color: var(--text-muted); font-size: 0.74rem; }

.ai-score {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--accent);
}
.ai-scorebar { height: 5px; background: var(--bg-input); border-radius: 999px; margin: 0.5rem 0 0.35rem; overflow: hidden; }
.ai-scorebar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.ai-reason { font-size: 0.78rem; color: var(--text-muted); }

/* ---- Uploader & waveform trimmer ---- */
.upload-grid { display: grid; grid-template-columns: 1fr 2fr 1.5fr; gap: 0.8rem; }

.stem-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.7rem;
    margin-top: 1rem;
}
.stem-cell {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.stem-cell.is-full { grid-column: 1 / -1; }
.stem-cell label.field-label em { color: var(--accent); font-style: normal; }

.stem-input {
    font-size: 0.74rem;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    width: 100%;
}
.stem-input::file-selector-button {
    background: var(--bg-elevated);
    color: var(--text-bright);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    margin-right: 0.6rem;
    cursor: pointer;
}

.waveform {
    width: 100%;
    height: 70px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: var(--bg-body);
}

.trim-meta { font-size: 0.72rem; color: var(--text-muted); }
.trim-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.3rem; }
.trim-controls label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; }
.trim-controls input[type="number"] {
    width: 4.5rem;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-bright);
    padding: 0.2rem 0.3rem;
    font-size: 0.72rem;
}

.upload-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.1rem; }
.upload-status { font-size: 0.82rem; color: var(--text-muted); }
.upload-status.is-ok  { color: var(--accent); font-weight: 700; }
.upload-status.is-err { color: var(--danger, #ff6b6b); font-weight: 700; }

/* ---- Activity matrix ---- */
.presence-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.55;
    margin-right: 0.45rem;
    vertical-align: 1px;
}
.presence-dot.is-online { background: var(--accent); opacity: 1; box-shadow: 0 0 8px rgba(0, 230, 118, 0.6); }

.badge-online { color: #04210f; background: var(--accent); }

.practice-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
    font-size: 0.8rem;
}

@media (max-width: 760px) {
    .upload-grid { grid-template-columns: 1fr 1fr; }
    .stem-fields { grid-template-columns: 1fr 1fr; }
    .ai-card-head { flex-wrap: wrap; }
}

/* --------------------------------------------------------------------------
   13. Choral Repertoire System (v3) — filters, lifecycle badges, song manager
   -------------------------------------------------------------------------- */
/* ---- Filter toolbar ---- */
.filter-toolbar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.filter-toolbar .search-input { margin-bottom: 0; flex: 1 1 260px; }

.filter-select {
    min-width: 160px;
    background: var(--bg-input);
    color: var(--text-bright);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.filter-select:hover, .filter-select:focus { border-color: var(--accent-border); outline: none; }

/* ---- Song card badges & composer ---- */
.song-card-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
    min-height: 0.8rem;
}

.badge-learn { color: #1c1405; background: var(--warning); }
.badge-arch  { color: #0d0d0d; background: #8b8b93; }
.badge-genre {
    color: #dbe4ff;
    background: rgba(96, 125, 242, 0.22);
    border: 1px solid rgba(96, 125, 242, 0.4);
    text-transform: none;
    letter-spacing: 0;
}

.song-composer {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.split-composer {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ---- Song manager ---- */
.song-manager-wrap { max-height: 480px; overflow-y: auto; }
.song-manager-table .td-name strong { display: flex; align-items: center; gap: 0.5rem; }

.status-toggle {
    background: var(--bg-input);
    color: var(--text-bright);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.status-toggle:focus { outline: none; border-color: var(--accent-border); }
.status-toggle[data-status="learning"] { border-color: rgba(255, 179, 71, 0.55); }
.status-toggle[data-status="mastered"] { border-color: rgba(0, 230, 118, 0.55); }

.store-state { margin-left: 0.5rem; font-size: 0.78rem; font-weight: 700; }
.store-state.store-pending { color: var(--text-muted); }
.store-state.store-ok  { color: var(--accent); }
.store-state.store-err { color: var(--danger, #ff6b6b); max-width: 8rem; }

/* ---- Edit modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.72);
    animation: fade-in 200ms var(--ease) both;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
    width: 100%;
    max-width: 560px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
    animation: rise-in 240ms var(--ease) both;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.modal-head h3 { font-size: 1.05rem; }
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { color: var(--text-bright); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

.edit-status { font-size: 0.82rem; margin-top: 0.5rem; }
.edit-status.is-err { color: var(--danger, #ff6b6b); }

.modal-card-wide { max-width: 720px; }
.audio-song-sub { font-size: 0.82rem; margin: -0.4rem 0 0.9rem; }

.audio-stem-rows { display: grid; gap: 0.55rem; max-height: 58vh; overflow-y: auto; }
.audio-stem-row {
    display: grid;
    grid-template-columns: minmax(92px, 150px) minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}
.audio-stem-name { font-weight: 700; font-size: 0.85rem; }
.audio-stem-file {
    font-size: 0.76rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    text-align: left;
}
.audio-stem-file.is-missing { color: var(--danger, #ff6b6b); }
.audio-stem-input { font-size: 0.76rem; max-width: 220px; }
.audio-stem-state { font-size: 0.76rem; font-weight: 600; min-width: 52px; }
.audio-stem-state.is-ok  { color: var(--accent, #00e676); }
.audio-stem-state.is-err { color: var(--danger, #ff6b6b); }

@media (max-width: 620px) {
    .audio-stem-row { grid-template-columns: 1fr auto; }
    .audio-stem-file { grid-column: 1 / -1; direction: ltr; }
    .audio-stem-input { grid-column: 1 / -1; max-width: none; }
}

.field-title-hint { font-size: 0.74rem; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.upload-grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

@media (max-width: 760px) {
    .filter-toolbar .filter-select { flex: 1 1 140px; }
    .modal-card { padding: 1rem; }
}


/* Voice-part badge (admin roster) */
.part-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.5rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.4;
}

/* --------------------------------------------------------------------------
   14. Fullscreen viewer — scores & lyrics (click / double-click)
   -------------------------------------------------------------------------- */
#fullscreen-view {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    background: #0b0b0b;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    animation: fade-in 180ms var(--ease) both;
}
#fullscreen-view[hidden] { display: none; }

.fullscreen-sheet {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.fullscreen-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    transition: all 180ms var(--ease);
}
.fullscreen-close:hover { background: var(--accent); color: #0d0d0d; border-color: var(--accent); }
.fullscreen-close svg { width: 20px; height: 20px; }

#fullscreenBody { height: 100%; overflow: auto; }

.fs-lyrics {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.4rem calc(2rem + env(safe-area-inset-bottom));
    font-size: 1.4rem;
    line-height: 1.75;
}
.fs-lyrics .lyric-line {
    margin-bottom: 1.2rem;
    color: var(--text-primary);
    font-weight: 500;
}

.fs-score { width: 100%; height: 100%; }
.fs-score-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: #2b2b2b;
}

/* Dock hidden: keep the slim trace bar visible — reserve its height so
   content still clears it (replaces the full-dock reserve above). */
html.dock-hidden #main-content {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
    #studio-dock { transition: none; }
    #fullscreen-view { animation: none; }
}

/* --------------------------------------------------------------------------
   15. Admin sub-page tabs
   -------------------------------------------------------------------------- */
.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.4rem;
}
.admin-tab {
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 180ms var(--ease);
}
.admin-tab:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.admin-tab.is-active {
    color: #0d0d0d;
    background: var(--accent);
    border-color: var(--accent);
}

@media (max-width: 420px) {
    .admin-tab { flex: 1 1 40%; text-align: center; }
}
