/* Dynamic Image Studio — iOS grouped chrome, light/dark. */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --background: #000000;
  --foreground: #ffffff;
  --foreground-secondary: rgba(235, 235, 245, 0.78);
  --faint: rgba(235, 235, 245, 0.42);
  --card: #1c1c1e;
  --card-solid: #1c1c1e;
  --card-elevated: #2c2c2e;
  --popover: #2c2c2e;
  --muted: rgba(120, 120, 128, 0.24);
  --muted-hover: rgba(120, 120, 128, 0.36);
  --muted-foreground: rgba(235, 235, 245, 0.58);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --input: rgba(255, 255, 255, 0.14);
  --input-bg: #1c1c1e;
  --ring: rgba(255, 255, 255, 0.22);
  --hover-fill: rgba(120, 120, 128, 0.18);
  --btn-fill: rgba(120, 120, 128, 0.28);
  --btn-fill-hover: rgba(120, 120, 128, 0.40);

  --glass: #1c1c1e;
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --glow-a: rgba(255, 255, 255, 0.04);
  --glow-b: rgba(94, 92, 230, 0.10);
  --stage-bg: #000000;
  --stage-glow: rgba(255, 255, 255, 0.04);
  --checker-a: #1c1c1e;
  --checker-b: #000000;
  --seg-bg: rgba(120, 120, 128, 0.20);
  --handle-bg: #ffffff;
  --guide-border: rgba(255, 255, 255, 0.28);

  --primary: #ffffff;
  --primary-hover: #e8e8ed;
  --primary-foreground: #000000;
  --primary-soft: rgba(255, 255, 255, 0.12);
  --primary-ring: rgba(255, 255, 255, 0.22);
  --primary-glow: rgba(255, 255, 255, 0.10);
  --primary-text-shadow: none;
  --primary-btn-top: #ffffff;
  --primary-btn-border: rgba(255, 255, 255, 0.16);
  --primary-btn-edge: rgba(0, 0, 0, 0.25);

  --braze: #5e5ce6;
  --braze-hover: #4f4dd6;
  --braze-foreground: #ffffff;
  --braze-soft: rgba(94, 92, 230, 0.18);
  --braze-ring: rgba(94, 92, 230, 0.32);
  --braze-glow: rgba(94, 92, 230, 0.20);
  --braze-border: rgba(94, 92, 230, 0.38);
  --braze-tab: #bfbdff;
  --braze-card-border: rgba(94, 92, 230, 0.28);

  --destructive: #ff453a;
  --destructive-soft: rgba(255, 69, 58, 0.16);
  --destructive-border: #ff6961;
  --destructive-hover: #ff6961;
  --success: #30d158;
  --success-fg: #30d158;
  --success-soft: rgba(48, 209, 88, 0.14);
  --success-border: #30d158;
  --success-hover: #64e986;

  --warning-bg: rgba(255, 159, 10, 0.16);
  --warning-border: rgba(255, 159, 10, 0.4);
  --warning-foreground: #ffd60a;

  --notice-bg: rgba(120, 120, 128, 0.18);
  --notice-border: rgba(255, 255, 255, 0.12);
  --notice-fg: rgba(235, 235, 245, 0.78);

  --layer-active-bg: rgba(255, 255, 255, 0.12);
  --layer-active-border: rgba(255, 255, 255, 0.22);
  --layer-active-fg: #ffffff;
  --var-active-bg: rgba(94, 92, 230, 0.16);
  --var-active-border: rgba(94, 92, 230, 0.42);
  --var-name: #bfbdff;
  --chip-fg: #ffffff;
  --id-chip-fg: rgba(235, 235, 245, 0.7);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  --control-inset: inset 0 1px 1px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --background: #f2f2f7;
  --foreground: #000000;
  --foreground-secondary: rgba(60, 60, 67, 0.78);
  --faint: rgba(60, 60, 67, 0.42);
  --card: #ffffff;
  --card-solid: #ffffff;
  --card-elevated: #f2f2f7;
  --popover: #ffffff;
  --muted: rgba(120, 120, 128, 0.12);
  --muted-hover: rgba(120, 120, 128, 0.20);
  --muted-foreground: rgba(60, 60, 67, 0.60);
  --border: rgba(60, 60, 67, 0.18);
  --border-strong: rgba(60, 60, 67, 0.28);
  --input: rgba(60, 60, 67, 0.18);
  --input-bg: #ffffff;
  --ring: rgba(0, 0, 0, 0.16);
  --hover-fill: rgba(120, 120, 128, 0.12);
  --btn-fill: rgba(120, 120, 128, 0.16);
  --btn-fill-hover: rgba(120, 120, 128, 0.24);

  --glass: #ffffff;
  --glass-border: rgba(60, 60, 67, 0.16);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glow-a: rgba(0, 0, 0, 0.03);
  --glow-b: rgba(94, 92, 230, 0.08);
  --stage-bg: #e5e5ea;
  --stage-glow: rgba(0, 0, 0, 0.04);
  --checker-a: #d1d1d6;
  --checker-b: #e5e5ea;
  --seg-bg: rgba(120, 120, 128, 0.12);
  --handle-bg: #ffffff;
  --guide-border: rgba(60, 60, 67, 0.28);

  --primary: #000000;
  --primary-hover: #1c1c1e;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(0, 0, 0, 0.06);
  --primary-ring: rgba(0, 0, 0, 0.14);
  --primary-glow: rgba(0, 0, 0, 0.08);
  --primary-text-shadow: none;
  --primary-btn-top: #1c1c1e;
  --primary-btn-border: rgba(0, 0, 0, 0.12);
  --primary-btn-edge: rgba(0, 0, 0, 0.2);

  --braze: #5e5ce6;
  --braze-hover: #4f4dd6;
  --braze-foreground: #ffffff;
  --braze-soft: rgba(94, 92, 230, 0.12);
  --braze-ring: rgba(94, 92, 230, 0.24);
  --braze-glow: rgba(94, 92, 230, 0.14);
  --braze-border: rgba(94, 92, 230, 0.32);
  --braze-tab: #5e5ce6;
  --braze-card-border: rgba(94, 92, 230, 0.22);

  --destructive: #ff3b30;
  --destructive-soft: rgba(255, 59, 48, 0.10);
  --destructive-border: #ff6961;
  --destructive-hover: #d70015;
  --success: #34c759;
  --success-fg: #248a3d;
  --success-soft: rgba(52, 199, 89, 0.12);
  --success-border: #34c759;
  --success-hover: #248a3d;

  --warning-bg: #fff6e5;
  --warning-border: #ffd60a;
  --warning-foreground: #9a6700;

  --notice-bg: #f2f2f7;
  --notice-border: rgba(60, 60, 67, 0.16);
  --notice-fg: rgba(60, 60, 67, 0.78);

  --layer-active-bg: rgba(0, 0, 0, 0.06);
  --layer-active-border: rgba(0, 0, 0, 0.14);
  --layer-active-fg: #000000;
  --var-active-bg: rgba(94, 92, 230, 0.10);
  --var-active-border: rgba(94, 92, 230, 0.32);
  --var-name: #5e5ce6;
  --chip-fg: #1c1c1e;
  --id-chip-fg: rgba(60, 60, 67, 0.6);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.10);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --control-inset: inset 0 1px 1px rgba(0, 0, 0, 0.04);
}

:root {
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 10px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --control-h: 34px;
  --panel-pad: 18px;
  --chrome-h: 56px;
  --subbar-h: 48px;
  --layout-gap: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  background: var(--background);
  color: var(--foreground);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 480px at 0% -10%, var(--glow-a), transparent 55%),
    radial-gradient(720px 420px at 100% 0%, var(--glow-b), transparent 50%);
}

.hidden { display: none !important; }

.icon-sprite {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
.i {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.i-logo {
  width: 16px; height: 16px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen {
  position: relative; z-index: 1;
  height: 100%; display: flex; flex-direction: column; min-height: 0;
  overflow: hidden;
}
.screen.hidden { display: none !important; }

.glass {
  background: var(--card-solid);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  height: var(--chrome-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--card-solid);
  border-bottom: 1px solid var(--glass-border);
}
.brand {
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 0; flex: 1 1 auto;
}
.logo {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  box-shadow: var(--inset);
}
.brand-meta {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0; flex: 1 1 auto; max-width: 420px;
}
.brand-line {
  display: flex; align-items: baseline; gap: 8px; min-width: 0;
}
.brand-lbl {
  flex: 0 0 36px;
  font: 600 10px var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-foreground);
}
.brand-val {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 13.5px var(--font); color: var(--foreground);
}
.brand-val.mono { font: 500 12px var(--mono); color: var(--foreground-secondary); }
.brand-val.muted { color: var(--muted-foreground); font-weight: 400; }
.tpl-id {
  font: 500 10.5px var(--mono); color: var(--foreground-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: .02em; padding-left: 2px;
}
.tpl-id.muted { color: var(--muted-foreground); font-weight: 400; }

.top-actions {
  display: flex; align-items: center; gap: var(--space-2);
  flex: 0 1 auto; min-width: 0;
}
.top-braze {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--muted);
}
.top-braze-btn.btn.braze {
  flex: 0 0 auto;
  min-height: var(--control-h);
  padding: 0 16px;
  cursor: pointer;
}
.top-braze-btn.btn.braze:hover {
  background: var(--braze-hover);
}
.top-ws {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
  padding: 0 2px 0 4px;
}
.top-ws > span:first-child {
  flex: 0 0 auto;
  font: 600 10px var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-foreground);
}
.top-ws-name {
  font: 600 12.5px var(--font);
  color: var(--foreground);
  white-space: nowrap;
}
.top-ws select {
  width: 10.5rem;
  min-width: 10.5rem;
  field-sizing: fixed;
  white-space: nowrap;
  text-overflow: ellipsis;
  background-color: var(--input-bg);
  color: var(--foreground);
  min-height: calc(var(--control-h) - 4px);
  border-radius: var(--radius-pill);
}
.top-braze.on {
  border-color: var(--braze-border);
  background: var(--braze-soft);
}
.sep { width: 1px; height: 20px; background: var(--border); }

.theme-toggle .theme-moon { display: none; }
[data-theme="light"] .theme-toggle .theme-sun { display: none; }
[data-theme="light"] .theme-toggle .theme-moon { display: block; }

/* ── variables panel ─────────────────────────────────────── */
.vars-block { background: transparent; }
.vars-block h3 { color: var(--muted-foreground); }
.var-list { display: flex; flex-direction: column; gap: var(--space-2); }
.var-empty { margin: 0; }
.var-row {
  display: flex; align-items: stretch; gap: 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--muted); overflow: hidden;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.var-row:hover { border-color: var(--border-strong); }
.var-row.active {
  border-color: var(--var-active-border);
  background: var(--var-active-bg);
  box-shadow: inset 0 0 0 1px var(--braze-soft);
}
.var-row-main {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: 1fr; gap: 2px;
  text-align: left; padding: 8px 10px;
  background: transparent; border: 0; color: inherit; cursor: pointer;
  font: inherit;
}
.var-row-main:hover { background: var(--hover-fill); }
.var-name {
  font: 600 12px var(--mono); color: var(--var-name);
  background: transparent; border: 0; padding: 0;
}
.var-row.active .var-name { color: var(--var-name); }
.var-default {
  font-size: 11px; color: var(--muted-foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.var-default em { color: var(--faint); font-style: normal; }
.var-used { font-size: 10.5px; color: var(--faint); }
.var-row-actions {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 4px; border-left: 1px solid var(--border);
}

.var-form {
  padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--input-bg); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--control-inset);
  overflow: visible;
}
.var-form.nested { margin: 0; }
.var-form-title {
  font: 600 13px var(--font); color: var(--foreground);
  margin: 0;
}
.var-form .field { margin: 0; }
.var-form .field em { font-style: normal; color: var(--faint); font-weight: 400; }
.field-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.attr-refresh {
  width: 24px; height: 24px; flex-shrink: 0;
}
.attr-refresh svg { width: 13px; height: 13px; display: block; }
.attr-refresh:disabled { opacity: .45; cursor: wait; }
.var-form-actions {
  display: flex; justify-content: flex-end; gap: var(--space-2); margin: 0;
}
.attr-combo { position: relative; }
.attr-combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 30;
  max-height: 220px; overflow-y: auto;
  margin: 0; padding: 4px 0; list-style: none;
  background: var(--popover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.attr-combo-item {
  padding: 7px 10px; cursor: pointer;
  font: 500 12.5px var(--font); color: var(--foreground);
}
.attr-combo-item:hover,
.attr-combo-item[aria-selected="true"] {
  background: var(--primary-soft);
}
.attr-combo-item .muted { font: 400 11px var(--font); color: var(--muted-foreground); }
.attr-combo-empty {
  padding: 10px 12px;
  color: var(--muted-foreground);
  font: 400 12px var(--font);
}
.liquid-preview {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) 10px;
  min-height: var(--control-h);
  display: flex; align-items: center;
}
.liquid-preview code {
  font: 500 12px var(--mono); color: var(--foreground-secondary);
  word-break: break-all;
}
.chip.on {
  border-color: var(--braze); background: var(--braze-soft); color: var(--var-name);
}
#btnInsertVar { margin: 0; }

/* ── buttons & controls ──────────────────────────────────── */
.btn {
  background: var(--btn-fill); color: var(--foreground);
  border: 0; border-radius: var(--radius-pill);
  padding: 0 14px; height: 34px;
  font: 590 13px/1 var(--font); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .12s ease, color .12s ease, opacity .12s ease, box-shadow .12s ease;
  white-space: nowrap;
  box-shadow: none;
  letter-spacing: -0.011em;
}
.btn:hover { background: var(--btn-fill-hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:active { transform: none; opacity: 0.88; }
.btn.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--inset);
  text-shadow: none;
}
.btn.primary:hover { background: var(--primary-hover); color: var(--primary-foreground); }
.btn.primary.unsaved { box-shadow: var(--inset); }
.btn.commit {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--inset);
  text-shadow: none;
}
.btn.commit:hover {
  background: var(--primary-hover);
  color: var(--primary-foreground);
  filter: none;
}
.btn.commit:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring); }
.btn.braze {
  background: var(--braze);
  color: var(--braze-foreground);
  box-shadow: none;
  text-shadow: none;
}
.btn.braze:hover { background: var(--braze-hover); color: var(--braze-foreground); }
.btn.braze:focus-visible { box-shadow: 0 0 0 4px var(--braze-ring); }
.btn.braze:disabled:hover { background: var(--braze); color: var(--braze-foreground); }
.unsaved-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--radius-pill);
  font: 500 12px var(--font); letter-spacing: 0;
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border);
  user-select: none; white-space: nowrap;
}
.unsaved-badge::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--foreground);
  opacity: 0.45;
}
.unsaved-badge.hidden { display: none; }
.btn.success {
  background: var(--success-soft);
  color: var(--success-fg);
  box-shadow: none;
}
.btn.success:hover {
  background: var(--success-soft);
  color: var(--success-hover);
}
.btn.danger {
  background: var(--btn-fill);
  color: var(--destructive);
  box-shadow: none;
}
.btn.danger:hover {
  background: var(--destructive-soft);
  color: var(--destructive-hover);
}
.btn.ghost {
  background: transparent;
  color: var(--muted-foreground);
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--btn-fill);
  color: var(--foreground);
}
.btn.tiny {
  padding: 0 12px; height: 28px; font-size: 12px;
  border-radius: var(--radius-pill);
  gap: 6px;
}
.btn.tiny .i { width: 14px; height: 14px; }
.btn.full { width: 100%; justify-content: center; margin: 0; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--btn-fill); }
.btn.primary:disabled:hover { background: var(--primary); color: var(--primary-foreground); }
.btn.commit:disabled:hover { background: var(--primary); color: var(--primary-foreground); }
.btn.ghost:disabled:hover { background: transparent; }

.icon-btn {
  background: var(--btn-fill); border: 0;
  color: var(--foreground);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, opacity .12s;
  box-shadow: none;
}
.icon-btn .i { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--btn-fill-hover); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.icon-btn:active { transform: none; opacity: 0.88; }
.topbar .icon-btn { width: 34px; height: 34px; }

.mini-select, select, input[type=text], input[type=number], input[type=search], textarea {
  background: var(--input-bg); color: var(--foreground);
  border: 1px solid var(--input); border-radius: var(--radius-sm);
  padding: 0 10px; font: 12.5px/1.45 var(--font); width: 100%;
  min-height: var(--control-h);
  transition: border-color .12s, box-shadow .12s, background .12s;
  box-shadow: var(--control-inset);
}
input[type=search] { -webkit-appearance: none; appearance: none; }
select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
.mini-select {
  width: auto; max-width: 180px; min-width: 140px;
  background: var(--card-elevated);
  box-shadow: var(--inset), var(--shadow-sm);
}
textarea {
  font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.55;
  background: var(--input-bg);
  min-height: 72px; padding: var(--space-2) 10px;
}
.text-field { position: relative; }
.text-field textarea { display: block; width: 100%; padding-right: 36px; min-height: 72px; }
.emoji-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  background: var(--btn-fill);
  border: 0;
  border-radius: 50%;
  color: var(--foreground);
  cursor: pointer;
  box-shadow: none;
}
.emoji-btn:hover { background: var(--btn-fill-hover); }
.emoji-btn[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.emoji-picker {
  margin-top: 8px;
  background: var(--popover);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.emoji-cats {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--border);
}
.emoji-cat {
  background: transparent; border: none; color: var(--muted-foreground);
  font: 500 10.5px var(--font); padding: 5px 7px; border-radius: var(--radius-xs);
  cursor: pointer;
}
.emoji-cat:hover { color: var(--foreground); background: var(--muted); }
.emoji-cat.on { color: var(--foreground); background: var(--muted-hover); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 6px;
  max-height: 168px;
  overflow-y: auto;
}
.emoji-cell {
  aspect-ratio: 1;
  background: transparent; border: none;
  font-size: 18px; line-height: 1;
  border-radius: var(--radius-xs);
  cursor: pointer;
  padding: 0;
}
.emoji-cell:hover { background: var(--muted-hover); }
.emoji-cell img {
  width: 20px; height: 20px; display: block; margin: 0 auto;
  object-fit: contain; pointer-events: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  background: var(--card-elevated);
  box-shadow: 0 0 0 3px var(--primary-ring), var(--control-inset);
}

.url-input {
  font-family: var(--mono); font-size: 11px; color: var(--chip-fg); cursor: text;
}
.url-input::placeholder { font-family: var(--font); color: var(--faint); }
.url-input:disabled, input:disabled {
  background: var(--input-bg); opacity: 1; color: var(--muted-foreground); cursor: not-allowed;
}

.color-native {
  position: absolute; width: 0; height: 0; opacity: 0;
  pointer-events: none; border: 0; padding: 0;
}
.color-btn {
  display: inline-flex; align-items: center; gap: 10px;
  width: 100%; height: 32px; padding: 0 10px 0 var(--space-2);
  background: var(--btn-fill);
  border: 0;
  border-radius: 999px;
  color: var(--foreground);
  cursor: pointer;
  box-shadow: none;
}
.color-btn:hover { background: var(--btn-fill-hover); }
.color-btn[aria-expanded="true"] {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.color-btn-chip {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #ffffff22;
  box-shadow: 0 0 0 1px #00000066;
}
.color-btn-hex {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--muted-foreground);
}
.color-btn-caret {
  margin-left: auto;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted-foreground);
}
.color-pop {
  position: fixed; z-index: 80;
  width: 220px; padding: 10px;
  background: var(--popover);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-lg);
}
.color-pop-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.color-pop-well {
  position: relative; overflow: hidden;
  width: var(--control-h); height: var(--control-h); flex: 0 0 var(--control-h); padding: 3px;
  background: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.color-pop-well:hover { border-color: var(--border-strong); }
.color-pop-well-fill {
  display: block; width: 100%; height: 100%;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #00000055;
}
.color-pop-well input[type=color] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  border: 0; padding: 0; margin: 0;
}
.color-pop .color-hex {
  flex: 1; min-width: 0; height: var(--control-h); padding: 0 var(--space-2);
  background: var(--muted);
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.color-pop-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-foreground);
  margin: 0 0 6px;
}
.swatches {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.swatch {
  width: 22px; height: 22px; padding: 0;
  border-radius: 50%; cursor: pointer;
  border: 1px solid #ffffff33;
  box-shadow: inset 0 0 0 1px #00000055;
}
.swatch:hover { outline: 2px solid var(--foreground); outline-offset: 1px; opacity: .9; }
.swatch.on { outline: 2px solid var(--foreground); outline-offset: 1px; }

/* Native range → shadcn-like slider */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 999px;
  background: var(--border-strong);
  border: 1px solid var(--border);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -6px;
  border-radius: 50%;
  background: var(--foreground);
  border: 2px solid var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
}
input[type=range]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input[type=range]::-moz-range-track {
  height: 5px; border-radius: 999px; background: var(--border-strong); border: 1px solid var(--border);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--foreground); border: 2px solid var(--card);
}
input[type=checkbox] {
  accent-color: var(--foreground); width: 14px; height: 14px; cursor: pointer;
}

/* ── compose / preview mode tabs ─────────────────────────── */
.modebar {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; height: var(--subbar-h); padding: 0 var(--space-5);
  background: var(--card-solid);
  border-bottom: 1px solid var(--glass-border);
}
.mode-tabs {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px;
  background: var(--muted);
  border: 0;
  border-radius: var(--radius-pill);
}
.mode-tab {
  background: transparent; border: 0; color: var(--faint);
  font: 590 13px var(--font); padding: 0 14px; height: 30px; cursor: pointer;
  position: relative; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: 6px;
}
.mode-tab .i { width: 13px; height: 13px; }
.mode-tab:hover { color: var(--foreground); background: var(--hover-fill); }
.mode-tab.active {
  color: var(--foreground);
  background: var(--card-elevated);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.mode-tab.active::after { display: none; }
.mode-tab[data-mode="braze"].active {
  color: var(--braze-tab);
  background: var(--braze-soft);
  box-shadow: none;
}

/* ── layout ──────────────────────────────────────────────── */
.layout {
  --compose-left: 248px;
  --compose-right: 328px;
  display: grid;
  grid-template-columns: var(--compose-left) 12px minmax(0, 1fr) 12px var(--compose-right);
  gap: 0;
  column-gap: 4px;
  padding: var(--layout-gap);
  flex: 1;
  min-height: 0;
}
.panel {
  background: var(--glass);
  overflow-y: auto; display: flex; flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}
.panel.left,
.panel.right {
  border-right: 1px solid var(--glass-border);
  border-left: 1px solid var(--glass-border);
  background: var(--glass);
  min-width: 0;
}

.resize-handle {
  position: relative;
  z-index: 5;
  width: 12px;
  margin: 0;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  border: 0;
  padding: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.resize-handle::before {
  content: '';
  position: absolute;
  inset: 0 4px;
  background: var(--border);
  border-radius: 1px;
}
.resize-grip {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--card-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.resize-grip::before,
.resize-grip::after {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 1.5px;
  border-radius: 1px;
  background: var(--muted-foreground);
}
.resize-grip::before { left: 4px; }
.resize-grip::after { right: 4px; }
.resize-handle:hover::before,
.resize-handle:focus-visible::before,
.resize-handle.active::before {
  background: color-mix(in srgb, var(--foreground) 28%, transparent);
}
.resize-handle:hover .resize-grip,
.resize-handle:focus-visible .resize-grip,
.resize-handle.active .resize-grip {
  background: var(--foreground);
  border-color: var(--foreground);
}
.resize-handle:hover .resize-grip::before,
.resize-handle:hover .resize-grip::after,
.resize-handle:focus-visible .resize-grip::before,
.resize-handle:focus-visible .resize-grip::after,
.resize-handle.active .resize-grip::before,
.resize-handle.active .resize-grip::after {
  background: var(--background);
}
.resize-handle:focus-visible {
  outline: none;
}
body.resizing,
body.resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
body.resizing iframe {
  pointer-events: none;
}

.block {
  padding: var(--panel-pad);
  border-bottom: 1px solid var(--glass-border);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.tpl-meta .meta-row { margin: 0; }
.meta-lbl {
  display: block;
  font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-foreground); margin-bottom: var(--space-1);
}
.meta-val-row {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.meta-val {
  flex: 1; min-width: 0;
  font: 600 13px var(--font); color: var(--foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.meta-val.mono {
  font: 500 12px var(--mono); color: var(--foreground-secondary);
  user-select: all;
}
.meta-val.muted { color: var(--muted-foreground); font-weight: 400; }
.meta-input {
  flex: 1; min-width: 0;
  background: var(--muted); border: 1px solid var(--border-strong); color: var(--foreground);
  font: 600 13px var(--font); padding: 0 10px; min-height: var(--control-h);
  border-radius: var(--radius-sm);
}
.meta-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.tpl-meta .btn.tiny { flex-shrink: 0; }
.block.grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.block h3 {
  font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted-foreground); margin: 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
}
.block h3 .unit { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .85; }
.block h3 .btn { text-transform: none; letter-spacing: 0; }
.h3-actions {
  display: flex; align-items: center; gap: var(--space-1);
  text-transform: none; letter-spacing: 0;
}

.block label.f1,
.block label.f2 {
  display: flex; flex-direction: column; gap: 6px;
}
.block label input[type=range] { margin-top: 6px; min-height: 0; }
.block label b {
  color: var(--foreground-secondary); font-weight: 600; float: right;
  font-variant-numeric: tabular-nums; font-size: 11px;
}
.block label.inline {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--foreground); font-size: 12.5px;
  min-height: var(--control-h);
}
.block label.inline input { margin: 0; }
.lbl {
  display: block; margin: 0;
  font: 500 12px var(--font); color: var(--muted-foreground);
}
.fill-mode { margin: 0; }
.fill-mode .seg { margin: 0; }
.fill-mode + div { margin: 0; }
#pBgMode { margin: 0; }

.row { display: flex; gap: var(--space-2); align-items: flex-end; }
.row > * { min-width: 0; }
.row .f1 { flex: 1; } .row .f2 { flex: 2; }
.row.btn-row { align-items: center; margin: 0; gap: var(--space-2); }
.row.btn-row .btn { flex: 1; }

.hint { font-size: 12px; color: var(--faint); line-height: 1.5; margin: 0; }
.hint code, code {
  font-family: var(--mono);
  background: var(--muted); color: var(--foreground-secondary);
  border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; font-size: 10.5px;
}
.meta {
  font-size: 12px; color: var(--muted-foreground); margin: 0;
  font-variant-numeric: tabular-nums;
  padding: var(--space-2) 10px; border-radius: var(--radius-xs);
  background: var(--muted); border: 1px solid var(--border);
}
.err { color: var(--destructive); font-size: 12px; margin: 0; }
.err:empty { display: none; }
.empty-note {
  padding: var(--space-8) var(--panel-pad); text-align: center;
  color: var(--faint); font-size: 12.5px; line-height: 1.55;
}

/* ── dropzone ────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 22px 12px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  cursor: pointer; text-align: center;
  background: var(--muted);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--foreground-secondary);
  background: var(--muted-hover);
  box-shadow: none;
}
.dz-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--card-elevated); border: 1px solid var(--border);
  color: var(--muted-foreground); margin-bottom: 2px;
}
.dz-icon .i { width: 16px; height: 16px; }
.dz-text { font-size: 12.5px; color: var(--foreground-secondary); }
.dz-text u { color: var(--foreground); text-decoration-color: var(--border-strong); }
.dz-hint { font-size: 10.5px; color: var(--faint); }

/* ── layers ──────────────────────────────────────────────── */
.layers { list-style: none; overflow-y: auto; flex: 1; min-height: 0; margin: 0; }
.layers li {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12.5px; color: var(--muted-foreground);
  border: 1px solid transparent;
  margin-bottom: var(--space-1);
  transition: background .12s, border-color .12s, color .12s;
}
.layers li.empty-layer {
  cursor: default; justify-content: center;
  border-style: dashed; border-color: var(--border);
  color: var(--faint); padding: 14px 8px;
}
.layers li.empty-layer:hover { background: transparent; color: var(--faint); }
.layers li:hover {
  background: var(--muted); color: var(--foreground); border-color: var(--border);
}
.layers li.active {
  background: var(--layer-active-bg);
  border-color: var(--layer-active-border);
  color: var(--layer-active-fg); font-weight: 500;
}
.layers li .name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.layers li.off .name { opacity: .45; text-decoration: line-through; }

.kind-icon {
  width: 26px; height: 26px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--muted); border: 1px solid var(--border);
  color: var(--muted-foreground);
}
.kind-icon svg, .kind-icon .i { width: 14px; height: 14px; display: block; }
.kind-icon.text { color: var(--foreground-secondary); }
.kind-icon.button {
  color: var(--success-fg);
  background: var(--success-soft);
  border-color: var(--success-border);
}
.kind-icon.base {
  color: var(--var-name);
  background: var(--braze-soft);
  border-color: var(--braze-border);
}
.layers li.active .kind-icon.text {
  color: var(--layer-active-fg); background: var(--primary-soft); border-color: var(--layer-active-border);
}
.layers li.active .kind-icon.button {
  color: var(--success-fg); background: var(--success-soft); border-color: var(--success-border);
}
.layers li.active .kind-icon.base {
  color: var(--var-name); background: var(--braze-soft); border-color: var(--braze-border);
}

.layers li.base-layer {
  margin-top: 6px;
  border-top: 1px dashed var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding-top: 10px;
}
.layers li.base-layer.active {
  background: var(--muted);
  border-color: var(--border-strong);
  color: var(--foreground);
  box-shadow: none;
}

.layer-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  margin-left: auto;
}
.layer-btn {
  background: transparent; border: 0; color: var(--faint);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.layer-btn svg { width: 14px; height: 14px; display: block; }
.layer-btn:hover {
  background: var(--btn-fill); color: var(--foreground);
}
.layer-btn.eye.off { color: var(--muted-foreground); }
.layer-btn.copy:hover {
  background: var(--braze-soft); color: var(--var-name);
}
.layer-btn.trash:hover {
  background: var(--destructive-soft); color: var(--destructive-hover);
}

/* ── stage ───────────────────────────────────────────────── */
.stage-wrap {
  display: flex; flex-direction: column; min-width: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 40%, var(--stage-glow) 0%, transparent 70%),
    var(--stage-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
  overflow: hidden;
}
.stage-toolbar {
  height: var(--subbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass);
}
.zoom { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
#zoomLabel {
  font-size: 11.5px; color: var(--muted-foreground); min-width: 42px;
  text-align: center; font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.stage-info {
  font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 10px;
}
.stage-toggles { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }
.chk {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted-foreground); cursor: pointer; flex-shrink: 0;
  padding: 0 var(--space-2); height: 28px; border-radius: var(--radius-xs);
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.chk:hover { background: var(--muted); border-color: var(--border); color: var(--foreground); }

.warnbar {
  flex-shrink: 0; padding: var(--space-2) var(--space-4); font-size: 12px;
  background: var(--warning-bg); color: var(--warning-foreground);
  border-bottom: 1px solid var(--warning-border);
}

.layers li.warn .name::after {
  content: '⚠'; margin-left: 6px; color: var(--warning-foreground); font-size: 11px;
}

.stage-scroll {
  flex: 1; overflow: auto; display: grid; place-items: center; padding: var(--space-8);
}
.stage {
  position: relative; flex-shrink: 0; overflow: hidden;
  background:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%),
    linear-gradient(45deg, var(--checker-a) 25%, var(--checker-b) 25%, var(--checker-b) 75%, var(--checker-a) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg), 0 0 80px var(--stage-glow);
}
#preview {
  position: absolute; top: 0; left: 0; border: 0; display: block;
  transform-origin: 0 0;
}
.overlay { position: absolute; inset: 0; z-index: 2; }
.align-guides {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
}
.align-line {
  position: absolute;
  background: #e879f9;
  box-shadow: 0 0 4px #e879f988;
}
.align-line.v { width: 1px; margin-left: -0.5px; }
.align-line.h { height: 1px; margin-top: -0.5px; }
.ov-box.align-hit {
  border-color: #e879f9aa !important;
  border-style: solid;
}
.stage-grid {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M40 0v40M0 40h40' fill='none' stroke='rgba(255,255,255,0.28)' stroke-width='1' stroke-dasharray='1.2 7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 5% 5%;
}
.empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--faint); font-size: 13px; pointer-events: none;
  background: radial-gradient(circle at center, var(--muted), transparent 70%);
}

.badge {
  background: var(--primary-soft); color: var(--chip-fg); border: 1px solid var(--layer-active-border);
  border-radius: 999px; padding: 2px 8px; font: 600 9.5px var(--font);
  text-transform: uppercase; letter-spacing: .06em;
}
.badge.soft {
  background: var(--muted); color: var(--muted-foreground); border-color: var(--border);
}
.badge.button, .badge.soft.button {
  background: var(--success-soft); color: var(--success-fg); border-color: var(--success-border);
}

/* interaction layer */
.ov-box { position: absolute; cursor: move; border: 1px solid transparent; }
.ov-box:hover { border-color: color-mix(in srgb, var(--foreground) 35%, transparent); }
.ov-box.selected {
  border: 1px solid var(--foreground);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 18%, transparent);
}
.ov-box.var-hit {
  border: 1.5px solid var(--braze) !important;
  box-shadow: 0 0 0 2px var(--braze-soft);
}
.ov-box.guides { border-color: var(--guide-border); border-style: dashed; }
.ov-box.guides:hover { border-color: var(--foreground); border-style: solid; }
.ov-box.selected.guides { border-style: solid; border-color: var(--foreground); }

.handle {
  position: absolute; width: 8px; height: 8px;
  background: var(--handle-bg); border: 1.5px solid var(--foreground); border-radius: 1px;
  box-shadow: var(--shadow-sm);
}
.ov-box:not(.selected) .handle { display: none; }
.h-nw { left: -5px; top: -5px; cursor: nwse-resize; }
.h-n  { left: 50%; top: -5px; margin-left: -4.5px; cursor: ns-resize; }
.h-ne { right: -5px; top: -5px; cursor: nesw-resize; }
.h-e  { right: -5px; top: 50%; margin-top: -4.5px; cursor: ew-resize; }
.h-se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.h-s  { left: 50%; bottom: -5px; margin-left: -4.5px; cursor: ns-resize; }
.h-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.h-w  { left: -5px; top: 50%; margin-top: -4.5px; cursor: ew-resize; }

/* ── segmented control ───────────────────────────────────── */
.seg {
  display: flex; padding: 3px; gap: 2px;
  min-height: var(--control-h);
  background: var(--seg-bg); border: 0; border-radius: var(--radius-pill);
  box-shadow: none;
}
.seg button {
  flex: 1; background: transparent; border: 0; border-radius: var(--radius-pill);
  color: var(--faint); padding: 0 10px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: background .12s, color .12s;
}
.seg button .i { width: 14px; height: 14px; }
.seg button:hover { background: var(--muted); color: var(--foreground); }
.seg button.on {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: none;
}

.size-step {
  display: flex; gap: var(--space-2);
}
.size-row { align-items: flex-end; }
.size-row > label { margin: 0; }
.size-row .size-step { flex: 0 0 auto; margin: 0; }
.size-step button {
  flex: 1;
  background: var(--btn-fill);
  color: var(--foreground);
  border: 0;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  box-shadow: none;
}
.size-row .size-step button {
  width: 32px; height: 32px; flex: none;
}
.size-step button:hover {
  background: var(--btn-fill-hover);
}
.size-step button:disabled {
  opacity: .35; cursor: not-allowed;
}
.size-step button:disabled:hover {
  background: var(--btn-fill);
}
#btnFontSmaller { font-size: 13px; font-weight: 600; }
#btnFontLarger { font-size: 18px; font-weight: 700; }
.size-hint { margin: 0; }

/* ── chips, data ─────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; }
.chip {
  background: var(--muted); border: 1px solid var(--border); color: var(--chip-fg);
  border-radius: var(--radius-pill); padding: 4px 10px; font: 11px var(--mono); cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.chip.styled {
  box-shadow: inset 0 0 0 1px var(--layer-active-border);
}
.token-style { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.token-style .lbl { margin: 0 0 var(--space-1); }

.data-fields { display: flex; flex-direction: column; gap: 8px; }
.data-fields .df { display: flex; align-items: center; gap: 8px; }
.data-fields .df span {
  font: 11px var(--mono); color: var(--chip-fg);
  width: 92px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis;
}
details.raw { margin-top: 12px; }
details.raw summary {
  cursor: pointer; font-size: 11.5px; color: var(--muted-foreground); margin-bottom: 8px;
  user-select: none;
}
details.raw summary:hover { color: var(--foreground); }
details.raw textarea { margin-bottom: 8px; }

pre.code {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-3); font: 11.5px/1.5 var(--mono); color: var(--foreground-secondary);
  overflow-x: auto; white-space: pre; margin: 0;
  box-shadow: var(--control-inset);
}

/* ── modal ───────────────────────────────────────────────── */
.modal:not([open]) {
  display: none !important;
}
.modal[open] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 20px;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  z-index: 80;
}
.modal::backdrop {
  background: color-mix(in srgb, var(--background) 72%, transparent);
}
.modal-card {
  width: fit-content;
  min-width: min(32rem, calc(100vw - 40px));
  max-width: min(42rem, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  margin: 0;
  padding: 0;
  display: flex; flex-direction: column; gap: 0;
  background: var(--popover);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-lg);
  overflow: hidden;
}
.modal-notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  color: var(--notice-fg);
  font: 500 13px var(--font);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.modal-warn {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 159, 10, 0.16);
  border: 1px solid rgba(255, 159, 10, 0.4);
  color: var(--foreground);
  font: 500 13px var(--font);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
[data-theme="light"] .modal-warn {
  background: rgba(255, 149, 0, 0.14);
  border-color: rgba(200, 110, 0, 0.35);
  color: #7a4a00;
}
.modal-warn.hidden,
.modal-notice.hidden { display: none; }
.modal-block-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-block-list.hidden { display: none; }
.modal-block-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-block-ws {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: 600 11px var(--font);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.modal-block-ws strong {
  font: 600 14px/1.35 var(--font);
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--foreground);
  overflow-wrap: anywhere;
}
.modal-block-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.modal-block-kind {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--braze-soft);
  color: var(--foreground);
  font: 600 11px var(--font);
  letter-spacing: .02em;
}
.modal-block-card[data-kind="content_card"] .modal-block-kind {
  background: var(--notice-bg);
}
.modal-block-name {
  font: 600 14px/1.35 var(--font);
  color: var(--foreground);
  overflow-wrap: anywhere;
}
.modal-block-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 8px 12px;
  width: 100%;
  font: 500 13px/1.4 var(--font);
}
.modal-block-row dt {
  margin: 0;
  color: var(--muted-foreground);
  font-weight: 500;
}
.modal-block-row dd {
  margin: 0;
  color: var(--foreground);
  overflow-wrap: anywhere;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h2 {
  font-size: 17px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.25;
}
.modal-head .hint {
  max-width: none;
  margin: 0;
  overflow-wrap: anywhere;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-foot {
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#confirmInputWrap {
  padding: 0 22px;
}
#confirmInputWrap.field input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font: 500 14px var(--font);
}
.braze-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.braze-section:last-child { border-bottom: none; }
.braze-section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.braze-section h3 {
  font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.braze-code {
  margin: 0;
  max-height: min(28vh, 260px);
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.55;
  color: var(--foreground-secondary);
  user-select: all;
}

/* ── toast / busy ────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 70px);
  background: var(--popover); color: var(--foreground);
  border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 11px 16px; font-size: 12.5px;
  box-shadow: var(--glass-highlight), var(--shadow-lg);
  opacity: 0; transition: transform .22s, opacity .22s; pointer-events: none; z-index: 60;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { border-left: 3px solid var(--success); }
.toast.bad { border-left: 3px solid var(--destructive); }

.busy {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--background) 72%, transparent); z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: 13px; color: var(--foreground);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
  box-shadow: 0 0 20px var(--primary-glow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 1180px) {
  .brand-meta { max-width: 280px; }
  .stage-scroll { padding: 16px; }
}
@media (max-width: 940px) {
  .stage-info { display: none; }
  .brand-meta { max-width: 200px; }
  .stage-scroll { padding: 12px; }
}
@media (max-width: 760px) {
  .mini-select { max-width: 120px; min-width: 100px; }
  .chk { display: none; }
  .preview-toolbar .chk { display: inline-flex; }
  .h3-actions .btn { height: 26px; padding: 0 10px; font-size: 11px; }
}

/* ── center stage dropzone ───────────────────────────────── */
.stage-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-3); width: min(520px, 86%); min-height: 280px;
  padding: var(--space-8) var(--space-6); cursor: pointer; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--glass);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.stage-drop:hover, .stage-drop.over {
  border-color: var(--foreground-secondary);
  background: var(--card-elevated);
  box-shadow: var(--shadow-md);
}
.stage-drop .dz-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--muted); border: 1px solid var(--border);
  color: var(--muted-foreground); margin: 0;
}
.stage-drop .dz-icon .i { width: 20px; height: 20px; }
.stage-drop .dz-title {
  font: 600 16px var(--font); color: var(--foreground);
}
.stage-drop .dz-text { font-size: 13px; color: var(--muted-foreground); }
.stage-drop .dz-text u { color: var(--foreground); text-decoration-color: var(--border-strong); }
.stage-drop .dz-hint { font-size: 12px; color: var(--faint); margin: 0; max-width: 280px; }

/* ── home / new screens ──────────────────────────────────── */
.home-topbar .brand-title {
  font: 600 14px var(--font); color: var(--foreground); padding: 2px 0;
}
.home-body {
  flex: 1; min-height: 0; overflow: auto;
  padding: var(--space-6);
  background: transparent;
}
#homeView .home-body {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.home-body.center {
  display: grid; place-items: center;
}
.home-card, .new-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-lg);
  overflow: hidden;
}
.home-card {
  width: 100%;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.home-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0; flex-wrap: wrap;
}
.home-card-head > div:first-child { flex: 1 1 180px; min-width: 0; }
.home-card-head h1, .new-card h1 {
  font: 600 18px/1.25 var(--font); color: var(--foreground); margin: 0;
  letter-spacing: -0.022em;
}
.home-card-head h1 { margin-bottom: var(--space-1); }
.home-card-head .hint { margin: 0; max-width: 52ch; }
.home-card-actions {
  display: flex; align-items: center; gap: var(--space-2);
  flex: 0 1 auto; justify-content: flex-end; flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  width: 240px;
  max-width: 100%;
  flex: 0 0 auto;
}
.search-wrap .i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--faint); pointer-events: none;
}
.home-card-actions input[type=search] {
  width: 100%;
  height: 34px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--input-bg);
  box-shadow: none;
  padding: 0 14px 0 34px;
}
.home-card-actions input[type=search]:focus {
  background: var(--input-bg);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.new-card {
  width: min(460px, 100%);
  margin: 0 auto;
  padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-3);
  overflow: visible;
}
.new-card .hint { margin: 0; }
.field {
  display: flex; flex-direction: column; gap: 6px;
  margin: 0; font-size: 12px; color: var(--muted-foreground);
}
.field span { font: 500 12px var(--font); color: var(--muted-foreground); }
.new-card .field input {
  font: 500 14px var(--mono);
  padding: 0 var(--space-3);
  min-height: 40px;
}
.new-card .field.name-field input { font-family: var(--font); }
.new-actions {
  display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-1);
}

.table-wrap {
  flex: 1; min-height: 0;
  overflow: auto;
}
.tpl-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.tpl-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font: 600 11px var(--font);
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); background: var(--card-solid);
  padding: 12px var(--space-6); border-bottom: 1px solid var(--glass-border);
}
.tpl-table td {
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tpl-table tr:last-child td { border-bottom: 0; }
.tpl-table tbody tr {
  transition: background .12s;
}
.tpl-table tbody tr:hover { background: var(--hover-fill); }
.col-preview { width: 96px; }
.tpl-thumb {
  display: block; width: 88px; height: 56px; padding: 0;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); background: var(--input-bg);
  box-shadow: var(--inset);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.tpl-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tpl-thumb:hover {
  border-color: var(--layer-active-border);
  box-shadow: 0 0 0 1px var(--primary-ring), var(--shadow-md);
  transform: translateY(-1px);
}
.tpl-thumb.empty {
  display: grid; place-items: center;
  font-size: 10px; color: var(--faint); cursor: default;
  background:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%),
    linear-gradient(45deg, var(--checker-a) 25%, var(--checker-b) 25%, var(--checker-b) 75%, var(--checker-a) 75%);
  background-size: 10px 10px; background-position: 0 0, 5px 5px;
}
.tpl-name-cell { font-weight: 500; color: var(--foreground); }
button.tpl-name-cell, .linkish-name {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: 500 13px var(--font); color: var(--foreground); text-align: left;
}
button.tpl-name-cell:hover, .linkish-name:hover { color: var(--layer-active-fg); text-decoration: underline; text-underline-offset: 2px; }
.muted-cell { color: var(--muted-foreground); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-id {
  white-space: nowrap;
  min-width: 160px;
  width: 1%;
}
.id-chip {
  display: inline-block;
  font: 500 11.5px var(--mono); color: var(--id-chip-fg);
  background: var(--primary-soft); border: 1px solid var(--layer-active-border);
  padding: 3px 10px; border-radius: var(--radius-pill);
  white-space: nowrap;
  max-width: none;
}
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.tpl-table .btn.tiny { height: 28px; padding: 0 10px; }
.table-empty {
  text-align: center; color: var(--faint); padding: var(--space-8) var(--space-4) !important;
}
.linkish {
  background: none; border: 0; color: var(--chip-fg); cursor: pointer;
  font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.linkish:hover { color: var(--layer-active-fg); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ── Braze-style preview screen ──────────────────────────── */
.preview-screen {
  --preview-left: 300px;
  display: grid;
  grid-template-columns: var(--preview-left) 12px minmax(0, 1fr);
  gap: 0;
  column-gap: 4px;
  padding: var(--layout-gap);
  flex: 1;
  min-height: 0;
}
.preview-screen.hidden { display: none !important; }

.preview-user {
  overflow-y: auto;
  min-width: 0;
  background: var(--card-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}
.preview-user-head {
  padding: var(--panel-pad);
  border-bottom: 1px solid var(--glass-border);
  position: sticky; top: 0;
  background: var(--card-solid);
  z-index: 2;
  display: flex; flex-direction: column; gap: var(--space-4);
}
.preview-section { padding: 0; border-bottom: 1px solid var(--glass-border); }
.preview-section.collapsed .preview-fields,
.preview-section.collapsed .preview-empty-hint { display: none; }
.preview-section-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: 0;
  color: var(--foreground); padding: var(--space-3) var(--panel-pad);
  cursor: pointer; font: 600 13px var(--font);
}
.preview-section-toggle:hover { color: var(--foreground); background: var(--hover-fill); }
.preview-section-action {
  font: 500 12px var(--font); color: var(--primary);
}
.preview-section.collapsed .preview-section-action::after { content: none; }
.preview-fields { padding: 0 var(--panel-pad) var(--panel-pad); }
.preview-field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--space-3); }
.preview-field:last-child { margin-bottom: 0; }
.preview-field label {
  font: 500 12px var(--font); color: var(--muted-foreground);
}
.preview-field input,
.preview-field select {
  font: 12.5px var(--font);
  padding: 0 10px;
}
.preview-empty-hint { padding: 0 var(--panel-pad) var(--panel-pad); }

.preview-canvas {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--stage-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
  overflow: hidden;
}
.preview-toolbar {
  flex-shrink: 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2);
  padding: 10px 14px;
  background: var(--card-solid);
  border-bottom: 1px solid var(--glass-border);
}
.preview-toolbar .seg { min-height: 32px; width: auto; }
.preview-toolbar .seg button { flex: 0 0 auto; padding: 0 12px; }
.preview-hide-phone { margin-left: 4px; }
.preview-canvas[data-scene="image"] .preview-hide-phone { display: none; }
.preview-toolbar .live-preview-status {
  position: static; margin-left: auto;
}
.preview-canvas-inner {
  flex: 1; min-height: 0;
  overflow: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.preview-canvas[data-scene="image"] .preview-canvas-inner {
  align-items: center;
}
.preview-empty {
  color: var(--muted-foreground);
  font: 500 13px var(--font);
  text-align: center;
  max-width: 280px;
  margin: auto;
}
.live-preview-frame {
  position: relative;
  display: none;
  flex-direction: column;
  gap: 8px;
  width: min(860px, 100%);
}
.preview-canvas[data-scene="image"] .live-preview-frame,
.preview-canvas[data-scene="all"] .live-preview-frame,
.preview-canvas[data-scene="card"] .live-preview-frame {
  display: flex;
}
.preview-canvas[data-scene="email"] .live-preview-frame { display: none; }
.live-preview-frame .preview-jpeg {
  display: block; border: 0; background: #111;
  width: 100%; height: auto;
  max-height: min(560px, 68vh);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,.08);
}
.preview-canvas[data-scene="image"] .live-preview-frame {
  flex: 1 1 auto;
  width: min(960px, 100%);
}
.preview-canvas[data-scene="image"] .live-preview-frame .preview-jpeg {
  max-height: calc(100vh - 200px);
  border-radius: 8px;
}
.live-preview-status {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--popover);
  border: 1px solid var(--glass-border);
  color: var(--muted-foreground);
  font: 500 11px var(--font);
  pointer-events: none;
  white-space: nowrap;
}
.preview-disclaimer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  text-align: center;
  color: var(--faint);
  font: 400 12px var(--font);
}

.preview-mocks {
  display: none;
  flex-direction: column;
  gap: 32px;
  width: 100%;
}
.preview-mock-group {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 36px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}
.preview-mock-group[data-group="ios"],
.preview-mock-group[data-group="android"] {
  flex-wrap: nowrap;
}
.preview-canvas:not([data-scene="image"]) .preview-mocks { display: flex; }
.preview-canvas[data-scene="card"] [data-mock^="email"],
.preview-canvas[data-scene="email"] [data-mock^="card"] { display: none; }
.preview-canvas[data-hide-phone="1"] .preview-mock[data-device="phone"] { display: none; }
.preview-mock { display: flex; flex-direction: column; gap: 10px; }
.preview-mock-kicker {
  margin: 0;
  font: 600 11px var(--font);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  text-align: center;
}

/* ── phone chrome ────────────────────────────────────────── */
.phone { width: 300px; }
.phone-bezel {
  position: relative;
  background: #1c1c1e;
  border-radius: 40px;
  padding: 12px 10px 10px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.12);
}
.phone-island {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 24px; border-radius: 14px; background: #000; z-index: 2;
}
.phone-hole { display: none; }
.phone-screen {
  position: relative;
  aspect-ratio: 390 / 844;
  height: auto;
  border-radius: 30px;
  overflow: hidden;
  background: #f2f2f7;
  color: #1c1c1e;
  display: flex; flex-direction: column;
}
.phone-status {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 6px;
  font: 600 11px var(--font);
  color: #1c1c1e;
  flex-shrink: 0;
}
.phone-status-icons {
  width: 46px; height: 10px;
  background:
    linear-gradient(#1c1c1e, #1c1c1e) 0 2px / 10px 6px no-repeat,
    linear-gradient(#1c1c1e, #1c1c1e) 14px 1px / 8px 8px no-repeat,
    linear-gradient(#1c1c1e, #1c1c1e) 28px 0 / 18px 10px no-repeat;
  opacity: .85;
}
.phone-feed { flex: 1; min-height: 0; overflow: hidden; padding: 8px 12px 16px; }
.phone-feed.banner { display: flex; flex-direction: column; gap: 10px; }

.sk {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, #e6e6ea 0%, #f3f3f6 40%, #e6e6ea 80%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.5s ease-in-out infinite;
}
@keyframes sk-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.sk-appbar {
  display: grid;
  grid-template-columns: 28px 1fr 22px;
  gap: 8px;
  align-items: center;
  padding: 4px 2px 8px;
}
.sk-avatar { width: 28px; height: 28px; border-radius: 50%; }
.sk-appbar-copy { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sk-icon { width: 22px; height: 22px; border-radius: 6px; }
.sk-line { height: 8px; width: 100%; }
.sk-line.w35 { width: 35%; }
.sk-line.w40 { width: 40%; }
.sk-line.w45 { width: 45%; }
.sk-line.w55 { width: 55%; }
.sk-line.w70 { width: 70%; }
.sk-line.w80 { width: 80%; }
.sk-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.phone.android .sk-card { border-radius: 12px; }
.sk-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
}
.sk-media.short { aspect-ratio: 16 / 7; }

.phone-home {
  flex-shrink: 0; height: 18px;
  display: flex; align-items: center; justify-content: center;
}
.phone-home::after {
  content: ''; width: 108px; height: 4px; border-radius: 4px; background: #1c1c1e;
}
.phone-nav { display: none; }
.phone.android .phone-nav {
  display: flex; justify-content: space-around; align-items: center;
  height: 28px; flex-shrink: 0; color: #444;
}
.phone.android .phone-nav::before {
  content: '◁   ○   ▢';
  font-size: 11px; letter-spacing: 10px; opacity: .55;
}
.phone.android .phone-home { display: none; }

.phone.android .phone-bezel {
  border-radius: 24px;
  padding: 10px 8px 14px;
  background: #111;
}
.phone.android .phone-island { display: none; }
.phone.android .phone-hole {
  display: block;
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%; background: #000; z-index: 2;
}
.phone.android .phone-screen {
  border-radius: 16px;
  background: #f6f6f6;
}
.phone.android .phone-status { padding: 14px 16px 4px; font-weight: 500; }

.ccard.banner {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 14px;
  overflow: hidden;
  line-height: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.phone.android .ccard.banner {
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 6px 18px rgba(0,0,0,.1);
}
.ccard.banner .preview-jpeg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Gmail phone ─────────────────────────────────────────── */
.phone-screen.gmail-phone { background: #fff; }
.gmail-m-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 8px;
  flex-shrink: 0;
}
.gmail-m-back {
  width: 10px; height: 10px;
  border-left: 2px solid #5f6368;
  border-bottom: 2px solid #5f6368;
  transform: rotate(45deg);
  margin: 4px 6px 0 2px;
}
.gmail-m-actions {
  width: 92px; height: 14px;
  background:
    linear-gradient(#5f6368, #5f6368) 0 2px / 16px 10px no-repeat,
    linear-gradient(#5f6368, #5f6368) 28px 1px / 12px 12px no-repeat,
    radial-gradient(circle, #5f6368 1.4px, transparent 1.5px) 58px 3px / 28px 8px no-repeat;
  opacity: .7;
}
.gmail-m-msg { flex: 1; min-height: 0; overflow: auto; padding: 2px 0 12px; }
.gmail-m-subject {
  margin: 0 16px 12px;
  font: 400 20px/1.25 'Google Sans', var(--font);
  color: #202124;
}
.gmail-m-from, .gmail-web-from {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 0 16px 12px;
}
.gmail-avatar, .gmail-web-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #d93025; color: #fff;
  display: grid; place-items: center;
  font: 600 14px var(--font);
}
.gmail-from-name { margin: 0; font: 600 13px var(--font); color: #202124; }
.gmail-from-email { font-weight: 400; color: #5f6368; font-size: 11px; }
.gmail-from-addr { margin: 1px 0 0; font: 400 12px var(--font); color: #5f6368; }
.gmail-m-from-meta { min-width: 0; }
.gmail-m-date { font: 400 11px var(--font); color: #5f6368; align-self: start; padding-top: 2px; }
.gmail-body { line-height: 0; background: #fff; }
.gmail-body .preview-jpeg { display: block; width: 100%; height: auto; }

/* ── Gmail web ───────────────────────────────────────────── */
.gmail-web {
  width: min(720px, 100%);
  background: #fff;
  color: #202124;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid #dadce0;
}
.preview-mock[data-mock="email-web"] {
  flex: 1 1 640px;
  max-width: 760px;
}
.gmail-web-top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: #f6f8fc;
  border-bottom: 1px solid #e8eaed;
}
.gmail-logo {
  display: flex; align-items: center; gap: 6px;
  font: 400 18px 'Product Sans', var(--font);
  color: #5f6368;
  white-space: nowrap;
}
.gmail-logo b {
  width: 28px; height: 22px; border-radius: 4px;
  background: #ea4335; color: #fff;
  display: grid; place-items: center;
  font: 700 14px Georgia, serif;
}
.gmail-search {
  flex: 1;
  background: #eaf1fb;
  border-radius: 8px;
  padding: 10px 16px;
  font: 400 13px var(--font);
  color: #5f6368;
}
.gmail-web-top .gmail-web-avatar { width: 32px; height: 32px; font-size: 12px; }
.gmail-web-app { display: grid; grid-template-columns: 180px 1fr; min-height: 340px; }
.gmail-web-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 12px 16px 8px;
  font: 500 13px var(--font); color: #202124;
}
.gmail-compose {
  align-self: flex-start;
  background: #c2e7ff;
  color: #001d35;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 16px;
  margin: 0 0 10px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.gmail-web-nav span:not(.gmail-compose) {
  padding: 8px 16px 8px 20px;
  border-radius: 0 18px 18px 0;
}
.gmail-web-nav .on {
  background: #d3e3fd;
  font-weight: 700;
}
.gmail-web-read { padding: 8px 24px 28px; min-width: 0; }
.gmail-web-subject {
  margin: 8px 0 16px;
  font: 400 22px/1.3 var(--font);
  font-weight: 400;
}
.gmail-web-from { padding: 0 0 16px; }
.gmail-body.web {
  max-width: 560px;
  border: 1px solid #e8eaed;
  border-radius: 2px;
  overflow: hidden;
}

[data-theme="light"] .phone-bezel { box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(0,0,0,.12); }

.preview-sample {
  display: flex; flex-direction: column; gap: var(--space-2);
}
.preview-sample-actions {
  display: flex; gap: var(--space-2); align-items: stretch;
}
.preview-sample-actions .btn { justify-content: center; }
#btnSampleUser { flex: 1; }
#btnClearPreviewUser { flex: 0 0 auto; }
.preview-sample .hint { margin: 0; }
.preview-braze-load {
  display: flex; flex-direction: column; gap: var(--space-2);
  margin: 0;
}
.preview-braze-load .lbl {
  display: block; margin: 0;
  font: 500 12px var(--font);
  letter-spacing: 0; text-transform: none;
  color: var(--muted-foreground);
}
.preview-braze-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: var(--space-2); align-items: center;
}
.preview-braze-row select,
.preview-braze-row input {
  font: 12.5px var(--font);
}
.preview-braze-row input { padding: 0 10px; }
.preview-braze-row .btn { height: var(--control-h); }
.preview-braze-load .hint { margin: 0; }

/* ── Braze integration page ──────────────────────────────── */
.braze-screen {
  --braze-left: 280px;
  display: grid;
  grid-template-columns: var(--braze-left) 12px minmax(0, 1fr);
  gap: 0;
  column-gap: 4px;
  padding: var(--layout-gap);
  flex: 1; min-height: 0;
}
.braze-screen.hidden { display: none !important; }
.braze-side {
  overflow-y: auto;
  min-width: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}
.braze-side .field { margin: 0; }
.braze-side select { width: 100%; }
.ws-name {
  margin: 0;
  font: 600 14px/1.35 var(--font);
  color: var(--foreground);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.braze-side .field span {
  font: 500 12px var(--font);
  letter-spacing: 0; text-transform: none;
  color: var(--muted-foreground);
}
.braze-screen input:focus,
.braze-screen select:focus,
.braze-screen textarea:focus,
.preview-braze-row input:focus,
.preview-braze-row select:focus {
  border-color: var(--braze);
  box-shadow: 0 0 0 3px var(--braze-ring), inset 0 1px 2px #00000040;
}
.braze-main {
  overflow-y: auto;
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-4);
  background: var(--stage-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}
.braze-card {
  background: var(--glass);
  border: 1px solid var(--braze-card-border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.braze-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  margin: 0;
}
.braze-card-head > div {
  display: flex; flex-direction: column; gap: var(--space-1);
}
.braze-card-head h2 {
  font: 600 16px var(--font); color: var(--foreground); margin: 0;
  letter-spacing: -0.02em;
}
.braze-howto {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: 14px 16px;
  background: var(--braze-soft);
  border: 1px solid var(--braze-border);
  border-radius: var(--radius-sm);
}
.braze-howto p {
  margin: 0;
  font: 400 13.5px/1.45 var(--font);
  color: var(--foreground);
}
.braze-howto .braze-liquid {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  background: var(--input-bg);
  border: 1px solid var(--braze-border);
  border-radius: var(--radius-sm);
  font: 500 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  cursor: pointer;
}
.braze-howto .braze-liquid:hover { border-color: var(--braze); }
#brazeBlockName[readonly] {
  opacity: .8;
  cursor: default;
}
.braze-steps {
  display: flex; gap: 0; margin: 0; padding: 0;
  list-style: none;
}
.braze-steps li {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px 12px;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  color: var(--muted-foreground);
}
.braze-steps li:hover { color: var(--foreground); }
.braze-steps li.on {
  color: var(--foreground);
  border-bottom-color: var(--foreground);
}
.braze-steps li.done { color: var(--foreground); }
.braze-step-n {
  font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint);
}
.braze-steps li.on .braze-step-n { color: var(--foreground); }
.braze-step-t { font: 600 14px var(--font); }
.braze-tpl-summary {
  display: flex; flex-direction: column; gap: var(--space-3);
}
.braze-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
  width: 100%;
}
.braze-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  cursor: pointer;
  box-shadow: var(--control-inset);
}
.braze-choice:hover { border-color: var(--braze-border); }
.braze-choice.on {
  border-color: var(--braze);
  background: var(--braze-soft);
  box-shadow: none;
}
.braze-choice strong { font: 600 14px var(--font); }
.braze-choice span {
  font: 400 12.5px/1.4 var(--font);
  color: var(--muted-foreground);
}
.braze-linked-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--braze-soft);
  color: var(--foreground);
  border: 1px solid var(--braze-border);
}
.braze-advanced {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}
.braze-advanced summary {
  cursor: pointer;
  font: 500 13px var(--font);
  color: var(--muted-foreground);
}
.braze-advanced summary:hover { color: var(--foreground); }
.braze-advanced .stack,
.braze-advanced .braze-preview-wrap { margin-top: var(--space-3); }
.braze-note {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: 0; padding: var(--space-3);
  background: var(--notice-bg); color: var(--notice-fg);
  border: 1px solid var(--notice-border);
  border-radius: var(--radius-sm);
  font: 500 12.5px var(--font);
  line-height: 1.4;
}
.braze-note.hidden { display: none; }
.braze-note p { margin: 0; flex: 1; min-width: 0; }
.braze-preview-wrap { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.braze-block-kind,
.braze-block-mode {
  margin: 0;
  align-self: flex-start;
  width: max-content;
}
.braze-block-kind button,
.braze-block-mode button {
  flex: 0 0 auto;
  padding: 0 14px;
}
.braze-block-kind button.on,
.braze-block-mode button.on {
  background: var(--braze);
  color: var(--braze-foreground);
}
.braze-create {
  display: flex; flex-direction: column; gap: var(--space-3);
  align-items: flex-start;
}
.braze-create > .stack,
.braze-create > .braze-preview-wrap,
.braze-create > .braze-result,
.braze-create > .braze-choices,
.braze-create > .braze-advanced {
  align-self: stretch;
  width: 100%;
}
.braze-create-actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  align-self: flex-start;
  width: auto;
}
.braze-create-actions .btn {
  width: auto; flex: 0 0 auto;
  padding: 0 16px;
}
.braze-list-hint { margin: 0; }
.braze-preview-wrap .braze-code { max-height: 220px; }
.braze-result {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0; padding: var(--space-3);
  background: var(--success-soft); border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
}
.braze-liquid {
  font: 500 12.5px var(--mono); color: var(--success-fg);
  user-select: all;
}
.braze-list-wrap { margin: 0; }
.braze-list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0;
}
.braze-list-head h3 {
  font: 600 11px var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-foreground); margin: 0;
}
.braze-block-picker { margin: 0; gap: 0; }
.braze-block-picker-lbl {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin: 0 0 6px;
  font: 500 12px var(--font); letter-spacing: 0; text-transform: none;
  color: var(--muted-foreground);
}
.braze-block-picker input[type=search] {
  width: 100%; max-width: none;
}
.braze-block-picker.open input[type=search] {
  border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}
.braze-block-picker.open input[type=search]:focus,
.braze-block-picker.open:focus-within input[type=search] {
  border-color: var(--braze);
  border-bottom-color: transparent;
  box-shadow: none;
}
.braze-block-picker .braze-list {
  display: none;
}
.braze-block-picker.open .braze-list {
  display: block;
  max-height: 280px; overflow-y: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--popover);
}
.braze-block-picker.open:focus-within .braze-list {
  border-color: var(--braze);
}
.braze-list-empty {
  margin: 0; padding: 12px;
  color: var(--muted-foreground);
  font: 400 12px var(--font);
}
.braze-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
  color: var(--foreground); padding: 9px 12px; cursor: pointer;
  font: 500 12.5px var(--font);
}
.braze-list-row:last-child { border-bottom: 0; }
.braze-list-row:hover { background: var(--braze-soft); }
.braze-list-row.active { background: var(--braze-soft); }
.braze-list-row .muted { color: var(--muted-foreground); font: 400 11px var(--mono); }
.braze-code {
  max-height: 220px; overflow: auto;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3); font: 11.5px/1.5 var(--mono); color: var(--foreground-secondary);
  white-space: pre-wrap; margin: 0; user-select: all;
}

