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

:root {
    --primary-color: #7e83ff;
    --primary-hover: #6d73ff;
    --secondary-color: #a48bff;
    --accent-color: #38bdf8;
    --success-color: #34d399;
    --danger-color: #f97373;
    --warning-color: #fbbf24;
    --bg-dark: #151c2f;
    --bg-darker: #101726;
    --bg-light: #1f2a3e;
    --bg-lighter: #2c3a52;
    --text-primary: #f8fafc;
    --text-secondary: #a8b1c5;
    --text-muted: #7b869b;
    --border-color: rgba(148, 163, 184, 0.2);
    --border-light: rgba(148, 163, 184, 0.35);
    --shadow: 0 12px 32px rgba(10, 14, 29, 0.35);
    --shadow-lg: 0 28px 60px rgba(5, 8, 20, 0.45);
    --glow-primary: 0 0 24px rgba(126, 131, 255, 0.4);
    --glow-success: 0 0 24px rgba(52, 211, 153, 0.4);
    --track-label-width: 180px;
    --timeline-width: 4800px;
}

body {
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: radial-gradient(circle at top, rgba(20, 28, 46, 0.95), rgba(12, 18, 33, 0.98));
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Audio Notifications */
.audio-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    z-index: 10000;
    max-width: 400px;
    font-size: 0.9rem;
    font-weight: 500;
    display: none;
    animation: slideInRight 0.3s ease-out;
}

.audio-notification.error {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.95), rgba(239, 68, 68, 0.9));
    border: 1px solid rgba(248, 113, 113, 0.4);
}

.audio-notification.success {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.95), rgba(16, 185, 129, 0.9));
    border: 1px solid rgba(52, 211, 153, 0.4);
}

/* Loading indicator for audio */
.audio-loading {
    position: relative;
}

.audio-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    overflow: hidden;
}

.welcome-container {
    text-align: center;
    padding: 4rem 3rem;
    background: linear-gradient(135deg, rgba(31, 42, 62, 0.9), rgba(23, 31, 49, 0.85));
    border-radius: 24px;
    box-shadow: 
        0 32px 80px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 520px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.12);
    position: relative;
    overflow: hidden;
}

.welcome-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(126, 131, 255, 0.6), transparent);
}

.logo {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
    text-transform: lowercase;
}

.logo-small {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    text-transform: lowercase;
}

.separator {
    color: var(--border-color);
    margin: 0 0.75rem;
}

.welcome-container h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.welcome-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    text-transform: none;
    letter-spacing: 0.01em;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 
        0 8px 20px rgba(126, 131, 255, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 32px rgba(126, 131, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(31, 42, 62, 0.8), rgba(23, 31, 49, 0.9));
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(39, 52, 78, 0.9), rgba(31, 42, 62, 0.95));
    border-color: rgba(148, 163, 184, 0.35);
    transform: translateY(-1px);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-light);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Editor Screen */
.editor-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(33, 41, 62, 0.82), rgba(20, 26, 41, 0.86));
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.4);
    flex-shrink: 0;
}

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

.header-left h1 {
    font-size: 1.5rem;
}

.file-name {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.2s ease;
}

.file-name:hover {
    color: var(--text-primary);
}

.file-name.editing {
    color: var(--text-primary);
}

.file-name.editing input {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    width: 14ch;
    box-shadow: 0 0 12px rgba(15, 23, 42, 0.45);
}

.file-name.editing input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Transport Controls */
.transport-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(30, 39, 60, 0.82), rgba(23, 31, 49, 0.8));
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 6px 18px rgba(8, 12, 24, 0.35);
    flex-wrap: nowrap;
    flex-shrink: 0;
    min-height: auto;
    justify-content: flex-start;
}

.volume-control-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.playback-controls {
    display: flex;
    gap: 0.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--border-color);
}

.metronome-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0 1rem;
    border-right: 1px solid var(--border-color);
    min-width: 70px;
}

.metronome-indicator span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.metronome-orb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), rgba(99,102,241,0.85) 60%, rgba(39,39,224,0.3));
    box-shadow: 
        0 0 8px rgba(99, 102, 241, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    opacity: 0.35;
    transform: scale(0.85);
    transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.metronome-orb.active {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 
        0 0 20px rgba(99, 102, 241, 0.9),
        0 0 8px rgba(99, 102, 241, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.metronome-orb.downbeat {
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.98), rgba(244, 114, 182, 0.9) 60%, rgba(236, 72, 153, 0.3));
    box-shadow: 
        0 0 24px rgba(244, 114, 182, 0.95),
        0 0 12px rgba(244, 114, 182, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border-color: rgba(244, 114, 182, 0.4);
}

.metronome-orb.beat {
    animation: orbPulse 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes orbPulse {
    0% {
        transform: scale(0.85);
    }
    40% {
        transform: scale(1.35);
    }
    100% {
        transform: scale(1.1);
    }
}

.btn-play {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--success-color), #22c55e);
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 8px 20px rgba(52, 211, 153, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.btn-play::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.btn-play:hover {
    transform: scale(1.08);
    box-shadow: 
        0 12px 32px rgba(52, 211, 153, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-play:hover::before {
    width: 100%;
    height: 100%;
}

.btn-play:active {
    transform: scale(1.02);
}

.btn-play.playing {
    background: linear-gradient(135deg, var(--danger-color), #ef4444);
    box-shadow: 
        0 8px 20px rgba(248, 113, 113, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-play.playing:hover {
    box-shadow: 
        0 12px 32px rgba(248, 113, 113, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-play svg {
    width: 22px;
    height: 22px;
    fill: white;
    position: relative;
    z-index: 1;
}

.btn-stop {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 42, 62, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.22);
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}

.btn-stop:hover {
    background: rgba(39, 52, 78, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
    transform: translateY(-1px);
}

.btn-stop svg {
    width: 16px;
    height: 16px;
    fill: var(--text-primary);
}

.cursor-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--border-color);
}

.cursor-mode label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.mode-toggle {
    display: flex;
    background: rgba(31, 42, 62, 0.72);
    border-radius: 10px;
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    backdrop-filter: blur(12px);
}

.mode-toggle button {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.mode-toggle button.active {
    background: linear-gradient(135deg, rgba(126, 131, 255, 0.9), rgba(56, 189, 248, 0.75));
    color: white;
    box-shadow: 0 10px 18px rgba(20, 30, 55, 0.45);
}

.metronome-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.toggle {
    position: relative;
    width: 48px;
    height: 24px;
    display: inline-block;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(32, 41, 62, 0.7);
    border-radius: 30px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 2.5px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(200, 210, 230, 0.8));
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 8px rgba(12, 18, 33, 0.35);
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: var(--glow-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(223, 229, 255, 0.9));
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* Preview Panel - Now in Timeline Controls */
.timeline-controls .preview-panel {
    display: flex;
    gap: 0.5rem;
    padding: 0;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
}

.timeline-controls .preview-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: center;
    flex-shrink: 0;
}

.timeline-controls .preview-label {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-controls .preview-value {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    background: rgba(33, 45, 70, 0.65);
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', monospace;
    letter-spacing: 0.04em;
    min-width: 84px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.status-stopped {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    font-weight: 700;
}

.status-started {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

/* Timeline Container */
.timeline-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem;
    background: linear-gradient(160deg, rgba(18, 26, 42, 0.88), rgba(12, 20, 34, 0.95));
    position: relative;
    z-index: 1;
    min-height: 300px;
    height: 0;
}

.timeline-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    background: var(--bg-light);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.controls-left {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-darker);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.zoom-controls label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-left: 0.5rem;
}

#zoomLevel {
    min-width: 60px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.timeline-wrapper {
    position: relative;
    flex: 1 1 auto;
    overflow: auto;
    background: var(--bg-darker);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: crosshair;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    --measure-width: 100px;
    --beat-width: 25px;
    --timeline-width: 4800px;
    min-height: 0;
    height: 100%;
    z-index: 1;
}

/* Right-click hint tooltip */
.timeline-wrapper::before {
    content: 'Right-click to add events';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.9);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
    font-weight: 500;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.timeline-wrapper:hover::before {
    opacity: 1;
}

.timeline-ruler {
    height: 50px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.85) 100%);
    border-bottom: 2px solid var(--border-light);
    position: relative;
    min-width: calc(var(--track-label-width) + var(--timeline-width));
    padding-left: var(--track-label-width);
    box-shadow: inset 0 -6px 12px rgba(8, 15, 32, 0.65);
}

.timeline-ruler::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: var(--track-label-width);
    height: 100%;
    background: linear-gradient(180deg, rgba(28, 37, 54, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset -6px 0 12px rgba(8, 15, 32, 0.6);
    z-index: 1;
}

.timeline-ruler::after {
    content: '';
    position: absolute;
    top: 0;
    left: var(--track-label-width);
    right: 0;
    height: 100%;
    background-image: linear-gradient(to bottom, rgba(241, 245, 249, 0.12) 0%, rgba(148, 163, 184, 0) 50%);
    pointer-events: none;
    z-index: 1;
}

.ruler-mark {
    position: absolute;
    top: 0;
    height: 100%;
    border-left: 1px solid var(--border-color);
    padding-left: 6px;
    padding-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 2;
}

.ruler-mark.major {
    border-left-width: 2px;
    border-left-color: var(--border-light);
}

.ruler-mark.major::after {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    width: 2px;
    height: 12px;
    background: var(--primary-color);
}

.timeline-tracks {
    position: relative;
}

.track {
    display: grid;
    grid-template-columns: var(--track-label-width) 1fr;
    border-bottom: 1px solid var(--border-color);
    min-height: 80px;
    transition: background 0.2s;
    position: relative;
}

.track:hover {
    background: rgba(99, 102, 241, 0.02);
}

.track:last-child {
    border-bottom: none;
}

.track-label {
    width: var(--track-label-width);
    padding: 1.1rem 1rem 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
    border-right: 1px solid rgba(148, 163, 184, 0.25);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    left: 0;
    z-index: 3;
    backdrop-filter: blur(10px);
    box-shadow: inset -8px 0 16px rgba(8, 15, 32, 0.6);
}

.track-label::before {
    content: '';
    width: 3px;
    height: 20px;
    border-radius: 2px;
}

.track:nth-child(1) .track-label::before {
    background: var(--success-color);
}

.track:nth-child(2) .track-label::before {
    background: var(--primary-color);
}

.track:nth-child(3) .track-label::before {
    background: var(--warning-color);
}

.track-content {
    position: relative;
    min-width: max(100%, var(--timeline-width));
    overflow: hidden;
    background-color: rgba(18, 27, 45, 0.9);
    background-image:
        linear-gradient(to bottom, rgba(33, 43, 66, 0.55), rgba(12, 18, 33, 0.75)),
        repeating-linear-gradient(
            to right,
            rgba(248, 250, 252, 0.12) 0px,
            rgba(248, 250, 252, 0.12) 3px,
            transparent 3px,
            transparent var(--measure-width)
        ),
        repeating-linear-gradient(
            to right,
            rgba(148, 163, 184, 0.14) 0px,
            rgba(148, 163, 184, 0.14) calc(var(--beat-width) / 4),
            rgba(12, 18, 33, 0) calc(var(--beat-width) / 4),
            rgba(12, 18, 33, 0) var(--beat-width)
        ),
        repeating-linear-gradient(
            to right,
            rgba(125, 211, 252, 0.14) 0px,
            rgba(125, 211, 252, 0.14) var(--beat-width),
            rgba(18, 27, 45, 0) var(--beat-width),
            rgba(18, 27, 45, 0) calc(var(--beat-width) * 2)
        ),
        repeating-linear-gradient(
            to right,
            rgba(126, 131, 255, 0.18) 0px,
            rgba(126, 131, 255, 0.18) var(--measure-width),
            rgba(18, 27, 45, 0) var(--measure-width),
            rgba(18, 27, 45, 0) calc(var(--measure-width) * 2)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(38, 50, 74, 0.45) 0px,
            rgba(38, 50, 74, 0.45) 45px,
            rgba(12, 18, 33, 0.85) 45px,
            rgba(12, 18, 33, 0.85) 90px
        );
    background-size: auto 100%, var(--measure-width) 100%, var(--beat-width) 100%, var(--beat-width) 100%, var(--measure-width) 100%, 100% auto;
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

.timeline-cursor {
    position: absolute;
    top: 0;
    left: var(--track-label-width);
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.95) 0%, rgba(59, 130, 246, 0.9) 100%);
    pointer-events: none;
    z-index: 100;
    box-shadow: var(--glow-primary);
    transition: left 0.1s ease-out;
}

.timeline-cursor::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 19px;
    height: 19px;
    background: var(--primary-color);
    border-radius: 50%;
    border: 3px solid var(--bg-darker);
    box-shadow: var(--glow-primary);
}

.timeline-cursor::after {
    content: '';
    position: absolute;
    top: 19px;
    left: -5.5px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 12px solid var(--primary-color);
}

.timeline-status-marker {
    position: absolute;
    top: 8px;
    left: calc(var(--track-label-width) + 12px);
    background: rgba(27, 37, 59, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-left: 3px solid rgba(56, 189, 248, 0.85);
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 12px 24px rgba(10, 14, 29, 0.35);
    z-index: 90;
    pointer-events: none;
    backdrop-filter: blur(6px);
    opacity: 0.4;
}

.timeline-status-marker .marker-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Timeline Events */
.timeline-event {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 0.75rem;
    background: linear-gradient(160deg, rgba(30, 64, 175, 0.85), rgba(59, 130, 246, 0.65));
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-width: 80px;
    max-width: 160px;
    backdrop-filter: blur(6px);
    font-size: 0.85rem;
}

.timeline-event.spans-duration {
    min-width: 60px;
    max-width: none;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.timeline-event:active {
    cursor: grabbing;
}

.timeline-event:hover {
    transform: translateY(-50%) scale(1.05) translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.5);
    z-index: 10;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.1rem;
}

.event-position {
    background: rgba(15, 23, 42, 0.4);
    padding: 0.15rem 0.4rem;
    border-radius: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.6rem;
    color: rgba(249, 250, 251, 0.9);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.event-type {
    opacity: 0.75;
    font-weight: 600;
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.6rem;
}

.event-main {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    color: #f8fafc;
    line-height: 1.2;
}

.timeline-event.event-startstop {
    background: linear-gradient(155deg, rgba(16, 185, 129, 0.88), rgba(5, 150, 105, 0.7));
}

.timeline-event.event-startstop.stop {
    background: linear-gradient(155deg, rgba(248, 113, 113, 0.95), rgba(220, 38, 38, 0.75));
}

.timeline-event.event-bpm {
    background: linear-gradient(140deg, rgba(99, 102, 241, 0.85), rgba(56, 189, 248, 0.7));
    border: 1px solid rgba(126, 131, 255, 0.45);
    box-shadow: 0 2px 8px rgba(11, 16, 32, 0.4), 0 0 0 1px rgba(126,131,255,0.25);
}

.timeline-event.event-bpm.gradual {
    background: linear-gradient(90deg, rgba(244, 114, 182, 0.9), rgba(126, 131, 255, 0.8));
    border: 1px solid rgba(244, 114, 182, 0.6);
    position: relative;
    box-shadow: 0 2px 8px rgba(11, 16, 32, 0.4), 0 0 0 1px rgba(244,114,182,0.4), 0 0 12px -2px rgba(244,114,182,0.5);
}

.timeline-event.event-bpm.gradual.spans-duration {
    background: linear-gradient(90deg, 
        rgba(244, 114, 182, 0.9) 0%, 
        rgba(186, 123, 210, 0.85) 50%, 
        rgba(126, 131, 255, 0.8) 100%);
    border-left: 3px solid rgba(244, 114, 182, 0.9);
    border-right: 3px solid rgba(126, 131, 255, 0.9);
    border-top: 1px solid rgba(200, 120, 220, 0.6);
    border-bottom: 1px solid rgba(200, 120, 220, 0.6);
}

.timeline-event.event-bpm.gradual.spans-duration::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    height: 2px;
    background: linear-gradient(90deg, rgba(244, 114, 182, 0.8), rgba(126, 131, 255, 0.8));
    transform: translateY(-50%);
    border-radius: 1px;
}

.timeline-event.event-bpm.gradual.spans-duration::after {
    content: '⟶';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(126, 131, 255, 0.9);
    font-weight: 700;
    font-size: 0.8rem;
}

.timeline-event.event-timesig {
    background: linear-gradient(155deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.78));
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

/* Event Panel */
.event-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-light);
    border-left: 2px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.event-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-light));
    border-bottom: 2px solid var(--border-light);
}

.event-panel-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.event-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.85rem;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-dark);
}

.form-control:hover {
    border-color: var(--border-light);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* ============================================
   NEW FEATURES STYLING
   ============================================ */

/* Volume Control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.volume-control label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}

.volume-slider {
    flex: 1;
    max-width: 200px;
    height: 4px;
    border-radius: 2px;
    background: rgba(31, 42, 62, 0.72);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(126, 131, 255, 0.4);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(126, 131, 255, 0.6);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

#volumeValue {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 38px;
    text-align: right;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

/* Bookmarks Panel */
.bookmarks-panel {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 500px;
    background: linear-gradient(135deg, rgba(31, 42, 62, 0.98), rgba(23, 31, 49, 0.95));
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: slideInLeft 0.3s ease-out;
    pointer-events: auto;
}

@keyframes slideInLeft {
    from {
        transform: translateY(-50%) translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
    }
}

.bookmarks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.bookmarks-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    max-height: 400px;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2rem 1rem;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.bookmark-item:hover {
    background: rgba(39, 52, 78, 0.7);
    border-color: rgba(126, 131, 255, 0.4);
    transform: translateX(4px);
}

.bookmark-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bookmark-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.bookmark-position {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.bookmark-item .btn-delete {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: var(--danger-color);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.bookmark-item .btn-delete:hover {
    background: var(--danger-color);
    color: white;
    transform: scale(1.1);
}

.bookmarks-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.5);
    border-radius: 0 0 16px 16px;
}

.bookmarks-footer small {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Grid Lines - Show on every beat */
.timeline-ruler.show-grid-lines {
    background-image: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(var(--beat-width, 25px) - 1px),
            rgba(148, 163, 184, 0.12) calc(var(--beat-width, 25px) - 1px),
            rgba(148, 163, 184, 0.12) var(--beat-width, 25px)
        );
}

.timeline-tracks .track-content {
    background-image: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(var(--beat-width, 25px) * var(--zoom, 1) - 1px),
            rgba(148, 163, 184, 0.08) calc(var(--beat-width, 25px) * var(--zoom, 1) - 1px),
            rgba(148, 163, 184, 0.08) calc(var(--beat-width, 25px) * var(--zoom, 1))
        );
}

/* Light Theme */
body.light-theme {
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    --bg-dark: #f8fafc;
    --bg-darker: #ffffff;
    --bg-light: #e2e8f0;
    --bg-lighter: #cbd5e1;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: rgba(100, 116, 139, 0.3);
    --border-light: rgba(100, 116, 139, 0.5);
}

body.light-theme .timeline-event {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

body.light-theme .timeline-wrapper {
    background: #ffffff;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.light-theme .timeline-ruler {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    box-shadow: inset 0 -2px 8px rgba(0, 0, 0, 0.05);
}

body.light-theme .bookmarks-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.9));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.1);
}

body.light-theme .bookmark-item {
    background: rgba(241, 245, 249, 0.7);
    border-color: rgba(100, 116, 139, 0.2);
}

body.light-theme .bookmark-item:hover {
    background: rgba(226, 232, 240, 0.9);
    border-color: rgba(126, 131, 255, 0.5);
}

/* Theme Toggle Button - Add to header */
.theme-toggle {
    margin-left: 0.5rem;
    padding: 0.5rem;
    background: rgba(31, 42, 62, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    background: rgba(39, 52, 78, 0.9);
    transform: translateY(-1px);
}

/* Selection highlight for events */
.timeline-event.selected {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 24px rgba(126, 131, 255, 0.7);
    z-index: 10;
}

.timeline-event {
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

.timeline-event:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Selection Box for Drag Selection */
.selection-box {
    position: absolute;
    border: 2px solid var(--primary-color);
    background: rgba(126, 131, 255, 0.15);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 0 12px rgba(126, 131, 255, 0.4);
}

body.light-theme .selection-box {
    background: rgba(99, 102, 241, 0.12);
    border-color: #6366f1;
}

/* Keyboard shortcut hints */
.shortcut-hint {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.98);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    backdrop-filter: blur(16px);
    border: 2px solid rgba(126, 131, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 450px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    line-height: 1.9;
}

.shortcut-hint.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.shortcut-hint strong {
    color: var(--accent);
    font-size: 1rem;
    display: block;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(126, 131, 255, 0.2);
    padding-bottom: 8px;
}

body.light-theme .shortcut-hint {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(126, 131, 255, 0.5);
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body.light-theme .preview-value {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(203, 213, 225, 0.5);
    color: var(--text-primary);
}

body.light-theme .timeline-event {
    border: 1px solid rgba(203, 213, 225, 0.6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.light-theme .metronome-orb {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
}

body.light-theme .volume-slider {
    background: rgba(203, 213, 225, 0.5);
}

body.light-theme .status-stopped {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

body.light-theme .status-started {
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

body.light-theme .editor-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.9));
    border-bottom: 1px solid rgba(203, 213, 225, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.light-theme .transport-controls {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.9));
    border-bottom: 1px solid rgba(203, 213, 225, 0.7);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body.light-theme .timeline-container {
    background: linear-gradient(160deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.98));
}

body.light-theme .timeline-controls {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(203, 213, 225, 0.5);
}

body.light-theme .track {
    border-bottom: 1px solid rgba(203, 213, 225, 0.4);
}

body.light-theme .track:hover {
    background: rgba(99, 102, 241, 0.03);
}

body.light-theme .btn {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(203, 213, 225, 0.6);
    color: var(--text-primary);
}

body.light-theme .btn:hover {
    background: rgba(226, 232, 240, 0.9);
    border-color: rgba(99, 102, 241, 0.4);
}

body.light-theme .btn-primary {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: white;
    border: none;
}

body.light-theme .btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
}
