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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #475569;
    --success: #22c55e;
    --error: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

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

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Navigation */
.nav-links {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--bg-tertiary);
}

.nav-links a.active {
    color: var(--primary);
    background: var(--bg-secondary);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-area p {
    margin-bottom: 0.5rem;
}

.upload-area .hint {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Video Preview */
.video-preview {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
}

.video-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    display: inline-block;
    max-width: 100%;
}

.video-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.video-preview video {
    max-width: 100%;
    max-height: 50vh;
    display: block;
    border-radius: 8px;
}

/* Caption Preview Overlay */
.caption-preview {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 10px 20px;
    pointer-events: none;
    z-index: 10;
}

/* Position classes */
.caption-preview.pos-bottom_center,
.caption-preview.pos-bottom_left,
.caption-preview.pos-bottom_right {
    bottom: 40px;
}

.caption-preview.pos-middle_center,
.caption-preview.pos-middle_left,
.caption-preview.pos-middle_right {
    top: 50%;
    transform: translateY(-50%);
}

.caption-preview.pos-top_center,
.caption-preview.pos-top_left,
.caption-preview.pos-top_right {
    top: 20px;
}

.caption-preview.pos-bottom_left,
.caption-preview.pos-middle_left,
.caption-preview.pos-top_left {
    justify-content: flex-start;
}

.caption-preview.pos-bottom_right,
.caption-preview.pos-middle_right,
.caption-preview.pos-top_right {
    justify-content: flex-end;
}

.preview-text {
    display: inline-block;
    padding: 4px 8px;
    text-align: center;
    line-height: 1.4;
    max-width: 90%;
    word-wrap: break-word;
    /* Default styles - will be overridden by JS */
    font-family: Arial, sans-serif;
    font-size: 24px;
    color: #FFFFFF;
    text-shadow:
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Settings Section */
.settings-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.settings-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.setting-group select,
.setting-group input[type="number"] {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text);
    font-size: 1rem;
}

.setting-group select:focus,
.setting-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Color Settings */
.color-settings {
    margin-bottom: 1.5rem;
}

.color-settings h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.color-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.color-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-group label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.color-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

/* Additional Options */
.additional-options {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

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

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

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

/* Progress Section */
.progress-section {
    margin-top: 1.5rem;
}

.progress-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.progress-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Result Section */
.result-section {
    margin-top: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
}

.result-section h2 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--success);
}

.result-section video {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1rem;
}

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

.result-actions .btn {
    flex: 1;
}

/* Error Section */
.error-section {
    margin-top: 1.5rem;
}

.error-container {
    background: var(--bg-secondary);
    border: 1px solid var(--error);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.error-container h3 {
    color: var(--error);
    margin-bottom: 0.5rem;
}

.error-container p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .color-grid {
        flex-direction: column;
    }

    .result-actions {
        flex-direction: column;
    }
}
