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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e94560;
}

header h1 {
    font-size: 1.5rem;
    color: #fff;
    font-weight: 600;
}

.midi-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.status-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #555;
    transition: background 0.3s;
}

.status-dot.connected { background: #4ade80; box-shadow: 0 0 8px #4ade8088; }
.status-dot.error { background: #e94560; }

/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    background: #1a1a2e;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #2a2a4a;
}

.sidebar h2 {
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-card {
    background: #16213e;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #2a2a4a;
}

.info-card h3 {
    font-size: 0.85rem;
    color: #8888aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.info-card .value {
    font-size: 1.15rem;
    color: #fff;
    font-weight: 600;
}

.info-card .sub {
    font-size: 0.8rem;
    color: #8888aa;
    margin-top: 4px;
}

/* Practice Timer */
.timer-section {
    background: #16213e;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #2a2a4a;
    text-align: center;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    margin: 10px 0;
}

.timer-label {
    font-size: 0.8rem;
    color: #e94560;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.timer-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-start { background: #4ade80; color: #0f0f1a; }
.btn-start:hover { background: #22c55e; }
.btn-pause { background: #f59e0b; color: #0f0f1a; }
.btn-pause:hover { background: #d97706; }
.btn-reset { background: #444; color: #ccc; }
.btn-reset:hover { background: #555; }

/* Practice Sections */
.practice-sections {
    margin-top: 12px;
}

.section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.section-item:hover { background: #16213e; }
.section-item.active {
    background: #16213e;
    border-color: #e94560;
}

.section-item.done {
    opacity: 0.5;
    text-decoration: line-through;
}

.section-time {
    color: #8888aa;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Main content */
.main-content {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

/* Piano */
.piano-container {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #2a2a4a;
}

.piano-container h2 {
    font-size: 0.9rem;
    color: #8888aa;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.piano-wrapper {
    overflow-x: auto;
    padding-bottom: 10px;
}

.piano {
    display: flex;
    position: relative;
    height: 180px;
    min-width: max-content;
    margin: 0 auto;
}

.key {
    position: relative;
    cursor: pointer;
    transition: background 0.08s;
    border-radius: 0 0 5px 5px;
    z-index: 1;
}

.key.white {
    width: 40px;
    height: 180px;
    background: linear-gradient(180deg, #f0f0f0 0%, #fff 10%, #e8e8e8 100%);
    border: 1px solid #bbb;
    margin-right: -1px;
}

.key.black {
    width: 26px;
    height: 115px;
    background: linear-gradient(180deg, #222 0%, #111 100%);
    border: 1px solid #000;
    margin-left: -13px;
    margin-right: -13px;
    z-index: 2;
    border-radius: 0 0 4px 4px;
}

.key.white.active, .key.white.playing { background: linear-gradient(180deg, #e94560 0%, #c73a52 100%); }
.key.black.active, .key.black.playing { background: linear-gradient(180deg, #e94560 0%, #a83048 100%); }

.key.white.playing:not(.active) { background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%); }
.key.black.playing:not(.active) { background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%); }

.key.white.target {
    background: linear-gradient(180deg, #4ade80 20%, #22c55e 100%);
    border-color: #16a34a;
}

.key.black.target {
    background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
}

.key.white.active.target {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    border-color: #d97706;
}

.key.black.active.target {
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.key-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #999;
    pointer-events: none;
}

.key.black .key-label { color: #666; bottom: 6px; font-size: 0.55rem; }

/* Note display */
.note-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 14px;
    min-height: 50px;
}

.current-note {
    font-size: 2.2rem;
    font-weight: 700;
    color: #e94560;
    min-width: 80px;
    text-align: center;
}

.note-history {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 400px;
}

.note-history span {
    background: #2a2a4a;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #aaa;
}

/* Exercise panel */
.exercise-panel {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #2a2a4a;
    flex: 1;
}

.exercise-panel h2 {
    font-size: 0.9rem;
    color: #8888aa;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.scale-notes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.scale-note {
    width: 50px; height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    background: #2a2a4a;
    color: #aaa;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.scale-note.next {
    border-color: #4ade80;
    color: #4ade80;
    background: #4ade8015;
}

.scale-note.hit {
    background: #4ade80;
    color: #0f0f1a;
    border-color: #4ade80;
}

.scale-note.missed {
    border-color: #e94560;
    color: #e94560;
}

/* Inversions */
.inversions-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.inversion-card {
    background: #16213e;
    border-radius: 8px;
    padding: 14px;
    border: 1px solid #2a2a4a;
    min-width: 140px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.inversion-card:hover { border-color: #e94560; }
.inversion-card.active-inv { border-color: #4ade80; background: #4ade8010; }

.inversion-card h4 {
    font-size: 0.8rem;
    color: #8888aa;
    margin-bottom: 8px;
}

.inversion-notes {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

/* Progression */
.progression-display {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.chord-badge {
    padding: 12px 24px;
    background: #16213e;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid #2a2a4a;
    transition: all 0.3s;
}

.chord-badge.current-chord {
    border-color: #e94560;
    background: #e9456020;
    color: #e94560;
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    background: #16213e;
    border-radius: 8px;
    padding: 12px 18px;
    border: 1px solid #2a2a4a;
    text-align: center;
    min-width: 100px;
}

.stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.stat .stat-label {
    font-size: 0.7rem;
    color: #8888aa;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Velocity meter */
.velocity-bar {
    width: 100%;
    height: 6px;
    background: #2a2a4a;
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}

.velocity-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #e94560);
    border-radius: 3px;
    transition: width 0.1s;
    width: 0%;
}

/* MIDI device selector */
.device-selector {
    margin-top: 10px;
}

.device-selector select {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #2a2a4a;
    background: #16213e;
    color: #e0e0e0;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid #2a2a4a;
    }
}

/* Tab navigation for exercises */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #2a2a4a;
    color: #aaa;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #e94560;
    color: #fff;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Practice tips */
.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: #aaa;
    border-bottom: 1px solid #2a2a4a;
}

.tips-list li:last-child { border-bottom: none; }

.tips-list li::before {
    content: "\2022";
    color: #e94560;
    margin-right: 8px;
}

/* ── Song Player ── */
.player-header {
    margin-bottom: 16px;
}

.song-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #2a2a4a;
    background: #16213e;
    color: #e0e0e0;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.player-song-info {
    font-size: 0.9rem;
    color: #ccc;
    min-height: 36px;
}

.player-transport {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.transport-btn {
    width: 40px; height: 40px;
    border: none;
    border-radius: 8px;
    background: #2a2a4a;
    color: #ccc;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.transport-btn:hover { background: #3a3a5a; color: #fff; }
.transport-btn.play-btn { background: #4ade80; color: #0f0f1a; font-size: 1.2rem; width: 48px; height: 48px; }
.transport-btn.play-btn:hover { background: #22c55e; }

.player-pos {
    margin-left: 12px;
    font-size: 0.85rem;
    color: #8888aa;
    font-variant-numeric: tabular-nums;
}

.player-progress-bar {
    width: 100%;
    height: 8px;
    background: #2a2a4a;
    border-radius: 4px;
    margin-bottom: 16px;
    cursor: pointer;
    overflow: hidden;
}

.player-progress {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #6366f1);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.player-controls-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.75rem;
    color: #8888aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group input[type="range"] {
    width: 140px;
    accent-color: #e94560;
}

.control-group span {
    font-size: 0.8rem;
    color: #aaa;
}

.hand-selector {
    display: flex;
    gap: 4px;
}

.hand-btn {
    padding: 6px 14px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16213e;
    color: #aaa;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.hand-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.player-staff-container {
    width: 100%;
    margin-top: 12px;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    overflow: hidden;
    background: #0d0d1a;
}

.player-staff-container canvas {
    display: block;
    width: 100%;
}

.pdf-viewer {
    width: 100%;
    height: 500px;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    margin-top: 12px;
    background: #fff;
}

.tab-nav {
    flex-wrap: wrap;
}

/* ── Song Learner ── */
.learner-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.learner-controls .song-select {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.learner-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.learner-hand-btn {
    padding: 6px 14px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    background: #16213e;
    color: #aaa;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.learner-hand-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.learner-staff-container {
    background: #0d0d1a;
    border-radius: 8px;
    border: 1px solid #2a2a3a;
    overflow: hidden;
}

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

.attribution-footer {
    text-align: center;
    padding: 12px;
    font-size: 0.75rem;
    color: #555;
    border-top: 1px solid #1a1a2e;
    margin-top: 16px;
}
.attribution-footer a { color: #4a9eff; text-decoration: none; }
.attribution-footer a:hover { text-decoration: underline; }
