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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #2b2b2b;
    color: #d4d4d4;
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
}

.player-container {
    background: #3c3c3c;
    border: 1px solid #555;
    border-radius: 8px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.title-bar {
    background: #2d2d30;
    padding: 8px 12px;
    border-bottom: 1px solid #555;
    font-size: 13px;
    color: #cccccc;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.title-bar-text {
    flex: 1;
}

.help-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007acc;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    transition: background 0.2s;
}

.help-icon:hover {
    background: #0098ff;
}

.content {
    padding: 15px 15px 10px 15px;
    flex: 1 1 auto;
    min-height: 0;
}

.section {
    background: #2d2d30;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 12px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: #9cdcfe;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* MIDI Channels */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.channel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.channel-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #007acc;
}

.channel-number {
    font-size: 11px;
    color: #cccccc;
}

.vu-meter {
    width: 40px;
    height: 6px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.vu-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00 0%, #ffff00 60%, #ff0000 100%);
    width: 0%;
    transition: width 0.05s ease-out;
}

.master-vu {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.master-vu-label {
    font-size: 11px;
    font-weight: 600;
    color: #9cdcfe;
    letter-spacing: 0.4px;
}

.master-vu-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 220px;
}

.master-vu-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.vu-side {
    font-size: 10px;
    color: #cccccc;
    width: 14px;
    text-align: right;
    letter-spacing: 0.5px;
}

.master-vu-row .vu-meter {
    width: 100%;
    max-width: none;
    height: 8px;
}

.master-vu-row .vu-meter-fill {
    transition: width 0.05s ease-out;
}

.channel-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-small {
    padding: 4px 12px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #3c3c3c;
    color: #cccccc;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #505050;
    border-color: #007acc;
}

.btn-small:active {
    background: #2d2d30;
}

/* File Loading Buttons */
.btn-file-load {
    padding: 4px 12px;
    background: #0e639c;
    color: #fff;
    border: 1px solid #007acc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-file-load:hover {
    background: #1177bb;
}

.btn-file-load:active {
    background: #004578;
}

.file-load-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.file-load-status {
    font-size: 11px;
    color: #858585;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Playback Controls */
.controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

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

.control-label {
    font-size: 12px;
    color: #cccccc;
    min-width: 70px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #1e1e1e;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    background: #007acc;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    background: #007acc;
    cursor: pointer;
    border: none;
}

.slider-value {
    font-size: 11px;
    color: #cccccc;
    min-width: 45px;
    text-align: right;
}

.btn-reset {
    padding: 3px 10px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #3c3c3c;
    color: #cccccc;
    font-size: 11px;
    cursor: pointer;
    min-width: 50px;
}

.btn-reset:hover {
    background: #505050;
    border-color: #007acc;
}

select {
    padding: 4px 8px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #3c3c3c;
    color: #cccccc;
    font-size: 11px;
    cursor: pointer;
    outline: none;
}

select:hover {
    border-color: #007acc;
}

/* Transport Controls */
.transport-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transport-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-transport {
    padding: 6px 16px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #3c3c3c;
    color: #cccccc;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-transport:hover:not(:disabled) {
    background: #505050;
    border-color: #007acc;
}

.btn-transport:active:not(:disabled) {
    background: #2d2d30;
}

.btn-transport:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loop-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.loop-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #007acc;
}

.loop-label {
    font-size: 12px;
    color: #cccccc;
    cursor: pointer;
}

.export-progress {
    display: none;
    margin-top: 10px;
    padding: 8px;
    background: #1e1e1e;
    border-radius: 3px;
}

.export-status {
    font-size: 11px;
    color: #9cdcfe;
    margin-bottom: 6px;
}

.export-progress-bar {
    width: 100%;
    height: 4px;
    background: #3c3c3c;
    border-radius: 2px;
    overflow: hidden;
}

.export-progress-fill {
    height: 100%;
    background: #007acc;
    width: 0%;
    transition: width 0.2s;
}

.progress-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.time-display {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    min-width: 72px;
    text-align: center;
    color: #cccccc;
}

.time-display:first-child {
    cursor: pointer;
}

.time-display:first-child:hover {
    color: #9cdcfe;
}

.progress-bar {
    flex: 1 1 220px;
    height: 6px;
    border-radius: 3px;
    background: #1e1e1e;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #007acc;
    border-radius: 3px;
    transition: width 0.1s ease;
    width: 0%;
}

/* Virtual Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.keyboard-select {
    flex: 1;
}

.velocity-display {
    font-size: 11px;
    color: #cccccc;
}

.keys-container {
    background: #1e1e1e;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 120px;
    overflow-x: auto;
}

.key {
    position: relative;
    cursor: default;
    user-select: none;
}

.white-key {
    width: 30px;
    height: 95px;
    background: linear-gradient(to bottom, #ffffff 0%, #f5f5f5 50%, #e8e8e8 100%);
    border: 1px solid #3c3c3c;
    border-radius: 0 0 3px 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: all 0.05s ease;
}

.white-key:hover {
    background: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 50%, #d8d8d8 100%);
}

.white-key.active {
    background: linear-gradient(to bottom, #007acc 0%, #005a9e 50%, #004578 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 8px rgba(0, 122, 204, 0.6);
    transform: translateY(1px);
}

.white-key.from-playback {
    background: linear-gradient(to bottom, #00cc88 0%, #009e6e 50%, #007855 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 6px rgba(0, 204, 136, 0.5);
}

.black-key {
    width: 12px;
    height: 60px;
    background: linear-gradient(to bottom, #2a2a2a 0%, #1a1a1a 50%, #000000 100%);
    border: 1px solid #000;
    border-radius: 0 0 2px 2px;
    position: absolute;
    right: -8px;
    z-index: 1;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.6);
    transition: all 0.05s ease;
}

/* Specific positioning for different black key positions */
.black-key-C { right: -8.5px; }
.black-key-D { right: -9.5px; }
.black-key-F { right: -9px; }
.black-key-G { right: -8.5px; }
.black-key-A { right: -9.0px; } 

.black-key:hover {
    background: linear-gradient(to bottom, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
}

.black-key.active {
    background: linear-gradient(to bottom, #0077cc 0%, #0055aa 50%, #003388 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 8px rgba(0, 122, 204, 0.7);
    transform: translateY(1px);
}

.black-key.from-playback {
    background: linear-gradient(to bottom, #00aa77 0%, #008855 50%, #006644 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 6px rgba(0, 204, 136, 0.6);
}

.octave-label {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    color: #888;
    font-weight: 500;
    pointer-events: none;
}

.white-key.active .octave-label,
.white-key.from-playback .octave-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Karaoke Panel */
.karaoke-panel {
    background: #2d2d30;
    border-top: 1px solid #555;
    padding: 8px 12px;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.karaoke-line {
    text-align: center;
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.karaoke-previous {
    font-size: 13px;
    color: rgba(204, 204, 204, 0.7);
}

.karaoke-current {
    font-size: 15px;
    font-weight: 600;
    color: #4ec9b0;
}

/* Status Bar */
.status-bar {
    background: #252526;
    border-top: 1px solid #555;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 11px;
    color: #cccccc;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label {
    color: #9cdcfe;
}

.status-separator {
    width: 1px;
    height: 16px;
    background: #555;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.status-indicator.stopped {
    background: #d16969;
}

.status-indicator.playing {
    background: #4ec9b0;
}

.status-indicator.paused {
    background: #dcdcaa;
}

@media (max-width: 960px) {
    body {
        padding: 12px;
    }

    .content {
        padding: 12px;
    }

    .channels-grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    }

    .channel-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 720px) {
    .title-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .control-group {
        flex: 1 1 240px;
    }

    .slider-value {
        min-width: 36px;
    }

    .btn-reset {
        min-width: 48px;
        margin-left: auto;
    }

    .file-load-container {
        align-items: flex-start;
    }

    .file-load-status {
        white-space: normal;
        flex-basis: 100%;
    }

    .transport-controls {
        align-items: stretch;
    }

    .btn-transport {
        flex: 1 1 45%;
    }

    .loop-control {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .master-vu {
        flex-direction: column;
        align-items: flex-start;
    }

    .master-vu-bars {
        min-width: 0;
        width: 100%;
    }

    .time-display {
        text-align: left;
    }

    .progress-section {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    .progress-bar {
        flex: 1 1 100%;
    }

    .status-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .status-separator {
        display: none;
    }

    .virtual-keyboard-section {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .section {
        padding: 10px;
    }

    .section-title {
        margin-bottom: 8px;
    }

    .keyboard-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .keyboard-select {
        min-width: 150px;
    }

    .keys-container {
        height: 100px;
    }
}
