/* css/cutter.css - FIXED CUTTER & JOINER (MOBILE SAFE) */

/* Add this as the very first line in your file */
* {
    box-sizing: border-box;
}
html, body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */
}

/* --- Audio Editor Layout --- */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    padding: 20px;
    min-height: calc(100vh - 140px);
    max-width: 1600px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* --- Tab System --- */
.tools-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.tool-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    padding-left: 10px;
}

.tab-btn {
    background: #1e1e1e;
    color: #888;
    border: none;
    padding: 12px 15px; /* Reduced padding for better fit */
    font-size: 0.9rem; /* Slightly smaller font */
    font-weight: 600;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center; /* Center content */
    gap: 6px; /* Reduced gap */
    min-height: 44px; /* Touch target */
    white-space: nowrap; /* Keep text on one line */
    flex: 1; /* Make tabs equal width */
    text-align: center;
}

.tab-btn:hover { background: #2a2a2a; color: white; }
.tab-btn.active { background: #252525; color: var(--primary); border-top: 2px solid var(--primary); }

.tab-content { display: none; width: 100%; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
.tab-content .studio-panel { border-top-left-radius: 0; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Left Side: Studio Panel --- */
.studio-panel {
    background: #252525;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    width: 100%;
    box-sizing: border-box;
}

/* 1. Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e1e1e;
    padding: 10px 20px;
    border-radius: 10px;
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-name {
    color: #888;
    font-size: 0.9rem;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2. Waveform Area */
.waveform-area {
    background: #151515;
    border-radius: 10px;
    min-height: 250px;
    position: relative;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
}

#wave-timeline {
    height: 20px;
    background: #111;
    border-top: 1px solid #333;
    border-radius: 0 0 10px 10px;
}

.empty-state {
    text-align: center;
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
    color: #555;
    pointer-events: none;
}
.empty-state i { font-size: 3rem; margin-bottom: 10px; opacity: 0.5; }
.empty-state h3 { color: white; margin-bottom: 5px; }
.limit-text { font-size: 0.8rem; color: #444; margin-top: 10px; }

/* 3. Playback Controls */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #1e1e1e;
    border-radius: 10px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #333;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 10px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 44px; /* Touch target */
    min-height: 44px;
}
.control-btn:hover:not(:disabled) { background: var(--primary); transform: scale(1.1); }
.control-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.time-display {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: bold;
    background: #111;
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid #333;
    white-space: nowrap;
}

/* 4. Edit Panel */
.edit-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.edit-group h4 {
    color: #888;
    font-size: 0.85rem;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
.time-inputs label {
    display: block;
    font-family: monospace;
    font-size: 1rem;
    color: white;
    margin-bottom: 5px;
}
.checkbox-group label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    min-height: 20px;
    padding-top: 2px;
}
.checkbox-group input {
    margin-right: 8px;
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.edit-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

/* ========================================= */
/* NEW CONTROL TOOLBAR (Inputs & Format)    */
/* ========================================= */

.control-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e1e1e; /* Dark container background */
    padding: 10px 15px;
    border-radius: 8px;
    width: 100%;
    margin-top: 10px;
    border: 1px solid #333;
    box-sizing: border-box; /* Ensure padding doesn't break layout */
    gap: 10px; /* Space between groups on small screens */
    flex-wrap: wrap; /* Allow wrapping on mobile */
}

/* Time Inputs Group */
.time-control {
    display: flex;
    gap: 20px;
}

.time-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #252525;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #444;
}

.time-box label {
    color: #888;
    font-size: 0.85rem;
    margin: 0;
}

.time-box input {
    background: transparent;
    border: none;
    color: #2196F3; /* Bright Blue Text */
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    width: 70px;
    outline: none;
}

/* Actions Group (Right Side) */
.action-control {
    display: flex;
    gap: 10px;
    align-items: center;
}

.format-dropdown {
    background: #333;
    color: white;
    border: 1px solid #555;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    font-size: 0.9rem;
}

.save-btn {
    background: white; /* High contrast button like reference */
    color: black;
    border: none;
    padding: 8px 25px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.save-btn:hover {
    transform: scale(1.05);
    background: #f0f0f0;
}

/* --- Right Side: History Panel --- */
.history-panel {
    background: #202020;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.05);
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.history-header h3 { font-size: 1.1rem; color: white; }
.clear-btn {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
}
.clear-btn:hover { color: #ff0000; }
.history-list {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 500px;
}
.history-item {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid var(--primary);
    transition: background 0.2s;
}
.history-item:hover { background: #333; }
.h-name {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.h-meta {
    font-size: 0.8rem;
    color: #888;
    display: block;
    margin-bottom: 10px;
}
.h-actions {
    display: flex;
    gap: 10px;
}
.h-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    min-height: 32px;
    min-width: 44px;
}
.h-download { background: var(--primary); color: white; }
.no-history { color: #888; font-style: italic; text-align: center; margin-top: 20px; }
.history-note { font-size: 0.75rem; color: #666; text-align: center; margin-top: 10px; }

/* --- Audio Joiner Styles --- */
.join-upload-area {
    border: 2px dashed #444;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    background: #1e1e1e;
    transition: all 0.2s;
    margin-bottom: 20px;
    cursor: pointer;
    box-sizing: border-box;
    width: 100%;
}
.join-upload-area:hover, .join-upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(33, 150, 243, 0.05);
}
.upload-content i { font-size: 2.5rem; color: #555; margin-bottom: 10px; }
.upload-content h3 { 
    color: white; 
    margin-bottom: 5px; 
    font-size: 1.3rem; /* Slightly smaller for better fit */
    overflow-wrap: break-word; /* Fix long text overflow */
    word-break: break-word;
}
.upload-content p { 
    color: #888; 
    margin-bottom: 15px; 
    font-size: 0.9rem;
    overflow-wrap: break-word; /* Fix long text overflow */
    word-break: break-word;
    line-height: 1.4;
}

.track-list-container {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 15px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
}
.list-header {
    display: flex;
    justify-content: space-between;
    color: #888;
    font-size: 0.85rem;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
    margin-bottom: 10px;
    text-transform: uppercase;
}
.text-btn {
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 0.8rem;
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
}
.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 300px;
}
.empty-list-msg { text-align: center; color: #444; font-style: italic; padding-top: 40px; }

.track-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    background: #252525;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #333;
    box-sizing: border-box;
    width: 100%;
    gap: 10px;
}
.drag-handle {
    color: #555;
    cursor: grab;
    font-size: 1.1rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}
.track-info { overflow: hidden; min-width: 0; }
.t-name {
    display: block;
    color: white;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.t-meta { font-size: 0.75rem; color: #888; }
.remove-track-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 10px;
    font-size: 1rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.remove-track-btn:hover { color: #ff4444; }

/* Join Actions (Desktop) */
.join-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 100%;
}
.join-info {
    color: #888;
    font-size: 0.9rem;
    display: flex;
    gap: 15px;
}
.join-info span {
    background: #1a1a1a;
    padding: 5px 10px;
    border-radius: 4px;
}

/* --- WaveSurfer Handles --- */
.wavesurfer-region {
    border: 2px solid #fff !important;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
    background-color: rgba(33, 150, 243, 0.2) !important;
}
.wavesurfer-handle { background-color: var(--primary) !important; width: 4px !important; }

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content.processing-content {
    background: #252525;
    padding: 40px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}
.modal-content h3 { margin: 20px 0 10px; color: white; font-size: 1.5rem; }
.modal-content p { color: #aaa; margin-bottom: 20px; font-size: 0.9rem; }
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(33, 150, 243, 0.3);
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}
.progress-bar { height: 100%; background: #2196F3; width: 0%; transition: width 0.3s linear; }

/* ================================================================= */

/* --- Audio Extractor Styles --- */

.divider-text {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider-text span {
    background: #252525;
    padding: 0 15px;
    color: #666;
    font-weight: bold;
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

.divider-text::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #333;
    z-index: 0;
}

.url-extractor-box {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 10px;
    border: 1px solid #333;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.url-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: white;
}

.url-desc {
    color: #888;
    margin-bottom: 20px;
    font-size: 0.9rem;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
}

.url-input-wrapper {
    display: flex;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

#urlInput {
    flex-grow: 1;
    padding: 12px 15px;
    background: #111;
    border: 1px solid #444;
    border-radius: 6px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border 0.2s;
    box-sizing: border-box;
    min-height: 44px;
    width: 100%;
}

#urlInput:focus {
    border-color: var(--primary);
}

#urlLoadBtn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 20px;
}

/* Browse Videos Button Wrapper */
.browse-videos-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.browse-videos-wrapper .btn {
    min-width: 200px;
    padding: 12px 25px;
}

/* ================================================================= */
/* -------------------- MOBILE / RESPONSIVE FIXES ------------------ */
/* ================================================================= */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        gap: 15px;
        padding: 15px;
    }
    
    .history-panel {
        max-height: 250px;
        padding: 15px;
        margin-top: 20px;
    }
    
    .edit-panel {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .waveform-area {
        min-height: 200px;
    }
    
    /* Tab fixes for tablet */
    .tool-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
        padding-left: 0;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        border-radius: 8px;
        flex: 1;
        justify-content: center;
    }
    
    .tab-btn.active {
        border-top: none;
        border: 1px solid var(--primary);
    }
}

/* Mobile Large (480px - 768px) */
@media (max-width: 768px) {
    /* 1. Global Padding Fix */
    .editor-container {
        max-width: 100%;
        margin: 0;
        padding: 10px;
        min-height: calc(100vh - 100px);
    }
    
    .studio-panel {
        padding: 15px;
        width: 100%;
        gap: 15px;
    }
    
    /* 2. Tabs - Equal width grid on mobile */
    .tool-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
        padding-left: 0;
        margin: 0;
        overflow-x: visible;
    }
    
    .tab-btn {
        padding: 10px 8px;
        font-size: 0.8rem;
        border-radius: 8px;
        min-height: 40px;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.2;
        flex: 1;
    }
    
    .tab-btn.active {
        border-top: none;
        border: 1px solid var(--primary);
    }
    
    /* 3. Toolbar Fix */
    .toolbar {
        flex-direction: column !important;
        gap: 15px;
        align-items: stretch;
        padding: 10px;
    }
    
    .file-upload-wrapper {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        align-items: center;
    }
    
    .file-name {
        max-width: 100%;
        white-space: normal;
        text-align: center;
        word-break: break-word;
    }
    
    /* 4. Playback Controls */
    .controls-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 10px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        margin-right: 5px;
    }
    
    .time-display {
        font-size: 1rem;
        padding: 8px 15px;
        width: 100%;
        text-align: center;
        margin-top: 10px;
        order: 3;
        white-space: normal;
        word-break: keep-all;
    }
    
    /* 5. Waveform Area */
    .waveform-area {
        min-height: 180px;
    }
    
    /* 6. Edit Panel */
    .edit-panel {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .edit-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .btn {
        width: 95%;
        box-sizing: border-box;
        padding: 12px;
        font-size: 0.95rem;
        min-height: 44px;
    }
    
    /* 7. Checkbox Group - Better Touch */
    .checkbox-group label {
        min-height: 44px;
        padding: 12px 0;
        margin-bottom: 0;
        display: flex;
        align-items: center;
    }
    
    .checkbox-group input {
        margin-right: 12px;
    }
    
    /* 8. Upload Areas */
    .join-upload-area {
        padding: 20px 15px;
        margin-bottom: 15px;
    }
    
    .upload-content h3 {
        font-size: 1.2rem;
        word-wrap: break-word;
        line-height: 1.3;
        padding: 0 5px;
    }
    
    .upload-content p {
        padding: 0 5px;
        font-size: 0.85rem;
    }
    
    /* 9. Audio Joiner */
    .track-list-container {
        padding: 10px;
        min-height: 180px;
    }
    
    .join-actions {
        flex-direction: column !important;
        gap: 15px;
        align-items: stretch;
        margin-top: 15px;
        padding-top: 15px;
    }
    
    .join-info {
        justify-content: center;
        flex-wrap: wrap;
        font-size: 0.85rem;
        gap: 10px;
        text-align: center;
    }
    
    .track-item {
        grid-template-columns: auto 1fr auto;
        gap: 8px;
        padding: 8px;
    }
    
    /* 10. Audio Extractor */
    .url-extractor-box {
        padding: 20px 15px;
    }
    
    .url-input-wrapper {
        flex-direction: column;
        max-width: 100%;
        margin: 0;
        width: 100%;
    }
    
    #urlInput {
        font-size: 16px; /* Prevent iOS zoom */
        width: 100%;
    }
    
    #urlLoadBtn {
        width: 100%;
        margin-top: 10px;
        padding: 12px;
    }
    
    /* 11. Browse Videos Button */
    .browse-videos-wrapper .btn {
        width: 100%;
        max-width: 300px;
        min-width: auto;
    }
    
    /* 12. History Panel */
    .history-panel {
        max-height: 200px;
    }
    
    /* 13. Modal Fix */
    .modal-content.processing-content {
        padding: 30px 20px;
        max-width: 95vw;
        margin: 0 10px;
    }
    
    .modal-content h3 {
        font-size: 1.3rem;
    }
    
    /* 14. History Items */
    .h-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    /* 15. Divider Text */
    .divider-text {
        margin: 15px 0;
    }
    
    .divider-text span {
        font-size: 0.85rem;
        padding: 0 10px;
    }

    /* --- NEW TOOLBAR FIXES (Tablet) --- */
    .control-toolbar {
        justify-content: center; /* Center items if they wrap */
        gap: 15px;
    }

    .time-control {
        width: 100%; /* Force time inputs to take full width */
        justify-content: center;
        gap: 20px;
    }
    
    .action-control {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }
    
    .save-btn {
        width: 50%; /* Make button bigger on tablet */
        text-align: center;
    }
}

/* Mobile Small (up to 480px) */
@media (max-width: 480px) {
    /* 1. Smaller Controls */
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        margin-right: 3px;
    }
    
    /* 2. Time Display - Smaller font */
    .time-display {
        font-size: 0.9rem;
        padding: 6px 10px;
        white-space: normal;
        line-height: 1.4;
    }
    
    /* 3. Tab Buttons - Smaller font, equal width */
    .tab-btn {
        padding: 8px 6px;
        font-size: 0.75rem;
        min-height: 36px;
        line-height: 1.1;
    }
    
    .tab-btn i {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }
    
    /* Make tabs show icon + text stacked */
    .tab-btn {
        flex-direction: column;
        gap: 4px;
    }
    
    /* 4. Waveform Area - Even smaller */
    .waveform-area {
        min-height: 150px;
    }
    
    /* 5. History Items */
    .history-item {
        padding: 12px;
    }
    
    .h-actions {
        flex-wrap: wrap;
    }
    
    .h-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-height: 40px;
    }
    
    /* 6. Edit Groups */
    .edit-group h4 {
        font-size: 0.8rem;
    }
    
    .checkbox-group label {
        font-size: 0.85rem;
    }
    
    /* 7. Track Items */
    .track-item {
        grid-template-columns: 30px 1fr 30px;
        gap: 5px;
    }
    
    .t-name {
        font-size: 0.85rem;
    }
    
    .t-meta {
        font-size: 0.7rem;
    }
    
    /* 8. Modal Spinner */
    .spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
    
    .modal-content h3 {
        font-size: 1.3rem;
    }
    
    /* 9. Upload Content */
    .upload-content i {
        font-size: 2rem;
    }
    
    .upload-content h3 {
        font-size: 1.1rem;
    }
    
    .upload-content p {
        font-size: 0.8rem;
    }
    
    /* 10. Divider Text */
    .divider-text span {
        font-size: 0.85rem;
        padding: 0 8px;
    }
    
    /* 11. Edit Actions */
    .edit-actions .btn {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    /* 12. Browse Videos Button */
    .browse-videos-wrapper .btn {
        max-width: 100%;
        padding: 12px 20px;
    }
    
    /* 13. URL Extractor */
    .url-extractor-box {
        padding: 15px 12px;
    }
    
    .url-header h3 {
        font-size: 1.1rem;
    }
    
    .url-desc {
        font-size: 0.8rem;
    }

    /* --- NEW TOOLBAR FIXES (Phone) --- */
    .control-toolbar {
        flex-direction: column; /* Stack everything vertically */
        align-items: stretch; /* Stretch to fill screen width */
        padding: 15px;
        gap: 15px;
    }

    /* 1. Time Inputs: Make them sit side-by-side, full width */
    .time-control {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .time-box {
        flex: 1; /* Each box takes 50% width */
        justify-content: center;
        padding: 8px 5px;
    }

    .time-box input {
        width: 60px; /* Prevent text clipping */
        font-size: 0.95rem; /* Readable font size */
    }
    
    .time-box label {
        font-size: 0.8rem;
    }

    /* 2. Actions: Stack Format and Save button side-by-side */
    .action-control {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .format-dropdown {
        flex: 1; /* Grow to fill space */
        text-align: center;
        height: 44px; /* Good touch target size */
    }

    .save-btn {
        flex: 1; /* Grow to fill space */
        height: 44px; /* Good touch target size */
        padding: 0; /* Text centering fix */
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Very Small Screens (up to 360px) */
@media (max-width: 360px) {
    /* 1. Even Smaller Controls */
    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        margin-right: 2px;
    }
    
    /* 2. Tab Buttons - Icon only or very small text */
    .tab-btn span {
        font-size: 0.7rem;
    }
    
    .tab-btn i {
        font-size: 1rem;
    }
    
    .tab-btn {
        padding: 6px 4px;
        min-height: 40px;
    }
    
    .tool-tabs {
        gap: 4px;
    }
    
    /* 3. Time Display - Compact format */
    .time-display {
        font-size: 0.8rem;
        padding: 5px 8px;
    }
    
    /* 4. Button Text */
    .btn {
        font-size: 0.85rem;
        padding: 10px;
    }
    
    /* 5. Header Text */
    .history-header h3,
    .list-header {
        font-size: 0.9rem;
    }
    
    /* 6. Upload Labels */
    .upload-content h3 {
        font-size: 1rem;
    }
    
    .upload-content p {
        font-size: 0.75rem;
    }
    
    /* 7. Waveform Area */
    .waveform-area {
        min-height: 120px;
    }
    
    /* 8. History Items - Single column actions */
    .h-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .h-btn {
        width: 100%;
        text-align: center;
    }
    
    /* 9. Edit Panel - Even tighter */
    .edit-panel {
        gap: 10px;
    }
    
    .edit-group h4 {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
    
    /* 10. Icon sizes */
    .upload-content i {
        font-size: 1.8rem;
    }
    
    .empty-state i {
        font-size: 2.5rem;
    }
}

/* Extra Small Screens (up to 320px) - iPhone SE etc. */
@media (max-width: 320px) {
    .tab-btn {
        padding: 5px 3px;
        font-size: 0.65rem;
    }
    
    .tab-btn i {
        font-size: 0.9rem;
    }
    
    .upload-content h3 {
        font-size: 0.95rem;
    }
    
    .url-header h3 {
        font-size: 1rem;
    }
    
    .editor-container {
        padding: 8px;
    }
    
    .studio-panel {
        padding: 12px;
    }
}

/* Landscape Orientation */
@media (max-height: 600px) and (orientation: landscape) {
    .editor-container {
        min-height: auto;
        grid-template-columns: 2fr 1fr;
        padding: 10px;
    }
    
    .waveform-area {
        min-height: 120px;
    }
    
    .history-panel {
        max-height: 200px;
    }
    
    .track-list {
        max-height: 150px;
    }
    
    .controls-bar {
        padding: 8px 15px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    /* Tabs in landscape */
    .tool-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .tab-btn {
        padding: 6px 4px;
        font-size: 0.75rem;
    }
}

/* iPhone Notch/Safe Area Support */
@supports (padding: max(0px)) {
    .editor-container,
    .studio-panel,
    .history-panel {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    @media (max-width: 768px) {
        .editor-container {
            padding-top: max(10px, env(safe-area-inset-top));
            padding-bottom: max(10px, env(safe-area-inset-bottom));
        }
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .control-btn,
    .tab-btn,
    .btn {
        border-width: 1.5px;
    }
    
    .wavesurfer-region {
        border-width: 1.5px !important;
    }
}

/* Print Styles */
@media print {
    .editor-container {
        display: none;
    }
    
    .no-print {
        display: none;
    }
}

/* ================================================================= */

/* ========================================= */
/* UPDATED: CHOIR ANIMATION STYLES      */
/* ========================================= */

.singing-stage-left {
    position: relative;
    height: 120px; /* Slightly taller */
    display: flex;
    align-items: flex-end; /* Align singers to bottom */
    justify-content: flex-start; /* Align to LEFT side */
    margin-bottom: 30px;
    overflow: hidden;
    padding-left: 20px; /* Spacing from left edge */
}

/* --- THE CHOIR --- */
.choir-group {
    display: flex;
    gap: 15px; /* Space between kids */
    position: relative;
    z-index: 10;
}

.singer {
    font-size: 2.5rem; /* Good size for multiple icons */
    position: relative;
    /* We use different bounce speeds for variety */
}

/* Gender Differentiation via Color */
.singer.boy {
    color: #64b5f6; /* Soft Blue */
    animation: singerBounce 0.7s infinite alternate ease-in-out;
}

.singer.girl {
    color: #f06292; /* Soft Pink */
    animation: singerBounce 0.8s infinite alternate-reverse ease-in-out; /* Reverse bounce for variety */
}

@keyframes singerBounce {
    0% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(-8px) scaleY(1.05); } /* Bob up and stretch slightly */
}

/* --- THE WAVY NOTES STREAM --- */
/* --- THE WAVY NOTES STREAM --- */
.notes-stream {
    position: absolute;
    /* Move them slightly more to the right so they don't overlap the last kid too much */
    left: 160px; 
    bottom: 40px; 
    width: 200px; /* Give it specific width to ensure room for animation */
    height: 100px;
    pointer-events: none;
    z-index: 20; /* FORCE ON TOP of the kids */
}

.notes-stream i {
    position: absolute;
    font-size: 1.5rem;
    color: #FFD700; /* GOLD COLOR - Makes them super visible against dark bg */
    opacity: 0;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); /* Glowing effect */
}

/* --- THE WAVY KEYFRAME ANIMATION --- */
@keyframes floatWaveRight {
    0% {
        opacity: 0;
        transform: translate(0, 10px) scale(0.5) rotate(-10deg); /* Start slightly lower */
    }
    10% {
        opacity: 1; /* Make them appear very quickly */
    }
    40% {
        /* Wave Peak Up */
        transform: translate(60px, -40px) scale(1.1) rotate(10deg);
    }
    70% {
        /* Wave Trough Down */
        transform: translate(120px, 0px) scale(1.3) rotate(-5deg);
    }
    100% {
        opacity: 0;
        /* End far right */
        transform: translate(180px, -50px) scale(1.5) rotate(20deg);
    }
}

/* Individual Note Timing */
.stream-note-1 {
    left: 0;
    bottom: 0;
    animation: floatWaveRight 2.5s infinite linear;
}

.stream-note-2 {
    left: 10px;
    bottom: 10px;
    color: #64b5f6 !important; /* Blue note */
    font-size: 1.2rem !important;
    animation: floatWaveRight 2.5s infinite linear;
    animation-delay: 0.6s;
}

.stream-note-3 {
    left: 5px;
    bottom: 5px;
    color: #ff4081 !important; /* Pink note */
    font-size: 1.8rem !important;
    animation: floatWaveRight 2.8s infinite linear;
    animation-delay: 1.2s;
}

.stream-note-4 {
    left: 15px;
    bottom: 0;
    color: #FFD700 !important; /* Gold note */
    animation: floatWaveRight 2.4s infinite linear;
    animation-delay: 1.8s;
}