/**
 * Version Notes:
 * File: /assets/css/editor.css
 * Version: 1.4.0
 * Last Modified: 2026-03-23 03:00 PM
 * Changes:
 * - v1.4.0: Added Audio Library Browser styles (track rows, play button, selected state, scrollbar)
 * - v1.2.0: Added CRF slider, estimate box styles
 * - v1.0.0: Initial creation: full dark theme UI for PokéPapi Video Editor
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ======================== RESET & BASE ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-hover: #1e1e3a;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8a;
    --accent-primary: #8b5cf6;
    --accent-secondary: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
    --accent-glow: 0 0 20px rgba(139, 92, 246, 0.3);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --border: rgba(139, 92, 246, 0.15);
    --border-hover: rgba(139, 92, 246, 0.35);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ======================== LAYOUT ======================== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ======================== HEADER ======================== */
.app-header {
    text-align: center;
    padding: 40px 0 32px;
    position: relative;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.app-logo {
    font-size: 2.5rem;
    font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
}

/* ======================== MAIN GRID ======================== */
.editor-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-top: 32px;
    overflow-y: auto;
}

.editor-main {
    min-width: 0;
    overflow-y: auto;
}

/* Mobile styles moved to bottom of file */

/* ======================== CARDS ======================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    font-size: 1.3rem;
}

/* ======================== DROP ZONE ======================== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-zone.drag-over {
    border-color: var(--accent-primary);
    transform: scale(1.01);
}

.drop-zone.drag-over::before {
    opacity: 0.05;
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.drop-zone-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ======================== MEDIA LIST (Sortable) ======================== */
.media-list {
    max-height: 350px;
    overflow-y: auto;
    min-height: 80px;
    margin-top: 16px;
    overflow-y: auto;
}

.media-list:empty::after {
    content: 'Drop files above to add to timeline →';
    display: block;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 24px;
}

.media-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: var(--transition);
    user-select: none;
    position: relative;
    overflow-y: auto;
    max-width: 100%;
}

.media-item:active { cursor: grabbing; }

.media-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.media-item.dragging {
    opacity: 0.5;
    box-shadow: var(--accent-glow);
}

.media-item.drag-placeholder {
    border: 2px dashed var(--accent-primary);
    background: rgba(139, 92, 246, 0.05);
}

.media-drag-handle {
    color: var(--text-muted);
    font-size: 1.6rem;          /* v1.56.14: bigger glyph */
    cursor: grab;
    flex-shrink: 0;
    padding: 8px 10px;          /* 44x44 tap target on touch */
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;         /* let SortableJS own touch gestures here */
}
.media-drag-handle:active { cursor: grabbing; }

.media-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow-y: auto;
    cursor: pointer;                 /* v1.57.1 — click to preview */
    transition: outline 0.12s ease;
}
.media-thumb:hover {
    outline: 2px solid var(--accent-primary, #8b5cf6);
    outline-offset: 1px;
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-info {
    flex: 1;
    min-width: 0;
}

.media-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow-y: auto;
    text-overflow: ellipsis;
}

.media-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.media-badge.video { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.media-badge.image { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.media-badge.audio { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.media-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.media-remove:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ======================== SETTINGS PANEL ======================== */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.setting-input,
.setting-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: var(--transition);
    width: 100%;
}

.setting-input:focus,
.setting-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ======================== TIMELINE PREVIEW ======================== */
.timeline-preview {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 8px;
}

.timeline-bar {
    display: flex;
    height: 40px;
    border-radius: 6px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.tl-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 30px;
    position: relative;
    overflow-y: auto;
}

.tl-segment.intro { background: linear-gradient(135deg, #10b981, #059669); }
.tl-segment.video { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tl-segment.outro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
.tl-segment.outro::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.7));
}
.tl-segment.audio {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    height: 20px;
    border-radius: 4px;
    margin-top: 4px;
}

.timeline-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ======================== BUTTONS ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
    border-radius: var(--radius);
}

.btn-block {
    width: 100%;
}

/* ======================== PROGRESS ======================== */
.progress-container {
    display: none;
    margin-top: 20px;
}

.progress-container.active { display: block; }

.progress-bar-bg {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: progressShimmer 1.5s infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ======================== RESULT ======================== */
.result-container {
    display: none;
    margin-top: 24px;
}

.result-container.active { display: block; }

.result-card {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.result-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 8px;
}

.result-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ======================== TOAST / NOTIFICATIONS ======================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2147483000;  /* v1.57.3 - above all modals (max ~10000) so toasts ("URL copied") never hide behind a modal/blur */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent-primary); }

.toast-text { font-size: 0.85rem; flex: 1; }

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

/* ======================== VIDEO INFO BAR ======================== */
.video-info-bar {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 12px;
    display: none;
}

.video-info-bar.active { display: block; }

.video-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.vi-item {
    text-align: center;
}

.vi-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.vi-value {
    font-size: 1rem;
    font-weight: 700;
    color: #60a5fa;
    font-family: 'JetBrains Mono', monospace;
}

/* ======================== UPLOAD PROGRESS PER-FILE ======================== */
.upload-progress {
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 2px;
    margin-top: 6px;
    overflow-y: auto;
    display: none;
}

.upload-progress.active { display: block; }

.upload-progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ======================== PROCESSING OVERLAY ======================== */
.processing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.processing-overlay.active {
    display: flex;
}

.processing-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    text-align: center;
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.processing-minimize-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}
.processing-minimize-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    color: #fff;
}

/* Floating progress pill */
.processing-pill {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    background: var(--bg-card);
    border: 1px solid var(--accent-primary);
    border-radius: 50px;
    padding: 10px 20px 10px 14px;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.3), var(--shadow-lg);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: pill-slide-in 0.35s ease-out;
}
.processing-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 32px rgba(139, 92, 246, 0.45), var(--shadow-lg);
}
.processing-pill.active {
    display: flex;
}
@keyframes pill-slide-in {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.processing-pill-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(139, 92, 246, 0.25);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.processing-pill-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.processing-pill-pct {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-secondary);
    min-width: 32px;
    text-align: right;
}

.processing-spinner {
    width: 64px;
    height: 64px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.processing-status {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ======================== FOOTER ======================== */
.app-footer {
    text-align: center;
    padding: 32px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* === END OF FILE (FILENAME: /videoeditor/assets/css/editor.css) === */

/* ======================== CRF SLIDER ======================== */
.crf-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #10b981 0%, #f59e0b 50%, #ef4444 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 8px 0;
}

.crf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--bg-card);
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
    transition: all 0.15s ease;
}

.crf-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.6);
}

.crf-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--bg-card);
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

.crf-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.crf-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 8px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    margin-left: 6px;
}

/* ======================== ESTIMATE BOX ======================== */
.estimate-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 14px;
    text-align: center;
}

.estimate-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.estimate-value {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.estimate-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === END ADDITIONS === */

/* ======================== AUDIO LIBRARY BROWSER ======================== */
.audio-library-browser {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    overflow-y: auto;
}

.audio-library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(139, 92, 246, 0.05);
}

.audio-library-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.audio-library-count {
    font-size: 0.7rem;
    background: rgba(139, 92, 246, 0.2);
    padding: 2px 8px;
    border-radius: 8px;
    color: var(--accent-secondary);
    font-weight: 600;
}

.audio-library-list {
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) transparent;
}

.audio-library-list::-webkit-scrollbar {
    width: 6px;
}
.audio-library-list::-webkit-scrollbar-track {
    background: transparent;
}
.audio-library-list::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}
.audio-library-list::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

.audio-library-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 24px 16px;
    font-style: italic;
}

.audio-library-loading {
    text-align: center;
    color: var(--accent-secondary);
    font-size: 0.8rem;
    padding: 20px 16px;
}

/* Individual Track Row */
.audio-track-row:last-child {
    border-bottom: none;
}

.audio-track-row:hover {
    background: rgba(139, 92, 246, 0.08);
}

.audio-track-row.selected {
    background: rgba(139, 92, 246, 0.15);
    border-left: 3px solid var(--accent-primary);
}

/* Play Button */
.audio-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-secondary);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
}

.audio-play-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.audio-play-btn.playing {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    animation: audioPulse 1.5s ease-in-out infinite;
}

@keyframes audioPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* Track Info */
.audio-track-info {
    flex: 1;
    min-width: 0;
}

.audio-track-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow-y: auto;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.audio-track-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    margin-top: 1px;
}

/* Select Indicator */
.audio-track-select {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.audio-track-row:hover .audio-track-select {
    opacity: 0.3;
}

.audio-track-row.selected .audio-track-select {
    opacity: 1;
}

/* Selected Info Bar */
.audio-selected-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(16, 185, 129, 0.08);
    border-top: 1px solid rgba(16, 185, 129, 0.2);
}

.audio-selected-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.audio-selected-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--success);
    flex: 1;
    white-space: nowrap;
    overflow-y: auto;
    text-overflow: ellipsis;
}

.audio-deselect-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.audio-deselect-btn:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Category Badge (for "All Tracks" view) */
.audio-track-cat-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-secondary);
    margin-left: 6px;
    vertical-align: middle;
}

/* Audio Scrub Bar */
.audio-scrub-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 0 2px;
    margin-top: 4px;
}

.audio-scrub-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    flex-shrink: 0;
}

.audio-scrub-current { text-align: right; }
.audio-scrub-duration { text-align: left; }

.audio-scrub-track {
    flex: 1;
    height: 6px;
    background: rgba(139, 92, 246, 0.12);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.audio-scrub-track:hover {
    height: 8px;
}

.audio-scrub-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-scrub-handle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-secondary);
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    transition: left 0.1s linear;
    cursor: grab;
}

.audio-scrub-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

.audio-track-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.06);
    cursor: pointer;
    transition: var(--transition);
    flex-wrap: wrap;
}

/* ==================== PROGRESS BAR ==================== */
.progress-bar-container {
    width: 100%;
    margin-top: 16px;
}

.progress-bar-track {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    overflow-y: auto;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), #00e676);
    border-radius: 8px;
    transition: width 0.5s ease-out;
    position: relative;
    min-width: 0;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.15) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-bar-label {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 8px;
    color: #fff;
    letter-spacing: 1px;
}

.progress-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.progress-stats span {
    background: rgba(255,255,255,0.05);
    padding: 4px 10px;
    border-radius: 6px;
}

.progress-eta {
    margin-top: 14px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.progress-eta strong {
    color: var(--accent-secondary);
    font-size: 1.05rem;
}

/* ==================== PROJECTS MODAL ==================== */
.projects-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.projects-overlay.active {
    display: flex;
}

.projects-modal {
    background: var(--surface-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
}

.projects-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.projects-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.projects-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.projects-body {
    overflow-y: auto;
    padding: 16px 24px 24px;
    flex: 1;
}

.projects-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.projects-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-size: 0.95rem;
}

.session-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.session-card:hover {
    border-color: var(--accent-primary);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.session-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
}

.session-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.session-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.session-file-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.05);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.session-file-tag .file-delete-btn {
    background: none;
    border: none;
    color: #ff5252;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.session-file-tag:hover .file-delete-btn {
    opacity: 1;
}

.session-actions {
    display: flex;
    gap: 8px;
}

.session-actions .btn {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === END OF FILE (FILENAME: /videoeditor/assets/css/editor.css) === */

/* ======================== MODALS ======================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--warning);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* === ACCORDION SETTINGS === */
.accordion-toggle {
    user-select: none;
    transition: background 0.15s;
    padding: 12px 16px;
}
.accordion-toggle:hover {
    background: rgba(255,255,255,0.03);
}
.accordion-arrow {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.accordion-body {
    padding: 0 16px 16px;
    overflow-y: auto;
    transition: max-height 0.25s ease-out;
}
.accordion-card.collapsed .accordion-body {
    display: none;
}
.accordion-card .card-title {
    margin-bottom: 0;
}
.accordion-card:not(.collapsed) .card-title {
    margin-bottom: 8px;
}

/* === HEADER ACTIONS === */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.header-actions .btn-primary {
    font-size: 1rem;
    padding: 8px 20px;
}

/* === QUICK PRESET BAR === */
.preset-quick-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.preset-quick-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.preset-quick-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}
.preset-quick-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}


/* ======================== MOBILE RESPONSIVE ======================== */

/* Tablet */
@media (max-width: 900px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }
    .app-container {
        padding: 12px 10px;
    }
    .app-header {
        padding: 20px 0 16px;
    }
    .app-logo {
        font-size: 1.8rem;
    }
    .app-subtitle {
        font-size: 0.8rem;
    }
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        margin-top: 10px;
    }
    .header-actions .btn {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    .card {
        padding: 16px;
    }
    .setting-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    html {
        font-size: 15px;
    }
    .app-container {
        padding: 8px 8px;
    }
    .app-header {
        padding: 12px 0 12px;
        text-align: left;
    }
    .app-header::after {
        display: none;
    }
    .app-logo {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }
    .app-subtitle {
        font-size: 0.7rem;
        display: none;
    }
    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin-top: 8px;
    }
    .header-actions .btn-primary {
        grid-column: 1 / -1;
        font-size: 1rem;
        padding: 10px 16px;
    }
    .header-actions .btn {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    .editor-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 12px;
    }
    .card {
        padding: 12px;
        border-radius: 8px;
    }
    .card-title {
        font-size: 0.9rem;
    }
    .drop-zone {
        padding: 24px 12px;
    }
    .drop-zone-icon {
        font-size: 2rem;
    }
    .drop-zone-text {
        font-size: 0.85rem;
    }
    .drop-zone-hint {
        font-size: 0.7rem;
    }
    .setting-label {
        font-size: 0.75rem;
    }
    .setting-input,
    .setting-select {
        font-size: 0.85rem;
        padding: 6px 8px;
    }
    .setting-hint {
        font-size: 0.7rem;
    }
    .setting-row {
        flex-direction: column;
        gap: 8px;
    }
    .btn {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    .btn-lg {
        font-size: 0.95rem;
        padding: 10px 16px;
    }

    /* Video info bar */
    .video-info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .vi-label {
        font-size: 0.65rem;
    }
    .vi-value {
        font-size: 0.8rem;
    }

    /* Audio section */
    .audio-library-list {
        max-height: 250px;
    }
    .audio-track-row {
        padding: 8px 6px;
    }
    .audio-track-name {
        font-size: 0.8rem;
    }
    .audio-track-meta {
        font-size: 0.65rem;
    }

    /* Timeline */
    .timeline-preview {
        font-size: 0.7rem;
    }
    .tl-segment {
        font-size: 0.65rem;
        padding: 4px 2px;
    }

    /* Accordion */
    .accordion-toggle {
        padding: 10px 12px;
    }
    .accordion-body {
        padding: 0 12px 12px;
    }

    /* Preset quick bar */
    .preset-quick-bar {
        gap: 4px;
    }
    .preset-quick-btn {
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    /* CRF slider */
    .crf-labels {
        font-size: 0.65rem;
    }
    .estimate-box {
        padding: 10px;
    }
    .estimate-value {
        font-size: 1.2rem;
    }

    /* Result container */
    .result-actions {
        flex-direction: column;
        gap: 6px;
    }
    .result-actions .btn {
        width: 100%;
    }
    .result-title {
        font-size: 1.1rem;
    }

    /* Processing overlay */
    .processing-modal {
        width: 90%;
        padding: 20px;
    }
    .processing-title {
        font-size: 1rem;
    }

    /* Modals */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto;
    }
    .projects-modal {
        width: 95%;
        max-height: 85vh;
    }

    /* Output history */
    #output-history-list {
        max-height: 300px;
    }

    /* Media list items */
    .media-item {
        padding: 8px;
        font-size: 0.8rem;
    }

    /* Toast */
    .toast-container {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }
    .toast {
        font-size: 0.8rem;
    }
}

/* Small phones */
@media (max-width: 380px) {
    html {
        font-size: 14px;
    }
    .app-logo {
        font-size: 1.2rem;
    }
    .header-actions .btn {
        font-size: 0.75rem;
        padding: 5px 8px;
    }
}


/* ======================== MOBILE TOUCH FIXES ======================== */
/* Prevent pseudo-elements from intercepting touches */
.drop-zone::before {
    pointer-events: none;
}

/* Ensure file input stays within its parent */
.drop-zone {
    overflow-y: auto;
}
.drop-zone input[type="file"] {
    z-index: 2;
}

/* Ensure all buttons/links are tappable */
.btn, button, a, select, input, .accordion-toggle, .preset-quick-btn {
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    touch-action: manipulation;
}

/* Cards */
.card {
    position: relative;
}

/* Slideshow preview modal - ensure close button is tappable on mobile */
@media (max-width: 600px) {
    .close-modal {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
    }
}



/* ======================== MOBILE PORTRAIT FIX ======================== */
@media (max-width: 768px) and (orientation: portrait) {
    /* On mobile portrait, the invisible file input with inset:0
       covers the entire drop-zone and blocks ALL touch events below it.
       Kill it entirely and let the JS click handler on .drop-zone do the work. */
    .drop-zone input[type="file"] {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        top: 0 !important;
        left: 0 !important;
        inset: auto !important;
        opacity: 0 !important;
        pointer-events: none !important;
        overflow: hidden !important;
    }

    /* Ensure toast container doesn't intercept touches */
    .toast-container {
        pointer-events: none;
    }
    .toast-container .toast {
        pointer-events: auto;
    }

    /* Ensure nothing invisible blocks touches */
    .drop-zone::before {
        pointer-events: none !important;
    }
    .card::before, .card::after {
        pointer-events: none !important;
    }
}


/* ======================== PWA SAFE-AREA (Ship 1, v1.41.0) ======================== */
/* iOS notch / home-indicator handling for Add-to-Home-Screen standalone mode. */
html, body { min-height: 100vh; min-height: 100dvh; }

.app-container {
    /* Add the device safe-area insets to existing padding so content clears
       the notch, home indicator, and the rounded corners in landscape. */
    padding-top:    calc(24px + env(safe-area-inset-top));
    padding-right:  calc(20px + env(safe-area-inset-right));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    padding-left:   calc(20px + env(safe-area-inset-left));
}

@media (max-width: 768px) {
    .app-container {
        padding-top:    calc(16px + env(safe-area-inset-top));
        padding-right:  calc(12px + env(safe-area-inset-right));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        padding-left:   calc(12px + env(safe-area-inset-left));
    }
}


/* ======================== LUCIDE ICONS (v1.44.0) ======================== */
/* Stroke icons inherit currentColor so they're white on dark by default.
   Inline-block + vertical-align keeps them on the text baseline next to labels. */
[data-lucide], .lucide {
    display: inline-block;
    vertical-align: -0.15em;
    width: 1em;
    height: 1em;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}
/* Slightly larger inside primary action buttons */
.btn-primary [data-lucide], .btn-lg [data-lucide] {
    width: 1.1em;
    height: 1.1em;
    margin-right: 4px;
}
/* Toast icon: separate column, color matches toast tone */
.toast-icon { display: inline-flex; align-items: center; margin-right: 8px; }
.toast-icon [data-lucide] { width: 1.1rem; height: 1.1rem; }


/* ======================== MOBILE-NATIVE PWA (v1.45.3) ======================== */
/* iPhone / iPad standalone mode — make the editor feel like an app instead of
   a desktop site shrunk to fit. Stack the header vertically, full-width primary,
   compact secondary buttons, kill horizontal overflow. */
html, body { overflow-x: clip; }

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        text-align: left;
    }
    .app-header::after { display: none; }
    .app-logo {
        font-size: 1.4rem !important;
        justify-content: flex-start !important;
    }
    .app-logo img {
        width: 28px !important;
        height: 28px !important;
    }
    .app-subtitle { display: none; }

    .header-actions {
        display: flex !important;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 0;
        justify-content: flex-start;
    }
    .header-actions .btn {
        flex: 0 0 auto;
        font-size: 0.82rem !important;
        padding: 8px 12px !important;
        min-height: 38px;
        white-space: nowrap;
    }
    .header-actions .btn-primary {
        flex: 1 1 100% !important;
        font-size: 0.95rem !important;
        padding: 12px 16px !important;
        min-height: 44px;  /* iOS HIG touch target */
        order: 99;  /* push to the end so it sits as the prominent full-width CTA */
    }

    /* Theme picker: compact on mobile, sits inline with the secondary actions */
    .pp-theme-wrap {
        padding: 5px 8px !important;
        font-size: 0.8rem !important;
    }
    .pp-theme-wrap select { font-size: 0.8rem !important; padding-right: 12px !important; }
}

/* iPhone-narrow: tighter still */
@media (max-width: 480px) {
    .app-container {
        padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
                 calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    }
    .app-logo span { font-size: 1.35rem; }
    .header-actions .btn {
        font-size: 0.78rem !important;
        padding: 7px 10px !important;
    }
    /* Slightly hide the verbose action labels — leave the icon + a shortened word */
    .card {
        padding: 12px 10px !important;
        border-radius: 10px !important;
    }
    .card-title {
        font-size: 1rem !important;
    }
    /* Tap-friendly select / input sizes */
    select, input[type="text"], input[type="number"], input[type="search"], textarea {
        font-size: 16px !important;  /* prevents iOS auto-zoom */
        min-height: 38px;
    }
    button, .btn {
        min-height: 38px;
    }
}


/* ======================== MOBILE-NATIVE POLISH (v1.45.4) ======================== */

/* (2) Disabled button fades icon AND text together (was: icon stayed bright) */
button:disabled, .btn:disabled, button[disabled], .btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;  /* extra protection */
}
/* Lucide icons inside use currentColor, so they inherit the faded color too. */

@media (max-width: 768px) {

    /* (1) Sticky iOS-style nav bar: logo row pins to top with frosted-glass
           backdrop. Bleed to screen edges via negative margins so it looks
           edge-to-edge under the status bar, not "inside a padded container". */
    .app-container { position: relative; }
    .app-header {
        position: sticky;
        top: 0;
        z-index: 50;
        /* Cancel the container's padding so we bleed to screen edges */
        margin-left:  calc(-1 * (12px + env(safe-area-inset-left)));
        margin-right: calc(-1 * (12px + env(safe-area-inset-right)));
        margin-top:   calc(-1 * (16px + env(safe-area-inset-top)));
        margin-bottom: 12px;
        /* Restore + extend padding so content clears the status bar + insets */
        padding: calc(10px + env(safe-area-inset-top))
                 calc(12px + env(safe-area-inset-right))
                 10px
                 calc(12px + env(safe-area-inset-left));
        background: rgba(10, 10, 15, 0.78);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }

    /* (5) Smaller VideoPapi wordmark — more like an iOS title, less like a banner */
    .app-logo {
        font-size: 1.1rem !important;
        font-weight: 700;
        gap: 8px !important;
    }
    .app-logo span {
        font-size: 1.05rem;
        background: linear-gradient(135deg, var(--accent-primary, #8b5cf6), var(--accent-secondary, #ec4899));
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        letter-spacing: -0.01em;
    }
    .app-logo img {
        width: 26px !important;
        height: 26px !important;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {

    /* (4) Flatten cards on mobile — iOS Settings-style. No harsh border, softer
           glass background, tighter padding, larger corner radius. */
    .card {
        border: none !important;
        background: rgba(255, 255, 255, 0.035);
        padding: 14px 12px !important;
        border-radius: 14px !important;
        margin-bottom: 10px !important;
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
    }
    .card-title {
        font-size: 0.98rem !important;
        margin-bottom: 10px !important;
    }

    /* (3) Comfortable home-indicator gutter — content shouldn't end right at
           the bottom edge of the screen. Add a generous bottom inset. */
    .app-container {
        padding-bottom: calc(40px + env(safe-area-inset-bottom)) !important;
    }

    /* Header tweaks at iPhone width: even more compact action buttons */
    .header-actions .btn {
        padding: 7px 11px !important;
        font-size: 0.8rem !important;
    }
    .header-actions .btn-primary {
        padding: 13px 16px !important;
        font-size: 0.95rem !important;
    }
}


/* ======================== BOTTOM TAB BAR (v1.46.0) ======================== */
/* iOS-style sticky bottom tab bar. Mobile only — desktop hides it. */
.pp-tab-bar { display: none; }

@media (max-width: 768px) {
    .pp-tab-bar {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 100;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: rgba(10, 10, 15, 0.84);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid rgba(255,255,255,0.08);
        gap: 2px;
    }
    .pp-tab {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 6px 4px 4px;
        font-size: 0.66rem;
        color: rgba(255,255,255,0.55);
        text-decoration: none;
        border-radius: 8px;
        min-height: 50px;
        transition: color 0.15s, background 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .pp-tab [data-lucide] {
        width: 22px;
        height: 22px;
        stroke-width: 2;
    }
    .pp-tab span {
        font-weight: 500;
        letter-spacing: 0.01em;
    }
    .pp-tab.active {
        color: var(--accent-secondary, #ec4899);
    }
    .pp-tab:active {
        background: rgba(255,255,255,0.06);
    }

    /* Make sure content clears the tab bar — reserve room at the bottom of
       the page so the last card isn't hidden under the fixed bar. */
    .app-container {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
    /* Scroll padding so anchor jumps account for the sticky top nav */
    html { scroll-padding-top: 70px; }
}


/* ======================== RICH SELECT (Lucide-in-dropdown) v1.47.0 ======================== */
/* Custom dropdown UI that replaces native <select> visually so Lucide icons
   can render inside options. The native <select> stays in the DOM and keeps
   its value / change events. */
.pp-rich-select {
    position: relative;
    display: block;
}
.pp-rich-select .pp-rs-native {
    /* keep in DOM for form + JS, but hide visually */
    position: absolute !important;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.pp-rich-select .pp-rs-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--bg-secondary, #12121a);
    color: var(--text-primary, #f0f0f5);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    font: inherit;
    text-align: left;
    cursor: pointer;
    line-height: 1.3;
}
.pp-rich-select .pp-rs-trigger:hover { border-color: rgba(255,255,255,0.18); }
.pp-rich-select .pp-rs-trigger:focus-visible {
    outline: 2px solid var(--accent-primary, #8b5cf6);
    outline-offset: 1px;
}
.pp-rich-select .pp-rs-trigger [data-lucide] { width: 1em; height: 1em; flex-shrink: 0; }
.pp-rich-select .pp-rs-trigger .pp-rs-caret {
    margin-left: auto;
    opacity: 0.55;
    transition: transform 0.18s;
}
.pp-rich-select.pp-rs-open .pp-rs-trigger .pp-rs-caret { transform: rotate(180deg); }

.pp-rich-select .pp-rs-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    z-index: 200;
    background: var(--bg-card, #16162a);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    max-height: min(60vh, 360px);
    overflow-y: auto;
    padding: 4px;
}
.pp-rich-select .pp-rs-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    background: transparent;
    color: var(--text-primary, #f0f0f5);
    border: none;
    border-radius: 6px;
    font: inherit;
    text-align: left;
    cursor: pointer;
    line-height: 1.3;
}
.pp-rich-select .pp-rs-item [data-lucide] { width: 1em; height: 1em; flex-shrink: 0; opacity: 0.85; }
.pp-rich-select .pp-rs-item:hover { background: rgba(255,255,255,0.05); }
.pp-rich-select .pp-rs-item:active { background: rgba(255,255,255,0.10); }
.pp-rich-select .pp-rs-item.selected {
    background: color-mix(in srgb, var(--accent-primary, #8b5cf6) 22%, transparent);
    color: var(--text-primary, #f0f0f5);
}
.pp-rich-select .pp-rs-item.selected [data-lucide] { opacity: 1; }
.pp-rich-select .pp-rs-item:disabled { opacity: 0.45; cursor: not-allowed; }

.pp-rich-select .pp-rs-group { padding: 2px 0; }
.pp-rich-select .pp-rs-group + .pp-rs-group { border-top: 1px solid rgba(255,255,255,0.05); margin-top: 4px; padding-top: 6px; }
.pp-rich-select .pp-rs-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 4px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6a6a8a);
    font-weight: 700;
}
.pp-rich-select .pp-rs-group-label [data-lucide] { width: 0.95em; height: 0.95em; }

/* Mobile: full-width popover bleeds to screen edges + bigger touch targets */
@media (max-width: 480px) {
    .pp-rich-select .pp-rs-panel {
        max-height: min(70vh, 480px);
    }
    .pp-rich-select .pp-rs-item { padding: 12px 12px; min-height: 44px; }
    .pp-rich-select .pp-rs-trigger { padding: 11px 14px; min-height: 44px; }
}


/* ======================== v1.48.0 LAYOUT POLISH ======================== */

/* --- Header reorg: brand cluster on left (logo + theme picker), action row right --- */
.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.app-brand .app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    white-space: nowrap;
}
.app-brand .app-logo img {
    width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
}
.app-brand .app-logo span {
    background: linear-gradient(135deg, var(--accent-primary, #8b5cf6), var(--accent-secondary, #ec4899));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

/* Consistent header-button sizing — all buttons same height, same padding,
   icons + labels aligned. The primary CTA stays prominent via color, not size. */
.app-header .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.app-header .header-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 8px 14px;
    min-height: 38px;
    line-height: 1;
}
.app-header .header-actions .btn [data-lucide] {
    width: 1em; height: 1em; flex-shrink: 0;
}
.app-header .header-actions .btn-primary {
    background: var(--accent-gradient, linear-gradient(135deg, #8b5cf6, #ec4899));
    color: white;
}

/* --- Quick presets at the top (moved out of settings panel) --- */
.pp-top-presets {
    display: flex;
    gap: 8px;
    margin: 16px 0 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}
.pp-top-presets .preset-quick-btn { flex-shrink: 0; }

/* --- Library / Settings modal frame (shared style with Projects modal) --- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.72);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-frame {
    background: var(--bg-card, #16162a);
    color: var(--text-primary, #f0f0f5);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    width: 100%;
    max-width: 720px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
}
.modal-frame-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-frame-head h2 {
    margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; font-weight: 700;
}
.modal-frame-close {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary, #f0f0f5);
    border: none; border-radius: 8px;
    width: 32px; height: 32px;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.modal-frame-close:hover { background: rgba(255,255,255,0.10); }
.modal-frame-body {
    flex: 1; overflow-y: auto; padding: 14px 20px 20px;
}
.modal-frame-sheet { max-width: 560px; }

/* Settings menu items — iOS settings-app row style */
.pp-settings-menu-item {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%;
    background: rgba(255,255,255,0.04);
    color: inherit;
    border: none;
    border-radius: 10px;
    padding: 14px 16px;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 8px;
    text-align: left;
    transition: background 0.15s;
}
.pp-settings-menu-item:hover, .pp-settings-menu-item:active {
    background: rgba(255,255,255,0.08);
}
.pp-settings-menu-item [data-lucide] {
    width: 18px; height: 18px; opacity: 0.5;
}

/* --- Mobile-specific header tweaks (override earlier mobile rules) --- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 10px;
    }
    .app-brand {
        width: 100%;
        justify-content: flex-start;
        gap: 10px;
    }
    .app-brand .app-logo { font-size: 1.15rem; }
    .app-brand .app-logo img { width: 28px; height: 28px; }
    .app-brand .pp-theme-wrap { margin-left: auto; }

    .header-actions {
        width: 100%;
        gap: 6px !important;
    }
    .header-actions .btn {
        flex: 1 1 auto;
        font-size: 0.78rem !important;
        padding: 8px 10px !important;
        justify-content: center;
    }
    .header-actions .btn-primary {
        flex: 1 1 100%;
        order: 99;
        font-size: 0.95rem !important;
        padding: 12px 14px !important;
        min-height: 44px;
    }
}

/* iPhone-narrow: hide secondary button text, keep icons only — saves space */
@media (max-width: 420px) {
    .header-actions .btn:not(.btn-primary) span {
        position: absolute;
        width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); white-space: nowrap;
    }
    .header-actions .btn:not(.btn-primary) {
        min-width: 44px;
        padding: 9px 10px !important;
    }
    .header-actions .btn-primary span {
        display: inline;
    }
}


/* ======================== v1.49.0 BUTTON STACK ======================== */

/* Guide button next to theme picker (in .app-brand) — minimal icon button */
.btn-brand-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--bg-card, #16162a);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-primary, #f0f0f5);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.btn-brand-link:hover { border-color: rgba(255,255,255,0.20); background: var(--bg-hover, #1e1e3a); }
.btn-brand-link [data-lucide] { width: 18px; height: 18px; }

/* Header buttons stack vertically: icon on top, label middle, sublabel under */
.btn.btn-stack {
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px !important;
    min-height: 56px;
    line-height: 1.15;
}
.btn.btn-stack [data-lucide] {
    width: 18px;
    height: 18px;
    margin-bottom: 1px;
}
.btn.btn-stack .btn-label {
    font-size: 0.82rem;
    font-weight: 600;
}
.btn.btn-stack .btn-sub {
    font-size: 0.65rem;
    opacity: 0.62;
    font-weight: 400;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.btn-primary.btn-stack .btn-sub {
    color: rgba(255,255,255,0.85);
    opacity: 0.85;
}

/* Mobile: keep stacked layout, slightly tighter padding */
@media (max-width: 768px) {
    .app-brand {
        gap: 8px;
        width: 100%;
        justify-content: flex-start;
    }
    .app-brand .pp-theme-wrap { margin-left: auto; }
    .btn-brand-link { width: 34px; height: 34px; }
    .btn-brand-link [data-lucide] { width: 16px; height: 16px; }

    .btn.btn-stack {
        min-height: 52px;
        padding: 7px 8px !important;
    }
    .btn.btn-stack .btn-label { font-size: 0.78rem; }
    .btn.btn-stack .btn-sub { font-size: 0.6rem; }
}

/* iPhone-narrow: keep the sublabels (don't hide them — they're the whole point) */
@media (max-width: 420px) {
    .header-actions .btn:not(.btn-primary) span.btn-label {
        position: static !important;  /* override the v1.48 hide-label rule */
        width: auto !important; height: auto !important;
        clip: auto !important;
    }
    .header-actions .btn:not(.btn-primary) small.btn-sub {
        display: block;
    }
}


/* ======================== v1.56.0 PLAY BUTTON CIRCLE FIX ======================== */
/* The audio-play-btn was rendering as an oval on mobile because the flex parent
   was stretching it. min-width/min-height + aspect-ratio:1 force a true circle. */
.audio-play-btn {
    min-width: 32px;
    min-height: 32px;
    aspect-ratio: 1 / 1;
    padding: 0;
}
@media (max-width: 480px) {
    .audio-play-btn {
        min-width: 36px;
        min-height: 36px;
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }
}
