/* ========================================================================
   app.css -- ListingBox application styles
   ======================================================================== */

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

:root {
  --bg: #0c0c0e;
  --surface: #161619;
  --surface-2: #1e1e22;
  --surface-3: #26262b;
  --border: #2a2a30;
  --border-light: #38383f;
  --text: #e8e8ed;
  --text-dim: #a0a0a8;
  --text-muted: #78787f;
  --focus-ring: 0 0 0 2px var(--accent);
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --success: #22c55e;
  --error: #ef4444;
  --blue: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  animation: fadeIn 0.35s ease both;
}

/* --- Global Focus Ring --- */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- Layout --- */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.shell-header .powered-text {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 12px;
}
.shell-header .powered-text strong {
  color: var(--accent);
  font-weight: 600;
}

.shell-panels {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 16px;
  background: var(--surface);
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-center {
  border-right: 1px solid var(--border);
  background: var(--bg);
}

@media (max-width: 1024px) {
  .shell-panels {
    grid-template-columns: 1fr 1.4fr 1fr;
  }
}

/* Mobile tab bar — hidden on desktop */
.mobile-tabs {
  display: none;
}

@media (max-width: 768px) {
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-family: var(--font);
    min-height: 48px;
    cursor: pointer;
    position: relative;
  }
  .mobile-tab.active {
    color: var(--accent);
  }
  .mobile-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
  }
  .tab-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 20px);
    background: var(--accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    line-height: 1;
  }
  .shell-panels {
    grid-template-columns: 1fr;
    overflow: hidden;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .panel {
    display: none;
    overflow-y: auto;
    height: 100%;
    border-right: none;
    padding-bottom: 24px;
  }
  .panel.tab-active {
    display: block;
  }
  .action-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    margin: 0 0 12px 0;
    border-radius: 0;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  .panel-left,
  .panel-center,
  .panel-right {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
  .results-empty {
    padding: 32px 16px;
  }
  .batch-results {
    padding: 8px 12px;
  }
  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .toast-container {
    bottom: 120px;
  }
}

/* header styles now handled by .shell-header */

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

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: #000;
}

.logo h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo h1 span {
  color: var(--text-dim);
  font-weight: 400;
}

/* --- Sections --- */
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}

.section-label.no-line::after {
  display: none;
}

/* --- Prompt Presets --- */
.prompts-section {
  margin-bottom: 0;
}

.preset-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.preset-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 6px;
  min-height: 36px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
}

.preset-tab:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface-2);
}

.preset-tab.active {
  color: var(--accent);
  background: rgba(245, 158, 11, 0.08);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.15);
}

.empty-presets {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dim);
}
.empty-presets-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}
.empty-presets-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-presets-hint {
  font-size: 13px;
  line-height: 1.5;
  max-width: 360px;
  margin: 0 auto;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.preset-card {
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.preset-card:hover {
  border-color: var(--border-light);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.preset-card.selected {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.06);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(245, 158, 11, 0.15);
}

.preset-card.selected::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  z-index: 1;
}

.preset-card.selected::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.preset-example-img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  display: block;
}

.preset-card-body {
  padding: 6px 10px 8px;
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.preset-badge-row {
  margin-top: 4px;
}

.preset-badge {
  font-size: 9px;
  background: rgba(255,255,255,0.08);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Preset Preview Panel (Results Panel) --- */
.preset-preview-panel {
  display: none;
  margin-bottom: 16px;
  animation: previewFadeIn 0.25s ease;
}
.preset-preview-panel.visible {
  display: block;
}
.preset-preview-panel img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 10px;
}
.preset-preview-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.preset-preview-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.preset-preview-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
@keyframes previewFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.custom-prompt-row {
  display: flex;
  gap: 10px;
}

.custom-prompt-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  resize: none;
  min-height: 40px;
  overflow: hidden;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-prompt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.custom-prompt-input::placeholder {
  color: var(--text-muted);
}

/* --- Settings Row --- */
.settings-row {
  display: flex;
  gap: 16px;
  margin-top: 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-group label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.setting-select {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.setting-select:focus {
  border-color: var(--accent);
}

/* --- Upload Zone --- */
.upload-section {
  margin-bottom: 0;
}

.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  position: relative;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim), var(--accent));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.upload-zone:hover::before,
.upload-zone.dragover::before {
  opacity: 1;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06) 0%, rgba(245, 158, 11, 0.02) 100%);
}

.upload-zone.dragover {
  transform: scale(1.01);
}

.upload-icon {
  margin-bottom: 10px;
  color: var(--text-dim);
  transition: color 0.3s, transform 0.3s;
}

.upload-zone:hover .upload-icon {
  color: var(--accent);
  transform: translateY(-2px);
}

.upload-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.5;
}

.upload-text strong {
  color: var(--accent);
  font-weight: 600;
}

.upload-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.upload-zone input {
  display: none;
}

.panel-left .upload-zone {
  padding: 28px 12px;
}

/* --- Thumbnail Grid --- */
.thumbnails {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.2s ease;
}

.thumb:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

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

@media (hover: hover) {
  .thumb-remove {
    opacity: 0;
  }
  .thumb:hover .thumb-remove {
    opacity: 1;
  }
}

.thumb.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(245, 158, 11, 0.15);
}

.thumb-select-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: white;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 1;
}

.thumb.selected .thumb-select-indicator {
  background: var(--accent);
  border-color: var(--accent);
}

.gallery-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.gallery-controls .btn {
  font-size: 12px;
  padding: 6px 12px;
}

.thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Action Bar --- */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-info {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

.action-info strong {
  color: var(--text);
}

.action-info .credit-cost {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}

.btn {
  padding: 7px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: #fbbf24;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Run button ready glow */
#runBtn:not(:disabled) {
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
  animation: readyPulse 2s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.15); }
  50% { box-shadow: 0 0 18px rgba(245, 158, 11, 0.35); }
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
}

/* --- Results Grid --- */
.results-section {
  margin-top: 8px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  padding: 6px 0 8px 0;
}

.results-header .section-label::after {
  display: none;
}

/* --- Results Empty State --- */
.results-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-dim);
}

.results-empty-icon {
  margin-bottom: 16px;
  opacity: 0.4;
}

.results-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.results-empty-hint {
  font-size: 12px;
  line-height: 1.6;
  max-width: 240px;
  margin: 0 auto;
  color: var(--text-dim);
}

.results-empty-steps {
  margin-top: 20px;
  text-align: left;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
}

.results-empty-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.results-empty-step .step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* --- Batch Groups (BATCH-03) --- */
.batch-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.batch-group.batch-complete {
  border-color: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.08);
}

.batch-group.batch-processing {
  border-color: var(--accent-dim);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.08);
}

.batch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.batch-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.batch-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-time {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.batch-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.batch-status-done {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
}

.batch-status-active {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
}

.batch-progress-bar {
  width: 60px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.batch-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.batch-group.batch-complete .batch-progress-fill {
  background: linear-gradient(90deg, #16a34a, var(--success));
}

.batch-results {
  padding: 8px;
}

.batch-results .results-grid {
  margin-top: 0;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
  transition: all 0.3s ease;
  animation: cardEnter 0.35s ease both;
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-card.processing {
  border-color: var(--accent-dim);
}

.result-card.done {
  border-color: var(--success);
}

.result-card.done:hover {
  border-color: var(--success);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.15);
}

.result-card.error {
  border-color: var(--error);
}

.result-images {
  display: grid;
  grid-template-columns: 1fr;
  aspect-ratio: var(--aspect-ratio, 3 / 2);
  overflow: hidden;
  min-width: 0;
}

.result-images .after {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-width: 0;
}

.result-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-info {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-name {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-status {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.result-status.pending {
  color: var(--text-muted);
}

.result-status.processing {
  color: var(--accent);
}

.result-status.done {
  color: var(--success);
}

.result-status.error {
  color: var(--error);
}

.result-actions {
  padding: 0 8px 6px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.result-actions .btn-sm {
  padding: 5px 6px;
  font-size: 11px;
  min-height: 28px;
  text-align: center;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Processing Overlay --- */
.processing-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.processing-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(245, 158, 11, 0.04) 50%, transparent 100%);
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.processing-placeholder .spinner {
  width: 24px;
  height: 24px;
  z-index: 1;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 56px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.success {
  border-left: 3px solid var(--success);
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Manage Presets Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  place-items: center;
}

.modal-overlay.open {
  display: grid;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 22px;
}

.modal h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.modal-presets-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.modal-preset-item {
  display: flex;
  gap: 10px;
  align-items: start;
}

.modal-preset-item input {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
}

.modal-preset-item input:focus {
  border-color: var(--accent);
}

.modal-preset-item .name-input {
  width: 140px;
  flex: none;
}

.modal-preset-item .prompt-input {
  flex: 1;
}

.modal-preset-item button {
  width: 28px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex: none;
}

.modal-preset-item button:hover {
  color: var(--error);
  border-color: var(--error);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* --- Image Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  place-items: center;
  padding: 24px;
}

.lightbox-overlay.open {
  display: grid;
}

.lightbox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(90vw, calc(100vw - 48px));
  max-width: 100%;
  height: 88vh;
  height: 88dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.lightbox-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-close {
  width: 32px;
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex: none;
  transition: all 0.2s;
}

.lightbox-close:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.lightbox-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.lightbox-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.lightbox-pane img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.lightbox-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.lightbox-nav button {
  width: 32px;
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all 0.2s;
}

.lightbox-nav button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-light);
}

.lightbox-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}

.lightbox-counter {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.lightbox-compare-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: none;
}

.lightbox-arrow-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

@media (max-width: 640px) {
  .lightbox-overlay {
    padding: 12px;
  }
  .lightbox {
    width: calc(100vw - 24px);
    height: 90vh;
    height: 90dvh;
  }
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .shell-header {
    flex-direction: column;
    gap: 8px;
    height: auto;
    min-height: auto;
    padding: 8px 16px;
    align-items: flex-start;
  }
  .user-section {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .user-email {
    display: none;
  }
  .preset-tabs {
    grid-template-columns: repeat(3, 1fr);
  }
  .settings-row {
    flex-direction: column;
  }
  .results-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
  .action-bar {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
  }
  .action-bar > div {
    justify-content: center;
  }
  .gallery-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  .result-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- Auth Views --- */
.auth-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-logo h1 span {
  color: var(--text-dim);
  font-weight: 400;
}

.auth-title {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 24px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-field input:focus {
  border-color: var(--accent);
}

.auth-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  color: var(--text-dim);
}

/* --- Credit Balance --- */
.credit-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.9rem;
  color: var(--text);
}

.credit-icon {
  color: var(--accent);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
}

.credit-count {
  font-weight: 600;
  color: var(--text);
}

.buy-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: 4px;
  min-height: 30px;
  transition: background 0.2s, color 0.2s;
}

.buy-btn:hover {
  background: var(--accent);
  color: white;
}

#creditBalance.zero-balance .credit-count {
  color: var(--error, #ff4444);
}

.credit-warning {
  color: var(--error, #ff4444);
  font-size: 0.85rem;
}

/* --- Admin Dashboard --- */
.admin-dashboard-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
  min-height: 44px;
  display: none;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
}

.admin-dashboard-btn:hover {
  background: var(--accent);
  color: #fff;
}

.admin-dashboard-btn svg {
  flex-shrink: 0;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 8px 0;
}

.stat-card {
  text-align: center;
  padding: 20px 12px;
  background: var(--card-bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

@media (max-width: 500px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }
  .thumbnails {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Admin Dashboard Tabs & User List --- */
#adminDashboardOverlay .modal {
  width: 90vw;
  max-width: 1100px;
}

.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.admin-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.admin-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  font-weight: 500;
}

.admin-users-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.admin-users-search {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.admin-users-search:focus {
  border-color: var(--accent);
}

.admin-users-search::placeholder {
  color: var(--text-muted);
}

.admin-users-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-users-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-users-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.admin-users-table th.sortable:hover {
  color: var(--text);
}

.admin-users-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--text);
}

.admin-users-table tr:hover td {
  background: var(--bg);
}

.admin-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}

.admin-sort-indicator {
  font-size: 0.7rem;
  margin-left: 4px;
  color: var(--accent);
}

.admin-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 0;
}

.admin-pagination button {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s, color 0.2s;
}

.admin-pagination button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
}

.admin-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-pagination .page-info {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.admin-status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.admin-status-badge.verified {
  background: rgba(34,197,94,0.15);
  color: var(--success);
}

.admin-status-badge.unverified {
  background: rgba(245,158,11,0.15);
  color: var(--accent);
}

.admin-status-badge.locked {
  background: rgba(239,68,68,0.15);
  color: var(--error);
}

.admin-status-badge.active {
  background: rgba(34,197,94,0.1);
  color: var(--success);
}

.admin-status-badge.purchase {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

.admin-status-badge.usage {
  background: rgba(245,158,11,0.15);
  color: var(--accent);
}

.admin-status-badge.refund {
  background: rgba(168,85,247,0.15);
  color: #a855f7;
}

.admin-status-badge.grant {
  background: rgba(34,197,94,0.15);
  color: var(--success);
}

.admin-status-badge.suspended {
  background: rgba(239,68,68,0.2);
  color: #dc2626;
  font-weight: 700;
}

.admin-status-badge.role-user {
  background: rgba(107,114,128,0.15);
  color: #6b7280;
}

.admin-status-badge.role-superuser {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

.admin-status-badge.role-admin {
  background: rgba(168,85,247,0.15);
  color: #a855f7;
}

.admin-action-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  font-weight: 600;
  margin-right: 8px;
  margin-bottom: 8px;
}

.admin-action-btn:hover {
  opacity: 0.9;
}

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

.admin-action-btn.unlock {
  background: var(--success);
  color: #fff;
}

.admin-action-btn.suspend {
  background: var(--error);
  color: #fff;
}

.admin-action-btn.unsuspend {
  background: var(--accent);
  color: #fff;
}

.admin-user-link {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.admin-user-link:hover {
  text-decoration: underline;
}

.admin-back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
}

.admin-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.admin-credit-form {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.admin-credit-form h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.admin-credit-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-credit-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  width: 100px;
}

.admin-credit-input:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-credit-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  min-width: 160px;
}

.admin-credit-select:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-credit-custom-note {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
}

.admin-credit-custom-note:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-credit-submit {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  font-weight: 600;
}

.admin-credit-submit:hover {
  opacity: 0.9;
}

.admin-credit-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-detail-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-detail-item .label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-detail-item .value {
  font-size: 1rem;
  font-weight: 600;
}

/* --- Admin Promo Management --- */
.admin-status-badge.free_credits {
  background: rgba(34,197,94,0.15);
  color: var(--success);
}

.admin-status-badge.bonus_credits {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

.admin-status-badge.percentage_discount {
  background: rgba(168,85,247,0.15);
  color: #a855f7;
}

.admin-status-badge.inactive {
  background: rgba(239,68,68,0.15);
  color: var(--error);
}

.promo-code-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-promo-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}

.admin-promo-form h3 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.admin-promo-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-promo-form-row.full {
  grid-template-columns: 1fr;
}

.admin-promo-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-promo-field label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
}

.admin-promo-field input,
.admin-promo-field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.admin-promo-field input:focus,
.admin-promo-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-textarea {
  width: 100%;
  resize: vertical;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.admin-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-promo-field .hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.admin-promo-field input[type="text"].code-input {
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}

.admin-promo-readonly {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.admin-promo-readonly .label {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.admin-promo-readonly .value {
  font-weight: 600;
}

.admin-promo-actions {
  display: flex;
  gap: 6px;
}

.admin-promo-actions button {
  padding: 6px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.admin-promo-actions button:hover {
  background: var(--bg);
}

.admin-promo-actions button.deactivate {
  color: var(--error);
  border-color: var(--error);
}

.admin-promo-actions button.activate {
  color: var(--success);
  border-color: var(--success);
}

.admin-promo-submit {
  padding: 8px 20px;
  background: var(--accent);
  color: var(--bg-dark, #000);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 8px;
}

.admin-promo-submit:hover {
  opacity: 0.9;
}

.admin-promo-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .admin-users-toolbar {
    flex-direction: column;
  }
  .admin-users-search {
    min-width: 100%;
  }
  .admin-users-table {
    font-size: 0.8rem;
  }
  .admin-users-table th,
  .admin-users-table td {
    padding: 8px 6px;
  }
  .admin-promo-form-row {
    grid-template-columns: 1fr;
  }
  .admin-promo-readonly {
    flex-direction: column;
    gap: 8px;
  }
}

/* --- Buy Credits Modal --- */
.credit-pack-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.credit-pack-card:hover {
  border-color: var(--accent);
}

.credit-pack-info {
  display: flex;
  flex-direction: column;
}

.pack-name {
  font-weight: 600;
}

.pack-price {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.credit-pack-buy {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity 0.2s;
}

.credit-pack-buy:hover {
  opacity: 0.9;
}

.credit-pack-buy:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Email Verification Banner --- */
.verify-banner {
  background: #1e1a11;
  border: 1px solid #b4530940;
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--accent);
}

.verify-banner-text {
  flex: 1;
}

.verify-banner .btn-resend {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: opacity 0.2s;
}

.verify-banner .btn-resend:hover {
  opacity: 0.9;
}

.verify-banner .btn-resend:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.verify-banner .btn-resend.sent {
  background: var(--success);
  color: #fff;
}


/* powered-text styles moved to .shell-header .powered-text above */

/* --- History --- */
.history-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity 0.2s;
  display: none;
}

.history-btn:hover {
  opacity: 0.85;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.history-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-card img {
  width: 100%;
  aspect-ratio: var(--aspect-ratio, 3 / 2);
  object-fit: cover;
  display: block;
}

.history-info {
  padding: 10px;
  flex: 1;
}

.history-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.history-card .btn {
  margin: 0 10px 10px;
}

.history-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

.history-check {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.history-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.history-toggle {
  margin: 0 10px 10px;
  font-size: 0.75rem;
}

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.history-toolbar .count {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.history-toolbar .btn {
  font-size: 0.8rem;
  padding: 5px 12px;
}

/* --- Promo Code Redemption --- */
.promo-section {
  margin-top: 16px;
}

.promo-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.promo-divider::before,
.promo-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.promo-divider span {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.promo-input-row {
  display: flex;
  gap: 8px;
}

#promoCodeInput {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#promoCodeInput::placeholder {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

#promoCodeInput:focus {
  outline: none;
  border-color: var(--accent);
}

.promo-preview {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.promo-preview-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.promo-preview-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.promo-preview button {
  width: 100%;
  background: var(--success);
  color: #fff;
  padding: 8px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.promo-preview button:hover {
  opacity: 0.9;
}

.promo-preview button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.promo-preview-info {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.promo-preview-info .promo-preview-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.promo-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.8rem;
}

.promo-success {
  margin-top: 8px;
  padding: 12px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius-sm);
  color: var(--success);
  font-size: 0.85rem;
  text-align: center;
}

/* --- API Key Management Section (Super User) --- */
#apiKeySection {
  display: none;
  align-items: center;
  gap: 8px;
}

.api-key-icon {
  font-size: 1rem;
}

.api-key-hint {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* --- API Key Missing Banner (Super User) --- */
.api-key-banner {
  background: #1e1a11;
  border: 1px solid #b4530940;
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--accent);
}

.api-key-banner-text {
  flex: 1;
}

.api-key-banner .btn-add-key {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: opacity 0.2s;
}

.api-key-banner .btn-add-key:hover {
  opacity: 0.9;
}

/* --- Admin Preset Example Image Preview --- */
.preset-example-preview {
  margin-bottom: 8px;
}
.preset-example-preview img {
  max-width: 200px;
  max-height: 150px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 8px;
}

/* ========================================================================
   Workspace Tabs (Style / Staging toggle in header)
   ======================================================================== */
.workspace-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.workspace-tab {
  padding: 6px 16px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.workspace-tab:hover { color: var(--text); }
.workspace-tab.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* ========================================================================
   Staging Workspace Layout
   ======================================================================== */
.staging-workspace {
  grid-row: 2;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

/* --- Lane Tab Bar --- */
.lane-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.lane-tabs::-webkit-scrollbar { display: none; }
.lane-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.lane-tab:hover { color: var(--text); background: var(--surface-2); }
.lane-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border) var(--border) transparent;
  font-weight: 600;
}
.lane-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.lane-tab:hover .lane-tab-close,
.lane-tab.active .lane-tab-close { opacity: 1; }
.lane-tab-close:hover { color: var(--error); background: rgba(239,68,68,0.1); }
.lane-tab-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.lane-tab-error {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}
.lane-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-family: var(--font);
  color: var(--text-muted);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.lane-tab-add:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.lane-tab-add:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Staging 3-Column Panels --- */
.staging-panels {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
.staging-panel-left {
  border-right: 1px solid var(--border);
}
.staging-panel-center {
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.staging-panel-left,
.staging-panel-center,
.staging-panel-right {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  min-height: 0;
}

/* --- Staging Upload Zone (left panel) --- */
.staging-upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 28px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s;
  position: relative;
}
.staging-upload-zone:hover,
.staging-upload-zone.dragover { border-color: var(--accent); }
.staging-upload-zone input[type="file"] { display: none; }

/* --- Staging Upload Gallery --- */
.staging-upload-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.staging-upload-thumb {
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: border-color 0.15s;
}
.staging-upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.staging-upload-thumb:hover { border-color: var(--border-light); }
.staging-upload-thumb.assigned { border-color: var(--accent); }
.staging-upload-thumb.assigned-other { border-color: var(--border-light); }
.staging-photo-assigned {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.staging-photo-assigned.assigned-other-badge {
  background: var(--text-secondary);
  color: var(--bg);
  font-size: 9px;
}

/* --- Staging Upload Error State --- */
.staging-upload-error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(220, 38, 38, 0.25);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.staging-upload-retry,
.staging-upload-remove {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.staging-upload-retry:hover,
.staging-upload-remove:hover { transform: scale(1.15); }
.staging-upload-retry {
  background: var(--accent);
  color: #000;
}
.staging-upload-remove {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* --- Staging Results Sort Toggle --- */
.staging-results-sort {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.staging-results-sort .sort-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.staging-results-sort .sort-btn:hover { color: var(--text); }
.staging-results-sort .sort-btn.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.15); }

/* --- Staging Result Badge --- */
.staging-result-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.7);
  border-radius: 3px;
  backdrop-filter: blur(4px);
}

/* --- Staging: Center Panel Controls (mode, style, prompt, generate) --- */
.staging-assigned-photo {
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.staging-assigned-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.staging-assigned-photo-empty {
  aspect-ratio: 3 / 2;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
.lane-mode-selector { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.lane-mode-btn {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  font-size: 11px;
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.lane-mode-btn:hover { border-color: var(--border-light); color: var(--text); }
.lane-mode-btn:active { background: var(--surface-3); transform: scale(0.96); }
.lane-mode-btn.active { background: var(--accent); color: #000; font-weight: 600; border-color: var(--accent); }
.lane-mode-btn.active:active { background: var(--accent-dim); }
.lane-section-label { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-bottom: 4px; }
.lane-style-picker { margin-top: 8px; }
.lane-style-select { width: 100%; margin-top: 2px; }
/* --- Staging: Prompt Area & Generate Controls --- */
.lane-prompt-area { margin-top: 4px; }
.lane-prompt {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  box-sizing: border-box;
}
.lane-prompt:focus { border-color: var(--accent); outline: none; }
.lane-prompt::placeholder { color: var(--text-muted); }
.lane-generate-controls { margin-top: 4px; }
.lane-settings-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.lane-settings-row .setting-group { display: flex; align-items: center; gap: 4px; flex: 1; }
.lane-settings-row .setting-group label { font-size: 11px; color: var(--text-dim); font-weight: 500; white-space: nowrap; }
.lane-settings-row .setting-select { flex: 1; }
.lane-generate-btn { width: 100%; padding: 8px; font-size: 13px; font-weight: 600; transition: transform 0.1s, opacity 0.1s; }
.lane-generate-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.lane-generate-btn:not(:disabled):active { transform: scale(0.97); }
.lane-enhance-btn { width: 100%; margin-top: 4px; padding: 6px 8px; font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; transition: transform 0.1s, opacity 0.1s; }
.lane-enhance-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.lane-enhance-btn:not(:disabled):active { transform: scale(0.97); }
.lane-generate-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 4px; }

/* Lane progress spinner (inside generate button) */
.lane-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  animation: laneSpin 0.6s linear infinite;
}

@keyframes laneSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Staging: Results Controls (sort + clear) --- */
.staging-results-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.staging-results-clear {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}

/* --- Staging: Results Grouped Container --- */
.staging-results-grouped {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* --- Staging: Results Group (by-source view) --- */
.staging-results-group {
  margin-bottom: 16px;
}
.staging-results-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.staging-results-group-thumb {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm, 4px);
  object-fit: cover;
  border: 1px solid var(--border);
}
.staging-results-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Staging: Results Grid (right panel) --- */
.staging-result-thumb {
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-sm, 4px);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
  position: relative;
}
.staging-result-thumb:hover { border-color: var(--accent); }
.staging-result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- Staging: Result Download Button --- */
.staging-result-download {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm, 4px);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}
.staging-result-thumb:hover .staging-result-download { opacity: 1; }
.staging-result-download:hover { background: rgba(0,0,0,0.8); }

/* --- Staging: Processing placeholder in results grid --- */
.staging-result-processing { cursor: default; }
.staging-result-processing:hover { border-color: var(--border); }
.staging-result-processing .processing-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* --- Staging: Panel scrollbar hide-until-hover --- */
.staging-panel-left,
.staging-panel-center,
.staging-panel-right {
  scrollbar-width: none;
}
.staging-panel-left::-webkit-scrollbar,
.staging-panel-center::-webkit-scrollbar,
.staging-panel-right::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}
.staging-panel-left::-webkit-scrollbar-thumb,
.staging-panel-center::-webkit-scrollbar-thumb,
.staging-panel-right::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.staging-panel-left:hover,
.staging-panel-center:hover,
.staging-panel-right:hover {
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.staging-panel-left:hover::-webkit-scrollbar-thumb,
.staging-panel-center:hover::-webkit-scrollbar-thumb,
.staging-panel-right:hover::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

/* --- Staging: Lane tab keyboard focus --- */
.lane-tab:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.lane-tab-add:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

/* --- Staging Mobile Bottom Tabs --- */
.staging-mobile-tabs {
  display: none;
}

/* --- Staging responsive mobile layout --- */
@media (max-width: 768px) {
  .workspace-tabs {
    display: flex !important;
    gap: 2px;
    padding: 2px;
  }
  .workspace-tab {
    padding: 4px 12px;
    font-size: 12px;
  }
  .staging-active .mobile-tabs {
    display: none !important;
  }
  .staging-mobile-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .staging-active .staging-mobile-tabs {
    display: flex;
  }
  .staging-mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-family: var(--font);
    min-height: 48px;
    cursor: pointer;
    position: relative;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .staging-mobile-tab.active {
    color: var(--accent);
  }
  .staging-mobile-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
  }
  .staging-workspace {
    grid-template-rows: auto 1fr;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .lane-tabs {
    padding: 4px 8px;
    gap: 1px;
  }
  .lane-tab {
    padding: 5px 10px;
    font-size: 11px;
    min-height: 32px;
  }
  .lane-tab-close {
    opacity: 1;
    width: 20px;
    height: 20px;
    font-size: 16px;
  }
  .lane-tab-add {
    width: 32px;
    height: 32px;
  }
  .staging-panels {
    grid-template-columns: 1fr;
    overflow: hidden;
  }
  .staging-panel-left,
  .staging-panel-center,
  .staging-panel-right {
    display: none;
    overflow-y: auto;
    height: 100%;
    border-right: none;
    border-bottom: none;
    padding-bottom: 24px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    /* Always show scrollbar on mobile (touch scroll) */
    scrollbar-width: auto;
  }
  .staging-panel-left::-webkit-scrollbar-thumb,
  .staging-panel-center::-webkit-scrollbar-thumb,
  .staging-panel-right::-webkit-scrollbar-thumb {
    background: var(--border-light);
  }
  .staging-panel-left.stab-active,
  .staging-panel-center.stab-active,
  .staging-panel-right.stab-active {
    display: block;
  }
  /* Touch targets: ensure mode buttons are large enough */
  .lane-mode-btn {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 12px;
  }
  .lane-generate-btn {
    min-height: 44px;
    padding: 10px;
    font-size: 14px;
  }
  .lane-enhance-btn {
    min-height: 40px;
    padding: 8px;
  }
  .staging-upload-zone {
    padding: 24px 12px;
  }
  .staging-upload-thumb {
    min-width: 0;
    min-height: 0;
  }
  .staging-results-controls {
    flex-wrap: wrap;
    gap: 4px;
  }
}
