:root{
  /* Core surfaces */
  --bg:#0b1020;
  --panel:#111a33;
  --panel2:#0f1730;

  /* Text */
  --text:#e9eeff;
  --muted:#aab4dd;

  /* Lines */
  --line:rgba(255,255,255,.10);
  --line2:rgba(255,255,255,.07);
  --line3:rgba(255,255,255,.05);

  /* Brand + accents (keep --accent for compatibility) */
  --accent:#4f7cff;                 /* cool accent (links, focus, secondary) */
  --accent-rgb:79,124,255;

  --brand:#f2b84d;                  /* warm brand accent (primary actions) */
  --brand-rgb:242,184,77;

  /* Semantic */
  --ok:#2dd4bf;
  --ok-rgb:45,212,191;

  --warn:#f59e0b;
  --warn-rgb:245,158,11;

  --bad:#fb7185;
  --bad-rgb:251,113,133;

  /* Ambient glows (for "studio after hours" background) */
  --glow-a: rgba(var(--brand-rgb), .14);
  --glow-b: rgba(154, 125, 255, .10);

  --r:14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow2: 0 6px 16px rgba(0,0,0,.25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Light mode tokens (toggle sets documentElement.dataset.theme="light") */
:root[data-theme="light"]{
  /* Core surfaces */
  --bg:#f5f7ff;
  --panel:#ffffff;
  --panel2:#f2f4ff;

  /* Text */
  --text:#111827;
  --muted:#4b5563;

  /* Lines */
  --line:rgba(17,24,39,.12);
  --line2:rgba(17,24,39,.10);
  --line3:rgba(17,24,39,.08);

  /* Brand + accents (keep --accent for compatibility) */
  --accent:#2f63ff;
  --accent-rgb:47,99,255;

  --brand:#d97706;
  --brand-rgb:217,119,6;

  /* Semantic */
  --ok:#0f766e;
  --ok-rgb:15,118,110;

  --warn:#b45309;
  --warn-rgb:180,83,9;

  --bad:#be123c;
  --bad-rgb:190,18,60;

  /* Ambient glows (subtle in light mode) */
  --glow-a: rgba(var(--brand-rgb), .10);
  --glow-b: rgba(var(--accent-rgb), .06);

  --shadow: 0 10px 30px rgba(17,24,39,.12);
  --shadow2: 0 6px 16px rgba(17,24,39,.10);
}


*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--sans);
  background: radial-gradient(1200px 700px at 22% 12%, var(--glow-a), transparent 58%),
              radial-gradient(1000px 600px at 82% 28%, var(--glow-b), transparent 60%),
              var(--bg);
  color:var(--text);
}

:root[data-theme="light"] body{
  background: radial-gradient(1200px 700px at 22% 12%, var(--glow-a), transparent 58%),
              radial-gradient(1000px 600px at 82% 28%, var(--glow-b), transparent 60%),
              var(--bg);
}

a{ color:inherit; text-decoration:none; }

.container{
  max-width:1280px;
  margin:0 auto;
  padding:26px 18px 48px;
}

.header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}

.title{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.title h1{
  font-size:22px;
  margin:0;
  letter-spacing:.2px;
}
.title .sub{
  color:var(--muted);
  font-size:13px;
}

/* ===== Header Logo Swap (dark/light themes) ===== */
.siteLogoWrap{
  display:flex;
  align-items:center;
  gap:10px;
}

.siteLogo{
  display:block;
  height:26px;           /* matches old H1 visual weight */
  width:auto;
  max-width:min(520px, 72vw);
}

.siteLogo--lightbg{ display:none; }      /* shown in light theme */
:root[data-theme="light"] .siteLogo--darkbg{ display:none; }
:root[data-theme="light"] .siteLogo--lightbg{ display:block; }

/* Hide the legacy "Next step" header CTA (kept in DOM for JS wiring) */
.bmTopCtaHidden{ display:none !important; }

.grid{
  display:grid;
  grid-template-columns: clamp(320px, 28vw, 420px) minmax(0, 1fr);
  gap:16px;
  align-items:start;
}

/* ✅ Sticky preview (most reliable): stick the grid item itself */
@media (min-width: 981px){
  .previewCol{
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

.stack{
  display:flex;
  flex-direction:column;
  gap:16px;
  min-width:0;
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  border:1px solid var(--line2);
  border-radius:var(--r);
  box-shadow:var(--shadow2);
  overflow:hidden;
  min-width:0;
}
:root[data-theme="light"] .card{
  background: linear-gradient(180deg, rgba(17,24,39,.018), rgba(17,24,39,.008));
  border-color: var(--line2);
}

.card .card-h{
  padding:14px 14px 12px;
  border-bottom:1px solid var(--line3);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  background: linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,.02));
}
:root[data-theme="light"] .card .card-h{
  background: linear-gradient(180deg, rgba(17,24,39,.02), rgba(17,24,39,.01));
}

.card .card-h .h-left{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.card .card-h .step{
  font-size:12px;
  color:var(--muted);
  letter-spacing:.6px;
  text-transform:uppercase;
}
.card .card-h .name{
  font-size:14px;
  font-weight:600;
  letter-spacing:.15px;
}

.card .card-b{ padding:14px; }

.row{
  display:flex;
  gap:10px;
  align-items:flex-end;
  flex-wrap:wrap;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  flex:1 1 240px;
  min-width:240px;
}

label{
  font-size:12px;
  color:var(--muted);
}

input[type="text"], select, input[type="number"], input[type="email"]{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--line2);
  background: rgba(0,0,0,.08);
  color:var(--text);
  outline:none;
}
:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] select,
:root[data-theme="light"] input[type="number"],
:root[data-theme="light"] input[type="email"]{
  background: rgba(255,255,255,.90);
}

/* Select dropdown menu (option list) contrast
   Windows/Chrome often renders <option> menus with a light background even in dark UI.
   Force a solid option background + readable text globally. */
select{
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}
select option,
select optgroup{
  background-color: #0b1020;
  color: var(--text);
}

:root[data-theme="light"] select{
  color: rgba(17,24,39,.92);
  -webkit-text-fill-color: rgba(17,24,39,.92);
}
:root[data-theme="light"] select option,
:root[data-theme="light"] select optgroup{
  background-color: #ffffff;
  color: rgba(17,24,39,.92);
}

input[type="text"]:focus, select:focus, input[type="number"]:focus, input[type="email"]:focus{
  border-color: rgba(var(--accent-rgb), .55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .16);
}
:root[data-theme="light"] input[type="text"]:focus,
:root[data-theme="light"] select:focus,
:root[data-theme="light"] input[type="number"]:focus,
:root[data-theme="light"] input[type="email"]:focus{
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}


input::placeholder{ color: rgba(233,238,255,.35); }
:root[data-theme="light"] input::placeholder{ color: rgba(17,24,39,.35); }

.help{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}

.divider{
  height:1px;
  background: var(--line3);
  margin:12px 0;
}

.btn{
  border:1px solid var(--line2);
  background: rgba(0,0,0,.08);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  user-select:none;
  white-space:nowrap;
}
.btn:hover{ background: rgba(0,0,0,.22); border-color: rgba(255,255,255,.14); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.45; cursor:not-allowed; }

:root[data-theme="light"] .btn{ background: rgba(17,24,39,.04); }
:root[data-theme="light"] .btn:hover{ background: rgba(17,24,39,.07); }

.btn.primary{
  background: rgba(var(--brand-rgb), .92);
  border-color: rgba(var(--brand-rgb), .95);
  color:#0b1020;
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
}
.btn.primary:hover{ background: rgba(var(--brand-rgb), .98); }
.btn.primary:disabled{
  opacity:.55;
  color: rgba(11,16,32,.60);
  background: rgba(var(--brand-rgb), .35);
  border-color: rgba(var(--brand-rgb), .40);
}

:root[data-theme="light"] .btn.primary{
  background: rgba(var(--brand-rgb), .82);
  border-color: rgba(var(--brand-rgb), .72);
  color:#111827;
}
:root[data-theme="light"] .btn.primary:hover{ background: rgba(var(--brand-rgb), .90); }


:root[data-theme="light"] .btn.primary{
  background: rgba(var(--brand-rgb), .16);
  border-color: rgba(var(--brand-rgb), .38);
  color:#111827;
  box-shadow: none;
}
:root[data-theme="light"] .btn.primary:hover{ background: rgba(var(--brand-rgb), .20); }

.btn.good{
  background: rgba(45,212,191,.20);
  border-color: rgba(45,212,191,.55);
}
:root[data-theme="light"] .btn.good{
  background: rgba(15,118,110,.10);
  border-color: rgba(15,118,110,.25);
}

.btnIcon{
  padding:6px 10px;
  min-width:40px;
  text-align:center;
  font-family: var(--mono);
  line-height:1;
}

.chips{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
}
.chip{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line2);
  background: rgba(0,0,0,.08);
  color:var(--muted);
  line-height:1;
}
.chip.ok{ border-color: rgba(45,212,191,.45); color: rgba(45,212,191,.95); }
.chip.warn{ border-color: rgba(245,158,11,.45); color: rgba(245,158,11,.95); }
.chip.bad{ border-color: rgba(251,113,133,.45); color: rgba(251,113,133,.95); }

:root[data-theme="light"] .chip{
  background: rgba(255,255,255,.85);
  border-color: rgba(17,24,39,.14);
  color: rgba(17,24,39,.72);
  box-shadow: 0 6px 14px rgba(17,24,39,.08);
}
:root[data-theme="light"] .chip.ok{
  background: rgba(15,118,110,.10);
  border-color: rgba(15,118,110,.25);
  color: rgba(15,118,110,.95);
}
:root[data-theme="light"] .chip.warn{
  background: rgba(180,83,9,.10);
  border-color: rgba(180,83,9,.28);
  color: rgba(180,83,9,.95);
}
:root[data-theme="light"] .chip.bad{
  background: rgba(190,18,60,.10);
  border-color: rgba(190,18,60,.28);
  color: rgba(190,18,60,.95);
}

.inline{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.inline.right{ justify-content:flex-end; }

.kv{
  font-family: var(--mono);
  font-size:12px;
  color: rgba(233,238,255,.75);
  padding:8px 10px;
  border-radius:12px;
  border:1px dashed var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,.02));
}
:root[data-theme="light"] .kv{
  color: rgba(17,24,39,.70);
  background: rgba(17,24,39,.03);
}

.previewWrap{ padding:16px; }

.previewHeader{
  padding:14px 16px 12px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.previewKicker{
  text-transform:uppercase;
  letter-spacing:.10em;
  font-size:11px;
  opacity:.85;
}

.previewTitle{
  margin-top:4px;
  font-weight:700;
  font-size:14px;
}

.previewSub{
  margin-top:6px;
  font-size:12px;
  opacity:.85;
  line-height:1.35;
}


.canvasFrame{
  width:100%;
  height: min(78vh, 820px); /* a bit taller */
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(0,0,0,.12);
  padding:12px;            /* less “boxed-in” */
  overflow:hidden;

  /* Key change: let children stretch to fill */
  display:flex;
  align-items:stretch;
  justify-content:stretch;

  display:flex;
  align-items:center;
  justify-content:center;
}

:root[data-theme="light"] .canvasFrame{
  border-color: rgba(17,24,39,.10);
  background: rgba(17,24,39,.03);
}

#canvasStage{ position:relative; width:100%; height:100%;  will-change:transform;}
/* Make the actual canvas fill the available stage */
/* #c{ width:100%;  height:100%;  display:block;}*/

/* IMPORTANT: don't CSS-stretch the Konva canvas; let JS refit the stage */
#c{
  display:block;
  width:auto;
  height:auto;
  max-width:100%;
  max-height:100%;
}

.previewEmpty{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  text-align:center;
  padding:24px;
  pointer-events:none;
}

.hintOverlay{
  position:absolute;
  left:12px;
  right:12px;
  bottom:12px;
  pointer-events:none;
}

.btn.icon{ padding:4px 6px; min-width:28px; line-height:1; font-size:14px; }
.btn.danger{ color:#ff6b6b; border-color: rgba(255, 107, 107, 0.4); }
.btn.danger:hover:not(:disabled){ background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.8); }
.btn.busy{ opacity:0.6; cursor:wait; }
.btn.busy:hover{ background:inherit; }

.upload-status, .uploadStatus{
  margin-top:6px;
  font-size:12px;
  color: rgba(233,238,255,0.7);
  font-family: var(--mono);
}
:root[data-theme="light"] .upload-status,
:root[data-theme="light"] .uploadStatus{ color: rgba(17,24,39,.65); }
.upload-status.busy, .uploadStatus.busy{ color: rgba(255, 200, 120, 0.9); }
:root[data-theme="light"] .upload-status.busy,
:root[data-theme="light"] .uploadStatus.busy{ color: rgba(180,83,9,.90); }


/* --- Light mode: Jobs list contrast ----------------------------------- */
:root[data-theme="light"] #jobsList,
:root[data-theme="light"] .jobsList,
:root[data-theme="light"] .jobs,
:root[data-theme="light"] .jobsPanel{
  color: rgba(17,24,39,.92);
}

/* Job row/container (covers common class names) */
:root[data-theme="light"] .jobRow,
:root[data-theme="light"] .jobItem,
:root[data-theme="light"] .jobCard,
:root[data-theme="light"] .jobEntry{
  background: rgba(17,24,39,.03);
  border-color: rgba(47,99,255,.28);
}

/* Make text inside job rows readable */
:root[data-theme="light"] .jobRow *,
:root[data-theme="light"] .jobItem *,
:root[data-theme="light"] .jobCard *,
:root[data-theme="light"] .jobEntry *{
  color: rgba(17,24,39,.90);
}

/* “Muted” bits (ids, timestamps, helper text) */
:root[data-theme="light"] .jobRow .muted,
:root[data-theme="light"] .jobItem .muted,
:root[data-theme="light"] .jobCard .muted,
:root[data-theme="light"] .jobEntry .muted,
:root[data-theme="light"] .jobRow small,
:root[data-theme="light"] .jobItem small,
:root[data-theme="light"] .jobCard small,
:root[data-theme="light"] .jobEntry small{
  color: rgba(17,24,39,.65);
}

/* Pills/badges inside job rows (“created”, etc.) */
:root[data-theme="light"] .jobRow .pill,
:root[data-theme="light"] .jobItem .pill,
:root[data-theme="light"] .jobCard .pill,
:root[data-theme="light"] .jobEntry .pill,
:root[data-theme="light"] .jobRow .badge,
:root[data-theme="light"] .jobItem .badge,
:root[data-theme="light"] .jobCard .badge,
:root[data-theme="light"] .jobEntry .badge{
  background: rgba(17,24,39,.06);
  border-color: rgba(17,24,39,.14);
  color: rgba(17,24,39,.80);
}

/* --- Light mode: force readable job-row text (opacity + color) ---------- */
:root[data-theme="light"] .jobRow,
:root[data-theme="light"] .jobItem,
:root[data-theme="light"] .jobCard,
:root[data-theme="light"] .jobEntry,
:root[data-theme="light"] .job{
  color: rgba(17,24,39,.92) !important;
}

:root[data-theme="light"] .jobRow *,
:root[data-theme="light"] .jobItem *,
:root[data-theme="light"] .jobCard *,
:root[data-theme="light"] .jobEntry *,
:root[data-theme="light"] .job *{
  opacity: 1 !important; /* this is the key: kills "washed out" */
  color: rgba(17,24,39,.88) !important;
  text-shadow: none !important;
}

/* If the job id/title uses a special class, punch it up a notch */
:root[data-theme="light"] .jobId,
:root[data-theme="light"] .jobTitle,
:root[data-theme="light"] .jobName{
  color: rgba(17,24,39,.92) !important;
}

/* --- Light mode: Jobs list uses .kv rows with inline colors ------------- */
:root[data-theme="light"] #jobsList .kv{
  background: rgba(17,24,39,.03) !important;
  border-color: rgba(47,99,255,.28) !important;
}

/* Override inline text colors inside the job rows */
:root[data-theme="light"] #jobsList .kv,
:root[data-theme="light"] #jobsList .kv *{
  color: rgba(17,24,39,.90) !important;
  opacity: 1 !important;
}

/* Make the “meta” line a touch softer, but still readable */
:root[data-theme="light"] #jobsList .kv div[style*="font-family: var(--mono)"],
:root[data-theme="light"] #jobsList .kv div[style*="font-family:var(--mono)"]{
  color: rgba(17,24,39,.65) !important;
}

/* ===== Account card: Credits ===== */

#authControls { gap: 8px; }

#creditsSection{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Lockout state */
#creditsSection.credits-empty .credits-plan{ color: var(--bad); }
#creditsSection.credits-empty .credits-bar-wrap{ border-color: rgba(251,113,133,.35); }
#creditsSection.credits-empty .credits-bar-fill{ background: var(--bad) !important; }

/* Row: meta + action */
.credits-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.credits-meta{ min-width: 220px; }

.credits-plan{
  font-weight:700;
  letter-spacing:.06em;
  margin-bottom:2px;
  color: var(--accent);
}

.credits-line{
  color: var(--muted);
  font-size:12px;
}

/* Streamlined account card */
.tier-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.tier-row .tier-name {
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

#creditsExtra {
  display: none; /* moved into Account modal */
}


/* Progress bar container */
.credits-bar-wrap{
  position: relative;
  width:100%;
  height:18px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--line2);
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
}
:root[data-theme="light"] .credits-bar-wrap{
  background: rgba(17,24,39,.06);
}

/* Progress bar fill */
.credits-bar-fill{
  height:100%;
  width:0%;
  font-weight:600;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  color: rgba(255,255,255,0.85);
  white-space:nowrap;
  transition: width 0.25s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}

/* Optional 2nd segment (top-up credits). If not used, it stays hidden at 0%. */
.credits-bar-topup{
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:0%;
  border-radius:999px;
  opacity: 0.95;
  transition: width 0.25s ease;
}

/* Overlay label (percentage) */
.credits-bar-label{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  font-weight:700;
  letter-spacing:.2px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  pointer-events:none;
}
:root[data-theme="light"] .credits-bar-label{
  color: rgba(17,24,39,.75);
  text-shadow:none;
}

/* Small label inside the bar (left side) */
.credits-label{
  position:absolute;
  left:10px;
  top:50%;
  transform: translateY(-50%);
  font-size:11px;
  font-weight:600;
  opacity: 0.85;
  color: rgba(255,255,255,0.78);
}
:root[data-theme="light"] .credits-label{
  color: rgba(17,24,39,.60);
}
:root[data-theme="light"] .credits-bar-fill{
  color: rgba(17,24,39,.75);
  box-shadow: inset 0 0 0 1px rgba(17,24,39,.12);
}

/* Two-tone colors (used by the JS gradient) */
:root{
  --bm-credit-sub: #4fb3ff;
  --bm-credit-topup: #36d399;
}

/* Warning states (JS toggles .is-warn / .is-full on .credits-bar-wrap) */
.credits-bar-wrap.is-warn{
  border-color: rgba(245,158,11,.45);
  --bm-credit-sub: rgba(245,158,11,.72);
  --bm-credit-topup: rgba(245,158,11,.50);
}
.credits-bar-wrap.is-full{
  border-color: rgba(251,113,133,.55);
  --bm-credit-sub: rgba(251,113,133,.72);
  --bm-credit-topup: rgba(251,113,133,.55);
}

/* Secondary button look (if not defined elsewhere) */
.btn.btn-secondary{
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}
.btn.btn-secondary:hover{
  background: rgba(255,255,255,0.10);
}

#btnAddCredits{
  padding: 8px 12px;
  font-size: 12px;
}

/* Credits bar shimmer while refreshing (scoped + clipped) */
#creditsSection .credits-bar-wrap{
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#creditsSection .credits-bar-wrap.is-loading::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  transform: translateX(-100%);
  pointer-events:none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 35%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.08) 65%,
    transparent 100%
  );
  animation: bmShimmer 1s linear infinite;
}


:root[data-theme="light"] #creditsSection .credits-bar-wrap.is-loading::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0,0,0,0.06) 35%,
    rgba(0,0,0,0.12) 50%,
    rgba(0,0,0,0.06) 65%,
    transparent 100%
  );
}


.credits-bar-wrap.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 35%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.08) 65%,
    transparent 100%
  );
  animation: bmShimmer 1.0s linear infinite;
  pointer-events: none;
}

@keyframes bmShimmer {
  100% { transform: translateX(100%); }
}

/* Light mode tweak so shimmer is still visible */
body.light .credits-bar-wrap.is-loading::after,
:root[data-theme="light"] .credits-bar-wrap.is-loading::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0,0,0,0.06) 35%,
    rgba(0,0,0,0.12) 50%,
    rgba(0,0,0,0.06) 65%,
    transparent 100%
  );
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  cursor: default;
  color: var(--muted-text, #9aa0a6);
  font-size: 0.85em;
}

.tooltip-wrap:hover {
  color: var(--text-primary, #fff);
}

.tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.95);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.tooltip-wrap:hover .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Light mode */
body.light .tooltip,
:root[data-theme="light"] .tooltip {
  background: rgba(245, 245, 245, 0.98);
  color: #222;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}


.tier-hero-label{
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .85;
  color: rgba(233,238,255,.70);
}
:root[data-theme="light"] .tier-hero-label{
  color: rgba(17,24,39,.65);
}

.tier-hero {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(var(--brand-rgb), .18),
    rgba(154, 125, 255, .10)
  );
  border: 1px solid rgba(var(--brand-rgb), .35);
  margin-bottom: 10px;
  animation: tierPop 0.25s ease-out;
}

.tier-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tier-hero-plan {
  min-width: 0;
}

.tier-hero-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-hero-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.18);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tier-hero-btn:hover {
  background: rgba(0,0,0,.24);
}

.tier-chip {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
}

.tier-handle {
  margin-top: 2px;
  font-size: 11px;
  opacity: .85;
}

@keyframes tierPop {
  0% { transform: scale(.98); opacity: .85; }
  100% { transform: scale(1); opacity: 1; }
}

.tier-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .4px;
  color: var(--text);
}

.tier-sub {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.auth-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
}

.auth-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.auth-identity {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.auth-email {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.auth-status {
  font-size: 11px;
  color: var(--muted);
}

#accountCard.signed-in .card-h {
  padding-bottom: 8px;
}

/* Account Card: prevent flex growth that can leave blank space after refresh */
#accountCard .field{
  flex: 0 0 auto;
  min-width: 0;
}


/* Print realism <details> summary looks expandable */
.bmDetailsSummary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

/* Hide the default disclosure triangle so we control the caret */
.bmDetailsSummary::-webkit-details-marker { display: none; }
.bmDetailsSummary::marker { content: ""; }

.bmDetailsCaret::before {
  content: "▾";
  display: inline-block;
  opacity: 0.9;
  transform: rotate(-90deg); /* closed */
  transition: transform 150ms ease, opacity 150ms ease;
}

/* When details is open, rotate caret down */
details[open] .bmDetailsCaret::before {
  transform: rotate(0deg);
  opacity: 1;
}

.bmDetailsBadge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;

  color: #ff9f1c; /* warm orange */
  background: rgba(255, 159, 28, 0.15);
  border: 1px solid rgba(255, 159, 28, 0.45);
  border-radius: 999px;
  padding: 2px 8px;
  line-height: 1;
}

details > summary:hover .bmDetailsBadge {
  box-shadow: 0 0 0 1px rgba(255, 159, 28, 0.35);
}

/* Visually hide text but keep it in DOM (useful for hidden IDs). */
.bmSrOnly {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
/* ===== Account card: Storage ===== */

#storageSection{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.storage-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:10px;
}

.storage-meta{ min-width: 220px; }

.storage-line{
  color: var(--muted);
  font-size:12px;
}

/* Progress bar container (mirrors credits) */
.storage-bar-wrap{
  width:100%;
  height:18px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--line2);
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
  position: relative;
  isolation: isolate;
}
:root[data-theme="light"] .storage-bar-wrap{
  background: rgba(17,24,39,.06);
}

/* Storage fill */
.storage-bar-fill{
  height:100%;
  width:0%;
  border-radius:999px;
  transition: width 0.25s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
  background: rgba(79,124,255,.55);
}
:root[data-theme="light"] .storage-bar-fill{
  box-shadow: inset 0 0 0 1px rgba(17,24,39,.12);
  background: rgba(47,99,255,.35);
}

/* Label floats over bar */
.storage-bar-label{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  font-weight:700;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  pointer-events:none;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root[data-theme="light"] .storage-bar-label{
  color: rgba(17,24,39,.75);
  text-shadow: none;
}

/* Bottom-left label like Credits */
.storage-label{
  position:absolute;
  left:10px;
  bottom:-20px;
  font-size:11px;
  color: var(--muted);
  white-space:nowrap;
}

/* Give room for the bottom label */
#storageSection .storage-bar-wrap{ margin-bottom: 22px; }

/* Warning states (JS toggles .is-warn / .is-full on .storage-bar-wrap) */
.storage-bar-wrap.is-warn{
  border-color: rgba(245,158,11,.45);
}
.storage-bar-wrap.is-warn .storage-bar-fill{
  background: rgba(245,158,11,.65);
}
.storage-bar-wrap.is-full{
  border-color: rgba(251,113,133,.55);
}
.storage-bar-wrap.is-full .storage-bar-fill{
  background: rgba(251,113,133,.70);
}

/* ===== Account Modal layout ===== */
.account-modal-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
}
@media (max-width: 680px){
  .account-modal-grid{ grid-template-columns: 1fr; }
}

.account-kv{
  border:1px solid var(--line2);
  border-radius: 12px;
  padding:10px 12px;
  background: rgba(0,0,0,.10);
}
:root[data-theme="light"] .account-kv{
  background: rgba(17,24,39,.02);
}

.account-kv .k{
  font-size:11px;
  color: var(--muted);
  letter-spacing:.06em;
  text-transform:uppercase;
}
.account-kv .v{
  margin-top:4px;
  font-weight:700;
  font-size:13px;
  color: var(--text);
}

.account-modal-actions .btn.danger{
  padding: 10px 12px;
}

/* ============================
   Upload Manager Modal (Step 1)
   ============================ */

/* Utility */
.hidden{ display:none !important; }

/* Prevent background scroll when modal is open */
body.modal-open{ overflow:hidden; }

/* Modal shell */
.modal{
  position:fixed;
  inset:0;
  z-index:999;
}

.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
}

:root[data-theme="light"] .modal-backdrop{
  /* In light mode, keep the backdrop strong enough to clearly separate the modal */
  background: rgba(17,24,39,.46);
}

/* Modal card */
.modal-card{
  position:relative;
  width:min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin:14px auto;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--line2);
  border-radius: calc(var(--r) + 6px);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

:root[data-theme="light"] .modal-card{
  /* Light theme modals should be solid and readable (avoid see-through "ghost" UI) */
  background: #ffffff;
  border-color: rgba(17,24,39,.14);
}

/* Header */
.modal-header{
  padding:14px 14px 12px;
  border-bottom:1px solid var(--line3);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  background: rgba(0,0,0,.08);
}

:root[data-theme="light"] .modal-header{
  background: rgba(17,24,39,.03);
}

.modal-title{
  font-weight:800;
  letter-spacing:.2px;
  font-size:14px;
}

/* Body */
.modal-body{
  padding:14px;
  overflow:auto;
}

/* Two-pane layout */
.upload-mgr-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
  align-items:start;
}

@media (max-width: 900px){
  .upload-mgr-grid{ grid-template-columns: 1fr; }
}

.upload-pane{
  border:1px solid var(--line2);
  border-radius: var(--r);
  background: rgba(0,0,0,.10);
  overflow:hidden;
}

:root[data-theme="light"] .upload-pane{
  background: rgba(17,24,39,.02);
}

.upload-pane h3{
  margin:0;
  padding:12px 12px 10px;
  border-bottom:1px solid var(--line);
  font-size:13px;
  letter-spacing:.2px;
  background: rgba(0,0,0,.10);
}

:root[data-theme="light"] .upload-pane h3{
  background: rgba(17,24,39,.02);
}

/* Dropzone */
.dropzone{
  margin:12px;
  padding:14px 12px;
  border-radius: 14px;
  border: 2px dashed rgba(255,255,255,0.25);
  background: linear-gradient(
    rgba(255,255,255,0.08),
    rgba(255,255,255,0.04)
  );
  color: rgba(233,238,255,.85);
  font-size:12px;
  line-height:1.35;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  text-align:center;
  user-select:none;
  min-height: 140px;
}

:root[data-theme="light"] .dropzone{
  border-color: rgba(17,24,39,.18);
  background: rgba(47,99,255,.06);
  color: rgba(17,24,39,.80);
}

.dropzone.dragover{
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .18) inset;
}

:root[data-theme="light"] .dropzone.dragover{
  border-color: rgba(47,99,255,.55);
  background: rgba(47,99,255,.10);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .12) inset;
}

/* Link-style button inside dropzone */
.btn.link{
  padding:0;
  border:none;
  background:transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 8px;
}

.btn.link:hover{ opacity:.9; }
.btn.link:active{ transform: none; }

/* Thumbnails */
.thumb-grid{
  padding:10px;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap:8px;
  align-content: start; /* don't stretch rows vertically */
}

.thumb-empty{
  padding:12px;
  color: var(--muted);
  font-size:12px;
}

.thumb-card{
  border:1px solid var(--line2);
  border-radius: 14px;
  background: rgba(0,0,0,.12);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-width:0;
}

:root[data-theme="light"] .thumb-card{
  background: rgba(17,24,39,.02);
}

.thumb-img{
  display:block;
  width:100%;
  height:72px;          /* fixed thumbnail height */
  object-fit: cover;    /* crop instead of stretching */
  background: rgba(0,0,0,.08);
}

:root[data-theme="light"] .thumb-img{
  background: rgba(17,24,39,.04);
}

.thumb-meta{
  padding:8px 10px 6px;
  font-size:10px;
  color: rgba(233,238,255,.85);
  white-space:nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

:root[data-theme="light"] .thumb-meta{
  color: rgba(17,24,39,.78);
}

.thumb-del{
  margin:0 10px 10px;
  padding:7px 9px;
  font-size:11px;
  border-radius: 12px;
}
/* =========================
   Account Modal Tabs + Lists
   ========================= */

.am-identity{
  display:flex;
  align-items:center;
  gap:12px;
  margin:4px 0 12px 0;
}
.am-avatar{
  width:42px;
  height:42px;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  background: rgba(92, 223, 255, 0.15);
  border: 1px solid rgba(92, 223, 255, 0.35);
}
.am-who{ display:flex; flex-direction:column; gap:2px; }
.am-name{ font-weight:800; font-size:14px; line-height:1.1; }
.am-email{ opacity:.85; font-size:12px; }

.am-tabs{
  display:flex;
  gap:8px;
  padding:10px;
  border-radius:18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  margin: 10px 0 14px 0;
}
.am-tab{
  appearance:none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.16);
  color: rgba(255,255,255,0.88);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
.am-tab:hover{
  border-color: rgba(92, 223, 255, 0.35);
}
.am-tab.is-active{
  background: rgba(92, 223, 255, 0.18);
  border-color: rgba(92, 223, 255, 0.55);
  color: #fff;
}

.am-panel-head{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin: 6px 0 10px 0;
}
.am-panel-title{ font-weight: 900; font-size: 14px; }
.am-panel-sub{ opacity:.8; font-size: 12px; }

.am-list{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.12);
  overflow:hidden;
}

/* Assets split panes (Designs / Templates) */
.am-assets-split{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top: 12px;
}

.am-assets-pane{
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.14);
  overflow:hidden;
}

:root[data-theme="light"] .am-assets-pane{
  background: rgba(17,24,39,.03);
}

.am-assets-pane-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.am-assets-pane-title{ font-weight:900; font-size:12px; letter-spacing:.02em; }
.am-assets-pane-count{ opacity:.85; font-weight:800; font-size:12px; }

.am-assets-pane-b{
  padding: 10px;
  /* independently scrollable */
  max-height: clamp(200px, 32vh, 360px);
  overflow: auto;
}

.am-assets-group{ margin-bottom: 12px; }
.am-assets-group:last-child{ margin-bottom: 0; }

.am-assets-group-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 4px 2px 8px 2px;
}

.am-assets-group-title{ font-weight:800; opacity:.92; }
.am-assets-group-count{ opacity:.75; font-weight:700; }

.am-assets-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.am-asset-tile{
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  background: rgba(0,0,0,0.10);
  padding: 10px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

:root[data-theme="light"] .am-asset-tile{
  background: rgba(255,255,255,0.70);
}

.am-asset-thumb{
  width:100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow:hidden;
  position:relative;
  border: 1px solid rgba(255,255,255,0.10);
  /* Default: subtle dark surface */
  background: rgba(0,0,0,0.18);

  /* Checker pattern (for transparency). Kept subtle so it doesn't fight the artwork. */
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.08) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

:root[data-theme="light"] .am-asset-thumb{
  border-color: rgba(17,24,39,.12);
  background: rgba(17,24,39,.02);
  background-image:
    linear-gradient(45deg, rgba(17,24,39,0.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(17,24,39,0.07) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(17,24,39,0.07) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(17,24,39,0.07) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.am-asset-thumb img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  /* Prefer visibility over crop: designs often need the full bounding box */
  object-fit: contain;
}

.am-asset-thumb-fallback{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  color: var(--muted);
  font-size: 18px;
}

.am-asset-checkwrap{
  position:absolute;
  top:8px;
  right:8px;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(6px);
}

.am-asset-checkwrap input{
  margin:0;
  width: 14px;
  height: 14px;
}

.am-asset-name{
  font-weight:800;
  font-size:12px;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

.am-asset-meta{
  font-size: 11px;
  opacity: .78;
  white-space:nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}

.am-group-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 800;
}
.am-group-count{ opacity:.8; font-weight:700; }

.am-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.am-row:last-child{ border-bottom:none; }

.am-row-main{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}
.am-row-title{
  font-weight: 800;
  font-size: 13px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.am-row-sub{
  opacity: .8;
  font-size: 12px;
}

.am-icon-btn{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}
.am-icon-btn:hover{
  border-color: rgba(255,107,107,0.55);
  background: rgba(255,107,107,0.08);
}


/* Generate Zip Card formatting */

.ext-option.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ext-option.disabled input {
  cursor: not-allowed;
}

.upgrade-hint {
  font-size: 12px;
  opacity: 0.85;
  margin-left: 6px;
  white-space: nowrap;
}

/* -------------------------------------------------------------------------- */
/* Google Drive Picker (folder chooser)                                       */
/*                                                                            */
/* The Google Picker dialog inherits our app's dark-theme foreground colors.  */
/* Because the Picker UI is mostly white, that can make text/icons appear     */
/* "missing" (low contrast). These rules scope a light-UI palette to the      */
/* picker dialog only, without touching the rest of the app.                  */
/* -------------------------------------------------------------------------- */

/* Picker outer dialog and all descendants */
.picker-dialog,
.picker-dialog * {
  color: #111827 !important; /* near-black */
}

/* Keep Picker chrome readable and crisp */
.picker-dialog {
  background: #ffffff !important;
}

/* Restore link affordance inside the Picker */
.picker-dialog a {
  color: #2563eb !important; /* readable blue */
}

/* Form controls inside the Picker */
.picker-dialog input,
.picker-dialog select,
.picker-dialog textarea {
  color: #111827 !important;
}

/* Buttons inside the Picker */
.picker-dialog button,
.picker-dialog [role="button"] {
  color: #111827 !important;
}


/* === Google Drive folder browser (custom modal) === */
.bm-drive-browser-card{
  width:min(820px, 94vw);
  max-width:94vw;
  height:min(680px, 86vh);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* Slightly tighter header for this modal */
.bm-drive-browser-card .modal-header{
  padding:12px 14px;
}

.bm-drive-browser-toolbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
}

.bm-drive-browser-path{
  font-size:13px;
  opacity:.95;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:46vw;
}

.bm-drive-browser-search{
  width:min(320px, 44vw);
  background:var(--panel2);
  border:1px solid var(--line2);
  color:var(--text);
  padding:9px 10px;
  border-radius:12px;
  outline:none;
}
.bm-drive-browser-search:focus{
  border-color: rgba(var(--accent-rgb), .55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18);
}

.bm-drive-browser-msg{
  padding:10px 14px;
  font-size:13px;
  color:var(--muted);
}

.bm-drive-browser-body{
  padding:10px 14px 14px;
  overflow:auto;
  flex:1 1 auto;
}

.bm-drive-browser-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.bm-drive-browser-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border:1px solid var(--line2);
  background:rgba(255,255,255,.03);
  border-radius:12px;
  cursor:pointer;
  transition:transform .06s ease, background .12s ease, border-color .12s ease;
}
.bm-drive-browser-row:hover{
  background: rgba(var(--brand-rgb), .10);
  border-color: rgba(var(--brand-rgb), .28);
}
.bm-drive-browser-row:active{
  transform:scale(.995);
}

.bm-drive-browser-icon{
  width:26px;
  height:26px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  background:rgba(255,255,255,.05);
  border:1px solid var(--line2);
  flex:0 0 auto;
}

.bm-drive-browser-name{
  flex:1 1 auto;
  font-weight:600;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.bm-drive-browser-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}

.bm-drive-browser-footer{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-top:1px solid var(--line);
  background:linear-gradient(0deg, rgba(255,255,255,.03), rgba(255,255,255,0));
}

.bm-drive-browser-selected{
  font-size:13px;
  color:var(--muted);
  max-width:58vw;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Primary button style for the "Choose" / "Select" actions */
.btn.bm-drive-browser-choose,
.btn.bm-drive-browser-select{
  background: var(--brand);
  color: #111827;
  border-color: rgba(var(--brand-rgb), .35);
}
:root[data-theme="light"] .btn.bm-drive-browser-choose,
:root[data-theme="light"] .btn.bm-drive-browser-select{
  color: #111827;
}
.btn.bm-drive-browser-choose:disabled{
  opacity:.55;
  cursor:not-allowed;
}
/* ======================================================================
   Account modal: clearer, less "washed-out" surfaces + thumbnail support
   (Scoped to the Account modal only)
   ====================================================================== */

#accountModal .modal-card{
  background: linear-gradient(180deg, rgba(18,20,26,.92), rgba(12,14,18,.88));
  border-color: var(--line);
}
#accountModal .modal-header{
  background: linear-gradient(180deg, rgba(0,0,0,.16), rgba(0,0,0,.08));
}
#accountModal .modal-body{
  background: transparent;
}

#accountModal .am-tabs{
  background: rgba(0,0,0,.22);
  border-color: rgba(255,255,255,.10);
}
#accountModal .am-list{
  background: rgba(0,0,0,.20);
  border-color: rgba(255,255,255,.12);
}
#accountModal .account-kv{
  background: rgba(0,0,0,.18);
}

/* Thumbnails in Assets list (best-effort: applies to any <img> inside rows) */
#accountModal .am-row{
  align-items:flex-start;
}
#accountModal .am-row img{
  width:38px;
  height:38px;
  border-radius:12px;
  object-fit:cover;
  flex:0 0 auto;
  background: rgba(0,0,0,.20);
  border:1px solid var(--line2);
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  margin-top:1px;
}
#accountModal .am-row img[hidden],
#accountModal .am-row img[style*="display: none"]{
  display:none !important;
}

/* Make row text block line up nicely next to thumb */
#accountModal .am-row-main{
  padding-top:1px;
}

/* Light mode: keep the same "solid card" feel without going gray-on-gray */
:root[data-theme="light"] #accountModal .modal-card{
  background: #ffffff;
  border-color: rgba(17,24,39,.14);
}
:root[data-theme="light"] #accountModal .modal-header{
  background: rgba(17,24,39,.03);
}
:root[data-theme="light"] #accountModal .am-tabs{
  background: rgba(17,24,39,.03);
  border-color: rgba(17,24,39,.10);
}
:root[data-theme="light"] #accountModal .am-tab{
  background: rgba(255,255,255,.92);
  border-color: rgba(17,24,39,.14);
  color: rgba(17,24,39,.88);
}
:root[data-theme="light"] #accountModal .am-tab:hover{
  border-color: rgba(var(--accent-rgb), .35);
}
:root[data-theme="light"] #accountModal .am-tab.is-active{
  background: rgba(var(--accent-rgb), .10);
  border-color: rgba(var(--accent-rgb), .28);
  color: rgba(17,24,39,.92);
}
:root[data-theme="light"] #accountModal .am-list{
  background: rgba(17,24,39,.02);
  border-color: rgba(17,24,39,.10);
}
:root[data-theme="light"] #accountModal .account-kv{
  background: rgba(17,24,39,.02);
}
:root[data-theme="light"] #accountModal .am-row img{
  background: rgba(17,24,39,.02);
  border-color: rgba(17,24,39,.12);
  box-shadow: 0 6px 16px rgba(17,24,39,.10);
}


/* Account modal assets thumbnails */
#accountModal .am-thumb{
  width:46px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding-right:10px;
  flex: 0 0 auto;
}
#accountModal .am-thumb img{
  width:38px;
  height:38px;
  border-radius:10px;
  object-fit:cover;
  border:1px solid rgba(255,255,255,.12);
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  background: rgba(255,255,255,.04);
}
:root[data-theme="light"] #accountModal .am-thumb img{
  border-color: rgba(17,24,39,.14);
  box-shadow: 0 10px 20px rgba(17,24,39,.10);
  background: rgba(17,24,39,.03);
}



/* --- Stage 9: Recent Runs panel --- */
.bmRunsPanel { margin-top: 10px; }
.bmRunRow {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
  background: rgba(255,255,255,.03);
}
.bmRunTop { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.bmRunTitle { display:flex; align-items:center; gap:10px; min-width:0; flex-wrap:wrap; }
.bmRunId { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; opacity: .9; }
.bmRunCounts { font-size: 12px; opacity: .85; }
.bmRunPills { margin-top: 8px; display:flex; flex-wrap:wrap; gap:8px; }

.bmBadge { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); text-transform: lowercase; }
.bmBadge-queued, .bmBadge-running { background: rgba(79,124,255,.12); border-color: rgba(79,124,255,.35); }
.bmBadge-done, .bmBadge-succeeded, .bmBadge-success { background: rgba(70,200,120,.12); border-color: rgba(70,200,120,.35); }
.bmBadge-failed, .bmBadge-error { background: rgba(255,90,90,.12); border-color: rgba(255,90,90,.35); }

.bmPill { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.14); opacity: .95; }
.bmPill-queued, .bmPill-running { background: rgba(79,124,255,.10); border-color: rgba(79,124,255,.28); }
.bmPill-succeeded, .bmPill-success, .bmPill-done { background: rgba(70,200,120,.10); border-color: rgba(70,200,120,.28); }
.bmPill-failed, .bmPill-error { background: rgba(255,90,90,.10); border-color: rgba(255,90,90,.28); }
.bmPill-expired { background: rgba(255,180,60,.10); border-color: rgba(255,180,60,.28); }
.bmPill-muted { opacity: .7; }

.bmBtnMini {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  cursor: pointer;
}
.bmBtnMini:hover { background: rgba(255,255,255,.10); }
.bmBtnMini:disabled { opacity: .55; cursor: not-allowed; }

/* Account modal: History tab layout (avoid horizontal scroll) */
.amHistHead,
.amHistRow {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) 100px 90px 60px minmax(120px, 1fr);
  gap: 10px;
  align-items: start;
}

.amHistHead {
  padding: 8px 0 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  opacity: .9;
  font-size: 11px;
  font-weight: 700;
}

.amHistRow {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.amHistDate {
  opacity: .9;
}

.amHistProj {
  min-width: 0; /* allow ellipsis */
}

.amHistProjTitle {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.amHistCell {
  opacity: .95;
}

.amHistNum {
  text-align: right;
  font-weight: 700;
  opacity: .95;
}

.amHistActions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 720px) {
  .amHistHead,
  .amHistRow {
    grid-template-columns: 110px minmax(140px, 1fr) 90px 80px 50px minmax(110px, 1fr);
    gap: 8px;
  }
}


/* --- Shopify Tools Modal (Step 4) ---------------------------------------- */
.bmModalOverlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:9999;
}
.bmModalOverlay.isOpen{ display:flex; }

.bmModal{
  width:min(920px, 100%);
  max-height:85vh;
  overflow:auto;
  border-radius:14px;
  background:var(--panel, #111827);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 18px 60px rgba(0,0,0,.45);
}
.bmModalHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:16px 16px 10px 16px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.bmModalTitle{ font-size:18px; font-weight:700; margin:0; }
.bmModalSubtitle{ margin:6px 0 0 0; opacity:.85; font-size:13px; }
.bmModalClose{
  appearance:none;
  border:1px solid rgba(255,255,255,.18);
  background:transparent;
  color:inherit;
  border-radius:10px;
  padding:8px 10px;
  cursor:pointer;
}
.bmModalBody{ padding:14px 16px 16px 16px; }
.bmModalGrid{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
}
@media (min-width: 860px){
  .bmModalGrid{ grid-template-columns: 1.15fr .85fr; }
}
.bmModalCard{
  border:1px solid rgba(255,255,255,.08);
  border-radius:14px;
  padding:12px;
  background:rgba(255,255,255,.03);
}
.bmModalCard h4{ margin:0 0 8px 0; font-size:14px; }
.bmModalCard .help{ margin-top:6px; }
.bmModalActions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.bmModalStatus{ font-size:12px; opacity:.85; }
.bmModalDivider{ height:1px; background:rgba(255,255,255,.08); margin:10px 0; }

.bmFileRow{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.bmFileRow input[type=file]{
  max-width: 320px;
}

/* Shopify Tools: fix <select>/<option> contrast in dark modal (Windows/Chrome) */
.bmModal select{
  background: rgba(0,0,0,.22);
  color: var(--text);
  border-color: rgba(255,255,255,.14);
}
.bmModal select option{
  background: #0b1020; /* solid so option text isn't washed out */
  color: var(--text);
}

/* Light mode: keep options readable */
:root[data-theme="light"] .bmModal select{
  background: rgba(255,255,255,.92);
  color: rgba(17,24,39,.92);
  border-color: rgba(17,24,39,.18);
}
:root[data-theme="light"] .bmModal select option{
  background: #ffffff;
  color: rgba(17,24,39,.92);
}

/* --- Shopify Tools Premium Layout ---------------------------------------- */
.bmShopifyBody{ display:flex; flex-direction:column; gap:14px; }

.bmShopifyCard{
  border:1px solid rgba(255,255,255,.10);
  border-radius:16px;
  background:rgba(255,255,255,.03);
  padding:14px;
}

.bmShopifyContextRow{ display:flex; flex-direction:column; gap:12px; }
@media (min-width: 860px){
  .bmShopifyContextRow{ flex-direction:row; align-items:flex-start; justify-content:space-between; }
}
.bmShopifyContextBlock{ flex:1; min-width: 260px; }
.bmShopifyContextLabel{ font-size:12px; opacity:.75; margin-bottom:6px; }
.bmShopifyContextValue{ font-size:15px; font-weight:700; letter-spacing:.2px; }
.bmShopifyContextControls{ display:flex; gap:10px; align-items:center; }
.bmShopifyContextHint{ margin-top:10px; font-size:12px; opacity:.8; }

.bmShopifyStepHeader{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.bmShopifyStepTitle{ display:flex; align-items:baseline; gap:10px; }
.bmShopifyStepNo{
  font-size:12px;
  font-weight:700;
  letter-spacing:.3px;
  padding:2px 8px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.10);
}
.bmShopifyStepName{ font-size:15px; font-weight:800; }
.bmShopifyStepStatus{ display:flex; align-items:center; justify-content:flex-end; min-height:24px; }
.bmShopifyStatusRow{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
.bmShopifyStepHelp{ margin-top:8px; font-size:12px; opacity:.82; }
.bmShopifyStepControls{ margin-top:12px; }

.bmShopifyStepSub{ margin-top:8px; }

.bmFileInputHidden{ display:none; }
.bmFilePicker{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.bmFileName{ font-size:12px; opacity:.82; }

.bmShopifyPill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.16);
  opacity:.95;
}

.bmShopifyInline{ font-size:12px; opacity:.85; margin-left:10px; }

.bmShopifyExportGrid{ display:flex; flex-direction:column; gap:12px; }
.bmShopifyExportRow{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.bmShopifyExportLabel{ font-size:12px; opacity:.78; min-width: 92px; }

.bmShopifyStickyActions{
  position: sticky;
  bottom: 0;
  z-index: 5;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  padding:12px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:16px;
  background: rgba(0,0,0,.22);
  backdrop-filter: blur(6px);
}
:root[data-theme="light"] .bmShopifyStickyActions{
  background: rgba(255,255,255,.70);
  border-color: rgba(17,24,39,.12);
}
.bmShopifyStickyLeft{ display:flex; flex-direction:column; gap:6px; min-width: 240px; }
.bmShopifyStickyRight{ display:flex; gap:10px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }

.bmShopifyReadyRow{ display:flex; gap:10px; flex-wrap:wrap; }
.bmShopifyReadyItem{ font-size:12px; opacity:.70; }
.bmShopifyReadyItem.ok{ opacity:.95; }

.bmShopifyTips{ border:1px solid rgba(255,255,255,.10); border-radius:14px; background:rgba(255,255,255,.02); padding:10px 12px; }
.bmShopifyTipsSummary{ cursor:pointer; font-weight:700; font-size:13px; }
.bmShopifyTipsBody{ margin-top:8px; font-size:12px; opacity:.85; }

/* Shopify diagnostics preview (premium layout) */
.bmDiagPanel{ border:1px solid rgba(255,255,255,.10); border-radius:16px; background:rgba(255,255,255,.02); padding:12px 12px 10px; }
.bmDiagTitle{ font-weight:800; font-size:13px; margin-bottom:10px; }
.bmDiagSummary{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.bmDiagSplit{ display:flex; flex-direction:column; gap:12px; }
@media (min-width: 780px){ .bmDiagSplit{ flex-direction:row; } }
.bmDiagCol{ flex:1; min-width: 240px; }
.bmDiagH{ font-weight:800; font-size:12px; opacity:.9; margin:10px 0 8px; }
.bmDiagList{ margin:0; padding-left:18px; font-size:12px; opacity:.9; }
.bmDiagOk{ list-style:none; padding-left:0; opacity:.75; }

.bmDiagTable{ border:1px solid rgba(255,255,255,.08); border-radius:14px; overflow:hidden; }
.bmDiagTableHeader, .bmDiagTableRow{ display:grid; grid-template-columns: 1.2fr .9fr .9fr .6fr 1.6fr; gap:10px; padding:10px 12px; }
.bmDiagTableHeader{ font-size:11px; font-weight:800; opacity:.85; background:rgba(255,255,255,.04); }
.bmDiagTableRow{ font-size:12px; border-top:1px solid rgba(255,255,255,.06); }
.bmDiagTableEmpty{ padding:10px 12px; font-size:12px; opacity:.75; }

.bmDiagTag{ display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:800; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.04); }
.bmDiagTag.ok{ border-color: rgba(62, 224, 155, .35); background: rgba(62, 224, 155, .10); }
.bmDiagTag.warn{ border-color: rgba(255, 203, 74, .35); background: rgba(255, 203, 74, .10); }
.bmDiagTag.skip{ border-color: rgba(255, 104, 104, .30); background: rgba(255, 104, 104, .08); }
.bmDiagUrl{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; opacity:.85; }
/* --- BatchMock entitlements hints (credits / locked features) --- */
.bm-entitlement-hint{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.95;
}
.bm-entitlement-hint.is-info{
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}
.bm-entitlement-hint.is-warn{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
}
.bm-entitlement-hint a{
  text-decoration: underline;
}
