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

:root {
  --bg:        #0c0c0c;
  --surface:   #161616;
  --surface2:  #1f1f1f;
  --border:    #2a2a2a;
  --border-hi: #3a3a3a;
  --accent:    #c9996a;
  --accent2:   #e2bc91;
  --text:      #ececec;
  --text-muted:#777;
  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 20px 100px;
}

/* ── Auth bar ────────────────────────────────────────────────────────────── */
.auth-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}
.role-badge {
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-hi);
  color: var(--text-muted);
}
.role-badge.role-premium { border-color: var(--accent); color: var(--accent); }
.role-badge.role-admin   { border-color: #9b8de8; color: #9b8de8; }
.btn-auth {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 15px;
  border-radius: 99px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-auth:hover { border-color: var(--accent); color: var(--accent); }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 56px;
}
header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.subtitle { color: var(--text-muted); font-size: 0.95rem; }

/* ── Tools nav ───────────────────────────────────────────────────────────── */
.tools-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.tools-nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.tools-nav-item:hover {
  border-color: var(--accent);
  background: var(--surface2);
  color: var(--accent);
}

.tools-nav-icon {
  font-size: 15px;
  line-height: 1;
}

/* ── Steps ───────────────────────────────────────────────────────────────── */
.step { margin-bottom: 56px; }
.step-number {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.step h2 { font-size: 1.3rem; font-weight: 600; margin-bottom: 20px; }

/* ── Upload ──────────────────────────────────────────────────────────────── */
.upload-area {
  display: block;
  position: relative;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}
.upload-area:hover, .upload-area.dragging {
  border-color: var(--accent);
  background: #191410;
}
.upload-icon  { font-size: 2.2rem; margin-bottom: 12px; opacity: 0.7; }
.upload-text  { font-size: 0.95rem; margin-bottom: 6px; }
.upload-hint  { color: var(--text-muted); font-size: 0.82rem; }
#fileInput { position: absolute; left: -9999px; width: 1px; height: 1px; }

.photo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.photo-preview-wrap img {
  max-height: 280px;
  max-width: 100%;
  border-radius: var(--radius);
  object-fit: contain;
  border: 1px solid var(--border);
}
.btn-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 18px;
  border-radius: 99px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: border-color 0.2s, color 0.2s;
}
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }

/* ── Mode grid ───────────────────────────────────────────────────────────── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.btn-mode {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  color: var(--text);
}
.btn-mode:hover {
  border-color: var(--accent);
  background: #191410;
  transform: translateY(-2px);
}
.btn-mode.active { border-color: var(--accent); background: #191410; }
.mode-emoji  { font-size: 1.9rem; }
.mode-name   { font-size: 0.92rem; font-weight: 600; }
.mode-count  { font-size: 0.76rem; color: var(--text-muted); }

.mode-previews {
  width: 68px;
  height: 68px;
  border-radius: 9px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--surface2);
}
.mode-previews.single { grid-template-columns: 1fr; }
.mode-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Results topbar ──────────────────────────────────────────────────────── */
.results-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.results-topbar-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.results-topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-text-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.83rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.2s;
}
.btn-text-link:hover { color: var(--accent); }
.gen-progress { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ── Results grid ────────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Mixed mode dividers */
.length-section-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.length-section-header:first-child { margin-top: 0; }
.length-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.length-section-line { flex: 1; height: 1px; background: var(--border); }

/* ── Result card ─────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.22s, transform 0.18s;
}
.result-card:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

/* Card image */
.result-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.result-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Loading / placeholder */
.card-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.card-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.card-error-msg {
  font-size: 0.68rem;
  color: #d87070;
  text-align: center;
  line-height: 1.4;
}

/* Preview image (not yet generated) */
.card-has-preview { position: relative; }
.card-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.68) saturate(0.85);
}
.card-placeholder-fallback {
  width: 100%;
  height: 100%;
  background: var(--surface2);
}
.card-preview-try-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}
.card-has-preview:hover .card-preview-try-overlay { opacity: 1; }
.btn-gen-overlay {
  background: rgba(201,153,106,0.9);
  color: #1a0f06;
  border: none;
  padding: 8px 20px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-gen-overlay:hover:not(:disabled) { background: rgba(226,188,145,0.97); }
.btn-gen-overlay:disabled { opacity: 0.35; cursor: not-allowed; }

/* Card info — flex:1 pushes actions to bottom */
.result-card-info {
  flex: 1;
  padding: 13px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.card-desc {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.card-length-badge {
  align-self: flex-start;
  margin-top: 5px;
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Card actions — always at bottom */
.result-card-actions {
  padding: 0 12px 13px;
  display: flex;
  gap: 7px;
  align-items: center;
}
.result-card-actions--error {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}

/* Generate / primary button */
.btn-gen {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a0f06;
  border: none;
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-gen:hover:not(:disabled) { opacity: 0.85; }
.btn-gen:disabled { opacity: 0.35; cursor: not-allowed; }

/* Download button */
.btn-dl {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  text-align: center;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn-dl:hover { border-color: var(--accent); color: var(--accent); }

/* Regen icon button */
.btn-regen {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s, transform 0.3s;
  flex-shrink: 0;
}
.btn-regen:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(90deg);
}
.btn-regen:disabled { opacity: 0.28; cursor: not-allowed; }

/* ── Topbar buttons ──────────────────────────────────────────────────────── */
.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s;
  white-space: nowrap;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-collage {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a0f06;
  border: none;
  padding: 9px 20px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-collage:hover { opacity: 0.85; }

/* ── Login modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 380px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-box h3  { font-size: 1.25rem; font-weight: 700; }
.modal-sub     { color: var(--text-muted); font-size: 0.86rem; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }
.modal-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-error   { color: #d87070; font-size: 0.8rem; }
.modal-submit  { width: 100%; padding: 12px; font-size: 0.88rem; border-radius: var(--radius-sm); }

/* ── Admin video pick on cards ───────────────────────────────────────────── */
.card-video-pick {
  display: flex;
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s, border-color 0.15s;
}
.card-video-pick.sel {
  background: var(--accent);
  border-color: var(--accent);
}
.card-video-pick.sel {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1a1008;
}
.result-card.video-selected .result-card-img {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Floating video creation bar ─────────────────────────────────────────── */
.app-video-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 14px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 36px rgba(0,0,0,0.6);
  z-index: 200;
  min-width: 320px;
  max-width: min(820px, calc(100vw - 40px));
}

/* Sequence row — scrollable thumbnails with arrows */
.vbar-seq-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.vbar-seq-row::-webkit-scrollbar { display: none; }

.vbar-seq-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.vbar-seq-num {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.vbar-seq-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}
.vbar-seq-thumb-ph {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.vbar-seq-name {
  font-size: 0.62rem;
  color: var(--text-muted);
  max-width: 52px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vbar-seq-arrow {
  font-size: 1rem;
  color: var(--accent);
  flex-shrink: 0;
  margin: 0 2px;
  padding-bottom: 16px; /* align with thumb center */
}

/* Controls row */
.vbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.app-video-bar-info {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.app-video-bar-status {
  font-size: 0.76rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}

/* ── Video status section ────────────────────────────────────────────────── */
.video-status-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px 40px;
}
.video-status-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.video-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.video-status-title {
  font-size: 1rem;
  font-weight: 700;
}
.video-status-progress {
  font-size: 0.84rem;
  color: var(--accent);
  font-weight: 600;
}
.video-status-jobs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.video-status-job {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  font-size: 0.82rem;
}
.vsj-names { color: var(--text-muted); }
.vsj-status { font-weight: 600; white-space: nowrap; }
.vsj-watch {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.vsj-watch:hover { background: rgba(201,153,106,0.1); }
.vsj-retry {
  background: transparent;
  border: 1px solid rgba(240,112,112,0.5);
  color: #f07070;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.vsj-retry:hover { background: rgba(240,112,112,0.12); }
.vsj-retry:disabled { opacity: 0.5; cursor: not-allowed; }
.vsj-pending    { color: var(--text-muted); }
.vsj-processing { color: #7ab4ff; }
.vsj-done       { color: #7dd87d; }
.vsj-failed     { color: #f07070; }

.btn-video-delete {
  background: transparent;
  border: 1px solid rgba(240,112,112,0.4);
  color: #f07070;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-video-delete:hover { background: rgba(240,112,112,0.12); border-color: #f07070; }

.video-player-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}
.video-player-wrap video {
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius-sm);
  background: #000;
}
.video-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

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

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  header h1    { font-size: 1.6rem; }
  .mode-grid   { grid-template-columns: repeat(2, 1fr); }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .results-topbar { flex-direction: column; align-items: flex-start; }
}
