/* Remove Background editor */
.bge-hero.page-hero { padding-top: 1.25rem; padding-bottom: 0.25rem; }
.bge-hero .pill { display: none; }
.bge-hero h1 { margin: 0.35rem 0 0.25rem; }
.bge-hero .lead { margin: 0; font-size: 0.98rem; }
.bge-section { margin-top: 0.5rem; margin-bottom: 2rem; }
.bge {
  --bge-panel: var(--surface-solid);
  --bge-line: var(--border);
  --bge-soft: rgba(127, 127, 127, 0.1);
  --bge-accent: #2563eb;
  position: relative;
  color: var(--text);
}
.bge [hidden] { display: none !important; }
.bge[data-state="empty"] .bge-editor { display: none; }
.bge[data-state="editor"] .bge-empty { display: none; }

/* Empty state */
.bge-empty {
  border: 2px dashed color-mix(in srgb, var(--brand) 45%, transparent);
  border-radius: 24px;
  background: var(--surface);
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  transition: border-color 0.2s, background 0.2s;
}
.bge.is-drag .bge-empty,
.bge.is-drag .bge-stage { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.bge-empty-card { text-align: center; max-width: 460px; }
.bge-empty-icon {
  width: 72px; height: 72px; margin: 0 auto 1.1rem; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: 0 12px 30px var(--brand-glow);
}
.bge-upload-btn { font-size: 1.05rem; padding: 0.9rem 2.2rem; justify-content: center; text-align: center; }
.bge-empty-sub { margin: 0.9rem 0 0.3rem; color: var(--text); font-weight: 550; }
.bge-empty-note { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Toolbar */
.bge-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  background: var(--bge-panel); border: 1px solid var(--bge-line); border-radius: 999px;
  padding: 0.4rem 0.45rem 0.4rem 0.6rem; box-shadow: var(--shadow); margin-bottom: 1rem;
  position: sticky; top: 72px; z-index: 20;
}
.bge-tabs, .bge-actions { display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.bge-tab {
  display: inline-flex; align-items: center; gap: 0.45rem; border: 0; background: none; color: var(--text);
  font: inherit; font-weight: 550; font-size: 0.92rem; padding: 0.5rem 0.8rem; border-radius: 999px; cursor: pointer;
}
.bge-tab svg, .bge-icon svg, .bge-dl-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bge-tab:hover { background: var(--bge-soft); }
.bge-tab.is-on { background: color-mix(in srgb, var(--bge-accent) 14%, transparent); color: var(--bge-accent); }
html[data-theme="dark"] .bge-tab.is-on { color: #93b4ff; }
.bge-icon {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 999px; border: 0;
  background: none; color: var(--text); cursor: pointer; font: inherit; font-size: 1.1rem;
}
.bge-icon:hover:not(:disabled) { background: var(--bge-soft); }
.bge-icon:disabled { opacity: 0.35; cursor: default; }
.bge-icon.sm { width: 32px; height: 32px; font-size: 1rem; }
.bge-dl { position: relative; margin-left: 0.3rem; }
.bge-dl-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; border: 0; cursor: pointer; font: inherit; font-weight: 650;
  background: var(--bge-accent); color: #fff; padding: 0.62rem 1.1rem 0.62rem 1.3rem; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}
.bge-dl-btn:hover { filter: brightness(1.08); }
.bge-dl-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 290px; z-index: 30;
  background: var(--bge-panel); border: 1px solid var(--bge-line); border-radius: 16px; padding: 0.4rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.bge-dl-menu button {
  display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; width: 100%; text-align: left; border: 0;
  background: none; color: var(--text); font: inherit; padding: 0.65rem 0.75rem; border-radius: 10px; cursor: pointer;
}
.bge-dl-menu button:hover { background: var(--bge-soft); }
.bge-dl-menu b { font-size: 0.95rem; }
.bge-dl-size { color: var(--muted); font-size: 0.85rem; justify-self: end; }
.bge-dl-menu small { grid-column: 1 / -1; color: var(--muted); font-size: 0.8rem; }

/* Body */
.bge-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.bge.has-panel .bge-body { grid-template-columns: minmax(0, 1fr) 320px; }
.bge-stage-wrap { min-width: 0; }
.bge-stage {
  position: relative; height: min(68vh, 720px); min-height: 320px; overflow: auto; border-radius: 22px;
  border: 1px solid var(--bge-line); background: var(--surface);
  display: grid; place-items: center; padding: 12px;
}
.bge-stage.is-zoomed { place-items: start; }
.bge-canvas-box {
  position: relative; border-radius: 12px; overflow: hidden; margin: auto;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%), linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%), linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}
.bge-canvas-box canvas { display: block; width: 100%; height: 100%; }
.bge-stage.is-brush canvas { cursor: none; touch-action: none; }
.bge-brush {
  position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  background: rgba(239, 68, 68, 0.22);
}
.bge-brush.restore { background: rgba(34, 197, 94, 0.22); }

.bge-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.28); backdrop-filter: blur(2px); border-radius: 22px; overflow: hidden; }
.bge-scan {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%;
  background: linear-gradient(180deg, transparent, rgba(147, 180, 255, 0.35), transparent);
  animation: bge-scan 1.6s ease-in-out infinite;
}
@keyframes bge-scan { to { top: 100%; } }
.bge-busy-card {
  position: relative; display: grid; justify-items: center; gap: 0.6rem; background: var(--bge-panel); color: var(--text);
  border: 1px solid var(--bge-line); border-radius: 16px; padding: 1rem 1.4rem; min-width: 230px; font-weight: 600;
  box-shadow: var(--shadow);
}
.bge-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bge-soft); border-top-color: var(--bge-accent); animation: bge-spin 0.8s linear infinite; }
@keyframes bge-spin { to { transform: rotate(360deg); } }
.bge-busy-bar { width: 100%; height: 6px; background: var(--bge-soft); border-radius: 99px; overflow: hidden; }
.bge-busy-bar[hidden] { display: none; }
#bge-busy-fill { height: 100%; width: 0; background: var(--bge-accent); transition: width 0.2s; }
.bge-error { position: absolute; inset: auto 1rem 1rem; background: var(--bge-panel); border: 1px solid rgba(239, 68, 68, 0.45); border-radius: 14px; padding: 0.9rem 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.bge-error p { margin: 0; color: #ef4444; font-weight: 600; }

.bge-zoom { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.55rem; color: var(--muted); font-size: 0.85rem; }
.bge-zoom-val { border: 0; background: var(--bge-soft); color: var(--text); font: inherit; font-weight: 600; border-radius: 8px; padding: 0.3rem 0.6rem; cursor: pointer; min-width: 58px; }
.bge-size { margin-left: auto; }

/* Panel */
.bge-panel {
  background: var(--bge-panel); border: 1px solid var(--bge-line); border-radius: 20px; padding: 1rem 1.1rem 1.2rem;
  box-shadow: var(--shadow); max-height: min(76vh, 800px); overflow: auto; position: sticky; top: 140px;
}
.bge-panel[hidden] { display: none; }
.bge-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.bge-panel-head h3 { margin: 0; font-size: 1.05rem; }
.bge-pane[hidden] { display: none; }
.bge-pane h4 { margin: 1rem 0 0.5rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.bge-pane h4:first-child { margin-top: 0.2rem; }
.bge-hint { color: var(--muted); font-size: 0.83rem; margin: 0.4rem 0 0.8rem; }
.bge-range { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.5rem; margin: 0.75rem 0; font-size: 0.9rem; font-weight: 550; }
.bge-range[hidden] { display: none; }
.bge-range output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.bge-range input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--bge-accent); }
.bge-check, .bge-switch { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.9rem; font-weight: 550; margin: 0.7rem 0; cursor: pointer; }
.bge-check input, .bge-switch input { width: 18px; height: 18px; accent-color: var(--bge-accent); margin-top: 0.1rem; flex: none; }
.bge-field { display: grid; gap: 0.3rem; font-size: 0.9rem; font-weight: 550; margin: 0.75rem 0; }
.bge-field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 0.6rem; }
.bge-field select, .bge-field input[type="number"] {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--bge-line); border-radius: 10px; padding: 0.5rem 0.6rem; font: inherit;
}
.bge-field input[type="color"] { width: 46px; height: 32px; border: 1px solid var(--bge-line); border-radius: 8px; background: none; padding: 2px; cursor: pointer; }
.bge-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bge-soft); border-radius: 12px; padding: 4px; gap: 4px; margin: 0.4rem 0 0.2rem; }
.bge-seg[hidden] { display: none; }
.bge-seg button { border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; padding: 0.5rem; border-radius: 9px; cursor: pointer; }
.bge-seg button.is-on { background: var(--bge-panel); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); color: var(--bge-accent); }
.bge-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0; }
.bge-btn { border: 0; background: var(--bge-accent); color: #fff; font: inherit; font-weight: 600; font-size: 0.88rem; padding: 0.55rem 0.9rem; border-radius: 10px; cursor: pointer; }
.bge-btn.ghost { background: var(--bge-soft); color: var(--text); }
.bge-btn[hidden] { display: none; }
.bge-btn:hover { filter: brightness(1.07); }
.bge-effect { border: 1px solid var(--bge-line); border-radius: 14px; padding: 0.3rem 0.8rem; margin-bottom: 0.7rem; }
.bge-effect .bge-switch { font-weight: 650; }
.bge-effect:has(.bge-switch input:not(:checked)) > :not(.bge-switch) { opacity: 0.5; }

.bge-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 0.45rem; }
.bge-sw {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--bge-line); background: var(--c); cursor: pointer; padding: 0; position: relative;
}
.bge-sw.is-on { outline: 2px solid var(--bge-accent); outline-offset: 2px; }
.bge-sw-none {
  background-color: #fff;
  background-image: linear-gradient(45deg, #d1d5db 25%, transparent 25%), linear-gradient(-45deg, #d1d5db 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d1d5db 75%), linear-gradient(-45deg, transparent 75%, #d1d5db 75%);
  background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}
.bge-sw-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; display: block; }
.bge-sw-custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.bge-bg-thumb { margin-top: 0.4rem; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: center / cover no-repeat; border: 1px solid var(--bge-line); cursor: pointer; }
.bge-bg-thumb.is-on { outline: 2px solid var(--bge-accent); outline-offset: 2px; }
.bge-bg-thumb[hidden] { display: none; }

.bge-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45rem; }
.bge-presets button {
  display: grid; justify-items: center; gap: 0.3rem; border: 1px solid var(--bge-line); background: none; color: var(--text);
  font: inherit; font-size: 0.72rem; font-weight: 600; padding: 0.5rem 0.2rem; border-radius: 12px; cursor: pointer; line-height: 1.2; text-align: center;
}
.bge-presets button.is-on { border-color: var(--bge-accent); background: color-mix(in srgb, var(--bge-accent) 10%, transparent); color: var(--bge-accent); }
.bge-presets .r { display: block; height: 22px; aspect-ratio: var(--w) / var(--h); max-width: 34px; border: 2px solid currentColor; border-radius: 4px; }
.bge-presets .r.crop { aspect-ratio: 1; border-style: dashed; }
.bge-presets .r.custom { aspect-ratio: 1.3; border-style: dotted; }
.bge-custom { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.bge-custom[hidden] { display: none; }
.bge-custom .bge-field { margin: 0; }

/* Strip */
.bge-strip { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.bge-add {
  width: 58px; height: 58px; border-radius: 14px; border: 1px dashed var(--bge-line); background: var(--bge-soft); color: var(--text);
  font-size: 1.6rem; cursor: pointer; flex: none;
}
.bge-add:hover { border-color: var(--brand); }
.bge-thumbs { display: flex; gap: 0.55rem; overflow-x: auto; max-width: min(100%, 820px); padding: 4px; }
.bge-thumb {
  position: relative; width: 58px; height: 58px; flex: none; border-radius: 14px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; outline: none;
  background-color: #fff;
  background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%), linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%), linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}
.bge-thumb.is-on { border-color: var(--bge-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bge-accent) 30%, transparent); }
.bge-thumb:focus-visible { border-color: var(--brand); }
.bge-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bge-thumb-spin { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5); border-top-color: var(--bge-accent); animation: bge-spin 0.8s linear infinite; }
.bge-thumb-err { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(239, 68, 68, 0.75); font-weight: 800; }
.bge-thumb.is-review { border-color: #d97706; }
.bge-thumb-review {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0.12rem 0.15rem;
  background: rgba(180, 83, 9, 0.92); color: #fff; font-size: 0.48rem; font-weight: 800;
  letter-spacing: -0.02em; text-align: center; line-height: 1.1;
}
.bge-thumb-x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 0.65rem; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.bge-thumb:hover .bge-thumb-x, .bge-thumb.is-on .bge-thumb-x, .bge-thumb:focus-within .bge-thumb-x { opacity: 1; }
.bge-clear { border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
.bge-local-note { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 0.5rem 0 0; }

@media (max-width: 980px) {
  .bge.has-panel .bge-body { grid-template-columns: minmax(0, 1fr); }
  .bge-panel { position: static; max-height: none; }
  .bge-toolbar { border-radius: 20px; top: 64px; }
}
.bge-back, .bge-grab { display: none; }
.bge-touch-only { display: none; }
@media (pointer: coarse) {
  .bge-touch-only { display: block; }
  .bge-fine-only { display: none; }
}
.bge-resume {
  display: inline-flex; align-items: center; gap: 0.4rem; margin: 0.8rem auto 0; border: 1px solid var(--bge-line);
  background: var(--bge-panel); color: var(--text); font: inherit; font-weight: 650; padding: 0.7rem 1.4rem;
  border-radius: 999px; cursor: pointer; box-shadow: var(--shadow);
}
.bge-empty-card > .bge-resume { display: flex; }
.bge-empty-card > .bge-resume[hidden] { display: none; }

@media (max-width: 760px) {
  .bge-hero.page-hero { padding-top: 0.9rem; }
  .bge-hero .lead { font-size: 0.9rem; }
  .bge-section { margin-top: 0.25rem; }
  .bge-empty { min-height: 58vh; min-height: 58dvh; border-radius: 22px; padding: 1.5rem 1rem; }
  .bge-upload-btn { width: 100%; max-width: 320px; padding: 1rem 1.5rem; font-size: 1.08rem; }
  .bge-empty-card > .bge-resume { width: 100%; max-width: 320px; justify-content: center; }
}

/* ── App mode (phones): full-screen editor ─────────────────────────── */
html.bge-app-open, html.bge-app-open body { overflow: hidden !important; overscroll-behavior: none; }
html.bge-app-open .mobile-tabbar,
html.bge-app-open .chat-fab,
html.bge-app-open .chat-panel { display: none !important; }

.bge.is-app {
  position: fixed; inset: 0; z-index: 10000; height: 100vh; height: 100dvh;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.bge.is-app button { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.bge.is-app .bge-editor {
  display: flex; flex-direction: column; height: 100%;
  padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.bge.is-app .bge-toolbar, .bge.is-app .bge-body { display: contents; }

/* Top bar */
.bge.is-app .bge-actions {
  order: 1; flex: none; display: flex; flex-wrap: nowrap; align-items: center; gap: 0.15rem;
  padding: 0.45rem 0.6rem; background: var(--bge-panel); border-bottom: 1px solid var(--bge-line);
}
.bge.is-app .bge-back { display: inline-grid; margin-right: auto; }
.bge.is-app .bge-back svg { width: 24px; height: 24px; stroke-width: 2.2; }
.bge.is-app .bge-icon { width: 42px; height: 42px; }
.bge.is-app .bge-dl { margin-left: 0.35rem; }
.bge.is-app .bge-dl-btn { padding: 0.6rem 0.9rem 0.6rem 1.05rem; font-size: 0.92rem; }

/* Canvas */
.bge.is-app .bge-stage-wrap { order: 2; flex: 1 1 auto; min-height: 0; position: relative; display: flex; }
.bge.is-app .bge-stage {
  flex: 1; height: auto; min-height: 0; border: 0; border-radius: 0; padding: 8px;
  background: color-mix(in srgb, var(--bg) 70%, var(--bge-soft));
}
.bge.is-app .bge-busy { border-radius: 0; }
.bge.is-app .bge-busy-card { min-width: 0; width: min(280px, 80vw); }
.bge.is-app .bge-error { inset: auto 0.75rem 0.75rem; }
.bge.is-app .bge-canvas-box { border-radius: 6px; }
.bge.is-app .bge-stage { touch-action: none; }
.bge.is-app .bge-zoom {
  position: absolute; left: 0.5rem; bottom: 0.5rem; margin: 0; padding: 0.1rem; gap: 0;
  background: color-mix(in srgb, var(--bge-panel) 88%, transparent); border: 1px solid var(--bge-line); border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); backdrop-filter: blur(6px); font-size: 0.78rem;
}
.bge.is-app.has-panel .bge-zoom { display: none; }
.bge.is-app .bge-zoom .bge-icon.sm { width: 30px; height: 30px; font-size: 0.95rem; }
.bge.is-app .bge-zoom-val { min-width: 44px; background: none; padding: 0.2rem; font-size: 0.78rem; }
.bge.is-app .bge-size { display: none; }

/* Bottom sheet */
.bge.is-app .bge-panel {
  order: 3; flex: none; position: relative; top: auto; max-height: 44vh; max-height: 44dvh; overflow-y: auto;
  overscroll-behavior: contain; border: 0; border-top: 1px solid var(--bge-line); border-radius: 22px 22px 0 0;
  margin-top: -14px; padding: 0.35rem 1rem 0.8rem; box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.14);
  animation: bge-sheet 0.22s ease-out;
}
@keyframes bge-sheet { from { transform: translateY(40px); opacity: 0; } }
.bge.is-app .bge-grab { display: block; width: 44px; height: 5px; border-radius: 99px; background: var(--bge-line); margin: 0.2rem auto 0.5rem; cursor: pointer; }
.bge.is-app .bge-grab::before { content: ""; display: block; height: 24px; margin: -10px -40px 0; }
.bge.is-app .bge-panel-head { position: sticky; top: -0.35rem; z-index: 1; background: var(--bge-panel); margin: 0 -1rem 0.3rem; padding: 0 1rem 0.3rem; }
.bge.is-app .bge-range { margin: 0.55rem 0; }
.bge.is-app .bge-range input[type="range"] { height: 28px; }
.bge.is-app .bge-check input, .bge.is-app .bge-switch input { width: 22px; height: 22px; }
.bge.is-app .bge-swatches { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 0.5rem; }
.bge.is-app .bge-presets { grid-template-columns: repeat(4, 1fr); }
.bge.is-app .bge-presets button { padding: 0.55rem 0.15rem; }
.bge.is-app .bge-btn { padding: 0.7rem 1rem; }
.bge.is-app .bge-field select, .bge.is-app .bge-field input[type="number"] { font-size: 16px; padding: 0.6rem; }

/* Thumbnail strip */
.bge.is-app .bge-strip {
  order: 4; flex: none; flex-wrap: nowrap; justify-content: flex-start; gap: 0.5rem; margin: 0;
  padding: 0.45rem 0.6rem; background: var(--bge-panel); border-top: 1px solid var(--bge-line);
}
.bge.is-app.has-panel .bge-strip { display: none; }
.bge.is-app .bge-add, .bge.is-app .bge-thumb { width: 48px; height: 48px; border-radius: 12px; }
.bge.is-app .bge-add { font-size: 1.4rem; }
.bge.is-app .bge-thumbs { flex: 1; min-width: 0; max-width: none; padding: 3px; scrollbar-width: none; }
.bge.is-app .bge-thumbs::-webkit-scrollbar { display: none; }
.bge.is-app .bge-thumb-x { opacity: 1; width: 18px; height: 18px; }
.bge.is-app .bge-thumb:not(.is-on) .bge-thumb-x { display: none; }
.bge.is-app .bge-clear { flex: none; font-size: 0.8rem; }
.bge.is-app .bge-local-note { display: none; }

/* M3A: Preview-first ready dock (Download before opening Pro tabs) */
.bge-ready {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.55rem;
  margin: 0.55rem 0 0; padding: 0.7rem 0.85rem; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--bge-accent, var(--brand)) 35%, var(--bge-line, var(--border)));
  background: color-mix(in srgb, var(--bge-accent, var(--brand)) 10%, var(--bge-panel, var(--surface)));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.bge-ready[hidden] { display: none !important; }
.bge-ready-text { margin: 0; flex: 1 1 12rem; font-size: 0.88rem; line-height: 1.4; color: var(--text); }
.bge-ready.is-review {
  border-color: color-mix(in srgb, #d97706 45%, var(--bge-line, var(--border)));
  background: color-mix(in srgb, #d97706 14%, var(--bge-panel, var(--surface)));
}
.bge-ready-dl { min-height: 44px; padding: 0.55rem 1.1rem; font-weight: 700; }
.bge-continue { flex: 1 1 100%; margin-top: 0.35rem; }
.bge-continue-note { margin: 0 0 0.4rem; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.bge-continue-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bge-continue-actions .bge-btn { font-size: 0.8rem; padding: 0.45rem 0.7rem; }
.bge-product-quick { flex: 1 1 100%; margin-top: 0.35rem; }
.bge-product-quick[hidden] { display: none !important; }
.bge-mode-switch { display: inline-flex; gap: 0.25rem; margin-bottom: 0.4rem; }
.bge-mode {
  min-height: 40px; padding: 0.4rem 0.85rem; border-radius: 999px; border: 1px solid var(--bge-line, var(--border));
  background: transparent; color: var(--text); font-weight: 600; font-size: 0.82rem; cursor: pointer;
}
.bge-mode.is-on {
  background: color-mix(in srgb, var(--bge-accent, var(--brand)) 18%, transparent);
  border-color: color-mix(in srgb, var(--bge-accent, var(--brand)) 45%, var(--bge-line, var(--border)));
}
.bge-studio-label { margin: 0.15rem 0 0.35rem; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.bge-studio-bgs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.45rem; }
.bge-studio-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 40px; padding: 0.3rem 0.55rem;
  border-radius: 12px; border: 1px solid var(--bge-line, var(--border)); background: var(--bge-panel, var(--surface));
  color: var(--text); font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.bge-studio-chip.is-on {
  border-color: color-mix(in srgb, var(--bge-accent, var(--brand)) 50%, var(--bge-line, var(--border)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bge-accent, var(--brand)) 35%, transparent);
}
.bge-studio-chip i {
  width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12);
  background: var(--c, #fff); display: inline-block; flex: none;
}
.bge-studio-chip i.grad { background: var(--c); }
.bge-studio-chip i.checker {
  background:
    linear-gradient(45deg, #ccc 25%, transparent 25%) 0 0 / 8px 8px,
    linear-gradient(-45deg, #ccc 25%, transparent 25%) 0 4px / 8px 8px,
    linear-gradient(45deg, transparent 75%, #ccc 75%) 4px -4px / 8px 8px,
    linear-gradient(-45deg, transparent 75%, #ccc 75%) -4px 0 / 8px 8px,
    #fff;
}
.bge-studio-chip i.upload {
  background: transparent; border-style: dashed;
  position: relative;
}
.bge-studio-chip i.upload::before { content: "+"; display: block; text-align: center; line-height: 16px; font-weight: 700; color: var(--muted); }
.bge-brand-row {
  display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--muted);
}
.bge-brand-row[hidden] { display: none !important; }
.bge-brand-row input[type="color"] { width: 40px; height: 36px; padding: 0; border: 1px solid var(--bge-line, var(--border)); border-radius: 8px; background: transparent; }
.bge-quick-compose { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 0.75rem; margin: 0 0 0.45rem; }
.bge-range.tight { margin: 0; font-size: 0.78rem; }
.bge-range.tight output { font-variant-numeric: tabular-nums; }
.bge-quick-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bge-quick-actions .bge-btn { font-size: 0.8rem; padding: 0.45rem 0.7rem; min-height: 40px; }
.bge.bge-product-quick-mode .bge-tabs { opacity: 0.92; }

/* P9C1 batch factory */
.bge-batch {
  margin: 0.75rem 0 0.35rem; padding: 0.75rem 0.85rem; border: 1px solid var(--bge-line, var(--border));
  border-radius: 14px; background: color-mix(in srgb, var(--bge-panel, var(--surface)) 92%, transparent);
}
.bge-batch[hidden] { display: none !important; }
.bge-batch-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; }
.bge-batch-head strong { font-size: 0.9rem; }
.bge-batch-sel { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bge-batch-label { margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.bge-batch-bar {
  height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--bge-line, var(--border)) 70%, transparent);
  overflow: hidden; margin-bottom: 0.55rem;
}
.bge-batch-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: color-mix(in srgb, var(--bge-accent, var(--brand)) 75%, #22c55e);
  transition: width 0.2s ease;
}
.bge-batch-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bge-batch-actions .bge-btn { font-size: 0.78rem; padding: 0.4rem 0.65rem; min-height: 38px; }
.bge-batch-actions .bge-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bge-thumb.is-sel { outline: 2px solid color-mix(in srgb, var(--bge-accent, var(--brand)) 70%, transparent); outline-offset: 2px; }
.bge-thumb-ok, .bge-thumb-q {
  position: absolute; left: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.65rem; font-weight: 800; color: #fff;
  background: #16a34a; pointer-events: none;
}
.bge-thumb-q { background: #64748b; }
.bge[data-bge-preset="product"] .bge-strip { margin-top: 0.5rem; }
.bge-zip {
  margin-top: 0.75rem; padding-top: 0.65rem; border-top: 1px dashed var(--bge-line, var(--border));
}
.bge-zip strong { display: block; font-size: 0.88rem; margin-bottom: 0.25rem; }
.bge-zip-sizes, .bge-zip-formats { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; margin: 0 0 0.45rem; }
.bge-zip-custom {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--muted);
}
.bge-zip-custom input[type="number"] {
  width: 5.5rem; min-height: 36px; padding: 0.25rem 0.4rem; border-radius: 8px;
  border: 1px solid var(--bge-line, var(--border)); background: transparent; color: var(--text);
}
.bge-zip-btn { margin: 0.25rem 0 0.35rem; min-height: 42px; }
@media (max-width: 430px) {
  .bge-batch { padding: 0.65rem 0.7rem; border-radius: 12px; }
  .bge-batch-actions .bge-btn { flex: 1 1 calc(50% - 0.35rem); }
}

@media (max-width: 430px) {
  .bge-quick-actions .bge-btn { flex: 1 1 calc(50% - 0.35rem); }
  .bge-studio-chip span { display: none; }
  .bge-studio-chip { padding: 0.35rem; min-width: 40px; justify-content: center; }
  .bge-quick-compose { grid-template-columns: 1fr; }
}
.bge.is-app .bge-ready {
  position: absolute; left: 0.65rem; right: 0.65rem; bottom: 0.65rem; z-index: 6;
  margin: 0; backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bge-panel, var(--surface)) 88%, transparent);
  /* Keep CTA off the upper face region; canvas remains the dominant edit surface. */
  max-height: 28%;
}
.bge.is-app.has-panel .bge-ready { display: none !important; }
.bge.is-app .bge-stage-wrap { position: relative; }

/* Bottom tab bar */
.bge.is-app .bge-tabs {
  order: 5; flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; flex-wrap: nowrap;
  background: var(--bge-panel); border-top: 1px solid var(--bge-line);
  padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom));
}
.bge.is-app .bge-tab {
  flex-direction: column; justify-content: center; gap: 0.2rem; padding: 0.45rem 0.1rem; border-radius: 14px;
  font-size: 0.7rem; font-weight: 600; min-width: 0; line-height: 1.15;
}
.bge.is-app .bge-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bge.is-app .bge-tab svg { width: 22px; height: 22px; }
.bge.is-app .bge-tab.is-on { background: none; }
.bge.is-app .bge-tab.is-on svg { background: color-mix(in srgb, var(--bge-accent) 16%, transparent); border-radius: 999px; padding: 3px 12px; width: 46px; height: 28px; box-sizing: border-box; }

/* Download menu as an action sheet */
.bge.is-app.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 40; animation: bge-fade 0.18s ease-out; }
@keyframes bge-fade { from { opacity: 0; } }
.bge.is-app .bge-dl-menu {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; min-width: 0; z-index: 41;
  border-radius: 22px 22px 0 0; padding: 0.6rem 0.6rem calc(0.8rem + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.3); animation: bge-sheet 0.22s ease-out;
}
.bge.is-app .bge-dl-menu button { padding: 0.85rem 0.9rem; }

/* Small phones — keep canvas large; compact chrome (320–430 CSS px) */
@media (max-width: 430px) {
  .bge:not(.is-app) .bge-stage { height: min(62vh, 640px); min-height: 280px; }
  .bge:not(.is-app) .bge-toolbar { top: 56px; padding: 0.3rem 0.35rem; gap: 0.35rem; }
  .bge.is-app .bge-panel { max-height: 36vh; max-height: 36dvh; }
  .bge.is-app .bge-stage { touch-action: none; overscroll-behavior: none; }
}
@media (max-width: 360px) {
  .bge.is-app .bge-actions { padding: 0.35rem 0.4rem; }
  .bge.is-app .bge-icon { width: 38px; height: 38px; }
  .bge.is-app .bge-dl-btn { padding: 0.55rem 0.7rem; font-size: 0.85rem; gap: 0.3rem; }
  .bge.is-app .bge-tab { font-size: 0.6rem; letter-spacing: -0.01em; padding-left: 0; padding-right: 0; }
  .bge.is-app .bge-ready { left: 0.4rem; right: 0.4rem; bottom: 0.4rem; padding: 0.55rem 0.65rem; }
}
/* Landscape phones: keep the canvas as big as possible */
@media (max-height: 500px) {
  .bge.is-app .bge-strip { display: none; }
  .bge.is-app .bge-actions { padding-top: 0.25rem; padding-bottom: 0.25rem; }
  .bge.is-app .bge-tab { flex-direction: row; gap: 0.35rem; padding: 0.35rem 0.2rem; }
  .bge.is-app .bge-tab svg { width: 18px; height: 18px; }
  .bge.is-app .bge-tab.is-on svg { width: 18px; height: 18px; padding: 0; background: none; }
  .bge.is-app .bge-tab.is-on { background: color-mix(in srgb, var(--bge-accent) 14%, transparent); }
  .bge.is-app .bge-panel { max-height: 58vh; max-height: 58dvh; }
}
