:root {
  --bg: #000000;
  --bg-1: #0a0a0a;
  --bg-2: #111111;
  --bg-elevated: #1a1a1a;
  --bg-hover: #1f1f1f;

  --border: rgba(255,255,255,0.06);
  --border-h: rgba(255,255,255,0.12);
  --border-active: rgba(255,255,255,0.25);

  --t1: #f5f5f7;
  --t2: #86868b;
  --t3: #48484a;

  --accent: #ffffff;
  --accent-dim: rgba(255,255,255,0.10);
  --ok: #30d158;
  --ok-dim: rgba(48,209,88,0.12);
  --err: #ff453a;
  --err-dim: rgba(255,69,58,0.12);

  --r: 10px;
  --r-sm: 8px;
  --r-lg: 14px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --ease: .25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); background: var(--bg); color: var(--t1); min-height: 100vh; line-height: 1.5; }

.hidden { display: none !important; }

/* ── App Shell ─────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Header ────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
  flex-shrink: 0;
}
.header__brand { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.header__logo { height: 24px; width: auto; }
.header__right { display: flex; align-items: center; gap: 12px; }
.balance-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 100px; font-size: .8rem; font-weight: 500; color: var(--t2);
  font-family: var(--mono);
}

/* ── Tab Bar ───────────────────────────────────────────── */
.tab-bar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 24px;
  background: rgba(0,0,0,0.6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 8px;
  font-size: .75rem; font-weight: 500; font-family: var(--font);
  color: var(--t3); background: transparent;
  border: none; cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--t2); background: rgba(255,255,255,0.04); }
.tab--active {
  color: var(--t1); background: rgba(255,255,255,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.tab--active:hover { color: var(--t1); }

/* ── Tab Content ───────────────────────────────────────── */
.tab-content {
  flex: 1; overflow-y: auto;
  animation: tabFadeIn .2s ease;
}
.tab-content::-webkit-scrollbar { width: 6px; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
.tab-content--hidden { display: none !important; }
#tab-studio { overflow: hidden; display: flex; flex-direction: column; }
@keyframes tabFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Tab Placeholder (for upcoming phases) */
.tab-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 16px; color: var(--t3); padding: 40px;
}
.tab-placeholder__icon { width: 48px; height: 48px; opacity: .3; }
.tab-placeholder__title { font-size: 1.2rem; font-weight: 700; color: var(--t2); }
.tab-placeholder__text { font-size: .85rem; text-align: center; max-width: 400px; line-height: 1.6; }

/* ── Global Drop Overlay ───────────────────────────────── */
.drop-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  display: none; align-items: center; justify-content: center;
  pointer-events: none;
}
.drop-overlay--visible { display: flex; pointer-events: auto; }
.drop-overlay__content {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 60px 80px;
  border: 2px dashed var(--accent);
  border-radius: 24px;
  animation: dropPulse 2s ease infinite;
}
.drop-overlay__icon { width: 56px; height: 56px; color: var(--accent); }
.drop-overlay__text { font-size: 1.3rem; font-weight: 700; color: var(--t1); }
.drop-overlay__hint { font-size: .85rem; color: var(--t2); }
@keyframes dropPulse {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: rgba(255,255,255,0.3); }
}

/* ── Draggable Items ───────────────────────────────────── */
.history-item[draggable="true"] { cursor: grab; }
.history-item[draggable="true"]:active { cursor: grabbing; }
.history-item--dragging { opacity: .4; }
.player-card[draggable="true"] { cursor: grab; }
.dropzone--drag-over {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
  box-shadow: 0 0 20px rgba(255,255,255,0.12);
}
.upload-card--pulse { animation: uploadPulse .6s ease; }
@keyframes uploadPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.25); }
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ── Layout ────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar (Left) ────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  overflow: hidden;
}
.sidebar__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar__scroll::-webkit-scrollbar { width: 0; }

/* Section headers */
.section-label {
  font-size: .65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--t3); margin-bottom: 6px;
}

/* Model dropdown */
.model-select {
  width: 100%; padding: 10px 12px; font-size: .82rem; font-weight: 500;
  appearance: none; -webkit-appearance: none;
  background: var(--bg-elevated) 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='rgba(255,255,255,.4)' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--t1); cursor: pointer; transition: border-color var(--ease);
}
.model-select:hover { border-color: var(--border-h); }
.model-select:focus { outline: none; border-color: var(--accent); }

/* Model cost chip */
.model-cost-chip {
  display: flex; align-items: center; gap: 5px;
  margin-top: 6px; font-size: .7rem; color: var(--t3); font-weight: 500;
}
.model-cost-chip span { color: var(--accent); font-weight: 700; }

/* Generation count + total cost */
.gen-settings { margin-top: -4px; }
.gen-count-row { display: flex; align-items: flex-end; gap: 12px; }
.gen-total {
  display: flex; flex-direction: column; align-items: flex-end;
  padding-bottom: 4px; min-width: 70px;
}
.gen-total__label { font-size: .6rem; color: var(--t3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.gen-total__value { font-size: 1rem; font-weight: 800; color: var(--accent); }
/* Upload cards in sidebar */
.upload-section { display: flex; flex-direction: column; gap: 8px; }
.upload-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px; transition: border-color var(--ease);
}
.upload-card:hover { border-color: var(--border-h); }
.upload-card__header {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; font-weight: 600; color: var(--t2);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em;
}
.upload-card__header span { flex: 1; }
.card__clear {
  background: none; border: none; color: var(--t3);
  cursor: pointer; padding: 2px; border-radius: 4px;
}
.card__clear:hover { color: var(--err); }

.dropzone {
  position: relative; border: 1.5px dashed var(--border);
  border-radius: var(--r-sm); padding: 16px 8px; text-align: center;
  cursor: pointer; transition: all var(--ease);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.dropzone:hover, .dropzone--active { border-color: var(--accent); background: var(--accent-dim); }
.dropzone--has-file { border-color: var(--ok); border-style: solid; background: var(--ok-dim); }
.dropzone__icon { color: var(--t3); }
.dropzone__text { font-size: .75rem; color: var(--t2); }
.dropzone__hint { font-size: .6rem; color: var(--t3); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.media-preview { border-radius: var(--r-sm); overflow: hidden; position: relative; background: #000; margin-bottom: 6px; }
.media-preview img, .media-preview video { width: 100%; display: block; max-height: 140px; object-fit: contain; }
.preview-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4); border: none; color: #fff; cursor: pointer;
}
.preview-play:hover { background: rgba(0,0,0,.2); }

.url-row { margin-top: 6px; }
.upload-status { display: flex; align-items: center; gap: 5px; font-size: .7rem; color: var(--accent); margin-top: 4px; }

/* Options */
.options-section { display: flex; flex-direction: column; gap: 8px; }
.options-grid { display: flex; flex-direction: column; gap: 10px; }
.options-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field__label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--t3); }

/* Model Info Panel */
.model-info { margin-bottom: 8px; }
.model-info__toggle {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 0; font-size: .72rem; color: var(--t3);
  user-select: none; transition: color .15s;
}
.model-info__toggle:hover { color: var(--accent); }
.model-info__chevron { transition: transform .2s ease; }
.model-info__body {
  padding: 8px 12px; margin-top: 4px; border-radius: var(--r-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.model-info__row {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: .72rem; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.model-info__row:last-child { border-bottom: none; }
.model-info__row span:first-child { color: var(--t3); }
.model-info__row span:last-child { color: var(--t1); font-weight: 500; }

.input {
  width: 100%; padding: 7px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--t1); font-size: .8rem; font-family: var(--font);
  outline: none; transition: border-color var(--ease);
}
.input:focus { border-color: var(--border-active); }
.input::placeholder { color: var(--t3); }
.input--mono { font-family: var(--mono); font-size: .75rem; }
.input--sm { padding: 4px 8px; font-size: .72rem; }
select.input {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2348484a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px;
}
select.input option { background: var(--bg-2); color: var(--t1); }
textarea.input { resize: vertical; min-height: 44px; font-family: var(--font); }

.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .75rem; color: var(--t2); }
.toggle input { display: none; }
.toggle__slider {
  width: 34px; height: 20px; background: var(--bg-elevated); border-radius: 100px;
  position: relative; transition: background var(--ease); flex-shrink: 0;
}
.toggle__slider::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: var(--t3); border-radius: 50%;
  transition: all var(--ease);
}
.toggle input:checked + .toggle__slider { background: var(--ok); }
.toggle input:checked + .toggle__slider::after { left: 16px; background: #fff; }

.preset-row { display: flex; gap: 4px; }
.preset-row .input--sm { flex: 1; }

/* Action buttons */
.action-group {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 20px 16px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--r-sm); font-size: .8rem; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: all var(--ease); border: none;
  text-decoration: none;
}
.btn--primary { background: var(--t1); color: #000; }
.btn--primary:hover:not(:disabled) { opacity: .88; }
.btn--primary:disabled { opacity: .3; cursor: not-allowed; }
.btn--secondary { background: var(--bg-elevated); color: var(--t2); }
.btn--secondary:hover { background: var(--bg-hover); color: var(--t1); }
.btn--ghost { background: transparent; color: var(--t2); border: 1px solid var(--border); }
.btn--ghost:hover { border-color: var(--border-h); color: var(--t1); }
.btn--sm { padding: 5px 10px; font-size: .72rem; }
.btn--danger { background: transparent; color: var(--err); border: 1px solid rgba(255,69,58,.2); }
.btn--danger:hover { background: var(--err-dim); }

/* ── Output Area (Right) ───────────────────────────────── */
.output {
  overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.output::-webkit-scrollbar { width: 6px; }
.output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }

/* Active result / player */
.player-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.player-video { width: 100%; display: block; max-height: 60vh; background: #000; object-fit: contain; }
.player-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 8px;
}
.player-bar__info { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--t2); }
.player-bar__actions { display: flex; gap: 6px; }

/* Status card inside output */
.status-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; text-align: center;
}
.status-card__header { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 16px; }
.status-card__title { font-size: 1rem; font-weight: 600; }
.status-card__subtitle { font-size: .8rem; color: var(--t2); margin-bottom: 12px; }
.status-card__timer { font-family: var(--mono); font-size: .85rem; color: var(--t3); }
.progress-bar { width: 100%; height: 3px; background: var(--bg-elevated); border-radius: 100px; overflow: hidden; margin: 12px 0; }
.progress-bar__fill { height: 100%; background: var(--t1); border-radius: 100px; transition: width .5s ease; }

/* Error */
.error-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-1); border: 1px solid rgba(255,69,58,.2);
  border-radius: var(--r-lg); padding: 16px;
}
.error-card__title { font-size: .85rem; font-weight: 600; color: var(--err); }
.error-card__message { font-size: .78rem; color: var(--t2); font-family: var(--mono); word-break: break-word; margin-top: 2px; }

/* Compare */
.compare-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
}
.compare-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; font-size: .8rem; font-weight: 600; color: var(--t2);
}
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.compare-side { position: relative; }
.compare-label {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.75);
  padding: 2px 8px; border-radius: 4px; font-size: .6rem; font-weight: 600;
  text-transform: uppercase; z-index: 1;
}
.compare-video { width: 100%; border-radius: var(--r-sm); background: #000; display: block; }

/* ── History Grid ──────────────────────────────────────── */
.history-header {
  display: flex; align-items: center; justify-content: space-between;
}
.history-header__title { font-size: .85rem; font-weight: 600; color: var(--t2); }

.history-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 60px 0; color: var(--t3); font-size: .85rem;
}

.history-grid {
  --history-col-width: 200px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--history-col-width), 1fr));
  gap: 12px;
}

.history-item {
  position: relative; border-radius: var(--r); overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--ease);
}
.history-item:hover { border-color: var(--border-h); transform: translateY(-1px); }

.history-item__thumb-wrap { position: relative; aspect-ratio: 9/16; background: #000; overflow: hidden; }
.history-item__thumb { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.history-item__overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); opacity: 0; transition: opacity var(--ease);
}
.history-item:hover .history-item__overlay { opacity: 1; }

.history-item__info { padding: 10px 12px; }
.history-item__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.history-item__model { font-size: .7rem; font-weight: 600; color: var(--accent); }
.history-item__time { font-size: .65rem; color: var(--t3); font-family: var(--mono); }
.history-item__actions { display: flex; gap: 3px; margin-top: 6px; }
.history-item__actions .btn { flex: 1; padding: 4px; font-size: .65rem; }

/* Loading skeleton card */
.history-item--loading { pointer-events: none; }
.history-item__skeleton {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 10px;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
.history-item__skeleton .icon-md { color: var(--accent); opacity: .6; }
.history-item__skeleton-text { font-size: .72rem; color: var(--text-dim); font-weight: 500; }
@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* Loading card ETA progress */
.loading-eta {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.loading-eta__label {
  font-size: .72rem; color: var(--accent); font-weight: 600;
  font-family: var(--mono);
}
.loading-eta__countdown {
  font-size: .65rem; color: var(--t3); font-family: var(--mono);
}
.loading-progress-wrap {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: rgba(255,255,255,0.06);
}
.loading-progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #ffffff, #a0a0a0);
  border-radius: 0 2px 2px 0;
  transition: width .5s ease;
}
.loading-elapsed {
  font-family: var(--mono);
  color: var(--accent) !important;
  font-weight: 600 !important;
}

/* ── Fullscreen ────────────────────────────────────────── */
.fullscreen-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 1000;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  backdrop-filter: blur(20px);
}
.fullscreen-overlay--visible { display: flex; }
.fullscreen-close {
  position: absolute; top: 16px; right: 16px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t1); cursor: pointer;
}
.fullscreen-close:hover { background: var(--bg-hover); }
.fullscreen-video { max-width: 88vw; max-height: 72vh; border-radius: var(--r-lg); }
.fullscreen-actions { display: flex; gap: 8px; }

/* ── Icons ─────────────────────────────────────────────── */
.icon-xs { width: 13px; height: 13px; }
.icon-sm { width: 15px; height: 15px; }
.icon-md { width: 22px; height: 22px; }
.icon-lg { width: 28px; height: 28px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Multi-File Upload ─────────────────────────────────── */
.multi-files { display: flex; flex-direction: column; gap: 6px; }
.multi-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.multi-thumb {
  position: relative; width: 56px; height: 56px; border-radius: 6px;
  overflow: hidden; border: 1px solid var(--border);
}
.multi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.multi-thumb__remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  background: rgba(0,0,0,.7); border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; opacity: 0; transition: opacity var(--ease);
}
.multi-thumb:hover .multi-thumb__remove { opacity: 1; }

/* ── Header: Left section ─────────────────────────────── */
.header__left { display: flex; align-items: center; gap: 8px; }

/* Hamburger (hidden on desktop) */
.header__hamburger {
  display: none;
  background: none; border: none; color: var(--t2);
  cursor: pointer; padding: 4px; border-radius: var(--r-sm);
  transition: color var(--ease), background var(--ease);
}
.header__hamburger:hover { color: var(--t1); background: var(--bg-hover); }

/* Session cost chip */
.cost-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px; background: var(--accent-dim); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 100px; font-size: .8rem; font-weight: 500; color: var(--accent);
  font-family: var(--mono); cursor: default; transition: background var(--ease);
}
.cost-chip:hover { background: rgba(255,255,255,0.15); }

/* Accent button */
.btn--accent {
  background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(255,255,255,0.15);
  transition: background var(--ease), border-color var(--ease);
}
.btn--accent:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.25); }

/* Shortcut hints */
.shortcut-hint {
  font-family: var(--mono); font-size: .65rem; font-weight: 500;
  color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.06);
  padding: 1px 5px; border-radius: 4px; margin-left: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}

/* Sidebar backdrop (hidden on desktop, shown by JS on mobile) */
.sidebar__backdrop {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.sidebar__backdrop--visible { opacity: 1; pointer-events: auto; }

/* ── Gallery ──────────────────────────────────────────── */
.gallery {
  display: flex; flex-direction: column; height: 100%;
  overflow-y: auto; padding: 20px 24px;
}
.gallery::-webkit-scrollbar { width: 6px; }
.gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }

.gallery__toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.gallery__toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.gallery__toolbar-right { display: flex; align-items: center; gap: 8px; }

.gallery__zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t3);
  margin-left: 4px;
}
.gallery__zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.gallery__zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform .15s ease;
}
.gallery__zoom-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.gallery__zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
.gallery__search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.gallery__search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--t3); pointer-events: none; }
.gallery__search { padding-left: 30px !important; }
.gallery__filter { min-width: 120px; max-width: 160px; }
.gallery__sort { min-width: 100px; }

.gallery__fav-btn--active {
  background: rgba(255,69,58,0.12) !important;
  color: var(--err) !important;
  border-color: rgba(255,69,58,0.25) !important;
}

.gallery__stats {
  font-size: .75rem; color: var(--t3); font-weight: 500;
  margin-bottom: 16px; font-family: var(--mono);
}

.gallery__grid {
  --gallery-col-width: 200px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--gallery-col-width), 1fr));
  gap: 14px;
}

.gallery__card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: all var(--ease);
}
.gallery__card:hover { border-color: var(--border-h); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,.3); }

.gallery__card-thumb {
  position: relative; aspect-ratio: 9/16; background: #000; overflow: hidden;
}
.gallery__card-thumb img, .gallery__card-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease;
}
.gallery__card:hover .gallery__card-thumb img,
.gallery__card:hover .gallery__card-thumb video { transform: scale(1.03); }

.gallery__card-fav {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.6); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--t2); transition: all .2s ease;
  opacity: 0;
}
.gallery__card:hover .gallery__card-fav { opacity: 1; }
.gallery__card-fav--active {
  opacity: 1 !important;
  color: var(--err) !important;
  background: rgba(255,69,58,0.3) !important;
}
.gallery__card-fav--active svg { fill: var(--err); }

.gallery__card-status {
  position: absolute;
  bottom: .4rem;
  left: .4rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .65rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .02em;
  z-index: 2;
  text-transform: uppercase;
}

.gallery__card-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); opacity: 0; transition: opacity var(--ease);
}
.gallery__card:hover .gallery__card-overlay { opacity: 1; }

.gallery__card-info { padding: 12px 14px; }
.gallery__card-top {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;
}
.gallery__card-model { font-size: .7rem; font-weight: 600; color: var(--accent); }
.gallery__card-cost { font-size: .65rem; font-family: var(--mono); color: var(--t3); }
.gallery__card-prompt {
  font-size: .72rem; color: var(--t2); line-height: 1.4;
  margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gallery__card-bottom {
  display: flex; align-items: center; justify-content: space-between;
}
.gallery__card-date { font-size: .6rem; color: var(--t3); font-family: var(--mono); }
.gallery__card-actions { display: flex; gap: 3px; }
.gallery__card-actions .btn { padding: 3px 6px; }

/* Gallery loading/empty */
.gallery__loading, .gallery__empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 0; color: var(--t3); font-size: .85rem;
}

/* Lightbox */
.gallery__lightbox {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.92); backdrop-filter: blur(20px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 20px;
}
.gallery__lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t1); cursor: pointer; z-index: 1;
}
.gallery__lightbox-close:hover { background: var(--bg-hover); }
.gallery__lightbox-content { max-width: 80vw; max-height: 60vh; }
.gallery__lightbox-img { max-width: 100%; max-height: 60vh; border-radius: var(--r-lg); object-fit: contain; }
.gallery__lightbox-video { max-width: 80vw; max-height: 60vh; border-radius: var(--r-lg); }
.gallery__lightbox-meta {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 16px; max-width: 500px; width: 100%;
}
.lightbox-meta__row {
  display: flex; gap: 12px; padding: 4px 0; font-size: .78rem;
  border-bottom: 1px solid var(--border);
}
.lightbox-meta__row:last-child { border-bottom: none; }
.lightbox-meta__label { color: var(--t3); font-weight: 600; min-width: 60px; text-transform: uppercase; font-size: .65rem; letter-spacing: .04em; }
.lightbox-meta__value { color: var(--t1); flex: 1; }
.lightbox-meta__prompt { font-family: var(--font); line-height: 1.5; }
.gallery__lightbox-actions { display: flex; gap: 8px; }

/* ── Cost Dashboard ───────────────────────────────────── */
.costs {
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 24px;
}

.costs__kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.costs__kpi {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px; border-radius: var(--r-lg);
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  transition: all var(--ease);
}
.costs__kpi:hover { border-color: var(--border-h); background: rgba(255,255,255,0.05); }
.costs__kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.08); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.costs__kpi-body { display: flex; flex-direction: column; gap: 2px; }
.costs__kpi-label { font-size: .65rem; color: var(--t3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.costs__kpi-value { font-size: 1.3rem; font-weight: 700; color: var(--t1); font-family: var(--mono); }
.costs__kpi-sub { font-size: .68rem; color: var(--t3); }

.costs__section-title {
  font-size: .78rem; color: var(--t2); font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: .03em;
}

.costs__chart-wrap {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 20px;
}
.costs__chart-container { height: 240px; position: relative; }

.costs__kpi-value--green { color: var(--ok) !important; }

.costs__combined-section {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 20px;
}
.costs__combined-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.costs__combined-filter { display: flex; align-items: center; gap: 8px; }
.costs__filter-label { font-size: .78rem; color: var(--text-dim); }
.costs__filter-date {
  font-size: .78rem; padding: 4px 8px; border-radius: 6px;
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
}
.costs__combined-summary {
  display: flex; gap: 16px; margin-bottom: 12px;
  font-size: .82rem; color: var(--text-dim);
}
.costs__usage-stat strong { color: var(--text); }

.costs__table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.costs__table th {
  text-align: left; padding: 10px 12px; font-weight: 600; color: var(--t3);
  border-bottom: 1px solid var(--border); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
}
.costs__th--sortable { cursor: pointer; user-select: none; }
.costs__th--sortable:hover { color: var(--accent); }
.costs__table td { padding: 10px 12px; color: var(--t1); border-bottom: 1px solid rgba(255,255,255,0.03); }
.costs__td-model { font-weight: 600; color: var(--accent); }
.costs__td-date { color: var(--t3); font-family: var(--mono); font-size: .65rem; }
.costs__table-empty { text-align: center; padding: 30px; color: var(--t3); font-size: .8rem; }

/* ── Settings ─────────────────────────────────────────── */
.settings {
  display: flex; flex-direction: column; gap: 24px;
  overflow-y: auto; padding: 20px 24px; height: 100%; max-width: 700px; margin: 0 auto;
}
.settings::-webkit-scrollbar { width: 6px; }
.settings::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
.settings__section { margin: 0; }
.settings__title {
  font-size: .78rem; color: var(--t2); font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .03em;
}
.settings__card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 4px 0; overflow: hidden;
}

/* Key rows */
.settings__key-row {
  padding: 12px 16px; display: flex; flex-direction: column; gap: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.settings__key-row:last-child { border-bottom: none; }
.settings__key-row--disabled { opacity: 0.5; }
.settings__key-info { display: flex; align-items: center; gap: 8px; }
.settings__key-name { font-size: .78rem; font-weight: 600; color: var(--t1); }
.settings__key-badge {
  font-size: .6rem; padding: 2px 6px; border-radius: 4px;
  background: rgba(255,255,255,0.06); color: var(--t3);
}
.settings__key-field { display: flex; gap: 6px; }
.settings__key-input { flex: 1; font-family: var(--mono); font-size: .72rem; }
.settings__key-status { font-size: .72rem; }
.settings__status--ok { color: var(--ok); }
.settings__status--err { color: var(--err); }

/* Preference rows */
.settings__pref-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.settings__pref-row:last-child { border-bottom: none; }
.settings__pref-label { font-size: .78rem; color: var(--t1); }
.settings__pref-select { max-width: 200px; }
.settings__pref-input { max-width: 160px; font-family: var(--mono); font-size: .75rem; }

/* Toggle switch */
.settings__toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.settings__toggle input { opacity: 0; width: 0; height: 0; }
.settings__toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 22px; transition: all .3s ease;
}
.settings__toggle-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--t3); transition: all .3s ease;
}
.settings__toggle input:checked + .settings__toggle-slider {
  background: var(--accent); border-color: var(--accent);
}
.settings__toggle input:checked + .settings__toggle-slider::before {
  transform: translateX(18px); background: #fff;
}

/* Data management */
.settings__data-card { padding: 4px 0; }
.settings__data-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.settings__data-row:last-child { border-bottom: none; }
.settings__data-info { display: flex; flex-direction: column; gap: 1px; }
.settings__data-name { font-size: .78rem; color: var(--t1); font-weight: 500; }
.settings__data-desc { font-size: .65rem; color: var(--t3); }
.settings__divider { border: none; border-top: 1px solid var(--border); margin: 0; }
.settings__btn--warn { color: var(--warn) !important; }
.settings__btn--danger { color: var(--err) !important; }

/* Shortcuts table */
.settings__shortcuts-table { width: 100%; font-size: .78rem; }
.settings__shortcuts-table td { padding: 6px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.settings__shortcuts-table tr:last-child td { border-bottom: none; }
.settings__shortcut-key {
  font-family: var(--mono); font-weight: 600; color: var(--accent);
  min-width: 100px; font-size: .72rem;
}

/* ── Mobile Sidebar Trigger (hidden on desktop) ───────── */
.mobile-sidebar-trigger {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--accent-dim);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--accent);
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  margin-bottom: 12px;
  transition: background .15s;
}
.mobile-sidebar-trigger:hover { background: rgba(10,132,255,0.15); }

/* ── Responsive: Mobile ───────────────────────────────── */
@media (max-width: 768px) {
  /* Header compact */
  .header__hamburger { display: none !important; }
  .shortcut-hint { display: none; }
  .header { padding: 8px 12px; }
  .header__brand { font-size: .8rem; }

  /* Show sidebar trigger on mobile */
  .mobile-sidebar-trigger { display: flex; }

  /* ── Tab bar: fixed at bottom ── */
  .tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding: 4px 0 env(safe-area-inset-bottom, 4px);
    gap: 0;
    justify-content: space-around;
    align-items: stretch;
  }

  /* Tab buttons: vertical icon + label */
  .tab-bar .tab {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px 4px;
    border-radius: 0 !important;
    font-size: .58rem;
    min-width: 0;
  }
  .tab-bar .tab span { display: block !important; }
  .tab-bar .tab .icon-xs { width: 18px; height: 18px; }

  .tab-bar .tab--active {
    background: transparent !important;
    color: var(--accent);
  }
  .tab-bar .tab--active::after { display: none; }

  /* Main content area: leave room for bottom bar */
  .layout { grid-template-columns: 1fr; padding-bottom: 60px; }
  .output { padding: 12px; padding-bottom: 72px; }
  .tab-content { padding-bottom: 60px; }

  /* ── Sidebar: slide overlay (opened by hamburger JS or swipe) ── */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 60px; width: 320px; max-width: 85vw;
    z-index: 150; transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    border-right: 1px solid var(--border);
    padding-top: 50px;
  }
  .sidebar--open { transform: translateX(0); }
  .sidebar__backdrop { display: block; }
  .sidebar__backdrop--visible { opacity: 1; pointer-events: auto; }

  /* History */
  .history-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

  /* Player */
  .player-bar { flex-direction: column; gap: 8px; }

  /* Costs mobile */
  .costs { padding: 12px; }
  .costs__kpi-row { grid-template-columns: 1fr 1fr; }
  .costs__chart-row { grid-template-columns: 1fr; }
  .costs__kpi-value { font-size: 1rem; }

  /* Settings mobile */
  .settings { padding: 12px; }
  .player-bar__actions { flex-wrap: wrap; gap: 4px; }

  /* Fullscreen */
  .fullscreen-actions { flex-direction: column; gap: 8px; padding: 16px; }

  /* Compare */
  .compare-grid { grid-template-columns: 1fr; }

  /* Buttons */
  .action-group .btn { font-size: .85rem; }

  /* Cost chip compact */
  .cost-chip span, .balance-chip span { font-size: .72rem; }

  /* Gallery mobile */
  .gallery { padding: 12px; }
  .gallery__toolbar { flex-direction: column; }
  .gallery__toolbar-left, .gallery__toolbar-right { width: 100%; }
  .gallery__search-wrap { max-width: 100%; }
  .gallery__grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .gallery__lightbox-content { max-width: 95vw; }
  .gallery__lightbox-meta { max-width: 95vw; }

  /* Profile */
  .profile { padding: 12px; }
}

@media (max-width: 400px) {
  .header { padding: 10px 12px; }
  .header__brand { font-size: .8rem; }
  .history-grid { grid-template-columns: 1fr; }
  .sidebar { width: 100%; max-width: 100vw; }
}

/* ── EXIF Camouflage Settings ─────────────────────────────── */
.settings__exif-config { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.settings__pref-row--top { align-items: flex-start; }
.settings__pref-hint { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.settings__checkbox-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.settings__chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  cursor: pointer; font-size: .78rem; color: var(--text-dim);
  transition: all .15s;
}
.settings__chip:hover { background: rgba(255,255,255,0.08); }
.settings__chip:has(input:checked) { background: rgba(255,255,255,0.12); border-color: var(--accent); color: var(--text); }
.settings__chip input { display: none; }
.settings__range-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.settings__range { flex: 1; accent-color: var(--accent); }
.settings__range-value { font-size: .78rem; color: var(--text-dim); white-space: nowrap; min-width: 100px; }
.settings__exif-preview {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
}
.settings__exif-preview-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px;
}
.settings__exif-preview-body { display: flex; flex-direction: column; gap: 4px; }
.settings__exif-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; padding: 3px 0;
}
.settings__exif-row span:first-child { color: var(--text-dim); }
.settings__exif-row span:last-child { color: var(--text); font-family: 'SF Mono', monospace; }

/* ── Costs Usage / Daily Summary ───────────────────────────── */
.costs__usage-section { margin-top: 20px; }
.costs__usage-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.costs__usage-filter { display: flex; align-items: center; gap: 8px; }
.costs__filter-label { font-size: .78rem; color: var(--text-dim); }
.costs__filter-date {
  font-size: .78rem; padding: 4px 8px; border-radius: 6px;
  background: var(--bg-1); border: 1px solid var(--border); color: var(--text);
}
.costs__usage-summary {
  display: flex; gap: 16px; margin-bottom: 12px;
  font-size: .82rem; color: var(--text-dim);
}
.costs__usage-stat strong { color: var(--text); }
.costs__day-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  transition: background .15s;
}
.costs__day-card:hover { background: rgba(255,255,255,0.04); }
.costs__day-header {
  font-size: .78rem; font-weight: 600; color: var(--text);
  min-width: 90px;
}
.costs__day-bar {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.5), rgba(255,255,255,0.15));
  min-width: 5%;
}
.costs__day-stats {
  display: flex; gap: 16px; font-size: .75rem; color: var(--text-dim);
  margin-left: auto; white-space: nowrap;
}
.costs__day-stats span:last-child {
  font-family: 'SF Mono', monospace; color: var(--accent);
}
/* Spin animation for loader icon */
.spin { animation: spinAnim 1s linear infinite; }
@keyframes spinAnim { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* ── Toast Notifications ───────────────────────────────── */
.toast-container {
  position: fixed; top: 68px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 420px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r);
  background: rgba(28,28,30,0.95); border: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  color: var(--t1); font-size: .82rem; pointer-events: all;
  transform: translateX(120%); transition: transform .3s ease, opacity .3s ease;
  opacity: 0; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast--visible { transform: translateX(0); opacity: 1; }
.toast--error { border-color: rgba(255,69,58,0.4); }
.toast--error svg { color: var(--err); }
.toast--warning { border-color: rgba(255,159,10,0.4); }
.toast--warning svg { color: #ff9f0a; }
.toast--success { border-color: rgba(48,209,88,0.4); }
.toast--success svg { color: var(--ok); }
.toast--info { border-color: rgba(255,255,255,0.25); }
.toast--info svg { color: var(--accent); }
.toast__message { flex: 1; line-height: 1.4; }
.toast__close {
  background: none; border: none; color: var(--t2); cursor: pointer;
  padding: 2px; border-radius: 4px;
}
.toast__close:hover { color: var(--t1); background: var(--bg-hover); }

/* ── Error History Cards ───────────────────────────────── */
.history-item--error {
  border: 1px solid rgba(255,69,58,0.3) !important;
  background: rgba(255,69,58,0.05);
}
.history-item__error-icon {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; min-height: 80px;
  color: var(--err); opacity: 0.6;
}
.history-item__error-msg {
  font-size: .7rem; color: var(--err); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  margin-top: 2px;
}

/* ── Delete Button Danger Hover ────────────────────────── */
.h-delete:hover, .h-delete-card:hover {
  color: var(--err) !important;
  background: var(--err-dim) !important;
}

/* ── Model Info Feature Tags ───────────────────────────── */
.model-info__features {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 0 4px;
}
.model-info__tag {
  display: inline-block; font-size: .65rem;
  padding: 2px 8px; border-radius: 100px;
  background: var(--accent-dim); color: var(--accent);
  white-space: nowrap;
}
.model-info__link {
  color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem;
}
.model-info__link:hover { text-decoration: underline; }

/* ── User Badge ────────────────────────────────────────────── */
.user-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  font-size: .75rem;
}
.user-badge__name {
  color: var(--t2);
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#logout-btn:hover { color: var(--err) !important; }

/* ── Profile Page ──────────────────────────────────────────── */
.profile {
  max-width: 600px; margin: 0 auto;
  padding: 32px 20px; display: flex; flex-direction: column; gap: 24px;
}
.profile__header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
}
.profile__avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #444444, #222222);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile__avatar-text {
  font-size: 1.4rem; font-weight: 700; color: #fff;
}
.profile__header-info { flex: 1; min-width: 0; }
.profile__name { font-size: 1.1rem; font-weight: 600; color: var(--t1); margin: 0; }
.profile__email { font-size: .8rem; color: var(--t3); margin: 4px 0 6px; }
.profile__role-badge {
  display: inline-block; font-size: .65rem;
  padding: 2px 10px; border-radius: 100px;
  background: var(--accent-dim); color: var(--accent);
  text-transform: uppercase; font-weight: 600;
}

.profile__section {
  padding: 20px; border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
}
.profile__section--danger { border-color: rgba(239,68,68,.2); }
.profile__section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; font-weight: 600; color: var(--t1);
  margin: 0 0 16px;
}
.profile__form { display: flex; flex-direction: column; gap: 10px; }
.profile__label { font-size: .7rem; color: var(--t3); text-transform: uppercase; letter-spacing: 0.5px; }
.profile__input { max-width: 100%; }
.profile__input--disabled { opacity: 0.5; cursor: not-allowed; }
.profile__input-row { display: flex; gap: 8px; align-items: center; }
.profile__input-row .profile__input { flex: 1; }
.profile__hint { font-size: .7rem; color: var(--t4); margin: 4px 0 0; }
.profile__pw-btn { align-self: flex-start; margin-top: 4px; }

.profile__stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.profile__stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 8px; border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
.profile__stat-value { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.profile__stat-label { font-size: .65rem; color: var(--t3); margin-top: 4px; text-transform: uppercase; }

.btn--danger {
  background: rgba(239,68,68,.15); color: #ef4444;
  border: 1px solid rgba(239,68,68,.3);
}
.btn--danger:hover { background: rgba(239,68,68,.25); }

/* ══════════════════════════════════════════════════════════════
   SUBMISSIONS TAB
   ══════════════════════════════════════════════════════════════ */
.submissions-page, .approval-page, .admin-page {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}
.submissions-page__toolbar, .approval-page__toolbar, .admin-page__toolbar {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1rem;
}
.submissions-page__title, .approval-page__title, .admin-page__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.submissions-page__filters, .approval-page__filters, .admin-page__filters {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.submissions-page__filters .input,
.approval-page__filters .input {
  min-width: 0;
  flex: 1 1 120px;
  max-width: 200px;
  font-size: .75rem;
  padding: .4rem .5rem;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--t2);
  cursor: pointer;
  white-space: nowrap;
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Submissions / Approval Grid */
.submissions-grid, .approval-grid {
  --sub-col-width: 200px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--sub-col-width), 1fr));
  gap: 1rem;
}
.sub-card, .approval-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .2s, transform .15s;
}
.sub-card:hover, .approval-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}
.sub-card__media, .approval-card__media {
  position: relative;
  aspect-ratio: 9/16;
  overflow: hidden;
  background: var(--bg-2);
}
.sub-card__img, .sub-card__video, .approval-card__img, .approval-card__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sub-card__badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
  padding: .2rem .5rem;
  border-radius: 6px;
  font-size: .65rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sub-card__video-icon {
  position: absolute;
  bottom: .5rem;
  right: .5rem;
  color: #fff;
  opacity: .8;
}
.sub-card__info, .approval-card__info {
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.sub-card__model, .approval-card__model {
  font-size: .75rem;
  font-weight: 600;
  color: var(--t1);
}
.sub-card__creator, .approval-card__creator, .approval-card__dev {
  font-size: .7rem;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: .25rem;
}
.sub-card__date, .approval-card__date {
  font-size: .65rem;
  color: var(--t3);
}
.approval-card__reviewer {
  font-size: .65rem;
  color: var(--accent);
}
.sub-card__actions, .approval-card__actions {
  padding: .5rem .75rem .75rem;
  display: flex;
  gap: .4rem;
}
.sub-card--downloaded {
  opacity: 0.55;
  position: relative;
}
.sub-card--downloaded:hover { opacity: 0.8; }
.sub-card__check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #22c55e;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sub-card__check .icon-xs { width: 1.5rem; height: 1.5rem; }

/* ══════════════════════════════════════════════════════════════
   APPROVAL STATS BAR
   ══════════════════════════════════════════════════════════════ */
.approval-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.approval-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}
.approval-stat-card__value {
  font-size: 1.5rem;
  font-weight: 800;
}
.approval-stat-card__label {
  font-size: .7rem;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ══════════════════════════════════════════════════════════════
   ADMIN DASHBOARD
   ══════════════════════════════════════════════════════════════ */
.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 2rem;
}
.admin-kpi {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.admin-kpi__value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--t1);
}
.admin-kpi__label {
  font-size: .7rem;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: .25rem;
}
.admin-section {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-section__title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  padding: .6rem .75rem;
  cursor: pointer;
  user-select: none;
  background: var(--bg2);
  transition: background .15s;
}
.admin-section__title:hover { background: var(--bg3); }
.admin-section__title .toggle-chevron {
  margin-left: auto;
  transition: transform .2s;
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.admin-section.collapsed .toggle-chevron { transform: rotate(-90deg); }
.admin-section__body {
  padding: .75rem;
  transition: max-height .25s ease, opacity .2s ease;
  overflow: hidden;
}
.admin-section.collapsed .admin-section__body {
  max-height: 0 !important;
  padding: 0 .75rem;
  opacity: 0;
  pointer-events: none;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}
.data-table th {
  text-align: left;
  padding: .6rem .75rem;
  background: var(--bg-2);
  color: var(--t2);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .65rem;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--t1);
}
.data-table tbody tr:hover {
  background: var(--bg-hover);
}
.data-table .input--sm {
  padding: .25rem .4rem;
  font-size: .75rem;
  min-width: 100px;
}
.data-table--compact th, .data-table--compact td { padding: .4rem .5rem; text-align: center; }
.data-table--compact td:first-child, .data-table--compact th:first-child { text-align: left; }
.th-group { text-align: center !important; font-size: .7rem; border-bottom: 1px solid var(--border); }
.th-group--image { background: rgba(59,130,246,.08); }
.th-group--video { background: rgba(168,85,247,.08); }
.th-sub { font-size: .6rem; text-align: center !important; }

/* Badges */
.badge { padding: .15rem .5rem; border-radius: 4px; font-size: .65rem; font-weight: 600; }
.badge--image { background: rgba(255,255,255,.08); color: #d4d4d4; }
.badge--video { background: rgba(255,255,255,.08); color: #a0a0a0; }

/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 420px;
  max-width: 90vw;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal__header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--t1);
}
.modal__body {
  padding: 1.25rem;
}
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: .3rem;
}

/* Responsive */
@media (max-width: 640px) {
  .submissions-grid, .approval-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-kpis { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .approval-stats { flex-wrap: wrap; }
  .data-table { font-size: .7rem; }
  .data-table th, .data-table td { padding: .4rem .5rem; }

  /* Admin page mobile */
  .admin-page { padding: .75rem; }
  .admin-page__toolbar { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .admin-page__filters { width: 100%; flex-wrap: wrap; gap: .35rem; }
  .admin-page__filters .input { flex: 1; min-width: 100px; font-size: .78rem; }
  .admin-page__title { font-size: .9rem; }

  /* Admin sections compact */
  .admin-section__title { font-size: .8rem; padding: .5rem .6rem; }
  .admin-section__body { padding: .5rem; }

  /* KPI cards compact */
  .kpi { padding: .5rem .6rem; }
  .kpi__value { font-size: 1rem; }
  .kpi__label { font-size: .55rem; }

  /* Tables in admin: horizontal scroll */
  .admin-section__body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-section__body .data-table { min-width: 500px; }
  .data-table--compact th, .data-table--compact td { padding: .3rem .35rem; font-size: .65rem; white-space: nowrap; }

  /* Creator chips smaller */
  .creator-chip { font-size: .72rem !important; padding: .2rem .4rem !important; }

  /* Costs per developer & model table: horizontal scroll */
  .costs__combined-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .costs__combined-section .data-table,
  .costs__combined-section .costs__table { min-width: 600px; }
  .costs__table th, .costs__table td { white-space: nowrap; }
  .costs__combined-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .costs__combined-filter { width: 100%; flex-wrap: wrap; gap: .35rem; }
}

/* ══════════════════════════════════════════════════════════════
   PROMPTS TAB
   ══════════════════════════════════════════════════════════════ */
.prompts-page {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}
.prompts-page__toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.prompts-page__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.prompts-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  min-height: 400px;
}
.prompts-creator-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.prompts-creator-list__header {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.prompts-creator-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .15s;
}
.prompts-creator-card:hover {
  border-color: var(--border-active);
  background: rgba(255,255,255,.05);
}
.prompts-creator-card--active {
  border-color: var(--accent);
  background: rgba(255,255,255,.06);
}
.prompts-creator-card__name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--t1);
}
.prompts-creator-card__badge {
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 100px;
  background: var(--accent-dim);
  color: var(--accent);
}
.prompts-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.prompts-content__header {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.prompts-content__header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
}
.prompts-cards {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.prompts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem;
  color: var(--t3);
  font-size: .85rem;
}
.prompt-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  backdrop-filter: blur(16px);
  transition: border-color .15s;
}
.prompt-card:hover {
  border-color: var(--border-active);
}
.prompt-card__header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.prompt-card__title {
  flex: 1;
  font-size: .82rem;
  font-weight: 600;
}
.prompt-card__actions {
  display: flex;
  gap: .25rem;
}
.prompt-card__text {
  font-size: .8rem;
  resize: vertical;
  min-height: 60px;
}
.prompts-add-btn {
  align-self: flex-start;
}

/* ── Prompt Template Button (Studio Sidebar) ──────────────── */
.prompt-template-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--t2);
  cursor: pointer;
  padding: 2px 5px;
  margin-left: 6px;
  vertical-align: middle;
  transition: all .15s;
}
.prompt-template-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255,255,255,.06);
}
.prompt-template-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(28,28,30,0.98);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}
.prompt-template-dropdown__item {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .78rem;
  color: var(--t1);
  cursor: pointer;
  transition: background .1s;
}
.prompt-template-dropdown__item:hover {
  background: rgba(255,255,255,.10);
  color: var(--accent);
}

/* Responsive: Prompts */
@media (max-width: 768px) {
  .prompts-layout {
    grid-template-columns: 1fr;
  }
}

