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

body {
    background: #0a0a0f;
    color: #ccccdd;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    height: 100dvh;
    width: 100dvw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
}

#disc {
    touch-action: none;
    cursor: crosshair;
}

/* Controls bar */
#controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #1a1a24;
    border-top: 1px solid #2a2a3a;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#play-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #4a4a5a;
    border-radius: 50%;
    background: transparent;
    color: #ccccdd;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.15s;
    flex-shrink: 0;
}

#play-btn:hover {
    border-color: #7a7a9a;
    background: rgba(255, 255, 255, 0.05);
}

#play-btn.playing {
    border-color: #ff6644;
    color: #ff6644;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a7a8a;
    white-space: nowrap;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: #2a2a3a;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ccccdd;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ccccdd;
    border: none;
    cursor: pointer;
}

#bpm-value {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    text-align: right;
}

.toggle-group {
    display: flex;
    gap: 2px;
}

.toggle-btn {
    padding: 4px 8px;
    border: 1px solid #3a3a4a;
    border-radius: 3px;
    background: transparent;
    color: #7a7a8a;
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.toggle-btn:hover {
    border-color: #5a5a6a;
    color: #aaaabc;
}

.toggle-btn.active {
    border-color: #ff8844;
    color: #ff8844;
    background: rgba(255, 136, 68, 0.1);
}

#quantize-btn {
    padding: 6px 14px;
    border: 1px solid #3a3a4a;
    border-radius: 4px;
    background: transparent;
    color: #9a9aaa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

#quantize-btn:hover {
    border-color: #4488ff;
    color: #4488ff;
}

#quantize-btn,
.toggle-group {
    flex-shrink: 0;
}

#clear-btn {
    padding: 6px 14px;
    border: 1px solid #3a3a4a;
    border-radius: 4px;
    background: transparent;
    color: #9a9aaa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    flex-shrink: 0;
}

#clear-btn:hover {
    border-color: #ff4444;
    color: #ff4444;
}

/* Sound selection popup */
#sound-menu {
    display: none;
    position: absolute;
    z-index: 10;
    background: #1a1a24;
    border: 1px solid #3a3a4a;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    padding: 4px 0;
    min-width: 120px;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}

#sound-menu .sound-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #aaaabb;
    transition: background 0.1s;
}

#sound-menu .sound-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

#sound-menu .sound-item.selected {
    color: #ffffff;
}

#sound-menu .sound-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

#sound-menu .sound-letter {
    font-weight: 600;
    width: 16px;
    text-align: center;
}

#sound-menu .sound-check {
    margin-left: auto;
    font-size: 11px;
    opacity: 0;
}

#sound-menu .sound-item.selected .sound-check {
    opacity: 1;
}

.sound-edit-btn {
    margin-left: auto;
    padding: 0 4px;
    font-size: 13px;
    color: #6a6a7a;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.sound-item:hover .sound-edit-btn {
    opacity: 1;
}

.sound-edit-btn:hover {
    color: #aaaacc;
}

/* Recording UI in sound menu */
.sound-menu-divider {
    height: 1px;
    background: #2a2a3a;
    margin: 4px 0;
}

.sound-record-btn .sound-mic-icon {
    background: none;
    color: #ff4444;
    font-size: 10px;
    width: 8px;
    text-align: center;
    line-height: 8px;
}

.sound-record-btn:hover .sound-mic-icon {
    color: #ff6666;
}

.sound-record-view {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    min-width: 140px;
}

.recording-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4444;
    animation: recording-pulse 0.8s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes recording-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.recording-label {
    font-size: 13px;
    color: #ccccdd;
}

.recording-cancel {
    margin-left: auto;
    padding: 2px 8px;
    border: 1px solid #3a3a4a;
    border-radius: 3px;
    background: transparent;
    color: #9a9aaa;
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.recording-cancel:hover {
    border-color: #ff6644;
    color: #ff6644;
}

/* Trim editor */
#sound-menu.trim-editor-mode {
    min-width: 280px;
    padding: 8px;
}

.trim-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trim-waveform-wrap {
    position: relative;
    width: 100%;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    background: #0f0f18;
}

.trim-waveform {
    display: block;
    width: 100%;
    height: 100%;
}

.trim-dim {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 1;
}

.trim-handle {
    position: absolute;
    top: 0;
    width: 24px;
    height: 100%;
    cursor: ew-resize;
    touch-action: none;
    z-index: 2;
}

.trim-handle::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 11px;
    width: 2px;
    background: #ffffff;
    border-radius: 1px;
}

.trim-handle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 8px;
    width: 8px;
    height: 20px;
    transform: translateY(-50%);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.trim-controls {
    display: flex;
    gap: 6px;
}

.trim-controls button {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #3a3a4a;
    border-radius: 4px;
    background: transparent;
    color: #9a9aaa;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.trim-play-btn:hover {
    border-color: #44ddaa;
    color: #44ddaa;
}

.trim-done-btn:hover {
    border-color: #4488ff;
    color: #4488ff;
}

.trim-cancel-btn:hover {
    border-color: #ff6644;
    color: #ff6644;
}

/* Lane editor panel */
#sound-menu.lane-editor-mode {
    width: 280px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0;
}

.lane-editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a3a;
}

.lane-editor-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lane-editor-title {
    font-size: 14px;
    font-weight: 600;
    color: #ccccdd;
}

.lane-editor-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #6a6a7a;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 4px;
    transition: color 0.15s;
}

.lane-editor-close:hover {
    color: #ccccdd;
}

.lane-editor-sounds {
    max-height: 180px;
    overflow-y: auto;
    padding: 4px 0;
}

.lane-editor-effects {
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lane-effect-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lane-effect-row label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a7a8a;
    width: 38px;
    flex-shrink: 0;
}

.lane-effect-row input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
}

.lane-effect-value {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: #9a9aaa;
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}

/* Mobile adjustments */
@media (max-width: 500px) {
    #controls {
        gap: 12px;
        padding: 10px 12px;
    }

    input[type="range"] {
        width: 70px;
    }

    #play-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
}
