.frame-delete-menu{position:fixed;z-index:999999;display:flex;flex-direction:column;min-width:190px;padding:6px;background:var(--panel);color:var(--text);border:1px solid var(--border);border-radius:14px;box-shadow:0 8px 28px #0002}
.frame-delete-menu button{border:0;background:transparent;color:inherit;text-align:left;border-radius:8px;min-height:46px;padding:12px 16px;font:inherit;cursor:pointer}
.frame-delete-menu button:hover,.frame-delete-menu button:focus-visible{background:var(--surface);outline:2px solid var(--accent);outline-offset:-2px}
.frame-delete-menu button:disabled{opacity:.45;cursor:default}
.frame-delete-menu button{display:flex;align-items:center;gap:12px}
.frame-delete-menu .material-icons{width:22px;height:22px;flex:0 0 22px}
#frame-browser-panel { display:none; min-height:0; flex:1; flex-direction:column; }
#frame-browser-panel[hidden] { display:none !important; }
.frame-browser-controls { display:flex; flex-wrap:wrap; gap:8px; padding:14px 12px 8px; }
.frame-browser-search { width:100%; min-width:0; height:44px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); font:inherit; font-size:13px; }
.frame-browser-body { flex:1; min-height:0; overflow-y:auto; padding:4px 12px 16px; }
.frame-browser-body h3 { margin:0; font-size:14px; line-height:1.4; }
.frame-browser-section { margin-bottom:16px; }
.frame-browser-section-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px; }
.frame-browser-see-all,.frame-browser-secondary { min-height:44px; padding:8px; border:0; border-radius:6px; background:transparent; color:var(--text-dim); font:inherit; font-size:12px; cursor:pointer; }
.frame-browser-see-all:hover,.frame-browser-secondary:hover { background:var(--surface-hover); color:var(--text); }
.frame-browser-secondary[hidden] { display:none; }
.frame-browser-search:focus-visible,.frame-browser-see-all:focus-visible,.frame-browser-secondary:focus-visible,.frame-browser-tile:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.frame-browser-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding-top:10px; }
.frame-browser-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
.frame-browser-tile { position:relative; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; min-width:0; width:100%; gap:6px; padding:6px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text); font:inherit; font-size:12px; cursor:pointer; }
.frame-browser-tile:hover { border-color:var(--accent-border); background:var(--surface-hover); }
.frame-browser-tile > span { width:100%; overflow-wrap:anywhere; line-height:1.4; }
.frame-browser-preview { width:100%; min-width:0; overflow:hidden; flex-shrink:0; }
.frame-browser-row .frame-browser-tile > span { font-size:11px; }
.frame-browser-empty { margin:20px 0; color:var(--text-dim); font-size:13px; line-height:1.5; }
@media(min-width:761px) { #library-content[data-tool-group="Frames"][data-browse-view="detail"] #frame-browser-panel:not([hidden]) { display:flex; } }

.frame-browser-row .frame-browser-tile { padding:2px; border-color:transparent; background:transparent; }
.frame-browser-row .frame-browser-tile > span:not(.frame-browser-pro-badge) { display:none; }
.frame-browser-pro-badge { position:absolute; top:3px; right:3px; width:auto !important; padding:2px 4px; border-radius:4px; background:var(--surface); color:var(--text); border:1px solid var(--border); font-size:12px; font-weight:600; }

.frame-browser-status { flex-basis:100%; margin:0; color:var(--text-dim); font-size:12px; line-height:1.4; }
.frame-browser-controls button:disabled { opacity:.5; cursor:default; }
#library-content.inline-crop-mode > :not(#inline-frame-crop){display:none!important}
#inline-frame-crop{padding:20px;display:flex;flex-direction:column;gap:24px;flex:1;min-height:0;overflow:auto}
#inline-frame-crop[hidden]{display:none}
#inline-frame-crop header,#inline-frame-crop footer{display:flex;align-items:center;justify-content:space-between;gap:12px}
#inline-frame-crop h2{margin:0;font-size:20px}
#inline-frame-crop p{margin:0;color:var(--text-secondary);line-height:1.5}
#inline-frame-crop label{display:flex;flex-wrap:wrap;align-items:center;gap:12px;font-weight:600}
#inline-frame-crop input{width:100%;accent-color:var(--accent)}
#inline-frame-crop select{flex:1;min-height:44px}
#inline-frame-crop output{margin-left:auto;font-size:13px}
#inline-frame-crop button{min-height:44px;padding:10px 16px;border:1px solid var(--border);border-radius:10px;background:var(--panel);color:var(--text);cursor:pointer}
#inline-frame-crop footer{margin-top:auto}
#inline-frame-crop [data-done]{background:var(--accent);color:white;flex:1}
.inline-crop-overlay{position:absolute;inset:0;z-index:50;touch-action:none;cursor:move;outline:2px solid var(--accent);overflow:visible}
.inline-crop-preview{position:absolute;inset:0;pointer-events:none}
.inline-crop-ghost{position:absolute;max-width:none!important;opacity:.25;pointer-events:none}
.frame-drop-target{outline:3px solid var(--accent)!important;outline-offset:-3px;filter:brightness(1.05)}
.inline-crop-active > :not(.inline-crop-overlay){opacity:0!important}
.inline-crop-overlay{visibility:visible}

body.inline-frame-cropping .tm-selection{display:none!important}
.frame-hover-preview{position:absolute;inset:0;pointer-events:none;z-index:40}
.frame-hover-previewing > :not(.frame-hover-preview){opacity:0!important}
.frame-drag-source{opacity:.35!important}
#drawing-controls {
  --draw-paper: #ffffff;
  --draw-ink: #283241;
  --draw-muted: #657181;
  --draw-line: #e4e8ed;
  --draw-accent: #b51b2b;
  position: fixed;
  left: 94px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--draw-ink);
  font-family: inherit;
}
#drawing-controls[hidden], #drawing-controls [hidden] { display: none; }
#drawing-controls .draw-settings [hidden] { display: none; }
:root[data-theme="dark"] #drawing-controls {
  --draw-paper: #25262c;
  --draw-ink: #f1f3f6;
  --draw-muted: #b3bac7;
  --draw-line: #454953;
}
.drawing-active #library, .drawing-active #inspector { display: none; }
.drawing-active #center { margin-left: var(--draw-workspace-left, 0px); margin-bottom: var(--draw-workspace-bottom, 0px); }
.drawing-active #zoom-bar { visibility: hidden; }
#drawing-controls .draw-rail, #drawing-controls .draw-settings {
  background: var(--draw-paper);
  border: 1px solid var(--draw-line);
  box-shadow: 0 12px 32px #18233714, 0 2px 6px #18233708;
}
#drawing-controls .draw-rail { width: 96px; padding: 10px; border-radius: 24px; display: flex; flex-direction: column; gap: 4px; }
#drawing-controls button { background: transparent; color: inherit; border: 0; border-radius: 10px; padding: 8px; min-height: 44px; cursor: pointer; font: inherit; }
#drawing-controls button:hover { background: #b51b2b0c; }
#drawing-controls button:focus-visible { outline: 2px solid var(--draw-accent); outline-offset: 3px; }
#drawing-controls button:disabled { opacity: .35; cursor: default; }
#drawing-controls .draw-brush { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 2px 8px; font-size: 12px; min-height: 66px; }
#drawing-controls .draw-brush img { width: 76px; height: 46px; transition: transform 140ms ease; }
#drawing-controls .draw-brush[aria-pressed="true"] { background: #b51b2b0d; color: var(--draw-accent); box-shadow: inset 3px 0 var(--draw-accent); }
#drawing-controls .draw-brush[aria-pressed="true"] img { transform:none; }
:root[data-theme="dark"] #drawing-controls .draw-brush[aria-pressed="true"] { color: #ff9aa5; box-shadow: inset 3px 0 #ff9aa5; }
#drawing-controls .draw-history { display: flex; border-top: 1px solid var(--draw-line); padding-top: 6px; }
#drawing-controls .draw-history button { flex: 1; font-size: 22px; }
#drawing-controls .draw-actions { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; border-top: 1px solid var(--draw-line); }
#drawing-controls .draw-actions button { font-size: 12px; }
#drawing-controls .draw-confirm { background: var(--draw-accent); color: #fff; font-weight: 600; }
#drawing-controls .draw-confirm:hover { background: #941624; color: #fff; }
#drawing-controls .draw-settings { width: 248px; border-radius: 16px; padding: 18px; }
#drawing-controls .draw-settings h3 { margin: 0; font-size: 15px; font-weight: 650; }
#drawing-controls .draw-settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 1; background: var(--draw-paper); }
#drawing-controls [data-drawing-close-settings] { min-width: 52px; font-size: 12px; color: var(--draw-ink); }
#drawing-controls .draw-preview { display: block; width: 100%; height: 48px; margin: 10px 0 14px; background: repeating-linear-gradient(0deg,transparent,transparent 15px,#6571810b 15px,#6571810b 16px); border-radius: 8px; }
#drawing-controls .draw-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
#drawing-controls .draw-swatches button { width: 44px; height: 44px; min-height: 44px; padding: 0; border: 8px solid var(--draw-paper); border-radius: 50%; box-shadow: 0 0 0 1px var(--draw-line); }
#drawing-controls .draw-swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--draw-ink); }
#drawing-controls .draw-settings label { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 12px; color: var(--draw-muted); }
#drawing-controls output { color: var(--draw-ink); font-variant-numeric: tabular-nums; }
#drawing-controls input[type="range"] { width: 100%; accent-color: var(--draw-accent); margin: 0; height: 44px; }
#drawing-controls .draw-color { width: 44px; height: 44px; border: 1px solid var(--draw-line); border-radius: 8px; padding: 6px; background: var(--draw-paper); }
#drawing-controls .draw-hint { font-size: 12px; color: var(--draw-muted); line-height: 1.5; margin: 12px 0 0; }
#drawing-controls [data-drawing-open-color] { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; }
#drawing-controls [data-paint-only][hidden] { display: none; }
#drawing-controls .draw-current-color { width: 18px; height: 18px; border-radius: 50%; background: #b51b2b; border: 1px solid var(--draw-line); }
#drawing-controls .draw-touch-help { display: none; }
@media(max-width:700px) {
  .drawing-active #center { padding-bottom: 0; }
  #drawing-controls { left: 12px; right: 12px; top: auto; bottom: 16px; transform: none; flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  #drawing-controls .draw-rail { width: auto; border-radius: 20px; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; padding: 8px; align-items: center; }
  #drawing-controls .draw-brush { padding: 4px 1px; font-size: 11px; min-height: 54px; }
  #drawing-controls .draw-brush img { width: 48px; height: 32px; }
  #drawing-controls .draw-brush[aria-pressed="true"] { box-shadow: inset 0 -2px var(--draw-accent); }
  #drawing-controls .draw-history { grid-column: 3 / -1; flex-direction: row; border: 0; padding: 0; }
  #drawing-controls .draw-history button { padding: 0; min-height: 44px; }
  #drawing-controls .draw-actions { grid-column: 1 / -1; flex-direction: row; border: 0; padding-top: 4px; gap: 8px; }
  #drawing-controls .draw-actions button { flex: 1; min-height: 44px; }
  #drawing-controls .draw-settings { width: auto; padding: 12px 16px; max-height: 30vh; overflow-y: auto; }
  #drawing-controls .draw-preview { height: 24px; margin: 8px 0 12px; }
  #drawing-controls .draw-mouse-help { display: none; }
  #drawing-controls .draw-touch-help { display: block; }
}
@media(prefers-reduced-motion:reduce) { #drawing-controls .draw-brush img { transition: none; } }

#drawing-controls .draw-tool-art { display:block; position:relative; width:76px; height:46px; overflow:hidden; flex-shrink:0; }
#drawing-controls .draw-tool-art .approved-artwork { position:absolute; max-width:none; height:auto; object-fit:contain; transform:none; transition:none; }
@media(max-width:700px) { #drawing-controls .draw-tool-art { width:48px; height:32px; } }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Light is the primary theme (matches posterkaaran.com's brand palette —
   maroon/orange on warm white). Dark stays available as an opt-in via
   [data-theme="dark"] on <html>, preserving every value from the original
   dark redesign unchanged so switching back looks exactly as before. */
:root {
  --app-header-height: 64px;
  --nav-width: 76px;
  --library-width: 314px;
  --inspector-width: 328px;

  --workspace: #f1ece3;
  --canvas-bg: #ffffff;
  --canvas-shadow: 0 20px 60px rgba(162, 29, 40, 0.12), 0 0 0 1px rgba(162, 29, 40, 0.08);
  --panel-glass: rgba(255, 255, 255, 0.92);
  --panel-glass-strong: rgba(255, 255, 255, 0.98);
  --panel-muted: rgba(162, 29, 40, 0.045);
  --neutral-border: rgba(162, 29, 40, 0.14);
  --surface: #ffffff;
  --surface-sunken: rgba(162, 29, 40, 0.04);
  --surface-hover: rgba(162, 29, 40, 0.09);
  --surface-strong: rgba(162, 29, 40, 0.14);
  --border-subtle: rgba(162, 29, 40, 0.14);
  --border: rgba(162, 29, 40, 0.14);

  --text: #1a1a1a;
  --text-primary: #1a1a1a;
  --text-dim: #6f625f;
  --text-inverse: #ffffff;

  --accent: #A21D28;
  --accent-2: #ff9800;
  --accent-soft: rgba(162, 29, 40, 0.10);
  --accent-border: rgba(162, 29, 40, 0.30);
  --accent-gradient: linear-gradient(135deg, #A21D28 0%, #ff9800 100%);
  --accent-gradient-hover: linear-gradient(135deg, #8a1721 0%, #e68600 100%);
  --guest-badge-gradient: linear-gradient(135deg, #ff9800, #A21D28, #7d1520);
  --badge-pro-bg: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  --badge-pro-text: #ffffff;

  --focus-ring: 0 0 0 3px rgba(162, 29, 40, .22);
  --shadow-soft: 0 1px 12px rgba(0, 0, 0, .06);
  --shadow-med: 0 12px 36px rgba(0, 0, 0, .10);
  --shadow-strong: 0 18px 44px rgba(0, 0, 0, .16);

  --checker-a: rgba(0, 0, 0, 0.06);
  --checker-b: #ffffff;

  --status-success-bg: rgba(22, 163, 74, 0.10); --status-success-text: #15803d;
  --status-warning-bg: rgba(217, 119, 6, 0.10); --status-warning-text: #b45309;
  --status-danger-bg: rgba(220, 38, 38, 0.10);  --status-danger-text: #dc2626;
  --status-dirty-bg: var(--accent-soft);        --status-dirty-text: var(--accent);
  --avatar-bg: #0f7a1a;

  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] {
  --workspace: #141113;
  --canvas-bg: #1f1b1e;
  --canvas-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --panel-glass: rgba(31, 27, 30, 0.85);
  --panel-glass-strong: rgba(31, 27, 30, 0.95);
  --panel-muted: rgba(255, 255, 255, 0.04);
  --neutral-border: rgba(255, 255, 255, 0.08);
  --surface: #1f1b1e;
  --surface-sunken: rgba(0, 0, 0, 0.35);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);

  --text: #f4f4f5;
  --text-primary: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-inverse: #ffffff;

  --accent: #e04854;
  --accent-2: #ffaa33;
  --accent-soft: rgba(224, 72, 84, 0.12);
  --accent-border: rgba(224, 72, 84, 0.3);
  --accent-gradient: linear-gradient(135deg, #e04854 0%, #ffaa33 100%);
  --accent-gradient-hover: linear-gradient(135deg, #d946ef 0%, #7c3aed 100%);
  --guest-badge-gradient: linear-gradient(135deg, #f7b731, #bd1f2d, #6d4aff);
  --badge-pro-bg: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --badge-pro-text: #1a1a1a;

  --focus-ring: 0 0 0 3px rgba(224, 72, 84, .18);
  --shadow-soft: 0 1px 12px rgba(0, 0, 0, .2);
  --shadow-med: 0 12px 36px rgba(0, 0, 0, .4);
  --shadow-strong: 0 18px 44px rgba(0, 0, 0, .4);

  --checker-a: rgba(255, 255, 255, 0.08);
  --checker-b: #1f1b1e;

  --status-success-bg: rgba(34, 197, 94, 0.12); --status-success-text: #4ade80;
  --status-warning-bg: rgba(245, 158, 11, 0.12); --status-warning-text: #fbbf24;
  --status-danger-bg: rgba(239, 68, 68, 0.12);  --status-danger-text: #f87171;
  --status-dirty-bg: rgba(224, 72, 84, 0.12);  --status-dirty-text: #f472b6;
  --avatar-bg: #07810f;

  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
}

/* Required empty-editor entry point and reusable New design chooser. */
.create-design-chooser {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 15, 15, 0.54);
  backdrop-filter: blur(10px);
}

.create-design-panel {
  width: min(940px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--neutral-border);
  border-radius: 24px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-strong);
}

.create-design-header { display: flex; justify-content: space-between; gap: 24px; padding: 30px 32px 18px; }
.create-design-header h1 { margin: 2px 0 6px; font-size: clamp(26px, 4vw, 38px); line-height: 1.08; }
.create-design-header p { margin: 0; color: var(--text-dim); }
.create-design-eyebrow { color: var(--accent) !important; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.create-design-close { flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid var(--neutral-border); border-radius: 50%; background: var(--panel-muted); color: var(--text-primary); cursor: pointer; }

.create-design-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 0 32px 16px; border-bottom: 1px solid var(--neutral-border); }
.create-design-tabs button { flex: 0 0 auto; padding: 10px 14px; border: 1px solid var(--neutral-border); border-radius: 999px; background: transparent; color: var(--text-dim); font: inherit; font-weight: 700; cursor: pointer; }
.create-design-tabs button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.create-design-content { min-height: 330px; padding: 24px 32px; }
.create-design-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.create-design-grid[hidden], .create-design-custom[hidden] { display: none !important; }
.create-design-card { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--neutral-border); border-radius: 16px; background: var(--canvas-bg); color: var(--text-primary); text-align: left; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.create-design-card:hover { transform: translateY(-2px); border-color: var(--accent-border); box-shadow: var(--shadow-soft); }
.create-design-card-icon { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.create-design-card-copy { min-width: 0; display: grid; gap: 4px; }
.create-design-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.create-design-card-copy small { color: var(--text-dim); font-size: 11px; }
.create-design-card-arrow { margin-left: auto; color: var(--text-dim); font-size: 18px; }
.create-design-custom { max-width: 680px; margin: 24px auto; display: flex; flex-direction: column; gap: 16px; }
.create-design-custom label { display: grid; gap: 7px; color: var(--text-dim); font-size: 13px; font-weight: 700; }
.create-design-custom input, .create-design-custom select { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--neutral-border); border-radius: 12px; background: var(--canvas-bg); color: var(--text-primary); font: inherit; transition: border-color .15s ease; }
.create-design-custom input:focus, .create-design-custom select:focus { outline: none; border-color: var(--accent); }
.create-design-dims-row { display: grid; grid-template-columns: 1fr auto 1fr auto 130px; align-items: end; gap: 8px; }
.create-design-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--neutral-border); border-radius: 12px; background: var(--panel-muted); color: var(--text-dim); cursor: pointer; transition: all .16s ease; flex-shrink: 0; }
.create-design-icon-btn:hover { background: var(--canvas-bg); color: var(--text-primary); border-color: var(--accent); }
.create-design-icon-btn.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.create-design-meta-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-radius: 10px; background: var(--panel-muted); color: var(--text-dim); font-size: 12px; }
.create-design-meta-info strong { color: var(--text-primary); font-weight: 600; }
.create-design-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.create-design-chip { padding: 5px 10px; border: 1px solid var(--neutral-border); border-radius: 999px; background: var(--panel-muted); color: var(--text-primary); font-size: 11px; font-weight: 600; cursor: pointer; transition: all .14s ease; }
.create-design-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.create-design-primary { padding: 14px 18px; border: 0; border-radius: 12px; background: var(--accent-gradient); color: white; font: inherit; font-weight: 800; cursor: pointer; transition: opacity .16s ease; }
.create-design-primary:hover { opacity: .92; }
.create-design-error { margin: 0; color: var(--status-danger-text); font-size: 13px; font-weight: 600; }
.create-design-footer { padding: 16px 32px 24px; color: var(--text-dim); text-align: center; }
.create-design-footer a { color: var(--accent); font-weight: 800; }

/* Replace-a-saved-design chooser (askWhichDraftToReplace in main.ts). Built
   on the New design chooser's shell and the Projects tab's cards, so a full
   free shelf reads as "your designs", not as a paywall dialog. */
.draft-slots-panel { width: min(720px, 100%); }
.draft-slots-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.draft-slot-card { min-height: 104px; }
.draft-slot-card.selected { border-color: var(--accent); box-shadow: var(--focus-ring), var(--shadow-med); }
.draft-slot-card.selected .project-card-title { color: var(--accent); }
.draft-slots-footer { display: grid; gap: 10px; padding: 4px 32px 28px; }
.draft-slots-replace { padding: 14px 18px; border: 0; border-radius: 12px; background: var(--accent-gradient); color: white; font: inherit; font-weight: 800; cursor: pointer; transition: opacity .16s ease; }
.draft-slots-replace:hover:not(:disabled) { opacity: .92; }
.draft-slots-replace:disabled { background: var(--panel-muted); color: var(--text-dim); cursor: default; }
.draft-slots-upgrade { padding: 12px 18px; border: 1px solid var(--accent-border); border-radius: 12px; background: transparent; color: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
.draft-slots-upgrade:hover { background: var(--accent-soft); }

@media (max-width: 720px) {
  .draft-slots-grid { grid-template-columns: minmax(0, 1fr); }
  .draft-slots-footer { padding: 4px 18px 24px; }
}

@media (max-width: 720px) {
  .create-design-chooser { padding: 0; place-items: stretch; }
  .create-design-panel { width: 100%; max-height: 100vh; min-height: 100vh; border: 0; border-radius: 0; }
  .create-design-header { padding: 24px 18px 16px; }
  .create-design-tabs { padding: 0 18px 14px; }
  .create-design-content { padding: 18px; }
  .create-design-grid { grid-template-columns: 1fr; }
  .create-design-card { padding: 13px; }
  .create-design-custom { margin: 12px auto; }
  .create-design-dims-row { grid-template-columns: 1fr auto 1fr; gap: 8px; }
  .create-design-dims-row .create-design-unit-field { grid-column: 1 / -1; }
  .create-design-dims-row .create-design-lock-btn { display: none; }
  .create-design-footer { padding: 14px 18px 24px; }
}

body {
  display: block;
  min-width: 0;
  overflow: hidden;
  background: var(--workspace);
}

#app-shell {
  width: 100%;
  height: 100vh;
  /* Mobile browsers count the collapsible address bar in 100vh; dvh is the
     height actually on screen, so the zoom bar is never under the bottom nav. */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#editor-workspace {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#header {
  min-height: var(--app-header-height);
  height: var(--app-header-height);
  width: 100%;
  padding: 8px 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(max-content, 1fr);
  gap: 16px;
  align-items: center;
  position: relative;
  z-index: 1200;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--neutral-border);
  box-shadow: var(--shadow-soft);
}

#brand-area,
#document-meta,
#header-actions,
#history-controls {
  display: flex;
  align-items: center;
}

#brand-area { min-width: 0; gap: 12px; }

#brand-home {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.02em;
}

#brand-home img {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
}

#document-meta {
  min-width: 0;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--neutral-border);
}

#template-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

#status {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: var(--status-success-bg);
  color: var(--status-success-text);
  font-size: 11px;
  font-weight: 700;
}

#status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

#status[data-state="saving"] { background: var(--status-warning-bg); color: var(--status-warning-text); }
#status[data-state="dirty"] { background: var(--status-dirty-bg); color: var(--status-dirty-text); }
#status[data-state="error"] { background: var(--status-danger-bg); color: var(--status-danger-text); }

#history-controls {
  position: static;
  transform: none;
  gap: 4px;
  justify-self: center;
}

#header-actions {
  min-width: 0;
  justify-content: flex-end;
  gap: 8px;
}

#account-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#header-actions > #account-menu-wrap {
  flex: 0 0 auto;
}

.account-status {
  min-width: 162px;
  min-height: 42px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background:
    linear-gradient(var(--panel-glass-strong), var(--panel-glass-strong)) padding-box,
    var(--guest-badge-gradient) border-box;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .12);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.account-status:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
}

.account-status:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 12px 28px rgba(0, 0, 0, .18);
}

.account-status .material-icons {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  font-size: 19px;
}

.account-status-label {
  white-space: nowrap;
}

.account-status-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--text-inverse);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .02em;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.2);
}

.account-status.signed-in {
  min-width: 0;
  width: auto;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  box-shadow: none;
}

.account-status.signed-in:hover {
  box-shadow: 0 0 0 6px rgba(15, 122, 26, .15);
}

.account-status-name {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-status.signed-in .account-status-name,
.account-status.signed-in .account-status-plan {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#account-menu {
  width: min(320px, calc(100vw - 24px));
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  padding: 12px;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--neutral-border);
  border-radius: 22px;
  box-shadow: var(--shadow-strong);
  z-index: 1700;
}

#account-menu[hidden] {
  display: none;
}

#account-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 24px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  background: var(--panel-glass-strong);
  border-left: 1px solid var(--neutral-border);
  border-top: 1px solid var(--neutral-border);
}

.account-menu-card {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 2px 12px;
}

.account-menu-avatar {
  width: 74px;
  height: 74px;
  flex: 0 0 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--text-inverse);
  font-size: 36px;
  font-weight: 900;
}

.account-menu-copy {
  min-width: 0;
}

.account-menu-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 850;
}

.account-menu-email {
  max-width: 190px;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.25;
}

.account-menu-plan {
  width: max-content;
  max-width: 190px;
  margin-top: 9px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  font-size: 11px;
  font-weight: 800;
}

.account-menu-plan.pro {
  background: var(--accent-soft);
  color: var(--accent);
}

.account-menu-action {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--neutral-border);
  border-radius: 12px;
  background: var(--panel-muted);
  color: var(--text-primary);
  font-weight: 800;
  cursor: pointer;
}

.account-menu-action:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.toolbar-btn,
#header-actions > button,
#history-controls button {
  min-width: 40px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  font-weight: 700;
}

.toolbar-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1;
  vertical-align: middle;
}

.toolbar-btn .button-label {
  display: inline-flex;
  align-items: center;
  line-height: 20px;
  white-space: nowrap;
}

.toolbar-btn.icon-only,
#history-controls button {
  width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn .material-icons,
#history-controls .material-icons {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  font-size: 20px;
}

#save {
  background: var(--panel-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

#header-actions > #download-trigger-btn {
  --export-gradient: linear-gradient(135deg, #a21d28 0%, #bd4e10 100%);
  --export-gradient-hover: linear-gradient(135deg, #8a1721 0%, #a23d0b 100%);
  background: var(--export-gradient);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 16px rgba(162, 29, 40, 0.25);
}

#header-actions > #download-trigger-btn:hover:not(:disabled) {
  background: var(--export-gradient-hover);
  color: #fff;
}

:root[data-theme="dark"] #header-actions > #download-trigger-btn {
  --export-gradient: linear-gradient(135deg, #a52b3a 0%, #99520b 100%);
  --export-gradient-hover: linear-gradient(135deg, #892132 0%, #794009 100%);
}

#more-actions-wrap { position: relative; }
/* The mobile overflow (⋯) only exists below 760px; above it, every action it
   holds has its own header button. */
#mobile-more-wrap { position: relative; display: none; }

#admin-menu,
.header-menu {
  display: none;
  width: 286px;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  padding: 8px;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  box-shadow: var(--shadow-strong);
  z-index: 1500;
}

#admin-menu.open,
.header-menu.open { display: block; }

.admin-menu-title {
  padding: 7px 9px 9px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-menu-item,
#admin-menu > button,
.header-menu > button {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  font-weight: 600;
}

#admin-menu .material-icons,
.header-menu .material-icons { width: 20px; font-size: 19px; color: var(--text-dim); }
#admin-menu > button:hover,
.header-menu > button:hover { background: var(--accent-soft); }
#admin-menu #delete-btn { color: var(--status-danger-text); }
#admin-menu #delete-btn .material-icons { color: var(--status-danger-text); }

#live-controls {
  display: none;
  padding: 8px;
  margin-top: 6px;
  gap: 7px;
  border-top: 1px solid var(--neutral-border);
}

#admin-menu.open #live-controls { display: grid; grid-template-columns: 1fr auto; }
#liveId { width: 100%; min-width: 0; grid-column: 1 / -1; }
#fetchLive, #pushLive { width: 100%; min-height: 38px; }
#upload { display: none; }
#admin-menu.open #upload { display: flex; }

#save-as-new-controls {
  display: none;
  padding: 8px;
  margin-top: 6px;
  gap: 7px;
  border-top: 1px solid var(--neutral-border);
}

#admin-menu.open #save-as-new-controls { display: grid; }
#saveAsNewId, #saveAsNewCategoryName, #saveAsNewCategoryId { width: 100%; min-width: 0; }
#saveAsNewBtn { width: 100%; min-height: 38px; }

#library {
  width: var(--library-width);
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--neutral-border);
  box-shadow: none;
}

#library-nav {
  width: var(--nav-width);
  padding: 12px 8px;
  gap: 4px;
  border-right: 1px solid var(--neutral-border);
}

.nav-tab {
  width: 60px;
  min-height: 58px;
  height: auto;
  padding: 8px 4px;
  border-radius: 12px;
  gap: 5px;
  color: var(--text-dim);
}

.nav-tab .material-icons { font-size: 22px; }
/* Keep the mask-painted nav icons (Text Art, Stickers) the same size the rule above
   gives the icon font. They are not .material-icons, so without this they keep the
   18px from .nav-icon and sit visibly smaller than every icon beside them. */
.nav-tab .nav-icon--asset { width: 22px; height: 22px; }
.nav-label { font-size: 10px; font-weight: 700; }
.nav-tab.active { box-shadow: none; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); }

.secondary-nav { margin-top: auto; }

.tab-pane h2 {
  padding: 18px 16px 12px;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-transform: none;
}

#lib-search-input {
  min-height: 40px;
  margin: 0 12px 10px;
  padding: 9px 13px 9px 36px;
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  background: var(--panel-muted);
  color: var(--text-primary);
}

.panel-subhead {
  padding: 10px 16px 6px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

#projects-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 12px 18px;
}

/* Delete control + its in-place confirm strip (see projectCardHtml). The row
   is the positioning context; the card keeps its own full-width layout. */
.project-card-row { position: relative; }
.project-card-delete {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--neutral-border); border-radius: 9px;
  background: var(--panel-muted); color: var(--text-dim);
  cursor: pointer; opacity: 0; transition: opacity .16s ease, color .16s ease, border-color .16s ease;
}
.project-card-delete .material-icons { font-size: 18px; }
.project-card-row:hover .project-card-delete,
.project-card-delete:focus-visible { opacity: 1; }
.project-card-delete:hover { color: var(--danger); border-color: var(--danger); }
.project-card-confirm {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 10px; text-align: center;
  border: 1px solid var(--danger); border-radius: 14px;
  background: var(--panel-glass-strong); color: var(--text-primary);
}
.project-card-confirm[hidden] { display: none; }
.project-card-confirm-text { font-size: 13px; font-weight: 600; }
.project-card-confirm-actions { display: flex; gap: 8px; }
.project-card-confirm-yes, .project-card-confirm-no { padding: 7px 14px; border-radius: 9px; font: inherit; font-weight: 700; cursor: pointer; }
.project-card-confirm-yes { border: 0; background: var(--danger); color: #fff; }
.project-card-confirm-yes:hover { background: var(--danger-dark); }
.project-card-confirm-no { border: 1px solid var(--neutral-border); background: var(--panel-muted); color: var(--text-primary); }
.project-card-row.deleting { opacity: .55; pointer-events: none; }

/* Touch has no hover to reveal the control, so it is always visible there —
   and bigger, since a 32px target is under the comfortable tap size. */
@media (hover: none) {
  .project-card-delete { opacity: 1; width: 40px; height: 40px; }
  .project-card-delete .material-icons { font-size: 20px; }
}

.project-card {
  width: 100%;
  min-height: 108px;
  padding: 8px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.project-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-med);
}

.project-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-med);
}

.project-card-thumb {
  width: 72px;
  height: 92px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  background: var(--panel-muted);
}

.project-card-preview {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  object-fit: cover;
}

.project-card-fallback {
  width: 34px;
  height: 34px;
  position: absolute;
  object-fit: contain;
  opacity: .65;
}

.project-card-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.project-card-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-card-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 650;
}

.preset-text-btn,
.sticker-item-btn,
.shape-item-btn,
.textart-category-btn {
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  box-shadow: none;
  background: var(--panel-muted);
  color: var(--text-primary);
}

#center {
  min-width: 0;
  min-height: 0;
  flex: 1;
  position: relative;
  background: var(--workspace);
}

#download-dropdown {
  position: fixed;
  top: calc(var(--app-header-height) + 8px);
  right: 12px;
  width: 296px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-strong);
  z-index: 1600;
}

#stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 40px 48px 28px;
  justify-content: flex-start;
  align-items: flex-start;
  background: var(--workspace);
  background-image: radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 50%), radial-gradient(circle at 80% 80%, rgba(255, 152, 0, 0.06), transparent 45%);
}

#stage-inner { margin: auto; }

.template-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--workspace) 76%, transparent);
  opacity: 0;
  transition: opacity 160ms ease;
}

.template-loading-overlay.is-visible { opacity: 1; }
.template-loading-overlay[hidden] { display: none; }

.template-loading-card {
  width: min(310px, calc(100% - 24px));
  padding: 18px 20px 20px;
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 1px solid var(--neutral-border);
  border-radius: 20px;
  background: #fff;
  color: #241713;
  text-align: center;
  box-shadow: var(--shadow-strong);
}

.template-loading-media {
  width: clamp(132px, 18vw, 190px);
  aspect-ratio: 1;
  display: block;
  object-fit: contain;
  border-radius: 14px;
}

.template-loading-media[hidden] { display: none; }

.template-loading-card p {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .template-loading-overlay { transition: none; }
}

.tm-canvas {
  background: var(--canvas-bg);
  box-shadow: var(--canvas-shadow);
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-user-drag: none !important;
}
.tm-canvas img,
.tm-bg {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-user-drag: none !important;
  -khtml-user-drag: none !important;
  -moz-user-drag: none !important;
  -o-user-drag: none !important;
}
.tm-canvas [data-layer-index] {
  pointer-events: auto;
}
.tm-canvas.is-transparent-bg {
  background-image: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) !important;
  background-size: 16px 16px !important;
  background-position: 0 0, 8px 8px !important;
}

#zoom-bar {
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 48px;
  position: static;
  align-self: center;
  margin: 0 0 16px;
  transform: none;
  z-index: 20;
  padding: 6px 8px;
  gap: 5px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-med);
}

.zoom-preset {
  min-width: 40px;
  min-height: 34px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
}

.zoom-preset.active { background: var(--accent-soft); color: var(--accent); }
#zoomSlider { width: 132px; }
#zoomPercent { min-width: 42px; text-align: center; font-weight: 700; color: var(--text-primary); }
#zoomReset { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; color: var(--text-primary); }

/* Document controls occupy their own rows below the scrollable canvas.
   Keeping them in flow reserves space even when the canvas is zoomed. */
#page-rail {
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 48px;
  position: static;
  align-self: center;
  margin: 0 0 8px;
  z-index: 20;
  padding: 6px 8px;
  gap: 6px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  border-top: 1px solid var(--neutral-border);
  background: var(--panel-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-med);
}

.page-chip {
  min-width: 34px;
  min-height: 34px;
  justify-content: center;
  padding: 0 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.page-chip:hover { background: var(--surface-hover); }
.page-chip.active { background: var(--accent-soft); color: var(--accent); }
#page-rail-list { min-width: 0; }
.page-chip-select,
.page-chip-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.page-chip-select:focus-visible,
.page-chip-action:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.page-chip-action { opacity: .7; }
.page-chip-action:hover { opacity: 1; }

#page-add-btn {
  min-height: 34px;
  padding: 5px 9px 5px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

#page-add-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--accent); }
#page-rail-note { font-weight: 600; color: var(--text-dim); }

/* Collapsible page filmstrip; shadow-root previews cannot capture editor input. */
#page-rail[hidden], #page-actions-menu[hidden] { display: none; }
#page-rail { flex-shrink: 0; }
#page-rail-list { padding: 3px; gap: 10px; }
#page-rail .page-chip {
  position: relative; flex: 0 0 120px; height: 84px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--surface-hover);
}
#page-rail .page-chip.active { border: 2px solid var(--accent); }
#page-rail .page-chip-select { position: relative; width: 100%; height: 100%; padding: 0; }
.page-thumbnail { position: absolute; inset: 0; display: block; overflow: hidden; pointer-events: none; }
.page-number { position: absolute; left: 5px; bottom: 3px; padding: 1px 4px; border-radius: 4px; background: var(--surface); color: var(--text); font-size: 11px; }
#page-rail .page-chip-action { position: absolute; right: 2px; top: 2px; min-width: 28px; min-height: 26px; padding: 1px; opacity: 1; background: var(--surface); color: var(--text); border-radius: 7px; }
#page-rail .page-chip-action:hover { background: var(--accent-soft); color: var(--accent); }
#page-add-btn { flex-shrink: 0; }
#pages-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 34px; padding: 5px 10px; border: 0; border-left: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font-weight: 600; }
#pages-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
#pages-toggle .material-icons { font-size: 19px; }
#pages-count { font-size: 12px; font-variant-numeric: tabular-nums; }
#page-actions-menu { position: fixed; z-index: 10000; width: 176px; padding: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-glass-strong); box-shadow: 0 8px 30px #0002; }
#page-rail .page-chip-action, .page-number { background: var(--panel-glass-strong); }
#page-actions-menu button { display: block; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
#page-actions-menu button:hover, #page-actions-menu button:focus-visible { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
#page-actions-menu button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 760px) {
  #zoom-bar .zoom-preset:not(#zoomFit) { display: none; }
  #zoom-bar #zoomSlider { width: 64px; min-width: 40px; }
  #pages-toggle { padding: 5px 6px; gap: 4px; }
  #pages-toggle .material-icons { display: none; }
}

#inspector {
  width: var(--inspector-width);
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--neutral-border);
  box-shadow: none;
}

#inspector-header {
  min-height: 52px;
  padding: 10px 12px 0;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--neutral-border);
}

#inspector-tabs {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.inspector-tab {
  min-height: 40px;
  padding: 8px 5px;
  position: relative;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-dim);
  font-weight: 700;
}

.inspector-tab[aria-selected="true"] { color: var(--accent); }
.inspector-tab[aria-selected="true"]::after {
  content: '';
  height: 3px;
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -1px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

#close-inspector-btn {
  display: none;
  width: 40px;
  height: 40px;
  margin-bottom: 3px;
  padding: 0;
  border: 0;
  color: var(--text-primary);
}

.inspector-panel {
  min-height: 0;
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.inspector-panel.active { display: flex; }

#editor-settings {
  min-height: 44px;
  padding: 8px 14px !important;
  border-color: var(--neutral-border) !important;
}

#layer-list {
  height: auto;
  min-height: 0;
  flex: 1;
  padding: 10px 10px 100px 10px;
  border: 0;
  overflow-y: auto;
  position: relative;
}

#layer-list-toolbar {
  min-height: 48px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--neutral-border);
}

#layer-list-title { font-size: 13px; font-weight: 800; color: var(--text-primary); }

.layer-item-row {
  min-height: 54px;
  margin-bottom: 8px;
  background: var(--panel-muted);
  border: 2px solid transparent;
  border-radius: 12px;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  transition: all 0.15s ease;
  padding: 4px 6px;
  cursor: grab;
}

.layer-item-row:hover {
  background: var(--surface-hover);
  border-color: var(--neutral-border);
}

.layer-item-row.selected {
  border-color: var(--accent-2);
  background: var(--panel-glass);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.layer-drag-handle {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-primary) !important;
  cursor: grab;
  border-radius: 6px;
}

.layer-drag-handle .material-icons,
.layer-drag-handle svg {
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}

.layer-drag-handle:hover {
  color: var(--text-primary) !important;
  background: var(--surface-hover);
}

.layer-item-select {
  min-height: 44px;
  padding: 4px 8px;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-align: left;
}

.layer-thumb {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--canvas-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.layer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layer-shape-thumb {
  padding: 5px;
  box-sizing: border-box;
}

.layer-shape-thumb svg {
  display: block;
  width: 100%;
  height: 100%;
}

.layer-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.layer-status-indicators {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
}

.layer-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.layer-status-badge .material-icons {
  font-size: 16px;
}

.layer-more-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  margin-right: 2px;
}

.layer-item-row:hover .layer-more-btn,
.layer-item-row.selected .layer-more-btn,
.layer-item-row.menu-open .layer-more-btn {
  opacity: 1;
}

.layer-more-btn:hover {
  background: var(--surface-strong);
  color: var(--text-primary);
}

.layer-item-row.selected .layer-more-btn {
  background: var(--surface-strong);
  color: var(--text-primary);
}

.layer-item-row.selected .layer-more-btn:hover {
  background: var(--surface-strong);
}

#global-layer-options-menu,
.layer-options-menu.global-popup {
  display: none;
  flex-direction: column;
  position: fixed;
  z-index: 999999;
  min-width: 195px;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--neutral-border);
  padding: 6px;
  gap: 2px;
}

#global-layer-options-menu.visible,
.layer-options-menu.global-popup.visible {
  display: flex !important;
}

.btn-remove-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-remove-bg:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.24);
}
.btn-remove-bg:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn-restore-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-restore-bg:hover {
  background: rgba(220, 38, 38, 0.18);
  border-color: rgba(220, 38, 38, 0.5);
  color: var(--status-danger-text);
}

.bg-removal-canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 1000;
  color: #ffffff;
  pointer-events: none;
  overflow: hidden;
  animation: overlay-fade-in 0.2s ease-out;
}
@keyframes overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bg-removal-scanner-line {
  position: absolute;
  top: 0;
  left: -10%;
  width: 120%;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 15%, #ffffff 50%, var(--accent-2) 85%, transparent 100%);
  box-shadow: 0 0 14px var(--accent), 0 0 28px var(--accent-2), 0 0 36px #ffffff;
  z-index: 1001;
  pointer-events: none;
  will-change: transform;
  animation: scan-line-sweep 1.3s ease-in-out infinite alternate !important;
}
@keyframes scan-line-sweep {
  0% {
    transform: translateY(0px);
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(var(--scanner-travel-height, 180px));
    opacity: 0.6;
  }
}

.bg-removal-spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 50%;
  animation: btn-spin 0.75s linear infinite;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.3);
}

.bg-removal-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.layer-action-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.layer-action-item .material-icons,
.layer-action-item svg {
  font-size: 18px;
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  fill: var(--text-dim);
}

.layer-action-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.layer-action-item:hover .material-icons,
.layer-action-item:hover svg {
  color: var(--text-primary);
  fill: var(--text-primary);
}

.layer-action-item.delete-layer:hover {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}

.layer-action-item.delete-layer:hover .material-icons,
.layer-action-item.delete-layer:hover svg {
  color: var(--status-danger-text);
  fill: var(--status-danger-text);
}

.layer-action-item[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.layer-action-item[disabled]:hover {
  background: transparent;
  color: var(--text-dim);
}

#properties { min-height: 0; flex: 1; background: transparent; }
.prop-group { padding: 14px 16px; border-bottom: 1px solid var(--neutral-border); }
.prop-label { color: var(--text-primary); font-size: 12px; font-weight: 800; }

#transliteration-helper { margin:7px 0 0; color:var(--text-secondary); font-size:11px; line-height:1.45; }
#transliteration-controls { position:relative; }
.transliteration-label-row { display:flex; align-items:center; justify-content:space-between; }
#tanglish-help { width:24px; height:24px; padding:0; border:1px solid var(--neutral-border); border-radius:50%; background:var(--panel-muted); color:var(--text-secondary); font-weight:800; cursor:pointer; }
#transliteration-helper span { color:var(--text-primary); font-weight:700; }
#transliteration-suggestions, .transliteration-suggestions { position:relative; z-index:40; display:grid; gap:4px; margin-top:8px; max-height:min(220px,35vh); overflow-y:auto; }
#transliteration-suggestions[hidden], .transliteration-suggestions[hidden] { display:none; }
.transliteration-suggestion { width:100%; min-height:38px; padding:7px 10px; border:1px solid var(--neutral-border); border-radius:7px; background:var(--panel-muted); color:var(--text-primary); font:600 16px/1.25 Tamil001,sans-serif; text-align:left; cursor:pointer; touch-action:manipulation; }
.transliteration-suggestion[data-active="true"], .transliteration-suggestion:hover { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 14%,var(--panel-muted)); }

/* Panel strip: one horizontally scrollable row of a fixed height, mounted for
   as long as Tanglish mode is on. Constant height is the point — the controls
   below the field never move, so a suggestion arriving mid-tap cannot steal it.
   Same idea as the suggestion bar above a phone keyboard.
   Dressed as an input-method candidate bar: a recessed tray the chips sit in,
   the best match filled, and a hint while it is empty so the gap reads as
   intentional rather than broken. */
#transliteration-suggestions[data-strip="true"], .transliteration-suggestions[data-strip="true"] {
  display:flex; align-items:center; gap:6px; height:52px; max-height:52px; padding:6px 8px; box-sizing:border-box;
  border:1px solid var(--neutral-border); border-radius:12px; background:var(--panel-muted);
  overflow-x:auto; overflow-y:hidden; scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
[data-strip="true"]::-webkit-scrollbar { display:none; }
[data-strip="true"]:empty::before {
  content:"Suggestions appear here as you type"; color:var(--text-dim); font-size:12px; font-weight:500; line-height:1; white-space:nowrap;
}
[data-strip="true"] > .transliteration-suggestion {
  display:inline-flex; align-items:center; gap:6px; width:auto; flex:0 0 auto; min-height:36px; padding:6px 14px;
  border:1px solid transparent; border-radius:999px; background:var(--panel); box-shadow:0 1px 2px rgba(0,0,0,.08);
  font-size:17px; white-space:nowrap; color:var(--text-primary); transition:background-color .12s, border-color .12s, color .12s;
}
[data-strip="true"] > .transliteration-suggestion:hover { border-color:var(--accent); background:var(--panel); }
[data-strip="true"] > .transliteration-suggestion[data-active="true"] {
  border-color:var(--accent); background:var(--accent); color:#fff; box-shadow:none;
}
[data-strip="true"] > .transliteration-suggestion[data-raw="true"] {
  font-family:inherit; font-size:13px; font-weight:600; color:var(--text-dim);
  background:transparent; box-shadow:none; border:1px dashed var(--neutral-border);
}
[data-strip="true"] > .transliteration-suggestion[data-raw="true"]::before {
  content:"ABC"; font-size:9px; font-weight:800; letter-spacing:.06em; opacity:.7;
}
[data-strip="true"] > .transliteration-suggestion[data-raw="true"][data-active="true"] {
  border-style:solid; background:var(--text-dim); color:var(--panel);
}

/* Caret-anchored floating card (portalled to <body> by createFloatingPopup).
   Header = the roman word being converted, rows = candidates, footer = keys. */
#transliteration-suggestions[data-floating="true"], .transliteration-suggestions[data-floating="true"] {
  position:fixed; z-index:2147483000; display:block; gap:0; margin:0; padding:0;
  min-width:176px; max-width:min(300px,calc(100vw - 16px)); max-height:min(300px,50vh); overflow-y:auto;
  background:var(--panel-glass-strong); -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border:1px solid var(--neutral-border); border-radius:14px; box-shadow:0 16px 44px rgba(0,0,0,.28);
}
[data-floating="true"][data-typed]::before {
  content:attr(data-typed); display:block; position:sticky; top:0; z-index:1; padding:8px 14px 7px;
  background:var(--panel-glass-strong); border-bottom:1px solid var(--neutral-border);
  color:var(--text-dim); font-size:12px; font-weight:700; line-height:1.2; letter-spacing:.02em;
}
[data-floating="true"] > .transliteration-suggestion {
  display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:38px; margin:4px;
  width:calc(100% - 8px); padding:7px 12px; border:0; border-radius:9px; background:transparent;
  font-size:18px; position:relative; color:var(--text-primary);
}
[data-floating="true"] > .transliteration-suggestion[data-active="true"]::before {
  content:""; position:absolute; left:0; top:9px; bottom:9px; width:3px; border-radius:3px; background:var(--accent);
}
[data-floating="true"] > .transliteration-suggestion[data-raw="true"] {
  margin-top:0; border-top:1px solid var(--neutral-border); border-radius:0 0 9px 9px;
  font-family:inherit; font-size:13px; font-weight:600; color:var(--text-dim);
}
[data-floating="true"] > .transliteration-suggestion[data-raw="true"]::after {
  content:"Keep as typed"; font-size:10px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; opacity:.65;
}
[data-floating="true"] > .transliteration-suggestion[data-active="true"], [data-floating="true"] > .transliteration-suggestion:hover {
  background:color-mix(in srgb,var(--accent) 14%,transparent); color:var(--text-primary);
}
@media (hover:hover) and (pointer:fine) {
  [data-floating="true"][data-typed]::after {
    content:"↑↓ choose  ·  Space / Enter accept  ·  Esc close"; display:block; position:sticky; bottom:0;
    padding:7px 14px; background:var(--panel-glass-strong); border-top:1px solid var(--neutral-border);
    color:var(--text-dim); font-size:10.5px; font-weight:500; line-height:1.2; white-space:nowrap;
  }
}
#tanglish-tour-blocker { position:fixed; inset:0; z-index:9998; background:transparent; cursor:not-allowed; }
#tanglish-tour-blocker[hidden], #tanglish-spotlight[hidden], #tanglish-onboarding[hidden] { display:none; }
#tanglish-spotlight { position:fixed; z-index:9999; border:3px solid #ffbd2e; border-radius:12px; box-shadow:0 0 0 9999px rgba(9,12,20,.78),0 0 0 7px rgba(255,189,46,.28),0 0 28px rgba(255,189,46,.75); pointer-events:none; animation:tanglish-spotlight-pulse 1.4s ease-in-out infinite; }
#tanglish-onboarding { position:fixed; z-index:10000; left:50%; bottom:30px; width:min(430px,calc(100vw - 28px)); transform:translateX(-50%); box-sizing:border-box; padding:22px; border:1px solid rgba(255,255,255,.16); border-radius:18px; background:#171923; color:#fff; box-shadow:0 24px 80px rgba(0,0,0,.55); font-family:inherit; }
.tanglish-onboarding-badge { display:inline-block; padding:5px 9px; border-radius:999px; background:#ffbd2e; color:#271b00; font-size:10px; font-weight:900; letter-spacing:.08em; }
#tanglish-onboarding h2 { margin:12px 0 8px; color:#fff; font-size:21px; line-height:1.35; }
#tanglish-onboarding p { margin:0; color:#d8d9df; font-size:14px; line-height:1.6; }
.tanglish-animated-demo { position:relative; height:62px; margin:16px 0; overflow:hidden; border:1px solid rgba(255,189,46,.35); border-radius:12px; background:#0d0f16; font-size:21px; font-weight:800; cursor:pointer; }
.tanglish-animated-demo > span { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; opacity:0; }
.tanglish-demo-input { color:#fff; animation:tanglish-demo-input 4.8s infinite; }
.tanglish-demo-space { color:#ffbd2e; font-size:12px; animation:tanglish-demo-space 4.8s infinite; }
.tanglish-demo-result { color:#7ee2a8; animation:tanglish-demo-result 4.8s infinite; }
.tanglish-demo-caret { color:#ffbd2e; animation:tanglish-caret .65s step-end infinite; }
.tanglish-onboarding-actions { display:flex; gap:9px; justify-content:flex-end; flex-wrap:wrap; }
.tanglish-onboarding-actions button { min-height:42px; padding:8px 14px; border-radius:10px; font:inherit; font-size:13px; font-weight:800; cursor:pointer; }
#tanglish-onboarding-try { border:0; background:#ffbd2e; color:#271b00; }
#tanglish-onboarding-dismiss { border:1px solid rgba(255,255,255,.22); background:transparent; color:#fff; }
@keyframes tanglish-spotlight-pulse { 50% { box-shadow:0 0 0 9999px rgba(9,12,20,.78),0 0 0 11px rgba(255,189,46,.15),0 0 38px rgba(255,189,46,.9); } }
@keyframes tanglish-demo-input { 0%,34% { opacity:1; } 40%,100% { opacity:0; } }
@keyframes tanglish-demo-space { 0%,32%,67%,100% { opacity:0; } 40%,59% { opacity:1; } }
@keyframes tanglish-demo-result { 0%,65% { opacity:0; } 72%,96% { opacity:1; } 100% { opacity:0; } }
@keyframes tanglish-caret { 50% { opacity:0; } }
@media (max-width:600px) { #tanglish-onboarding { bottom:14px; padding:18px; } #tanglish-onboarding h2 { font-size:18px; } .tanglish-onboarding-actions { display:grid; } }

/* TextArt customize coach mark. Same spotlight-and-card treatment as the Tanglish
   tour above, reusing its badge/actions classes so the two read as one pattern.
   The card sits bottom-RIGHT rather than centred, because what it points at is the
   inspector on that side — centring it would put the copy furthest from its target. */
#textart-coach-blocker { position:fixed; inset:0; z-index:9998; background:transparent; cursor:not-allowed; }
#textart-coach-blocker[hidden], #textart-coach-spotlight[hidden], #textart-coach[hidden] { display:none; }
#textart-coach-spotlight { position:fixed; z-index:9999; border:3px solid #ffbd2e; border-radius:12px; box-shadow:0 0 0 9999px rgba(9,12,20,.78),0 0 0 7px rgba(255,189,46,.28),0 0 28px rgba(255,189,46,.75); pointer-events:none; animation:tanglish-spotlight-pulse 1.4s ease-in-out infinite; }
#textart-coach { position:fixed; z-index:10000; right:24px; bottom:30px; width:min(360px,calc(100vw - 28px)); box-sizing:border-box; padding:22px; border:1px solid rgba(255,255,255,.16); border-radius:18px; background:#171923; color:#fff; box-shadow:0 24px 80px rgba(0,0,0,.55); font-family:inherit; }
#textart-coach h2 { margin:12px 0 8px; color:#fff; font-size:20px; line-height:1.35; }
#textart-coach p { margin:0 0 16px; color:#d8d9df; font-size:14px; line-height:1.6; }
#textart-coach p b { color:#ffbd2e; }
#textart-coach-dismiss { border:0; background:#ffbd2e; color:#271b00; }
@media (max-width:600px) {
  #textart-coach { right:14px; left:14px; bottom:14px; width:auto; padding:18px; }
  #textart-coach h2 { font-size:18px; }
}
@media (prefers-reduced-motion: reduce) { #textart-coach-spotlight { animation:none; } }
.prop-row { gap: 9px; }
.prop-row input[type="range"] { min-width: 0; flex: 1; accent-color: var(--accent); }
.prop-row input[type="number"] { width: 68px; background: var(--panel-muted); color: var(--text-primary); border: 1px solid var(--neutral-border); border-radius: 6px; padding: 4px; }

#prop-empty,
.inspector-empty-state {
  margin: auto;
  padding: 32px 22px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

.inspector-empty-state .material-icons {
  display: block;
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 34px;
}

.tm-selection-toolbar { top: auto; bottom: calc(100% + (10px * var(--sel-inv-zoom, 1))); gap: 2px; padding: 5px; border-radius: 13px; background: var(--panel-glass-strong); backdrop-filter: blur(12px); border: 1px solid var(--neutral-border); }
/* Flipped below the box (layer near the artboard's top edge) — the nearest
   edge is now the TOP one, so anchor the counter-scale there instead so the
   toolbar still grows away from the selection rather than back across it. */
.tm-selection.toolbar-below .tm-selection-toolbar { top: calc(100% + (10px * var(--sel-inv-zoom, 1))); bottom: auto; transform-origin: top center; }
.tm-selection.toolbar-below .tm-selection-bottom-controls { top: calc(100% + (68px * var(--sel-inv-zoom, 1))); }
/* The frame's own hairline is inside the same double-scaled overlay — without
   this it thins to sub-pixel (1.5px x 0.55 x 0.5 = 0.4px) and visibly fades. */
.tm-selection { outline-width: calc(1.5px * var(--sel-inv-zoom, 1)); }
.tm-selection-action {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  color: var(--text-primary);
  background: var(--panel-muted);
  border: 1px solid transparent;
}
.tm-selection-action:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.tm-selection-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
}
.tm-selection-action svg * {
  fill: none;
  stroke: currentColor;
}
.tm-selection.is-locked { outline-color: var(--accent) !important; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Deliberately NOT font-family: 'Material Icons' — no such webfont is shipped,
   so that only ever resolved on a machine with the font installed locally (a
   developer's), and rendered the raw ligature word everywhere else. icons.ts
   swaps every one of these for an inline SVG instead; font-size still drives
   the SVG's 1em box below. */
.material-icons {
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga';
  pointer-events: none;
}
.material-icons svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.preview-mode #library-nav,
body.preview-mode #library,
body.preview-mode #inspector,
body.preview-mode #zoom-bar,
body.preview-mode #page-rail,
body.preview-mode #page-actions-menu,
body.preview-mode #history-controls,
body.preview-mode #document-meta,
body.preview-mode #brand-area,
body.preview-mode #header-actions > :not(#preview-btn) { display: none !important; }
body.preview-mode #header {
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  display: block;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1600;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body.preview-mode #header-actions { display: block; }
body.preview-mode #preview-btn {
  min-width: 124px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-glass);
  box-shadow: var(--shadow-med);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-primary);
}
body.preview-mode #editor-workspace {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  inset: 0;
  z-index: 1300;
}
body.preview-mode #stage {
  width: 100%;
  height: 100%;
  padding: 28px;
  pointer-events: none;
}
body.preview-mode .tm-selection { display: none !important; }

/* ── Redesigned Inspector Controls ────────────────────────── */

/* Section header title (like "Text Properties") */
.prop-section-title {
  padding: 14px 14px 6px;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Refined property group */
#inspector .prop-group {
  padding: 8px 14px;
  border-bottom: 1px solid var(--neutral-border);
}

#inspector .prop-group:last-child {
  border-bottom: none;
}

/* Refined prop-label — left aligned, uppercase */
#inspector .prop-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Refined prop-row */
#inspector .prop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

#inspector .prop-row:last-child {
  margin-bottom: 0;
}

/* Value badge — right-aligned box showing slider value */
.prop-value-badge {
  min-width: 48px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Slider track (range input) refinement inside inspector */
#inspector input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-strong);
  border-radius: 999px;
  outline: none;
  border: none;
}

#inspector input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

#inspector input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Number input inside inspector — styled as badge */
#inspector input[type="number"] {
  min-width: 48px;
  width: 56px;
  height: 30px;
  padding: 0 6px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
}

#inspector input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Font picker button refinement */
#inspector .textart-font-button {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 10px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

#inspector .textart-font-button::after {
  content: '▾';
  font-size: 14px;
  color: var(--text-dim);
  margin-left: 8px;
}

#inspector .textart-font-button:hover {
  border-color: var(--surface-strong);
}

/* Segmented control for font weight */
.segmented-control {
  display: flex;
  gap: 0;
  border-radius: 10px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  overflow: hidden;
}

.segment-btn {
  flex: 1;
  min-height: 34px;
  padding: 6px 10px;
  border: none;
  border-right: 1px solid var(--neutral-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn:last-child {
  border-right: none;
}

.segment-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.segment-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* Alignment icon row refinement */
#text-align-controls .prop-row {
  display: flex;
  gap: 4px;
}

#text-align-controls .aspect-btn.icon-btn {
  flex: 1;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

#text-align-controls .aspect-btn.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

#text-align-controls .aspect-btn.icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Color swatch palette header */
.swatch-palette-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Color swatches grid — neat 7-column layout */
#text-solid-swatches.text-preset-grid,
#text-gradient-presets.text-preset-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.text-solid-swatch,
.text-gradient-preset {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.text-solid-swatch:hover,
.text-gradient-preset:hover {
  transform: scale(1.15);
  border-color: var(--surface-strong);
}

.text-solid-swatch.active,
.text-gradient-preset.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* "Custom color" button */
#text-solid-more,
#text-gradient-more {
  width: 100%;
  min-height: 32px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

#text-solid-more:hover,
#text-gradient-more:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Header center capsule for undo/redo + status */
#history-controls {
  gap: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--panel-muted);
  border: 1px solid var(--neutral-border);
}

#history-controls button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
}

#history-controls button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

#history-controls button:disabled {
  opacity: 0.3;
}

/* Status badge inside the header capsule look */
#document-meta #status {
  font-size: 11px;
}

/* prop-row-label inside inspector refined */
#inspector .prop-row-label {
  min-width: 48px;
  padding: 0 6px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  width: auto;
}

/* Theme toggle (header) */
#theme-toggle-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  color: var(--text-primary);
  cursor: pointer;
}
#theme-toggle-btn:hover { background: var(--surface-hover); }
#theme-toggle-btn .material-icons { font-size: 20px; }
#theme-toggle-btn .theme-toggle-icon-dark { display: none; }
:root[data-theme="dark"] #theme-toggle-btn .theme-toggle-icon-light { display: none; }
:root[data-theme="dark"] #theme-toggle-btn .theme-toggle-icon-dark { display: inline-block; }

#mobile-context-toolbar { display: none; }

@media (max-width: 1440px) {
  :root { --library-width: 288px; --inspector-width: 300px; }
  #header { grid-template-columns: minmax(180px, 1fr) auto minmax(max-content, 1fr); gap: 10px; padding-inline: 10px; }
  #brand-home span { display: none; }
  #document-meta { padding-left: 6px; border-left: 0; }
  #stage { padding-inline: 28px; }
}

@media (max-width: 1160px) {
  #header { grid-template-columns: auto minmax(0, 1fr); }
  #history-controls { position: static; }
  #document-meta { display: none; }
  #library,
  #inspector {
    height: 100%;
    position: absolute;
    top: 0;
    z-index: 1000;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-strong);
  }
  #library { left: 0; }
  #inspector { right: 0; transform: translateX(105%); }
  #library.visible,
  #inspector.visible { transform: translateX(0); }
  #toggle-library-btn,
  #toggle-inspector-btn,
  #close-library-btn,
  #close-inspector-btn { display: inline-flex !important; }
  #stage { padding: 28px 20px; }
}

@media (max-width: 760px) {
  :root {
    --app-header-height: 58px;
    --mobile-nav-bar-height: 60px;
    /* Everything permanently docked at the bottom edge. The app banner anchors
       to this, so it can never cover the nav bar. */
    --mobile-dock-height: var(--mobile-nav-bar-height, 60px);
  }
  /* The context toolbar docks above the nav bar while a layer is selected, so
     the banner has to clear both. 68px is #mobile-context-toolbar's min-height. */
  body.mobile-context-active { --mobile-dock-height: calc(var(--mobile-nav-bar-height, 60px) + 68px); }
  /* Reserved below the control rows while the banner is on screen, so both
     the poster and document controls stay above the mobile dock. */
  body.app-banner-visible { --mobile-banner-allowance: 78px; }
  /* 3 columns now (was 2): brand-area | history-controls | header-actions,
     matching #header's actual DOM order — history-controls used to be in the
     display:none list below, which is why it was missing from the mobile bar
     entirely despite the underlying undo/redo state (main.ts's undoStack/
     redoStack, updateUndoRedoButtons, keyboard shortcuts) always having
     worked regardless of viewport. Same buttons/handlers, just made visible
     and given room. */
  #header { grid-template-columns: auto auto minmax(0, 1fr); }
  #header { padding: 7px 8px; gap: 6px; }
  #brand-area { gap: 4px; }
  #brand-home { display: none; }
  /* #account-menu-wrap is deliberately NOT in this list: it is the only route
     to sign in, sign out, the current plan and Upgrade on a phone, and the
     40px sizing right below was already written for it while it was hidden.
     The other four move into #mobile-more-menu rather than disappearing. */
  #theme-toggle-btn,
  #header-upgrade-btn,
  #mobile-zoom-btn,
  #preview-btn,
  #save {
    display: none !important;
  }
  #mobile-more-wrap { display: block; }
  #mobile-more-menu { width: min(250px, calc(100vw - 24px)); }
  /* Language is set once, so on a phone it lives in the More menu instead of
     taking a header slot (the pill used to spill over undo/redo). */
  #language-picker-host { display: none; }
  /* Exiting preview is the one time #preview-btn has to come back on a phone:
     preview-mode hides everything in the header except this button, and it is
     the only way out. Matches desktop, where it is the same pill. */
  body.preview-mode #preview-btn { display: inline-flex !important; }
  /* Same capsule as desktop, sized up to a finger-sized ~40px tap target
     (matching the other mobile header icon buttons — toggle-library-btn,
     toggle-inspector-btn, new-design-btn, download-trigger-btn — rather than
     desktop's tighter 34px) and trimmed padding so it fits the narrow bar. */
  #history-controls { display: flex !important; gap: 2px; padding: 3px; }
  #history-controls button { width: 40px; min-width: 40px; min-height: 40px; }
  #header-actions { gap: 6px; }
  #header-actions {
    min-width: 0;
    display: flex;
    justify-content: flex-end;
  }
  #header-actions .button-label { display: none; }
  .toolbar-btn, #header-actions > button { width: 40px; padding: 0; }
  .account-status {
    min-width: 40px;
    width: 40px;
    min-height: 40px;
    padding: 0;
  }
  .account-status:not(.signed-in) .account-status-label { display: none; }
  .account-status.signed-in { width: 40px; }
  .account-status-avatar {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }
  #account-menu {
    position: fixed;
    top: 66px;
    right: 8px;
  }
  #inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-bar-height, 60px);
    top: auto;
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    transform: translateY(calc(100% + var(--mobile-nav-bar-height, 60px)));
    transition: transform .22s ease;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-strong);
    z-index: 1002;
    background: var(--panel-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: none;
    border-top: 1px solid var(--neutral-border);
  }
  #inspector.visible { transform: translateY(0); }

  #mobile-context-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-bar-height, 60px);
    z-index: 1003;
    display: block;
    min-height: 68px;
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--neutral-border);
    background: var(--panel-glass);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .12);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  #mobile-context-toolbar[hidden] { display: none !important; }
  #mobile-context-actions {
    display: flex;
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  #mobile-context-actions::-webkit-scrollbar { display: none; }
  .mobile-context-action {
    flex: 0 0 62px;
    min-width: 62px;
    min-height: 52px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 7px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    scroll-snap-align: start;
  }
  .mobile-context-action .material-icons { font-size: 21px; }
  .mobile-context-action:active,
  .mobile-context-action[aria-pressed="true"] {
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent);
  }
  .mobile-context-action.danger { color: var(--status-danger-text); }

  #inspector.mobile-context-sheet {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(var(--mobile-nav-bar-height, 60px) + 72px + env(safe-area-inset-bottom, 0px));
    height: auto !important;
    min-height: 0;
    max-height: min(34vh, 320px);
    transform: translateY(calc(100% + var(--mobile-nav-bar-height, 60px) + 68px));
    border-radius: 16px;
    border: 1px solid var(--neutral-border);
    overflow-y: auto;
  }
  #inspector.mobile-context-sheet.visible { transform: translateY(0); }
  #inspector.mobile-context-sheet .inspector-panel.active,
  #inspector.mobile-context-sheet #properties {
    flex: 0 1 auto;
  }
  #inspector.mobile-context-sheet #inspector-tabs { display: none; }
  #inspector.mobile-context-sheet #inspector-header { min-height: 44px; justify-content: flex-end; }
  #inspector.mobile-context-sheet.mobile-property-focused #properties > * {
    display: none !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused #properties > .mobile-focus-panel {
    display: block !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-panel > * {
    display: none !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-panel > .mobile-focus-target {
    display: block !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-panel > .mobile-focus-path,
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-path > .mobile-focus-path,
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-path > .mobile-focus-target {
    display: block !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused .mobile-focus-path > * {
    display: none !important;
  }
  #inspector.mobile-context-sheet.mobile-property-focused #properties > .mobile-focus-target {
    display: block !important;
  }

  #mobile-zoom-popover { display: none !important; }

  #mobile-nudge-pad {
    display: grid;
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(3, 38px);
    gap: 4px;
    justify-content: center;
    margin-top: 6px;
  }

  #mobile-nudge-pad button {
    background: var(--panel-muted);
    border: 1px solid var(--neutral-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    color: var(--text-primary);
  }

  #mobile-nudge-pad button:active {
    background: var(--surface-hover);
  }

  #library { display: contents; }

  #library-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--mobile-nav-bar-height, 60px);
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
    border-right: none;
    border-top: 1px solid var(--neutral-border);
    z-index: 1001;
    background: var(--panel-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  #library-nav .nav-tab {
    flex: 0 0 auto;
    min-width: 52px;
  }
  #library-nav [data-tab="legacy"] { display: none; }

  #library-content {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-bar-height, 60px);
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    transform: translateY(calc(100% + var(--mobile-nav-bar-height, 60px)));
    transition: transform .22s ease;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-strong);
    z-index: 1001;
    background: var(--panel-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--neutral-border);
  }
  #library.visible #library-content { transform: translateY(0); }

  #toggle-library-btn { display: none !important; }

  #center {
    padding-bottom: calc(var(--mobile-dock-height, 60px) + var(--mobile-banner-allowance, 0px) + env(safe-area-inset-bottom, 0px));
  }
  #stage { padding: 16px 12px !important; }
  #zoom-bar {
    margin-bottom: 10px;
    max-width: calc(100% - 20px);
    min-height: 42px;
    padding: 5px 6px;
  }
  #page-rail {
    width: auto;
    max-width: calc(100% - 20px);
    min-height: 42px;
    padding: 5px 6px;
  }
  .page-chip, #page-add-btn { min-height: 32px; }
  /* The note is the first thing to go: at phone width the chips and the add
     button are what must stay reachable. */
  #page-rail-note { display: none; }
  #zoomSlider { width: min(34vw, 118px); }
  .zoom-preset {
    min-width: 34px;
    min-height: 32px;
    padding: 4px 7px;
  }
  #zoomReset {
    width: 32px;
    height: 32px;
  }
}

.header-upgrade-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 6px 9px;
  background: var(--panel-glass);
  color: var(--accent-2);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.15);
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  line-height: 1;
  overflow: hidden;
  max-width: 34px;
}

.header-upgrade-pill .button-label {
  opacity: 0;
  max-width: 0;
  transition: opacity 0.2s ease, max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.2s ease;
  overflow: hidden;
  white-space: nowrap;
  margin-left: 0;
}

.header-upgrade-pill:hover {
  max-width: 170px;
  padding: 6px 14px 6px 10px;
  background: linear-gradient(135deg, var(--panel-glass) 0%, rgba(255, 152, 0, 0.12) 100%);
  border-color: var(--accent-2);
  box-shadow: 0 4px 14px rgba(255, 152, 0, 0.3);
  transform: translateY(-1px);
}

.header-upgrade-pill:hover .button-label {
  opacity: 1;
  max-width: 120px;
  margin-left: 6px;
}

.header-upgrade-pill .material-icons {
  font-size: 18px;
  color: var(--status-warning-text);
  flex-shrink: 0;
}

/* Posterkaaran Pro modal: shared editor tokens keep this surface native to
   both themes instead of reviving the legacy standalone purple checkout. */
.upgrade-overlay {
  padding: 24px;
  background: var(--modal-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.upgrade-dialog {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  display: grid;
  grid-template-columns: minmax(220px, .78fr) minmax(340px, 1.22fr);
  overflow: hidden;
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius);
  background: var(--modal-panel);
  color: var(--text-primary);
  box-shadow: var(--modal-shadow);
  outline: none;
}

.upgrade-dialog:focus-visible { box-shadow: var(--shadow-strong), var(--focus-ring); }

.upgrade-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--neutral-border);
  border-radius: 50%;
  background: var(--modal-surface);
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.upgrade-close .material-icons { font-size: 20px; }
.upgrade-close:hover { border-color: var(--accent-border); color: var(--accent); }
.upgrade-close:focus-visible,
.upgrade-plan-card:focus-visible,
.upgrade-pay:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.upgrade-hero {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 52% 56%, rgba(255, 184, 77, .6), transparent 32%),
    linear-gradient(155deg, #6e171f 0%, #a21d28 45%, #e57b13 100%);
}

.upgrade-hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(44, 7, 10, .05), rgba(44, 7, 10, .44));
}

.upgrade-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.upgrade-mascot {
  position: absolute;
  z-index: 1;
  width: 160%;
  max-width: none;
  height: auto;
  left: 50%;
  bottom: -23%;
  transform: translateX(-50%);
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(49, 12, 3, .34));
}

.upgrade-purchase {
  min-width: 0;
  padding: 42px 34px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--panel-glass-strong);
}

.upgrade-heading { display: grid; gap: 7px; padding-right: 24px; }
.upgrade-kicker { color: var(--accent); }
.upgrade-heading h3 { margin: 0; color: var(--text-primary); font-size: clamp(22px, 2.3vw, 29px); line-height: 1.15; letter-spacing: -.035em; }
.upgrade-heading p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.55; }

.upgrade-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
}

.upgrade-benefits li { padding: 6px 10px; border-radius: 999px; background: var(--panel-muted); color: var(--text-primary); }

.upgrade-plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.upgrade-plan-card {
  position: relative;
  min-width: 0;
  min-height: 146px;
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  border: 1.5px solid var(--neutral-border);
  border-radius: 16px;
  background: var(--canvas-bg);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.upgrade-plan-card:hover { transform: translateY(-2px); border-color: var(--accent-border); color: var(--text-primary); }
.upgrade-plan-card.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent), var(--shadow-soft); }

.upgrade-selection-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 7px;
  border: 1px solid var(--neutral-border);
  border-radius: 999px;
  background: var(--canvas-bg);
  color: var(--text-dim);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  visibility: hidden;
}

.upgrade-plan-card.selected .upgrade-selection-mark { border-color: var(--accent); background: var(--accent); color: #fff; visibility: visible; }
.upgrade-value-badge { position: absolute; top: -10px; left: 14px; padding: 4px 9px; border-radius: 999px; background: var(--accent-gradient); color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.upgrade-plan-name { color: var(--text-dim); font-size: 12px; font-weight: 800; }
.upgrade-price { font-size: 29px; line-height: 1; letter-spacing: -.04em; }
.upgrade-period { color: var(--text-dim); font-size: 10px; line-height: 1.35; }

.upgrade-pay {
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border: 0;
  border-radius: 13px;
  background: var(--accent-gradient);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(162, 29, 40, .2);
}

.upgrade-pay:hover:not(:disabled) { background: var(--accent-gradient-hover); color: #fff; transform: translateY(-1px); }
.upgrade-pay:disabled { opacity: .6; cursor: wait; }
.upgrade-error { margin: -8px 0 0; color: var(--status-danger-text); font-size: 12px; text-align: center; }
.upgrade-error[hidden] { display: none !important; }
.upgrade-pay-once {
  width: 100%;
  min-height: 42px;
  margin: -6px 0 0;
  padding: 10px 16px;
  border: 1px solid var(--border, rgba(0, 0, 0, .15));
  border-radius: 12px;
  background: transparent;
  color: var(--text, inherit);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.upgrade-pay-once:hover:not(:disabled) { border-color: currentColor; }
.upgrade-pay-once:disabled { opacity: .6; cursor: wait; }
.upgrade-pay-once:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.upgrade-pay-once[hidden] { display: none !important; }
#account-cancel-renew-btn[hidden] { display: none !important; }
.upgrade-footnote { margin: -8px 0 0; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--text-dim); font-size: 9px; text-align: center; }
.upgrade-footnote .material-icons { font-size: 13px; }

@media (max-width: 680px) {
  .upgrade-overlay { padding: 12px; align-items: flex-start; overflow-y: auto; }
  .upgrade-dialog { width: min(100%, 480px); max-height: none; margin: auto; grid-template-columns: 1fr; border-radius: 20px; }
  .upgrade-hero { min-height: 180px; }
  .upgrade-mascot { width: 58%; left: 72%; bottom: -120px; }
  .upgrade-purchase { padding: 28px 20px 22px; gap: 16px; }
  .upgrade-heading { padding-right: 18px; }
  .upgrade-heading h3 { font-size: 23px; }
  .upgrade-plan-card { min-height: 132px; }
}

@media (max-width: 420px) {
  .upgrade-plan-grid { grid-template-columns: 1fr; }
  .upgrade-plan-card { min-height: 104px; padding: 17px 16px; }
  .upgrade-mascot { width: 64%; left: 72%; bottom: -132px; }
}

@media (max-width: 900px) {
  .toolbar-btn .button-label {
    display: none !important;
  }
  .toolbar-btn {
    padding: 6px 10px !important;
    min-width: 36px;
    justify-content: center;
  }
  .account-status-name,
  .account-status-plan {
    display: none !important;
  }
  .account-status {
    padding: 4px 8px !important;
  }
}

/* ── In-editor feedback card (கருத்து) ─────────────────────────────────────
   Bottom-anchored, not a centered modal: it appears seconds after a download
   and must read as an aside the user can ignore, not as something blocking
   the design they were just working on. */
.pk-feedback {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9600;
  display: flex;
  justify-content: center;
  /* Clears whatever is docked at the bottom edge. On mobile that is the nav
     bar (plus the context toolbar when a layer is selected) — the same
     variable the app banner uses so it can never cover the navigation.
     Undefined above 760px, where the fallback 0px leaves it at the edge. */
  padding: 0 16px calc(20px + var(--mobile-dock-height, 0px) + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  animation: pk-feedback-in .22s ease both;
}
.pk-feedback-closing { animation: pk-feedback-out .18s ease both; }

@keyframes pk-feedback-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pk-feedback-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(16px); }
}

.pk-feedback-card {
  position: relative;
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 12px;
  padding: 20px 20px 18px;
  border: 1px solid var(--neutral-border);
  border-radius: 18px;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
}

.pk-feedback-close {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--panel-muted);
  color: var(--text-dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.pk-feedback-close:hover { color: var(--text-primary); }

.pk-feedback-title { margin: 0; padding-inline-end: 30px; font-size: 16px; font-weight: 800; color: var(--text-primary); }
.pk-feedback-sub { margin: -6px 0 0; font-size: 13px; color: var(--text-dim); }

.pk-feedback-ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pk-feedback-rating {
  display: grid;
  /* Top-aligned, not centred: the four Tamil labels wrap to different line
     counts, and centring each one inside its own box made the row look
     ragged. Anchoring them to a common baseline keeps the row even. */
  align-content: start;
  justify-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-muted);
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, color .14s ease;
}
.pk-feedback-rating:hover { transform: translateY(-2px); border-color: var(--accent, #A21D28); color: var(--text-primary); }
.pk-feedback-emoji { font-size: 26px; line-height: 1; }
/* Every emoji carries its words. 😐 and 😞 are read very differently by
   different people, and an ambiguous tap is bad data. */
.pk-feedback-rating-label { font-size: 10.5px; font-weight: 700; line-height: 1.25; text-align: center; }

.pk-feedback-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.pk-feedback-chip {
  padding: 7px 13px;
  border: 1px solid var(--neutral-border);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .14s ease;
}
/* The :hover half is not redundant. The global `button:hover:not(:disabled)`
   rule scores (0,2,1) — one higher than `.pk-feedback-chip.is-selected` — so
   it repainted the label accent-maroon on top of the accent gradient the
   moment the pointer rested on the chip the user had just picked. */
.pk-feedback-chip.is-selected,
.pk-feedback-chip.is-selected:hover { background: var(--accent-gradient); border-color: transparent; color: #fff; }

.pk-feedback-text {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--neutral-border);
  border-radius: 12px;
  background: var(--panel-muted);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.pk-feedback-text:focus { outline: 2px solid var(--accent, #A21D28); outline-offset: 1px; }

.pk-feedback-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
  cursor: pointer;
}
.pk-feedback-consent input { margin-top: 2px; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--accent, #A21D28); }
.pk-feedback-consent[hidden] { display: none; }

.pk-feedback-send {
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-gradient);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
/* Same (0,2,1) global button:hover rule as the chips above — without the
   explicit colour the primary action's label goes maroon-on-gradient. */
.pk-feedback-send:hover { background: var(--accent-gradient-hover); color: #fff; }

.pk-feedback-whatsapp { justify-self: center; color: var(--text-dim); font-size: 12.5px; font-weight: 700; text-decoration: underline; }
.pk-feedback-whatsapp:hover { color: var(--text-primary); }

.pk-feedback-thanks { margin: 0; padding: 10px 30px 10px 0; font-size: 15px; font-weight: 700; line-height: 1.5; color: var(--text-primary); }

@media (max-width: 420px) {
  /* Keeps the dock clearance from the base rule — a plain shorthand here
     would reset padding-bottom and drop the card back over the nav bar. */
  .pk-feedback {
    padding-inline: 10px;
    padding-bottom: calc(12px + var(--mobile-dock-height, 0px) + env(safe-area-inset-bottom, 0px));
  }
  .pk-feedback-card { padding: 18px 16px 16px; border-radius: 16px; }
  .pk-feedback-ratings { gap: 6px; }
  .pk-feedback-rating { padding: 9px 2px; }
  .pk-feedback-rating-label { font-size: 9.5px; }
}

.pk-softprompt {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9600;
  display: flex;
  justify-content: center;
  padding: 0 16px calc(20px + var(--mobile-dock-height, 0px) + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  animation: pk-feedback-in .22s ease both;
}
.pk-softprompt-closing { animation: pk-feedback-out .18s ease both; }

.pk-softprompt-card {
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 20px 20px 18px;
  border: 1px solid var(--neutral-border);
  border-radius: 18px;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
  text-align: center;
}
.pk-softprompt-icon { font-size: 30px; line-height: 1; }
.pk-softprompt-title { margin: 0; font-size: 16px; font-weight: 800; color: var(--text-primary); }
.pk-softprompt-sub { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-dim); }
/* Stacked, not side by side: the Tamil labels are long enough that two columns
   wrap both buttons onto two lines each at this card width. */
.pk-softprompt-actions { display: grid; gap: 8px; width: 100%; margin-top: 4px; }
.pk-softprompt-primary,
.pk-softprompt-ghost {
  padding: 11px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}
.pk-softprompt-primary { background: var(--accent-gradient); color: #fff; }
.pk-softprompt-primary:hover { background: var(--accent-gradient-hover); color: #fff; }
.pk-softprompt-ghost { background: transparent; border-color: var(--neutral-border); color: var(--text-dim); }
.pk-softprompt-ghost:hover { color: var(--text-primary); }

.pk-softprompt-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--mobile-dock-height, 0px) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 9610;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  animation: pk-feedback-in .22s ease both;
}

/* ── Add to Home Screen ───────────────────────────────────────────────────────
   A strip, not a modal: installing is worth offering but never worth blocking
   the editor for. Shares .android-app-banner's stacking order and bottom
   calc() so it clears the mobile dock the same way — the two are mutually
   exclusive (see installBadgeEligible) and occupy exactly the same slot. */
.pk-install-badge {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px) + var(--mobile-dock-height, 0px));
  z-index: 11500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  animation: pk-feedback-in .22s ease both;
}
.pk-install-badge-closing { animation: pk-feedback-out .18s ease both; }
.pk-install-badge-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.pk-install-badge-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pk-install-badge-copy strong { font-size: 13px; color: var(--text-primary); }
.pk-install-badge-copy span {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pk-install-badge-cta {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 9px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.pk-install-badge-close {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--panel-muted);
  color: var(--text-dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.pk-install-badge-close:hover { color: var(--text-primary); }

/* Safari has no install API at all, so these steps ARE the install path on
   iPhone — not a fallback for a missing event. */
.pk-install-sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9600;
  display: flex;
  justify-content: center;
  padding: 0 16px calc(20px + var(--mobile-dock-height, 0px) + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  animation: pk-feedback-in .22s ease both;
}
.pk-install-closing { animation: pk-feedback-out .18s ease both; }
.pk-install-sheet-card {
  position: relative;
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 10px;
  padding: 20px 20px 18px;
  border: 1px solid var(--neutral-border);
  border-radius: 18px;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
}
.pk-install-close {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--panel-muted);
  color: var(--text-dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.pk-install-close:hover { color: var(--text-primary); }
.pk-install-title { margin: 0; padding-inline-end: 30px; font-size: 16px; font-weight: 800; color: var(--text-primary); }
.pk-install-sub { margin: -6px 0 2px; font-size: 13px; color: var(--text-dim); }
.pk-install-steps { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: pk-install-step; }
.pk-install-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--neutral-border);
  background: var(--panel-muted);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.pk-install-step::before {
  counter-increment: pk-install-step;
  content: counter(pk-install-step);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}
.pk-install-glyph { flex: 0 0 auto; width: 22px; height: 22px; color: var(--accent); }

@media (max-width: 560px) {
  .pk-install-badge-copy span { display: none; }
}

/* "Designed by @creator" on Creator Program templates in the related grid. */
.pk-designer {
  display: block;
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--text-dim);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px 2px;
}

/* ── Creator mode (creatorMode.ts) ─────────────────────────────────────────
   Opened from the Creator Program site: one submit action instead of Export,
   no template library, a watermark over the canvas. */
body.creator-mode #download-trigger-btn,
body.creator-mode #header-upgrade-btn,
body.creator-mode #mobile-upgrade-btn,
body.creator-mode #account-upgrade-btn,
body.creator-mode .nav-tab[data-tab="templates"],
body.creator-mode .create-design-footer { display: none !important; }
/* Outranks the header's own .toolbar-btn background. */
#header-actions .creator-submit-btn {
  background: var(--accent-gradient, linear-gradient(135deg, #a21d28, #d97706)) !important;
  color: #fff !important;
  border-color: transparent !important;
  font-weight: 700;
}
#header-actions .creator-submit-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.creator-mode-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; font-size: 13px; line-height: 1.4;
  background: var(--accent-soft, #f6e4e5); color: var(--text, #1d1718);
  border-bottom: 1px solid var(--border, rgba(162, 29, 40, 0.14));
}
.creator-mode-banner .material-icons { font-size: 18px; color: var(--accent, #a21d28); }
.creator-mode-banner-text { flex: 1 1 260px; }
.creator-mode-banner-link { font-weight: 600; color: var(--accent, #a21d28); white-space: nowrap; }
.creator-watermark {
  position: absolute; inset: 0; z-index: 9000;
  pointer-events: none; background-repeat: repeat;
}

/* Frosted glass — a card in the shape inspector: switch header, style presets, tint swatches. */
#inspector .glass-card { margin: 10px 12px; padding: 12px; border: 1px solid var(--neutral-border); border-radius: 14px; background: var(--panel-muted); transition: border-color .2s, box-shadow .2s; }
#inspector .glass-card:has(.glass-switch:checked) { border-color: var(--accent-border, var(--accent)); box-shadow: 0 0 0 3px var(--accent-soft); }
.glass-switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.glass-icon { flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-size: 20px; color: var(--accent); background: linear-gradient(135deg, rgba(255,255,255,.9), var(--accent-soft)); border: 1px solid var(--neutral-border); }
.glass-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.glass-title { font-size: 13px; font-weight: 800; color: var(--text-primary); }
.glass-sub { font-size: 11px; color: var(--text-dim); line-height: 1.35; }
.glass-switch { appearance: none; -webkit-appearance: none; flex: 0 0 38px; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: var(--surface-strong, #d6d0ce); position: relative; cursor: pointer; transition: background .2s; }
.glass-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.glass-switch:checked { background: var(--accent); }
.glass-switch:checked::after { transform: translateX(16px); }
.glass-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#shape-glass-fields { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
#shape-glass-fields[hidden] { display: none; }
#shape-glass-fields .swatch-palette-header { margin: 2px 0 -2px; }
.glass-presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.glass-preset { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 2px 6px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--text-dim); font-size: 10.5px; font-weight: 700; cursor: pointer; }
.glass-preset:hover { background: var(--accent-soft); color: var(--accent); }
.glass-preset.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.glass-preset:focus-visible, .glass-tint-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The tile fakes the effect: bright blobs behind a tinted, blurred pane. */
.glass-preset-tile { position: relative; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: radial-gradient(circle at 28% 32%, #ff5a7a 0 22%, transparent 23%), radial-gradient(circle at 72% 70%, #ffb020 0 20%, transparent 21%), linear-gradient(135deg, #2563eb, #9333ea); }
.glass-preset-tile::after { content: ''; position: absolute; inset: 22% 14%; border-radius: 6px; background: color-mix(in srgb, var(--tint) calc(var(--alpha) * 100%), transparent); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); border: 1px solid rgba(255,255,255,.7); box-shadow: inset 0 1px 0 rgba(255,255,255,.8); }
.glass-row { display: flex; align-items: center; }
#inspector .glass-row .prop-row-label { min-width: 56px; }
.glass-value { min-width: 44px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--neutral-border); background: var(--panel-glass-strong); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.glass-tints { display: flex; flex-wrap: wrap; gap: 8px; }
.glass-tint-swatch, .glass-tint-custom { position: relative; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); background: var(--swatch); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.glass-tint-swatch.active, .glass-tint-custom.active { box-shadow: 0 0 0 2px var(--panel-glass-strong), 0 0 0 4px var(--accent); }
.glass-tint-custom { background: var(--swatch, conic-gradient(#f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e)); overflow: hidden; }
.glass-tint-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* Templates search: the input sits in a wrapper (for the clear button and the
   suggestions dropdown), so it has to take the full width itself. The native
   search-field clear control is hidden in favour of #template-search-clear. */
#template-search-wrap #lib-search-input { display: block; width: calc(100% - 24px); box-sizing: border-box; padding-right: 30px; }
#lib-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.bg-catalog{margin-top:14px}.bg-category-list{display:flex;gap:6px;overflow-x:auto;padding-bottom:7px;scrollbar-width:thin}.bg-category-list button{flex:0 0 auto;border:1px solid var(--border);border-radius:999px;padding:6px 9px;background:var(--surface);color:var(--text);font-size:10px;cursor:pointer}.bg-category-list button.active{border-color:var(--accent);background:var(--accent-soft);color:var(--accent)}.bg-image-status{min-height:18px;margin:4px 0;color:var(--text-dim);font-size:10px}.bg-image-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.bg-image-tile{position:relative;padding:0;border:2px solid transparent;border-radius:8px;overflow:hidden;background:var(--surface);cursor:pointer;aspect-ratio:1}.bg-image-tile:hover{border-color:var(--accent)}.bg-image-tile img{width:100%;height:100%;object-fit:cover;display:block}.bg-image-pro{position:absolute;right:4px;top:4px;padding:2px 5px;border-radius:999px;background:#f4c542;color:#382900;font-size:9px;font-weight:800}.bg-load-sentinel{height:1px}.bg-image-download-progress{position:absolute;left:0;right:0;bottom:0;height:5px;background:rgba(255,255,255,.35);overflow:hidden;z-index:2}.bg-image-download-progress span{display:block;height:100%;width:var(--bg-progress,0%);background:var(--accent);transition:width .12s linear}.bg-image-download-progress.indeterminate span{width:40%;animation:bg-download-progress 1s ease-in-out infinite}@keyframes bg-download-progress{from{transform:translateX(-100%)}to{transform:translateX(350%)}}

/* ── Caricature Studio Styles ── */
.caricature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.caricature-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.caricature-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: #fff;
  letter-spacing: 0.5px;
}
.caricature-cat-pills {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.caricature-cat-pills::-webkit-scrollbar { display: none; }
.caricature-pill {
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--neutral-border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.caricature-pill:hover {
  background: var(--surface-hover);
  color: var(--accent);
}
.caricature-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.caricature-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  grid-auto-rows: max-content;
}
.caricature-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--neutral-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
  outline: none;
}
.caricature-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.caricature-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-med);
}
.caricature-card-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--panel-muted);
  overflow: hidden;
  flex: 0 0 auto;
}
.caricature-card-thumb-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  padding: 6px;
}
.caricature-card-thumb-wrap.caricature-cutout-preview img {
  object-fit: contain;
  padding: 6px;
}
.caricature-card-view-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  padding: 0;
  box-sizing: border-box;
}
.caricature-card-view-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  cursor: pointer;
}
.caricature-card-view-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.08);
}
.caricature-card-view-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.caricature-card-view-btn .material-icons {
  font-size: 15px;
}
.caricature-slot-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 4px;
  background: var(--surface-sunken);
  color: var(--text-dim);
  border: 1px solid var(--neutral-border);
  line-height: 1.3;
}
.caricature-card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.caricature-card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 31px;
}
.caricature-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.caricature-card-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 4px;
  background: var(--surface-sunken);
  color: var(--text-dim);
  border: 1px solid var(--neutral-border);
  line-height: 1.3;
}
.caricature-card-badge-cutout {
  background: rgba(21, 128, 61, 0.1);
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.25);
}
:root[data-theme="dark"] .caricature-card-badge-cutout {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}
.caricature-card-cat {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: capitalize;
  margin-top: 2px;
}

/* Studio Drawer */
.caricature-studio-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--neutral-border);
  flex-shrink: 0;
  background: var(--panel-glass);
}
.caricature-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.caricature-back-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
}
.caricature-back-btn svg {
  display: block;
}
.caricature-studio-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.caricature-studio-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.caricature-selected-preview {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--neutral-border);
  transition: all 0.15s ease;
}
.caricature-selected-preview:hover {
  border-color: var(--accent-border);
}
.caricature-thumb-wrap {
  position: relative;
  width: 58px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel-muted);
  flex-shrink: 0;
}
.caricature-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  cursor: pointer;
}
.caricature-selected-preview.caricature-cutout-preview .caricature-thumb-wrap img {
  object-fit: contain;
  padding: 2px;
}
.caricature-thumb-view-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  transition: background 0.15s ease;
}
.caricature-thumb-view-btn:hover {
  background: var(--accent);
}
.caricature-thumb-view-btn .material-icons {
  font-size: 13px;
}
.caricature-selected-title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.caricature-meta-info {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Slots */
.caricature-slots-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.caricature-slot-card {
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.caricature-slot-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.caricature-gender-icon {
  font-size: 18px;
  color: var(--accent);
}
.caricature-dropzone {
  border: 2px dashed var(--neutral-border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  background: var(--panel-muted);
  transition: all 0.15s ease;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caricature-dropzone:hover, .caricature-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.caricature-dropzone:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.caricature-dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}
.dropzone-icon {
  font-size: 24px;
  color: var(--accent);
}
.dropzone-text {
  font-size: 11px;
}
.caricature-dropzone-filled {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caricature-slot-preview-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
.caricature-slot-remove-btn {
  position: absolute;
  top: -6px;
  right: 18%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caricature-slot-remove-btn::before {
  content: '';
  position: absolute;
  inset: -10px;
  cursor: pointer;
}
.caricature-slot-remove-btn span {
  font-size: 14px;
}
.caricature-photo-tips {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.35;
}

/* Action Buttons */
.caricature-primary-btn {
  width: 100%;
  padding: 11px 16px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-soft);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.caricature-primary-btn:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}
.caricature-primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.caricature-secondary-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--neutral-border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.caricature-secondary-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* Progress Spinner */
.caricature-progress-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--neutral-border);
  text-align: center;
  gap: 8px;
}
.caricature-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--neutral-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: caricatureSpin 0.8s linear infinite;
}
@keyframes caricatureSpin {
  to { transform: rotate(360deg); }
}
.caricature-progress-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.caricature-progress-sub {
  font-size: 10.5px;
  color: var(--text-dim);
}

/* Result Box */
.caricature-result-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid rgba(46, 125, 50, 0.3);
  box-shadow: var(--shadow-med);
}
.caricature-result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--status-success-text);
}
.caricature-result-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.caricature-result-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.caricature-result-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.caricature-loading-state, .caricature-empty-state, .caricature-error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.caricature-error-state {
  color: var(--status-danger-text);
}

/* AI Enhancement Mode Toggle Switch */
.caricature-mode-toggle {
  display: flex;
  background: var(--surface-sunken, rgba(0, 0, 0, 0.05));
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
  gap: 3px;
}
.caricature-mode-btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-dim, #666);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}
.caricature-pro-tag {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--badge-pro-bg);
  color: var(--badge-pro-text);
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

/* Quota Tracker Card */
.caricature-quota-card {
  background: var(--panel-muted, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--neutral-border, rgba(0, 0, 0, 0.08));
  border-radius: 8px;
  padding: 8px 10px;
}
.caricature-quota-upgrade-btn {
  background: var(--badge-pro-bg);
  color: var(--badge-pro-text);
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: opacity 0.15s ease;
}
.caricature-quota-upgrade-btn:hover {
  opacity: 0.9;
}

.caricature-mode-btn.active {
  background: var(--surface, #fff);
  color: var(--text-primary, #111);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.caricature-mode-btn.active .mode-title {
  color: var(--accent);
}
.caricature-mode-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  opacity: 0.95;
}

/* Before / After Result Comparison Bar */
.caricature-compare-bar {
  display: flex;
  background: var(--surface-sunken, rgba(0, 0, 0, 0.05));
  padding: 3px;
  border-radius: 6px;
  gap: 3px;
}
.caricature-compare-btn {
  flex: 1;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-dim, #666);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caricature-compare-btn::before {
  content: '';
  position: absolute;
  inset: -3px;
  cursor: pointer;
}
.caricature-compare-btn.active {
  background: var(--surface, #fff);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Transparent PNG Checkerboard Background */
.caricature-cutout-preview {
  background-color: var(--canvas-bg);
  background-image: 
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* Multi-Face Selector Modal & Cards */
.caricature-face-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: var(--surface-sunken);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}
.caricature-face-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.caricature-face-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}
.caricature-face-card img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--neutral-border);
  box-shadow: var(--shadow-soft);
  margin-bottom: 6px;
}
.caricature-face-card span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Slot Face Selection Indicator Badge */
.caricature-slot-face-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  background: #dcfce7;
  padding: 2.5px 8px;
  border-radius: 999px;
  line-height: 1.2;
}
:root[data-theme="dark"] .caricature-slot-face-badge {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.15);
}
.caricature-slot-face-badge .material-icons {
  font-size: 13px;
  color: inherit;
}
.caricature-slot-face-change-btn {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border, rgba(162, 29, 40, 0.2));
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1.2;
}
.caricature-slot-face-change-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.caricature-slot-loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--panel-glass-strong);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  border-radius: 8px;
  z-index: 10;
  overflow: hidden;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--accent-border);
}
.caricature-slot-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--neutral-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: caricatureSpin 0.75s linear infinite;
  flex-shrink: 0;
}
.caricature-slot-loading-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.caricature-slot-loading-sub {
  font-size: 9.5px;
  color: var(--text-dim);
  line-height: 1.25;
  max-width: 90%;
}
.caricature-slot-scan-beam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, #ffffff 50%, var(--accent) 70%, transparent);
  animation: caricatureScanSweep 1.3s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes caricatureScanSweep {
  0% { transform: translateY(0); opacity: 0.35; }
  50% { opacity: 0.9; }
  100% { transform: translateY(68px); opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .caricature-spinner,
  .caricature-slot-spinner {
    animation: none;
    border-color: var(--accent);
    opacity: 0.75;
  }
  .caricature-slot-scan-beam {
    display: none;
    animation: none;
  }
}

.caricature-change-template-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.caricature-change-template-btn:hover {
  background: var(--accent);
  color: #fff;
}
.caricature-reuse-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 8px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.caricature-reuse-btn:hover {
  background: var(--surface-hover);
}

/* Language picker: header dropdown + first-visit chooser. Uses the editor's
   theme tokens (editorShell.css) so it follows light/dark mode. */

.pk-lang-dropdown { position: relative; }

.pk-lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px 0 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pk-lang-trigger:hover { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.pk-lang-trigger svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pk-lang-trigger svg:last-child { width: 15px; height: 15px; opacity: 0.7; }
.pk-lang-trigger-label { font-weight: 600; white-space: nowrap; }

.pk-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  width: 248px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.16);
}
.pk-lang-menu[hidden] { display: none; }

.pk-lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pk-lang-option:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.pk-lang-option.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pk-lang-option .pk-lang-art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.pk-lang-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pk-lang-native { font-size: 15px; font-weight: 700; line-height: 1.3; }
.pk-lang-english { font-size: 12px; color: var(--text-dim); }
.pk-lang-check { width: 20px; height: 20px; color: var(--accent); visibility: hidden; flex: none; }
.pk-lang-check svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pk-lang-option.selected .pk-lang-check { visibility: visible; }

/* ── First-visit chooser ───────────────────────────────────────────────── */
.pk-lang-chooser-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(15 10 10 / 0.55);
  backdrop-filter: blur(3px);
}
.pk-lang-chooser {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 28px 24px 24px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.3);
}
.pk-lang-chooser-logo { width: 64px; height: 64px; object-fit: contain; }
.pk-lang-chooser-title { margin: 10px 0 4px; font-size: 22px; font-weight: 700; }
.pk-lang-chooser-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.pk-lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pk-lang-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--panel-muted, var(--surface));
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pk-lang-tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.pk-lang-tile.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.pk-lang-tile .pk-lang-art { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.pk-lang-tile .pk-lang-names { align-items: center; padding: 8px 6px 10px; }
.pk-lang-tile .pk-lang-native { font-size: 17px; }
.pk-lang-continue {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.pk-lang-continue:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
  .pk-lang-trigger { padding: 0 8px; }
  .pk-lang-trigger svg:last-child { display: none; }
}

/* ── Coming-soon languages (no templates yet) ─────────────────────────── */
.pk-lang-soon { position: relative; }
.pk-lang-soon .pk-lang-art { filter: grayscale(0.85); opacity: 0.6; }
.pk-lang-soon .pk-lang-names { opacity: 0.6; }
.pk-lang-soon-badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pk-lang-tile.pk-lang-soon .pk-lang-soon-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
}
.pk-lang-option.pk-lang-soon .pk-lang-check { display: none; }

.pk-lang-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10001;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f1b1a;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.pk-lang-toast[hidden] { display: none; }
/* ─────────────────────────────────────────────────────────────────────────────
   Editor theme — the design-tool presentation layer.

   Loaded after editorShell.css and only restyles: every id, class and piece of
   editor behaviour underneath is unchanged. Desktop rules sit behind
   (min-width: 761px) so the separately tuned phone layout is left alone.

   Tokens: --pk-* are the shared vocabulary for the redesigned shell. They alias
   the existing brand values instead of redefining the brand.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --pk-primary: #A21D28;
  --pk-primary-hover: #8a1721;
  --pk-accent: #F97316;
  --pk-primary-gradient: linear-gradient(135deg, #B51224 0%, #F97316 100%);
  --pk-primary-gradient-hover: linear-gradient(135deg, #941020 0%, #EA580C 100%);
  --pk-primary-soft: rgba(162, 29, 40, 0.08);
  --pk-primary-soft-strong: rgba(162, 29, 40, 0.14);

  --pk-bg: #F4F4F5;
  --pk-surface: #FFFFFF;
  --pk-surface-hover: #F6F6F7;
  --pk-surface-sunken: #F9F9FA;
  --pk-sticker-check-a: #E4E4E7;
  --pk-sticker-check-b: #D4D4D8;

  --pk-text: #18181B;
  --pk-text-secondary: #71717A;
  --pk-text-tertiary: #A1A1AA;

  --pk-border: #E4E4E7;
  --pk-border-strong: #D4D4D8;

  --pk-radius-sm: 6px;
  --pk-radius-md: 10px;
  --pk-radius-lg: 14px;

  --pk-shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.05);
  --pk-shadow-sm: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
  --pk-shadow-md: 0 8px 24px rgba(24, 24, 27, 0.08), 0 2px 6px rgba(24, 24, 27, 0.04);
  --pk-shadow-artboard: 0 1px 2px rgba(24, 24, 27, 0.06), 0 18px 48px rgba(24, 24, 27, 0.12);

  --pk-sidebar-width: 76px;
  --pk-content-panel-width: 300px;
  --pk-properties-width: 340px;
  --pk-header-height: 68px;

  --pk-ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  --pk-primary: #e04854;
  --pk-primary-hover: #cc3543;
  --pk-accent: #ffaa33;
  --pk-primary-gradient: linear-gradient(135deg, #e04854 0%, #ffaa33 100%);
  --pk-primary-gradient-hover: linear-gradient(135deg, #d946ef 0%, #7c3aed 100%);
  --pk-primary-soft: rgba(224, 72, 84, 0.12);
  --pk-primary-soft-strong: rgba(224, 72, 84, 0.2);

  --pk-bg: #141113;
  --pk-surface: #1f1b1e;
  --pk-surface-hover: #2a2328;
  --pk-surface-sunken: #191518;
  --pk-sticker-check-a: #1c1c23;
  --pk-sticker-check-b: #26262e;

  --pk-text: #f4f4f5;
  --pk-text-secondary: #a1a1aa;
  --pk-text-tertiary: #71717a;

  --pk-border: rgba(255, 255, 255, 0.08);
  --pk-border-strong: rgba(255, 255, 255, 0.14);

  --pk-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --pk-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --pk-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --pk-shadow-artboard: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 18px 48px rgba(0, 0, 0, 0.6);
}

@media (min-width: 761px) {
  /* Re-point the shell's own tokens at the neutral palette, so every existing
     rule that already reads them (menus, cards, inputs) follows along. */
  :root {
    --app-header-height: var(--pk-header-height);
    --nav-width: var(--pk-sidebar-width);
    /* #library holds the sidebar AND the content panel. */
    --library-width: calc(var(--pk-sidebar-width) + var(--pk-content-panel-width));
    --inspector-width: var(--pk-properties-width);
    --workspace: var(--pk-bg);
    --canvas-shadow: var(--pk-shadow-artboard);
    --panel-glass: var(--pk-surface);
    --panel-glass-strong: var(--pk-surface);
    --panel-muted: var(--pk-surface-sunken);
    --neutral-border: var(--pk-border);
    --border: var(--pk-border);
    --surface: var(--pk-surface-sunken);
    --panel: var(--pk-surface);
    --text: var(--pk-text);
    --surface-hover: var(--pk-surface-hover);
    --surface-strong: var(--pk-border);
    --text-primary: var(--pk-text);
    --text-dim: var(--pk-text-secondary);
    --accent-soft: var(--pk-primary-soft);
    --shadow-soft: var(--pk-shadow-sm);
    --shadow-med: var(--pk-shadow-md);
  }
  @media (max-width: 1440px) {
    :root { --library-width: calc(var(--pk-sidebar-width) + 264px); --inspector-width: 312px; }
  }

  body { background: var(--pk-bg); color: var(--pk-text); }

  /* ── TopAppBar ──────────────────────────────────────────────────────────── */
  #header {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 0 16px 0 14px;
    background: var(--pk-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--pk-border);
    box-shadow: none;
  }
  #brand-area { gap: 14px; }
  #brand-home { gap: 10px; font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
  #brand-home img { width: 36px; height: 36px; flex-basis: 36px; border-radius: 10px; box-shadow: var(--pk-shadow-sm); }

  /* DocumentBreadcrumb: "Design › <title>" */
  #document-meta {
    gap: 6px;
    padding-left: 14px;
    border-left: 1px solid var(--pk-border);
    font-size: 13px;
    color: var(--pk-text-secondary);
  }
  .doc-crumb { color: var(--pk-text-secondary); font-weight: 500; white-space: nowrap; }
  .doc-crumb-sep { width: 14px; height: 14px; flex: 0 0 14px; color: var(--pk-text-tertiary); }
  #template-name {
    max-width: 240px;
    padding: 4px 6px;
    margin-left: -2px;
    border: 1px solid transparent;
    border-radius: var(--pk-radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--pk-text);
    cursor: text;
    outline: none;
    transition: border-color .15s, background .15s;
  }
  #template-name:hover { border-color: var(--pk-border); background: var(--pk-surface-hover); }
  #template-name[contenteditable="true"] {
    max-width: 320px;
    border-color: var(--pk-primary);
    background: var(--pk-surface);
    box-shadow: 0 0 0 3px var(--pk-primary-soft);
    text-overflow: clip;
  }

  /* HistoryControls: two quiet icon buttons, no capsule */
  #history-controls {
    gap: 2px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    justify-self: start;
  }
  #history-controls button {
    width: 34px; min-width: 34px; min-height: 34px; height: 34px;
    border-radius: var(--pk-radius-md);
    color: var(--pk-text-secondary);
  }
  #history-controls button:hover:not(:disabled) { background: var(--pk-surface-hover); color: var(--pk-text); }

  /* DocumentStatus — centred, quiet, colour carries the state */
  #header-status { display: flex; justify-content: center; min-width: 0; }
  #status {
    min-height: 28px;
    padding: 4px 10px 4px 8px;
    gap: 6px;
    border-radius: var(--pk-radius-md);
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--status-success-text);
  }
  #status::before {
    width: 18px; height: 18px; border-radius: 0;
    background: currentColor;
    -webkit-mask: var(--pk-status-icon) center / contain no-repeat;
    mask: var(--pk-status-icon) center / contain no-repeat;
  }
  #status { --pk-status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .8-7.9A6 6 0 0 0 6.4 9 4.5 4.5 0 0 0 7 18Z'/%3E%3Cpath d='m9 13 2 2 4-4'/%3E%3C/svg%3E"); }
  #status[data-state="saving"] { background: transparent; --pk-status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .8-7.9A6 6 0 0 0 6.4 9 4.5 4.5 0 0 0 7 18Z'/%3E%3Cpath d='M12 11v4m-2-2 2-2 2 2'/%3E%3C/svg%3E"); }
  #status[data-state="dirty"] { background: transparent; color: var(--pk-text-secondary); --pk-status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .8-7.9A6 6 0 0 0 6.4 9 4.5 4.5 0 0 0 7 18Z'/%3E%3Ccircle cx='12' cy='13' r='1.6' fill='black'/%3E%3C/svg%3E"); }
  #status[data-state="error"] { background: transparent; --pk-status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 18h10a4 4 0 0 0 .8-7.9A6 6 0 0 0 6.4 9 4.5 4.5 0 0 0 7 18Z'/%3E%3Cpath d='M12 10v3m0 2.5v.01'/%3E%3C/svg%3E"); }

  /* Actions: ghost secondaries, one strong primary */
  #header-actions { gap: 6px; }
  .toolbar-btn,
  #header-actions > button,
  #theme-toggle-btn {
    min-height: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--pk-radius-md);
    border: 1px solid var(--pk-border);
    background: var(--pk-surface);
    color: var(--pk-text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--pk-shadow-xs);
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  }
  .toolbar-btn:hover:not(:disabled),
  #header-actions > button:hover:not(:disabled),
  #theme-toggle-btn:hover { background: var(--pk-surface-hover); border-color: var(--pk-border-strong); }
  .toolbar-btn.icon-only,
  #theme-toggle-btn { width: 36px; min-width: 36px; padding: 0; }
  #header-actions > #theme-toggle-btn { border-color: transparent; background: transparent; box-shadow: none; color: var(--pk-text-secondary); }
  #header-actions > #theme-toggle-btn:hover { color: var(--pk-text); background: var(--pk-surface-hover); }
  #zoom-bar #zoomReset { display: none; }
  /* Brand name returns wherever the header has room for it. */
  @media (min-width: 1280px) { #brand-home span { display: inline; } }
  /* Actions read left→right: utilities | upgrade · account | document actions | export. */
  #header-actions > #theme-toggle-btn { order: 1; }
  #header-actions > #header-upgrade-btn { order: 3; }
  #header-actions > #new-design-btn { order: 4; }
  #header-actions > #preview-btn { order: 5; }
  #header-actions > #save { order: 6; }
  #header-actions > #download-trigger-btn { order: 7; }
  #header-actions > #account-menu-wrap { order: 8; margin-left: 4px; }
  #header-actions > #more-actions-wrap { order: 9; }
  #header-actions > #mobile-more-wrap,
  #header-actions > #mobile-zoom-btn,
  #header-actions > #psd-import-warnings { order: 10; }
  #header-actions > #header-upgrade-btn { margin-left: 6px; }
  #header-actions > #header-upgrade-btn::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 7px;
    bottom: 7px;
    width: 1px;
    background: var(--pk-border);
  }
  .toolbar-btn .material-icons,
  #header-actions > button .material-icons { width: 18px; height: 18px; flex-basis: 18px; font-size: 18px; }
  #save { color: var(--pk-text); border-color: var(--pk-border); background: var(--pk-surface); }

  #header-actions > #download-trigger-btn {
    padding: 0 16px;
    border: 0;
    background: var(--export-gradient);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(162, 29, 40, .25), 0 6px 16px rgba(234, 88, 12, .22);
  }
  #header-actions > #download-trigger-btn:hover:not(:disabled) { background: var(--export-gradient-hover); color: #fff; }
  :root[data-theme="dark"] #header-actions > #download-trigger-btn { box-shadow: 0 6px 18px rgba(236, 72, 153, .25); }

  /* UpgradeButton: warm outline, not a second primary. Always labelled on a
     desktop, instead of the old hover-to-reveal pill. */
  #header-actions > #header-upgrade-btn.header-upgrade-pill {
    position: relative;
    overflow: visible;
    max-width: none;
    transform: none;
    height: 36px;
    min-height: 36px;
    padding: 0 12px;
    gap: 6px;
    border: 1px solid rgba(234, 88, 12, .35);
    border-radius: var(--pk-radius-md);
    background: rgba(249, 115, 22, .07);
    color: #C2410C;
    font-size: 13px;
    font-weight: 700;
    box-shadow: none;
  }
  #header-actions > #header-upgrade-btn.header-upgrade-pill:hover { background: rgba(249, 115, 22, .13); box-shadow: none; padding: 0 12px; }
  #header-upgrade-btn.header-upgrade-pill .button-label,
  #header-upgrade-btn.header-upgrade-pill:hover .button-label { opacity: 1; max-width: none; margin-left: 0; }
  #header-upgrade-btn.header-upgrade-pill .material-icons { color: #EA580C; font-size: 18px; }
  @media (max-width: 1280px) {
    #header-upgrade-btn.header-upgrade-pill .button-label { display: none; }
    #header-actions > #header-upgrade-btn.header-upgrade-pill { width: 36px; padding: 0; justify-content: center; }
  }
  :root[data-theme="dark"] #header-actions > #header-upgrade-btn.header-upgrade-pill { color: #fdba74; border-color: rgba(253, 186, 116, .3); background: rgba(253, 186, 116, .08); }

  /* UserMenu trigger: a plain secondary button while signed out, the avatar
     once signed in. */
  #header-actions .account-status {
    min-width: 0;
    min-height: 36px;
    height: 36px;
    padding: 0 12px;
    gap: 7px;
    border: 1px solid var(--pk-border);
    border-radius: var(--pk-radius-md);
    background: var(--pk-surface);
    color: var(--pk-text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--pk-shadow-xs);
    transform: none;
  }
  #header-actions .account-status:hover { background: var(--pk-surface-hover); border-color: var(--pk-border-strong); box-shadow: var(--pk-shadow-xs); transform: none; }
  #header-actions .account-status .material-icons { color: var(--pk-text-secondary); font-size: 18px; width: 18px; height: 18px; flex-basis: 18px; }
  #header-actions .account-status .account-status-avatar { width: 30px; height: 30px; flex-basis: 30px; }
  #header-actions .account-status.signed-in { padding: 0 4px; width: 36px; min-width: 36px; border-color: transparent; background: transparent; }
  .header-divider { width: 1px; height: 22px; background: var(--pk-border); flex: 0 0 1px; margin: 0 4px; }

  /* ── SidebarNavigation ─────────────────────────────────────────────────── */
  #library { background: var(--pk-surface); border-right: 1px solid var(--pk-border); backdrop-filter: none; -webkit-backdrop-filter: none; }
  #library-nav {
    width: var(--pk-sidebar-width);
    padding: 10px 8px;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    background: var(--pk-surface);
    border-right: 1px solid var(--pk-border);
  }
  #library-nav::-webkit-scrollbar { display: none; }
  .nav-tab {
    position: relative;
    flex: 0 0 auto;
    width: 60px;
    min-height: 58px;
    padding: 8px 2px 7px;
    gap: 5px;
    border: 0;
    border-radius: var(--pk-radius-md);
    color: var(--pk-text-secondary);
    transition: background .15s, color .15s;
  }
  .nav-tab .material-icons, .nav-tab .nav-icon { font-size: 21px; }
  .nav-tab .nav-icon--asset { width: 21px; height: 21px; }
  .nav-tab svg.nav-icon, .nav-tab .nav-icon svg { width: 21px; height: 21px; }
  .nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0; line-height: 1.15; }
  .nav-tab:hover { background: var(--pk-surface-hover); color: var(--pk-text); }
  .nav-tab.active { background: var(--pk-primary-soft); color: var(--pk-primary); border: 0; box-shadow: none; }
  .nav-tab.active .nav-label { font-weight: 700; }
  .nav-tab.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--pk-primary);
  }
  .nav-tab:focus-visible { outline: 2px solid var(--pk-primary); outline-offset: 1px; }
  .nav-tab:disabled { opacity: .4; cursor: not-allowed; }

  /* ── ContentPanel ──────────────────────────────────────────────────────── */
  #library-content { background: var(--pk-surface); }
  .tab-pane h2 {
    padding: 18px 16px 12px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--pk-text);
    border: 0;
  }
  #lib-search-input,
  #sticker-search-input,
  .pk-search-field {
    min-height: 38px;
    border: 1px solid var(--pk-border);
    border-radius: var(--pk-radius-md);
    background-color: var(--pk-surface-sunken);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 16px;
    background-position: 12px center;
    padding-left: 36px;
    color: var(--pk-text);
    font-size: 13px;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
  }
  #lib-search-input:focus,
  #sticker-search-input:focus,
  .pk-search-field:focus { outline: none; border-color: var(--pk-primary); background-color: var(--pk-surface); box-shadow: 0 0 0 3px var(--pk-primary-soft); }
  .panel-subhead { padding: 12px 16px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--pk-text-tertiary); }
  #library-legal { border-top: 1px solid var(--pk-border); }

  /* Cards in every library grid share one quiet treatment */
  .preset-text-btn,
  .sticker-item-btn,
  .shape-item-btn,
  .textart-category-btn {
    border: 1px solid var(--pk-border);
    border-radius: var(--pk-radius-md);
    background: var(--pk-surface);
    transition: border-color .15s, box-shadow .15s, transform .15s var(--pk-ease);
  }
  .preset-text-btn:hover,
  .sticker-item-btn:hover,
  .shape-item-btn:hover,
  .textart-category-btn:hover { border-color: var(--pk-border-strong); box-shadow: var(--pk-shadow-md); }
  .template-item img { border-radius: 8px; }

  /* ── CanvasWorkspace ───────────────────────────────────────────────────── */
  #center { background: var(--pk-bg); }
  #stage {
    background: var(--pk-bg);
    background-image: radial-gradient(circle, rgba(24, 24, 27, .07) 1px, transparent 1.2px);
    background-size: 22px 22px;
  }
  :root[data-theme="dark"] #stage { background-image: radial-gradient(circle, rgba(255, 255, 255, .06) 1px, transparent 1.2px); }
  .tm-canvas { box-shadow: var(--pk-shadow-artboard); border-radius: 2px; }

  /* ── CanvasControlBar ──────────────────────────────────────────────────── */
  #zoom-bar {
    min-height: 44px;
    padding: 4px;
    gap: 2px;
    border: 1px solid var(--pk-border);
    border-radius: 12px;
    background: var(--pk-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: var(--pk-shadow-md);
  }
  .pk-ctrl-btn,
  #zoomFit,
  #zoomReset {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--pk-text);
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  #zoomFit { width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; }
  .pk-ctrl-btn:hover:not(:disabled),
  #zoomFit:hover,
  #zoomReset:hover { background: var(--pk-surface-hover); }
  .pk-ctrl-btn[aria-pressed="true"],
  #zoomFit.active { background: var(--pk-primary-soft); color: var(--pk-primary); }
  .pk-ctrl-btn svg { width: 18px; height: 18px; }
  .pk-ctrl-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--pk-border); flex: 0 0 1px; }
  #zoom-bar #zoomSlider { display: none; }
  #zoomPercentBtn {
    position: relative;
    min-width: 58px;
    height: 34px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--pk-text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
  }
  #zoomPercentBtn:hover, #zoomPercentBtn[aria-expanded="true"] { background: var(--pk-surface-hover); }
  #zoomPercent { min-width: 0; font-weight: 600; }
  #zoom-presets {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 124px;
    padding: 4px;
    display: grid;
    gap: 2px;
    border: 1px solid var(--pk-border);
    border-radius: 10px;
    background: var(--pk-surface);
    box-shadow: var(--pk-shadow-md);
    z-index: 30;
  }
  #zoom-presets[hidden] { display: none; }
  #zoom-presets .zoom-preset {
    width: 100%;
    min-height: 32px;
    padding: 0 10px;
    justify-content: flex-start;
    text-align: left;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
  }
  #zoom-presets .zoom-preset:hover { background: var(--pk-surface-hover); }
  #zoom-presets .zoom-preset.active { background: var(--pk-primary-soft); color: var(--pk-primary); }
  .zoom-bar-group { position: relative; display: inline-flex; align-items: center; gap: 2px; }
  #pages-toggle {
    height: 34px;
    min-height: 34px;
    margin-left: 2px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pk-text);
  }
  #pages-toggle:hover:not(:disabled) { background: var(--pk-surface-hover); }
  #pages-count { color: var(--pk-text-secondary); font-weight: 500; }
  body.pk-hand-tool #stage { cursor: grab; }
  body.pk-hand-tool.pk-panning #stage { cursor: grabbing; }
  body.pk-hand-tool #stage .tm-canvas { pointer-events: none; }

  #page-rail { border: 1px solid var(--pk-border); border-radius: 12px; background: var(--pk-surface); box-shadow: var(--pk-shadow-md); }

  /* ── PropertiesPanel ───────────────────────────────────────────────────── */
  #inspector { background: var(--pk-surface); border-left: 1px solid var(--pk-border); backdrop-filter: none; -webkit-backdrop-filter: none; }
  #inspector-header { min-height: 48px; padding: 0 12px; border-bottom: 1px solid var(--pk-border); }
  .inspector-tab {
    min-height: 47px;
    border-radius: 0;
    color: var(--pk-text-secondary);
    font-size: 13px;
    font-weight: 600;
  }
  .inspector-tab:hover { color: var(--pk-text); }
  .inspector-tab[aria-selected="true"] { color: var(--pk-primary); }
}

/* New control-bar pieces outside the desktop query: keep phones on their
   existing compact bar (Fit, slider, %, reset, pages). */
#zoomPercentBtn { border: 0; background: transparent; color: inherit; font: inherit; padding: 0 4px; cursor: pointer; }
.zoom-bar-group { position: relative; display: inline-flex; align-items: center; }
@media (max-width: 760px) {
  #header-status,
  #handToolBtn,
  #zoomOutBtn,
  #zoomInBtn,
  #fullscreenBtn,
  #zoom-bar .pk-ctrl-sep,
  #zoom-presets { display: none !important; }
  #zoomPercentBtn { pointer-events: none; }
  .doc-crumb, .doc-crumb-sep { display: none; }
}

/* ── PropertyGroup sections (propertyGroups.ts) ────────────────────────────── */
.pk-group { border-bottom: 1px solid var(--neutral-border); }
.pk-group[hidden] { display: none; }
.pk-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px 0 16px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.pk-group-head::-webkit-details-marker { display: none; }
.pk-group-head:hover { background: var(--surface-hover); }
.pk-group-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pk-group-icon { width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-dim); }
.pk-group-title { flex: 1; }
.pk-group-chevron { width: 16px; height: 16px; flex: 0 0 16px; color: var(--text-dim); transition: transform .2s var(--pk-ease); }
.pk-group[open] > .pk-group-head .pk-group-chevron { transform: rotate(180deg); }
.pk-group-body { padding: 0 0 6px; }
/* Members were full-width panel sections; inside a group they are sub-rows. */
#inspector .pk-group-body > .prop-group,
#inspector .pk-group-body > div > .prop-group { border-bottom: 0; padding-top: 6px; padding-bottom: 8px; }
#inspector .pk-group-body #arrange-group { margin-top: 0 !important; border-top: 0 !important; }
#prop-text > .pk-group[data-pk-group="color"] { order: 10; }
#prop-text > .pk-group[data-pk-group="style"] { order: 20; }
#prop-text > .pk-group[data-pk-group="stroke"] { order: 21; }
#prop-text > .pk-group[data-pk-group="effects"] { order: 22; }
#prop-text > .pk-group[data-pk-group="spacing"] { order: 15; }
@media (max-width: 760px) {
  /* Phones show one control group per sheet: no section chrome there. */
  .pk-group { border-bottom: 0; }
  .pk-group-head { display: none; }
}

@media (min-width: 761px) {
  /* Calmer property rows: sentence-case labels, tighter rhythm. */
  #inspector .prop-section-title { padding: 16px 16px 4px; font-size: 15px; font-weight: 700; color: var(--pk-text); }
  #inspector .prop-group { padding: 10px 16px; }
  #inspector .prop-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--pk-text-secondary);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 7px;
  }
  #inspector .swatch-palette-header { font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--pk-text-secondary); }
  #inspector textarea,
  #inspector select,
  #inspector .textart-font-button {
    border: 1px solid var(--pk-border) !important;
    border-radius: var(--pk-radius-md) !important;
    background: var(--pk-surface) !important;
    color: var(--pk-text) !important;
    min-height: 38px;
    font-size: 13px;
  }
  #inspector textarea:focus,
  #inspector select:focus,
  #inspector .textart-font-button:focus-visible { border-color: var(--pk-primary) !important; box-shadow: 0 0 0 3px var(--pk-primary-soft); outline: none; }
  #inspector textarea { padding: 9px 11px !important; line-height: 1.45; }
  #inspector .segmented-control { padding: 3px; gap: 3px; border: 1px solid var(--pk-border); border-radius: var(--pk-radius-md); background: var(--pk-surface-sunken); }
  #inspector .segmented-control .segment-btn { border: 0; border-radius: 7px; min-height: 30px; font-size: 12.5px; font-weight: 600; color: var(--pk-text-secondary); background: transparent; box-shadow: none; }
  #inspector .segmented-control .segment-btn.active { background: var(--pk-surface); color: var(--pk-primary); box-shadow: var(--pk-shadow-sm); }
  #inspector .prop-row-label,
  #inspector .prop-value-badge { border-color: var(--pk-border); background: var(--pk-surface); border-radius: 8px; }
  #inspector input[type="range"] { background: var(--pk-border); height: 4px; }
  #inspector input[type="range"]::-webkit-slider-thumb { width: 16px; height: 16px; border: 2px solid #fff; background: var(--pk-primary); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
  #text-align-controls .aspect-btn.icon-btn { border-radius: 8px; }
  #inspector-edit-panel { scrollbar-gutter: stable; }
}

/* ── ContextualToolbar (contextToolbar.ts) ─────────────────────────────────── */
#context-toolbar { display: none; }
@media (min-width: 761px) {
  #center { position: relative; }
  /* Room above the artboard for the toolbar; Fit already reserves this much. */
  #stage { padding-top: 60px; padding-bottom: 28px; }
  #context-toolbar:not([hidden]) {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 2px;
    max-width: calc(100% - 24px);
    height: 44px;
    padding: 4px;
    border: 1px solid var(--pk-border);
    border-radius: 12px;
    background: var(--pk-surface);
    box-shadow: var(--pk-shadow-md);
    animation: ctb-in .16s var(--pk-ease);
  }
  body.preview-mode #context-toolbar { display: none !important; }
  @keyframes ctb-in { from { opacity: 0; transform: translate(-50%, -4px); } }
  @media (prefers-reduced-motion: reduce) { #context-toolbar:not([hidden]) { animation: none; } }

  #context-toolbar [hidden] { display: none !important; }
  .ctb-btn {
    flex: 0 0 auto;
    min-width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--pk-text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  .ctb-btn[data-wide] { padding: 0 10px; }
  .ctb-btn:hover { background: var(--pk-surface-hover); }
  .ctb-btn:focus-visible { outline: 2px solid var(--pk-primary); outline-offset: -2px; }
  .ctb-btn[aria-pressed="true"],
  .ctb-btn[aria-expanded="true"] { background: var(--pk-primary-soft); color: var(--pk-primary); }
  .ctb-btn[data-ctb="font"], .ctb-btn[data-ctb="art-font"] {
    min-width: 132px;
    max-width: 180px;
    justify-content: space-between;
    border: 1px solid var(--pk-border);
    height: 32px;
  }
  .ctb-font-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
  .ctb-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--pk-border); flex: 0 0 1px; }
  .ctb-stepper { display: inline-flex; align-items: center; height: 32px; border: 1px solid var(--pk-border); border-radius: 8px; overflow: hidden; }
  .ctb-stepper .ctb-btn { height: 30px; min-width: 28px; border-radius: 0; }
  .ctb-stepper input {
    width: 40px;
    height: 30px;
    border: 0;
    border-left: 1px solid var(--pk-border);
    border-right: 1px solid var(--pk-border);
    background: transparent;
    color: var(--pk-text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    -moz-appearance: textfield;
  }
  .ctb-stepper input::-webkit-inner-spin-button,
  .ctb-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .ctb-stepper input:focus { outline: none; background: var(--pk-primary-soft); }
  .ctb-swatch { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15), 0 0 0 2px var(--pk-surface), 0 0 0 3px var(--pk-border); }
  .ctb-pop-wrap { position: relative; display: inline-flex; }
  .ctb-pop {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    padding: 12px;
    border: 1px solid var(--pk-border);
    border-radius: 12px;
    background: var(--pk-surface);
    box-shadow: var(--pk-shadow-md);
  }
  .ctb-pop label { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--pk-text-secondary); }
  .ctb-pop-value { color: var(--pk-text); font-variant-numeric: tabular-nums; }
  .ctb-pop input[type="range"] { width: 100%; accent-color: var(--pk-primary); }
  @media (max-width: 1100px) { .ctb-label { display: none; } .ctb-btn[data-ctb="font"], .ctb-btn[data-ctb="art-font"] { min-width: 96px; } }
}

/* ── Content panels ────────────────────────────────────────────────────────── */
.text-panel-body { flex: 1; overflow-y: auto; padding: 0 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.text-panel-body .panel-subhead { padding: 4px 4px 2px; }
#tab-text .preset-text-btn {
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 1px solid var(--neutral-border);
  border-radius: 12px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
#tab-text .preset-text-btn:hover { border-color: var(--accent-border); box-shadow: var(--shadow-med); }
#tab-text .preset-text-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.preset-sample { font-family: 'Mukta Malar', 'Noto Sans Tamil', sans-serif; line-height: 1.25; }
.add-heading .preset-sample { font-size: 24px; font-weight: 800; }
.add-subheading .preset-sample { font-size: 17px; font-weight: 700; }
.add-body .preset-sample { font-size: 13.5px; font-weight: 500; color: var(--text-dim); }
.text-panel-tip {
  margin-top: 6px;
  padding: 12px;
  display: flex;
  gap: 10px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.5;
}
.text-panel-tip-badge {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-family: 'Mukta Malar', 'Noto Sans Tamil', sans-serif;
}

@media (min-width: 761px) {
  #shape-list.grid-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 4px 12px 16px; align-content: start; }
  #shape-list .shape-item-btn { aspect-ratio: 1; min-width: 0; min-height: 0; padding: 8px 4px 6px; gap: 4px; }
  #shape-list .shape-label { max-width: 100%; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
  #shape-list .shape-preview-svg { width: 30px; height: 30px; color: var(--pk-text); }
  #shape-list .shape-label { font-size: 10.5px; color: var(--pk-text-secondary); }

  #sticker-category-select,
  #tab-stickers select {
    min-height: 38px;
    padding: 0 34px 0 12px !important;
    border: 1px solid var(--pk-border) !important;
    border-radius: var(--pk-radius-md) !important;
    background: var(--pk-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px !important;
    color: var(--pk-text) !important;
    font-size: 13px !important;
    appearance: none;
  }
}

.upload-dropzone {
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1.5px dashed var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-muted);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.upload-dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.upload-dropzone-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.upload-dropzone-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.upload-dropzone-hint { margin-bottom: 8px; font-size: 11.5px; color: var(--text-dim); }
.upload-dropzone #user-upload-btn { border-radius: 10px !important; min-height: 38px; }
#user-uploads-list:empty::before {
  content: 'Images you upload will be listed here, ready to reuse.';
  grid-column: 1 / -1;
  padding: 18px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ── LayerManager ──────────────────────────────────────────────────────────── */
@media (min-width: 761px) {
  #layer-list { padding: 6px 8px 100px; }
  #layer-list-toolbar { min-height: 44px; padding: 6px 14px; }
  #layer-list-title { font-size: 13px; font-weight: 700; }
  .layer-item-row {
    min-height: 44px;
    margin-bottom: 2px;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
  }
  .layer-item-row:hover { background: var(--pk-surface-hover); border-color: transparent; }
  .layer-item-row.selected { background: var(--pk-primary-soft); border-color: var(--pk-primary-soft-strong); box-shadow: none; }
  .layer-drag-handle { width: 22px; min-width: 22px; height: 28px; opacity: .45; }
  .layer-item-row:hover .layer-drag-handle { opacity: .8; }
  .layer-drag-handle .material-icons, .layer-drag-handle svg { width: 16px; height: 16px; font-size: 16px; color: var(--pk-text-secondary) !important; fill: var(--pk-text-secondary) !important; }
  .layer-item-select { min-height: 38px; padding: 2px 6px; gap: 10px; font-size: 13px; font-weight: 500; }
  .layer-item-row.selected .layer-item-select { color: var(--pk-primary); font-weight: 600; }
  .layer-thumb { width: 32px; height: 32px; flex-basis: 32px; border-radius: 7px; border-color: var(--pk-border); }
}

/* ── Narrow desktop (side panels become drawers) ───────────────────────────── */
@media (min-width: 761px) and (max-width: 1280px) {
  #header-actions > #new-design-btn .button-label,
  #header-actions > #preview-btn .button-label { display: none; }
  #header-actions > #new-design-btn,
  #header-actions > #preview-btn { width: 36px; min-width: 36px; padding: 0; }
}
@media (min-width: 761px) and (max-width: 1160px) {
  #header-actions > #save .button-label,
  #header-actions .account-status .account-status-label { display: none; }
  #header-actions > #save,
  #header-actions .account-status { width: 36px; min-width: 36px; padding: 0; justify-content: center; }
  #status { font-size: 0; gap: 0; padding: 4px; }
  #status::before { margin: 0; }
  /* Keep the toolbar centred on the part of the workspace the drawer leaves. */
  body:has(#inspector.visible) #context-toolbar:not([hidden]) { left: calc((100% - var(--inspector-width)) / 2); max-width: calc(100% - var(--inspector-width) - 24px); overflow-x: auto; }
  body:has(#library.visible) #context-toolbar:not([hidden]) { left: calc(var(--library-width) + (100% - var(--library-width)) / 2); }
}

/* Toolbar colour popover */
@media (min-width: 761px) {
  .ctb-color-pop { width: 232px; }
  .ctb-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 10px; }
  .ctb-color-chip {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
  }
  .ctb-color-chip:hover { transform: scale(1.08); box-shadow: 0 0 0 2px var(--pk-surface), 0 0 0 4px var(--pk-primary); }
  .ctb-color-chip.is-transparent { background: repeating-conic-gradient(#e4e4e7 0% 25%, #fff 0% 50%) 50% / 10px 10px; }
  .ctb-color-sub { margin: 2px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--pk-text-secondary); }
  .ctb-grad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; max-height: 120px; overflow-y: auto; }
  .ctb-grad-chip {
    width: 100%; aspect-ratio: 2 / 1; padding: 0; cursor: pointer;
    border: 1px solid rgba(0, 0, 0, .12); border-radius: 8px;
    transition: transform .12s, box-shadow .12s;
  }
  .ctb-grad-chip:hover { transform: scale(1.06); box-shadow: 0 0 0 2px var(--pk-surface), 0 0 0 4px var(--pk-primary); }
  .ctb-grad-more {
    display: block; width: 100%; margin-bottom: 10px; padding: 6px 0; border: 0; background: transparent;
    color: var(--pk-primary); font: inherit; font-size: 12px; font-weight: 600; text-align: left; cursor: pointer;
  }
  .ctb-grad-more:hover { text-decoration: underline; }
  .ctb-color-custom {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 10px;
    margin: 0 !important;
    padding: 8px 10px;
    border: 1px solid var(--pk-border);
    border-radius: 10px;
    color: var(--pk-text) !important;
    font-size: 12.5px !important;
    cursor: pointer;
  }
  .ctb-color-custom:hover { background: var(--pk-surface-hover); }
  .ctb-color-custom input { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
}

/* Sidebar icons: inline SVG (crisp at any DPI), darker ink than the labels. */
.nav-tab .nav-svg { width: 22px; height: 22px; flex: 0 0 22px; font-size: 0; }
@media (min-width: 761px) {
  .nav-tab { color: #3F3F46; }
  .nav-tab .nav-label { color: #52525B; }
  .nav-tab:hover, .nav-tab:hover .nav-label { color: var(--pk-text); }
  .nav-tab.active, .nav-tab.active .nav-label { color: var(--pk-primary); }
  .nav-tab.active .nav-svg { stroke-width: 2; }
  :root[data-theme="dark"] .nav-tab { color: #D4D4D8; }
  :root[data-theme="dark"] .nav-tab .nav-label { color: #A1A1AA; }
  :root[data-theme="dark"] .nav-tab.active,
  :root[data-theme="dark"] .nav-tab.active .nav-label { color: var(--pk-primary); }
}

/* ── Background panel ──────────────────────────────────────────────────────── */
#tab-background.tab-pane.active { overflow-y: auto; }
.bg-tabs { display: flex; gap: 4px; margin: 0 12px 4px; border-bottom: 1px solid var(--neutral-border); }
.bg-tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.bg-tab:hover { color: var(--text-primary); }
.bg-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.bg-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bg-pane { padding: 12px 12px 20px; display: flex; flex-direction: column; gap: 18px; }
.bg-pane[hidden] { display: none; }
.bg-section-title { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.bg-section[hidden] { display: none; }

.bg-current { display: flex; align-items: center; gap: 8px; }
.bg-well {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--neutral-border);
  box-shadow: inset 0 0 0 2px var(--panel-glass-strong);
  cursor: pointer;
}
.bg-well input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; padding: 0; cursor: pointer; }
.bg-hex {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.bg-hex:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bg-icon-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--neutral-border);
  border-radius: 10px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  cursor: pointer;
}
.bg-icon-btn:hover { background: var(--surface-hover); }
.bg-icon-btn[hidden] { display: none; }

.bg-chip-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.bg-chip {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.bg-grad-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bg-grad-chip { width: 100%; aspect-ratio: 1.1; padding: 0; border: 1px solid rgba(0, 0, 0, .08); border-radius: 12px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.bg-chip:hover, .bg-grad-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-med); }
.bg-chip.active, .bg-grad-chip.active { box-shadow: 0 0 0 2px var(--panel-glass-strong), 0 0 0 4px var(--accent); }
.bg-chip:focus-visible, .bg-grad-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bg-grad-editor { display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--neutral-border); border-radius: 14px; background: var(--panel-muted); }
.bg-grad-preview { height: 56px; border-radius: 10px; border: 1px solid rgba(0, 0, 0, .08); }
.bg-grad-stops { display: flex; align-items: center; gap: 8px; }
.bg-grad-stops .bg-well { flex-basis: 36px; width: 36px; height: 36px; border-radius: 50%; }
.bg-grad-track { flex: 1; height: 2px; border-radius: 2px; background: var(--neutral-border); }
.bg-grad-angle-row { display: flex; align-items: center; gap: 10px; }
.bg-row-label { font-size: 12px; font-weight: 600; color: var(--text-dim); min-width: 40px; }
.bg-grad-angle-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.bg-value { min-width: 48px; height: 30px; display: grid; place-items: center; border: 1px solid var(--neutral-border); border-radius: 8px; background: var(--panel-glass-strong); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.bg-image-options { display: flex; flex-direction: column; gap: 8px; }
.bg-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--neutral-border);
  border-radius: 12px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.bg-option:hover { border-color: var(--accent-border); box-shadow: var(--shadow-med); }
.bg-option.active { border-color: var(--accent); background: var(--accent-soft); }
.bg-option-thumb { flex: 0 0 48px; height: 48px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.bg-option-thumb--transparent { background: repeating-conic-gradient(#e4e4e7 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.bg-option-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bg-option-copy b { font-size: 13px; font-weight: 700; }
.bg-option-copy small { font-size: 11.5px; color: var(--text-dim); }
.bg-tab { border-radius: 0; box-shadow: none; }
.bg-grad-angle-row input[type="range"] { min-width: 0; }
.bg-value { flex: 0 0 auto; min-width: 44px; padding: 0 6px; }
@media (min-width: 761px) {
  #status { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ── Shared colour picker (colorPicker.ts) ─────────────────────────────────── */
#pk-color-picker {
  position: fixed;
  z-index: 20000;
  width: 248px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--neutral-border);
  border-radius: 14px;
  background: var(--panel-glass-strong);
  box-shadow: 0 16px 40px rgba(24, 24, 27, .18), 0 2px 6px rgba(24, 24, 27, .08);
  color: var(--text-primary);
}
#pk-color-picker[hidden] { display: none; }
.pkcp-sv {
  --hue: red;
  position: relative;
  height: 150px;
  border-radius: 10px;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue));
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
.pkcp-sv:focus-visible { box-shadow: 0 0 0 2px var(--panel-glass-strong), 0 0 0 4px var(--accent); }
.pkcp-sv-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 2px 4px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.pkcp-hue {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  outline: none;
}
.pkcp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3); cursor: pointer; }
.pkcp-hue::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.pkcp-row { display: flex; align-items: center; gap: 8px; }
.pkcp-preview { flex: 0 0 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .12); }
.pkcp-hex {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--neutral-border);
  border-radius: 8px;
  background: var(--panel-glass-strong);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}
.pkcp-hex:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pkcp-eyedropper { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--neutral-border); border-radius: 8px; background: var(--panel-glass-strong); color: var(--text-primary); cursor: pointer; }
.pkcp-eyedropper:hover { background: var(--surface-hover); }
.pkcp-eyedropper[hidden] { display: none; }
input[type="color"][aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Fill colour section (fillSection.ts) ──────────────────────────────────── */
#text-color-controls .fill-mode { margin: 2px 0 12px; display: grid; grid-template-columns: 1fr 1fr; }
#text-color-controls .fill-solid-row { display: flex; align-items: center; gap: 8px; }
.fill-well { flex-basis: 40px; width: 40px; height: 40px; }
#text-color-controls .fill-hex { height: 40px; }
#text-color-controls .fill-eyedropper { flex-basis: 40px; width: 40px; height: 40px; }
#text-color-controls .text-preset-grid:not(.is-collapsed),
#text-color-controls #text-solid-swatches { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
#text-color-controls .text-solid-swatch { width: 100%; height: auto; aspect-ratio: 1; border-radius: 9px; box-shadow: none; border: 1px solid rgba(0, 0, 0, .1); }
#text-color-controls .text-solid-swatch:hover { outline: none; box-shadow: 0 0 0 2px var(--panel-glass-strong), 0 0 0 4px var(--accent); border-radius: 9px; }
#text-color-controls.is-gradient .fill-solid-row,
#text-color-controls.is-gradient .swatch-palette-header,
#text-color-controls.is-gradient #text-solid-swatches,
#text-color-controls.is-gradient #text-solid-more { display: none !important; }
#text-color-controls:not(.is-gradient) #gradient-controls { display: none !important; }
#text-color-controls #gradient-controls { padding: 0; border: 0; }
#text-color-controls #gradient-controls > .prop-row:first-child { display: none; }
#text-color-controls #gradientFields { margin-top: 0; }
#text-color-controls #gradientFields .prop-row { gap: 8px; }
#text-color-controls #gradientFields input[type="color"] { width: 36px; height: 36px; border-radius: 50%; }
#text-color-controls #text-gradient-presets .text-gradient-preset { width: 100%; height: auto; aspect-ratio: 1.3; border-radius: 10px; }

/* ── Long design names never push into the header actions ─────────────────── */
@media (min-width: 761px) {
  /* Actions always get their full width (max-content) and the brand/name
     column is the one that gives way. With plain `auto` tracks a long design
     name squeezed the actions below their content, and they spilled left over
     undo/redo (seen at ~1536px with a long Telugu title). */
  #header { grid-template-columns: minmax(0, auto) auto minmax(0, 1fr) max-content; }
  #brand-area { overflow: hidden; }
  #brand-area, #document-meta { min-width: 0; }
  #header-status { overflow: hidden; }
  #header-actions > * { flex-shrink: 0; }
  #template-name {
    display: block;
    flex: 0 1 auto;
    min-width: 56px;
    max-width: clamp(80px, 16vw, 260px);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  #template-name[contenteditable="true"] { max-width: clamp(120px, 22vw, 340px); text-overflow: clip; }
}

/* "No colour" swatches: checkerboard with a red slash, in every palette. */
.text-solid-swatch[data-color="transparent"],
.ctb-color-chip.is-transparent {
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 10px 10px !important;
  position: relative !important;
  overflow: hidden !important;
}
.text-solid-swatch[data-color="transparent"]::after,
.ctb-color-chip.is-transparent::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -10%;
  right: -10%;
  height: 2px;
  background: var(--status-danger-text);
  transform: rotate(-45deg);
}

/* Give a long design name room: document actions drop their labels (icon +
   tooltip) before the name is squeezed. */
@media (min-width: 761px) and (max-width: 1535px) {
  #header-actions > #new-design-btn .button-label,
  #header-actions > #preview-btn .button-label { display: none; }
  #header-actions > #new-design-btn,
  #header-actions > #preview-btn { width: 36px; min-width: 36px; padding: 0; }
}
@media (min-width: 761px) and (max-width: 1360px) {
  #header-upgrade-btn.header-upgrade-pill .button-label { display: none; }
  #header-actions > #header-upgrade-btn.header-upgrade-pill { width: 36px; padding: 0; justify-content: center; }
}
@media (min-width: 761px) {
  #header-status { justify-content: center; min-width: 0; }
  #status { min-width: 0; max-width: 100%; flex-shrink: 1; }
  #status::before { flex: 0 0 18px; }
}
@media (min-width: 761px) {
  #header-status { container-type: inline-size; }
  @container (max-width: 150px) {
    #status { font-size: 0; gap: 0; padding: 4px; }
  }
}

/* ── Fill: solid extras + gradient editor (fillSection.ts) ────────────────── */
.fill-sub-label { display: block; margin: 0 0 7px; font-size: 12px; font-weight: 500; color: var(--text-dim); }
.fill-solid-extras { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 12px; }
.fill-opacity[hidden] { display: none; }
.fill-opacity { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
.fill-opacity .fill-sub-label { grid-column: 1 / -1; }
.fill-opacity-range { width: 100%; min-width: 0; accent-color: var(--accent); }
.fill-opacity-box, .grad-angle-box {
  display: inline-flex; align-items: center; height: 34px; padding: 0 8px 0 0;
  border: 1px solid var(--neutral-border); border-radius: 8px; background: var(--panel-glass-strong);
  font-size: 12px; color: var(--text-dim);
}
.fill-opacity-box input, .grad-angle-box input {
  width: 44px; height: 32px; border: 0 !important; background: transparent !important; padding: 0 2px 0 8px !important;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-primary); text-align: right; box-shadow: none !important;
  -moz-appearance: textfield;
}
.fill-opacity-box input::-webkit-inner-spin-button, .grad-angle-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#text-color-controls #gradientFields { display: none !important; }
.grad-editor { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.grad-editor[hidden] { display: none; }
.grad-bar { position: relative; height: 28px; margin: 4px 10px 6px; }
.grad-bar-fill { position: absolute; inset: 0 -10px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .08); }
.grad-handles { position: absolute; inset: 0; }
.grad-handle {
  position: absolute; top: 100%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 1px 3px rgba(0, 0, 0, .3);
}
.grad-stops-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grad-stops { display: flex; gap: 8px; }
.grad-stop { position: relative; }
.grad-stop-well {
  position: relative; display: block; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: var(--stop); border: 1px solid rgba(0, 0, 0, .15); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); cursor: pointer;
}
.grad-stop-well input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.grad-stop-well:has(input[aria-expanded="true"]) { box-shadow: 0 0 0 2px var(--panel-glass-strong), 0 0 0 4px var(--accent); }
.grad-stop-remove {
  position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--text-primary); color: var(--panel-glass-strong); font-size: 11px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.grad-stop:hover .grad-stop-remove, .grad-stop-remove:focus-visible { opacity: 1; }
.grad-add {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--neutral-border); border-radius: 8px; background: var(--panel-glass-strong);
  color: var(--text-primary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.grad-add:hover:not(:disabled) { background: var(--surface-hover); }
.grad-add:disabled { opacity: .45; cursor: not-allowed; }
.grad-add[hidden] { display: none; }
.grad-swap { width: 32px; height: 32px; flex-basis: 32px; margin-left: auto; }
.grad-meta { display: flex; flex-direction: column; gap: 10px; }
.grad-angle { display: flex; align-items: center; gap: 10px; }
.grad-angle[hidden], .grad-type[hidden] { display: none !important; }
.grad-meta-label { font-size: 12px; font-weight: 500; color: var(--text-dim); min-width: 40px; }
.grad-angle-range { flex: 1; min-width: 0; accent-color: var(--accent); }
.grad-type { display: grid; grid-template-columns: repeat(3, 1fr); }
#text-color-controls.is-gradient .fill-solid-extras { display: none; }
#transliteration-controls[hidden] { display: none !important; }

/* Frosted glass (shapes) sits right under the fill it replaces. */
#prop-text > #shape-glass-controls { order: 6; }
#inspector #prop-text > .glass-card { margin: 4px 16px 14px; }
/* With glass on, the shape paints the glass tint, not its fill. */
#prop-text:has(#shape-glass-enabled:checked) #text-color-controls { display: none !important; }

/* Background gradient: middle colours between start and end. */
.bg-grad-mids { display: contents; }
.bg-grad-mid { position: relative; display: inline-flex; }
.bg-grad-mid .bg-well { flex-basis: 36px; width: 36px; height: 36px; border-radius: 50%; }
.bg-grad-mid-remove {
  position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--text-primary); color: var(--panel-glass-strong); font-size: 11px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.bg-grad-mid:hover .bg-grad-mid-remove, .bg-grad-mid-remove:focus-visible { opacity: 1; }
.bg-grad-add {
  flex: 0 0 36px; width: 36px; height: 36px; padding: 0; display: grid; place-items: center;
  border: 1px dashed var(--neutral-border); border-radius: 50%; background: transparent;
  color: var(--text-dim); font-size: 18px; line-height: 1; cursor: pointer;
}
.bg-grad-add:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.bg-grad-add:disabled { opacity: .35; cursor: not-allowed; }
/* With middle colours the row has no room for the decorative track. */
.bg-grad-stops:has(.bg-grad-mid) .bg-grad-track { display: none; }
.bg-grad-stops { flex-wrap: wrap; row-gap: 8px; }
.bg-grad-stops:has(.bg-grad-mid) #bg-grad-swap { margin-left: auto; }

#text-color-controls > .fill-opacity { margin-top: 14px; }

/* ── Recent / Saved shelf (colours and gradients) ─────────────────────────
   One strip wherever a colour is chosen: colour picker, fill, gradient editor,
   Background panel. Saved entries carry a small remove badge on hover. */
.pk-shelf { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pk-shelf-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pk-shelf-label { flex: 1 1 auto; min-width: 0; font-size: 11.5px; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-shelf-tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--surface-hover, rgba(0, 0, 0, .05)); }
.pk-shelf-head .pk-shelf-tabs:first-child { margin-right: auto; }
.pk-shelf-tabs button { padding: 3px 10px; border: 0; border-radius: 999px; background: transparent; color: var(--text-dim); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.pk-shelf-tabs button.active { background: var(--panel-glass-strong, #fff); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.pk-shelf-save { flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--neutral-border); border-radius: 8px; background: var(--panel-glass-strong, #fff); color: var(--text-dim); cursor: pointer; }
.pk-shelf-save svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.pk-shelf-save:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pk-shelf-save.saved { color: #f5a524; border-color: #f5a524; }
.pk-shelf-save.saved svg { fill: currentColor; }
.pk-shelf-save:disabled { opacity: .45; cursor: default; }
.pk-shelf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 7px; }
.pk-shelf--gradient .pk-shelf-list { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
.pk-shelf-list.is-empty { display: block; }
.pk-shelf-list.is-empty::before { content: attr(data-empty); font-size: 11.5px; color: var(--text-dim); }
.pk-shelf-item { position: relative; min-width: 0; }
.pk-shelf-swatch { display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 1px solid rgba(0, 0, 0, .12); border-radius: 50%; background: var(--swatch); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.pk-shelf--gradient .pk-shelf-swatch { aspect-ratio: 1.4; border-radius: 8px; }
.pk-shelf-swatch:hover { transform: translateY(-1px); }
.pk-shelf-swatch.active, .pk-shelf-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--panel-glass-strong, #fff), 0 0 0 4px var(--accent); }
.pk-shelf-remove { position: absolute; top: -5px; right: -5px; display: none; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: var(--text-primary, #18181b); color: #fff; font-size: 11px; line-height: 1; cursor: pointer; }
.pk-shelf-item:hover .pk-shelf-remove, .pk-shelf-remove:focus-visible { display: grid; }
@media (hover: none) { .pk-shelf-remove { display: grid; } }
#pk-color-picker .pk-shelf { padding-top: 10px; border-top: 1px solid var(--neutral-border); }
.fill-grad-shelf { padding-top: 4px; }
#bg-recent-section .pk-shelf, .bg-grad-editor + .pk-shelf { margin-bottom: 4px; }
.bg-grad-editor + .pk-shelf { margin: 14px 0 6px; }

/* Stickers are transparent PNGs, and a white one on a white card looks like
   an empty tile. A faint checkerboard (the usual transparency cue) gives
   white and dark stickers something to stand out against. */
#sticker-list .sticker-item-btn {
  background-color: var(--pk-sticker-check-a);
  background-image: conic-gradient(var(--pk-sticker-check-b) 25%, transparent 0 50%, var(--pk-sticker-check-b) 0 75%, transparent 0);
  background-size: 16px 16px;
}
/* Refinements reuse the existing editor surfaces and token vocabulary. */
:root { --export-gradient:linear-gradient(135deg,#a21d28,#bd4e10); --export-gradient-hover:linear-gradient(135deg,#8a1721,#a23d0b); --action-fill:#a21d28; }
:root[data-theme=dark] { --export-gradient:linear-gradient(135deg,#a52b3a,#99520b); --export-gradient-hover:linear-gradient(135deg,#892132,#794009); --action-fill:#a52b3a; }
.editor-group-btn { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; min-height:64px; width:100%; border:0; border-radius:10px; background:transparent; color:var(--text-dim); font:inherit; font-size:12px; line-height:1.35; cursor:pointer; padding:8px 2px; }
.editor-group-btn .nav-icon,.editor-group-btn .material-icons { width:22px; height:22px; font-size:22px; }
.editor-group-btn .rail-icon { width:24px; height:24px; flex:0 0 24px; }
.editor-source-tab[hidden],#editor-tool-choices[hidden] { display:none !important; }
.tool-art-image { display:block; object-fit:contain; }
.editor-group-btn { min-height:64px; gap:5px; }
.editor-group-btn[aria-pressed=true] { background:var(--accent-soft); color:var(--accent); font-weight:600; }
.editor-group-btn:focus-visible, #editor-tool-choices button:focus-visible, .custom-select-trigger:focus-visible, .option-item:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#editor-tool-choices { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; padding:16px 12px; border-bottom:1px solid var(--border); }
#editor-tool-choices .nav-tab { display:flex; flex-direction:column; min-width:0; width:100%; height:auto; min-height:96px; padding:8px 2px; gap:8px; margin:0; font-size:12px; line-height:1.35; border:1px solid transparent; border-radius:10px; background:transparent; }
#editor-tool-choices .nav-tab:hover { background:var(--surface-hover); }
#editor-tool-choices .nav-tab.active { background:var(--accent-soft); border-color:var(--accent-border); }
#editor-tool-choices .tool-art { display:grid; place-items:center; width:68px; height:68px; flex:0 0 68px; }
#editor-tool-choices .tool-art-image { width:68px; height:68px; transform:none; }
#editor-tool-choices .nav-tab { height:100px; min-height:100px; justify-content:center; }
#editor-tool-choices .nav-tab::before { display:none; }
#editor-tool-choices .nav-tab[hidden] { display:none !important; }
#editor-tool-choices .nav-label { font-size:12px; line-height:1.35; text-align:center; white-space:nowrap; }
#editor-tool-choices .nav-icon, #editor-tool-choices .material-icons { width:18px; height:18px; font-size:18px; }
#editor-frame-intro { display:none; padding:16px; }
#editor-frame-intro h3 { margin:0 0 12px; font-size:17px; }
#editor-frame-intro p { margin:0; color:var(--text-dim); font-size:13px; line-height:1.5; }
#library-content[data-tool-group=Frames] #editor-frame-intro { display:block; }
#library-content[data-tool-group=Frames] .tab-pane { display:none !important; }
:root[data-theme=dark] { --action-text:#ff8793; }
:root[data-theme=dark] .editor-group-btn[aria-pressed=true],
:root[data-theme=dark] #editor-tool-choices .nav-tab.active,
:root[data-theme=dark] #editor-tool-choices .nav-tab.active .nav-label,
:root[data-theme=dark] .inspector-tab[aria-selected=true],
:root[data-theme=dark] #zoomFit.active,
:root[data-theme=dark] #inspector .segment-btn.active { color:var(--action-text); }
#shape-list .shape-item-btn, #shape-list .shape-item-btn span,.drawable-shape-btn { font-size:12px; line-height:1.35; overflow-wrap:normal; }
#shape-list .shape-item-btn { aspect-ratio:auto; min-height:84px; }
#shape-list { display:block; }
.shape-category { padding:8px 0; border-bottom:1px solid var(--border); }
.shape-category summary { padding:10px 2px; font-size:13px; font-weight:600; cursor:pointer; }
.shape-category-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.tanglish-helper,.pk-kbd-help,.bg-category-list button,.bg-image-status,.upload-hint,.bg-option-desc,.pk-shelf-heading,.pk-shelf-tab,.pk-shelf-empty { font-size:12px; line-height:1.4; }
button,input,select,textarea { font-family:inherit; }
#download-confirm-btn { background:var(--export-gradient); }
#download-confirm-btn:hover { background:var(--export-gradient-hover); color:white; filter:none; }
#user-upload-btn:hover,#apply-crop-btn:hover,#brand-kit-apply-btn:hover { color:#fff; filter:brightness(.94); }
#user-upload-btn,#apply-crop-btn,#brand-kit-apply-btn { background:var(--action-fill) !important; color:white; }
/* Low-emphasis copy must still be readable. */
:root:not([data-theme=dark]) { --text-muted:#6b5e58; }
@media (max-width:760px) {
  #library-nav { display:flex; overflow-x:auto; overflow-y:hidden; overscroll-behavior-x:contain; }
  .editor-group-btn { flex:0 0 76px; min-width:76px; min-height:60px; font-size:12px; padding:4px 1px; gap:2px; }
  #editor-tool-choices .nav-tab { height:82px; min-height:82px; }
  #editor-tool-choices { padding:40px 12px 10px; gap:6px; }
  #editor-tool-choices .tool-art { width:48px; height:48px; flex-basis:48px; }
  #editor-tool-choices .tool-art-image { width:48px; height:48px; }
  #library-nav { scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
  #library-nav::-webkit-scrollbar { display:block; height:3px; }
  #library-nav::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
  #history-controls button,.toolbar-btn,#header-actions>button,.account-status { width:44px; min-width:44px; min-height:44px; height:44px; }
  #close-library-btn { width:44px; height:44px; padding:0; align-items:center; justify-content:center; }
  #header { --app-header-height:62px; padding:7px 6px; gap:4px; }
  :root { --app-header-height:62px; }
  #header-actions { gap:4px; }
  #header-actions #new-design-btn { display:none; }
  .draw-brush span { font-size:12px; }
}
@media (max-width:360px) {
  #header { grid-template-columns:auto auto minmax(0,1fr); gap:3px; padding-inline:4px; }
  #header-actions { gap:3px; }
  #more-actions-wrap { display:none !important; }
  #history-controls { padding:0; gap:0; }
}
@media (min-width:761px) and (max-width:1160px) {
  body:has(#inspector.visible) #zoom-bar { align-self:flex-start; margin-left:12px; max-width:calc(100% - var(--inspector-width) - 24px); flex-wrap:wrap; }
}

/* Explicit optical bounds avoid a second compositor scaling pass. */
#editor-tool-choices .tool-art { position:relative; overflow:hidden; }
#editor-tool-choices .tool-art-image.approved-artwork { position:absolute; max-width:none; object-fit:contain; transform:none; }

/* Category homes drill into desktop collections while mobile retains its existing flow. */
#editor-elements-heading,#editor-elements-back,#editor-elements-detail-header { display:none; }
@media(min-width:761px) {
  #library-content[data-browse-view="home"] #editor-elements-heading { display:block; margin:0; padding:18px 16px 0; font-size:17px; line-height:1.4; }
  #library-content[data-browse-view="home"] .tab-pane { display:none !important; }
  #library-content[data-browse-view="home"] #editor-tool-choices { border-bottom:0; flex:1; min-height:0; align-content:start; }
  #library-content[data-browse-view="detail"] #editor-tool-choices { display:none; }
  #library-content[data-browse-view="detail"] #editor-elements-detail-header:not([hidden]) { display:flex; align-items:center; gap:6px; padding:8px 12px; border-bottom:1px solid var(--border); }
  #editor-elements-detail-header h2 { margin:0; font-size:17px; line-height:1.4; }
  #library-content[data-browse-view="detail"] #editor-elements-back:not([hidden]) { display:flex; align-items:center; justify-content:center; min-width:44px; min-height:44px; padding:10px; margin:0; background:transparent; border:0; border-radius:6px; color:var(--text); cursor:pointer; }
  #editor-elements-back:hover { color:var(--accent); }
  #editor-elements-back:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
  #library-content[data-browse-view="detail"] .tab-pane > h2,
  #library-content[data-browse-view="detail"] .tab-pane > .caricature-header,
  #library-content[data-browse-view="detail"] .caricature-studio-header { display:none; }
  #library-content[data-tool-group="Frames"] #editor-frame-intro { display:none; }
}
@font-face{font-family:'Editor Manrope';src:url('/editor-fonts/Manrope-variable.woff2') format('woff2');font-weight:400 800;font-style:normal;font-display:swap}
@font-face{font-family:'Editor Anek Tamil';src:url('/editor-fonts/AnekTamil-variable.woff2') format('woff2');font-weight:400 800;font-style:normal;font-display:swap;unicode-range:U+0B80-0BFF,U+200C-200D}
:root{--editor-ui-font:'Editor Manrope','Editor Anek Tamil','Segoe UI',sans-serif}
#header,#library,#inspector,#zoom-bar,#context-toolbar,#mobile-context-toolbar,.tm-selection,.modal-overlay,.global-popup,.frame-delete-menu,.drawing-controls{font-family:var(--editor-ui-font)}
.tm-selection-toolbar{background:var(--panel);backdrop-filter:none;-webkit-backdrop-filter:none;gap:2px;padding:4px;box-shadow:0 4px 14px #0002}
.tm-selection-action{width:44px;height:44px;background:transparent;border-radius:8px}
.tm-selection-action svg{width:24px;height:24px;display:block;stroke-width:2}
.tm-selection-action svg *{vector-effect:non-scaling-stroke}
@media(max-width:760px){
 #header button,#header .custom-select-trigger{min-width:44px;min-height:44px}
 #header .header-undo-redo button{min-width:44px}
 #context-toolbar button,#zoom-bar button{min-width:44px;min-height:44px}
 #zoom-bar{max-width:calc(100vw - 24px)}
}

#persistence-indicator { display:flex; align-items:center; gap:8px; min-width:0; }
#persistence-status { font-size:12px; line-height:1.4; max-width:240px; color:var(--text-dim); }
#persistence-status[data-state=failed],#persistence-status[data-state=action-required] { color:var(--accent); }
#persistence-indicator button { min-height:44px; padding:6px 10px; border:1px solid var(--border); border-radius:8px; background:var(--panel); color:var(--text); font:inherit; font-size:12px; cursor:pointer; }
#persistence-indicator button[hidden] { display:none; }
#persistence-indicator button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.editor-recovery-dialog { border:1px solid var(--border); border-radius:16px; padding:24px; width:min(420px,calc(100vw - 32px)); background:var(--panel); color:var(--text); box-shadow:0 16px 48px #0003; }
.editor-recovery-dialog::backdrop { background:#0005; }
.editor-recovery-dialog h2 { margin:0 0 12px; font-size:20px; }
.editor-recovery-dialog p { margin:0 0 20px; color:var(--text-dim); line-height:1.5; }
.recovery-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:10px; }
.recovery-actions button { min-height:44px; padding:10px 16px; border:1px solid var(--border); border-radius:10px; background:var(--panel); color:var(--text); font:inherit; cursor:pointer; }
.recovery-actions [data-restore] { background:var(--action-fill,var(--accent)); color:white; }
@media(max-width:1000px) { #persistence-indicator { position:fixed; bottom:12px; left:12px; z-index:110; max-width:calc(100vw - 24px); background:var(--panel); border-radius:10px; padding:0 8px; box-shadow:0 2px 12px #0001; } #persistence-indicator:has(#persistence-status:empty) { display:none; } #persistence-status { max-width:220px; padding:6px 0; } }
#persistence-indicator { position:fixed; bottom:12px; left:100px; z-index:110; max-width:calc(100vw - 124px); background:var(--panel); border-radius:10px; padding:0 8px; box-shadow:0 2px 12px #0001; }
#persistence-indicator:has(#persistence-status:empty) { display:none; }
#persistence-status { padding:6px 0; }
body.drawing-active #persistence-indicator,body.inline-frame-cropping #persistence-indicator { display:none; }
@media(max-width:760px) { #persistence-indicator { left:12px; top:72px; bottom:auto; max-width:calc(100vw - 24px); } }
#shared-selection-panel { padding: 20px 16px; }
#shared-selection-panel[hidden] { display:none; }
#shared-selection-panel h3 { margin:0 0 8px; font-size:16px; }
.selection-help, [data-group-order-note] { color:var(--text-dim,#716764); font-size:13px; line-height:1.5; }
.selection-shared-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:16px; }
.selection-shared-actions button { min-height:44px; padding:8px 10px; border:1px solid var(--border,#e4d9da); border-radius:9px; background:var(--panel,#fff); color:var(--text-primary,#272123); font:inherit; font-size:13px; cursor:pointer; }
.selection-shared-actions button:hover { background:var(--accent-soft,#fcf3f4); border-color:var(--accent,#c51a32); }
.selection-shared-actions button:focus-visible { outline:2px solid #c51a32; outline-offset:2px; }
.selection-shared-actions button:disabled { opacity:.5; cursor:default; }
.tm-selection.is-multiple { touch-action:none; }
.layer-member-edit { min-height:32px; border:0; background:transparent; color:#746566; font-size:12px; cursor:pointer; }
.tm-selection-group-action { width:auto !important; min-width:44px; padding:0 12px !important; white-space:nowrap; font:inherit; font-size:13px; font-weight:600; }
.tm-selection-group-action:disabled { opacity:.45; cursor:default; }
.tm-member-outline { position:absolute; box-sizing:border-box; border:calc(1px * var(--sel-inv-zoom,1)) solid var(--accent,#c51a32); pointer-events:none; z-index:990; }
.tm-group-hover { position:absolute; box-sizing:border-box; border:calc(1px * var(--sel-inv-zoom,1)) solid var(--accent,#c51a32); pointer-events:none; z-index:990; }
.tm-group-hit-area { position:absolute; pointer-events:auto; cursor:move; background:transparent; }
.pk-hand-tool .tm-group-hit-area,.drawing-active .tm-group-hit-area,.inline-frame-cropping .tm-group-hit-area,.preview-mode .tm-group-hit-area { pointer-events:none; }
.tm-marquee { position:fixed; pointer-events:none; z-index:10000; border:1px solid var(--accent,#c51a32); background:rgba(190,18,45,.08); background:color-mix(in srgb,var(--accent,#c51a32) 8%,transparent); box-sizing:border-box; }
.tm-marquee-hit { outline:1px solid var(--accent,#c51a32); outline-offset:2px; }
.selection-context-menu { position:fixed; z-index:10002; min-width:196px; max-width:calc(100vw - 16px); max-height:calc(100vh - 16px); overflow-y:auto; box-sizing:border-box; padding:6px; border:1px solid var(--border,#e4d9da); border-radius:12px; background:var(--panel,#fff); box-shadow:var(--pk-shadow-md,0 8px 28px #0002); }
.selection-context-menu button { display:block; width:100%; min-height:44px; padding:10px 12px; border:0; border-radius:7px; text-align:left; background:transparent; color:var(--text-primary,#272123); font:inherit; font-size:14px; cursor:pointer; }
.selection-context-menu button:hover,.selection-context-menu button:focus-visible { background:var(--accent-soft,#fcf3f4); outline:2px solid var(--accent,#c51a32); outline-offset:-2px; }
.selection-context-menu button.is-destructive { color:var(--accent,#c51a32); }
.selection-context-menu button:disabled { opacity:.45; cursor:default; }
/*!
 * Cropper.js v1.6.2
 * https://fengyuanchen.github.io/cropperjs
 *
 * Copyright 2015-present Chen Fengyuan
 * Released under the MIT license
 *
 * Date: 2024-04-21T07:43:02.731Z
 */

.cropper-container {
  direction: ltr;
  font-size: 0;
  line-height: 0;
  position: relative;
  -ms-touch-action: none;
      touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.cropper-container img {
    backface-visibility: hidden;
    display: block;
    height: 100%;
    image-orientation: 0deg;
    max-height: none !important;
    max-width: none !important;
    min-height: 0 !important;
    min-width: 0 !important;
    width: 100%;
  }

.cropper-wrap-box,
.cropper-canvas,
.cropper-drag-box,
.cropper-crop-box,
.cropper-modal {
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.cropper-wrap-box,
.cropper-canvas {
  overflow: hidden;
}

.cropper-drag-box {
  background-color: #fff;
  opacity: 0;
}

.cropper-modal {
  background-color: #000;
  opacity: 0.5;
}

.cropper-view-box {
  display: block;
  height: 100%;
  outline: 1px solid #39f;
  outline-color: rgba(51, 153, 255, 0.75);
  overflow: hidden;
  width: 100%;
}

.cropper-dashed {
  border: 0 dashed #eee;
  display: block;
  opacity: 0.5;
  position: absolute;
}

.cropper-dashed.dashed-h {
    border-bottom-width: 1px;
    border-top-width: 1px;
    height: calc(100% / 3);
    left: 0;
    top: calc(100% / 3);
    width: 100%;
  }

.cropper-dashed.dashed-v {
    border-left-width: 1px;
    border-right-width: 1px;
    height: 100%;
    left: calc(100% / 3);
    top: 0;
    width: calc(100% / 3);
  }

.cropper-center {
  display: block;
  height: 0;
  left: 50%;
  opacity: 0.75;
  position: absolute;
  top: 50%;
  width: 0;
}

.cropper-center::before,
  .cropper-center::after {
    background-color: #eee;
    content: ' ';
    display: block;
    position: absolute;
  }

.cropper-center::before {
    height: 1px;
    left: -3px;
    top: 0;
    width: 7px;
  }

.cropper-center::after {
    height: 7px;
    left: 0;
    top: -3px;
    width: 1px;
  }

.cropper-face,
.cropper-line,
.cropper-point {
  display: block;
  height: 100%;
  opacity: 0.1;
  position: absolute;
  width: 100%;
}

.cropper-face {
  background-color: #fff;
  left: 0;
  top: 0;
}

.cropper-line {
  background-color: #39f;
}

.cropper-line.line-e {
    cursor: ew-resize;
    right: -3px;
    top: 0;
    width: 5px;
  }

.cropper-line.line-n {
    cursor: ns-resize;
    height: 5px;
    left: 0;
    top: -3px;
  }

.cropper-line.line-w {
    cursor: ew-resize;
    left: -3px;
    top: 0;
    width: 5px;
  }

.cropper-line.line-s {
    bottom: -3px;
    cursor: ns-resize;
    height: 5px;
    left: 0;
  }

.cropper-point {
  background-color: #39f;
  height: 5px;
  opacity: 0.75;
  width: 5px;
}

.cropper-point.point-e {
    cursor: ew-resize;
    margin-top: -3px;
    right: -3px;
    top: 50%;
  }

.cropper-point.point-n {
    cursor: ns-resize;
    left: 50%;
    margin-left: -3px;
    top: -3px;
  }

.cropper-point.point-w {
    cursor: ew-resize;
    left: -3px;
    margin-top: -3px;
    top: 50%;
  }

.cropper-point.point-s {
    bottom: -3px;
    cursor: s-resize;
    left: 50%;
    margin-left: -3px;
  }

.cropper-point.point-ne {
    cursor: nesw-resize;
    right: -3px;
    top: -3px;
  }

.cropper-point.point-nw {
    cursor: nwse-resize;
    left: -3px;
    top: -3px;
  }

.cropper-point.point-sw {
    bottom: -3px;
    cursor: nesw-resize;
    left: -3px;
  }

.cropper-point.point-se {
    bottom: -3px;
    cursor: nwse-resize;
    height: 20px;
    opacity: 1;
    right: -3px;
    width: 20px;
  }

@media (min-width: 768px) {

.cropper-point.point-se {
      height: 15px;
      width: 15px;
  }
    }

@media (min-width: 992px) {

.cropper-point.point-se {
      height: 10px;
      width: 10px;
  }
    }

@media (min-width: 1200px) {

.cropper-point.point-se {
      height: 5px;
      opacity: 0.75;
      width: 5px;
  }
    }

.cropper-point.point-se::before {
    background-color: #39f;
    bottom: -50%;
    content: ' ';
    display: block;
    height: 200%;
    opacity: 0;
    position: absolute;
    right: -50%;
    width: 200%;
  }

.cropper-invisible {
  opacity: 0;
}

.cropper-bg {
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
}

.cropper-hide {
  display: block;
  height: 0;
  position: absolute;
  width: 0;
}

.cropper-hidden {
  display: none !important;
}

.cropper-move {
  cursor: move;
}

.cropper-crop {
  cursor: crosshair;
}

.cropper-disabled .cropper-drag-box,
.cropper-disabled .cropper-face,
.cropper-disabled .cropper-line,
.cropper-disabled .cropper-point {
  cursor: not-allowed;
}
