/* ══════════════════════════════════════════════════════════════
   Virtuoso Piano — Performance Interface
   Design system: minimalist dark + subtle glassmorphism
   Palette based on the Stitch/Material3 tokens supplied with the
   design documents (charcoal surfaces, electric-cyan accent).
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg:             #131313;
    --surface:        #1f2020;
    --surface-low:    #1b1c1c;
    --surface-lowest: #0e0e0e;
    --surface-high:   #2a2a2a;
    --surface-hi:     #353535;
    --on-surface:     #e4e2e1;
    --on-surface-v:   #c4c7c7;
    --muted:          #8e9192;
    --outline:        #444748;
    --primary:        #c8c6c5;
    --tertiary:       #00daf3;
    --tertiary-soft:  rgba(0,218,243,0.12);
    --accent:         #a060ff;
    --accent-soft:    rgba(160,96,255,0.14);

    --radius-sm:  0.125rem;
    --radius:     0.25rem;
    --radius-md:  0.375rem;
    --radius-lg:  0.5rem;
    --radius-xl:  0.75rem;

    --topnav-h:   56px;
    --sidebar-w:  280px;

    --shadow-xl:  0 30px 80px rgba(0,0,0,0.6);
    --shadow-md:  0 10px 24px rgba(0,0,0,0.45);

    --glass-bg:   rgba(28,28,30,0.62);
    --glass-brd:  rgba(255,255,255,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    background:
        radial-gradient(1100px 700px at 70% -10%, rgba(0,218,243,0.05), transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(160,96,255,0.05), transparent 60%),
        var(--bg);
    min-height: 100vh;
    color: var(--on-surface);
    font-family: 'Manrope', 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::selection { background: var(--tertiary); color: #00363d; }

button { font-family: inherit; color: inherit; }

/* ── Top Nav ───────────────────────────────────────────────── */
.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topnav-h);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(14,14,14,0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--on-surface);
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(0,218,243,0.18), rgba(160,96,255,0.18));
    color: var(--tertiary);
    border: 1px solid rgba(0,218,243,0.25);
}
.brand-name {
    font-weight: 800;
    font-size: 0.92rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.topnav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}
.topnav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: color 0.2s, background 0.2s;
}
.topnav-link:hover { color: var(--on-surface); background: rgba(255,255,255,0.04); }
.topnav-link.is-active {
    color: var(--tertiary);
    border-bottom: 2px solid var(--tertiary);
    border-radius: 0;
    padding-bottom: 4px;
}

.topnav-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--on-surface-v);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.15s;
}
.icon-btn:hover {
    color: var(--on-surface);
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
}
.icon-btn:active { transform: scale(0.95); }

#toggle-sidebar-btn { display: none; }

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    padding-top: var(--topnav-h);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    position: sticky;
    top: var(--topnav-h);
    align-self: start;
    height: calc(100vh - var(--topnav-h));
    background: rgba(20,20,21,0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255,255,255,0.05);
    padding: 28px 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }

.sidebar-section { display: flex; flex-direction: column; gap: 12px; }

.sidebar-eyebrow {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}
.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--on-surface);
    margin-bottom: 4px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-hint {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.45;
}
.sidebar-hint code {
    color: var(--on-surface-v);
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    padding: 0 4px;
    font-size: 0.68rem;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
.hint-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--tertiary);
    box-shadow: 0 0 10px rgba(0,218,243,0.7);
    margin-top: 6px;
    flex-shrink: 0;
}

/* ── Track selector (inside sidebar) ──────────────────────── */
.selector-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.selector-label {
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.select-shell {
    position: relative;
}
.select-shell::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.select-track {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: var(--surface-low);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    color: var(--on-surface);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 12px 36px 12px 14px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.select-track:hover {
    border-color: rgba(0,218,243,0.4);
    background: var(--surface-high);
}
.select-track:focus {
    border-color: var(--tertiary);
    box-shadow: 0 0 0 3px rgba(0,218,243,0.15);
}
.select-track option    { background: var(--surface); color: var(--on-surface); }
.select-track optgroup  { background: var(--surface-low); color: var(--muted); font-style: normal; font-weight: 600; }

.import-midi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    background: linear-gradient(135deg, rgba(0,218,243,0.14), rgba(160,96,255,0.14));
    border: 1px solid rgba(0,218,243,0.25);
    color: var(--on-surface);
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.import-midi-btn:hover {
    background: linear-gradient(135deg, rgba(0,218,243,0.22), rgba(160,96,255,0.22));
    border-color: rgba(0,218,243,0.5);
}
.import-midi-btn:active { transform: scale(0.98); }

/* ── Stage (main) ──────────────────────────────────────────── */
.stage {
    padding: 28px 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

/* ── Now Playing Panel ────────────────────────────────────── */
.now-playing {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 20px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.now-playing::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0,218,243,0.04), transparent 55%);
    pointer-events: none;
}

.now-thumb {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--surface-high), var(--surface-lowest));
    border: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tertiary);
    flex-shrink: 0;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
}

.now-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.now-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.now-title {
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #fff;
    line-height: 1.15;
}
.now-subtitle {
    color: var(--on-surface-v);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: var(--tertiary-soft);
    border: 1px solid rgba(0,218,243,0.25);
    color: var(--tertiary);
}
.mode-pill .mode-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--tertiary);
    box-shadow: 0 0 8px rgba(0,218,243,0.8);
}
.mode-pill.is-playing {
    background: var(--accent-soft);
    border-color: rgba(160,96,255,0.35);
    color: #caa8ff;
    animation: pill-pulse 1.6s ease-in-out infinite;
}
.mode-pill.is-playing .mode-dot {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(160,96,255,0.9);
}
@keyframes pill-pulse {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

.now-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 60px;
}
.stat-label {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
}
.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}
.stat-tertiary { color: var(--tertiary) !important; }
.stat-accent   { color: #caa8ff !important; }
.stat-sep {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.08);
}

/* ── Fake-play Info Strip ─────────────────────────────────── */
.fake-info {
    display: none;
    padding: 18px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
    flex-direction: column;
    gap: 12px;
}
.fake-info.visible { display: flex; }

.progress-track {
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--tertiary), var(--accent));
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(0,218,243,0.4);
    transition: width 0.3s ease;
}

.fake-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.press-hint {
    color: var(--on-surface-v);
    font-size: 0.84rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    animation: hint-pulse 2.2s ease-in-out infinite;
}
.press-hint.bravo {
    color: var(--tertiary);
    text-shadow: 0 0 14px rgba(0,218,243,0.5);
    animation: hint-pulse 1s ease-in-out infinite;
}
@keyframes hint-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}

.reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--on-surface-v);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transition: all 0.2s;
    white-space: nowrap;
}
.reset-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--tertiary);
    border-color: rgba(0,218,243,0.35);
}

.bar-jump-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 4px;
    border-top: 1px dashed rgba(255,255,255,0.06);
    margin-top: 2px;
    padding-top: 10px;
}
.bar-jump-label {
    color: var(--muted);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}
.bar-jump-scroll {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px 0;
    flex: 1;
}
.bar-jump-scroll::-webkit-scrollbar { display: none; }

.bar-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--on-surface-v);
    font-size: 0.66rem;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 9px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.bar-btn:hover {
    background: rgba(0,218,243,0.08);
    color: var(--tertiary);
    border-color: rgba(0,218,243,0.3);
}
.bar-btn.active {
    background: linear-gradient(135deg, rgba(0,218,243,0.28), rgba(160,96,255,0.28));
    border-color: rgba(0,218,243,0.5);
    color: #fff;
    box-shadow: 0 0 14px rgba(0,218,243,0.25);
}
.bar-btn.past {
    background: rgba(0,218,243,0.07);
    border-color: rgba(0,218,243,0.18);
    color: rgba(255,255,255,0.45);
}

/* ── Piano Shell ──────────────────────────────────────────── */
.piano-shell {
    background: linear-gradient(180deg, #0c0c0d 0%, #0a0a0b 100%);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-xl);
    padding: 0 0 16px;
    box-shadow:
        var(--shadow-xl),
        inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden;
    position: relative;
}

.piano-labelbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 30px;
    padding: 0 18px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.labelbar-text {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    white-space: nowrap;
}
.labelbar-octaves {
    display: flex;
    gap: 28px;
    flex: 1;
    justify-content: center;
    overflow: hidden;
}
.labelbar-octaves span {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.18);
}

.piano-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
    padding: 18px 20px 14px;
}
.piano-wrapper::-webkit-scrollbar { height: 4px; }
.piano-wrapper::-webkit-scrollbar-track { background: transparent; }
.piano-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }

#piano {
    position: relative;
    display: inline-block;
    cursor: default;
    touch-action: pan-x;
}

/* ── Keys ─────────────────────────────────────────────────── */
.key {
    position: absolute;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.white-key {
    background: linear-gradient(180deg, #fcfcfc 0%, #f4f4f4 70%, #e2e2e2 100%);
    border-left:   1px solid rgba(0,0,0,0.08);
    border-right:  1px solid rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(0,0,0,0.18);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 1;
    padding-bottom: 13px;
    box-shadow:
        inset 1px 0 0 rgba(255,255,255,0.95),
        inset -1px 0 0 rgba(0,0,0,0.05),
        inset 0 -4px 8px rgba(0,0,0,0.08),
        0 3px 6px rgba(0,0,0,0.45),
        0 1px 2px rgba(0,0,0,0.3);
    transition: background 0.05s, box-shadow 0.05s, transform 0.05s;
}
.white-key.active {
    background: #fff;
    box-shadow:
        inset 0 0 20px rgba(0,218,243,0.55),
        inset 0 2px 4px rgba(0,0,0,0.12),
        0 1px 2px rgba(0,0,0,0.3);
    transform: translateY(2px);
}

.black-key {
    background: linear-gradient(180deg, #2a2a2a 0%, #161616 45%, #0a0a0a 90%, #000 100%);
    border-radius: 0 0 var(--radius) var(--radius);
    z-index: 2;
    padding-bottom: 10px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 1px 0 0 rgba(255,255,255,0.05),
        inset -1px 0 0 rgba(0,0,0,0.35),
        inset 0 -4px 0 rgba(0,0,0,0.85),
        3px 6px 14px rgba(0,0,0,0.8),
        0 2px 4px rgba(0,0,0,0.65);
    transition: background 0.05s, box-shadow 0.05s, transform 0.05s;
}
.black-key.active {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    box-shadow:
        inset 0 0 14px rgba(0,218,243,0.75),
        inset 0 2px 4px rgba(0,0,0,0.5),
        2px 4px 8px rgba(0,0,0,0.6);
    transform: translateY(2px);
}

/* ── Key Labels ───────────────────────────────────────────── */
.note-label {
    font-size: 9px;
    font-weight: 700;
    color: rgba(0,0,0,0.3);
    line-height: 1;
    pointer-events: none;
    letter-spacing: 0.04em;
}
.note-label.c-label { color: rgba(0,0,0,0.48); font-size: 10px; }
.black-key .note-label { color: rgba(255,255,255,0.35); font-size: 8px; }

.kb-label {
    font-size: 8px;
    font-weight: 600;
    color: rgba(0,0,0,0.34);
    background: rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-sm);
    padding: 1px 4px;
    margin-top: 4px;
    line-height: 1.2;
    pointer-events: none;
    letter-spacing: 0.04em;
}
.black-key .kb-label {
    color: rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
    font-size: 7px;
}

/* ── Stage Footer (size control + hint) ──────────────────── */
.stage-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4px 0 0;
}

.size-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-brd);
    border-radius: 999px;
    padding: 6px 14px;
}
.size-control-label {
    font-size: 0.56rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 4px 0 2px;
}

.size-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: var(--on-surface-v);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}
.size-btn:hover {
    background: rgba(0,218,243,0.12);
    color: var(--tertiary);
    border-color: rgba(0,218,243,0.4);
}

.size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 3px;
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tertiary);
    border: none;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,218,243,0.5);
    transition: transform 0.15s;
}
.size-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.size-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--tertiary);
    border: none;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,218,243,0.5);
}

.size-label {
    color: var(--on-surface-v);
    font-size: 0.68rem;
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.scroll-hint {
    text-align: center;
    font-size: 0.62rem;
    font-weight: 500;
    color: rgba(255,255,255,0.28);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.scroll-hint .touch-hint { display: none; }
@media (pointer: coarse) {
    .scroll-hint .desktop-hint { display: none; }
    .scroll-hint .touch-hint   { display: inline; }
}

/* ── Free-play Guide ──────────────────────────────────────── */
.guide {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
    padding: 22px 26px;
}

.guide-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}
.guide-eyebrow {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--tertiary);
}
.guide-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.005em;
}

.guide-rows { display: flex; flex-direction: column; gap: 12px; }
.guide-row  { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.guide-label {
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    min-width: 110px;
    padding-top: 4px;
    text-transform: uppercase;
}
.guide-keys { display: flex; gap: 5px; flex-wrap: wrap; }
.guide-chip {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    padding: 4px 9px;
    font-size: 0.72rem;
    color: var(--on-surface-v);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.guide-chip .k {
    color: var(--tertiary);
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════ */

/* Tablet / smaller desktops */
@media (max-width: 1200px) {
    :root { --sidebar-w: 240px; }
    .stage { padding: 24px 22px 32px; }
    .now-thumb { width: 72px; height: 72px; }
}

/* Collapse sidebar to an off-canvas drawer */
@media (max-width: 900px) {
    #toggle-sidebar-btn { display: inline-flex; }
    .topnav-links { display: none; }

    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: var(--topnav-h);
        left: 0;
        height: calc(100vh - var(--topnav-h));
        width: min(320px, 86vw);
        padding: 22px 18px 18px;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-xl);
    }
    .sidebar.is-open { transform: translateX(0); }

    .stage { padding: 18px 16px 28px; gap: 14px; }

    .now-playing { padding: 16px; gap: 14px; }
    .now-thumb   { width: 60px; height: 60px; }
    .now-thumb svg { width: 30px; height: 30px; }
    .now-title   { font-size: 1.25rem; }
    .now-subtitle { font-size: 0.82rem; }
    .now-stats   { gap: 12px; margin-top: 4px; }
    .stat-sep    { display: none; }

    .piano-labelbar { padding: 0 12px; }
    .labelbar-text  { display: none; }
    .labelbar-octaves { gap: 18px; }
}

/* Phone portrait */
@media (max-width: 560px) {
    .topnav { padding: 0 14px; }
    .brand-name { font-size: 0.78rem; letter-spacing: 0.14em; }

    .stage { padding: 14px 10px 24px; gap: 12px; }

    .now-playing { flex-direction: column; align-items: flex-start; padding: 14px; gap: 10px; }
    .now-thumb   { width: 52px; height: 52px; border-radius: var(--radius-md); }
    .now-thumb svg { width: 26px; height: 26px; }
    .now-heading { gap: 8px; }
    .now-title   { font-size: 1.15rem; }
    .now-subtitle { font-size: 0.78rem; }
    .stat-label  { font-size: 0.52rem; }
    .stat-value  { font-size: 0.82rem; }

    .fake-info   { padding: 14px 16px; }
    .press-hint  { font-size: 0.76rem; }
    .reset-btn   { font-size: 0.62rem; padding: 5px 10px; }

    .piano-shell    { border-radius: var(--radius-lg); }
    .piano-labelbar { height: 24px; padding: 0 10px; }
    .labelbar-octaves { gap: 12px; }
    .labelbar-octaves span { font-size: 0.46rem; }
    .piano-wrapper   { padding: 12px 10px 10px; }

    .size-control   { padding: 5px 10px; gap: 8px; }
    .size-slider    { width: 80px; }
    .size-control-label { display: none; }

    .guide { padding: 18px 18px; }
    .guide-label { min-width: 90px; font-size: 0.6rem; }
    .guide-chip  { font-size: 0.66rem; }
}

/* Short-height (landscape phones) — keep piano centre stage */
@media (max-height: 560px) {
    .stage        { padding: 10px 14px 16px; gap: 8px; }
    .now-playing  { padding: 10px 14px; gap: 12px; }
    .now-thumb    { width: 48px; height: 48px; }
    .now-thumb svg { width: 24px; height: 24px; }
    .now-title    { font-size: 1rem; }
    .now-subtitle { font-size: 0.72rem; }
    .now-stats    { margin-top: 2px; gap: 10px; }
    .stat-sep     { display: none; }

    .fake-info    { padding: 10px 14px; gap: 8px; }
    .progress-track { height: 2px; }
    .press-hint   { font-size: 0.7rem; }
    .bar-jump-wrap { padding-top: 6px; }
    .bar-btn      { font-size: 0.58rem; padding: 3px 7px; min-width: 22px; }

    .piano-labelbar { height: 20px; }
    .labelbar-octaves { display: none; }
    .piano-wrapper  { padding: 8px 12px; }

    .stage-footer   { gap: 4px; }
    .size-control   { padding: 4px 10px; }
    .size-control-label { display: none; }
    .scroll-hint    { font-size: 0.54rem; letter-spacing: 0.1em; }

    .guide { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   VIEWS — Performance / Tutorials / Library routing
   ══════════════════════════════════════════════════════════════ */

.view { display: none; flex-direction: column; gap: 18px; }
.view.is-active { display: flex; animation: view-fade-in 0.3s ease both; }

@keyframes view-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* ══════════════════════════════════════════════════════════════
   HERO (Tutorials & Library headers)
   ══════════════════════════════════════════════════════════════ */

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 26px 28px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    flex-wrap: wrap;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(400px 220px at 100% 0%, rgba(160,96,255,0.10), transparent 70%),
        linear-gradient(135deg, rgba(0,218,243,0.05), transparent 55%);
    pointer-events: none;
}

.hero-text { flex: 1 1 320px; min-width: 0; position: relative; }
.hero-eyebrow {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--tertiary);
    margin-bottom: 10px;
}
.hero-title {
    font-size: clamp(1.5rem, 2.8vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #fff;
    line-height: 1.15;
    margin-bottom: 8px;
}
.hero-subtitle {
    color: var(--on-surface-v);
    font-size: 0.96rem;
    line-height: 1.55;
    max-width: 640px;
}

.hero-actions { display: flex; gap: 10px; position: relative; flex-wrap: wrap; }
.hero-stats   { display: flex; gap: 22px; position: relative; flex-wrap: wrap; }
.hero-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 72px;
}
.hero-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.hero-stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS (primary / secondary)
   ══════════════════════════════════════════════════════════════ */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.15s, background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--tertiary) 0%, #58e6f2 100%);
    color: #082a30;
    box-shadow: 0 10px 26px -10px rgba(0,218,243,0.6);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px -10px rgba(0,218,243,0.8);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    background: rgba(255,255,255,0.06);
    color: var(--muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    background: rgba(255,255,255,0.04);
    color: var(--on-surface);
    border-color: rgba(255,255,255,0.12);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(0,218,243,0.4);
    color: var(--tertiary);
}
.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════
   TUTORIALS VIEW
   ══════════════════════════════════════════════════════════════ */

.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lesson-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--on-surface-v);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lesson-item:hover {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
    color: var(--on-surface);
}
.lesson-item.is-active {
    background: linear-gradient(135deg, rgba(0,218,243,0.12), rgba(160,96,255,0.10));
    border-color: rgba(0,218,243,0.35);
    color: #fff;
    box-shadow: 0 4px 14px -6px rgba(0,218,243,0.5);
}
.lesson-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--on-surface-v);
    flex-shrink: 0;
}
.lesson-item.is-active .lesson-num {
    background: rgba(0,218,243,0.25);
    border-color: rgba(0,218,243,0.6);
    color: #fff;
}
.lesson-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lesson-name {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lesson-hint-text {
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lesson-item.is-active .lesson-hint-text { color: var(--on-surface-v); }

.lesson-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    padding: 22px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
}
.lesson-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    line-height: 1.5;
}
.lesson-step p {
    color: var(--on-surface-v);
    font-size: 0.88rem;
    margin: 0;
}
.lesson-step-num {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0,218,243,0.2), rgba(160,96,255,0.2));
    border: 1px solid rgba(0,218,243,0.35);
    color: var(--tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.lesson-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: var(--glass-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-brd);
    border-radius: 999px;
    align-self: center;
    min-width: min(420px, 100%);
}
.lesson-counter {
    color: var(--on-surface-v);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

/* Tutorial piano highlight */
.key.lesson-hint {
    box-shadow:
        inset 0 0 0 2px rgba(0,218,243,0.8),
        inset 0 0 22px rgba(0,218,243,0.35),
        0 0 24px rgba(0,218,243,0.5),
        0 3px 6px rgba(0,0,0,0.45),
        0 1px 2px rgba(0,0,0,0.3);
    animation: hint-glow 1.6s ease-in-out infinite;
}
.black-key.lesson-hint {
    box-shadow:
        inset 0 0 0 2px rgba(0,218,243,0.9),
        inset 0 0 18px rgba(0,218,243,0.5),
        0 0 20px rgba(0,218,243,0.6),
        3px 6px 14px rgba(0,0,0,0.8);
}
@keyframes hint-glow {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.08); }
}

/* ══════════════════════════════════════════════════════════════
   LIBRARY VIEW
   ══════════════════════════════════════════════════════════════ */

.search-shell {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-low);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    padding: 0 12px;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.search-shell:focus-within {
    border-color: var(--tertiary);
    box-shadow: 0 0 0 3px rgba(0,218,243,0.15);
}
.search-shell svg { color: var(--muted); flex-shrink: 0; }
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--on-surface);
    font-family: inherit;
    font-size: 0.88rem;
    padding: 10px 10px;
    outline: none;
}
.search-input::placeholder { color: var(--muted); }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--on-surface-v);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover {
    background: rgba(255,255,255,0.06);
    color: var(--on-surface);
}
.chip.is-on {
    background: linear-gradient(135deg, rgba(0,218,243,0.22), rgba(160,96,255,0.22));
    border-color: rgba(0,218,243,0.5);
    color: #fff;
}

.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.track-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-brd);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.track-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0,218,243,0.04), transparent 55%);
    pointer-events: none;
}
.track-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0,218,243,0.28);
    box-shadow: 0 20px 40px -20px rgba(0,218,243,0.28);
}
.track-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
}
.track-emoji {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.track-badge {
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 999px;
    border: 1px solid;
    white-space: nowrap;
}
.badge-standard  { color: #58e6f2; background: rgba(0,218,243,0.10); border-color: rgba(0,218,243,0.3); }
.badge-midi      { color: #58e6f2; background: rgba(0,218,243,0.10); border-color: rgba(0,218,243,0.3); }
.badge-signature { color: #ffd36b; background: rgba(255,211,107,0.10); border-color: rgba(255,211,107,0.35); }

.track-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    letter-spacing: -0.005em;
    position: relative;
}
.track-source {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.4;
    position: relative;
}
.track-source code {
    background: rgba(255,255,255,0.04);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
    font-size: 0.7rem;
    color: var(--on-surface-v);
}
.track-play-btn {
    margin-top: 4px;
    align-self: flex-start;
    position: relative;
    padding: 8px 14px;
    font-size: 0.72rem;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 0.88rem;
    background: rgba(255,255,255,0.02);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: var(--radius-xl);
}

/* ══════════════════════════════════════════════════════════════
   SETTINGS MODAL
   ══════════════════════════════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s;
    padding: 20px;
}
.modal-backdrop.is-open { opacity: 1; }
.modal-backdrop[hidden] { display: none !important; }

.modal-card {
    width: min(640px, 100%);
    max-height: calc(100vh - 80px);
    background: linear-gradient(180deg, #1b1c1d 0%, #141516 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(10px) scale(0.98);
    transition: transform 0.25s ease;
}
.modal-backdrop.is-open .modal-card { transform: translateY(0) scale(1); }

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.modal-eyebrow {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--tertiary);
    margin-bottom: 6px;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
}
.modal-body {
    padding: 8px 24px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-wrap: wrap;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { flex: 1 1 200px; min-width: 180px; }
.setting-label h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--on-surface);
    margin-bottom: 2px;
    letter-spacing: -0.005em;
}
.setting-label p {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.45;
}

.segmented {
    display: inline-flex;
    background: var(--surface-low);
    border: 1px solid var(--outline);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    flex-wrap: wrap;
}
.segmented button {
    background: transparent;
    border: none;
    color: var(--on-surface-v);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: #fff; }
.segmented button.is-on,
.segmented button[aria-checked="true"] {
    background: linear-gradient(135deg, rgba(0,218,243,0.9), rgba(88,230,242,0.9));
    color: #082a30;
    box-shadow: 0 2px 10px -2px rgba(0,218,243,0.5);
}

.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    max-width: 460px;
}
.skin-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--surface-low);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    cursor: pointer;
    color: var(--on-surface-v);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
}
.skin-btn:hover {
    border-color: rgba(0,218,243,0.35);
    color: #fff;
}
.skin-btn.is-on,
.skin-btn[aria-checked="true"] {
    border-color: var(--tertiary);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(0,218,243,0.15);
    background: rgba(0,218,243,0.05);
}
.skin-swatch {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    position: relative;
}
.skin-swatch::before,
.skin-swatch::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
}
.skin-swatch-classic {
    background: linear-gradient(180deg, #fcfcfc 0%, #e2e2e2 100%);
}
.skin-swatch-classic::before {
    left: 30%; width: 14%;
    background: linear-gradient(180deg, #2a2a2a 0%, #0a0a0a 100%);
    height: 64%;
}
.skin-swatch-classic::after {
    right: 30%; width: 14%;
    background: linear-gradient(180deg, #2a2a2a 0%, #0a0a0a 100%);
    height: 64%;
}
.skin-swatch-neon {
    background: linear-gradient(180deg, #17181a 0%, #0a0a0b 100%);
    box-shadow: inset 0 0 18px rgba(0,218,243,0.2);
}
.skin-swatch-neon::before {
    left: 22%; width: 14%; height: 64%;
    background: linear-gradient(180deg, #0a0a0b, #000);
    box-shadow: 0 0 10px rgba(0,218,243,0.6);
}
.skin-swatch-neon::after {
    right: 22%; width: 14%; height: 64%;
    background: linear-gradient(180deg, #0a0a0b, #000);
    box-shadow: 0 0 10px rgba(160,96,255,0.6);
}
.skin-swatch-minimal {
    background: #f5f5f5;
}
.skin-swatch-minimal::before {
    left: 30%; width: 10%;
    background: #111;
    height: 60%;
}
.skin-swatch-minimal::after {
    right: 30%; width: 10%;
    background: #111;
    height: 60%;
}
.skin-swatch-wooden {
    background:
        linear-gradient(180deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0) 10%),
        repeating-linear-gradient(94deg,
            rgba(40,18,6,0.22) 0 1px,
            transparent 1px 4px,
            rgba(40,18,6,0.12) 4px 5px,
            transparent 5px 11px),
        linear-gradient(180deg, #7a4a23 0%, #4a2a14 60%, #2e1a0a 100%);
    border: 1px solid rgba(80,40,10,0.6);
}
.skin-swatch-wooden::before,
.skin-swatch-wooden::after {
    top: 28%;
    height: 46%;
    background: linear-gradient(180deg, #f7e8c6 0%, #e9d3a0 80%, #d8bd7e 100%);
    box-shadow: inset 0 -3px 4px rgba(120,80,30,0.3), 0 1px 2px rgba(0,0,0,0.5);
    border-radius: 1px;
}
.skin-swatch-wooden::before { left: 20%; width: 24%; }
.skin-swatch-wooden::after  { right: 20%; width: 24%; }
.skin-name { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.66rem; }

/* ── Toggle switch ─────────────────────────────────────── */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 999px;
    transition: background 0.2s, border-color 0.2s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.22s cubic-bezier(.4,0,.2,1), background 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.switch input:checked + .switch-slider {
    background: linear-gradient(135deg, var(--tertiary), #58e6f2);
    border-color: rgba(0,218,243,0.5);
}
.switch input:checked + .switch-slider::before {
    transform: translateX(20px);
    background: #fff;
}
.switch input:focus-visible + .switch-slider {
    box-shadow: 0 0 0 3px rgba(0,218,243,0.25);
}

/* ══════════════════════════════════════════════════════════════
   TOAST SYSTEM
   ══════════════════════════════════════════════════════════════ */

.toast-stack {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    min-width: 220px;
    max-width: 340px;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(38,38,40,0.96), rgba(26,26,28,0.96));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.08);
    border-left: 3px solid var(--tertiary);
    border-radius: var(--radius-lg);
    color: var(--on-surface);
    font-size: 0.82rem;
    line-height: 1.35;
    box-shadow: 0 14px 32px -8px rgba(0,0,0,0.7);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }
.toast-ok    { border-left-color: var(--tertiary); }
.toast-error { border-left-color: #ff6b6b; }
.toast-warn  { border-left-color: #ffd36b; }

@media (max-width: 560px) {
    .toast-stack { left: 14px; right: 14px; bottom: 14px; }
    .toast { min-width: 0; max-width: none; }
}

/* ══════════════════════════════════════════════════════════════
   PIANO SKINS
   ══════════════════════════════════════════════════════════════ */

/* Neon — dark ambient glow, neon-blue white keys */
body.piano-skin-neon .white-key {
    background: linear-gradient(180deg, #1a1b1e 0%, #0e0f11 75%, #070709 100%);
    border-color: rgba(0,218,243,0.12);
    box-shadow:
        inset 1px 0 0 rgba(0,218,243,0.12),
        inset 0 -4px 8px rgba(0,0,0,0.6),
        inset 0 0 24px rgba(0,218,243,0.08),
        0 3px 6px rgba(0,0,0,0.55),
        0 0 12px rgba(0,218,243,0.08);
}
body.piano-skin-neon .white-key.active {
    background: linear-gradient(180deg, #0a1a1f 0%, #051418 100%);
    box-shadow:
        inset 0 0 26px rgba(0,218,243,0.8),
        inset 0 2px 4px rgba(0,0,0,0.35),
        0 0 22px rgba(0,218,243,0.55);
}
body.piano-skin-neon .black-key {
    background: linear-gradient(180deg, #111214 0%, #050607 100%);
    box-shadow:
        inset 0 1px 0 rgba(0,218,243,0.18),
        inset -1px 0 0 rgba(0,0,0,0.45),
        inset 0 -4px 0 rgba(0,0,0,0.9),
        3px 6px 14px rgba(0,0,0,0.9),
        0 0 8px rgba(160,96,255,0.15);
}
body.piano-skin-neon .black-key.active {
    box-shadow:
        inset 0 0 18px rgba(160,96,255,0.9),
        inset 0 2px 4px rgba(0,0,0,0.5),
        2px 4px 8px rgba(0,0,0,0.6),
        0 0 18px rgba(160,96,255,0.55);
}
body.piano-skin-neon .note-label   { color: rgba(0,218,243,0.6); }
body.piano-skin-neon .note-label.c-label { color: rgba(0,218,243,0.85); }
body.piano-skin-neon .black-key .note-label { color: rgba(160,96,255,0.6); }
body.piano-skin-neon .kb-label {
    color: rgba(0,218,243,0.7);
    background: rgba(0,218,243,0.08);
    border-color: rgba(0,218,243,0.18);
}
body.piano-skin-neon .black-key .kb-label {
    color: rgba(160,96,255,0.7);
    background: rgba(160,96,255,0.08);
    border-color: rgba(160,96,255,0.22);
}

/* Minimal — clean flat design */
body.piano-skin-minimal .white-key {
    background: #f7f7f7;
    border-color: rgba(0,0,0,0.06);
    box-shadow:
        inset 0 -2px 4px rgba(0,0,0,0.04),
        0 1px 2px rgba(0,0,0,0.25);
    border-radius: 0 0 4px 4px;
}
body.piano-skin-minimal .white-key.active {
    background: #e8f5f8;
    box-shadow: inset 0 0 12px rgba(0,218,243,0.35), 0 1px 2px rgba(0,0,0,0.2);
}
body.piano-skin-minimal .black-key {
    background: #111;
    box-shadow:
        inset 0 -3px 0 rgba(255,255,255,0.04),
        0 2px 4px rgba(0,0,0,0.7);
    border-radius: 0 0 3px 3px;
}
body.piano-skin-minimal .black-key.active {
    background: #222;
    box-shadow: inset 0 0 10px rgba(0,218,243,0.8);
}

/* ── Wooden — vintage upright with walnut case, brass nameplate,
       ivory naturals, and ebony sharps with amber glow ────────── */

/* Case: deep walnut with horizontal wood grain */
body.piano-skin-wooden .piano-shell {
    background:
        /* Subtle vignette at top */
        linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 14px),
        /* Fine wood grain streaks */
        repeating-linear-gradient(92deg,
            rgba(30,14,4,0.35) 0 1px,
            transparent 1px 5px,
            rgba(30,14,4,0.18) 5px 6px,
            transparent 6px 13px,
            rgba(60,28,10,0.25) 13px 14px,
            transparent 14px 22px),
        /* Base walnut gradient */
        linear-gradient(180deg,
            #7a4a23 0%,
            #5e3519 35%,
            #3a2010 70%,
            #2a1509 100%);
    border-color: rgba(80,40,15,0.7);
    box-shadow:
        inset 0 1px 0 rgba(210,150,80,0.18),
        inset 0 -2px 0 rgba(0,0,0,0.6),
        0 24px 60px -16px rgba(0,0,0,0.75),
        var(--shadow-xl);
}

/* Brass nameplate strip above the keys */
body.piano-skin-wooden .piano-labelbar {
    background:
        linear-gradient(180deg,
            #e8c27a 0%,
            #b9894a 45%,
            #8a5f28 85%,
            #6d4a1e 100%);
    border-bottom: 1px solid rgba(30,14,4,0.6);
    box-shadow:
        inset 0 1px 0 rgba(255,235,190,0.5),
        inset 0 -1px 0 rgba(30,14,4,0.5);
}
body.piano-skin-wooden .labelbar-text {
    color: rgba(40,22,6,0.82);
    text-shadow: 0 1px 0 rgba(255,230,180,0.35);
    letter-spacing: 0.32em;
}
body.piano-skin-wooden .labelbar-octaves span {
    color: rgba(40,22,6,0.6);
    text-shadow: 0 1px 0 rgba(255,230,180,0.3);
}

/* Felt strip between brass and keys */
body.piano-skin-wooden .piano-wrapper {
    background:
        linear-gradient(180deg,
            rgba(120,28,20,0.7) 0,
            rgba(80,18,14,0.55) 7px,
            rgba(0,0,0,0.28) 14px,
            transparent 20px);
}

/* Ivory naturals — aged cream with warm undertone */
body.piano-skin-wooden .white-key {
    background: linear-gradient(180deg,
        #fbf3de 0%,
        #f5ead0 25%,
        #eedfba 70%,
        #e4d19e 100%);
    border-left: 1px solid rgba(90,55,20,0.18);
    border-right: 1px solid rgba(90,55,20,0.22);
    border-bottom: 1px solid rgba(60,35,10,0.5);
    box-shadow:
        /* Ivory sheen on top */
        inset 0 1px 0 rgba(255,250,225,0.95),
        inset 1px 0 0 rgba(255,245,215,0.7),
        inset -1px 0 0 rgba(140,95,45,0.18),
        /* Aged shadow pooling at the base */
        inset 0 -6px 10px rgba(150,105,50,0.3),
        inset 0 -12px 20px rgba(110,70,30,0.12),
        /* Separation from case */
        0 4px 8px rgba(30,14,4,0.55),
        0 1px 2px rgba(30,14,4,0.4);
}
body.piano-skin-wooden .white-key.active {
    background: linear-gradient(180deg,
        #ffe9b0 0%,
        #f3cf7a 60%,
        #e0b45a 100%);
    box-shadow:
        inset 0 0 22px rgba(200,130,40,0.55),
        inset 0 0 0 1px rgba(180,110,30,0.35),
        inset 0 2px 4px rgba(90,50,15,0.25),
        0 0 18px rgba(210,140,50,0.35),
        0 1px 2px rgba(30,14,4,0.5);
}

/* Ebony sharps — deep dark wood */
body.piano-skin-wooden .black-key {
    background:
        /* Very subtle ebony grain */
        repeating-linear-gradient(180deg,
            rgba(60,30,10,0.15) 0 2px,
            transparent 2px 5px),
        linear-gradient(180deg,
            #2d1a0b 0%,
            #1a0e05 45%,
            #0a0502 85%,
            #040201 100%);
    border-radius: 0 0 3px 3px;
    box-shadow:
        /* Top highlight */
        inset 0 1px 0 rgba(220,160,90,0.22),
        inset 1px 0 0 rgba(200,140,70,0.1),
        inset -1px 0 0 rgba(0,0,0,0.45),
        /* Inner shadow at base — felt resting */
        inset 0 -5px 0 rgba(0,0,0,0.92),
        inset 0 -8px 6px rgba(0,0,0,0.5),
        /* Drop shadow on the ivories behind */
        3px 6px 14px rgba(20,10,3,0.85),
        0 2px 4px rgba(10,5,1,0.7);
}
body.piano-skin-wooden .black-key.active {
    background:
        linear-gradient(180deg,
            #3a2310 0%,
            #1e1207 55%,
            #0a0502 100%);
    box-shadow:
        inset 0 0 18px rgba(255,165,60,0.85),
        inset 0 0 0 1px rgba(240,145,45,0.35),
        inset 0 2px 4px rgba(0,0,0,0.55),
        2px 4px 8px rgba(15,7,2,0.75),
        0 0 14px rgba(230,135,40,0.45);
}

/* Key labels: engraved look */
body.piano-skin-wooden .note-label       { color: rgba(60,35,10,0.55); }
body.piano-skin-wooden .note-label.c-label { color: rgba(60,35,10,0.8); }
body.piano-skin-wooden .black-key .note-label { color: rgba(220,170,100,0.55); }
body.piano-skin-wooden .kb-label {
    color: rgba(60,35,10,0.6);
    background: rgba(60,35,10,0.08);
    border-color: rgba(60,35,10,0.22);
}
body.piano-skin-wooden .black-key .kb-label {
    color: rgba(220,170,100,0.7);
    background: rgba(220,170,100,0.08);
    border-color: rgba(220,170,100,0.22);
}

/* Amber lesson-hint instead of cyan */
body.piano-skin-wooden .key.lesson-hint {
    box-shadow:
        inset 0 0 0 2px rgba(230,150,55,0.85),
        inset 0 0 24px rgba(230,150,55,0.4),
        0 0 24px rgba(230,150,55,0.55),
        0 4px 8px rgba(30,14,4,0.55);
}
body.piano-skin-wooden .black-key.lesson-hint {
    box-shadow:
        inset 0 0 0 2px rgba(230,150,55,0.95),
        inset 0 0 18px rgba(230,150,55,0.55),
        0 0 20px rgba(230,150,55,0.6),
        3px 6px 14px rgba(15,7,2,0.8);
}

/* Label visibility toggles */
body.hide-note-labels .note-label { display: none; }
body.hide-kb-labels   .kb-label   { display: none; }

/* ══════════════════════════════════════════════════════════════
   Responsive tweaks for new components
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .hero { padding: 22px 20px; gap: 16px; }
    .hero-title { font-size: 1.55rem; }
    .hero-subtitle { font-size: 0.88rem; }
    .hero-actions { width: 100%; }
    .hero-stats { gap: 16px; width: 100%; }
    .hero-stat-value { font-size: 1.5rem; }

    .lesson-steps { padding: 18px; }
    .lesson-nav { min-width: 100%; padding: 10px 14px; }

    .track-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
    .track-card { padding: 14px; }

    .modal-card { max-height: calc(100vh - 40px); }
    .modal-head { padding: 18px 18px 14px; }
    .modal-body { padding: 6px 18px 18px; }
    .setting-row { padding: 14px 0; }
    .segmented { width: 100%; justify-content: space-between; }
    .segmented button { flex: 1; padding: 8px 6px; }
}

@media (max-width: 560px) {
    .hero { flex-direction: column; align-items: flex-start; padding: 18px 16px; }
    .hero-title { font-size: 1.35rem; }
    .lesson-steps { grid-template-columns: 1fr; padding: 14px; }
    .lesson-step p { font-size: 0.84rem; }
    .track-grid { grid-template-columns: 1fr; }
}
