/* ---- Story Editor ---- */
.story-editor {
    width: 100%; min-height: 200px; padding: 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: white;
    font-size: 14px; line-height: 1.8; resize: vertical; transition: var(--transition);
}
.story-editor:focus { outline: none; border-color: #8B5CF6; box-shadow: 0 0 0 3px rgba(139,92,246,0.1); }

/* ---- Step Indicator ---- */
.step-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.step-dot { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.step-dot .sd-num { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.step-dot.active .sd-num { background: var(--grad); color: white; border-color: transparent; }
.step-dot.active { color: var(--text-1); }
.step-dot.done .sd-num { background: var(--c-success); color: white; border-color: transparent; }
.step-line { flex: 1; height: 2px; background: var(--bg-card); border-radius: 1px; }
.step-line.active { background: var(--grad); }

/* ---- Create Step 1: two-column layout (Photo = flexible main, Scene = side) ---- */
.create-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.create-layout {
    display: grid;
    /* Photo panel is the main flexible area (users have many photos); scene is the side column */
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 16px;
    align-items: stretch;
}
@media (max-width: 1080px) {
    .create-layout { grid-template-columns: 1fr; }
}

/* Step indicator */
.create-steps {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}
.c-step {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-sub); text-decoration: none;
}
.c-step.active { color: var(--text); }
.c-step.done { color: var(--text); cursor: pointer; }
.c-step.done:hover .c-step-dot { box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25); }
.c-step-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    font-size: 15px; flex-shrink: 0;
}
.c-step.active .c-step-dot, .c-step.done .c-step-dot {
    background: var(--grad); border: none; color: #fff;
    box-shadow: 0 4px 18px rgba(124, 58, 237, 0.45);
}
.c-step-txt { display: flex; flex-direction: column; line-height: 1.25; }
.c-step-txt b { font-size: 13px; }
.c-step-txt { font-size: 11px; }
.c-step-line { flex: 1; height: 2px; background: var(--border); border-radius: 1px; min-width: 30px; }
.c-step-line.on { background: var(--grad); }

/* Scene panel next-step zone: big always-on button, vertically centered in the right column */
.scene-next-zone {
    flex: 1 1 auto;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; min-height: 150px; padding: 14px 2px 4px;
}
.next-status { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
.ns-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.04); color: var(--text-3);
    border: 1px solid var(--border);
    max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.ns-chip.ok {
    background: rgba(16,185,129,0.10); color: #34D399;
    border-color: rgba(52,211,153,0.35);
}
.ns-chip.miss {
    background: rgba(245,158,11,0.10); color: #FBBF24;
    border-color: rgba(251,191,36,0.35);
}
.next-btn-big {
    width: 100%; height: 54px;
    font-size: 16px; font-weight: 700;
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(124,58,237,0.45);
    white-space: nowrap;
}
.next-btn-big:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(124,58,237,0.55); }
.next-hint { color: var(--text-3); text-align: center; }
/* Flash highlight when Next is clicked without a selection */
@keyframes flashNeed {
    0%, 100% { box-shadow: none; }
    25%, 75% { box-shadow: 0 0 0 3px rgba(251,191,36,0.55); }
}
.flash-need { animation: flashNeed 0.9s ease 2; border-radius: var(--radius); }

.create-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.panel-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-title { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; }
.panel-step {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--grad); color: #fff;
    font-size: 11px; font-weight: 700; margin-right: 8px; flex-shrink: 0;
}

/* Desktop: panels fill the remaining viewport height, lists scroll inside */
@media (min-width: 1081px) {
    .create-wrap { height: calc(100vh - var(--topbar-h) - 48px); }
    .create-layout { flex: 1; min-height: 0; }
    .scene-panel, .photo-panel { height: 100%; }
    .photo-groups { flex: 1; max-height: none; min-height: 0; }
    /* Scene list keeps its natural height (fixed set of scenes, scrolls if long);
       remaining space centers the Next button in the middle of the right column. */
    .scene-grid { flex: 0 1 auto; max-height: 42%; min-height: 150px; }
    .custom-scene { flex-shrink: 0; }
    #customInput { flex-shrink: 0; }
}
/* Below desktop: photo panel gets a viewport-relative height so the photo area
   stretches and the status line stays pinned to the card bottom. */
@media (max-width: 1080px) {
    .photo-panel { height: clamp(380px, calc(100vh - var(--topbar-h) - 56px), 680px); }
    .photo-groups { flex: 1; min-height: 0; }
}
.create-preview::-webkit-scrollbar { width: 4px; }
.create-preview::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Photo groups + grid in create panel
   No max-height cap: the container is stretched by flex:1 to fill the panel's
   remaining space, so the grid adapts and only scrolls when images truly overflow. */
.photo-groups {
    display: flex; flex-direction: column;
    flex: 1; min-height: 0;
    overflow-y: auto; padding-right: 4px;
}
.photo-groups::-webkit-scrollbar { width: 4px; }
.photo-groups::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.photo-group {
    display: flex; flex-direction: column;
    flex: 0 0 auto;
}
/* The last expanded group stretches to fill remaining card height (its rows grow
   with it); earlier groups stay at natural height so headers never jump. */
.photo-group.grow { flex: 1 1 auto; }
/* Natural-flow stacking: each group is exactly its content height, so the system
   group header always sits right below the user group's last row. No flex-grow
   distribution -> expanding/collapsing never jumps; parent scrolls when needed. */
.photo-group-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 2px 6px; cursor: pointer; user-select: none; flex-shrink: 0;
}
.photo-group-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-2);
}
.photo-group-title i { color: #8B5CF6; }
.photo-group-arrow { font-size: 12px; color: var(--text-3); transition: var(--transition); }
.photo-group.collapsed .photo-group-arrow { transform: rotate(-90deg); }
.photo-group.collapsed .photo-grid { display: none; }
.photo-grid {
    /* Rows size to the square thumbnails (auto): a stretched .grow group used
       to blow 1fr rows up to ~160px, squeezing images into 83px squares with
       ~50px dead gaps between rows. auto + align-content:start keeps rows
       tight at the top and parks the leftover space at the bottom. */
    flex: 1;
    display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: auto; gap: 10px;
    align-content: start;
}
@media (max-width: 768px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
.photo-item {
    position: relative; aspect-ratio: 1; border-radius: var(--radius);
    overflow: hidden; cursor: pointer;
    border: 2px solid transparent; transition: var(--transition);
}
.photo-item:hover { transform: scale(1.03); }
.photo-item.selected { border-color: #8B5CF6; box-shadow: 0 0 0 2px rgba(139,92,246,0.2); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.pi-badge {
    position: absolute; top: 4px; left: 4px;
    padding: 2px 5px; border-radius: 4px;
    background: rgba(0,0,0,0.6); font-size: 9px; color: #F59E0B;
}
.pi-check {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #8B5CF6; color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
}

/* Step-1 v3 photo cards: clear selected state + check badge */
@keyframes checkPop { from { transform: scale(0); } to { transform: scale(1); } }
.photo-card {
    position: relative; aspect-ratio: 1; border-radius: var(--radius);
    overflow: hidden; cursor: pointer;
    border: 2px solid transparent; transition: var(--transition);
    background: var(--bg-input);
}
.photo-card:hover { transform: scale(1.03); }
.photo-card.selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139,92,246,0.25), 0 6px 18px rgba(139,92,246,0.35);
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-check {
    position: absolute; top: 4px; right: 4px; z-index: 2;
    width: 18px; height: 18px; border-radius: 50%;
    background: #8B5CF6; color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.photo-card.selected .photo-check { display: flex; animation: checkPop .22s ease; }

.upload-inline .upload-zone { padding: 16px; margin-bottom: 10px; }
.upload-inline .upload-icon { font-size: 24px; margin-bottom: 4px; }

.photo-load-more {
    color: var(--text-3); cursor: pointer; font-size: 12px;
    padding: 8px; transition: var(--transition);
}
.photo-load-more:hover { color: #8B5CF6; }
.scroll-area { min-height: 200px; }
.scroll-area .mat-grid { margin-bottom: 20px; }

/* Scene grid in create panel */
/* Scene panel is now the main area: rich vertical cards with example images */
.scene-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 10px;
    align-content: start;
    flex: 0 1 auto; min-height: 150px;
    overflow-y: auto; padding-right: 4px;
}
.scene-grid::-webkit-scrollbar { width: 4px; }
.scene-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
@media (max-width: 768px) {
    .scene-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}
.scene-item {
    display: flex; flex-direction: column;
    border-radius: var(--radius);
    border: 2px solid transparent; cursor: pointer;
    transition: var(--transition); position: relative;
    overflow: hidden; background: rgba(255,255,255,0.02);
}
.scene-item:hover { background: rgba(255,255,255,0.05); transform: translateY(-2px); }
.scene-item.selected {
    border-color: #8B5CF6;
    background: rgba(139,92,246,0.08);
}
.si-img {
    width: 100%; aspect-ratio: 16/10; flex-shrink: 0;
    overflow: hidden; background: var(--bg-input);
    border-radius: calc(var(--radius) - 2px);
}
.si-img img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition); }
.scene-item:hover .si-img img { transform: scale(1.05); }
.si-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--text-3);
}
.si-info { padding: 10px 12px 12px; }
.si-name { font-size: 13px; font-weight: 600; }
.si-desc {
    font-size: 11px; color: var(--text-3); line-height: 1.35; margin-top: 3px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.si-check {
    position: absolute; top: 8px; right: 8px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #8B5CF6; color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Step-1 v3 scene cards (right column): clear selected state + check badge */
.scene-card {
    display: flex; flex-direction: column;
    border-radius: var(--radius);
    border: 2px solid transparent; cursor: pointer;
    transition: var(--transition); position: relative;
    overflow: hidden; background: rgba(255,255,255,0.02);
}
.scene-card:hover { background: rgba(255,255,255,0.05); transform: translateY(-2px); }
.scene-card.selected {
    border-color: #8B5CF6; background: rgba(139,92,246,0.08);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.18), 0 8px 20px rgba(139,92,246,0.25);
}
.scene-img {
    position: relative; width: 100%; aspect-ratio: 16/10; flex-shrink: 0;
    overflow: hidden; background: var(--bg-input);
}
.scene-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: var(--transition); }
.scene-card:hover .scene-img img { transform: scale(1.05); }
.scene-ph {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--text-3);
}
.scene-body { padding: 7px 10px 9px; }
.scene-name { font-size: 13px; font-weight: 600; }
.scene-desc {
    font-size: 11px; color: var(--text-3); line-height: 1.35; margin-top: 3px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.scene-check {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 26px; height: 26px; border-radius: 50%;
    background: #8B5CF6; color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.scene-card.selected .scene-check { display: flex; animation: checkPop .22s ease; }
.custom-scene { margin-top: 12px; flex-shrink: 0; }

/* Custom Scene */
.custom-scene-item { border-style: dashed; border-color: rgba(139,92,246,0.3); }
.custom-scene-item.selected { border-style: solid; }
.custom-scene-img { background: rgba(139,92,246,0.1) !important; }
.custom-scene-input { border-top: 1px solid var(--border); padding-top: 12px; }

/* Preview panel */
.preview-img {
    position: relative; border-radius: var(--radius);
    overflow: hidden; aspect-ratio: 4/3;
    background: var(--bg-input);
}
.preview-img img { width: 100%; height: 100%; object-fit: cover; }
.preview-scene-tag {
    position: absolute; top: 10px; left: 10px;
    padding: 4px 10px; border-radius: 20px;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
    font-size: 11px; font-weight: 600;
}
.preview-empty {
    aspect-ratio: 4/3; border-radius: var(--radius);
    background: var(--bg-input);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-3);
}
.preview-empty i { font-size: 32px; margin-bottom: 8px; }
.preview-empty p { font-size: 12px; }

/* Create panel head hint */
.panel-hint { font-size: 11px; color: var(--text-3); }
@media (max-width: 768px) { .panel-hint { display: none; } }

/* ---- Generate Step 2 page ---- */
.gen-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}
@media (max-width: 1080px) {
    .gen-layout { grid-template-columns: 1fr; }
}
.gen-main {
    display: flex; flex-direction: column;
    gap: 14px; min-width: 0;
    overflow-y: auto; padding-right: 4px;
}
.gen-main::-webkit-scrollbar { width: 4px; }
.gen-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.gen-side { min-width: 0; display: flex; flex-direction: column; }

/* Selection summary */
.gen-summary {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}
.gs-photo {
    width: 54px; height: 54px; border-radius: 10px;
    object-fit: cover; border: 1px solid var(--border);
}
.gs-meta { display: flex; flex-direction: column; min-width: 0; }
.gs-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; }
.gs-scene {
    font-size: 14px; font-weight: 600; margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: flex; align-items: center; gap: 7px;
}
.gs-scene i { color: var(--primary); flex-shrink: 0; }
.gs-story-state { display: flex; align-items: center; gap: 7px; margin-top: 6px; min-width: 0; }
.sdot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: #FBBF24; animation: sdotPulse 1.2s ease infinite;
}
.sdot.ok { background: #34D399; animation: none; }
.sdot.warn { background: #FBBF24; }
.sdot.err { background: #F87171; animation: none; }
@keyframes sdotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Generic generate card */
.gen-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    flex-shrink: 0;
}
.gc-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.gc-title {
    font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 8px;
}

/* Story */
.story-box { min-height: 90px; }
.story-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 90px; color: var(--text-3); font-size: 13px;
    border: 1px dashed var(--border); border-radius: var(--radius);
    background: rgba(255,255,255,0.02);
}
.story-loading i { margin-right: 8px; }
.story-loading .bi-arrow-repeat { animation: spin 1s linear infinite; }
.story-loading.t-err { color: #f87171; }
.story-editor {
    width: 100%; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-1); font-size: 13.5px; line-height: 1.7;
    padding: 12px 14px; resize: vertical; outline: none;
}
.story-editor:focus { border-color: var(--primary); }

/* Output type cards */
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .type-cards { grid-template-columns: 1fr; } }
.type-card {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    gap: 10px; padding: 26px 16px 22px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer; user-select: none;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.type-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.type-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(124,58,237,0.14), rgba(6,182,212,0.08));
    box-shadow: 0 6px 24px rgba(124,58,237,0.22);
}
.type-card.disabled { opacity: 0.45; cursor: not-allowed; }
.tc-icon {
    width: 58px; height: 58px; border-radius: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06); font-size: 27px; color: var(--primary);
}
.type-card.selected .tc-icon { background: var(--grad); color: #fff; }
.tc-body { display: flex; flex-direction: column; min-width: 0; }
.tc-body b { font-size: 15px; }
.tc-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tc-check {
    position: absolute; top: 10px; right: 10px;
    width: 22px; height: 22px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: var(--grad); color: #fff; font-size: 12px;
}
.type-card.selected .tc-check { display: flex; }

/* Spec pills (video resolution) */
.spec-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    margin: 4px 0 10px;
    display: flex; align-items: center; gap: 10px;
}
.spec-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.spec-pill {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 11px 24px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 12px;
    color: var(--text-1); cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.spec-pill b { font-size: 14px; font-weight: 600; }
.spec-pill:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.34);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.spec-pill.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(124,58,237,0.16), rgba(6,182,212,0.09));
    box-shadow: 0 4px 18px rgba(124,58,237,0.2);
}
.spec-pill b { font-size: 14px; }
.spec-pill span { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* Aspect ratio picker: frame preview + label so the shape is obvious */
.ratio-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ratio-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 11px 7px 8px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 11px;
    color: var(--text-1); cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.ratio-pill:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.34);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.ratio-pill.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(124,58,237,0.16), rgba(6,182,212,0.09));
    box-shadow: 0 4px 18px rgba(124,58,237,0.2);
}
.rp-box {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
}
.rp-box i {
    display: block;
    border: 1.5px solid var(--text-3);
    border-radius: 3px;
    background: rgba(255,255,255,0.06);
    transition: border-color 0.2s, background 0.2s;
}
.ratio-pill.selected .rp-box i {
    border-color: var(--primary);
    background: rgba(124,58,237,0.28);
}
.rp-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.rp-txt b { font-size: 12.5px; font-weight: 600; }
.rp-txt small { font-size: 10.5px; color: var(--text-3); }

/* Duration slider */
.dur-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; padding: 3px 10px;
    background: var(--grad); color: #fff;
    border-radius: 999px; font-size: 12px; font-weight: 700;
}
.dur-row { display: flex; align-items: center; gap: 14px; }
.dur-minmax { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.dur-slider {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 8px; border-radius: 4px; outline: none;
    /* Fallback track; JS paints a purple->cyan progress gradient over it */
    background: rgba(255,255,255,0.14);
    cursor: pointer;
}
.dur-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; border: 4px solid #7C3AED;
    box-shadow: 0 2px 12px rgba(124,58,237,0.55);
    cursor: grab;
}
.dur-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }
.dur-slider::-moz-range-thumb {
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff; border: 4px solid #7C3AED;
    box-shadow: 0 2px 12px rgba(124,58,237,0.55);
    cursor: grab;
}

/* Resolution cards (image) */
.res-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.res-card {
    display: flex; align-items: center; justify-content: flex-start;
    padding: 12px 16px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 12px;
    color: var(--text-1); cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.res-card:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.34);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.res-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(124,58,237,0.16), rgba(6,182,212,0.09));
    box-shadow: 0 4px 18px rgba(124,58,237,0.2);
}
.res-card b { font-size: 13.5px; }

/* Side summary */
.side-photo {
    width: 100%; aspect-ratio: 4/3; object-fit: cover;
    border-radius: var(--radius); border: 1px solid var(--border);
    display: block;
}
.side-scene {
    font-size: 13px; font-weight: 600; margin: 12px 0 4px;
    display: flex; align-items: center; gap: 7px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-scene i { color: var(--primary); flex-shrink: 0; }
.spec-rows { margin: 10px 0; border-top: 1px solid var(--border); }
.spec-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.spec-row span { color: var(--text-3); }
.spec-row b { font-weight: 600; }

/* Cost + balance */
.cost-panel {
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(124,58,237,0.24), rgba(6,182,212,0.13));
    border: 1px solid rgba(139,92,246,0.5);
    border-radius: var(--radius);
    box-shadow: 0 4px 22px rgba(124,58,237,0.2), inset 0 1px 0 rgba(255,255,255,0.08);
}
.cost-label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: rgba(255,255,255,0.72); font-weight: 600;
    text-transform: uppercase; letter-spacing: 1.5px;
}
.cost-label i { color: #22D3EE; font-size: 12px; }
.cost-num {
    font-size: 34px; font-weight: 800; line-height: 1.15;
    background: linear-gradient(90deg, #A78BFA, #22D3EE);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(124,58,237,0.5));
    display: inline-flex; align-items: baseline; gap: 8px;
}
.cost-num small {
    font-size: 13px; font-weight: 600; letter-spacing: 0.5px;
    -webkit-text-fill-color: rgba(255,255,255,0.62);
}
.cost-flash { animation: costPulse 0.5s ease; }

/* v80: per-feature discount display inside Total Cost / Cost cards */
.cost-orig {
    font-size: 0.6em; font-weight: 700;
    -webkit-text-fill-color: rgba(255,255,255,0.45); color: rgba(255,255,255,0.45);
    text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.75);
    text-decoration-thickness: 2px;
}
.cost-off {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px;
    background: linear-gradient(135deg, rgba(255,176,32,0.22), rgba(255,94,58,0.26));
    border: 1px solid rgba(255,176,32,0.6);
    color: #FFC24D; font-size: 11px; font-weight: 800; letter-spacing: 0.4px;
    -webkit-text-fill-color: #FFC24D; white-space: nowrap;
    animation: offPulse 2.4s ease-in-out infinite;
}
.cost-off i { font-size: 10px; }
.cost-orig[hidden], .cost-off[hidden] { display: none; }
@keyframes offPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255,176,32,0); }
    50% { box-shadow: 0 0 14px rgba(255,176,32,0.45); }
}
/* Compact scale inside the smaller edit-page Cost rows */
.ie-cost-row .cost-orig { font-size: 12px; font-weight: 600; }
.ie-cost-row .cost-off { font-size: 10.5px; padding: 1px 8px; }
@keyframes costPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.18); filter: brightness(1.4) drop-shadow(0 2px 10px rgba(124,58,237,0.5)); }
    100% { transform: scale(1); }
}
.bal-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px; font-size: 13px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
}
.bal-val { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; color: #fff; }
.bal-val i { color: var(--accent); }
.bal-warn {
    margin-top: 8px; color: #f59e0b; font-size: 12.5px;
}
.bal-warn a { color: var(--accent); }
.gen-btn { margin-top: 12px; padding: 12px; font-size: 15px; }
.gen-btn:disabled { opacity: 0.5; }
/* Selections still missing: keep the button fully coloured and clickable,
   only hint with a slightly softer glow (clicking shows what is needed). */
.gen-btn-wait { box-shadow: none; }
.gen-btn-wait:hover { box-shadow: 0 10px 26px rgba(124,58,237,0.45); }

/* ==========================================================================
   Create page v4 - single page (photo + library on the left, generate on the right)
   All new selectors use the cr- prefix so the legacy step-1/step-2 rules above
   stay untouched.
   ========================================================================== */
.cr-wrap { padding: 20px 0 24px; }
.cr-layout { display: grid; grid-template-columns: minmax(0,1fr) 384px; gap: 18px; align-items: start; }
@media (max-width: 1180px) { .cr-layout { grid-template-columns: 1fr; } }

.cr-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    display: flex; flex-direction: column; min-width: 0;
}

/* ---- Left: my photos ---- */
.cr-photos { overflow-y: auto; padding-right: 4px; min-height: 120px; }
.cr-photos::-webkit-scrollbar, .cr-lib::-webkit-scrollbar, .cr-gen::-webkit-scrollbar { width: 4px; }
.cr-photos::-webkit-scrollbar-thumb, .cr-lib::-webkit-scrollbar-thumb, .cr-gen::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1); border-radius: 2px;
}
/* Tiles match the Pick a Scene card width (152px track) */
.cr-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    grid-auto-rows: auto; gap: 10px; align-content: start; align-items: start;
}
/* Photo tiles: height follows the image itself (no aspect-ratio, no
   object-fit) so every photo is fully visible - heads never get cropped. */
.cr-tile {
    position: relative; border-radius: var(--radius);
    overflow: hidden; cursor: pointer; background: var(--bg-input);
    border: 2px solid transparent; transition: var(--transition);
}
/* Upload card carries no image: keep its fixed 4/3 box */
.cr-tile.cr-up { aspect-ratio: 4/3; }
.cr-tile:hover { transform: translateY(-2px); z-index: 1; }
.cr-tile img { width: 100%; height: auto; display: block; }
.cr-tile.selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 2px rgba(139,92,246,0.28), 0 4px 12px rgba(139,92,246,0.34);
}
.cr-tile .cr-ck {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    width: 21px; height: 21px; border-radius: 50%;
    background: #8B5CF6; color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 12px; border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 7px rgba(0,0,0,0.45);
}
.cr-tile.selected .cr-ck { display: flex; animation: checkPop .2s ease; }
/* "No person" badge on photo tiles (person detection result) */
.cr-flag {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 7px; border-radius: 20px;
    background: rgba(17, 24, 39, 0.78); color: #FBBF24;
    font-size: 10px; font-weight: 600; line-height: 1.5;
    backdrop-filter: blur(3px);
    box-shadow: 0 2px 7px rgba(0,0,0,0.4);
    pointer-events: none;
}
.cr-flag i { font-size: 10.5px; }
.cr-empty { padding: 22px 10px; text-align: center; font-size: 12.5px; color: var(--text-3); }
.cr-empty.sm { padding: 10px 10px; font-size: 11.5px; }
.photo-status { min-height: 18px; margin-top: 6px; font-size: 12px; }
.photo-status i { margin-right: 4px; }

/* Upload tile: first cell of the photo grid */
.cr-up {
    display: flex !important; align-items: center; justify-content: center;
    border: 2px dashed var(--border); color: var(--text-3);
    cursor: pointer; transition: var(--transition);
}
a.cr-up { text-decoration: none; color: var(--text-3); }
a.cr-up:hover { color: var(--primary); }
.cr-up:hover { border-color: var(--primary); color: var(--primary); background: rgba(139,92,246,0.06); }
.cr-up.drag { border-color: var(--accent); color: var(--accent); background: rgba(6,182,212,0.08); }
.cr-up-in { display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.cr-up-in i { font-size: 22px; }
.cr-up-in b { font-size: 12px; font-weight: 700; }
.cr-up-in em { font-size: 10px; font-style: normal; color: var(--text-3); }
.cr-up-busy { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; }
.cr-up.busy .cr-up-in { display: none; }
.cr-up.busy .cr-up-busy { display: flex; }
.cr-up-busy i { font-size: 22px; }
.cr-up-busy u { display: block; margin-top: 4px; font-size: 11px; text-decoration: none; color: var(--text-3); }
.cr-up.busy { border-color: var(--primary); border-style: solid; }
@keyframes crSpin { to { transform: rotate(360deg); } }
.cr-up-busy .spin { animation: crSpin 0.9s linear infinite; display: inline-block; }

/* ---- Left: library (scenes + sample photos, de-emphasised) ---- */
.cr-lib {
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid var(--border); flex-shrink: 0;
}
.cr-lib-head {
    display: flex; align-items: center; gap: 7px; margin-bottom: 10px;
    font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--text-3);
}
.cr-lib-head i { color: var(--primary); font-size: 12px; letter-spacing: 0; }
.cr-lib-head .cr-lib-count { margin-left: auto; letter-spacing: 0; font-weight: 600; }
.cr-sub { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.cr-sub .panel-step { width: 18px; height: 18px; font-size: 10px; margin-right: 2px; }

/* Scenes: compact cards, image + name (no inner scroll - cards wrap in rows) */
.cr-scenes {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 10px; align-content: start;
}
.cr-scene {
    position: relative; display: flex; flex-direction: column;
    border-radius: var(--radius); overflow: hidden; cursor: pointer;
    background: rgba(255,255,255,0.03); border: 2px solid transparent;
    transition: var(--transition);
}
.cr-scene:hover { background: rgba(255,255,255,0.06); transform: translateY(-2px); }
.cr-scene.selected {
    border-color: #8B5CF6; background: rgba(139,92,246,0.09);
    box-shadow: 0 0 0 2px rgba(139,92,246,0.2), 0 6px 16px rgba(139,92,246,0.22);
}
.cr-scene-img { position: relative; width: 100%; aspect-ratio: 4/3; background: var(--bg-input); overflow: hidden; }
.cr-scene-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: var(--transition); }
.cr-scene:hover .cr-scene-img img { transform: scale(1.06); }
.cr-scene-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text-3); }
.cr-scene-name { padding: 6px 8px 8px; font-size: 12px; font-weight: 600; line-height: 1.3; }
.cr-scene .cr-ck {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    width: 21px; height: 21px; border-radius: 50%;
    background: #8B5CF6; color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 12px; border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 2px 7px rgba(0,0,0,0.45);
}
.cr-scene.selected .cr-ck { display: flex; animation: checkPop .2s ease; }

.cr-custom { margin-top: 10px; }
.cr-custom textarea { font-size: 13px; resize: vertical; min-height: 92px; }
/* AI scene enhancer (Create custom scene): same look as Custom Make's Enhance */
.cr-enhance-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; }
.cr-enhance-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 999px; cursor: pointer;
    font-size: 12px; font-weight: 700; color: #fff;
    background: var(--grad); border: 1px solid rgba(139,92,246,.55);
    box-shadow: 0 3px 14px rgba(124,58,237,.35);
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.cr-enhance-btn:hover { background: var(--grad-hover); box-shadow: 0 4px 20px rgba(124,58,237,.5); transform: translateY(-1px); }
.cr-enhance-btn:disabled { opacity: .65; cursor: wait; transform: none; }
.cr-enhance-btn .spin { animation: crSpin .9s linear infinite; display: inline-block; }
.cr-enhance-hint { font-size: 11px; color: var(--text-3); }
/* Enhance button cost tag (mirrors the Total Cost panel: struck original + OFF badge + discounted credits) */
.enhance-cost {
    display: inline-flex; align-items: baseline; gap: 6px;
    font-size: 12px; font-weight: 700; color: var(--text-1);
}
.enhance-cost b {
    font-size: 14px; font-weight: 800; line-height: 1;
    background: linear-gradient(90deg, #A78BFA, #22D3EE);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.enhance-cost small { font-size: 10.5px; font-weight: 600; color: var(--text-3); letter-spacing: 0.3px; }
.enhance-cost .cost-orig { font-size: 12px; font-weight: 600; }
.enhance-cost .cost-off { font-size: 9.5px; padding: 1px 7px; }

/* Sample photos: same size as scene cards, no muted overlay */
.cr-samples-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.cr-samples {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 10px; align-content: start; align-items: start;
}

/* ---- Right: generate panel ----
   Flex column: the top part scrolls, the cost + Generate footer stays pinned so
   the button is always visible without scrolling. */
.cr-gen {
    gap: 0; padding: 14px; position: sticky; top: calc(var(--topbar-h) + 16px);
    height: calc(100vh - var(--topbar-h) - 62px);
    overflow: hidden;
}
/* Custom Make: short form - panel hugs its content, footer follows right after
   (no dead space between Duration and the cost / Generate card) */
.cr-gen.cr-gen-auto { height: auto; }
.cr-gen.cr-gen-auto .cr-gen-scroll { flex: 0 0 auto; overflow: visible; }
.cr-gen-scroll {
    flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px;
    display: flex; flex-direction: column; gap: 11px;
}
.cr-gen-scroll::-webkit-scrollbar { width: 4px; }
.cr-gen-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
@media (max-width: 1180px) {
    .cr-gen { position: static; height: auto; overflow: visible; }
    .cr-gen-scroll { overflow: visible; }
}

/* Summary: the two chosen items side by side */
.cr-sum { display: flex; flex-direction: column; gap: 8px; }
.cr-sum-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.cr-sum-cell { min-width: 0; text-align: center; }
.cr-sum-th {
    position: relative; width: 100%; aspect-ratio: 16/10; border-radius: var(--radius);
    overflow: hidden; background: var(--bg-input);
    border: 1px solid var(--border); display: block;
}
.cr-sum-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-sum-th .cr-sum-ph {
    width: 100%; height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    font-size: 18px; color: var(--text-3);
}
.cr-sum-th.filled { border-color: rgba(139,92,246,0.55); box-shadow: 0 0 0 1px rgba(139,92,246,0.25); }
.cr-sum-cap {
    margin-top: 4px; font-size: 11px; color: var(--text-3);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cr-sum-cap b { color: var(--text-1); font-weight: 600; }
.cr-sum-plus { font-size: 14px; color: var(--primary); opacity: 0.85; }
.cr-sum-state { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); }

.cr-sec { border-top: 1px solid var(--border); padding-top: 11px; }
.cr-sec-head {
    display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
    font-size: 12.5px; font-weight: 700;
}
.cr-sec-head .panel-step { width: 19px; height: 19px; font-size: 10px; margin-right: 2px; }
.cr-gen .type-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
.cr-gen .type-card { flex-direction: row; text-align: left; gap: 8px; padding: 9px 10px; }
.cr-gen .tc-icon { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }
.cr-gen .tc-body b { font-size: 12.5px; }
.cr-gen .tc-sub { font-size: 10.5px; }
.cr-gen .tc-check { top: 5px; right: 5px; width: 16px; height: 16px; font-size: 9px; }
.cr-gen .spec-pills { gap: 7px; }
.cr-gen .spec-pill { padding: 7px 14px; border-radius: 10px; }
.cr-gen .spec-pill b { font-size: 12.5px; }
.cr-gen .ratio-pills { gap: 6px; }
.cr-gen .ratio-pill { padding: 5px 9px 5px 6px; border-radius: 9px; gap: 6px; }
.cr-gen .rp-box { width: 28px; height: 28px; }
.cr-gen .rp-txt b { font-size: 11.5px; }
.cr-gen .rp-txt small { font-size: 9.5px; }
.cr-gen .spec-label { font-size: 12px; margin: 2px 0 7px; }
.cr-gen .res-cards { grid-template-columns: 1fr 1fr; gap: 7px; }
.cr-gen .res-card { padding: 8px 10px; border-radius: 10px; justify-content: center; }
.cr-gen .res-card b { font-size: 12.5px; }

/* Pinned footer: cost + Generate always visible */
.cr-foot {
    flex-shrink: 0; border-top: 1px solid var(--border);
    margin-top: 10px; padding-top: 10px;
}
.cr-foot .spec-rows { margin-bottom: 8px; }
.cr-recap {
    display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
    font-size: 11.5px; color: var(--text-3);
}
.cr-recap i { color: var(--primary); }
.cr-recap-sep { opacity: 0.4; }
.cr-foot .cost-panel { margin: 0 0 7px; padding: 9px 12px; }
.cr-foot .cost-num { font-size: 21px; }
.cr-foot .cost-num small { font-size: 11px; }
.cr-foot .bal-row { padding: 0 2px 7px; font-size: 12px; }
.cr-foot .gen-btn { padding: 11px; font-size: 14px; }
.cr-foot .bal-warn { margin-bottom: 6px; font-size: 11.5px; }
/* Collapse the hint slot when empty so it costs no height */
.cr-foot #genHint:empty { display: none; }

