/* PIANODEX - PREMIUM STYLING SYSTEM */

:root {
    /* Color Palette */
    --bg-dark: #080c14;
    --bg-gradient: linear-gradient(135deg, #060910 0%, #0e1626 100%);
    
    --panel-bg: rgba(19, 30, 49, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    
    --text-primary: #f1f5f9;
    --text-muted: #94a3b8;
    --text-accent: #00f0ff;
    
    --accent-cyan: #00f0ff;
    --accent-cyan-glow: rgba(0, 240, 255, 0.4);
    
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.4);
    
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.4);
    
    --accent-gold: #f59e0b;
    --accent-gold-glow: rgba(245, 158, 11, 0.4);
    
    /* Key dimensions */
    --key-white-width: 50px;
    --key-white-height: 220px;
    --key-black-width: 30px;
    --key-black-height: 135px;
    
    /* Fonts */
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

body {
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* APP CONTAINER */
.app-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-grow: 1;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow: var(--panel-shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
    animation: pulseGlow 3s infinite alternate;
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.5px;
}

.logo-text span {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* MIDI Status indicator */
.midi-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-label {
    font-size: 14px;
    color: var(--text-muted);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.status-indicator.connected {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.status-indicator.disconnected {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

.status-indicator.connected .pulse-dot {
    animation: statusPulse 1.5s infinite;
}

/* MAIN LAYOUT */
.app-main {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    gap: 20px;
    flex-grow: 1;
}

/* PANELS */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(12px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow-y: auto;
}

.panel-left {
    max-height: calc(100vh - 120px);
}

.panel-center {
    grid-column: 2;
    padding: 24px;
    gap: 24px;
    overflow: hidden; /* Canvas and Keyboard hold inner scrolls */
}

.panel-right {
    max-height: calc(100vh - 120px);
}

.panel h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel h3 i {
    color: var(--accent-cyan);
}

/* UTILITIES */
.muted {
    color: var(--text-muted);
    font-size: 14px;
}

.divider {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 15px 0;
}

/* INPUTS & SELECTS */
.select-control {
    width: 100%;
    background: rgba(8, 12, 20, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-control:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

/* EXERCISE LIST */
.exercise-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.exercise-list::-webkit-scrollbar {
    width: 4px;
}

.exercise-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ex-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ex-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.ex-item.active {
    background: rgba(0, 240, 255, 0.08);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.05);
}

.ex-title {
    font-size: 14px;
    font-weight: 600;
}

.ex-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* METRONOME CARD */
.metronome-card {
    background: rgba(8, 12, 20, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
}

.tempo-display-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tempo-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.tempo-value-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tempo-value {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.tempo-unit {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 2px;
}

.btn-tempo-step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-tempo-step:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-cyan);
}

.slider-control {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    margin: 15px 0 20px 0;
}

.slider-control::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.slider-control::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.metronome-toggles {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* BUTTONS */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #00f0ff 0%, #3b82f6 100%);
    color: #080c14;
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.25);
}

.btn-primary:hover {
    opacity: 0.95;
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon-only {
    padding: 10px;
    width: 40px;
}

/* SWITCHES */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-title {
    font-size: 13px;
    font-weight: 600;
}

.setting-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 20px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.switch input:checked + .switch-slider {
    background-color: var(--accent-cyan);
}

.switch input:checked + .switch-slider:before {
    transform: translateX(18px);
}

.setting-sub-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    animation: slideDown 0.3s ease;
}

.setting-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-input-group label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.input-with-unit {
    display: flex;
    align-items: center;
    background: rgba(8, 12, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 4px 8px;
}

.input-with-unit input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
}

.input-with-unit span {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

/* METRICS DASHBOARD */
.metrics-dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.metric-card {
    background: rgba(8, 12, 20, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.metric-card.highlight {
    border-color: rgba(0, 240, 255, 0.2);
    background: rgba(0, 240, 255, 0.02);
}

.metric-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-val {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-val .percent, .metric-val .ms {
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 2px;
}

.text-gold {
    color: var(--accent-gold);
    text-shadow: 0 0 10px var(--accent-gold-glow);
}

.metric-visual-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan-glow);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* EXERCISE FEEDBACK PANEL */
.exercise-feedback-panel {
    background: rgba(8, 12, 20, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exercise-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.fingering-indicator-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    animation: pulseHighlight 2s infinite alternate;
}

.tip-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.finger-number {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-cyan);
}

/* ROLLING NOTE STREAM / VISUALIZER */
.note-stream-container {
    position: relative;
    height: 120px;
    background: #060910;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    overflow: hidden;
}

.note-stream-guide-line {
    position: absolute;
    left: 80px; /* Play target line */
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 240, 255, 0.4);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.8);
    z-index: 2;
}

.note-stream-viewport {
    width: 100%;
    height: 100%;
    position: relative;
}

.stream-empty-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

#canvas-stream {
    width: 100%;
    height: 100%;
    display: block;
}

/* PIANO KEYBOARD */
.piano-keyboard-container {
    background: #04060b;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px 10px 10px 10px;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.piano-keyboard-container::-webkit-scrollbar {
    height: 6px;
}

.piano-keyboard-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.keyboard-inner {
    position: relative;
    display: flex;
    height: var(--key-white-height);
}

.piano-key {
    position: relative;
    transition: all 0.1s ease;
}

.piano-key.white {
    position: relative;
    width: var(--key-white-width);
    height: var(--key-white-height);
    background: linear-gradient(to bottom, #ffffff 0%, #ebebeb 100%);
    border: 1px solid #c5c5c5;
    border-bottom: 4px solid #b8b8b8;
    border-radius: 0 0 4px 4px;
    z-index: 1;
}

.piano-key.white:hover {
    background: linear-gradient(to bottom, #ffffff 0%, #f4f4f4 100%);
}

.piano-key.white.active {
    background: linear-gradient(to bottom, #e0f2fe 0%, var(--accent-cyan) 100%);
    border-bottom-width: 1px;
    transform: translateY(3px);
    box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.piano-key.white.correct {
    background: linear-gradient(to bottom, #ecfdf5 0%, var(--accent-green) 100%);
    box-shadow: 0 0 20px var(--accent-green-glow);
}

.piano-key.white.wrong {
    background: linear-gradient(to bottom, #fef2f2 0%, var(--accent-red) 100%);
    box-shadow: 0 0 20px var(--accent-red-glow);
}

.piano-key.black {
    position: absolute;
    top: 0;
    width: var(--key-black-width);
    height: var(--key-black-height);
    background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%);
    border-left: 1px solid #334155;
    border-right: 1px solid #334155;
    border-bottom: 6px solid #020617;
    border-radius: 0 0 3px 3px;
    z-index: 10;
}

.piano-key.black:hover {
    background: linear-gradient(to bottom, #334155 0%, #1e293b 100%);
}

.piano-key.black.active {
    background: linear-gradient(to bottom, #0ea5e9 0%, var(--accent-cyan) 100%);
    border-bottom-width: 1px;
    transform: translateY(5px);
    box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.piano-key.black.correct {
    background: linear-gradient(to bottom, #059669 0%, var(--accent-green) 100%);
    box-shadow: 0 0 16px var(--accent-green-glow);
}

.piano-key.black.wrong {
    background: linear-gradient(to bottom, #dc2626 0%, var(--accent-red) 100%);
    box-shadow: 0 0 16px var(--accent-red-glow);
}

.key-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    pointer-events: none;
}

.piano-key.black .key-label {
    bottom: 8px;
    color: #94a3b8;
    font-size: 8px;
}

/* PRACTICE TECHNIQUE */
.technique-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tip-item {
    display: flex;
    gap: 12px;
}

.tip-icon {
    width: 32px;
    height: 32px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 8px;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.tip-content h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

.tip-content p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* KEYBOARD MAPPING CARD */
.keyboard-mapping-card {
    background: rgba(8, 12, 20, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 12px;
}

.keyboard-mapping-card p {
    margin-bottom: 12px;
    font-size: 12px;
}

.key-map-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.key-map-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    padding: 4px 6px;
}

.key-map-item kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 2px solid rgba(255, 255, 255, 0.25);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 18px;
    text-align: center;
}

.key-map-item span {
    font-size: 10px;
    color: var(--text-muted);
}

/* ANIMATIONS & KEYFRAMES */
@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 4px var(--accent-cyan-glow)); }
    100% { filter: drop-shadow(0 0 10px var(--accent-cyan-glow)); }
}

@keyframes statusPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseHighlight {
    0% { box-shadow: 0 0 4px rgba(0, 240, 255, 0.1); }
    100% { box-shadow: 0 0 12px rgba(0, 240, 255, 0.3); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS */

.mobile-only {
    display: none !important;
}

/* TABLETS & SMALLER DESKTOPS */
@media (max-width: 1200px) {
    .app-main {
        grid-template-columns: 280px 1fr;
    }
    .panel-right {
        grid-column: 1 / span 2;
        max-height: none;
    }
}

/* MOBILE VIEWS (PORTRAIT & LANDSCAPE DRAWER OVERLAYS) */
@media (max-width: 1024px) {
    .mobile-only {
        display: inline-flex !important;
    }
    
    .app-container {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    /* Transform header into right vertical toolbar */
    .app-header {
        position: fixed !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 60px !important;
        height: 100vh !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 20px 0 !important;
        border-radius: 0 !important;
        border: none !important;
        border-left: 1px solid var(--panel-border) !important;
        background: rgba(10, 16, 28, 0.95) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 999 !important;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5) !important;
    }

    .brand {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .logo-text {
        display: none !important;
    }

    .header-mobile-toggles {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        align-items: center !important;
    }

    .header-mobile-toggles .btn {
        width: 42px !important;
        height: 42px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 16px !important;
    }

    .midi-status-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0 !important;
    }

    .midi-status-bar .status-label {
        display: none !important;
    }

    .midi-status-bar #midi-status {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        width: 40px !important;
        height: 40px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .midi-status-bar #midi-status .status-text {
        display: none !important;
    }

    .midi-status-bar #midi-status .pulse-dot {
        width: 12px !important;
        height: 12px !important;
    }

    .app-main {
        grid-template-columns: 1fr !important;
        margin-right: 60px !important;
        height: 100vh !important;
        width: calc(100vw - 60px) !important;
        gap: 0 !important;
    }

    /* Transform panels into absolute drawers */
    .panel-left, .panel-right {
        position: fixed !important;
        top: 0;
        bottom: 0;
        width: 320px !important;
        max-height: 100vh !important;
        z-index: 1000 !important;
        background: rgba(10, 16, 28, 0.96) !important;
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto;
        padding-top: 50px !important; /* Make room for close button */
    }

    .panel-left {
        left: 0;
        transform: translateX(-100%);
        border-right: 1px solid var(--panel-border);
        border-radius: 0 16px 16px 0;
    }

    .panel-right {
        right: 0;
        transform: translateX(100%);
        border-left: 1px solid var(--panel-border);
        border-radius: 16px 0 0 16px;
    }

    .panel-left.open, .panel-right.open {
        transform: translateX(0) !important;
    }

    .panel-center {
        grid-column: 1 !important;
        padding: 10px 15px 15px 15px !important;
        height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        background: transparent !important;
        border: none !important;
        overflow: hidden;
    }

    /* Close Button Styling */
    .panel-close-btn {
        position: absolute;
        top: 15px;
        right: 20px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 32px;
        cursor: pointer;
        z-index: 1010;
        line-height: 1;
        transition: color 0.2s ease;
    }

    .panel-close-btn:hover {
        color: var(--accent-red);
    }
    
    .metrics-dashboard {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* SMARTPHONES & LANDSCAPE MODE SPECIFICS */
@media (max-height: 540px), (max-width: 900px) and (orientation: landscape) {
    :root {
        /* Scale down the keyboard size to fit landscape viewport height */
        --key-white-width: 32px;
        --key-white-height: 120px;
        --key-black-width: 20px;
        --key-black-height: 75px;
    }

    .app-container {
        padding: 0 !important;
        gap: 0 !important;
    }

    .app-header {
        padding: 10px 0 !important;
        box-shadow: none !important;
    }

    .app-main {
        gap: 0 !important;
    }

    .panel-center {
        padding: 8px 12px 12px 12px !important;
        gap: 6px !important;
    }

    /* Keep metrics side-by-side but compact */
    .metrics-dashboard {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }

    .metric-card {
        padding: 4px 8px !important;
    }

    .metric-title {
        font-size: 9px !important;
        margin-bottom: 2px !important;
    }

    .metric-val {
        font-size: 18px !important;
    }

    .metric-visual-bar {
        margin-top: 4px !important;
    }

    .exercise-feedback-panel {
        padding: 8px !important;
        gap: 4px !important;
    }

    .exercise-header h2 {
        font-size: 13px !important;
    }

    .fingering-indicator-box {
        padding: 3px 6px !important;
    }

    .finger-number {
        font-size: 13px !important;
    }

    .note-stream-container {
        height: 75px !important;
    }

    .note-stream-guide-line {
        left: 60px !important; /* Bring timing target line closer on small screens */
    }

    .piano-keyboard-container {
        padding: 6px 3px 3px 3px !important;
    }

    .key-label {
        font-size: 8px !important;
        bottom: 4px !important;
    }

    .piano-key.black .key-label {
        font-size: 7px !important;
        bottom: 3px !important;
    }

    /* Narrower drawer width for landscape mobile */
    .panel-left, .panel-right {
        width: 280px !important;
    }
}

/* ORIENTATION WARNING OVERLAY */
.orientation-warning-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #090e1a;
    z-index: 999999;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

.warning-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 320px;
}

.rotate-device-icon {
    position: relative;
    font-size: 60px;
    color: var(--accent-blue);
    margin-bottom: 10px;
    animation: pulseGlow 2s infinite alternate;
}

.rotate-arrow {
    position: absolute;
    font-size: 24px;
    color: var(--accent-green);
    bottom: -5px;
    right: -10px;
    animation: spinClockwise 3s infinite linear;
}

.warning-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.warning-content p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

@keyframes spinClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 5px rgba(0, 240, 255, 0.2)); }
    100% { filter: drop-shadow(0 0 15px rgba(0, 240, 255, 0.6)); }
}

/* On mobile/tablets, show warning ONLY if in portrait mode */
@media (max-width: 1024px) and (orientation: portrait) {
    .orientation-warning-overlay {
        display: flex;
    }
}
