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

:root {
  --bg: #0a0a0a;
  --surface: #121212;
  --surface2: #1f1f1f;
  --surface3: #2a2a2a;
  --border: #333333;
  --accent: #fe2c55;
  --accent-light: #ff6b81;
  --accent2: #25f4ee;
  --text: #ffffff;
  --text-secondary: #b3b3b3;
  --muted: #7a7a7a;
  --radius: 12px;
}

/* ── Light mode ── */
[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface2: #f5f5f5;
  --surface3: #efefef;
  --border: #e0e0e0;
  --accent: #fe2c55;
  --accent-light: #ff6b81;
  --accent2: #14b8a6;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --muted: #999999;
}

/* Light mode: box shadows are lighter */
[data-theme="light"] .product-nav {
  border-right-color: rgba(20,184,166,0.15);
}
[data-theme="light"] .edit-panel {
  border-left-color: rgba(20,184,166,0.2);
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
}
[data-theme="light"] .edit-bar {
  border-left-color: rgba(20,184,166,0.2);
  box-shadow: -6px 0 16px rgba(0,0,0,0.06);
}
[data-theme="light"] button,
[data-theme="light"] input[type="button"],
[data-theme="light"] input[type="submit"] {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
[data-theme="light"] .lightbox {
  background: rgba(0,0,0,0.7);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── Top-right info bar (balance + theme toggle) ── */
.topbar-info {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
}

.topbar-info > * {
  flex-shrink: 0;
}

body:has(#edit-panel.visible) .topbar-info {
  opacity: 0;
  pointer-events: none;
}

.balance-display {
  display: flex;
  gap: 16px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.balance-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.2s;
}

.balance-item.low {
  color: var(--accent2);
}

.balance-item.critical {
  color: #ff4444;
  animation: pulse-critical 1s ease-in-out infinite;
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.balance-refresh {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  line-height: 1;
  transition: color 0.2s, transform 0.3s;
  display: flex;
  align-items: center;
}

.balance-refresh:hover {
  color: var(--accent);
}

.balance-refresh:active {
  transform: rotate(180deg);
}

[data-theme="light"] .balance-display {
  background: rgba(255,255,255,0.8);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Theme toggle button ── */
.theme-toggle {
  position: relative;
  z-index: 499;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s, transform 0.15s, border-color 0.2s;
}
.theme-toggle:hover {
  background: var(--surface3);
  border-color: var(--accent2);
  color: var(--accent2);
  transform: scale(1.08);
}

/* ── Workspace menu (SaaS-style dropdown) ── */
.workspace-menu {
  position: relative;
}

.workspace-menu > summary {
  list-style: none;
}

.workspace-menu > summary::-webkit-details-marker {
  display: none;
}

.workspace-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-width: 120px;
  width: auto;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  height: 38px;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}

.workspace-menu-trigger:hover {
  background: var(--surface3);
  border-color: var(--accent2);
  color: var(--accent2);
  transform: translateY(-1px);
}

.workspace-menu-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.workspace-menu-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.workspace-menu-caret {
  font-size: 11px;
  opacity: 0.75;
  margin-left: auto;
}

.workspace-menu[open] .workspace-menu-trigger {
  border-color: var(--accent2);
  color: var(--accent2);
}

.workspace-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(15, 15, 15, 0.98);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
  backdrop-filter: blur(14px);
  display: grid;
  gap: 8px;
  transform-origin: top right;
  animation: menu-pop 0.14s ease-out;
}

[data-theme="light"] .workspace-menu-panel {
  background: rgba(255,255,255,0.98);
}

@keyframes menu-pop {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.workspace-menu-section {
  display: grid;
  gap: 6px;
}

.workspace-menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 4px 8px 2px;
}

.workspace-menu-link,
.workspace-menu-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.workspace-menu-link:hover,
.workspace-menu-action:hover {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--accent2);
}

.workspace-menu-link span,
.workspace-menu-action span {
  font-size: 15px;
}

.workspace-menu-link small,
.workspace-menu-action small {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 12px;
}

.workspace-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 4px;
}

.workspace-menu-danger:hover {
  color: #ff6b81;
}

@media (max-width: 700px) {
  .workspace-menu-trigger {
    min-width: 0;
    padding: 0 10px;
  }
  .workspace-menu-label {
    display: none;
  }
  .workspace-menu-panel {
    width: min(88vw, 260px);
  }
}

/* ── Left product nav sidebar ── */
.product-nav {
  position: fixed;
  top: 0; left: 0;
  width: 220px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: transform 0.25s ease, width 0.25s ease;
  overflow: hidden;
}
.product-nav.hidden { transform: translateX(-100%); }
.product-nav.collapsed { width: 52px; }

.product-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.product-nav-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
}
.product-nav.collapsed .product-nav-title { opacity: 0; }


/* Collapsed nav: center thumbnails and header */
.product-nav.collapsed .product-nav-header {
  justify-content: center;
  padding: 16px 0;
}
.product-nav.collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
  margin: 2px 4px;
  gap: 0;
}
.product-nav.collapsed .nav-item.active {
  padding-left: 0;
}

.product-nav-collapse {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.25s;
}
.product-nav.collapsed .product-nav-collapse { transform: rotate(180deg); }
.product-nav-collapse:hover { color: var(--text); }

.product-nav-balance {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.product-nav-balance-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-nav-balance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(37, 244, 238, 0.05);
  border: 1px solid rgba(37, 244, 238, 0.1);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.product-nav-balance-item:hover {
  background: rgba(37, 244, 238, 0.08);
  border-color: rgba(37, 244, 238, 0.2);
}

.product-nav-balance-label {
  color: var(--text-secondary);
  flex: 1;
}

.product-nav-balance-value {
  color: var(--text);
  transition: color 0.2s;
  text-align: right;
  font-weight: 700;
}

.product-nav-balance-value.low {
  color: var(--accent2);
}

.product-nav-balance-value.critical {
  color: #ff4444;
  animation: pulse-critical 1s ease-in-out infinite;
}

.product-nav.collapsed .product-nav-balance {
  display: block;
  padding: 8px 4px;
}

.product-nav.collapsed .product-nav-balance-display {
  gap: 0;
}

.product-nav.collapsed .product-nav-balance-item {
  justify-content: center;
  padding: 8px 4px;
  margin: 0 auto;
  min-height: 36px;
}

.product-nav.collapsed .product-nav-balance-label {
  display: none;
}

.product-nav.collapsed .product-nav-balance-value {
  text-align: center;
  font-size: 10px;
  line-height: 1.1;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-nav-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.product-nav-list::-webkit-scrollbar { width: 4px; }
.product-nav-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 6px;
  margin: 2px 6px;
  min-width: 0;
}
.nav-item:hover { background: var(--surface2); }
.nav-item.active {
  background: rgba(20,184,166,0.1);
  border: 1.5px solid var(--accent2);
  padding-left: 11px;
  box-shadow: 0 0 0 1px inset rgba(20,184,166,0.2);
}

.nav-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface3);
}
.nav-item-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--surface3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav-item-info {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.product-nav.collapsed .nav-item-info { display: none; }

.nav-item-num {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}
.nav-item-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}
.nav-item-counts {
  display: flex;
  gap: 6px;
  margin-top: 3px;
}
.nav-count-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}
.nav-count-img { background: rgba(37,244,238,0.12); color: var(--accent2); }
.nav-count-vid { background: rgba(254,44,85,0.12); color: var(--accent-light); }
.nav-count-generating {
  background: rgba(168,85,247,0.15);
  color: #c084fc;
  animation: nav-gen-pulse 1.2s ease-in-out infinite;
}
.nav-count-error { background: rgba(239,68,68,0.15); color: #f87171; }
@keyframes nav-gen-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Page wrap shifts right when sidebar open ── */
#page-wrap {
  padding: 40px 16px 240px;
  transition: margin-left 0.25s ease;
}
#page-wrap.nav-open { margin-left: 220px; }
#page-wrap.nav-collapsed { margin-left: 52px; }

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 4px;
}
header h1 {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 60%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
header p { color: var(--text-secondary); font-size: 14px; letter-spacing: 0.2px; }

/* ── Input cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 900px;
  margin: 0 auto 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
}
.card:hover {
  border-color: rgba(37,244,238,0.3);
  box-shadow: 0 4px 16px rgba(37,244,238,0.15);
}

label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

/* ── API key row ── */
.api-row { display: flex; gap: 8px; }
.api-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 13px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
  transition: all 0.2s;
}
.api-row input:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(37,244,238,0.1);
  background: var(--surface);
}
.api-row input::placeholder { color: var(--muted); }

.btn-ghost {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--accent2); border-color: var(--accent2); }

/* ── Button Group ── */
.button-group {
  display: flex;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: 900px;
}

.sticky-actions-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 -16px 20px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ── Export group: dropdown + Go button ── */
.export-group {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--accent2);
  box-shadow: 0 2px 8px rgba(37, 244, 238, 0.1);
}

.export-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--accent2);
  border: none;
  outline: none;
  padding: 9px 12px 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-right: 1px solid var(--border);
  min-width: 160px;
}

.export-select:focus { outline: none; }

.export-group .btn-secondary {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 9px 16px;
  white-space: nowrap;
}

.export-group .btn-secondary:hover {
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  border: 2px solid var(--accent2);
  color: var(--accent2);
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(37, 244, 238, 0.1);
}

.btn-secondary:hover {
  background: rgba(37, 244, 238, 0.08);
  box-shadow: 0 4px 16px rgba(37, 244, 238, 0.2);
  transform: translateY(-1px);
}

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

/* ── Textarea ── */
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 13px;
  font-family: monospace;
  resize: vertical;
  min-height: 100px;
  outline: none;
  line-height: 1.6;
  transition: all 0.2s;
}
textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(37,244,238,0.1); }
textarea::placeholder { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ── Primary button ── */
.btn-primary {
  width: 100%; max-width: 900px;
  margin: 24px auto 28px;
  display: block;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none; border-radius: 10px;
  color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(254,44,85,0.2);
  position: relative; overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.4s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(254,44,85,0.25); }
.btn-primary:hover::before { left: 100%; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Progress ── */
#progress-wrap { max-width: 900px; margin: 0 auto 28px; display: none; }
#progress-text { font-size: 13px; color: var(--text-secondary); display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress-bar-bg {
  background: var(--surface2); border-radius: 99px;
  height: 8px; overflow: hidden; border: 1px solid var(--border);
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px; transition: width 0.4s ease; width: 0%;
  box-shadow: 0 0 16px rgba(37,244,238,0.4);
}

/* ── Product cards ── */
#results { max-width: 900px; margin: 0 auto; }

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: border-color 0.3s ease;
}
.product-card:hover { border-color: rgba(37,244,238,0.2); }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.card-num {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff; font-size: 11px; font-weight: 800;
  border-radius: 6px; padding: 3px 9px;
  flex-shrink: 0; letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(254,44,85,0.3);
}
.card-meta { flex: 1; min-width: 0; }
.card-title {
  font-weight: 600; font-size: 14px;
  display: block; margin-bottom: 8px;
  white-space: normal; line-height: 1.4;
}
.error-text { color: #ff6b6b; }

.card-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-badge {
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 99px;
}
.stat-orig { background: rgba(255,255,255,0.08); color: var(--text-secondary); text-decoration: line-through; }
.stat-real { background: rgba(37,244,238,0.12); color: var(--accent2); }
.stat-disc { background: rgba(254,44,85,0.12); color: var(--accent-light); }
.stat-rate { background: rgba(255,215,0,0.1); color: #ffd700; }
.stat-cat  { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.stat-seller { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* Light mode badge overrides */
[data-theme="light"] .stat-orig { background: var(--surface2); }
[data-theme="light"] .stat-rate  { background: rgba(255,193,7,0.15); color: #92700a; }
[data-theme="light"] .stat-cat   { background: var(--surface2); }
[data-theme="light"] .stat-seller { background: var(--surface2); }

/* ── Card section headers ── */
.card-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 8px;
  border-top: 1px solid var(--border);
}
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
  flex: 1;
}
.count-badge {
  font-size: 11px; font-weight: 700;
  background: var(--surface3);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.btn-select-all {
  background: none; border: 1px solid var(--border);
  color: var(--accent2); cursor: pointer;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
  transition: all 0.2s;
}
.btn-select-all:hover { background: rgba(37,244,238,0.08); border-color: var(--accent2); }

.btn-create-action {
  background: rgba(254,44,85,0.08);
  border: 1px solid var(--accent);
  color: var(--accent); cursor: pointer;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-create-action:hover {
  background: rgba(254,44,85,0.16);
  border-color: var(--accent-light);
  color: var(--accent-light);
  transform: translateY(-1px);
}

[data-theme="light"] .btn-create-action {
  background: rgba(254,44,85,0.06);
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(254,44,85,0.15);
}
[data-theme="light"] .btn-create-action:hover {
  background: rgba(254,44,85,0.12);
  box-shadow: 0 2px 8px rgba(254,44,85,0.25);
}

/* ── Product image gallery ── */
.card-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 20px 16px;
}

.img-thumb {
  position: relative;
  width: 90px; height: 90px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.img-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.2s;
}
.img-thumb:hover { border-color: var(--accent2); transform: translateY(-2px); }
.img-thumb:hover img { transform: scale(1.06); }

/* Product images - no selection, just download */
.img-thumb--product {
  cursor: zoom-in;
}
.img-thumb--product:hover {
  cursor: zoom-in;
}
.img-download {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65);
  color: var(--accent2);
  text-decoration: none;
  font-size: 18px; font-weight: 800;
  opacity: 0; transition: opacity 0.2s;
}
.img-thumb--product:hover .img-download {
  opacity: 1;
}

.thumb-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.thumb-check {
  width: 28px; height: 28px;
  background: var(--accent2); color: #000;
  font-weight: 800; font-size: 13px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transform: scale(0.7); transition: transform 0.15s;
}
.thumb-check--num { font-size: 12px; }
.img-thumb:not(.img-thumb--product):hover .thumb-overlay { opacity: 1; }
.img-thumb.selected { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
.img-thumb.selected .thumb-overlay { opacity: 1; }
.img-thumb.selected .thumb-check { transform: scale(1); }

/* ── AI Generated Images section ── */
.card-ai-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 20px 16px;
  min-height: 40px;
}

.ai-thumb {
  position: relative;
  width: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ai-thumb:hover { border-color: var(--accent2); transform: translateY(-2px); }
.ai-thumb img {
  width: 80px;
  height: auto;
  display: block;
}
.ai-thumb .thumb-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.ai-thumb:hover .thumb-overlay { opacity: 1; }
.ai-thumb.selected { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
.ai-thumb.selected .thumb-overlay { opacity: 1; }
.ai-thumb.selected .thumb-check { transform: scale(1); }

.ai-dl {
  display: block;
  text-align: center;
  background: var(--surface3);
  color: var(--accent2);
  font-size: 11px; font-weight: 600;
  padding: 4px;
  text-decoration: none;
  transition: background 0.2s;
  position: relative;
  z-index: 1;
}
.ai-dl:hover { background: var(--border); }

/* ── AI Generated Videos section ── */
.card-ai-videos {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 20px 16px;
  min-height: 40px;
}

.ai-video-wrap {
  position: relative;
  width: 180px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: border-color 0.2s;
  cursor: pointer;
}
.ai-video-wrap:hover { border-color: var(--accent2); }
.ai-video-wrap video {
  width: 180px;
  height: auto;
  display: block;
  pointer-events: none; /* clicks go to wrap, not video controls */
}

/* Expand icon overlay on video thumbnails */
.ai-video-expand-icon {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.ai-video-wrap:hover .ai-video-expand-icon { opacity: 1; }

.ai-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.ai-thumb:hover .ai-thumb-remove,
.ai-video-wrap:hover .ai-thumb-remove {
  opacity: 1;
}
.ai-thumb-remove:hover { background: var(--accent); }

.ai-video-download {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.55);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.ai-video-wrap:hover .ai-video-download { opacity: 1; }
.ai-video-download:hover { background: var(--accent2); color: #000; }

/* ── Video item wrapper (video + GDrive button below) ── */
.ai-video-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.ai-gdrive-btn {
  width: 180px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.ai-gdrive-btn:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--accent2);
  color: var(--text);
}
.ai-gdrive-btn:disabled { cursor: default; opacity: 0.5; }
.ai-gdrive-btn--success { color: #4caf50 !important; border-color: #4caf50 !important; }
.ai-gdrive-btn--error   { color: var(--accent) !important; border-color: var(--accent) !important; }

.ai-thumb-placeholder {
  width: 80px;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface2) 0%, var(--surface3) 50%, var(--surface2) 100%);
  background-size: 200% 100%;
  animation: loading-pulse 1.5s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}
.ai-thumb-placeholder span {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
}
.ai-thumb-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent2);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.ai-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0 8px;
  align-self: center;
}

/* ── Variants section ── */
.card-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 20px 16px;
  min-height: 40px;
}

.variant-thumb {
  position: relative;
  width: 100px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.2s ease;
  cursor: zoom-in;
}
.variant-thumb:hover { border-color: var(--accent2); transform: translateY(-2px); }
.variant-thumb img {
  width: 100px;
  height: auto;
  display: block;
  object-fit: cover;
}

.variant-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.72);
  color: #ffffff;
  font-size: 11px; font-weight: 600;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.variant-thumb.selected { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }

/* ── Edit Panel ── */
#edit-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.6);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 200;
  overflow: hidden;
}
#edit-panel.visible { transform: translateX(0); }

#edit-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 190;
}

#edit-panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Expandable body — collapsed by default */
.edit-panel-body {
  flex: 1;
  overflow-y: auto;
  transition: all 0.35s ease;
}

.edit-panel-inner {
  background: transparent;
  border-top: none;
  padding: 20px;
}

.edit-panel-mobile-head {
  display: none;
}

.edit-panel-mobile-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}

/* ── Always-visible compact bar ── */
.edit-bar {
  background: var(--surface);
  border-left: 2px solid rgba(37,244,238,0.35);
  box-shadow: -8px 0 32px rgba(0,0,0,0.6);
  padding: 8px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid var(--border);
}

.edit-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#edit-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  white-space: nowrap;
  flex-shrink: 0;
  display: none;
}

/* ── Edit panel product indicator ── */
.edit-panel-product-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.edit-panel-product-indicator img {
  flex-shrink: 0;
}

.edit-panel-product-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

.edit-panel-product-label {
  font-size: 9px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.edit-panel-product-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.edit-panel-product-title {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* Action buttons */
.edit-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.btn-bar-action {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none; border-radius: 7px;
  color: #fff; cursor: pointer;
  padding: 7px 12px; font-size: 12px; font-weight: 700;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(124,58,237,0.35);
}
.btn-bar-action:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124,58,237,0.5); }

.btn-bar-action--video {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  box-shadow: 0 2px 10px rgba(20,184,166,0.3);
}
.btn-bar-action--video:hover { box-shadow: 0 4px 14px rgba(20,184,166,0.5); }

.btn-bar-close {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  padding: 7px 10px; border-radius: 7px;
  font-size: 11px; font-weight: 700;
  transition: all 0.2s;
  display: none;
}
.btn-bar-close:hover { color: var(--text); border-color: var(--muted); }

.btn-clear-sel {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px; padding: 7px 12px; border-radius: 7px;
  transition: all 0.2s;
}
.btn-clear-sel:hover { background: rgba(255,107,107,0.1); color: #ff6b6b; border-color: #ff6b6b; }

/* ── Selected images preview strip (in bar) ── */
#ws-selected-preview {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: center;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
#ws-selected-preview::-webkit-scrollbar { display: none; }

.preview-thumb {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 5px; overflow: visible;
  cursor: grab; flex-shrink: 0;
  user-select: none;
}
.preview-thumb img {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid var(--accent2);
  display: block;
  pointer-events: none;
}
.preview-thumb.dragging { opacity: 0.4; cursor: grabbing; }
.preview-thumb.drag-over img { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.preview-num {
  position: absolute; top: -5px; left: -5px;
  background: var(--accent2); color: #000;
  font-size: 8px; font-weight: 900;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.preview-remove {
  position: absolute; top: -5px; right: -5px;
  background: #ff4444; color: #fff;
  border: none; border-radius: 50%;
  width: 14px; height: 14px;
  font-size: 8px; font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  z-index: 2;
  transition: background 0.2s;
}
.preview-remove:hover { background: #cc0000; }

/* ── Shared WaveSpeed API key field ── */
.edit-field--key {
  margin-bottom: 14px;
}
.edit-field--key label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted);
  margin-bottom: 6px; font-weight: 600;
}

/* ── Edit panel tabs ── */
.edit-panel-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.edit-tab {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}
.edit-tab:hover { color: var(--text); }
.edit-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.edit-tab-panel { display: none; }
.edit-tab-panel.active { display: block; }

/* ── Edit fields ── */
.edit-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.edit-fields--video {
  grid-template-columns: 1fr 1fr;
}
.edit-fields--video .edit-field--prompt {
  grid-column: 1 / -1;
}
.edit-fields--video .edit-field--negative {
  grid-column: 1 / -1;
}

.btn-negative-prompt {
  grid-column: 1 / -1;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.02em;
}
.btn-negative-prompt:hover {
  color: var(--accent2);
  border-color: var(--accent2);
}
.edit-field label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted);
  margin-bottom: 6px; font-weight: 600;
}
.edit-field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 32px 10px 12px;
  font-size: 13px;
  outline: none; cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237a7a7a' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.edit-field select:focus { border-color: var(--accent2); }
.edit-field textarea { min-height: 68px; font-family: inherit; }

.template-select-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.template-select-row select {
  min-width: 180px;
  max-width: 100%;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 32px 10px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237a7a7a' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.template-select-row select:focus {
  border-color: var(--accent2);
}

/* ── Auto-generate video row ── */
.auto-video-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.auto-video-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.auto-video-toggle input[type="checkbox"] { display: none; }

.avt-track {
  width: 34px; height: 18px;
  background: var(--surface3);
  border-radius: 9px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
  border: 1px solid var(--border);
}

.avt-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.auto-video-toggle input:checked ~ .avt-track {
  background: rgba(37,244,238,0.15);
  border-color: var(--accent2);
}

.auto-video-toggle input:checked ~ .avt-track .avt-thumb {
  transform: translateX(16px);
  background: var(--accent2);
}

.avt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.auto-video-toggle input:checked ~ .avt-track + .avt-label,
.auto-video-toggle:has(input:checked) .avt-label { color: var(--accent2); }

.auto-video-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.avc-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-panel-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.edit-panel-footer .btn-generate { flex-shrink: 0; }
.edit-meta { font-size: 12px; color: var(--muted); }
.btn-recover-task {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--accent2);
  font-size: 11px; padding: 3px 10px; cursor: pointer;
  margin-left: 6px; vertical-align: middle;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0; height: 22px; line-height: 16px;
}
.btn-recover-task:hover { color: var(--accent2); border-color: var(--accent2); }

.btn-generate {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none; border-radius: 8px;
  color: #fff; cursor: pointer;
  padding: 8px 20px; font-size: 13px; font-weight: 700;
  line-height: 1.3;
  transition: all 0.25s;
  box-shadow: 0 4px 16px rgba(124,58,237,0.4);
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.5); }
.btn-generate:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-generate--video {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  box-shadow: 0 4px 16px rgba(20,184,166,0.35);
}
.btn-generate--video:hover { box-shadow: 0 8px 24px rgba(20,184,166,0.5); }

.btn-cancel {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
  box-shadow: 0 4px 12px rgba(239,68,68,0.35);
}
.btn-cancel:hover { box-shadow: 0 6px 20px rgba(239,68,68,0.5); transform: translateY(-1px); }

/* ── Output grids ── */
.ws-output-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}
.ws-generating { color: var(--text-secondary); font-size: 13px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.ws-result-img { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ws-result-img img {
  height: 260px; width: auto; max-width: 148px;
  border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.ws-result-video { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ws-result-video video {
  height: 260px; width: auto; max-width: 148px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  background: #000;
}

.btn-dl-img {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--accent2); text-decoration: none;
  font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px;
  transition: all 0.2s;
}
.btn-dl-img:hover { background: var(--border); }

/* ── Loading Placeholders ── */
.ws-placeholder {
  aspect-ratio: 9 / 16;
  background: linear-gradient(90deg, var(--surface2) 0%, var(--surface3) 50%, var(--surface2) 100%);
  background-size: 200% 100%;
  animation: loading-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  flex-direction: column;
  gap: 12px;
}

.ws-placeholder-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent2);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes loading-pulse {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
}

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

/* ── Generation error card ── */
.ws-error-card {
  aspect-ratio: 9 / 16;
  background: rgba(239,68,68,0.08);
  border: 1.5px dashed rgba(239,68,68,0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  text-align: center;
  cursor: default;
}
.ws-error-card--video { aspect-ratio: 9 / 16; }
.ws-error-icon { font-size: 22px; }

/* Message + retry hidden until hover */
.ws-error-msg {
  font-size: 11px;
  color: #ff6b6b;
  line-height: 1.4;
  word-break: break-word;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.btn-retry {
  margin-top: 4px;
  padding: 6px 14px;
  background: rgba(239,68,68,0.18);
  border: 1px solid rgba(239,68,68,0.45);
  border-radius: 6px;
  color: #ff8a8a;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s;
}
.ws-error-card:hover .ws-error-msg,
.ws-error-card:hover .btn-retry {
  opacity: 1;
  transform: translateY(0);
}
.btn-retry:hover { background: rgba(239,68,68,0.32); }

/* Sensitive content error variant */
.ws-error-card--sensitive {
  background: rgba(251,191,36,0.06);
  border-color: rgba(251,191,36,0.35);
}
.ws-error-card--sensitive .ws-error-icon { font-size: 24px; }
.ws-error-card--sensitive .ws-error-msg {
  color: #f5c842;
  opacity: 1;
  transform: none;
}
.ws-error-nocredit {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Toast ── */
#toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 22px;
  font-size: 14px; font-weight: 500;
  opacity: 0; transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none; z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Lightbox ── */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
  backdrop-filter: blur(6px);
}
#lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  object-fit: contain;
  cursor: default;
}
#lightbox video {
  max-width: min(90vw, calc(90vh * 9 / 16));
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  cursor: default;
  background: #000;
}
#lightbox-close {
  position: fixed; top: 20px; right: 24px;
  background: rgba(255,255,255,0.12);
  border: none; color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%; font-size: 16px;
  cursor: pointer; z-index: 3001;
  display: flex; align-items: center; justify-content: center;
}
#lightbox-close:hover { background: var(--accent); }

/* ── Filename modal ── */
#filename-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}
#filename-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  width: 360px;
  max-width: 90vw;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
#filename-modal-label {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em;
}
#filename-modal-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
#filename-modal-input:focus { outline: none; border-color: var(--accent2); }
.filename-modal-btns {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px;
}
.filename-modal-btns button {
  padding: 8px 18px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
}
#filename-modal-cancel {
  background: var(--surface3); color: var(--text-secondary);
}
#filename-modal-cancel:hover { background: var(--border); }
#filename-modal-save {
  background: var(--accent2); color: #000;
}
#filename-modal-save:hover { opacity: 0.85; }

/* ── Image Upload Interface ── */
.upload-area {
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  transition: border-color 0.2s, background 0.2s;
}
.upload-area.drag-over {
  border-color: var(--accent2);
  background: rgba(37,244,238,0.06);
}

.upload-label {
  display: block;
  margin-bottom: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.btn-add-image {
  display: block;
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.btn-add-image:hover {
  background: rgba(37, 244, 238, 0.1);
}

.uploaded-preview-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 12px;
  min-height: 60px;
  align-content: start;
}

.uploaded-preview {
  display: contents;
}

.upload-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
  padding: 20px 10px;
  font-size: 13px;
}

.upload-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

.upload-thumb:hover {
  border-color: var(--accent2);
}

.upload-thumb.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.upload-thumb.drag-over {
  border-color: var(--accent);
  background: rgba(254, 44, 85, 0.1);
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-thumb.upload-add {
  background: var(--surface3);
  border: 2px dashed var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 300;
  color: var(--accent2);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.upload-thumb.upload-add:hover {
  background: rgba(37, 244, 238, 0.1);
  border-color: var(--accent2);
}

.upload-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--accent2);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.upload-thumb:hover .upload-remove {
  opacity: 1;
}

.upload-remove:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* ── Video Source Selection ── */
.video-source-area {
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.source-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.source-tab {
  flex: 1;
  background: var(--surface3);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.source-tab:hover {
  border-color: var(--accent2);
  color: var(--accent2);
}

.source-tab.active {
  background: rgba(37, 244, 238, 0.15);
  border-color: var(--accent2);
  color: var(--accent2);
}

.source-panel {
  display: none;
}

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

.source-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.generated-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  min-height: 100px;
  align-content: start;
}

/* ── Generated Images Gallery (Add Generated tab) ── */
.generated-images-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.generated-images-gallery::-webkit-scrollbar { width: 4px; }
.generated-images-gallery::-webkit-scrollbar-track { background: transparent; }
.generated-images-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.gen-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.gen-group-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(37, 244, 238, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.gen-group-title {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
}

.gen-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color 0.15s;
}

.gen-thumb:hover { border-color: var(--accent2); }

.gen-thumb--selected { border-color: var(--accent); }

.gen-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-thumb-check {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.gen-thumb--selected .gen-thumb-check {
  opacity: 1;
}

.video-source-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.video-source-thumb:hover {
  border-color: var(--accent2);
}

.video-source-thumb.selected {
  border-color: var(--accent);
}

.video-source-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-source-thumb .source-index {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--accent2);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* ── Tablet / small laptop ── */
@media (max-width: 980px) {
  .topbar-info {
    top: 10px;
    right: 10px;
  }

  .product-nav {
    width: 88px;
  }

  .product-nav.collapsed {
    width: 46px;
  }

  .product-nav-header {
    padding: 12px 8px;
    justify-content: center;
  }

  .product-nav-title {
    display: none;
  }

  .product-nav-collapse {
    font-size: 28px;
    padding: 0;
  }

  .product-nav-balance {
    padding: 8px 6px;
  }

  .product-nav-balance-item {
    justify-content: center;
    padding: 8px 6px;
  }

  .product-nav-balance-label {
    display: none;
  }

  .product-nav-balance-value {
    width: 100%;
    text-align: center;
    font-size: 10px;
  }

  .nav-item {
    justify-content: center;
    padding: 8px 6px;
    margin: 4px 6px;
  }

  .nav-item-info {
    display: none;
  }

  .nav-item-thumb,
  .nav-item-thumb-placeholder {
    width: 54px;
    height: 54px;
    border-radius: 10px;
  }

  #page-wrap {
    padding: 28px 14px 180px;
  }

  #page-wrap.nav-open {
    margin-left: 88px;
  }

  #page-wrap.nav-collapsed {
    margin-left: 46px;
  }

  header {
    margin-bottom: 28px;
    padding-top: 28px;
  }

  header h1 {
    font-size: 30px;
  }

  header p {
    font-size: 13px;
  }

  .card,
  .product-card,
  #results,
  #progress-wrap,
  .button-group,
  .btn-primary {
    max-width: none;
  }

  .card {
    padding: 18px 18px 20px;
  }

  .sticky-actions-bar {
    gap: 10px;
    justify-content: stretch;
  }

  .sticky-actions-bar > * {
    flex: 1 1 220px;
  }

  .export-group {
    width: 100%;
  }

  .export-select {
    min-width: 0;
    flex: 1;
  }

  .product-card {
    margin-bottom: 16px;
  }

  .card-header {
    padding: 16px;
    gap: 10px;
  }

  .card-title {
    font-size: 13px;
  }

  .card-section-header,
  .card-images,
  .card-ai-images,
  .card-ai-videos,
  .card-variants {
    padding-left: 16px;
    padding-right: 16px;
  }

  .img-thumb {
    width: 76px;
    height: 76px;
  }

  .variant-thumb,
  .variant-thumb img {
    width: 88px;
  }

  .ai-video-wrap,
  .ai-video-wrap video,
  .ai-gdrive-btn {
    width: 148px;
  }

  #edit-panel {
    width: min(540px, calc(100vw - 20px));
  }

  .edit-panel-inner {
    padding: 18px;
  }

  .edit-bar {
    padding: 10px 12px;
  }

  .edit-bar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .btn-bar-action,
  .btn-bar-close,
  .btn-clear-sel {
    padding: 8px 10px;
    font-size: 11px;
  }

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

  .edit-field select,
  .template-select-row select,
  textarea {
    font-size: 16px;
  }
}

/* ── Mobile ── */
@media (max-width: 700px) {
  body.mobile-editing {
    overflow: hidden;
  }

  body.mobile-editing .product-nav {
    transform: translateX(-100%);
  }

  body.mobile-editing #page-wrap {
    margin-left: 0 !important;
  }

  body.mobile-editing .topbar-info,
  body.mobile-editing .sticky-actions-bar {
    opacity: 0;
    pointer-events: none;
  }

  .topbar-info {
    top: max(10px, env(safe-area-inset-top));
    right: 8px;
  }

  .workspace-menu-trigger {
    height: 44px;
    padding: 0 10px;
  }

  .product-nav {
    width: 64px;
  }

  .product-nav.collapsed {
    width: 34px;
  }

  .product-nav-header {
    padding: 10px 4px;
  }

  .product-nav-balance {
    padding: 6px 2px;
  }

  .product-nav-balance-item {
    padding: 6px 2px;
    min-height: 32px;
  }

  .product-nav-balance-value {
    font-size: 9px;
  }

  .nav-item-thumb,
  .nav-item-thumb-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }

  #page-wrap {
    padding: 22px 12px calc(180px + env(safe-area-inset-bottom));
  }

  #page-wrap.nav-open {
    margin-left: 64px;
  }

  #page-wrap.nav-collapsed {
    margin-left: 34px;
  }

  header {
    margin-bottom: 22px;
    padding-top: 44px;
  }

  header h1 {
    font-size: 24px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .sticky-actions-bar {
    margin: 0 -12px 16px;
    padding: 10px 12px;
    top: 0;
  }

  .sticky-actions-bar > * {
    flex: 1 1 100%;
  }

  .button-group {
    margin-bottom: 10px;
  }

  .btn-primary,
  .btn-secondary {
    font-size: 14px;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px;
  }

  .card-num {
    align-self: flex-start;
  }

  .card-title {
    font-size: 12px;
    line-height: 1.45;
  }

  .card-stats {
    gap: 5px;
  }

  .stat-badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  .card-section-header,
  .card-images,
  .card-ai-images,
  .card-ai-videos,
  .card-variants {
    padding-left: 14px;
    padding-right: 14px;
  }

  .card-images,
  .card-ai-images,
  .card-variants {
    gap: 6px;
  }

  .img-thumb {
    width: 64px;
    height: 64px;
  }

  .ai-thumb {
    width: 68px;
  }

  .ai-thumb img,
  .ai-thumb-placeholder {
    width: 68px;
  }

  .ai-video-wrap,
  .ai-video-wrap video,
  .ai-gdrive-btn {
    width: min(42vw, 136px);
  }

  .variant-thumb,
  .variant-thumb img {
    width: 76px;
  }

  #edit-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 88dvh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -14px 36px rgba(0,0,0,0.55);
    transform: translateY(100%);
    z-index: 250;
  }

  #edit-panel::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    z-index: 3;
  }

  #edit-panel.visible {
    transform: translateY(0);
  }

  .edit-panel-body {
    overscroll-behavior: contain;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .edit-panel-inner {
    padding: 14px 10px 10px;
  }

  .edit-panel-mobile-head {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
  }

  .edit-panel-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    gap: 0;
    margin: 0 -10px 8px;
    padding: 0 10px 6px;
  }

  .edit-tab {
    flex: 1;
    padding: 7px 4px;
    font-size: 10px;
    white-space: nowrap;
  }

  .upload-area,
  .video-source-area {
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 10px;
  }

  .upload-label {
    margin-bottom: 6px;
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .uploaded-preview-wrapper {
    min-height: 0;
    margin-top: 6px;
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  }

  .upload-hint {
    padding: 6px 4px;
    font-size: 11px;
  }

  .upload-thumb.upload-add {
    min-height: 54px;
    font-size: 20px;
    border-width: 1.5px;
  }

  .source-tabs {
    flex-direction: row;
    gap: 4px;
    margin-bottom: 8px;
  }

  .source-tab {
    padding: 7px 6px;
    font-size: 10px;
    border-width: 1px;
  }

  .uploaded-preview-wrapper,
  .source-preview,
  .generated-images-grid {
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 5px;
  }

  .template-select-row,
  .auto-video-row,
  .auto-video-settings {
    flex-direction: column;
    align-items: stretch !important;
  }

  .template-select-row {
    margin-bottom: 4px;
  }

  .edit-field,
  .edit-fields {
    gap: 8px;
  }

  .edit-field label {
    margin-bottom: 4px;
    font-size: 10px;
  }

  .edit-field select,
  .template-select-row select {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 14px;
  }

  #wsPrompt,
  #wsVideoPrompt,
  #autoVideoPrompt,
  #wsNegativePrompt {
    min-height: 68px;
    line-height: 1.45;
    font-size: 14px;
  }

  .btn-negative-prompt {
    font-size: 10px;
    padding: 5px 9px;
  }

  .auto-video-toggle {
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .avt-label {
    white-space: normal;
    line-height: 1.35;
  }

  .edit-panel-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
  }

  .edit-panel-footer .edit-meta {
    flex: 1 1 100%;
    order: 1;
  }

  .edit-panel-footer .btn-recover-task {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 28px;
    padding: 5px 8px;
    font-size: 10px;
    margin-left: 0;
  }

  .edit-panel-footer .btn-generate {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 9px 10px;
    font-size: 11px;
  }

  .edit-meta {
    font-size: 10px;
    line-height: 1.4;
  }

  .ws-output-grid {
    gap: 12px;
    justify-content: center;
  }

  .ws-result-img img,
  .ws-result-video video {
    height: 200px;
    max-width: 115px;
  }

  .edit-bar {
    gap: 8px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }

  body.mobile-editing .edit-bar {
    display: none;
  }

  .edit-bar-left,
  .edit-bar-right {
    width: 100%;
  }

  .edit-bar-right {
    justify-content: stretch;
    gap: 4px;
  }

  .btn-bar-action {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 8px 8px;
    font-size: 10px;
    border-radius: 9px;
  }

  .btn-bar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 10px;
  }

  .btn-clear-sel {
    width: 34px;
    min-width: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
  }

  .preview-thumb,
  .preview-thumb img {
    width: 26px;
    height: 26px;
  }

  .preview-remove,
  .preview-num {
    width: 12px;
    height: 12px;
    font-size: 7px;
  }
}

@media (max-width: 480px) {
  .topbar-info {
    right: 6px;
  }

  .product-nav {
    width: 58px;
  }

  .product-nav.collapsed {
    width: 32px;
  }

  #page-wrap.nav-open {
    margin-left: 58px;
  }

  #page-wrap.nav-collapsed {
    margin-left: 32px;
  }

  .nav-item-thumb,
  .nav-item-thumb-placeholder {
    width: 34px;
    height: 34px;
  }

  .card,
  .product-card {
    border-radius: 12px;
  }

  .card-title {
    font-size: 11px;
  }

  .stat-badge {
    font-size: 10px;
    padding: 3px 7px;
  }

  .img-thumb {
    width: 58px;
    height: 58px;
  }

  .variant-thumb,
  .variant-thumb img,
  .ai-thumb,
  .ai-thumb img,
  .ai-thumb-placeholder {
    width: 62px;
  }

  .btn-bar-action,
  .btn-bar-close,
  .btn-clear-sel {
    font-size: 10px;
    padding: 8px 6px;
  }

  .edit-panel-inner {
    padding: 18px 10px 12px;
  }

  #edit-panel {
    max-height: 92dvh;
  }

  .source-tab,
  .edit-tab {
    font-size: 10px;
  }

  .edit-panel-footer .btn-generate {
    padding: 8px 9px;
    font-size: 10px;
  }

  .edit-meta {
    font-size: 9px;
  }

  #wsPrompt,
  #wsVideoPrompt,
  #autoVideoPrompt,
  #wsNegativePrompt {
    min-height: 56px;
  }
}
