:root {
  color-scheme: dark;
  --bg: #10130f;
  --surface: #171d17;
  --surface-2: #20291f;
  --line: #314031;
  --text: #edf4ea;
  --muted: #9aa796;
  --soft: #cbd7c7;
  --accent: #8fcf78;
  --accent-2: #c6e46f;
  --soil: #b48a5a;
  --danger: #e16f65;
  --warning: #d6ae55;
  --info: #6fa8dc;
  --shadow: 0 22px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sidebar {
  min-height: 100vh;
  padding: 22px 18px;
  background: #0c100e;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
}

.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #0c100e;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 0;
  font-size: 13px;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .08em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.nav { display: grid; gap: 6px; }
.nav-btn {
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  display: flex;
  justify-content: space-between;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-btn:hover { background: #151a17; color: var(--soft); transform: translateX(2px); }
.nav-btn.active { background: var(--surface-2); color: var(--text); }
.nav-btn span {
  min-width: 24px;
  text-align: center;
  border-radius: 999px;
  background: #26352d;
  color: var(--accent-2);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.tab-btn {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: rgba(117, 199, 154, .45);
}
.analytics-tab { display: none; }
.analytics-tab.active { display: block; }
.insight-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--soft);
}
.insight-list li + li { margin-top: 6px; }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 5px rgba(117, 199, 154, .12); }

.workspace { min-width: 0; padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h2 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.topbar p { margin: 5px 0 0; color: var(--muted); }

/* Cost tracker widget */
.cost-tracker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 12px;
  white-space: nowrap;
}
.cost-items { display: flex; gap: 12px; align-items: center; }
.cost-item { color: var(--muted); }
.cost-item strong { color: var(--soft); font-size: 13px; }
.cost-total { color: var(--accent); font-weight: 600; font-size: 14px; margin-left: 4px; }
.cost-total strong { color: var(--accent-2); }
.cost-reset {
  font-size: 16px !important;
  padding: 2px 6px !important;
  border-radius: 6px !important;
  min-width: auto !important;
  line-height: 1;
}

.page { display: none; animation: rise .22s ease both; }
.page.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; line-height: 1; }

.split, .moderation-layout {
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr);
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-head p { margin: 4px 0 0; }
.muted { color: var(--muted); font-size: 12px; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: #24302a;
  color: var(--soft);
  font-size: 12px;
}
.badge.ok { color: var(--accent-2); background: rgba(117, 199, 154, .14); }
.badge.warn { color: var(--warning); background: rgba(214, 174, 85, .14); }
.badge.err { color: var(--danger); background: rgba(225, 111, 101, .14); }
.badge.info { color: var(--info); background: rgba(111, 168, 220, .14); }

.kv { display: grid; grid-template-columns: minmax(140px, .4fr) 1fr; gap: 9px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.list { display: grid; gap: 10px; }
.item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121713;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.item:hover { border-color: #466553; transform: translateY(-1px); background: #151b17; }
.item.selected { border-color: var(--accent); }
.item h4 { margin: 0 0 5px; font-size: 14px; }
.item p { margin: 0; color: var(--muted); font-size: 12px; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}
.product-card h3 { margin: 0 0 8px; }
.product-card p { color: var(--muted); margin: 0 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 4px 7px; border-radius: 999px; color: var(--soft); background: #26302b; }

.reference-panel { margin-bottom: 16px; }
.reference-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(240px, .8fr) minmax(280px, 1fr);
  gap: 14px;
}
.reference-layout h4 {
  margin: 0 0 10px;
  color: var(--soft);
  font-size: 13px;
}
.reference-item .item-row { align-items: flex-start; }
.reference-paths { margin-top: 10px; }
.reference-paths .chip { overflow-wrap: anywhere; }

.form-panel { max-width: 980px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}
label { display: grid; gap: 7px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  color: var(--text);
  background: #0d120f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
}
textarea {
  resize: vertical;
  line-height: 1.45;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.angle-help {
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101511;
}
.angle-help-title {
  color: var(--soft);
  font-weight: 700;
  margin-bottom: 6px;
}
.angle-help-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}
.angle-help-meta span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #26302b;
  color: var(--accent-2);
  font-size: 11px;
}
.angle-help-tech {
  margin-top: 7px;
  color: #6f7d75;
  font-size: 11px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--soft);
}
.check input { width: 18px; min-height: 18px; accent-color: var(--accent); }

.actions, .section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.primary, .ghost, .link-btn, .danger {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 13px;
}
.primary { background: var(--accent); color: #07100b; font-weight: 700; }
.primary:hover { background: var(--accent-2); }
.ghost { background: var(--surface); border-color: var(--line); color: var(--soft); }
.link-btn { background: transparent; color: var(--accent-2); padding-inline: 0; }
.danger { background: transparent; border-color: rgba(225,111,101,.6); color: var(--danger); }
.run-state { color: var(--muted); }

.queue { align-self: start; }
.review {
  min-height: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.empty-state.small { min-height: 90px; }
.video-frame {
  background: #050705;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #000;
}
video { display: block; width: 100%; max-height: 62vh; background: #000; }
.review h3 { margin: 16px 0 6px; }
.review pre {
  margin: 14px 0 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  background: #0d120f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--soft);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  color: var(--accent-2);
  background: #0d120f;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 5px;
}
.generation-progress-panel, .batch-panel { margin-top: 16px; }
.draft-layout {
  display: grid;
  grid-template-columns: minmax(300px, .75fr) minmax(520px, 1.25fr);
  gap: 16px;
  margin-top: 16px;
}
.generation-stage {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--soft);
}
.generation-stage span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
}
.progress {
  height: 7px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d120f;
  border: 1px solid var(--line);
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.batch-meta { margin-top: 8px !important; }
.danger-text { color: var(--danger) !important; }
.ok-text { color: var(--accent-2) !important; }
.warn-text { color: var(--warning) !important; }

/* ── Competitor Scanner ───────────────────────────────────── */
.scanner-control {
  margin-bottom: 16px;
}
.scanner-form {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(220px, .7fr) minmax(120px, .25fr);
  gap: 14px;
  align-items: start;
}
.scanner-form textarea {
  min-height: 128px;
}
.scanner-actions {
  flex-wrap: wrap;
}
.scanner-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.competitor-results {
  align-items: start;
}
.source-line {
  margin-top: 6px !important;
  font-size: 11px !important;
}

/* ── Gallery Grid ──────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.gallery-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease;
}
.gallery-card:hover { border-color: #466553; transform: translateY(-2px); }
.gallery-card.badge-published { border-color: rgba(117, 199, 154, .35); }
.gallery-card.badge-rejected { border-color: rgba(225, 111, 101, .35); }
.gallery-card.badge-pending { border-color: rgba(214, 174, 85, .35); }
.gallery-card.badge-error { border-color: rgba(225, 111, 101, .5); }

.gallery-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #050705;
  display: block;
}
.gallery-thumb-placeholder {
  width: 100%;
  height: 200px;
  display: grid;
  place-items: center;
  background: #0c100e;
  font-size: 48px;
  color: var(--muted);
}

.gallery-info {
  padding: 14px;
  display: grid;
  gap: 6px;
}
.gallery-info strong { font-size: 14px; }
.gallery-angle {
  font-size: 11px;
  color: var(--accent-2);
  background: rgba(117, 199, 154, .12);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
}
.gallery-status { font-size: 12px; color: var(--muted); }
.gallery-date { font-size: 11px; color: var(--muted); }
.gallery-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.btn-small {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--accent-2);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: background .15s ease;
  cursor: pointer;
}
.btn-small:hover { background: #26352d; text-decoration: none; }

/* ── Star Rating ───────────────────────────────────── */
.star-rating { display: flex; gap: 4px; }
.star {
  font-size: 20px;
  color: #3a4a42;
  cursor: pointer;
  transition: color .15s ease, transform .12s ease;
  user-select: none;
}
.star:hover { color: #d6ae55; transform: scale(1.15); }
.star.active { color: #d6ae55; }
.modal-stars .star { font-size: 28px; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .5);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin: 0 0 20px; font-size: 18px; }
.modal label { margin-bottom: 14px; }
.modal select, .modal textarea {
  width: 100%;
  color: var(--text);
  background: #0d120f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  font: inherit;
}
.modal textarea { resize: vertical; }
.modal select:focus, .modal textarea:focus { border-color: var(--accent); }
.modal .actions { margin-top: 20px; }

/* ── Scene previews ───────────────────────────────────────── */

.scenes-panel { margin-top: 16px; }
.scenes-panel h4 { margin: 0 0 10px; font-size: 14px; color: var(--soft); }
.scenes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.scene-card {
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: border-color 0.2s;
}
.scene-card:hover { border-color: var(--accent); }
.scene-card video {
  width: 100%;
  aspect-ratio: 9/16;
  object-fit: cover;
  display: block;
  cursor: pointer;
  background: var(--bg);
}
.scene-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
}
.scene-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.scene-regen-btn,
.scene-mute-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 14px;
  border-radius: 6px;
  width: 30px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-left: 4px;
}
.scene-regen-btn:hover,
.scene-mute-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.scene-regen-btn:disabled,
.scene-mute-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.scene-mute-btn {
  /* Different colour so the two scene-actions don't blur together. */
  color: #c0392b;
}
.scene-mute-btn:hover {
  background: #c0392b;
  color: var(--bg);
  border-color: #c0392b;
}

/* ── Scene regeneration status ────────────────────────────── */
.scene-regen-status {
  display: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  transition: all 0.3s;
}
.scene-regen-status.active {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  animation: pulse-border 2s infinite;
}
.scene-regen-status.active.success {
  border-color: var(--accent);
  background: rgba(117, 199, 154, 0.1);
  animation: none;
}
.scene-regen-status.active.error {
  border-color: var(--danger);
  background: rgba(225, 111, 101, 0.1);
  animation: none;
}
@keyframes pulse-border {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: var(--line); }
}

/* ── Schedule ──────────────────────────────────────────────── */

.schedule-status-bar { margin-bottom: 12px; }
.schedule-banner {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.schedule-banner.active {
  background: rgba(117, 199, 154, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent-2);
}
.schedule-banner.paused {
  background: rgba(214, 174, 85, 0.1);
  border: 1px solid var(--warning);
  color: var(--warning);
}

button.accent-2 {
  background: var(--info);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  transition: background .15s;
}
button.accent-2:hover { background: #5b94c7; }

.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge-pending { background: rgba(214, 174, 85, 0.15); color: var(--warning); }
.badge-generating { background: rgba(111, 168, 220, 0.15); color: var(--info); }
.badge-published { background: rgba(117, 199, 154, 0.15); color: var(--accent); }
.badge-rejected { background: rgba(225, 111, 101, 0.15); color: var(--danger); }

.btn-small.danger {
  background: rgba(225, 111, 101, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.btn-small.danger:hover { background: rgba(225, 111, 101, 0.3); }

#nav-scheduled {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  background: var(--info);
  color: #fff;
  border-radius: 8px;
  font-size: 11px;
  padding: 1px 5px;
  margin-left: 4px;
}

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; position: static; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .workspace { padding: 18px; }
  .metrics, .split, .moderation-layout, .form-grid, .draft-layout, .scanner-form, .reference-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .cost-tracker { width: 100%; justify-content: space-between; }
  .cost-items { flex-wrap: wrap; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
