/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #000000;
    --secondary: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    --accent: #ff0000;
    --success: #10b981;
    --border: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.2s ease;
    --sidebar-width: 56px;
}

[data-theme="dark"] {
    --primary: #ffffff;
    --secondary: #1a1a1a;
    --gray-100: #1f1f1f;
    --gray-200: #2a2a2a;
    --gray-300: #404040;
    --gray-400: #9a9a9a;
    --gray-500: #b0b0b0;
    --gray-600: #d0d0d0;
    --gray-700: #e0e0e0;
    --gray-800: #f0f0f0;
    --accent: #ff4444;
    --success: #10b981;
    --border: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Floating Sidebar */
.sidebar {
    position: fixed;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: var(--sidebar-width);
    background: var(--secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sidebar-header {
    padding: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header svg {
    color: var(--primary);
    display: block;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 0 8px;
}

.sidebar-item {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.sidebar-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.sidebar-item.active {
    background: var(--primary);
    color: var(--secondary);
}

.sidebar-item[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: var(--secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--secondary);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    padding: 12px 16px;
    box-shadow: var(--shadow);
}

.mobile-nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.hamburger:hover {
    background: var(--gray-100);
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: var(--primary);
    transition: var(--transition);
    border-radius: 1px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

.mobile-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--secondary);
    border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 150;
    box-shadow: var(--shadow);
}

.mobile-menu.active {
    transform: translateY(0);
}

.mobile-menu-items {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.mobile-menu-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.mobile-menu-item.active {
    background: var(--primary);
    color: var(--secondary);
}

/* Main Workspace */
.workspace {
    width: 100%;
    min-height: 100vh;
    padding: clamp(16px, 3vw, 20px);
    padding-left: calc(var(--sidebar-width) + 32px + 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Prevent scrolling */
}

.workspace-grid {
    display: grid;
    grid-template-columns: 1fr clamp(280px, 25vw, 320px) 1fr;
    gap: clamp(12px, 2vw, 20px);
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 40px); /* Fit within viewport */
    overflow: hidden; /* Prevent scrolling */
}

/* Panels */
.panel {
    background: var(--secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%; /* Fill available height */
    max-height: calc(100vh - 80px); /* Prevent overflow */
}

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

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

/* Left Panel - Image Upload */
.panel-left {
    display: flex;
    flex-direction: column;
}

.upload-zone {
    flex: 1;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--secondary);
    min-height: 200px;
    max-height: calc(100vh - 200px);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--gray-100);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(255, 0, 0, 0.05);
    transform: scale(1.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--gray-400);
    text-align: center;
}

.upload-placeholder svg {
    color: var(--gray-400);
}

.upload-placeholder p {
    font-weight: 500;
    color: var(--gray-600);
}

.text-xs {
    font-size: 12px;
    color: var(--gray-500);
}

.preview-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

/* Middle Panel - Controls */
.panel-middle {
    background: var(--gray-100);
    color: var(--primary);
}

.controls-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    overflow-y: auto; /* Allow scrolling within controls if needed */
}

.controls-container-polished {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    height: 100%;
    overflow-y: auto; /* Allow controlled scrolling */
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    color: var(--primary);
}

.label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

.input {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--secondary);
    color: var(--primary);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.char-count {
    position: absolute;
    right: 14px;
    top: 36px;
    font-size: 11px;
    color: var(--gray-400);
}

.select {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--secondary);
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
}

.select option {
    background: var(--secondary);
    color: var(--primary);
}

.select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* Slider Controls */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-300);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--secondary);
    box-shadow: var(--shadow-sm);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--secondary);
    box-shadow: var(--shadow-sm);
}

.slider-value {
    min-width: 32px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

/* Process Button */
.generate-btn, .btn-process, #processBtn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.generate-btn:hover:not(:disabled), .btn-process:hover:not(:disabled), #processBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 191, 165, 0.3);
}

.generate-btn:disabled, .btn-process:disabled, #processBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* All Generate Buttons - unified style */
#generateTTSBtn, #generateVideoCaptionBtn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#generateTTSBtn:hover:not(:disabled), #generateVideoCaptionBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 191, 165, 0.3);
}

#generateTTSBtn:disabled, #generateVideoCaptionBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Right Panel - Result */
.panel-right {
    display: flex;
    flex-direction: column;
}

.result-zone {
    flex: 1;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--gray-400);
    text-align: center;
}

.result-placeholder svg {
    color: var(--gray-400);
}

.result-placeholder p {
    font-size: 14px;
    color: var(--gray-500);
}

.result-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

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

/* TTS Input Zone */
.tts-input-zone {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}

.tts-textarea {
    width: 100%;
    flex: 1;
    min-height: 200px;
    max-height: calc(100vh - 300px); /* Limit height to fit viewport */
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--secondary);
    color: var(--primary);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: var(--transition);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tts-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tts-textarea::placeholder {
    color: var(--gray-400);
    font-style: normal;
    opacity: 0.7;
}

.char-count {
    align-self: flex-end;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

/* Icon Buttons */
.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--secondary);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--gray-100);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
}

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

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    font-size: 14px;
    color: var(--gray-600);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 1fr clamp(260px, 30vw, 280px) 1fr;
        gap: clamp(8px, 1.5vw, 16px);
    }
}

@media (max-width: 992px) {
    .sidebar {
        display: none;
    }
    
    .mobile-nav {
        display: block;
    }
    
    .workspace {
        padding: clamp(12px, 2vw, 16px);
        padding-left: clamp(12px, 2vw, 16px);
        padding-top: 80px;
    }
    
    .workspace-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: clamp(12px, 2vw, 16px);
        max-width: 100%;
    }
    
    .panel {
        min-height: 300px;
    }
    
    .panel-header h2 {
        font-size: clamp(12px, 2vw, 14px);
    }
    
    .controls-container {
        padding: clamp(12px, 3vw, 20px);
        gap: clamp(16px, 3vw, 24px);
    }
    
    .input, .select {
        padding: clamp(10px, 2vw, 14px);
        font-size: clamp(14px, 2.5vw, 16px);
        min-height: 44px;
    }
    
    .generate-btn, .btn-process, #processBtn,
    #generateTTSBtn, #generateVideoCaptionBtn {
        padding: clamp(12px, 3vw, 16px);
        font-size: clamp(14px, 2.5vw, 16px);
        min-height: 48px;
    }
}

@media (max-width: 768px) {
    .workspace {
        padding: 12px;
        padding-top: 70px;
    }
    
    .workspace-grid {
        gap: 12px;
    }
    
    .panel {
        border-radius: clamp(6px, 1.5vw, 10px);
    }
    
    .panel-header {
        padding: clamp(12px, 3vw, 16px);
    }
    
    .upload-zone, .result-zone {
        padding: clamp(12px, 3vw, 20px);
        min-height: 200px;
    }
    
    .tts-textarea {
        min-height: 150px;
        font-size: clamp(14px, 2.5vw, 16px);
    }
    
    .modal-content {
        margin: 20px;
        max-width: calc(100vw - 40px);
    }
    
    .modal-header, .modal-body {
        padding: clamp(16px, 4vw, 32px);
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .links {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .mobile-nav {
        padding: 8px 12px;
    }
    
    .workspace {
        padding: 8px;
        padding-top: 60px;
    }
    
    .workspace-grid {
        gap: 8px;
    }
    
    .panel-header h2 {
        font-size: 12px;
    }
    
    .controls-container {
        padding: 12px;
        gap: 16px;
    }
    
    .upload-zone, .result-zone {
        padding: 12px;
        min-height: 150px;
    }
    
    .upload-placeholder svg {
        width: 32px;
        height: 32px;
    }
    
    .result-image, .result-video {
        max-width: 100%;
        height: auto;
    }
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 8px;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.theme-toggle[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: var(--secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow);
}

/* BGM Controls Styling */
.file-input-container {
    margin-bottom: 15px;
}

.file-input {
    display: none;
}

.file-input-label {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    border: none;
    min-width: 200px;
    text-align: center;
}

.file-input-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.file-input-icon {
    margin-left: 8px;
    font-size: 16px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.volume-control label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    min-width: 80px;
}

.volume-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

/* BGM Section Animation */
#bgmSection {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating Footer */
.floating-footer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.floating-footer:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.footer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.company-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.company-link:hover {
    opacity: 0.8;
}

.link-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.link-button.github {
    background: var(--gray-800);
    color: var(--secondary);
    border-color: var(--gray-800);
}

.link-button.github:hover {
    background: var(--gray-700);
    transform: translateY(-2px);
}

.link-button.donate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.link-button.donate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .link-button.github {
    background: var(--gray-200);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.8);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--primary);
}

.modal-header {
    padding: 32px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.modal-logo {
    display: inline-flex;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: var(--gray-500);
    font-size: 14px;
}

.modal-body {
    padding: 32px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    text-align: center;
}

.feature svg {
    color: var(--accent);
}

.feature span {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.credits {
    text-align: center;
    margin-bottom: 24px;
}

.credits p {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 4px;
}

.credits strong {
    color: var(--primary);
}

.version {
    font-size: 12px;
    color: var(--gray-400);
}

.links {
    display: flex;
    gap: 12px;
}

.link-button.github {
    border-color: var(--gray-800);
}

.link-button.github:hover {
    background: var(--gray-700);
    transform: translateY(-2px);
}

.link-button.donate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.link-button.donate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .link-button.github {
    background: var(--gray-200);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.8);
}

/* Loading Modal */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
}

.loading-modal.active {
    display: block;
}

.loading-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.water-loader {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.9));
    transition: height 0.3s ease;
    opacity: 1;
}

.water-wave {
    position: absolute;
    left: 0;
    width: 200%;
    height: 60px;
    bottom: 100%;
    fill: rgba(255, 255, 255, 0.5);
    animation: wave 3s linear infinite;
}

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

.water-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: bold;
    color: #ffffff;
    z-index: 10;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    font-family: 'Inter', sans-serif;
}

.progress-message {
    text-align: center;
    color: #ffffff;
    font-size: 16px;
    font-style: italic;
    animation: fadeInOut 2s ease-in-out infinite;
    max-width: 300px;
    font-family: 'Inter', sans-serif;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Polished TTS Controls (uiverse.io inspired) */
.controls-container-polished {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    height: 100%;
}

.control-row {
    display: flex;
    gap: 12px;
}

.control-item, .control-item-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-section-group {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.control-section-group:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.1);
}

.control-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group-title::before {
    content: '';
    width: 4px;
    height: 12px;
    background: var(--accent);
    border-radius: 2px;
}

.label-polished {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.label-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.slider-polished {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-300);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider-polished::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--secondary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.slider-polished::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.2);
}

.slider-value-display {
    min-width: 35px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
}

.segmented-control {
    display: flex;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--gray-100);
}

.segmented-control input {
    display: none;
}

.segmented-control label {
    flex: 1;
    padding: 8px 16px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    border-right: 1px solid var(--border);
}

.segmented-control label:last-child {
    border-right: none;
}

.segmented-control input:checked + label {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.effects-info {
    margin-top: 8px;
    font-size: 11px;
    color: var(--gray-500);
    line-height: 1.4;
    padding: 8px 12px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.upload-container-polished {
    background: var(--secondary);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

.upload-container-polished:hover {
    border-color: var(--accent);
    background: var(--gray-100);
}

.btn-upload-polished {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-upload-polished:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

.btn-generate-polished {
    background: linear-gradient(135deg, var(--accent) 0%, #ff6b6b 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn-generate-polished::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-generate-polished:hover::before {
    left: 100%;
}

.btn-generate-polished:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 0, 0, 0.4);
}

.btn-generate-polished:active {
    transform: translateY(0);
}

.generate-section {
    margin-top: 32px;
    text-align: center;
}

.label-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    color: var(--gray-400);
}

.select-polished {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--secondary);
    color: var(--primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.select-polished:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.input-polished {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--secondary);
    color: var(--primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.input-polished:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.1);
}

.analysis-results {
    background: var(--gray-100);
    border-radius: var(--radius);
    margin: 16px;
    margin-bottom: 0;
    border: 1px solid var(--border);
}

.analysis-content {
    font-size: 12px;
    line-height: 1.5;
    color: var(--primary);
}

.analysis-item {
    margin-bottom: 8px;
    padding: 8px;
    background: var(--secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.analysis-label {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

.analysis-value {
    color: var(--primary);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-polished {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--gray-200);
    border-radius: 2px;
    outline: none;
}

.slider-polished::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--primary);
    cursor: pointer;
    border: 2px solid var(--secondary);
    transition: var(--transition);
}

.slider-polished::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-value-display {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    min-width: 35px;
    text-align: right;
}

.segmented-control {
    display: flex;
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    background-color: var(--secondary);
    cursor: pointer;
    transition: var(--transition);
    border-right: 1px solid var(--border);
}

.segmented-control label:last-child {
    border-right: none;
}

.segmented-control label:hover {
    background-color: var(--gray-100);
}

.segmented-control input[type="radio"]:checked + label {
    background-color: var(--primary);
    color: var(--secondary);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.upload-container-polished {
    margin-top: 4px;
}

.btn-upload-polished {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--secondary);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-upload-polished:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-upload-polished svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.image-preview-grid-polished {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.video-preview-zone-polished {
    margin-top: 12px;
}

.btn-generate-polished {
    width: 100%;
    margin-top: auto; /* Pushes to the bottom */
    padding: 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-generate-polished:hover:not(:disabled) {
    opacity: 0.85;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-generate-polished svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
    transition: transform 0.3s ease;
}

.btn-generate-polished:hover svg {
    transform: translateX(4px);
}
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
}

.image-preview-item .remove-image:hover {
    background: #cc0000;
}

/* Mobile: Adjust image preview grid */
@media (max-width: 768px) {
    .image-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
    }
    
    .image-preview-item {
        width: 60px;
        height: 60px;
    }
    
    .image-preview-item .remove-image {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
}

.result-video {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    background: var(--secondary);
    position: relative;
}

/* Hide all video overlays and loading indicators */
.result-video::-webkit-media-controls-overlay-play-button,
.result-video::-webkit-media-controls-loading-panel,
.result-video::-webkit-media-text-track-container {
    display: none !important;
}

video[poster] {
    object-fit: cover;
}

/* Remove any loading text overlays */
video::cue {
    display: none !important;
}

/* Utilities */
.hidden {
    display: none !important;
}
