/**
 * Virtual Piano Modules CSS
 * Styles for all new modules: Recorder, Effects, Visualizer, Storage
 *
 * @version 1.0.0
 */

/* ===================================================
   COMMON STYLES
   =================================================== */

.recorder-section,
.effects-section,
.learning-mode-wrapper,
.presets-section {
    margin: 2rem 0;
    padding: 2rem;
    background: var(--pm-bg-card, #1F1F1F);
    border-radius: 12px;
    border: 1px solid var(--pm-border, rgba(245, 200, 66, 0.2));
    box-shadow: var(--pm-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.6));
}

/* ===================================================
   RECORDER STYLES
   =================================================== */

.recorder-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.recorder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--pm-border);
    padding-bottom: 1rem;
}

.recorder-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--pm-primary, #D7BF81);
}

.recorder-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.status-dot.recording {
    background: #ff4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
    animation: pulse 1.5s infinite;
}

.status-dot.paused {
    background: #ff9800;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    color: var(--pm-text-secondary, #CCCCCC);
    font-size: 0.9rem;
}

.recorder-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.rec-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--pm-bg-light, #252525);
    border: 1px solid var(--pm-border);
    border-radius: 8px;
    color: var(--pm-text-primary, #FFF);
    cursor: pointer;
    transition: all 0.3s ease;
}

.rec-btn:hover:not(:disabled) {
    background: var(--pm-bg-medium, #1A1A1A);
    border-color: var(--pm-border-hover, rgba(245, 200, 66, 0.4));
    transform: translateY(-2px);
}

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

.rec-btn svg {
    flex-shrink: 0;
}

.recorder-timer {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pm-primary);
    text-align: center;
    font-family: 'Courier New', monospace;
}

.recorder-downloads {
    padding: 1.5rem;
    background: var(--pm-bg-medium);
    border-radius: 8px;
}

.recorder-downloads h4 {
    margin: 0 0 1rem 0;
    color: var(--pm-text-primary);
}

.download-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.download-btn {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--pm-primary-dark, #D4A436), var(--pm-primary, #D7BF81));
    border: none;
    border-radius: 8px;
    color: #1a1a1a;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 157, 58, 0.4);
}

.recording-info {
    display: flex;
    justify-content: space-between;
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

/* ===================================================
   EFFECTS STYLES
   =================================================== */

.effects-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.effects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--pm-border);
    padding-bottom: 1rem;
}

.effects-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--pm-primary);
}

.toggle-effects-btn {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--pm-border);
    border-radius: 6px;
    color: var(--pm-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-effects-btn:hover {
    border-color: var(--pm-primary);
    color: var(--pm-primary);
}

.effects-panel {
    display: grid;
    gap: 1.5rem;
}

.effect-section {
    padding: 1.5rem;
    background: var(--pm-bg-medium);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.effect-header {
    margin-bottom: 1rem;
}

.effect-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--pm-text-primary);
    cursor: pointer;
}

.effect-toggle {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--pm-primary);
}

.effect-controls {
    display: grid;
    gap: 1rem;
}

.control-group {
    display: grid;
    grid-template-columns: 100px 1fr 80px;
    align-items: center;
    gap: 1rem;
}

.control-group label {
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--pm-bg-light);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--pm-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--pm-primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-value {
    color: var(--pm-primary);
    font-weight: 600;
    text-align: right;
    font-size: 0.9rem;
}

.effect-select {
    padding: 0.5rem;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 6px;
    color: var(--pm-text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.effect-select:focus {
    outline: none;
    border-color: var(--pm-primary);
}

/* Sustain Section */
.sustain-section {
    background: linear-gradient(135deg, rgba(197, 157, 58, 0.1), rgba(197, 157, 58, 0.05));
    border-color: rgba(197, 157, 58, 0.3);
}

.sustain-indicator {
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.sustain-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--pm-bg-dark);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.sustain-status.active {
    border-color: var(--pm-primary);
    box-shadow: 0 0 20px rgba(197, 157, 58, 0.4);
}

.sustain-key {
    padding: 0.5rem 1rem;
    background: var(--pm-bg-light);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--pm-primary);
    font-size: 1.1rem;
}

.sustain-text {
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

/* Effect Presets */
.effect-presets {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--pm-border);
}

.effect-presets label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--pm-text-secondary);
    font-weight: 600;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.preset-btn {
    padding: 0.75rem 1rem;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 6px;
    color: var(--pm-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover,
.preset-btn.active {
    background: var(--pm-primary);
    color: #1a1a1a;
    border-color: var(--pm-primary);
}

/* ===================================================
   VISUALIZER / LEARNING MODE STYLES
   =================================================== */

.learning-mode-section {
    margin: 2rem 0;
    padding: 2rem;
    background: var(--pm-bg-card);
    border-radius: 12px;
    border: 1px solid var(--pm-border);
}

.learning-header {
    text-align: center;
    margin-bottom: 2rem;
}

.learning-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    color: var(--pm-primary);
}

.learning-header p {
    color: var(--pm-text-secondary);
    margin: 0;
}

.learning-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--pm-bg-medium);
    border: 2px dashed var(--pm-border);
    border-radius: 8px;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-light, #FFE4A1));
    border: none;
    border-radius: 8px;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 157, 58, 0.4);
}

.file-name {
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--pm-bg-medium);
    border-radius: 8px;
    flex-wrap: wrap;
}

.control-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 8px;
    color: var(--pm-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--pm-primary);
    color: #1a1a1a;
    border-color: var(--pm-primary);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 200px;
}

.speed-control label {
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
}

.speed-control input[type="range"] {
    flex: 1;
}

.speed-control span {
    color: var(--pm-primary);
    font-weight: 600;
    min-width: 50px;
}

.loop-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--pm-text-secondary);
    cursor: pointer;
    user-select: none;
}

.loop-toggle input {
    cursor: pointer;
    accent-color: var(--pm-primary);
}

.progress-bar-container {
    padding: 1rem;
    background: var(--pm-bg-medium);
    border-radius: 8px;
}

.progress-bar {
    height: 8px;
    background: var(--pm-bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pm-primary), var(--pm-primary-light));
    width: 0%;
    transition: width 0.1s linear;
}

.time-display {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    color: var(--pm-text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
}

.visualizer-container {
    margin-top: 1.5rem;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#visualizerCanvas {
    display: block;
    width: 100%;
    height: 400px;
}

/* Highlight keys during learning mode */
.piano-key.learning-active {
    background: var(--pm-primary) !important;
    box-shadow: 0 0 20px rgba(197, 157, 58, 0.8) !important;
    transform: translateY(2px);
}

/* ===================================================
   STORAGE / PRESETS STYLES
   =================================================== */

.presets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.presets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--pm-border);
    padding-bottom: 1rem;
}

.presets-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--pm-primary);
}

.user-badge,
.guest-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--pm-bg-medium);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--pm-text-secondary);
}

.user-badge {
    color: var(--pm-primary);
    border: 1px solid var(--pm-primary);
}

.preset-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.save-preset-btn,
.sync-btn,
.login-prompt-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-preset-btn {
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-light));
    color: #1a1a1a;
}

.save-preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(197, 157, 58, 0.4);
}

.sync-btn,
.login-prompt-btn {
    background: var(--pm-bg-light);
    color: var(--pm-text-primary);
    border: 1px solid var(--pm-border);
}

.sync-btn:hover,
.login-prompt-btn:hover {
    border-color: var(--pm-primary);
    color: var(--pm-primary);
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.no-presets {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pm-text-secondary);
}

.no-presets p {
    margin: 0.5rem 0;
}

.no-presets .hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background: var(--pm-bg-medium);
    border: 1px solid var(--pm-border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.preset-item:hover {
    border-color: var(--pm-border-hover);
    transform: translateX(4px);
}

.preset-info {
    flex: 1;
}

.preset-name {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--pm-text-primary);
}

.preset-description {
    margin: 0 0 0.5rem 0;
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

.preset-date {
    font-size: 0.85rem;
    color: var(--pm-text-muted);
}

.preset-actions {
    display: flex;
    gap: 0.75rem;
}

.preset-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 6px;
    color: var(--pm-text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-action-btn.load-btn:hover {
    background: var(--pm-primary);
    color: #1a1a1a;
    border-color: var(--pm-primary);
}

.preset-action-btn.delete-btn:hover {
    background: #f44336;
    color: #fff;
    border-color: #f44336;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--pm-bg-card);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--pm-border);
}

.modal-header h3 {
    margin: 0;
    color: var(--pm-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--pm-text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--pm-bg-light);
    color: var(--pm-text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--pm-text-secondary);
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 6px;
    color: var(--pm-text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--pm-primary);
}

.preset-preview {
    padding: 1rem;
    background: var(--pm-bg-medium);
    border-radius: 6px;
    margin-top: 1rem;
}

.preset-preview h4 {
    margin: 0 0 0.75rem 0;
    color: var(--pm-text-primary);
    font-size: 0.95rem;
}

.preset-preview ul {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--pm-text-secondary);
    font-size: 0.9rem;
}

.preset-preview li {
    margin: 0.5rem 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--pm-border);
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-light));
    color: #1a1a1a;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(197, 157, 58, 0.4);
}

.btn-secondary {
    background: var(--pm-bg-light);
    color: var(--pm-text-primary);
    border: 1px solid var(--pm-border);
}

.btn-secondary:hover {
    border-color: var(--pm-primary);
}

/* ===================================================
   SOLO/MUTE CONTROLS (Drum Machine)
   =================================================== */

.track-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.track-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pm-bg-light);
    border: 1px solid var(--pm-border);
    border-radius: 4px;
    color: var(--pm-text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.track-btn.solo-btn.active {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
}

.track-btn.mute-btn.active {
    background: #f44336;
    color: #fff;
    border-color: #f44336;
}

.track-btn:hover:not(.active) {
    border-color: var(--pm-primary);
    color: var(--pm-primary);
}

/* ===================================================
   RESPONSIVE DESIGN
   =================================================== */

@media (max-width: 768px) {
    .recorder-section,
    .effects-section,
    .learning-mode-wrapper,
    .presets-section {
        padding: 1.5rem 1rem;
    }

    .recorder-controls,
    .download-buttons,
    .playback-controls,
    .preset-actions {
        flex-direction: column;
    }

    .rec-btn,
    .download-btn {
        width: 100%;
    }

    .control-group {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .control-group label {
        font-weight: 600;
    }

    .control-value {
        text-align: left;
    }

    .preset-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .preset-item .preset-actions {
        width: 100%;
        flex-direction: row;
    }

    .modal-content {
        margin: 1rem;
    }

    .preset-buttons {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .effects-header h3,
    .recorder-header h3,
    .presets-header h3 {
        font-size: 1.25rem;
    }

    .learning-header h2 {
        font-size: 1.5rem;
    }

    .recorder-timer {
        font-size: 1.5rem;
    }

    .speed-control {
        width: 100%;
    }

    .preset-buttons {
        grid-template-columns: 1fr;
    }
}

/* Mobile portrait - compact module sections */
@media (max-width: 768px) and (orientation: portrait) {
    .recorder-section,
    .effects-section,
    .learning-mode-wrapper,
    .presets-section {
        padding: 1rem 0.75rem;
    }

    .effect-section {
        padding: 0.75rem;
    }

    .effect-controls {
        gap: 0.5rem;
    }

    .control-group {
        gap: 0.25rem;
    }
}

/* ===================================================
   MOBILE LANDSCAPE COMPACT STYLES
   =================================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .recorder-section,
    .effects-section,
    .learning-mode-wrapper,
    .presets-section {
        margin: 0.75rem 0;
        padding: 0.75rem;
    }

    .recorder-header,
    .effects-header,
    .presets-header {
        padding-bottom: 0.5rem;
    }

    .recorder-header h3,
    .effects-header h3,
    .presets-header h3 {
        font-size: 1rem;
    }

    .recorder-controls {
        gap: 0.5rem;
    }

    .rec-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
        gap: 0.3rem;
    }

    .rec-btn svg {
        width: 14px;
        height: 14px;
    }

    .recorder-timer {
        font-size: 1.25rem;
    }

    .download-buttons {
        gap: 0.5rem;
    }

    .download-btn {
        min-width: 100px;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Effects panel compact */
    .effects-panel {
        gap: 0.75rem;
    }

    .effect-section {
        padding: 0.75rem;
    }

    .effect-title {
        font-size: 0.9rem;
        gap: 0.5rem;
    }

    .effect-toggle {
        width: 16px;
        height: 16px;
    }

    .control-group {
        grid-template-columns: 70px 1fr 55px;
        gap: 0.5rem;
    }

    .control-group label {
        font-size: 0.75rem;
    }

    .control-value {
        font-size: 0.75rem;
    }

    /* Modal compact - FIXED for mobile landscape */
    .modal {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: 10px;
    }

    .modal-content {
        max-width: 95%;
        max-height: 85vh;
        margin: 0 auto;
    }

    .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    .modal-close {
        width: 26px;
        height: 26px;
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 0.75rem 1rem;
    }

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

    .form-group label {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
    }

    .form-group input,
    .form-group textarea {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    /* Presets compact */
    .preset-item {
        padding: 0.75rem;
    }

    .preset-name {
        font-size: 0.9rem;
    }

    .preset-description {
        font-size: 0.75rem;
    }

    .preset-action-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.75rem;
    }

    /* Track controls compact */
    .track-btn {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }
}

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

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

/* ===================================================
   MOBILE DAW LAYER
   Touch-first overrides — every control hits the 44px iOS target,
   side-by-side panels stack, the transport floats above the keyboard,
   and modals go full-screen on portrait phones. Layered LAST so it
   wins over earlier media queries without !important on every rule.
   =================================================== */

/* Touch devices: enforce 44×44 minimum on every clickable control,
   regardless of viewport width. Hover-capable mice get the compact UI. */
@media (hover: none) and (pointer: coarse) {
    .track-btn,
    .preset-action-btn,
    .modal-close,
    .rec-btn,
    .daw-transport-btn,
    .hero-btn-v2,
    .effect-toggle + span,
    .preset-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .track-btn {
        width: 40px;
        height: 40px;
        font-size: 0.85rem;
    }

    .effect-toggle {
        width: 22px;
        height: 22px;
        cursor: pointer;
    }
    /* Bigger hit zone around the checkbox label */
    .effect-title {
        padding: 0.5rem 0;
        min-height: 44px;
    }

    /* Range sliders need a bigger thumb for fingers */
    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

/* Portrait phones — the case the original CSS underserved.
   Stacks every panel vertically, keeps modals readable at <360px wide. */
@media (max-width: 540px) and (orientation: portrait) {
    .recorder-section,
    .effects-section,
    .learning-mode-wrapper,
    .presets-section {
        margin: 0.75rem 0;
        padding: 0.875rem 0.625rem;
        border-radius: 10px;
    }

    .recorder-header,
    .effects-header,
    .presets-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .recorder-header h3,
    .effects-header h3,
    .presets-header h3 {
        font-size: 1.05rem;
        flex: 1 1 auto;
    }

    .recorder-controls,
    .download-buttons,
    .preset-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .recorder-controls .rec-btn,
    .download-buttons .download-btn {
        width: 100%;
        justify-content: center;
    }

    /* Side-by-side track strips become full-width rows */
    .drum-track,
    .timeline-track,
    .audio-strip {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }
    .track-controls {
        width: 100%;
        justify-content: flex-end;
    }

    /* Modal goes nearly full-screen */
    .modal {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: 12px;
    }
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 24px);
        margin: 0;
        border-radius: 12px;
    }
    .modal-header h3 {
        font-size: 1.05rem;
    }
    .modal-body {
        padding: 0.875rem;
        overflow-y: auto;
    }

    /* Effects: single-column control layout — labels above sliders */
    .control-group {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
    .control-group label {
        font-size: 0.85rem;
        font-weight: 600;
    }

    /* Sequencer / drum machine: scrollable horizontally with snap so the
       grid never breaks the page layout */
    .sequencer-container,
    .drum-timeline-ruler-container {
        overflow-x: auto;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .sequencer-container > * {
        scroll-snap-align: start;
    }
}

/* Floating transport bar on touch devices < 768px wide.
   Keeps Play / Stop / Record permanently within thumb reach so the user
   never loses the controls when the keyboard or sequencer scrolls. */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .daw-transport-section.daw-transport-floating,
    .floating-transport {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9500;
        padding: 0.5rem 0.75rem env(safe-area-inset-bottom, 0.5rem);
        background: rgba(15, 15, 18, 0.92);
        border-top: 1px solid var(--pm-border, rgba(245, 200, 66, 0.25));
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        gap: 0.5rem;
        justify-content: center;
    }
    body.has-floating-transport {
        padding-bottom: 76px;
    }
}

/* Reduce motion — respect user setting */
@media (prefers-reduced-motion: reduce) {
    .status-dot.recording,
    .recorder-section,
    .effects-section {
        animation: none !important;
        transition: none !important;
    }
}

/* =====================================================================
   STUDIO MASTER / TRACK FOCUS GREYING
   When the user plays the master, the source tracks dim so the master
   waveform / output is visually emphasised — but the live knobs (PAN /
   REV / DLY) stay at full opacity so the user can keep tweaking without
   losing the visual feedback of the animated indicators.
   ===================================================================== */
.audio-track.master-dimmed {
    opacity: 0.32;
    filter: saturate(0.55);
    pointer-events: none;
    transition: opacity 0.35s ease, filter 0.35s ease;
}
/* Knobs / potentiometers stay alive even when the strip is dimmed */
.audio-track.master-dimmed .knob-mini-visual,
.audio-track.master-dimmed .knob-mini-indicator,
.audio-track.master-dimmed .knob-mini-label,
.audio-track.master-dimmed [class*="knob"],
.audio-track.master-dimmed [class*="potentiometer"],
.audio-track.master-dimmed .knob-mini-visual * {
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
}
.audio-track.master-track.master-dimmed {
    /* Same dim treatment when the user plays a single track and the master
       fades — knobs still alive */
    opacity: 0.32;
    filter: saturate(0.55);
    pointer-events: none;
}
.audio-track.master-track.master-dimmed .knob-mini-visual,
.audio-track.master-track.master-dimmed [class*="knob"],
.audio-track.master-track.master-dimmed [class*="potentiometer"] {
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
}

/* The active focused track gets a subtle glow so the user knows what's
   currently driving the speakers */
.audio-track.focus-playing {
    box-shadow: 0 0 0 1px rgba(215, 191, 129, 0.45),
                0 8px 28px rgba(215, 191, 129, 0.12);
    transition: box-shadow 0.35s ease;
}
.audio-track.master-track.focus-playing {
    box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.55),
                0 10px 32px rgba(76, 175, 80, 0.18);
}

/* =====================================================================
   MOBILE PORTRAIT — Audio Tracks header buttons + sequencer overflow
   The audit found the 3 tracks-actions buttons (Add / Upload / Export)
   bleeding off-screen because the parent flex row had no wrap. Same
   treatment for the sequencer scroll container + transport bar.
   ===================================================================== */
@media (max-width: 540px) {
    .tracks-actions,
    .daw-track-actions {
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 6px !important;
        justify-content: stretch;
    }
    .tracks-actions .track-action-btn,
    .tracks-actions .add-track-btn,
    .daw-track-actions .track-action-btn,
    .daw-track-actions .add-track-btn {
        flex: 1 1 calc(33.33% - 6px);
        min-width: 0;
        padding: 0.6rem 0.4rem;
        font-size: 0.78rem;
        text-align: center;
        justify-content: center;
        white-space: nowrap;
    }
    .tracks-header,
    .daw-tracks-section .tracks-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .tracks-title { width: 100%; }

    /* Transport bar: tighter spacing + scroll horizontally if too wide */
    .daw-transport-section,
    .transport-buttons-group {
        flex-wrap: wrap;
        gap: 6px !important;
        justify-content: center;
    }
    .transport-btn-pro {
        min-width: 44px;
        height: 44px;
        padding: 0;
    }
    .transport-btn-play-tracks,
    .transport-btn-play-master {
        min-width: 64px !important;
    }
}

/* Mobile portrait extreme — phones < 380px (some Android compact) */
@media (max-width: 380px) {
    .tracks-actions .track-action-btn,
    .daw-track-actions .track-action-btn {
        flex: 1 1 calc(50% - 6px);
    }
    .transport-btn-pro .btn-label {
        font-size: 8px;
    }
}

/* =====================================================================
   MODERN STUDIO BUTTONS — applied site-wide
   Subtle gloss + bigger radius + smooth scale on press. Designed to feel
   premium without overpowering the existing gold/dark theme.
   ===================================================================== */
.transport-btn-pro,
.toolbar-toggle-btn,
.track-action-btn,
.add-track-btn,
.rec-btn,
.daw-transport-btn,
.hero-btn-v2 {
    border-radius: 10px;
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    transition: transform 0.18s cubic-bezier(0.2, 0, 0.2, 1),
                box-shadow 0.25s ease,
                background 0.25s ease,
                border-color 0.25s ease;
    will-change: transform;
}
.transport-btn-pro:hover,
.toolbar-toggle-btn:hover,
.track-action-btn:hover,
.add-track-btn:hover,
.rec-btn:hover,
.hero-btn-v2:hover {
    transform: translateY(-1px) scale(1.025);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(215, 191, 129, 0.4) inset;
}
.transport-btn-pro:active,
.toolbar-toggle-btn:active,
.track-action-btn:active,
.add-track-btn:active,
.rec-btn:active,
.hero-btn-v2:active {
    transform: translateY(0) scale(0.97);
    transition-duration: 0.08s;
}

/* Ripple-like gloss on the new modern buttons */
.transport-btn-pro,
.toolbar-toggle-btn,
.track-action-btn,
.hero-btn-v2 {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.transport-btn-pro::after,
.toolbar-toggle-btn::after,
.track-action-btn::after,
.hero-btn-v2::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
                rgba(255, 255, 255, 0.08) 0%,
                rgba(255, 255, 255, 0) 45%,
                rgba(0, 0, 0, 0.18) 100%);
    pointer-events: none;
    z-index: -1;
    border-radius: inherit;
}

/* Recording / playing state animations */
.transport-btn-record-pro.is-recording {
    animation: pulseRec 1.4s ease-in-out infinite;
}
@keyframes pulseRec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.65); }
    50%      { box-shadow: 0 0 0 10px rgba(244, 67, 54, 0); }
}

/* =====================================================================
   COUNT-IN BUTTON
   Pulses when armed (waiting for next record start), shows beat dots
   while counting in.
   ===================================================================== */
.count-in-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.count-in-btn[data-armed="true"] {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.55),
                0 6px 18px rgba(76, 175, 80, 0.2);
}
.count-in-btn .count-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(215, 191, 129, 0.4);
    transition: transform 0.12s ease, background 0.12s ease;
}
.count-in-btn .count-dot.lit {
    background: #f5c842;
    transform: scale(1.6);
    box-shadow: 0 0 8px rgba(245, 200, 66, 0.85);
}

/* =====================================================================
   HERO ↔ GUIDE FUSION
   The first component (#appGuideComponent) sits flush against the bottom
   of the hero so the page reads as a single unit. Negative margin
   creates visual continuity, the section keeps its own padding.
   ===================================================================== */
.studio-hero-v2 {
    margin-bottom: 0 !important;
    padding-bottom: 32px !important;
}
.piano-main {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
.studio-layout-wrapper > .component-container-v2:first-of-type,
.studio-modules-container > .component-container-v2:first-of-type {
    margin-top: -28px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 2;
}

/* =====================================================================
   MICROPHONE TUNER / AUTOTUNE — modern card styling
   ===================================================================== */
.mic-feature-card {
    background: linear-gradient(140deg, rgba(35, 35, 40, 0.92), rgba(20, 20, 25, 0.95));
    border: 1px solid rgba(215, 191, 129, 0.18);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04),
                0 12px 32px rgba(0, 0, 0, 0.5);
}
.mic-tuner-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 0;
}
.mic-tuner-note {
    font-size: 3rem;
    font-weight: 800;
    color: #f5c842;
    text-shadow: 0 0 14px rgba(245, 200, 66, 0.3);
    line-height: 1;
}
.mic-tuner-cents {
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    color: rgba(215, 191, 129, 0.7);
}
.mic-tuner-needle-track {
    position: relative;
    width: min(280px, 100%);
    height: 8px;
    background: linear-gradient(to right,
                rgba(244, 67, 54, 0.4),
                rgba(255, 193, 7, 0.3),
                rgba(76, 175, 80, 0.6),
                rgba(255, 193, 7, 0.3),
                rgba(244, 67, 54, 0.4));
    border-radius: 4px;
    overflow: hidden;
}
.mic-tuner-needle-track .mic-tuner-needle-mark {
    position: absolute;
    top: -4px;
    left: 50%;
    width: 4px;
    height: 16px;
    background: #fff;
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
    transition: left 0.08s linear;
}
.autotune-active-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.25rem 0.75rem;
    background: rgba(76, 175, 80, 0.18);
    color: #4caf50;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 99px;
    border: 1px solid rgba(76, 175, 80, 0.4);
}
.autotune-active-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulseRec 1.6s ease-in-out infinite;
}

/* =====================================================================
   MICROPHONE STUDIO COMPONENT
   Full layout for #microphoneStudioComponent: connect row, vocal recorder,
   feature tabs (Tuner / Autotune / Training), recordings list. Designed
   to match the existing .component-container-v2 visual language.
   ===================================================================== */
#microphoneStudioComponent .component-body-v2 {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
}

.mic-studio-connect-row,
.mic-studio-record-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.mic-studio-status-box {
    flex: 1 1 220px;
    min-width: 200px;
    padding: 0.65rem 0.9rem;
    background: rgba(15, 15, 18, 0.55);
    border: 1px solid rgba(215, 191, 129, 0.18);
    border-radius: 10px;
}
.mic-studio-status-text {
    font-size: 0.85rem;
    color: rgba(215, 191, 129, 0.85);
    margin-bottom: 0.5rem;
}
.mic-studio-level-meter {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}
.mic-studio-level-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4caf50 0%, #f5c842 70%, #ff5252 100%);
    border-radius: 3px;
    transition: width 0.06s linear;
}

/* Buttons */
.mic-studio-btn,
.mic-feature-btn,
.mic-feature-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(140deg, rgba(40, 40, 45, 0.95), rgba(22, 22, 26, 0.95));
    border: 1px solid rgba(215, 191, 129, 0.28);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.2, 0, 0.2, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease,
                background 0.25s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.mic-studio-btn-primary {
    background: linear-gradient(140deg, rgba(215, 191, 129, 0.22), rgba(160, 130, 60, 0.18));
    border-color: rgba(215, 191, 129, 0.55);
    color: #f5e3b4;
}
.mic-studio-btn-primary.connected {
    background: linear-gradient(140deg, rgba(76, 175, 80, 0.22), rgba(36, 80, 38, 0.22));
    border-color: rgba(76, 175, 80, 0.55);
    color: #b6f0b8;
}
.mic-studio-btn-record {
    color: #ffb3b3;
    border-color: rgba(255, 90, 90, 0.45);
}
.mic-studio-btn-record.recording {
    background: linear-gradient(140deg, rgba(244, 67, 54, 0.32), rgba(120, 30, 30, 0.32));
    color: #fff;
    animation: pulseRec 1.4s ease-in-out infinite;
}
.mic-studio-btn-record .rec-dot-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff5252;
}
.mic-studio-btn-stop .stop-square-icon {
    width: 10px;
    height: 10px;
    background: rgba(215, 191, 129, 0.8);
    border-radius: 2px;
}
.mic-studio-btn[disabled],
.mic-feature-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}
.mic-studio-btn:hover:not([disabled]),
.mic-feature-btn:hover:not([disabled]),
.mic-feature-btn-secondary:hover:not([disabled]) {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(215, 191, 129, 0.5) inset;
    border-color: rgba(215, 191, 129, 0.7);
}
.mic-studio-btn:active:not([disabled]),
.mic-feature-btn:active:not([disabled]) {
    transform: translateY(0) scale(0.97);
    transition-duration: 0.08s;
}
.mic-feature-btn.active {
    background: linear-gradient(140deg, rgba(215, 191, 129, 0.32), rgba(140, 100, 40, 0.32));
    border-color: rgba(215, 191, 129, 0.7);
    color: #fff5d4;
    box-shadow: 0 0 16px rgba(215, 191, 129, 0.25);
}
.mic-feature-btn-secondary {
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(215, 191, 129, 0.85);
}

/* Recording info badge */
.mic-studio-recording-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.4rem 0.85rem;
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.4);
    border-radius: 99px;
    color: #ff8a8a;
    font-weight: 600;
}
.mic-studio-recording-info .rec-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff5252;
    animation: pulseRec 1.4s ease-in-out infinite;
}
.mic-studio-recording-info .rec-timer {
    font-variant-numeric: tabular-nums;
    color: #fff;
}

/* Feature tabs */
.mic-feature-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: rgba(15, 15, 18, 0.55);
    border: 1px solid rgba(215, 191, 129, 0.14);
    border-radius: 12px;
}
.mic-feature-tab {
    flex: 1;
    padding: 0.6rem 0.9rem;
    background: transparent;
    border: none;
    color: rgba(215, 191, 129, 0.7);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.mic-feature-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}
.mic-feature-tab.active {
    background: linear-gradient(140deg, rgba(215, 191, 129, 0.28), rgba(120, 90, 40, 0.28));
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Feature panels */
.mic-feature-panel {
    background: linear-gradient(140deg, rgba(35, 35, 40, 0.65), rgba(22, 22, 26, 0.65));
    border: 1px solid rgba(215, 191, 129, 0.14);
    border-radius: 14px;
    padding: 1.25rem;
}
.mic-feature-panel.hidden {
    display: none;
}
.mic-feature-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-bottom: 1rem;
}
.mic-feature-hint {
    font-size: 0.85rem;
    color: rgba(215, 191, 129, 0.65);
    flex: 1 1 220px;
}

/* Tuner display */
.tuner-display.hidden,
.autotune-display.hidden,
.training-display.hidden {
    display: none;
}
.tuner-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}
.tuner-note-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.tuner-note {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    color: #f5c842;
    text-shadow: 0 0 18px rgba(245, 200, 66, 0.3);
    font-variant-numeric: tabular-nums;
}
.tuner-cents {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: rgba(215, 191, 129, 0.7);
}
.tuner-freq {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
}
.tuner-needle-block {
    width: 100%;
    max-width: 360px;
}
.tuner-needle-track {
    position: relative;
    width: 100%;
    height: 36px;
    background: linear-gradient(to right,
        rgba(244, 67, 54, 0.4),
        rgba(255, 193, 7, 0.3),
        rgba(76, 175, 80, 0.6),
        rgba(255, 193, 7, 0.3),
        rgba(244, 67, 54, 0.4));
    border-radius: 8px;
    overflow: visible;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.tuner-mark {
    position: absolute;
    top: 100%;
    transform: translate(-50%, 4px);
    font-size: 0.65rem;
    color: rgba(215, 191, 129, 0.6);
    pointer-events: none;
}
.tuner-mark-50  { left: 0%; transform: translate(0%, 4px); }
.tuner-mark-25  { left: 25%; }
.tuner-mark-0   { left: 50%; color: #f5c842; font-weight: 700; }
.tuner-mark-p25 { left: 75%; }
.tuner-mark-p50 { left: 100%; transform: translate(-100%, 4px); }
.tuner-needle {
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: 50%;
    width: 4px;
    background: rgba(245, 200, 66, 0.85);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(245, 200, 66, 0.6);
    transform-origin: 50% 50%;
    transition: transform 0.08s ease, background 0.12s ease;
}
.tuner-history-canvas {
    width: 100%;
    max-width: 480px;
    height: 60px;
    border-radius: 8px;
    background: rgba(15, 15, 18, 0.55);
}

/* Autotune config */
.autotune-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.autotune-config-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.config-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(215, 191, 129, 0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mic-feature-select {
    padding: 0.5rem 0.7rem;
    background: rgba(20, 20, 24, 0.85);
    color: #fff;
    border: 1px solid rgba(215, 191, 129, 0.25);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}
.mic-feature-select:focus {
    outline: none;
    border-color: rgba(215, 191, 129, 0.6);
}
.autotune-config-slider input[type="range"] {
    width: 100%;
}
.autotune-display {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(76, 175, 80, 0.12);
    border-radius: 10px;
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #b6f0b8;
    font-size: 0.85rem;
}
.autotune-status {
    font-weight: 600;
}

/* Training display */
.training-display {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-top: 0.5rem;
}
.training-target-block {
    flex: 1 1 200px;
    text-align: center;
    padding: 1rem;
    background: rgba(15, 15, 18, 0.55);
    border-radius: 12px;
    border: 1px solid rgba(215, 191, 129, 0.14);
}
.training-target-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(215, 191, 129, 0.6);
}
.training-target-note {
    font-size: 3rem;
    font-weight: 800;
    color: #f5c842;
    margin: 0.4rem 0;
    line-height: 1;
}
.training-feedback {
    font-size: 0.9rem;
    color: rgba(215, 191, 129, 0.8);
    min-height: 1.5em;
}
.training-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.training-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.65rem 1rem;
    background: rgba(15, 15, 18, 0.55);
    border-radius: 10px;
    border: 1px solid rgba(215, 191, 129, 0.14);
}
.training-stat .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(215, 191, 129, 0.55);
}
.training-stat .stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* Recordings list */
.mic-recordings-section {
    margin-top: 0.5rem;
}
.mic-recordings-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f5c842;
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.mic-recordings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
/* Two-row layout for the recording item — top row holds the metadata
   and action buttons, bottom row holds the player. This guarantees the
   play button is never overlapped by a long recording name or progress
   bar dots, which was the bug the user reported. */
.mic-recording-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    grid-template-areas:
        "name  duration edit   send"
        "player player   player player";
    align-items: center;
    gap: 0.5rem 0.6rem;
    padding: 0.7rem 0.85rem;
    background: rgba(15, 15, 18, 0.55);
    border: 1px solid rgba(215, 191, 129, 0.14);
    border-radius: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}
.mic-recording-item .rec-name {
    grid-area: name;
    font-weight: 600;
    color: #f5c842;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.mic-recording-item .rec-duration {
    grid-area: duration;
    font-size: 0.8rem;
    color: rgba(215, 191, 129, 0.6);
    white-space: nowrap;
}
.mic-recording-item .edit-vocal-btn { grid-area: edit; }
.mic-recording-item .send-to-mix-btn { grid-area: send; }
.mic-recording-item .vocal-player-container { grid-area: player; }
.mic-recording-item .edit-vocal-btn,
.mic-recording-item .send-to-mix-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(215, 191, 129, 0.25);
    border-radius: 7px;
    color: rgba(215, 191, 129, 0.9);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}
.mic-recording-item .edit-vocal-btn:hover,
.mic-recording-item .send-to-mix-btn:hover {
    background: rgba(215, 191, 129, 0.15);
    border-color: rgba(215, 191, 129, 0.55);
}
.mic-recording-item .vocal-player-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(215, 191, 129, 0.08);
}
.mic-recording-item .vocal-play-pause-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(215, 191, 129, 0.4);
    background: rgba(215, 191, 129, 0.12);
    color: #f5c842;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mic-recording-item .vocal-play-pause-btn.playing {
    background: rgba(76, 175, 80, 0.22);
    color: #b6f0b8;
    border-color: rgba(76, 175, 80, 0.55);
}
.mic-recording-item .vocal-progress-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mic-recording-item .vocal-progress-bar {
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
}
.mic-recording-item .vocal-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f5c842, rgba(215, 191, 129, 0.7));
    border-radius: 3px;
}
.mic-recording-item .vocal-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    color: rgba(215, 191, 129, 0.6);
}

/* Mobile portrait — every row stacks vertically and goes full-width */
/* Tablet + phone: stack the mic rows and let the status box shrink so nothing
   overflows horizontally (the status box's 200px min-width could push the layout
   wider than a narrow screen). */
@media (max-width: 768px) {
    .mic-studio-connect-row,
    .mic-studio-record-row,
    .mic-feature-row {
        flex-direction: column;
        align-items: stretch;
    }
    .mic-studio-status-box {
        flex: 1 1 auto;
        min-width: 0;
    }
    .mic-studio-btn,
    .mic-feature-btn,
    .mic-feature-btn-secondary {
        width: 100%;
        justify-content: center;
    }
    .mic-feature-tabs { flex-wrap: wrap; }
}

@media (max-width: 540px) {
    #microphoneStudioComponent .component-body-v2 {
        padding: 0.75rem;
        gap: 0.6rem;
    }
    .mic-studio-btn,
    .mic-feature-btn,
    .mic-feature-btn-secondary {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    .mic-feature-tab {
        flex: 1 1 33%;
        padding: 0.45rem 0.4rem;
        font-size: 0.8rem;
    }
    /* The pitch read-outs are the biggest elements; keep them legible but not huge. */
    .tuner-note { font-size: 2.25rem; }
    .training-target-note { font-size: 2rem; }
    .training-stats { width: 100%; justify-content: space-around; }
    .mic-recording-item { flex-wrap: wrap; }
}
}
/* ===== LIGHT THEME — microphone studio surfaces =====
   The mic panels/status/tabs/buttons hard-code grey backgrounds; re-skin them to
   the warm beige + gold system with dark text in light mode (no grey). */
html[data-theme="light"] #microphoneStudioComponent .mic-studio-status-box {
    background: #F6F0E2;
    border-color: rgba(120, 100, 40, 0.25);
    color: var(--pm-text-primary);
}
html[data-theme="light"] #microphoneStudioComponent .mic-studio-status-text {
    color: var(--pm-text-secondary);
}
html[data-theme="light"] #microphoneStudioComponent .mic-feature-panel {
    background: #F3ECDD;
    border-color: rgba(120, 100, 40, 0.22);
    color: var(--pm-text-primary);
}
html[data-theme="light"] #microphoneStudioComponent .mic-feature-tabs {
    background: #ECE3D0;
    border-color: rgba(120, 100, 40, 0.22);
}
html[data-theme="light"] #microphoneStudioComponent .mic-feature-tab {
    color: var(--pm-text-secondary);
}
html[data-theme="light"] #microphoneStudioComponent .mic-feature-tab.active {
    background: var(--gradient-primary);
    color: #1a1a1a;
}
html[data-theme="light"] #microphoneStudioComponent .mic-studio-btn,
html[data-theme="light"] #microphoneStudioComponent .mic-feature-btn,
html[data-theme="light"] #microphoneStudioComponent .mic-feature-btn-secondary {
    background: #FBF7EC;
    border-color: rgba(120, 100, 40, 0.30);
    color: var(--pm-text-primary);
}
html[data-theme="light"] #microphoneStudioComponent .mic-studio-btn-primary {
    background: var(--gradient-primary);
    color: #1a1a1a;
}
