:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-hover: #1e1e3a;
    --border-color: #2a2a4a;
    --border-light: #3a3a5a;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a8a;
    --accent-primary: #7c3aed;
    --accent-secondary: #2563eb;
    --accent-gradient: linear-gradient(135deg, #7c3aed, #2563eb);
    --accent-hover: #6d28d9;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(37, 99, 235, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    font-size: 14px;
    color: var(--text-muted);
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

/* Step Indicator */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 40px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.step-item:hover {
    background: var(--bg-hover);
}

.step-item.active .step-number {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
}

.step-item.completed .step-number {
    background: var(--success);
    color: white;
}

.step-item.completed .step-number::after {
    content: '\2713';
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.step-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.step-item.active .step-label {
    color: var(--text-primary);
}

.step-line {
    width: 32px;
    height: 2px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Main Content */
.main-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    padding: 40px;
    min-height: 500px;
}

.step-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.step-panel.active {
    display: block;
}

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

.panel-header {
    margin-bottom: 32px;
}

.panel-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.panel-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Config Cards */
.config-unified {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}

.config-card-wide {
    width: 100%;
}

.config-fields-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.field-group-flex2 {
    flex: 2;
}

.field-group-flex3 {
    flex: 3;
}

.model-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.config-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.config-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.config-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gateway-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.vision-icon {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}

.image-icon {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
}

.video-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.config-card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.config-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.field-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-group input,
.field-group select,
.field-group textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.field-group input::placeholder,
.field-group textarea::placeholder {
    color: var(--text-muted);
}

.input-with-toggle {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-toggle input {
    width: 100%;
    padding-right: 40px;
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.toggle-visibility:hover {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

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

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 12px 16px;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.config-actions,
.step-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* Upload Area */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.03);
}

.upload-area.dragover {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.08);
}

.upload-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.upload-placeholder svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.upload-placeholder p {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.upload-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
}

.figure-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.figure-info h3 {
    font-size: 16px;
    font-weight: 600;
}

.info-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.info-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Recognition Layout */
.recognition-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 32px;
}

.recognition-figure {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    aspect-ratio: 3/4;
}

.recognition-figure img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recognition-result {
    min-height: 400px;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.result-section p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 0;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-state p {
    font-size: 15px;
    color: var(--text-secondary);
}

.loading-state span {
    font-size: 13px;
    color: var(--text-muted);
}

/* Scene Selection */
.scene-selection {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.scene-selection-header {
    margin-bottom: 20px;
}

.scene-selection-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.scene-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.scene-recommended {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.scene-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.scene-card:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.scene-card.selected {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.06);
}

.scene-card-check {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 4px;
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    transition: var(--transition);
    color: transparent;
}

.scene-card.selected .scene-card-check {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.scene-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scene-card-title {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-weight: 500;
}

.scene-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

.scene-card.selected .scene-card-title {
    color: var(--text-primary);
}

.scene-card-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
    border-radius: 4px;
    font-weight: 500;
}

.scene-card-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
    transition: var(--transition);
}

.scene-card-remove:hover {
    color: var(--error);
}

.scene-custom {
    margin-bottom: 20px;
}

.scene-custom h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.scene-custom-input-area {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.scene-custom-input-area textarea {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: var(--transition);
}

.scene-custom-input-area textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    white-space: nowrap;
}

.scene-custom-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.scene-summary {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 12px 0;
}

.scene-summary strong {
    color: var(--accent-primary);
    font-size: 15px;
}

/* Background Grid */
.background-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.bg-card {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    aspect-ratio: 21/9;
}

.bg-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.bg-card.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.bg-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-card .bg-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    font-size: 13px;
    color: white;
}

.bg-card .check-mark {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.bg-card.selected .check-mark {
    display: flex;
}

/* Video Generation */
.video-generation {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.video-preview-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.selected-bg-preview {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    aspect-ratio: 21/9;
}

.selected-bg-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-label {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    color: white;
}

.video-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.video-options h4 {
    font-size: 15px;
    font-weight: 600;
}

.video-option-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.video-result {
    margin-top: 16px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 12px;
}

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

.progress-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.video-player {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.video-player video {
    width: 100%;
    display: block;
    aspect-ratio: 21/9;
    background: black;
}

.video-actions {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: slideIn 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(--error); }
.toast.warning { border-left: 3px solid var(--warning); }

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

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

/* Responsive */
@media (max-width: 768px) {
    #app {
        padding: 16px;
    }

    .main-content {
        padding: 24px;
    }

    .step-indicator {
        flex-wrap: wrap;
        gap: 8px;
    }

    .step-line {
        display: none;
    }

    .step-label {
        display: none;
    }

    .config-grid,
    .model-cards-grid {
        grid-template-columns: 1fr;
    }

    .config-fields-row {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-section {
        grid-template-columns: 1fr;
    }

    .recognition-layout {
        grid-template-columns: 1fr;
    }

    .video-preview-area {
        grid-template-columns: 1fr;
    }

    .video-option-grid {
        grid-template-columns: 1fr;
    }
}
