/* =====================================================================
   BandSync — "The Rehearsal Room"
   Warm, analog, after-hours. Dark "stage" by default; "sheet music"
   paper in light mode. No infinite feeds, no glossy social chrome.
   ===================================================================== */

/* ---- Fonts (self-hosted, SIL OFL) ---- */
@font-face {
    font-family: "Fraunces";
    src: url("/lib/fonts/fraunces.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}
@font-face {
    font-family: "Figtree";
    src: url("/lib/fonts/figtree.woff2") format("woff2");
    font-weight: 300 900;
    font-display: swap;
}
@font-face {
    font-family: "Figtree";
    src: url("/lib/fonts/figtree-italic.woff2") format("woff2");
    font-weight: 300 900;
    font-style: italic;
    font-display: swap;
}

/* ---- Tokens: light = sheet-music paper ---- */
:root {
    --bg: #f4ede0;
    --bg-glow: rgba(214, 140, 60, .16);
    --surface: #fffaf1;
    --surface-2: #f1e7d6;
    --surface-3: #e8dcc6;
    --text: #231b13;
    --muted: #6d604f;
    --border: #dccdb4;
    --border-strong: #c9b597;
    --accent: #c25a14;
    --accent-strong: #a64a0c;
    --accent-ink: #fff8ef;
    --accent-soft: rgba(194, 90, 20, .12);
    --teal: #2b7a6f;
    --teal-soft: rgba(43, 122, 111, .12);
    --record: #cf3236;
    --ok: #2d7a4b;
    --warn: #9a5a00;
    --bad: #b42318;
    --amp: #1b1712;
    --amp-text: #efe5d4;
    --amp-muted: #a89a84;
    --brass: #d9a24a;
    --amp-hi: #221d17;
    --amp-edge: #3a3027;
    --spark: #ffd28a;
    --mark: #d9a24a;
    --score-accent: #c25a14;
    --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 10px 28px -16px rgba(70, 45, 15, .35);
    --shadow-pop: 0 18px 48px -12px rgba(50, 30, 10, .45);
    --radius: 14px;
    --radius-sm: 10px;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}

/* ---- Tokens: dark = the stage ---- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #13100d;
        --bg-glow: rgba(240, 164, 58, .11);
        --surface: #1e1915;
        --surface-2: #29221c;
        --surface-3: #342b23;
        --text: #f2e8d8;
        --muted: #b2a48e;
        --border: #3a3129;
        --border-strong: #4e4236;
        --accent: #f0a43a;
        --accent-strong: #ffb755;
        --accent-ink: #1b1105;
        --accent-soft: rgba(240, 164, 58, .14);
        --teal: #5cc0b0;
        --teal-soft: rgba(92, 192, 176, .14);
        --record: #ff5d5f;
        --ok: #5fd08a;
        --warn: #f2bd4c;
        --bad: #ff7a70;
        --amp: #0d0b09;
        --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 14px 36px -18px rgba(0, 0, 0, .8);
        --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, .75);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #13100d; --bg-glow: rgba(240, 164, 58, .11); --surface: #1e1915; --surface-2: #29221c; --surface-3: #342b23;
    --text: #f2e8d8; --muted: #b2a48e; --border: #3a3129; --border-strong: #4e4236; --accent: #f0a43a; --accent-strong: #ffb755;
    --accent-ink: #1b1105; --accent-soft: rgba(240, 164, 58, .14); --teal: #5cc0b0; --teal-soft: rgba(92, 192, 176, .14);
    --record: #ff5d5f; --ok: #5fd08a; --warn: #f2bd4c; --bad: #ff7a70; --amp: #0d0b09;
    --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 14px 36px -18px rgba(0, 0, 0, .8);
    --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, .75);
    color-scheme: dark;
}

/* ---- Base ---- */
* { box-sizing: border-box; }

/* The hidden attribute must win over component display rules (grid, flex, inline-flex…). */
[hidden] { display: none !important; }

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

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font: 16px/1.55 var(--font-body);
    background:
        radial-gradient(1200px 520px at 50% -180px, var(--bg-glow), transparent 70%),
        var(--bg);
    background-attachment: fixed;
}

/* Faint grain, like a worn rehearsal-room wall. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    opacity: .05;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

h1, h2, h3, .display {
    font-family: var(--font-display);
    font-variation-settings: "SOFT" 60, "WONK" 0, "opsz" 72;
    letter-spacing: -.01em;
    line-height: 1.15;
}
h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 650; margin: 0 0 6px; }
/* Signature: five staff lines under every page title. */
h1::after {
    content: "";
    display: block;
    width: 64px;
    height: 13px;
    margin-top: 12px;
    background: repeating-linear-gradient(to bottom, var(--accent) 0 1px, transparent 1px 3px);
    opacity: .7;
}
.hero h1::after, .form-card h1::after, .no-staff::after { display: none; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
h3 { font-family: var(--font-body); font-size: 12px; font-weight: 700; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

p { margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--bad); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.grow { flex: 1 1 auto; min-width: 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 4px 0 4px 22px; position: relative; }
ul.plain li::before { content: "♪"; position: absolute; left: 0; color: var(--accent); }
blockquote {
    margin: 0 0 14px;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    white-space: pre-wrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Top bar: an amp panel ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px 20px;
    flex-wrap: wrap;
    padding: 10px max(var(--gutter), calc((100% - var(--page-max)) / 2));
    color: var(--amp-text);
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, .018) 0 2px, transparent 2px 5px),
        linear-gradient(to bottom, var(--amp-hi), var(--amp));
    border-bottom: 2px solid var(--brass);
    box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .6);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--amp-text);
    text-decoration: none;
    font-family: var(--font-display);
    font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 48;
    font-weight: 700;
    font-size: 21px;
}
.brand:hover { color: #fff; }
.brand svg { width: 26px; height: 28px; flex: none; }
.nav-main { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-main a, .nav-user > a:not(.button) {
    color: var(--amp-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    padding: 6px 12px;
    border-radius: 999px;
}
.nav-main a:hover, .nav-user > a:not(.button):hover { color: var(--amp-text); background: rgba(255, 255, 255, .06); }
.nav-main a[aria-current="page"] { color: var(--amp-text); background: color-mix(in srgb, var(--brass) 16%, transparent); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-user form { margin: 0; }
.nav-user .me { display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px !important; }
.topbar .ghost { color: var(--amp-muted); border-color: rgba(255, 255, 255, .14); }
.topbar .ghost:hover:not(:disabled) { color: var(--amp-text); border-color: rgba(255, 255, 255, .3); }

/* ---- Page ---- */
/* Wide screens get a wide page: gutters grow with the window, and the top bar lines up with the content. */
:root { --page-max: 2400px; --gutter: clamp(16px, 3vw, 64px); }
.page { max-width: calc(var(--page-max) + 2 * var(--gutter)); margin: 0 auto; padding: 32px var(--gutter) 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 4px; }
.page-head h1, .page-head h2 { margin-right: 4px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    min-width: 0;
    box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }
.card.narrow { max-width: 560px; margin-top: 24px; }
.card.danger { border-color: color-mix(in srgb, var(--record) 40%, var(--border)); }
.card.request { margin-bottom: 16px; }

.form-card {
    max-width: 460px;
    margin: 24px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
.form-card button[type=submit].primary { width: 100%; margin-top: 4px; }
.form-card .row button[type=submit].primary { width: auto; flex: 1; }

.empty {
    color: var(--muted);
    padding: 22px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
    background: color-mix(in srgb, var(--surface) 50%, transparent);
}

.row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 10px 0; }
.row.options { align-items: center; gap: 20px; font-size: 14px; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); margin: 10px 0 14px; min-width: 0; }
.field .hint { font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0 14px; }

input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    min-width: 0;
    max-width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { width: 110px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }
input[type=file] { font: inherit; font-size: 14px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 600; margin-right: 10px; padding: 7px 12px; cursor: pointer;
    color: var(--text); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 8px;
}
textarea { resize: vertical; }

/* ---- Buttons: footswitches ---- */
button, .button {
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-bottom-width: 3px;
    border-radius: var(--radius-sm);
    padding: 8px 16px 7px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform .06s, background-color .15s, border-color .15s;
    white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); color: var(--text); }
button:active:not(:disabled), .button:active { transform: translateY(1px); border-bottom-width: 2px; padding-bottom: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .button.primary {
    color: var(--accent-ink);
    background: linear-gradient(to bottom, var(--accent-strong), var(--accent));
    border-color: var(--accent-strong);
    border-bottom-color: color-mix(in srgb, var(--accent) 60%, #000);
}
button.primary:hover:not(:disabled), .button.primary:hover { color: var(--accent-ink); filter: brightness(1.06); }
button.record {
    color: #fff;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--record) 85%, #fff), var(--record));
    border-color: var(--record);
    border-bottom-color: color-mix(in srgb, var(--record) 60%, #000);
}
button.record:hover:not(:disabled) { color: #fff; filter: brightness(1.06); }
button.ghost, .button.ghost { background: transparent; border-bottom-width: 1px; }
button.ghost:active:not(:disabled), .button.ghost:active { border-bottom-width: 1px; padding-bottom: 7px; }
button.small, .button.small { font-size: 13px; padding: 5px 11px 4px; }
.file-button { cursor: pointer; }

/* ---- Pills & badges ---- */
.pill {
    display: inline-block;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.pill.good { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.pill.fair { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.pill.poor, .pill.none { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
/* On air (playing now): white on a deep red that keeps 4.5:1 in every palette, with a pulsing dot
   so the word itself never fades. Not "live": Practice's live score panel owns .live. */
.pill.on-air { display: inline-flex; align-items: center; gap: 6px; color: #fff; background: color-mix(in srgb, var(--record) 78%, #000); border-color: transparent; font-weight: 800; letter-spacing: .06em; }
.pill.on-air::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-in-out infinite; }
.pill.countin { color: var(--warn); border-color: var(--warn); }
.pill.leader { font-family: var(--font-body); color: var(--accent); background: var(--accent-soft); border-color: transparent; }
@keyframes pulse { 50% { opacity: .65; } }

/* ---- Alerts (no-JS fallback for toasts, and inline form errors) ---- */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    margin: 0 0 16px;
    font-size: 15px;
}
.alert.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.alert.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.alert ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none; }

/* ---- Avatars ---- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);
    background: var(--surface-3);
}
.avatar.initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent-ink);
    background: linear-gradient(135deg, var(--accent), var(--teal));
}
.avatar-edit { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }

/* ---- Groups ---- */
.group-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.group-list a {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px 18px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.group-list a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.group-list b { font-family: var(--font-display); font-size: 19px; font-weight: 650; display: block; }
.monogram {
    width: 48px; height: 48px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 750; font-size: 20px;
    color: var(--accent-ink);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--teal)));
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
/* Member slots: filled = member, ring = free slot. The cap at a glance. */
.slots { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; vertical-align: middle; }
.slots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.slots i.on { background: var(--accent); border-color: var(--accent); }
.slots i.invite { border-style: dashed; border-color: var(--accent); }

.members { list-style: none; padding: 0; margin: 0 0 14px; }
.members li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.members li:last-child { border-bottom: 0; }
.members form { margin: 0; }

.invite-link { display: flex; gap: 8px; margin: 8px 0 6px; }
.invite-link input { flex: 1; font-family: var(--mono); font-size: 13px; }
.invites li { display: flex; align-items: center; gap: 10px; }
.invites li::before { top: 9px; }
.invites form { margin: 0; }

td.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
td.actions form { margin: 0; }

/* ---- Landing ---- */
.hero {
    position: relative;
    padding: 56px 0 40px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    gap: 32px;
    align-items: center;
}
.hero h1 {
    font-size: clamp(38px, 6.4vw, 68px);
    font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
    font-weight: 700;
    line-height: 1.02;
    margin-bottom: 18px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.lede { font-size: 19px; color: var(--muted); max-width: 34em; margin-bottom: 26px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cta .button { font-size: 17px; padding: 11px 22px 10px; }
.stave-art { width: 100%; height: auto; color: var(--text); }
.stave-art .lines line { stroke: currentColor; stroke-opacity: .28; stroke-width: 1.2; }
.stave-art .note { fill: var(--accent); }
.stave-art .note.b { fill: var(--teal); }
.stave-art .playhead { stroke: var(--accent); stroke-width: 2.5; animation: sweep 6s linear infinite; }
@keyframes sweep { from { transform: translateX(0); } to { transform: translateX(380px); } }
@media (prefers-reduced-motion: reduce) { .stave-art .playhead, .pill.on-air::before { animation: none; } }

.manifesto {
    margin: 12px 0 8px;
    padding: 26px 28px;
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, .02) 0 2px, transparent 2px 5px),
        linear-gradient(to bottom, var(--amp-hi), var(--amp));
    color: var(--amp-text);
    border: 1px solid var(--amp-edge);
    box-shadow: var(--shadow-pop);
}
.manifesto h2 { color: var(--amp-text); font-size: 24px; }
.nots { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 22px; }
.nots li { font-size: 17px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.nots li span { color: var(--amp-muted); font-weight: 400; font-size: 14px; display: block; }
.nots li::before { content: "✕"; color: var(--brass); font-weight: 800; }

.features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 34px 0; }
@media (max-width: 1000px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }
.feature { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.feature .icon {
    width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); margin-bottom: 12px;
}
.feature .icon svg { width: 24px; height: 24px; }
.feature h3 { font-family: var(--font-display); text-transform: none; letter-spacing: -.01em; font-size: 19px; color: var(--text); margin: 0 0 6px; }
.feature p { color: var(--muted); font-size: 15px; margin: 0; }

.footer { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---- Toasts ---- */
.toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 14px 13px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--teal);
    box-shadow: var(--shadow-pop);
    animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.leaving { animation: toast-out .22s ease-in forwards; }
.toast .t-icon { flex: none; width: 22px; height: 22px; color: var(--ok); margin-top: 1px; }
.toast.error .t-icon { color: var(--bad); }
.toast.info .t-icon { color: var(--teal); }
.toast .t-msg { flex: 1; font-size: 15px; line-height: 1.45; }
.toast .t-close { flex: none; padding: 2px 7px; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.toast .t-close:active { transform: none; padding: 2px 7px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@media (max-width: 560px) { .toasts { right: 16px; left: 16px; bottom: 16px; width: auto; } }

/* ---- Dialogs ---- */
dialog.modal {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-pop);
}
dialog.modal[open] { animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.15); }
dialog.modal::backdrop { background: rgba(15, 10, 5, .55); backdrop-filter: blur(3px); }
.modal-body { padding: 24px 24px 8px; }
.modal-body h2 { font-size: 22px; margin-bottom: 8px; }
.modal-body p { color: var(--muted); margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---- Audio lab ---- */
.lab-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.checks { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
.checks li::before { display: inline-block; width: 1.4em; font-weight: 700; }
.checks li.ok::before { content: "✓"; color: var(--ok); }
.checks li.bad::before { content: "✗"; color: var(--bad); }
.checks li.warn::before { content: "!"; color: var(--warn); }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; margin: 0; font-size: 14px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-family: var(--mono); font-size: 13px; text-align: right; overflow-wrap: anywhere; }
.stats.compact { margin-top: 8px; }

.meter { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; margin: 8px 0; }
#meter-fill { height: 100%; width: 0; background: linear-gradient(to right, var(--ok), var(--warn)); transition: width 60ms linear; }
#meter-fill.hot { background: var(--bad); }

.beats { display: flex; gap: 6px; align-items: center; min-height: 36px; }
.beats span { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); }
.beats span.down { width: 18px; height: 18px; }
.beats span.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--accent); }

.steps { padding-left: 20px; font-size: 14px; color: var(--muted); }
.cal-result { margin: 12px 0; font-size: 14px; }
.cal-result strong { font-family: var(--mono); }

.takes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.takes li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.takes .meta { flex: 1 1 260px; font-size: 13px; min-width: 0; }
.takes .meta b { font-size: 14px; }

.debug {
    position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); max-height: 60vh; overflow: auto;
    background: rgba(0, 0, 0, .86); color: #e5e5e5; border-radius: 8px; padding: 10px 12px; z-index: 30;
}
.debug h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #a3a3a3; }
.debug pre { margin: 0; font: 12px/1.45 var(--mono); white-space: pre-wrap; }

/* ---- Tab player ---- */
.tab-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.tab-head h2 { margin: 0; }
.tab-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.tab-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 4px 20px; margin: 8px 0; }
.tab-controls .speed { flex: 1 1 240px; }
.tab-controls .gain { width: 120px; }

.tracks { width: 100%; max-width: 760px; border-collapse: collapse; font-size: 14px; margin: 8px 0 14px; }
.tracks th { text-align: left; font-weight: 700; color: var(--muted); font-size: 12px; padding: 4px 8px; text-transform: uppercase; letter-spacing: .05em; }
.tracks td { padding: 7px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.tracks td:first-child { overflow-wrap: anywhere; }
.tracks input[type=range] { width: 120px; }

/* alphaTab draws black notation, so the score always sits on paper. */
.score-wrap {
    position: relative; height: 70vh; min-height: 320px; overflow: auto;
    background: #fdfaf3; color: #111; border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .08);
}
.score-empty { color: #6b6050; text-align: center; padding: 80px 16px; margin: 0; }
.at-cursor-bar { background: color-mix(in srgb, var(--score-accent) 18%, transparent); }
.at-cursor-beat { background: var(--score-accent); width: 3px; }
.at-highlight * { fill: var(--score-accent); stroke: var(--score-accent); }
.at-selection div { background: rgba(64, 64, 255, .1); }

/* ---- Small screens ---- */
@media (max-width: 760px) {
    .hero { grid-template-columns: 1fr; padding-top: 28px; }
    .stave-art { max-width: 420px; }
}
@media (max-width: 520px) {
    .topbar { padding: 10px 16px; }
    .nav-user .me span { display: none; }
    .card, .form-card { padding: 16px; }
}

/* ---- Practice room ---- */
.rig-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.rig-head h2 { margin: 0; }
.rig-head #rig-summary { flex: 1 1 240px; }
/* Fixed column counts: the full-width "Your sound" row would make an auto-fit grid create every track that fits, squeezing the columns. */
.rig-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 32px; margin-top: 12px; }
@media (min-width: 760px) { .rig-body { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .rig-body { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rig-col { min-width: 0; }
.rig-col select { width: 100%; }
.rig-head { cursor: default; }
.rig-head.clickable { cursor: pointer; }
.latency-list:not([hidden]) + .rig-latency-empty { display: none; }
.rig-col h3 { margin-top: 6px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline input { width: 90px; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(to right, var(--ok), var(--warn)); transition: width 60ms linear; }
.meter-fill.hot { background: var(--bad); }
.meter-fill.talk { background: linear-gradient(to right, var(--teal), var(--ok)); }
.meter-fill.talk.muted { opacity: .35; }
.card.rig { margin-bottom: 18px; }

.backing-tracks { margin: 4px 0 12px; }
.backing-tracks summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.chip.mine { border-color: var(--accent); color: var(--accent); }

.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 14px; }
button.big { font-size: 17px; padding: 11px 22px 10px; }

.live {
    display: grid;
    grid-template-columns: auto auto minmax(220px, 1fr) minmax(220px, 1.2fr);
    gap: 14px 24px;
    align-items: center;
    padding: 14px 18px;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.live-big { display: flex; flex-direction: column; align-items: center; min-width: 74px; }
.live-big span { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1; }
.live-big small, .result-acc small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.grades { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.grades b { font-family: var(--mono); color: var(--text); }
.g.perfect b { color: var(--ok); }
.g.good b, .g.ok b { color: var(--warn); }
.g.miss b { color: var(--bad); }

.timing-track { position: relative; height: 14px; border-radius: 7px; background: color-mix(in srgb, var(--bad) 25%, var(--surface-3)); overflow: hidden; }
.timing-track .zone { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); }
.timing-track .zone.ok { width: 100%; background: color-mix(in srgb, var(--warn) 18%, transparent); }
.timing-track .zone.good { width: 62.5%; background: color-mix(in srgb, var(--warn) 30%, transparent); }
.timing-track .zone.perfect { width: 31.25%; background: color-mix(in srgb, var(--ok) 40%, transparent); }
.needle { position: absolute; top: -2px; bottom: -2px; left: 50%; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--text); transition: left .12s ease-out; }
.needle.perfect { background: var(--ok); }
.needle.good, .needle.ok { background: var(--warn); }
.timing-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.timing-labels #lv-timing { color: var(--text); font-weight: 600; }

.score-layer { position: relative; }
.score-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.score-overlay .mark { position: absolute; border-radius: 50%; border: 2.5px solid; box-sizing: border-box; animation: mark-in .18s ease-out; }
.score-overlay .mark.perfect { border-color: #1f9d55; background: rgba(31, 157, 85, .16); }
.score-overlay .mark.good { border-color: #d48806; background: rgba(212, 136, 6, .16); }
.score-overlay .mark.miss { border-color: #d6303c; background: rgba(214, 48, 60, .14); }
@keyframes mark-in { from { transform: scale(1.6); opacity: 0; } }

.results { display: grid; grid-template-columns: auto minmax(220px, 1fr) minmax(240px, 1.4fr); gap: 18px 32px; align-items: start; margin: 8px 0 6px; }
.result-acc { display: flex; flex-direction: column; align-items: center; }
.result-acc span { font-family: var(--font-display); font-weight: 750; font-size: 64px; line-height: 1; color: var(--accent); }
.results h3 { margin-top: 0; }
.bars-strip { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 8px; }
.bars-strip span { width: 14px; height: 24px; border-radius: 3px; }
.bars-strip .hi { background: var(--ok); }
.bars-strip .mid { background: var(--warn); }
.bars-strip .lo { background: var(--bad); }
.history td { font-size: 14px; }
.t-action { margin-left: 10px; vertical-align: middle; }

@media (max-width: 860px) {
    .live { grid-template-columns: auto auto 1fr; }
    .live .timing { grid-column: 1 / -1; }
    .results { grid-template-columns: 1fr; }
}

/* ---- Bell ---- */
.bell { position: relative; display: inline-flex !important; align-items: center; padding: 6px 8px !important; }
.bell svg { width: 20px; height: 20px; }
.bell .badge {
    position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--record); color: #fff; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Notifications page ---- */
.notes { list-style: none; padding: 0; margin: 20px 0; max-width: 760px; }
.notes li { display: flex; align-items: baseline; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.notes .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; }
.notes li.unread .dot { background: var(--accent); }
.notes li.unread { font-weight: 600; }

/* ---- Band home ---- */
.band-hero { display: flex; align-items: center; gap: 18px; margin: 4px 0 18px; }
.band-hero h1 { margin: 0 0 4px; }
.monogram.big { width: 72px; height: 72px; font-size: 32px; border-radius: 18px; }
.band-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.band-main, .band-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.session-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; justify-content: space-between; }
.session-card > div { flex: 1 1 320px; }
.member-cards { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.member-cards li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.member-cards li:last-child { border-bottom: 0; }
.member-cards b { margin-right: 6px; }
.member-actions { display: flex; gap: 6px; }
.member-actions form { margin: 0; }
.instrument-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip.small { padding: 2px 10px; font-size: 13px; cursor: default; }
.chip.main { border-color: var(--accent); color: var(--accent); }
.tab-list { list-style: none; padding: 0; margin: 0 0 12px; }
.tab-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tab-list form { margin: 0; }
.tab-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 18px; flex: none; }
@media (max-width: 860px) { .band-layout { grid-template-columns: 1fr; } }
