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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f1117;
    color: #e0e0e0;
    line-height: 1.6;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a2d3a;
}

header h1 {
    font-size: 1.5rem;
    color: #fff;
}

.health-status {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
}

.health-status .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.health-status .status-dot.ok { background: #4caf50; }
.health-status .status-dot.err { background: #f44336; }

.card {
    background: #1a1d2e;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid #2a2d3a;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: #fff;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #aaa;
    font-size: 0.9rem;
}

textarea, input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: #0f1117;
    border: 1px solid #2a2d3a;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: #5b6eea;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

.btn-primary {
    background: #5b6eea;
    color: #fff;
}
.btn-primary:hover { background: #4a5cd8; }
.btn-primary:disabled { background: #3a3d4a; cursor: not-allowed; }

.btn-secondary {
    background: #2a2d3a;
    color: #ccc;
}
.btn-secondary:hover { background: #353849; }

.btn-remove {
    background: none;
    border: none;
    color: #f44336;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* Aspect ratio selector */
.aspect-ratio-selector {
    display: flex;
    gap: 12px;
}

.ratio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: #0f1117;
    border: 2px solid #2a2d3a;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.ratio-option:hover { border-color: #5b6eea; }
.ratio-option.selected { border-color: #5b6eea; background: #1a1d3a; }

.ratio-option input[type="radio"] { display: none; }

.ratio-option span {
    font-size: 0.85rem;
    font-weight: 500;
}

.ratio-preview {
    background: #5b6eea;
    border-radius: 3px;
    opacity: 0.7;
}

.ratio-preview.landscape {
    width: 48px;
    height: 27px;
}

.ratio-preview.portrait {
    width: 27px;
    height: 48px;
}

/* Reference images */
.ref-image-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: #0f1117;
    border-radius: 8px;
}

.ref-image-item input[type="file"] {
    font-size: 0.85rem;
    color: #aaa;
}

.ref-preview {
    grid-column: 1 / -1;
}

.ref-preview img {
    max-height: 80px;
    border-radius: 4px;
    margin-top: 4px;
}

/* Generated references */
.gen-ref-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: start;
    margin-bottom: 8px;
    padding: 8px;
    background: #0f1117;
    border-radius: 8px;
}

.gen-ref-item textarea {
    width: 100%;
    padding: 8px 10px;
    background: #1a1d2e;
    border: 1px solid #2a2d3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

.gen-ref-item textarea:focus {
    outline: none;
    border-color: #5b6eea;
}

/* Progress */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #2a2d3a;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #5b6eea;
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.85rem;
    color: #aaa;
    min-width: 40px;
    text-align: right;
}

/* Status */
.status-label {
    font-size: 0.9rem;
    margin-bottom: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
}

.status-label.generating_refs { background: #0d47a1; color: #82b1ff; }
.status-label.analyzing { background: #1a237e; color: #90caf9; }
.status-label.generating_images { background: #1b5e20; color: #a5d6a7; }
.status-label.generating_video { background: #e65100; color: #ffcc80; }
.status-label.assembling { background: #4a148c; color: #ce93d8; }
.status-label.completed { background: #1b5e20; color: #4caf50; }
.status-label.failed { background: #b71c1c; color: #ef9a9a; }
.status-label.pending { background: #2a2d3a; color: #aaa; }

.badge {
    font-size: 0.8rem;
    color: #888;
    font-weight: normal;
}

/* Scenes */
.scene-item {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #0f1117;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.scene-item .scene-status {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
}

.scene-transition-badge {
    font-size: 0.85rem;
    width: 20px;
    text-align: center;
    opacity: 0.7;
    flex-shrink: 0;
}
.scene-transition-badge.independent { color: #ffb74d; }
.scene-transition-badge.chain { color: #80cbc4; }

.scene-status.pending { background: #2a2d3a; color: #888; }
.scene-status.image_generating,
.scene-status.video_generating { background: #1a237e; color: #90caf9; }
.scene-status.image_done { background: #1b5e20; color: #a5d6a7; }
.scene-status.video_done { background: #1b5e20; color: #4caf50; }
.scene-status.failed { background: #b71c1c; color: #ef9a9a; }

/* Result */
#result-container {
    margin-top: 16px;
    text-align: center;
}

#result-video {
    width: 100%;
    max-height: 450px;
    border-radius: 8px;
    background: #000;
    margin-bottom: 12px;
}

.error-message {
    padding: 12px;
    background: #2d1111;
    border: 1px solid #b71c1c;
    border-radius: 8px;
    color: #ef9a9a;
    margin-top: 12px;
}

/* History */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #0f1117;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:hover { background: #1e2133; }

.history-item .history-meta {
    font-size: 0.85rem;
    color: #888;
}

.hidden { display: none !important; }
