/* ── LTX-Gen — Dark Industrial Theme ─────────────────────────── */

:root {
  --bg-base: #0e0f11;
  --bg-panel: #16181c;
  --bg-input: #1c1f25;
  --bg-hover: #22262e;
  --border: #2a2e38;
  --border-focus: #4a9eff;
  --text-primary: #e2e4e8;
  --text-secondary: #8b8f99;
  --text-muted: #5c6070;
  --accent: #4a9eff;
  --accent-dim: #2d5f99;
  --success: #3dd68c;
  --warn: #f0a030;
  --error: #ef4444;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Navigation ──────────────────────────────────────────────── */

.topnav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 2rem;
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  color: var(--accent);
  font-size: 0.9rem;
}

.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-links a:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-links a.active { color: var(--accent); background: rgba(74, 158, 255, 0.1); }

.nav-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--error); }
.status-dot.checking { background: var(--warn); animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: 0.4; } }

/* ── Container & Grid ────────────────────────────────────────── */

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .grid-2col { grid-template-columns: 1fr; }
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ── Panels ──────────────────────────────────────────────────── */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Form Fields ─────────────────────────────────────────────── */

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.field-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.field-row .field { flex: 1; margin-bottom: 0; }

input[type="text"], input[type="url"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

textarea { resize: vertical; font-size: 0.85rem; }

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.hint code {
  font-family: var(--font-mono);
  background: var(--bg-hover);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.7rem;
}

/* ── Upload Zones ────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover { border-color: var(--accent-dim); background: rgba(74, 158, 255, 0.03); }
.upload-zone.dragover { border-color: var(--accent); background: rgba(74, 158, 255, 0.08); }
.upload-zone.has-file { border-style: solid; border-color: var(--border); }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.upload-icon { font-size: 2rem; }

.upload-preview { max-width: 100%; max-height: 200px; border-radius: var(--radius-sm); }
.upload-info { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; flex: 1; }
.upload-info.success { color: var(--success); }

.upload-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.btn-browse {
  padding: 0.25rem 0.65rem;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-browse:hover { background: var(--border); color: var(--text-primary); border-color: var(--accent-dim); }

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.field-label-row label { margin-bottom: 0; }

/* ── Prompt History Dropdown ─────────────────────────────────── */

.prompt-history-dropdown {
  position: relative;
  margin-top: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
}

.prompt-history-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.prompt-history-item:last-child { border-bottom: none; }
.prompt-history-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.prompt-history-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-history-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.1s;
}
.prompt-history-delete:hover { color: var(--error); }

.prompt-history-empty {
  padding: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

audio { width: 100%; margin-top: 0.5rem; }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn-generate {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}
.btn-generate:hover:not(:disabled) { background: #3a8aee; transform: translateY(-1px); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-generate:active { transform: translateY(0); }

.btn-primary {
  padding: 0.55rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #3a8aee; }

.btn-secondary {
  padding: 0.55rem 1.2rem;
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-download {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  background: var(--success);
  color: #0e0f11;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: opacity 0.15s;
}
.btn-download:hover { opacity: 0.85; }

.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cost Box ────────────────────────────────────────────────── */

.cost-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.15rem 0;
}
.cost-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}

/* ── Progress ────────────────────────────────────────────────── */

.progress-section { margin-top: 1.5rem; }

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.progress-stage { color: var(--text-primary); font-weight: 500; }
.progress-pct { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-timer {
  text-align: right;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Log Panel ───────────────────────────────────────────────── */

.log-toggle { margin-top: 0.75rem; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-label input { accent-color: var(--accent); }

.log-panel {
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  background: #0a0b0d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.log-panel pre {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Result ──────────────────────────────────────────────────── */

.result-section { margin-top: 1.5rem; }
.result-section h3 {
  font-size: 0.9rem;
  color: var(--success);
  margin-bottom: 0.75rem;
}

.result-section video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* ── Alerts ──────────────────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.alert-warn {
  background: rgba(240, 160, 48, 0.1);
  border: 1px solid rgba(240, 160, 48, 0.3);
  color: var(--warn);
}
.alert-warn a { color: var(--accent); }

/* ── Git / Settings ──────────────────────────────────────────── */

.git-status { font-size: 0.9rem; }
.git-branch { display: flex; align-items: center; gap: 0.75rem; }
.git-branch .label { color: var(--text-muted); font-size: 0.8rem; }
.git-branch .value { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }

.badge-warn {
  font-size: 0.7rem;
  background: rgba(240, 160, 48, 0.15);
  color: var(--warn);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-weight: 600;
}

.test-result { font-size: 0.85rem; margin-left: 0.5rem; }
.test-result.success { color: var(--success); }
.test-result.error { color: var(--error); }

/* ── Git Operation Status ────────────────────────────────────── */

.op-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  animation: fadeIn 0.2s;
}

.op-status-icon {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.op-working {
  background: rgba(74, 158, 255, 0.08);
  border: 1px solid rgba(74, 158, 255, 0.2);
  color: var(--accent);
}

.op-success {
  background: rgba(61, 214, 140, 0.08);
  border: 1px solid rgba(61, 214, 140, 0.2);
  color: var(--success);
}

.op-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
}

/* ── Deploy Console ──────────────────────────────────────────── */

.deploy-console {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.deploy-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.deploy-console-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.deploy-console-clear:hover { color: var(--text-primary); border-color: var(--text-muted); }

.deploy-console-output {
  background: #0a0b0d;
  padding: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.deploy-line { display: block; }
.deploy-stdout { color: var(--text-primary); }
.deploy-stderr { color: var(--text-secondary); }
.deploy-info { color: var(--accent); }
.deploy-success { color: var(--success); font-weight: 600; }
.deploy-error { color: var(--error); font-weight: 600; }

.commit-log {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.commit-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.commit-row:last-child { border-bottom: none; }
.commit-hash {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
}
.commit-msg { flex: 1; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit-date { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }

/* ── Audio Region Selector ────────────────────────────────────── */

.audio-region {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  padding-top: 0.5rem;
}

.audio-region-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.audio-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.audio-play-btn:hover { background: #3a8aee; transform: scale(1.08); }
.audio-play-btn.playing { background: var(--warn); }

.audio-region-times {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.78rem;
  flex: 1;
  justify-content: flex-end;
}
.time-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-secondary);
}
.time-field span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.time-input {
  width: 58px;
  padding: 0.25rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: center;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-primary);
}
.time-input:focus { border-color: var(--accent); }
.time-sep { color: var(--text-muted); font-size: 0.7rem; }

.audio-waveform-wrap {
  position: relative;
  height: 52px;
  cursor: crosshair;
  user-select: none;
  margin-bottom: 0.25rem;
}

.audio-waveform {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 3px;
  gap: 1px;
}
.audio-waveform span {
  flex: 1;
  background: var(--text-muted);
  border-radius: 1px;
  min-width: 1.5px;
  opacity: 0.2;
  transition: opacity 0.08s, background 0.08s;
}
.audio-waveform span.active {
  opacity: 0.8;
  background: var(--accent);
}

.audio-selection {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(74, 158, 255, 0.1);
  pointer-events: none;
  border-radius: 2px;
}

.audio-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.audio-handle::after {
  content: '';
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.15s, background 0.15s;
  box-shadow: 0 0 4px rgba(74, 158, 255, 0.4);
}
.audio-handle:hover::after, .audio-handle.dragging::after {
  height: 28px;
  background: #6db5ff;
  box-shadow: 0 0 8px rgba(74, 158, 255, 0.6);
}
.audio-handle-left { transform: translateX(-4px); }
.audio-handle-right { transform: translateX(4px); }

.audio-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--warn);
  pointer-events: none;
  display: none;
  z-index: 6;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(240, 160, 48, 0.5);
}

.audio-time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  opacity: 0.6;
  padding: 0 2px;
}

/* ── Batch Selector ──────────────────────────────────────────── */

.batch-selector {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.batch-btn {
  width: 44px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.batch-btn:hover { border-color: var(--accent-dim); color: var(--text-primary); }
.batch-btn.active {
  background: rgba(74, 158, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Job Cards ───────────────────────────────────────────────── */

.jobs-container {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.job-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.job-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.seed-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}
.job-card-timer {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.job-card-stage {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.job-card-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.job-card-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.job-card-fill.running {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent), var(--accent-dim));
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.job-card-fill.complete { background: var(--success); }
.job-card-fill.error { background: var(--error); }

.job-card-result { margin-top: 0.6rem; }
.job-card-result video {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
}
.job-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

/* ── Gallery ──────────────────────────────────────────────────── */

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.gallery-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.gallery-tab {
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.gallery-tab:hover { color: var(--text-primary); }
.gallery-tab.active {
  background: rgba(74, 158, 255, 0.12);
  color: var(--accent);
}

.gallery-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gallery-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.gallery-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.gallery-empty-text { font-size: 1.1rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.3rem; }
.gallery-empty-hint { font-size: 0.85rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.gallery-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}
.gallery-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.gallery-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.gallery-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}
.gallery-card:hover .gallery-thumb-overlay { opacity: 1; }
.gallery-play-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 158, 255, 0.9);
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  padding-left: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.gallery-card-info {
  padding: 0.6rem 0.75rem;
}
.gallery-card-date {
  font-size: 0.78rem;
  color: var(--text-primary);
  font-weight: 500;
}
.gallery-card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.gallery-seed {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 0.05em 0.35em;
  border-radius: 3px;
}

/* ── Lightbox ────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.2s;
}

.lightbox-content {
  max-width: 960px;
  width: 100%;
  position: relative;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}
.lightbox-close:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.1); }

.lightbox-content video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
}

.lightbox-info {
  margin-top: 0.75rem;
}
.lightbox-filename {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  word-break: break-all;
}
.lightbox-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.lightbox-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ── Utilities ───────────────────────────────────────────────── */

/* ── Media Selection Modal ───────────────────────────────────── */

.media-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.2s;
}

.media-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.media-modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.media-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}
.media-modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.media-modal-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1.25rem 0;
}

.media-tab {
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.media-tab:hover { color: var(--text-primary); }
.media-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.media-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
}

.media-modal-loading,
.media-modal-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.media-modal-error {
  padding: 1rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.85rem;
  line-height: 1.5;
}

.media-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.media-item {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}
.media-item:hover {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.media-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

.media-item-thumb {
  aspect-ratio: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.media-item-thumb img,
.media-item-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-item-thumb .media-icon {
  font-size: 2rem;
  opacity: 0.5;
}

.media-item-info {
  padding: 0.4rem 0.5rem;
}
.media-item-name {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-item-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.media-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
