:root {
  --brand-indigo: #0E0071;
  --brand-blue: #0070FC;
  --bg-page: #F2F8FF;
  --surface: #FFFFFF;
  --border-soft: #CCE3FF;
  --text: #333333;
  --text-muted: #657180;

  --pill-pending-bg: #FFF7E5;
  --pill-pending-fg: #9A6601;
  --pill-submitted-bg: #E5F1FF;
  --pill-submitted-fg: #0E0071;
  --pill-done-bg: #D0FEE5;
  --pill-done-fg: #003F1D;
  --accent-success: #00C158;
  --danger: #D9342B;

  --radius-card: 12px;
  --radius-ctrl: 8px;
  --radius-pill: 20px;
  --radius-badge: 4px;
  --shadow-card: 0 1px 3px rgba(14, 11, 26, 0.08);

  --font-body: "Noto Sans", system-ui, sans-serif;
  --font-brand: Barlow, "Playfair Display", serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 23.8px;
  color: var(--text);
  background: var(--bg-page);
}
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea { font-family: var(--font-body); }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--brand-indigo);
  color: #fff;
  padding: 20px 14px 24px;
  border-right: 0.5px solid rgba(255,255,255,0.07);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  padding: 18px 32px 0;
}
.content { padding: 24px 32px 40px; }

/* ---------- Sidebar ---------- */
.brand-block { padding: 4px 8px; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 24px; height: 18px; flex: 0 0 auto; display: block; }
.brand-mark { display: block; width: 140px; height: auto; margin-bottom: 4px; }
.brand-name {
  font-family: var(--font-brand);
  font-size: 20px; line-height: 34px; font-weight: 700;
  letter-spacing: -0.2px; color: #fff;
}
.brand-sub { font-size: 12px; color: var(--brand-blue); }

.side-group-label {
  text-transform: uppercase;
  font-size: 10px; font-weight: 500; letter-spacing: 0.8px;
  color: rgba(255,255,255,0.3);
  padding: 0 8px 6px;
}

.role-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  font-size: 13px; font-weight: 500;
  padding: 8px 28px 8px 10px;
  border-radius: 8px;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='white' stroke-opacity='0.7' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.role-select option { color: #111; }

.scope-row { display: flex; gap: 6px; align-items: center; }
.switch-btn {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.6);
  border: none;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 400;
}
.nav a:hover { background: rgba(255,255,255,0.05); }
.nav a.active { background: var(--brand-blue); }
.nav .icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
.nav .icon svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 1.5; fill: none; }

.side-stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 10px 12px;
}
.side-stat .label { font-size: 10px; letter-spacing: 0.8px; text-transform: uppercase; color: rgba(255,255,255,0.5); }
.side-stat .value { font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: #fff; margin-top: 2px; }

/* ---------- Topbar ---------- */
.topbar .username { font-size: 14px; color: var(--text); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.avatar-btn { border: none; cursor: pointer; padding: 0; }
.avatar-wrap { position: relative; display: inline-block; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 280px; background: #fff;
  border: 0.5px solid var(--border-soft); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(14, 11, 26, 0.12);
  padding: 6px; z-index: 50;
  display: none;
}
.user-menu.open { display: block; }
.user-menu-section {
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 10px 4px;
}
.user-menu-item {
  position: relative;
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; cursor: pointer;
  padding: 8px 10px; border-radius: 6px;
}
.user-menu-item:hover { background: var(--bg-page); }
.user-menu-item.current { background: var(--bg-page); }
.user-menu-item-label { font-size: 13px; font-weight: 600; color: var(--text); }
.user-menu-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.user-menu-check {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--brand-blue); font-weight: 700;
}
.dot-sep { color: var(--text-muted); }
.btn-outline-blue-sm {
  background: transparent; color: var(--brand-blue);
  border: 0.5px solid var(--brand-blue);
  padding: 5px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500;
}

/* ---------- Page Headers ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 18px;
}
h1.page-title {
  font-size: 24px; line-height: 40.8px; font-weight: 700;
  letter-spacing: -0.48px; color: var(--text);
  margin: 0;
}
.page-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Cards ---------- */
.sp-card {
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
}
.card-stack > * + * { margin-top: 14px; }
.section-label {
  font-size: 13px; font-weight: 600; letter-spacing: 0.78px;
  text-transform: uppercase; color: #444;
  margin-bottom: 10px;
}
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; color: var(--text); }
.card-sub { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer;
  font-size: 14px; font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
}
/* Primary CTA — the canonical "do this thing" button (downloads, saves, creates).
   Previously only set bg/color, so browsers fell back to default <button> chrome
   (sharp corners, 2px outset border, cramped padding). Now fully owns its styling
   so every .btn-primary in the app reads as a confident solid CTA. */
.btn-primary {
  background: var(--brand-blue); color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1.3;
  transition: filter 120ms, transform 80ms, box-shadow 120ms;
}
.btn-primary:hover:not([disabled]) { filter: brightness(0.95); box-shadow: 0 2px 6px rgba(0,112,252,0.25); }
.btn-primary:active:not([disabled]) { transform: translateY(1px); }
.btn-primary-sm { background: var(--brand-blue); color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; border: none; cursor: pointer;}
/* Outline — paired with btn-primary in CTA rows. Bumped to match btn-primary's height
   (28→32px-ish) so the two read as a clean pair instead of size-mismatched. */
.btn-outline {
  background: transparent; color: var(--brand-blue);
  border: 1px solid var(--brand-blue);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  line-height: 1.3;
  transition: background 120ms, color 120ms;
}
.btn-outline:hover:not([disabled]) { background: rgba(0,112,252,0.06); }
.btn-outline-xs { background: transparent; color: var(--brand-blue); border: 0.5px solid var(--brand-blue); padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 500; cursor: pointer;}
.btn-success { background: #1FB161; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; border: none; cursor: pointer;}
.btn-danger-outline { background: transparent; color: var(--danger); border: 0.5px solid var(--danger); padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 500; cursor: pointer;}
.btn-ai-outline { background: transparent; color: var(--brand-blue); border: 1px dashed var(--brand-blue); padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 500; cursor: pointer;}
/* Disabled — was opacity:0.45 which made buttons nearly invisible. Bumped to a softer
   gray treatment that still clearly reads as disabled but stays legible. */
.btn[disabled], button[disabled] {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.65;
}

/* ---------- Filter tabs ---------- */
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab {
  padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: transparent; color: var(--brand-blue);
  border: 1px solid var(--border-soft); cursor: pointer;
}
.tab.active { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); font-weight: 600; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.66px; text-transform: uppercase;
}
.pill-pending { background: var(--pill-pending-bg); color: var(--pill-pending-fg); }
.pill-submitted { background: var(--pill-submitted-bg); color: var(--pill-submitted-fg); }
.pill-done { background: var(--pill-done-bg); color: var(--pill-done-fg); }
.pill-muted { background: #EEF2F6; color: #657180; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.48px;
  text-transform: uppercase; color: var(--text);
}
.field-help { font-size: 12px; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  background: #fff; border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 9px 12px;
  font-size: 14px; font-weight: 400; color: var(--text);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23657180' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.search-input {
  position: relative; display: flex; align-items: center;
}
.search-input input { padding-left: 34px; width: 100%; }
.search-input::before {
  content: ""; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23657180' stroke-width='1.5'><circle cx='7' cy='7' r='5'/><path d='m11 11 3 3'/></svg>") no-repeat center / contain;
}

/* ---------- Tables ---------- */
table.sp-table { width: 100%; border-collapse: collapse; }
.sp-table th {
  text-align: left; font-size: 12px; font-weight: 500;
  color: var(--text-muted); padding: 10px 16px;
  border-bottom: 0.5px solid var(--border-soft);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.sp-table td {
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 14px 16px; border-bottom: 1px solid #F2F8FF;
}
.sp-table tr:hover td { background: rgba(0, 112, 252, 0.03); }
.mono { font-family: var(--font-mono); }
.right { text-align: right; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: #fff; border: 0.5px solid var(--border-soft); border-radius: 12px; box-shadow: var(--shadow-card); padding: 16px 18px;}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.48px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--text); margin-top: 6px; }

/* ---------- Creative grid ---------- */
.cre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cre-grid-compact { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cre-card-compact .cre-meta { padding: 10px 12px 8px; gap: 4px; }
.cre-card-compact .cre-actions { padding: 8px 12px; }
.cre-card-compact .cre-thumb { aspect-ratio: 4 / 3; }
.cre-card { background: #fff; border: 0.5px solid var(--border-soft); border-radius: 12px; box-shadow: var(--shadow-card); overflow: hidden; display: flex; flex-direction: column;}
.cre-thumb {
  position: relative; aspect-ratio: 4/3; background: #F2F8FF;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cre-thumb .canvas { position: absolute; inset: 0; }
.cre-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.cre-title { font-size: 14px; font-weight: 600; color: var(--text); }
.cre-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.cre-tags .pill { font-size: 10px; letter-spacing: 0.5px; padding: 2px 8px; }
.cre-actions { display: flex; gap: 6px; align-items: center; padding: 10px 14px; border-top: 1px solid #F2F8FF; justify-content: space-between;}

/* ---------- Editor ---------- */
.editor-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 1000px) { .editor-wrap { grid-template-columns: 1fr; } }
.canvas-stage {
  position: relative; width: 100%;
  aspect-ratio: 4/3; background: #F2F8FF;
  border: 0.5px dashed var(--border-soft); border-radius: 8px;
  overflow: hidden;
}
.zone {
  position: absolute; border: 1.5px dashed var(--brand-blue);
  background: rgba(0,112,252,0.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-blue); font-size: 12px; font-weight: 600;
  cursor: move; user-select: none;
  border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.zone.selected { border-style: solid; box-shadow: 0 0 0 2px rgba(0,112,252,0.25); }
.zone .resize {
  position: absolute; right: -5px; bottom: -5px;
  width: 10px; height: 10px; background: var(--brand-blue); border-radius: 2px; cursor: nwse-resize;
}
.zone-rendered {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: #111;
  pointer-events: none; text-align: center; padding: 2px 4px;
}

.zone-list { display: flex; flex-direction: column; gap: 8px; }
.zone-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: 8px; background: #fff;
}
.zone-row.active { border-color: var(--brand-blue); }
.zone-row .name { font-size: 13px; font-weight: 600; }
.zone-row .meta { font-size: 11px; color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 16px; width: 480px; max-width: calc(100% - 32px);
  max-height: calc(100vh - 48px); overflow-y: auto;
  padding: 24px 28px; box-shadow: 0 10px 40px rgba(14,11,26,0.18);
}
.modal.lg { width: 640px; }
.modal.preview { width: 560px; padding: 20px 22px; }
.modal.preview .canvas-stage { max-height: 50vh; aspect-ratio: 4 / 3; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px;}
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); cursor: pointer; }
.modal-foot { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Util ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-16 { gap: 16px; }
.muted { color: var(--text-muted); }
.success-text { color: var(--accent-success); font-weight: 600; font-size: 12px; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--border-soft); margin: 12px 0; }
.kbd { font-family: var(--font-mono); font-size: 12px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: #0E0071; color: #fff; padding: 10px 14px;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.2);
  font-size: 13px;
}

/* ---------- Login page ---------- */
/* Full-viewport gate. No sidebar/topbar — the only thing the user can do is sign in. */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 112, 252, 0.10), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(14, 0, 113, 0.10), transparent 55%),
    var(--bg-page);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(14, 11, 26, 0.10);
  padding: 32px 32px 28px;
}
/* Stacked brand block — logo on top, product name below. The wordmark already carries
   the brand identity, so a vertical layout gives it room and avoids competing for the
   visual hierarchy with the "Welcome back" headline. */
.auth-brand {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 22px;
}
/* Logo asset is white wordmark + coloured dots, designed for the dark indigo sidebar.
   On the white auth-card it'd disappear entirely, so we wrap it in the same indigo
   chip the sidebar uses — the wordmark reads cleanly against the brand colour. */
.auth-brand-mark {
  display: block; width: 160px; height: auto;
  background: var(--brand-indigo);
  padding: 12px 16px;
  border-radius: 10px;
  box-sizing: content-box;
}
.auth-brand-name {
  font-family: var(--font-brand);
  font-size: 16px; font-weight: 600; color: var(--brand-indigo);
  letter-spacing: -0.2px;
}
.auth-title {
  font-size: 22px; font-weight: 700; color: var(--text);
  margin: 0 0 6px; line-height: 1.2;
}
.auth-sub {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 22px;
}
.auth-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.auth-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted);
}
.auth-input {
  width: 100%; padding: 11px 13px;
  border-radius: 8px; border: 1px solid var(--border-soft);
  font-size: 14px; background: #fff; color: var(--text);
}
.auth-input:focus {
  outline: none; border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(0, 112, 252, 0.12);
}
.auth-error {
  background: rgba(217, 52, 43, 0.08);
  color: var(--danger);
  border: 1px solid rgba(217, 52, 43, 0.30);
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.auth-submit {
  width: 100%; padding: 11px 18px;
  background: var(--brand-blue); color: #fff;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: filter 120ms;
  margin-top: 6px;
}
.auth-submit:hover  { filter: brightness(0.95); }
.auth-submit:active { filter: brightness(0.90); }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }
.auth-hint {
  margin-top: 16px;
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-page);
  border: 1px dashed var(--border-soft);
  border-radius: 8px; padding: 10px 12px;
  line-height: 1.5;
}
.auth-hint strong { color: var(--text); }
.auth-foot {
  margin-top: 18px;
  font-size: 12px; text-align: center; color: var(--text-muted);
}

/* Sign-out item in the avatar menu — same shape as switcher rows, danger-tinted. */
.user-menu-item-danger .user-menu-item-label { color: var(--danger); }
.user-menu-item-danger:hover { background: rgba(217, 52, 43, 0.06); }

/* ---------- Backgrounds Library — redesigned UX (stats, picker, library grid) ---------- */
/* Stats banner up top — instant "what's the state of the library" answer. */
.bg-stats {
  display: flex; gap: 12px; flex-wrap: wrap; margin: 0;
}
.bg-stat {
  flex: 0 0 auto; min-width: 140px;
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 14px 18px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 2px;
}
.bg-stat-num { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.1; }
.bg-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.bg-stat.good    .bg-stat-num { color: var(--accent-success); }
.bg-stat.warn    .bg-stat-num { color: var(--pill-pending-fg); }
.bg-stat.pending .bg-stat-num { color: var(--brand-blue); }

/* Upload card — collapsible by default; head + numbered steps. */
.bg-upload-head { margin-bottom: 14px; }
.bg-step-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 10px; margin-top: 4px;
}
.bg-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-blue); color: #fff;
  font-size: 12px; font-weight: 600;
}
.bg-step-locked {
  padding: 14px 16px; border-radius: 8px;
  background: var(--bg-page); color: var(--text-muted);
  font-size: 13px; margin-top: 12px;
  border: 1px dashed var(--border-soft);
}

/* Theme search + grouped picker — replaces the wall of 35 chips. */
.bg-theme-search {
  width: 100%; max-width: 480px;
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border-soft);
  font-size: 13px; margin-bottom: 14px;
  background: #fff;
}
.bg-theme-search:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0,112,252,0.10); }
.bg-theme-groups { display: flex; flex-direction: column; gap: 12px; }
.bg-theme-group {
  display: flex; flex-direction: column; gap: 6px;
}
.bg-theme-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted);
}
.bg-theme-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.bg-theme-chip-custom { border-style: dashed !important; }

/* Save bar at the bottom of the upload card. */
.bg-save-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.bg-save-status { font-size: 13px; color: var(--text-muted); }
.bg-save-status.warn { color: var(--pill-pending-fg); font-weight: 500; }

/* Library toolbar — search + filter chips. */
.bg-library-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.bg-library-search { flex: 1; min-width: 240px; max-width: 360px; }
.bg-library-search input {
  width: 100%; padding: 9px 12px;
  border-radius: 8px; border: 1px solid var(--border-soft);
  font-size: 13px; background: #fff;
}
.bg-library-search input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0,112,252,0.10); }
.bg-library-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.bg-filter-chip { display: inline-flex; align-items: center; gap: 6px; }
.bg-filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 16px; padding: 0 5px;
  border-radius: 8px; background: rgba(14, 11, 26, 0.08);
  font-size: 10px; font-weight: 600; color: var(--text-muted);
}
.bg-filter-chip.active .bg-filter-count {
  background: rgba(255, 255, 255, 0.25); color: #fff;
}

/* Library grid — compact, scannable cards. */
.bg-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}
.bg-library-card {
  background: var(--bg-page);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow 150ms, transform 150ms;
}
.bg-library-card:hover {
  box-shadow: 0 4px 14px rgba(14, 11, 26, 0.10);
  transform: translateY(-1px);
}
.bg-library-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px;
}
.bg-library-card-title { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.bg-library-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bg-status-pill { font-size: 10px; white-space: nowrap; }

/* Thumb row — three aspect ratios in a tidy line. */
.bg-library-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.bg-thumb-cell { display: flex; flex-direction: column; gap: 4px; }
.bg-thumb {
  position: relative;
  background: #fff;
  background-size: cover; background-position: center;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.bg-thumb.is-missing {
  background: repeating-linear-gradient(45deg,
    rgba(204, 227, 255, 0.18) 0 6px,
    rgba(204, 227, 255, 0.36) 6px 12px);
  display: flex; align-items: center; justify-content: center;
  border-style: dashed;
}
.bg-thumb-missing-label {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.bg-thumb-cell.bg-thumb-square    .bg-thumb { aspect-ratio: 1 / 1; }
.bg-thumb-cell.bg-thumb-landscape .bg-thumb { aspect-ratio: 1200 / 628; }
.bg-thumb-cell.bg-thumb-portrait  .bg-thumb { aspect-ratio: 4 / 5; }
.bg-thumb-caption {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 4px; font-size: 10px;
}
.bg-thumb-name { color: var(--text); font-weight: 600; }
.bg-thumb-dim  { color: var(--text-muted); font-family: var(--font-mono); }
.bg-thumb-remove {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(14, 11, 26, 0.55); color: #fff;
  border: none; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: none; align-items: center; justify-content: center;
}
.bg-thumb.has-image:hover .bg-thumb-remove { display: flex; }

/* Empty state — distinguishes "no library yet" from "no matches" */
.bg-empty-state {
  padding: 40px 24px; text-align: center;
  border: 1px dashed var(--border-soft); border-radius: var(--radius-card);
  background: var(--bg-page);
}
.bg-empty-icon { font-size: 32px; color: var(--brand-blue); margin-bottom: 8px; opacity: 0.7; }
.bg-empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.bg-empty-sub { font-size: 13px; color: var(--text-muted); max-width: 420px; margin: 0 auto; }

/* ---------- Download progress overlay ---------- */
.download-progress-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(14, 11, 26, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 180ms ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.download-progress-card {
  background: #fff; border-radius: 14px;
  padding: 28px 32px; min-width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  text-align: center;
}
.download-progress-spark {
  font-size: 28px; line-height: 1;
  color: var(--brand-blue);
  animation: dpSpin 1.2s ease-in-out infinite;
  display: inline-block;
}
@keyframes dpSpin {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.85; }
  50%      { transform: scale(1.15) rotate(180deg); opacity: 1; }
}
.download-progress-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-top: 10px;
}
.download-progress-sub {
  font-size: 13px; color: var(--text-muted);
  margin-top: 4px;
}
.download-progress-track {
  margin-top: 16px;
  height: 6px; width: 100%;
  background: #E2E8F0; border-radius: 3px;
  overflow: hidden;
}
.download-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand-blue), #5BAEFF);
  border-radius: 3px;
}
.empty {
  padding: 32px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border-soft); border-radius: 12px; background: #fff;
}

/* slot indicator */
.slot-thumb { position: relative; width: 56px; height: 42px; border-radius: 6px; background: #F2F8FF; border: 0.5px solid var(--border-soft); display:inline-flex; align-items:center;justify-content:center; font-size: 10px; color: var(--text-muted); overflow:hidden;}
.slot-thumb.empty { border-style: dashed; }
.slot-thumb .canvas { position: absolute; inset: 0; }
.slot-row { display: flex; align-items: center; gap: 10px; }
.slot-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); }

/* Dealer slot-assign page (First / Second / Third) */
.slot-assign-card { padding: 16px 20px; }
.slot-assign-body { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.slot-assign-thumb { position: relative; width: 200px; aspect-ratio: 4/3; flex: 0 0 200px; border-radius: 8px; overflow: hidden; background: #F2F8FF; border: 0.5px solid var(--border-soft); }
.slot-assign-thumb .canvas { position: absolute; inset: 0; }
.cre-card.selected { outline: 2px solid var(--brand-blue); outline-offset: -1px; }
@media (max-width: 600px) {
  .slot-assign-thumb { width: 100%; flex-basis: auto; }
}

/* coverage bar */
.coverage { height: 6px; background: #F2F8FF; border-radius: 3px; overflow: hidden; width: 160px;}
.coverage > span { display: block; height: 100%; background: var(--accent-success); }

/* tabs in page head */
.subnav { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border-soft); margin-bottom: 16px;}
.subnav button {
  background: transparent; border: none;
  padding: 8px 12px; border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer;
}
.subnav button.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }

/* checkbox row */
.check-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* AI prompt chips */
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  background: var(--bg-page); border: 1px solid var(--border-soft);
  color: var(--text); padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 400; cursor: pointer;
}

/* Slot picker */
.slot-pick { display: inline-flex; gap: 4px; }
.slot-pick button {
  font-size: 10px; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--border-soft); background: #fff; color: var(--text-muted);
  letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600; cursor: pointer;
}
.slot-pick button.on { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }

/* Background gallery */
.bg-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 280px; overflow-y: auto; padding: 4px;}
.bg-tile { aspect-ratio: 4/3; border-radius: 8px; border: 0.5px solid var(--border-soft); cursor: pointer; position: relative; overflow: hidden;}
.bg-tile.selected { outline: 2px solid var(--brand-blue); outline-offset: 1px; }
.bg-tile .lab { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,0.5); color:#fff; font-size: 10px; padding: 1px 6px; border-radius: 4px; }

/* Grouped predefined-bg picker (creative editor → Background → Predefined) */
.bg-section + .bg-section { margin-top: 18px; }
.bg-section-head { display: flex; align-items: baseline; gap: 8px; }
.bg-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-strong, #1a1a1a); font-weight: 700; }
.bg-section-count { font-size: 11px; color: var(--text-muted, #64748b); background: var(--border-soft, #e5e7eb); padding: 1px 7px; border-radius: 999px; }
.bg-section-help { font-size: 11px; color: var(--text-muted, #64748b); margin: 2px 0 8px; }
.bg-gallery.rich { max-height: none; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.bg-tile.rich { aspect-ratio: 4/3; }
.bg-tile.rich .bg-tile-label,
.bg-tile.compact .bg-tile-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 22px 10px 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.45) 55%, rgba(0,0,0,0) 100%);
  color: #fff;
}
.bg-tile-title { font-size: 13px; font-weight: 600; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,0.55); }
.bg-tile-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.bg-tile-chip {
  font-size: 9px; padding: 1px 6px; border-radius: 3px;
  background: rgba(255,255,255,0.22); color: rgba(255,255,255,0.95);
  text-transform: lowercase; letter-spacing: 0.2px; backdrop-filter: blur(2px);
}

/* Compact bg picker: single tabbed grid with fixed scroll height (no multi-section sprawl) */
.bg-gallery.compact {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; max-height: 320px; overflow-y: auto; padding: 4px;
  border: 0.5px solid var(--border-soft); border-radius: 8px; background: #FAFBFC;
}
.bg-tile.compact { aspect-ratio: 4/3; border-radius: 6px; cursor: pointer; position: relative; overflow: hidden; border: 0.5px solid var(--border-soft); }
.bg-tile.compact.selected { outline: 2px solid var(--brand-blue); outline-offset: 1px; }
.bg-tile.compact .bg-tile-title { font-size: 11px; }
.bg-tile.compact .bg-tile-chip { font-size: 8px; padding: 1px 5px; }

/* Tag-chip input (Add Background modal) */
.chip-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px; min-height: 38px;
  border: 0.5px solid var(--border-soft); border-radius: 6px; background: #fff;
}
.chip-input:focus-within { border-color: var(--brand-blue); }
.chip-input input { flex: 1; min-width: 80px; border: 0; outline: 0; padding: 4px 6px; font-size: 13px; background: transparent; }
.chip-input .chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--brand-blue); color: #fff;
}
.chip-input .chip .x {
  cursor: pointer; padding: 0 6px; border-radius: 10px;
  background: rgba(255,255,255,0.25); line-height: 16px; font-weight: 700;
}

/* Toggle */
.toggle { position: relative; display: inline-block; width: 34px; height: 20px; }
.toggle input { display: none; }
.toggle .slider { position: absolute; inset: 0; background: #CBD5E1; border-radius: 999px; transition: 0.15s; }
.toggle .slider::before { content:""; position:absolute; top:2px; left:2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: 0.15s; }
.toggle input:checked + .slider { background: var(--brand-blue); }
.toggle input:checked + .slider::before { transform: translateX(14px); }
.toggle input:disabled + .slider { opacity: 0.5; }

/* drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 720px; max-width: 100%; background: #fff; z-index: 91; box-shadow: -10px 0 40px rgba(14,11,26,0.18); display: flex; flex-direction: column;}
.drawer-head { padding: 20px 24px; border-bottom: 0.5px solid var(--border-soft); display: flex; justify-content: space-between; align-items: flex-start;}
.drawer-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* ---------- Dealer Creative Studio (DCS) ---------- */
.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
}
/* When no model is picked, the live-preview column hides and the steps column expands
   to full width — gives the model-picker hero center stage. */
.studio-layout.studio-layout-hero { grid-template-columns: 1fr; }
.studio-layout.studio-layout-hero .studio-preview-col { display: none; }
@media (max-width: 980px) { .studio-layout { grid-template-columns: 1fr; } }

/* ---------- Studio model-picker section (shown when state.productId is null) ----------
   Renamed from `.studio-hero` because that name is already used for the car-image
   overlay inside the canvas (position:absolute + pointer-events:none) — a name clash
   that made every tile in the picker unclickable. Using a unique prefix avoids it. */
.studio-pick-model {
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 32px 32px 28px;
}
.studio-pick-model-head { text-align: center; margin-bottom: 24px; }
.studio-pick-model-title {
  font-size: 22px; font-weight: 700; color: var(--text);
  margin: 0 0 6px; letter-spacing: -0.3px;
}
.studio-pick-model-sub {
  font-size: 13px; color: var(--text-muted);
  margin: 0; max-width: 640px; margin-left: auto; margin-right: auto;
}
.studio-pick-model-grid .studio-tile-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.studio-pick-model-grid .studio-tile-thumb { aspect-ratio: 4/3; }
.studio-pick-model-grid .studio-tile { transition: transform 150ms, box-shadow 150ms, outline-color 120ms; }
.studio-pick-model-grid .studio-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(14,11,26,0.10);
}
.studio-pick-model-foot {
  text-align: center; margin-top: 22px;
  font-size: 13px;
}
.studio-pick-model-foot .muted { color: var(--text-muted); margin-right: 8px; }

/* "Composing for: <model>" chip that replaces Step 1 once a model is picked. */
.studio-context-chip {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 12px 14px;
}
.studio-context-chip-thumb {
  width: 56px; height: 56px; flex: 0 0 auto;
  background: #F2F8FF center/contain no-repeat;
  border-radius: 8px;
}
.studio-context-chip-meta { flex: 1; min-width: 0; }
.studio-context-chip-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted);
}
.studio-context-chip-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-top: 2px;
}
.studio-steps { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.studio-step { padding: 16px 18px; }
.studio-step.disabled { opacity: 0.5; pointer-events: none; }
.studio-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.studio-step-title { font-size: 15px; font-weight: 600; color: var(--text); }
.studio-step-summary {
  margin-left: auto;
  font-size: 11px; font-weight: 500;
  color: var(--brand-blue);
  background: var(--bg-page); padding: 2px 10px; border-radius: 12px;
}
.studio-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.studio-tile {
  border: 1px solid var(--border-soft); border-radius: 8px;
  background: #fff; cursor: pointer;
  overflow: hidden;
  transition: outline-color 120ms;
}
.studio-tile:hover { outline: 1px solid var(--brand-blue); outline-offset: -1px; }
.studio-tile.selected { outline: 2px solid var(--brand-blue); outline-offset: -2px; }
.studio-tile-thumb {
  width: 100%; aspect-ratio: 4/3;
  /* `contain` (not `cover`) so the whole vehicle is visible — the uploaded asset is a
     side-on pose with empty padding around it; cropping it crops away the car body. */
  background: #F2F8FF center/contain no-repeat;
}
.studio-tile-thumb.empty { background: repeating-linear-gradient(45deg, #F2F8FF 0 8px, #E5F1FF 8px 16px); }
.studio-tile-label { font-size: 12px; font-weight: 600; padding: 6px 8px 2px; color: var(--text); }
.studio-tile-sub { font-size: 11px; padding: 0 8px 6px; color: var(--text-muted); }
.studio-input {
  width: 100%;
  padding: 8px 10px; border-radius: 8px;
  border: 0.5px solid var(--border-soft); background: #fff;
  font-size: 13px; color: var(--text);
}
.studio-input-readonly {
  background: var(--bg-page); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 600;
}

/* Preview pane */
.studio-preview-col { position: sticky; top: 18px; }
.studio-preview-card { padding: 16px 18px; }
/* Studio live-preview pane (dealer side).
   Layout:
     row 1: landscape hero, full width
     row 2: square (5fr) + portrait (4fr) — the 5:4 column ratio makes both bottom tiles
            land at identical pixel heights (square h = w; portrait h = w × 5/4; with widths
            5:4 the heights collapse to the same value).
   This replaces the older "huge square + two skinny thumbs" zigzag with a balanced trio. */
.studio-preview-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.studio-preview-body-empty {
  min-height: 220px;
  background: #FAFCFF;
  box-shadow: inset 0 0 0 0.5px var(--border-soft);
  border-radius: 10px;
}
.studio-preview-bottom-row {
  display: grid;
  grid-template-columns: 5fr 4fr;
  gap: 12px;
  align-items: start;
}
.studio-preview-tile {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.studio-preview-tile-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text-muted);
  padding-left: 2px;
}
.studio-preview-frame {
  position: relative;
  background: #0E0B1A;
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 1px 3px rgba(14,11,26,0.08);
  transition: box-shadow 150ms, transform 150ms;
}
.studio-preview-frame:hover {
  box-shadow: 0 4px 14px rgba(14,11,26,0.22);
  transform: translateY(-1px);
}
.studio-preview-square    .studio-preview-frame { aspect-ratio: 1 / 1; }
.studio-preview-portrait  .studio-preview-frame { aspect-ratio: 4 / 5; }
.studio-preview-landscape .studio-preview-frame { aspect-ratio: 1200 / 628; }
.studio-preview-frame svg { display: block; width: 100%; height: 100%; }

/* Corner expand button — overlays each frame; opens the all-sizes popup. */
.studio-preview-expand {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: rgba(14,11,26,0.55);
  color: #fff; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in;
  opacity: 0.85;
  transition: background 120ms, transform 120ms, opacity 120ms;
}
.studio-preview-frame:hover .studio-preview-expand { opacity: 1; }
.studio-preview-expand:hover { background: rgba(14,11,26,0.9); transform: scale(1.06); }

/* Loader during the 900ms compose animation — sits in the landscape hero slot. */
.studio-preview-loader {
  position: relative;
  aspect-ratio: 1200 / 628;
  background: linear-gradient(135deg, #EAF3FF 0%, #F7FAFF 100%);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}

/* All-aspects popup — grid puts square + portrait on top row, landscape full-width below. */
.studio-modal-body { padding: 0 4px; }
.studio-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.studio-modal-tile {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.studio-modal-tile-landscape { grid-column: 1 / -1; }
.studio-modal-tile-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text-muted);
}
.studio-modal-tile.focused .studio-modal-tile-label { color: var(--brand-blue); }
.studio-modal-frame {
  background: #0E0B1A;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(14,11,26,0.18);
}
.studio-modal-tile.focused .studio-modal-frame {
  box-shadow: 0 0 0 2px var(--brand-blue), 0 4px 14px rgba(14,11,26,0.22);
}
.studio-modal-tile-square    .studio-modal-frame { aspect-ratio: 1 / 1; }
.studio-modal-tile-portrait  .studio-modal-frame { aspect-ratio: 4 / 5; }
.studio-modal-tile-landscape .studio-modal-frame { aspect-ratio: 1200 / 628; }
.studio-modal-frame svg { display: block; width: 100%; height: 100%; }
@media (max-width: 720px) {
  .studio-modal-grid { grid-template-columns: 1fr; }
  .studio-modal-tile-landscape { grid-column: auto; }
}

/* Magical loader — shimmer + spark + sub-text. Runs for ~900ms after each bg pick. */
.studio-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #EAF3FF 0%, #F7FAFF 100%);
}
.studio-loader-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(
    100deg,
    rgba(255,255,255,0) 30%,
    rgba(255,255,255,0.85) 50%,
    rgba(255,255,255,0) 70%
  );
  background-size: 300% 100%;
  animation: studio-shimmer 1.4s linear infinite;
}
.studio-loader-spark {
  position: relative;
  font-size: 28px;
  color: var(--brand-blue);
  animation: studio-spark 1.2s ease-in-out infinite;
  text-shadow: 0 0 12px rgba(0,112,252,0.45);
}
.studio-loader-text {
  position: relative;
  font-size: 12px; font-weight: 500; letter-spacing: 0.4px;
  color: var(--text-muted);
}
@keyframes studio-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}
@keyframes studio-spark {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.85; }
  50%      { transform: scale(1.25) rotate(180deg); opacity: 1; }
}
/* Reveal wrapper that fades the composition in once the loader resolves. */
.studio-reveal { position: absolute; inset: 0; animation: studio-fade-in 280ms ease-out; }
@keyframes studio-fade-in {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}
.studio-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
}
.studio-hero {
  /* The uploaded hero PNG is pre-sized to the canvas: it's a transparent PNG with the
     car already positioned correctly for its aspect ratio. Overlay it 1:1 on top of
     the background — no rescaling box, no bottom-anchored fit. */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}
.studio-hero-placeholder {
  position: absolute; inset: 18% 10% 28%;
  border: 1px dashed rgba(255,255,255,0.6); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; letter-spacing: 0.3px;
  background: rgba(0,0,0,0.18);
}
.studio-logo {
  position: absolute; top: 14px;
  background: rgba(255,255,255,0.92); color: var(--brand-indigo);
  font-family: var(--font-brand); font-weight: 700;
  font-size: 12px; letter-spacing: 1.5px;
  padding: 6px 10px; border-radius: 6px;
}
.studio-logo.tl { left: 14px; }
.studio-logo.tr { right: 14px; }
.studio-tagline {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  max-width: 70%; text-align: center;
  color: #fff;
  font-family: var(--font-brand); font-weight: 700;
  font-size: 18px; letter-spacing: 0.2px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.studio-offer {
  position: absolute; right: 16px; top: 56px;
  text-align: right; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.studio-offer-qual { font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; opacity: 0.85; }
.studio-offer-value { font-family: var(--font-mono); font-size: 30px; font-weight: 700; line-height: 1; color: #FFD86B; }
.studio-offer-label { font-size: 12px; margin-top: 2px; font-weight: 500; }
.studio-dealer {
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}
.studio-dealer-name { font-weight: 700; font-size: 14px; }
.studio-dealer-phone { font-family: var(--font-mono); font-weight: 600; font-size: 15px; margin-top: 1px; }
.studio-dealer-addr { font-size: 11px; opacity: 0.9; margin-top: 1px; padding: 0 16px; line-height: 1.3; }

/* DCS Admin — product grid + background grid */
.studio-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.studio-admin-grid.sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.studio-admin-card {
  background: #fff;
  border: 0.5px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  transition: outline-color 120ms, transform 120ms;
}
.studio-admin-card:hover { outline: 1px solid var(--brand-blue); outline-offset: -1px; }
.studio-admin-thumb {
  position: relative;
  width: 100%; aspect-ratio: 4/3;
  /* `contain` (not `cover`) so the full vehicle is shown on the catalog tile —
     uploaded poses have transparent padding; `cover` cropped them mid-body. */
  background: #F2F8FF center/contain no-repeat;
}
.studio-admin-thumb-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
  background: repeating-linear-gradient(45deg, #F2F8FF 0 8px, #E5F1FF 8px 16px);
}
.studio-admin-meta { padding: 10px 12px; }
.studio-admin-name { font-size: 13px; font-weight: 600; color: var(--text); }
.studio-admin-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.studio-admin-stat {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
}
.studio-admin-stat .pill { font-size: 10px; padding: 1px 6px; }

/* DCS Admin — upload slots & action buttons (theme-aligned with brand-blue + border-soft) */
.studio-upload-slot { display: flex; flex-direction: column; gap: 6px; }
.studio-upload-tile {
  position: relative;
  width: 100%; aspect-ratio: 4/3;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-ctrl);
  background: #FAFCFF center/cover no-repeat;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 120ms, background-color 120ms, box-shadow 120ms;
}
.studio-upload-tile:hover {
  border-color: var(--brand-blue);
  background-color: var(--bg-page);
  box-shadow: 0 0 0 3px rgba(0,112,252,0.10);
}
.studio-upload-tile.has-image {
  border-style: solid;
  border-color: var(--border-soft);
}
.studio-upload-tile.uploading::after {
  content: "Uploading…";
  position: absolute; inset: 0;
  background: rgba(242,248,255,0.92);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--brand-blue);
  border-radius: var(--radius-ctrl);
}
.studio-upload-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  padding: 4px 8px; text-align: center;
}
.studio-upload-plus {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 400; line-height: 1;
}

/* Overlay action buttons — theme-styled pills, surfaced on hover */
.studio-upload-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.45) 100%);
  opacity: 0; transition: opacity 120ms;
  border-bottom-left-radius: var(--radius-ctrl);
  border-bottom-right-radius: var(--radius-ctrl);
}
.studio-upload-tile.has-image:hover .studio-upload-overlay,
.studio-bg-card:hover .studio-upload-overlay { opacity: 1; }
.studio-upload-action {
  background: #fff;
  border-radius: var(--radius-ctrl);
  padding: 4px 10px;
  font-size: 11px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(14, 11, 26, 0.12);
}
.studio-upload-action:hover { filter: brightness(0.96); }
.studio-bg-remove { /* sits at the bottom-right of the bg thumb */ }

/* "Staged" badge — shown when a file is staged locally but not yet committed to the server */
.studio-staged-badge {
  position: absolute; top: 6px; left: 6px;
  font-size: 9px; padding: 2px 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(14, 11, 26, 0.18);
}

/* Default-variant radio toggle — looks like a pill, not a raw radio */
.studio-default-variant-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  color: var(--brand-blue);
  background: #fff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.studio-default-variant-toggle:hover { background: var(--bg-page); }
.studio-default-variant-toggle.is-on {
  background: var(--brand-blue); color: #fff;
  border-color: var(--brand-blue); font-weight: 600;
}
.studio-default-variant-toggle input { display: none; }

/* Tighter default-slot — square only, smaller max */
/* Default side-pose tile: full car must fit inside, no cropping or stretching.
   The source PNG often carries transparent padding around the car — `contain`
   keeps the proportions and lets the tile background show around it. */
.studio-default-slot .studio-upload-tile {
  width: 260px; max-width: 100%;
  aspect-ratio: 16 / 10;
  background-color: #FAFCFF;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* Variant editor row (single-aspect — legacy, kept for safety) */
.studio-variant-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 0; border-top: 0.5px solid var(--border-soft);
}
.studio-variant-row:first-of-type { border-top: none; padding-top: 0; }

/* Variant block — name on top, three aspect-ratio tiles below */
.studio-variant-block {
  padding: 14px 0;
  border-top: 0.5px solid var(--border-soft);
}
.studio-variant-block:first-of-type { border-top: none; padding-top: 0; }

/* Aspect-ratio row of three upload tiles */
.studio-aspect-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 720px) { .studio-aspect-row { grid-template-columns: 1fr; } }
.studio-aspect-slot { display: flex; flex-direction: column; gap: 6px; }
.studio-aspect-header { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.studio-aspect-name { font-size: 12px; font-weight: 600; color: var(--text); }
.studio-aspect-dim  { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }

/* The aspect upload tile inherits .studio-upload-tile sizing, then overrides for each ratio */
.studio-aspect-slot .studio-upload-tile { width: 100%; }
.studio-aspect-slot .studio-upload-tile.aspect-square    { aspect-ratio: 1 / 1; }
.studio-aspect-slot .studio-upload-tile.aspect-landscape { aspect-ratio: 1200 / 628; }
.studio-aspect-slot .studio-upload-tile.aspect-portrait  { aspect-ratio: 960 / 1200; }

/* ---------- Brand template editor ---------- */
.tpl-chip {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-ctrl);
  background: #fff;
}
.tpl-chip.active { border-color: var(--brand-blue); box-shadow: 0 0 0 2px rgba(0,112,252,0.10); }
.tpl-chip.editing { background: var(--bg-page); }

.tpl-toggle-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
/* Translation section is short enough to always fit on one row. */
.tpl-toggle-grid.tpl-toggle-grid-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 720px) {
  .tpl-toggle-grid.tpl-toggle-grid-row {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
.tpl-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-ctrl);
  background: #fff;
  cursor: pointer;
}
.tpl-toggle input[type="checkbox"] { margin-top: 2px; accent-color: var(--brand-blue); }
.tpl-toggle:hover { background: var(--bg-page); }

.tpl-logo-tile {
  position: relative;
  width: 100%; max-width: 320px; aspect-ratio: 170 / 56;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-ctrl);
  /* Light grey solid — visible against both white and dark transparent logos. */
  background: #D9DEE6 center/contain no-repeat;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 120ms, background-color 120ms, box-shadow 120ms;
}
.tpl-logo-tile:hover { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0,112,252,0.10); }
/* Once a logo is uploaded, the tile shows a checker-pattern background so transparent
   PNGs with white content stay visible against the surrounding white form. The actual
   logo image is layered on a child .tpl-logo-tile-img element above it. */
.tpl-logo-tile.has-image {
  border-style: solid; border-color: var(--border-soft);
  background-color: #E5EAF0;
  background-image:
    linear-gradient(45deg, #C8CDD6 25%, transparent 25%),
    linear-gradient(-45deg, #C8CDD6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #C8CDD6 75%),
    linear-gradient(-45deg, transparent 75%, #C8CDD6 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.tpl-logo-tile-img {
  position: absolute; inset: 6px;
  background: center/contain no-repeat;
  pointer-events: none;
}
.tpl-logo-tile.has-image:hover .studio-upload-overlay { opacity: 1; }
.tpl-logo-tile.uploading::after {
  content: "Uploading…";
  position: absolute; inset: 0;
  background: rgba(242,248,255,0.92);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--brand-blue);
  border-radius: var(--radius-ctrl);
}

/* ---------- Template page: list cards (default view) ---------- */
.tpl-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tpl-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tpl-card:hover {
  border-color: var(--brand-blue);
  box-shadow: 0 4px 12px rgba(14, 11, 26, 0.10);
  transform: translateY(-1px);
}
.tpl-card.active {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px rgba(0, 112, 252, 0.12);
}
.tpl-card-thumb {
  width: 100%; aspect-ratio: 1 / 1;
  background: #1A1230;
  overflow: hidden;
}
.tpl-card-thumb svg { display: block; width: 100%; height: 100%; }
.tpl-card-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tpl-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.tpl-card-badge {
  font-size: 10px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--brand-blue);
  background: rgba(0, 112, 252, 0.08);
  padding: 3px 8px; border-radius: 10px;
  white-space: nowrap;
}
.tpl-card-badge.muted { color: var(--text-muted); background: var(--bg-page); }
.tpl-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Template page: editor (form + preview) ---------- */
.tpl-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .tpl-form-row { grid-template-columns: 1fr; }
}
.tpl-editor-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.tpl-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--brand-blue);
  font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px;
  cursor: pointer;
}
.tpl-back-btn:hover { background: var(--bg-page); }
.tpl-back-btn svg { display: block; }
.tpl-editor-title {
  font-size: 14px; font-weight: 600; color: var(--text);
}

#tpl-previews-card {
  position: sticky; top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.tpl-aspect-tabs { gap: 4px; }
.tpl-zoom-btn { display: inline-flex; align-items: center; gap: 6px; }
.tpl-zoom-btn svg { display: block; }

.tpl-preview-tile {
  background: #0E0B1A; border-radius: var(--radius-ctrl);
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.tpl-preview-tile.tpl-preview-big { padding: 10px; }
.tpl-preview-meta {
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,0.72);
  text-align: center;
  padding: 4px 2px 0;
}
.tpl-preview-frame {
  width: 100%; overflow: hidden; border-radius: 6px;
  background: #1A1230; margin: 0 auto;
}
.tpl-preview-frame svg { display: block; }
.tpl-preview-big.tpl-preview-square    .tpl-preview-frame { aspect-ratio: 1 / 1;      max-width: 380px; }
.tpl-preview-big.tpl-preview-portrait  .tpl-preview-frame { aspect-ratio: 4 / 5;      max-width: 320px; }
.tpl-preview-big.tpl-preview-landscape .tpl-preview-frame { aspect-ratio: 1200 / 628; max-width: 100%; }

/* ---------- Zoom modal ---------- */
.tpl-zoom-body { padding: 0 24px 24px; display: flex; justify-content: center; }
.tpl-zoom-frame { width: 100%; background: #1A1230; border-radius: 8px; overflow: hidden; }
.tpl-zoom-frame svg { display: block; }
.tpl-zoom-square    { max-width: 720px;  aspect-ratio: 1 / 1; }
.tpl-zoom-portrait  { max-width: 580px;  aspect-ratio: 4 / 5; }
.tpl-zoom-landscape { max-width: 1100px; aspect-ratio: 1200 / 628; }

/* ---------- Dealer Library (saved Studio compositions) ---------- */
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.lib-tile {
  background: var(--surface);
  border: 0.5px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform 150ms, box-shadow 150ms;
}
.lib-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(14,11,26,0.12); }
.lib-tile-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #0E0B1A;
  cursor: zoom-in;
  overflow: hidden;
}
.lib-tile-thumb svg { display: block; width: 100%; height: 100%; }
.lib-tile-hover {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14,11,26,0.55);
  color: #fff; font-size: 14px; font-weight: 600; letter-spacing: 0.2px;
  opacity: 0; transition: opacity 140ms;
}
.lib-tile-thumb:hover .lib-tile-hover { opacity: 1; }
.lib-tile-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.55); font-size: 12px;
}
.lib-tile-meta { padding: 10px 14px 12px; }
.lib-tile-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-tile-sub {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}
.lib-tile-actions {
  display: flex; gap: 6px; margin-top: 10px;
}

/* Library empty state */
.lib-empty {
  text-align: center;
  padding: 56px 32px;
}
.lib-empty-icon { font-size: 48px; margin-bottom: 12px; }
.lib-empty-title {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin: 0 0 8px;
}
.lib-empty-body {
  font-size: 13px; color: var(--text-muted);
  max-width: 520px; margin: 0 auto 20px;
}
.lib-empty-cta { display: flex; justify-content: center; }
