/* ─────────────────────────────────────────────────────────
   Kling Video Creator
   Luxury gold-foil design system — refined beyond the reference
───────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ── Tokens ── */
:root {
  --gold-1:      #7a5c1a;
  --gold-2:      #b08928;
  --gold-3:      #cfa840;
  --gold-4:      #e2c96a;
  --gold-5:      #f0dfaa;
  --gold-6:      #faf4e4;
  --gold-foil:   linear-gradient(110deg, #7a5c1a 0%, #cfa840 30%, #f0e090 52%, #cfa840 72%, #7a5c1a 100%);
  --gold-btn:    linear-gradient(135deg, #b08928 0%, #d4a83a 40%, #e8c860 60%, #c09030 100%);
  --gold-glow:   0 6px 32px rgba(176, 137, 40, 0.22);

  --bg:          #f6f3ec;
  --surface:     #ffffff;
  --surface-2:   #fdfaf4;
  --border:      rgba(176, 137, 40, 0.14);
  --border-mid:  rgba(176, 137, 40, 0.28);
  --border-str:  rgba(176, 137, 40, 0.5);

  --text-1:      #1c1608;
  --text-2:      #5c4920;
  --text-3:      #9c8454;
  --text-4:      #c8b07a;

  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   14px;
  --sidebar-w:   372px;
  --header-h:    58px;

  --font-brand:  'Cormorant Garamond', Georgia, serif;
  --font-ui:     'Inter', -apple-system, sans-serif;
}

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

/* ── Body + grain texture ── */
body {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Subtle grain overlay for depth — never a flat fill */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── Page load animation — orchestrated stagger ── */
@keyframes revealUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── API Banner ── */
.api-banner {
  background: #fff8ec;
  border-bottom: 1px solid rgba(200, 140, 30, 0.35);
  color: #7a5010;
  font-size: 12.5px;
  padding: 9px 24px;
  text-align: center;
  position: relative;
  z-index: 200;
}
.api-banner code {
  font-family: monospace;
  background: rgba(200,140,30,0.12);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Header ── */
.header {
  height: var(--header-h);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 20px rgba(176, 137, 40, 0.08);
  animation: revealUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.04s;
}

.brand { display: flex; align-items: baseline; gap: 11px; }

.brand-name {
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: var(--gold-foil);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmerText 4s linear 0.8s both;
}

@keyframes shimmerText {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.brand-sep {
  color: var(--gold-4);
  font-size: 16px;
  font-weight: 300;
}

.brand-sub {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.05em;
}

.model-tag {
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--gold-6);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  padding: 3px 11px;
  letter-spacing: 0.03em;
}

/* ── Workspace ── */
.workspace {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px solid var(--border-mid);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 22px 24px 32px;
  animation: revealUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.12s;
}

/* ── Gallery Panel ── */
.gallery-panel {
  flex: 1;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: revealUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.2s;
}

/* ── Control Groups ── */
.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-tag {
  font-size: 9px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.03em;
  color: var(--text-4);
  background: var(--gold-6);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Divider — gradient fade ── */
.rule {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border-mid) 30%, var(--border-mid) 70%, transparent 100%);
  margin: 2px 0;
  flex-shrink: 0;
}

/* ── Prompt ── */
.prompt-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.6;
  resize: vertical;
  min-height: 96px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prompt-input::placeholder { color: var(--text-4); }
.prompt-input:focus {
  outline: none;
  border-color: var(--gold-3);
  box-shadow: 0 0 0 3px rgba(207, 168, 64, 0.1);
}

.prompt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ghost-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ghost-btn:hover { color: var(--gold-1); background: var(--gold-6); }

.hint {
  font-size: 10px;
  color: var(--text-4);
  letter-spacing: 0.03em;
}

/* ── Upload Zones ── */
.upload-zone {
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--gold-3);
  background: var(--gold-6);
  box-shadow: 0 0 0 3px rgba(207,168,64,0.08);
}

/* Empty state (no image selected) */
.upload-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 14px;
  text-align: center;
}

.upload-icon {
  font-size: 22px;
  color: var(--gold-4);
  line-height: 1;
  margin-bottom: 2px;
}

.upload-text {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.upload-sub {
  font-size: 10.5px;
  color: var(--text-4);
}

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gold-2); font-size: 12px; font-family: var(--font-ui);
  text-decoration: underline; text-underline-offset: 2px;
  padding: 0;
}
.link-btn:hover { color: var(--gold-1); }

/* Preview state (image selected) */
.upload-preview-wrap {
  display: none;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
}
.upload-preview-wrap.visible { display: flex; }

.upload-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-str);
  flex-shrink: 0;
}

.upload-info {
  flex: 1;
  min-width: 0;
}

.upload-fname {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.upload-fsize {
  font-size: 10.5px;
  color: var(--text-4);
}

.upload-replace {
  font-size: 10.5px;
  color: var(--gold-2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  transition: color 0.15s;
}
.upload-replace:hover { color: var(--gold-1); }

/* Optional end-frame zone — slightly subdued */
.upload-zone.optional {
  opacity: 0.82;
}
.upload-zone.optional:hover,
.upload-zone.optional.drag-over {
  opacity: 1;
}
.upload-zone.optional .upload-idle { padding: 14px 14px; }

/* ── Aspect Ratio ── */
.aspect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.aspect-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-2);
  transition: all 0.15s;
  min-height: 68px;
}
.aspect-btn:hover {
  border-color: var(--gold-3);
  background: var(--gold-6);
}
.aspect-btn.active {
  border-color: var(--gold-2);
  background: var(--gold-6);
  color: var(--gold-1);
  box-shadow: inset 0 0 0 1px rgba(176,137,40,0.18), 0 2px 8px rgba(176,137,40,0.1);
  font-weight: 600;
}

.asp-box {
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.aspect-btn.active .asp-box { opacity: 1; }

/* ── Duration strip (2 s – 15 s) ── */
/* Duration uses shared .slider / .slider-row / .slider-ends styles */

/* ── Reference Elements ── */
.add-elem-btn {
  width: 100%;
  padding: 9px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-align: center;
  transition: all 0.15s;
}
.add-elem-btn:hover {
  border-color: var(--gold-3);
  background: var(--gold-6);
  color: var(--gold-1);
}
.add-elem-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ref-elem-card {
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ref-elem-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ref-elem-title {
  font-family: var(--font-brand);
  font-size: 13px;
  font-style: italic;
  font-weight: 600;
  color: var(--gold-2);
}

.ctrl-subgroup {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctrl-sublabel {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Compact upload zone for frontal image */
.upload-zone.compact .upload-idle { padding: 12px 10px; }
.upload-zone.compact .upload-icon { font-size: 16px; }
.upload-zone.compact .upload-text { font-size: 11px; }

/* Reference image slots */
.ref-images-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ref-img-slot {
  aspect-ratio: 1;
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.ref-img-slot:hover {
  border-color: var(--gold-3);
  background: var(--gold-6);
}
.ref-img-slot .slot-plus {
  font-size: 18px;
  color: var(--text-4);
  line-height: 1;
  pointer-events: none;
}
.ref-img-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slot-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.slot-remove:hover { background: rgba(0,0,0,0.8); }

/* ── Sidebar sticky render footer ── */
.sidebar-render-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 14px 0 8px;
  margin-top: 4px;
  background: linear-gradient(to top, rgba(255,255,255,0.97) 65%, transparent 100%);
}
.sidebar-render-footer .generate-btn { margin-top: 0; }

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
}

.toggle-label { font-size: 12.5px; font-weight: 500; color: var(--text-1); }
.toggle-desc  { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }

.toggle {
  width: 40px; height: 22px;
  border-radius: 11px;
  background: var(--border-mid);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  top: 3px; left: 3px;
  transition: left 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--gold-btn); }
.toggle.on::after { left: 21px; }

/* ── Advanced — smooth accordion ── */
.advanced-details {
  display: block;
}

.advanced-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.advanced-summary::-webkit-details-marker { display: none; }
.advanced-summary:hover {
  background: var(--gold-6);
  border-color: var(--border-mid);
}

.advanced-chevron {
  font-size: 11px;
  color: var(--text-4);
  transition: transform 0.22s ease;
  line-height: 1;
}
.advanced-details[open] .advanced-chevron {
  transform: rotate(180deg);
}

.advanced-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 2px 0;
  animation: fadeIn 0.2s ease both;
}

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

/* ── Slider ── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--gold-3) 0%, var(--gold-3) 50%, var(--border-mid) 50%, var(--border-mid) 100%);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--gold-2);
  box-shadow: 0 1px 8px rgba(176,137,40,0.4);
  border: 2px solid white;
  cursor: pointer;
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--gold-2);
  box-shadow: 0 1px 8px rgba(176,137,40,0.4);
  border: 2px solid white;
  cursor: pointer;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-val {
  font-family: var(--font-brand);
  font-size: 16px;
  font-weight: 600;
  color: var(--gold-2);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-4);
  margin-top: 3px;
}

/* ── Generate Button ── */
.generate-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--gold-btn);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--gold-glow);
  transition: box-shadow 0.2s, transform 0.1s;
  position: relative;
  overflow: hidden;
  margin-top: 6px;
}

/* Shimmer sweep — always resets so it fires every hover */
.generate-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.22) 50%, transparent 65%);
  transform: translateX(-100%);
}
.generate-btn:hover::before {
  animation: sweep 0.5s ease forwards;
}
@keyframes sweep {
  to { transform: translateX(100%); }
}

.generate-btn:hover  { box-shadow: 0 8px 40px rgba(176, 137, 40, 0.38); }
.generate-btn:active { transform: scale(0.985); }
.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.generate-icon { font-size: 16px; }

/* ── Panel Tabs ── */
.panel-tabs {
  display: flex;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-mid);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.panel-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 14px 16px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.panel-tab:hover { color: var(--text-2); }
.panel-tab.active {
  color: var(--gold-1);
  border-bottom-color: var(--gold-2);
}

.lib-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--gold-5);
  color: var(--gold-1);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

/* ── Generate View ── */
#generateView {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ── Library View ── */
#libraryView {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  min-height: 0;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

/* ── Status Bar ── */
.status-bar {
  padding: 10px 26px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.status-bar.loading {
  background: #fffcf0;
  color: var(--gold-1);
  border-bottom-color: var(--border-mid);
}
.status-bar.success {
  background: #f2f9f4;
  color: #2d6e45;
  border-bottom-color: rgba(80, 160, 100, 0.2);
}
.status-bar.error {
  background: #fdf2f2;
  color: #a03030;
  border-bottom-color: rgba(180,80,80,0.2);
}

.spinner {
  width: 14px; height: 14px;
  border: 1.5px solid rgba(176,137,40,0.2);
  border-top-color: var(--gold-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-timer {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-brand);
}

/* ── Gallery Grid ── */
.gallery {
  flex: 1;
  padding: 26px;
  display: flex;
  flex-direction: column;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ── Video Card ── */
.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.2s, box-shadow 0.22s;
  animation: fadeUp 0.38s ease both;
  cursor: pointer;
  position: relative;
}
.video-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-str);
  box-shadow: 0 10px 32px rgba(176,137,40,0.14);
}

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

.video-card video {
  width: 100%;
  display: block;
  background: #0a0804;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.video-card.ratio-9-16 video { aspect-ratio: 9 / 16; }
.video-card.ratio-1-1  video { aspect-ratio: 1 / 1; }

/* Play icon overlay — fades out on hover/playing */
.video-play-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 36px; /* above footer */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s;
}
.video-play-overlay::after {
  content: '▷';
  font-size: 28px;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  filter: drop-shadow(0 0 8px rgba(176,137,40,0.5));
  transition: transform 0.2s;
}
.video-card:hover .video-play-overlay,
.video-card.playing .video-play-overlay {
  opacity: 0;
}

.video-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
}

.video-meta { font-size: 11px; color: var(--text-3); }

.dl-btn {
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--gold-1);
  background: var(--gold-6);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.dl-btn:hover {
  background: var(--gold-5);
  border-color: var(--gold-2);
}

/* ── Skeleton card ── */
.video-card-skeleton {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border: 1px solid var(--border);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Library cards ── */
.lib-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  animation: fadeUp 0.28s ease both;
}
.lib-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-str);
  box-shadow: 0 6px 24px rgba(176,137,40,0.12);
}

.lib-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #0a0804;
}
.lib-card.ratio-9-16 video { aspect-ratio: 9 / 16; }
.lib-card.ratio-1-1  video { aspect-ratio: 1 / 1; }

.lib-card-info {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}
.lib-prompt {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.4;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.lib-meta {
  font-size: 10px;
  color: var(--text-4);
}
.lib-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 80px 24px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}
.lib-loading {
  grid-column: 1 / -1;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
}

/* ── Empty State ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 60px 24px;
}

.empty-glyph {
  font-size: 44px;
  line-height: 1;
  color: var(--gold-4);
  margin-bottom: 6px;
}

.empty-title {
  font-family: var(--font-brand);
  font-size: 28px;
  font-style: italic;
  font-weight: 400;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.empty-sub {
  font-size: 12.5px;
  color: var(--text-3);
}

/* ── Generation header in gallery ── */
.gen-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.gen-count { font-size: 13px; font-weight: 500; color: var(--text-2); }
.gen-meta  { font-size: 11px; color: var(--text-4); }
.gen-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
}
.gen-error { color: #b05050; }

.spinner-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(176,137,40,0.25);
  border-top-color: var(--gold-2);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Video Modal ── */
.video-modal {
  position: fixed; inset: 0;
  background: rgba(8, 5, 2, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.video-modal.open { display: flex; }

.vm-inner {
  display: flex;
  flex-direction: column;
  max-width: 90vw;
  max-height: 92vh;
  background: #0e0a05;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 32px 100px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  animation: vmIn 0.22s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

@keyframes vmIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

#modalVideo {
  max-width: 88vw;
  max-height: 80vh;
  display: block;
  object-fit: contain;
  background: #000;
}

.vm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
}

.vm-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vm-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.vm-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--gold-3);
  background: rgba(176,137,40,0.15);
  border: 1px solid rgba(176,137,40,0.25);
  border-radius: 10px;
  padding: 2px 8px;
}

.vm-actions { display: flex; gap: 8px; flex-shrink: 0; }

.vm-btn {
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  transition: all 0.15s;
}
.vm-btn:hover {
  border-color: rgba(207,168,64,0.4);
  color: var(--gold-4);
  background: rgba(176,137,40,0.1);
}
.vm-close { color: rgba(255,255,255,0.5); }

/* ── Negative prompt textarea ── */
.neg-prompt-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.neg-prompt-input::placeholder { color: var(--text-4); }
.neg-prompt-input:focus {
  outline: none;
  border-color: var(--gold-3);
  box-shadow: 0 0 0 3px rgba(207,168,64,0.08);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-str); border-radius: 10px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .workspace { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border-mid); }
  .gallery-panel { height: auto; min-height: 60vh; }
  .brand-sub { display: none; }
}
