:root {
  --ink: #1d1b2e;
  --ink-2: #4b4766;
  --muted: #8a87a0;
  --line: #e6e4ef;
  --bg: #f4f3f9;
  --surface: #ffffff;
  --accent: #7c5cff;
  --accent-2: #5b3ff0;
  --accent-soft: #efeaff;
  --danger: #e5484d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29, 27, 46, .06), 0 6px 24px rgba(29, 27, 46, .08);
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 var(--font); color: var(--ink); background: var(--bg); overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; z-index: 99; background: var(--surface); padding: 8px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); font-weight: 400; }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid transparent; background: var(--surface); font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 0; background: transparent; }
.icon-btn:hover:not(:disabled) { background: var(--accent-soft); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-2); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand small { font-size: 11px; font-weight: 600; color: var(--accent-2); background: var(--accent-soft);
  padding: 2px 8px; border-radius: 99px; letter-spacing: 0; }
.logo { width: 28px; height: 28px; border-radius: 8px; background:
  linear-gradient(135deg, var(--accent) 0 50%, transparent 50%), repeating-linear-gradient(45deg, #ff6fae 0 4px, #ffd166 4px 8px); }
.brand.small .logo { width: 24px; height: 24px; }

/* ---------- home ---------- */
.home { height: 100%; display: grid; grid-template-columns: 240px 1fr; }
.home-nav { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.home-nav .brand { padding: 0 6px; }
.create-btn { justify-content: center; }
.home-links { display: flex; flex-direction: column; gap: 2px; }
.home-links a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.home-links a:hover { background: var(--bg); }
.home-links a.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-note { margin-top: auto; font-size: 11px; color: var(--muted); line-height: 1.45; padding: 0 6px; }
.home-body { overflow: auto; min-width: 0; }
.home-top { display: flex; align-items: center; gap: 12px; padding: 12px 32px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.home-search { max-width: 560px; flex: 1; }
.home-actions { display: flex; gap: 8px; margin-left: auto; }
.home-pad { padding: 24px 32px 0; }
.view-title { font-size: 28px; letter-spacing: -.02em; margin: 0 0 12px; }
.small-note { font-size: 12px; }
.hero { padding: 40px 32px 28px; text-align: center; margin: 20px 32px 0; border-radius: 18px;
  background: linear-gradient(120deg, #5b3ff0, #8f5cff 55%, #ff6fae); color: #fff; }
.hero h1 { font-size: 38px; letter-spacing: -.03em; margin: 0 0 10px; }
.hero-brand { margin: 0 0 18px; opacity: .95; display: inline-flex; gap: 8px; align-items: center; }
.hero-brand a { color: #fff; font-weight: 700; }
.mini-swatches { display: inline-flex; gap: 3px; }
.mini-swatches i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.6); }
.preset-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 96px; padding: 10px 4px;
  border-radius: 12px; border: 0; background: rgba(255,255,255,.12); color: #fff; }
.preset:hover { background: rgba(255,255,255,.24); }
.preset .shape { background: rgba(255,255,255,.85); border-radius: 6px; }
.preset span { font-size: 12px; font-weight: 600; }
.preset small { font-size: 11px; opacity: .8; }
.home-section { padding: 8px 32px 28px; }
.section-head { display: flex; align-items: center; gap: 12px; }
.section-head h2 { font-size: 18px; margin: 16px 0 14px; }
.section-head .btn { margin-left: auto; text-decoration: none; color: var(--ink); }
.tpl-grid, .recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
.card { position: relative; border: 0; padding: 0; background: transparent; text-align: left; color: inherit; }
.card .thumb { aspect-ratio: 4/3; border-radius: 10px; background: #e9e7f2; display: grid; place-items: center;
  overflow: hidden; box-shadow: var(--shadow); transition: transform .15s; }
.card:hover .thumb { transform: translateY(-2px); }
.card .thumb img, .card .thumb canvas { max-width: 92%; max-height: 92%; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.card .name { display: flex; align-items: center; gap: 4px; font-weight: 600; margin-top: 8px; font-size: 13px; }
.card .meta { font-size: 11px; color: var(--muted); }
.card .del { position: absolute; right: 6px; top: 6px; opacity: 0; background: var(--surface); box-shadow: var(--shadow); }
.card:hover .del, .card:focus-within .del { opacity: 1; }
.star-mark svg { width: 14px; height: 14px; }
.empty { color: var(--muted); padding: 24px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; font-weight: 500; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { font-size: 11px; opacity: .65; }
.chip.add { border-style: dashed; }
.pill { font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent-2); padding: 3px 9px; border-radius: 99px; }

/* brand kit */
.kits { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 6px; }
.kit-card { display: flex; flex-direction: column; gap: 8px; width: 180px; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; text-align: left; font: inherit; }
.kit-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kit-card.add { align-items: center; justify-content: center; border-style: dashed; color: var(--ink-2); font-weight: 600; min-height: 86px; }
.kit-swatches { display: flex; height: 34px; border-radius: 8px; overflow: hidden; }
.kit-swatches i { flex: 1; }
.kit-editor { margin: 18px 32px 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; }
.kit-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kit-name { font-size: 22px; font-weight: 800; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; min-width: 240px; background: transparent; }
.kit-name:hover, .kit-name:focus { border-color: var(--line); outline: none; }
.kit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px 28px; margin-top: 10px; }
.kit-sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin: 14px 0 10px; }
.kit-sec.wide { grid-column: 1 / -1; }
.logo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.logo-tile { position: relative; width: 110px; height: 110px; border-radius: 10px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px;
  border: 1px solid var(--line); display: grid; place-items: center; padding: 8px; }
.logo-tile img { max-width: 100%; max-height: 100%; }
.logo-tile .icon-btn { position: absolute; right: 2px; top: 2px; background: var(--surface); width: 28px; height: 28px; }
.logo-tile.add { background: var(--bg); border-style: dashed; color: var(--ink-2); font-weight: 600; }
.palette { margin-bottom: 12px; }
.pal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pal-name { border: 1px solid transparent; background: transparent; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.pal-name:hover, .pal-name:focus { border-color: var(--line); outline: none; }
.brand-sw { position: relative; overflow: visible; cursor: pointer; margin-bottom: 16px; }
.brand-sw input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.brand-sw .hex { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-family: "Roboto Mono", monospace; }
.font-row { display: grid; grid-template-columns: 1fr 150px 70px; gap: 8px; align-items: center; margin-bottom: 8px; }
.font-row select { height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--surface); }
.font-sample { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
.voice-note { font-size: 12px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; }

/* library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.lib-tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lib-tile img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; display: block; }
.lib-meta { padding: 6px 8px; display: flex; flex-direction: column; font-size: 12px; }
.lib-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; }
.lib-actions .icon-btn { background: var(--surface); width: 30px; height: 30px; box-shadow: var(--shadow); }

/* shared view + present */
.viewer { position: fixed; inset: 0; z-index: 40; background: #24223a; overflow: auto; }
.viewer-top { position: sticky; top: 0; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1; }
.viewer-title { font-size: 14px; }
.viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 32px 24px 64px; }
.viewer-pages canvas { max-width: 100%; height: auto; box-shadow: 0 8px 30px rgba(0,0,0,.4); background: #fff; }
.present { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-items: center; outline: none; cursor: pointer; }
.present-stage canvas { display: block; }
.present-count, .present-hint { position: fixed; bottom: 14px; color: rgba(255,255,255,.6); font-size: 12px; }
.present-count { right: 18px; }
.present-hint { left: 18px; }

/* ---------- editor layout ---------- */
.editor { display: grid; height: 100%;
  grid-template: "top top top" 56px "rail panel work" 1fr / 76px 320px 1fr; }
.editor.panel-closed { grid-template-columns: 76px 0 1fr; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: linear-gradient(90deg, #2a1f63, #5b3ff0 60%, #8f5cff); color: #fff; }
.topbar .icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.15); }
.topbar .btn.primary { background: #fff; color: var(--accent-2); }
.doc-name { background: transparent; border: 1px solid transparent; border-radius: 6px; color: #fff; padding: 4px 8px;
  font-weight: 600; width: 260px; }
.doc-name:hover, .doc-name:focus { border-color: rgba(255,255,255,.4); outline: none; }
.save-state { font-size: 12px; opacity: .75; min-width: 60px; }
.rail { grid-area: rail; background: var(--surface); border-right: 1px solid var(--line); display: flex;
  flex-direction: column; gap: 2px; padding: 8px 6px; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border: 0;
  background: transparent; border-radius: 10px; font-size: 11px; font-weight: 500; color: var(--ink-2); }
.rail-btn:hover { background: var(--bg); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent-2); }
.rail-btn.rail-ai { color: var(--accent-2); }
.rail-btn.rail-ai svg { color: var(--accent); }
.rail-btn.rail-ai.active { background: linear-gradient(135deg, var(--accent-soft), #ffe9f4); }
.hint-box.ok { background: #e7f8f1; color: #0a7a5a; }
.panel { grid-area: panel; background: var(--surface); border-right: 1px solid var(--line); overflow: auto; padding: 16px; }
.editor.panel-closed .panel { display: none; }
.panel h3 { font-size: 13px; margin: 18px 0 10px; color: var(--ink-2); }
.panel h3:first-child { margin-top: 0; }
.search { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--bg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { aspect-ratio: 1; border: 0; border-radius: 8px; background: var(--bg); display: grid; place-items: center; padding: 10px; }
.tile:hover { background: var(--accent-soft); }
.tile svg { width: 100%; height: 100%; }
.tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
.text-preset { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; }
.text-preset:hover { border-color: var(--accent); }
.tpl-tile { border: 0; padding: 0; background: transparent; text-align: left; }
.tpl-tile .thumb { border-radius: 8px; overflow: hidden; background: var(--bg); display: grid; place-items: center; aspect-ratio: 1; }
.tpl-tile canvas { max-width: 100%; max-height: 100%; }
.tpl-tile span { font-size: 12px; font-weight: 500; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); padding: 0; }
.swatch.lg { width: 44px; height: 44px; border-radius: 8px; }
.swatch.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.add { display: grid; place-items: center; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; overflow: hidden; }
.swatch.add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-hint { border: 2px dashed var(--line); border-radius: 10px; padding: 20px; text-align: center; color: var(--muted); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile.gfx { padding: 8px; }
.h3-row { display: flex; align-items: baseline; justify-content: space-between; }
.link-btn { border: 0; background: none; color: var(--accent-2); font-size: 12px; font-weight: 600; padding: 0; text-decoration: none; cursor: pointer; }
.panel-select { flex: 1; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--surface); min-width: 0; }
.row-inline { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; color: var(--ink-2); }
.hint-box { background: var(--accent-soft); color: var(--accent-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 10px 0 0; }
.up-tile { position: relative; }
.up-tile .up-del { position: absolute; right: 4px; top: 4px; background: var(--surface); width: 28px; height: 28px; opacity: 0; }
.up-tile:hover .up-del, .up-tile:focus-within .up-del { opacity: 1; }
.up-star { position: absolute; left: 6px; top: 6px; }
.up-star svg { width: 16px; height: 16px; }
.brand-preset { border-left: 3px solid var(--accent); }
.fx-tile, .filter-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fx-tile:hover, .filter-tile:hover, .filter-tile.sel { border-color: var(--accent); }
.fx-sample { line-height: 1.1; height: 38px; display: grid; place-items: center; }
.fx-tile small, .filter-tile small { font-size: 10px; color: var(--ink-2); }
.filter-tile { padding: 3px; }
.filter-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.field .out { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.link-box { flex: 1; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 12px; font-family: "Roboto Mono", monospace; min-width: 0; }
.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.share-opt { display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; align-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; }
.share-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.share-opt svg { grid-row: 1 / 3; }
.share-opt small { color: var(--muted); font-size: 11px; }
.el.drop-target .inner { outline: 3px solid var(--accent); outline-offset: -3px; }
.topbar #btn-file, .topbar #btn-resize { height: 30px; }
.topbar .doc-name { text-align: center; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; width: 100%; text-align: left; }
.layer-row:hover { background: var(--bg); }
.layer-row.sel { border-color: var(--accent); background: var(--accent-soft); }
.layer-row .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.layer-row .kind { font-size: 10px; color: var(--muted); text-transform: uppercase; width: 38px; }
.field { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 12px; color: var(--ink-2); }
.field > span { width: 84px; }
.field input[type=range] { flex: 1; accent-color: var(--accent); }
.field input[type=number], .field select, .num { width: 70px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--surface); }

/* ---------- workspace ---------- */
.workspace { grid-area: work; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ctxbar { height: 52px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 12px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.ctxbar > * { flex: none; }
.ctxbar .spacer { flex: 1 0 8px; }
.ctxbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }
.ctxbar select { height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--surface); }
.ctxbar .font-select { width: 160px; }
.color-chip { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); position: relative; overflow: hidden; padding: 0; }
.color-chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.color-chip.text-chip { background: var(--surface) !important; display: grid; place-items: center; font-weight: 800; }
.color-chip.text-chip i { position: absolute; bottom: 4px; left: 6px; right: 6px; height: 4px; border-radius: 2px; }
.ctx-hint { color: var(--muted); font-size: 13px; }
.stage { flex: 1; overflow: auto; position: relative; background: var(--bg); outline: none; padding: 40px 60px 120px; }
.stage.drop { box-shadow: inset 0 0 0 3px var(--accent); }
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; min-width: min-content; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 4px; align-self: stretch; font-size: 12px; color: var(--ink-2); }
.page-head b { font-weight: 600; }
.page-head .icon-btn { width: 28px; height: 28px; }
.page-wrap { position: relative; box-shadow: 0 2px 10px rgba(29,27,46,.12); flex: none; }
.page-wrap.active { box-shadow: 0 0 0 2px var(--accent), 0 2px 10px rgba(29,27,46,.12); }
.page { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.el { position: absolute; transform-origin: 50% 50%; }
.el .inner { position: absolute; inset: 0; }
.el svg { position: absolute; inset: 0; overflow: visible; }
.el img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.el.text .inner { white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.el.text.editing .inner { outline: none; cursor: text; user-select: text; }
.el.locked { cursor: not-allowed; }
.add-page { margin-top: 4px; }

/* overlay (screen-space, unscaled) */
.overlay { position: absolute; inset: 0; pointer-events: none; }
.sel-box { position: absolute; border: 2px solid var(--accent); transform-origin: 50% 50%; }
.sel-box.multi { border-style: dashed; }
.sel-box.hover { border-width: 1.5px; opacity: .6; }
.sel-box.locked { border-color: var(--muted); }
.handle { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; border: 1.5px solid var(--accent);
  border-radius: 50%; pointer-events: auto; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.handle.edge { border-radius: 6px; }
.handle.edge.n, .handle.edge.s { width: 22px; height: 8px; margin: -4px 0 0 -11px; }
.handle.edge.e, .handle.edge.w { width: 8px; height: 22px; margin: -11px 0 0 -4px; }
.handle.rot { width: 22px; height: 22px; margin: -11px 0 0 -11px; display: grid; place-items: center; cursor: grab; }
.handle.rot::after { content: "⟳"; font-size: 13px; color: var(--accent-2); line-height: 1; }
.guide { position: absolute; background: #ff3d8b; }
.guide.x { width: 1px; top: 0; bottom: 0; }
.guide.y { height: 1px; left: 0; right: 0; }
.marquee { position: absolute; border: 1px solid var(--accent); background: rgba(124,92,255,.08); }
.badge { position: absolute; background: var(--ink); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, 0); }

/* Rulers — hidden unless the page-wrap has .rulers-on. They sit just outside
   the page's top/left edges and scroll with it (they are children of the wrap). */
.ruler { position: absolute; display: none; background: var(--surface); z-index: 3; }
.ruler-top { left: 0; top: -20px; height: 20px; border-bottom: 1px solid var(--line); cursor: ns-resize; }
.ruler-left { top: 0; left: -20px; width: 20px; border-right: 1px solid var(--line); cursor: ew-resize; }
.ruler-corner { position: absolute; display: none; top: -20px; left: -20px; width: 20px; height: 20px;
  background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); z-index: 3; }
.page-wrap.rulers-on .ruler, .page-wrap.rulers-on .ruler-corner { display: block; }

/* Draggable user guides — teal, grabbable (the overlay itself is pass-through). */
.user-guide { position: absolute; background: #00b3a4; pointer-events: auto; z-index: 2; }
.user-guide.x { width: 1px; top: 0; bottom: 0; cursor: ew-resize; box-shadow: 0 0 0 3px transparent; }
.user-guide.y { height: 1px; left: 0; right: 0; cursor: ns-resize; }
.user-guide.x::before { content: ''; position: absolute; left: -4px; top: 0; bottom: 0; width: 9px; }
.user-guide.y::before { content: ''; position: absolute; top: -4px; left: 0; right: 0; height: 9px; }
.user-guide:hover { background: #00d6c4; }

/* Equal-spacing hints while dragging (Canva-style pink distance tags). */
.space-bar { position: absolute; background: #ff3d8b; }
.space-bar.x { height: 2px; transform: translateY(-1px); }
.space-bar.y { width: 2px; transform: translateX(-1px); }
.space-tag { position: absolute; background: #ff3d8b; color: #fff; font-size: 10px; line-height: 1; font-weight: 600;
  padding: 2px 4px; border-radius: 3px; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none; }

/* Multi-stop gradient editor (in the colour popover). */
.grad-track { position: relative; margin-top: 4px; }
.grad-bar { height: 22px; border-radius: 6px; border: 1px solid var(--line); cursor: copy; background-clip: padding-box; }
.grad-handles { position: relative; height: 14px; }
.grad-stop { position: absolute; top: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35); transform: translateX(-50%); cursor: grab; padding: 0; }
.grad-stop.sel { box-shadow: 0 0 0 2px var(--accent); }

.bottombar { height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 12px; background: var(--surface);
  border-top: 1px solid var(--line); }
.bottombar input[type=range] { width: 140px; accent-color: var(--accent); }
.page-info { font-size: 12px; color: var(--ink-2); }

/* ---------- modal / toast / menu ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,18,35,.45); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: min(520px, 92vw); max-height: 86vh;
  overflow: auto; padding: 22px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.modal .row label { min-width: 70px; font-size: 13px; color: var(--ink-2); }
.modal input[type=number], .modal select { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.modal kbd, .modal code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; font-family: "Roboto Mono", monospace; }
.toast { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.menu { position: fixed; z-index: 55; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 6px; min-width: 200px; }
.menu button { display: flex; justify-content: space-between; width: 100%; border: 0; background: transparent; padding: 7px 10px;
  border-radius: 6px; text-align: left; font-size: 13px; }
.menu button:hover { background: var(--accent-soft); }
.menu kbd { color: var(--muted); font-size: 11px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; }
  .home-nav { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .home-links { flex-direction: row; flex-wrap: wrap; }
  .nav-note { display: none; }
  .hero { margin: 12px; }
  .home-top { padding: 10px 12px; flex-wrap: wrap; }
  .editor { grid-template-columns: 64px 0 1fr; }
  .editor .panel { display: none; }
  .editor.panel-open-mobile { grid-template-columns: 64px 260px 1fr; }
  .editor.panel-open-mobile .panel { display: block; }
  .doc-name { width: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- v3 ---------- */
.btn.on { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent); }
.cell-editor { position: absolute; z-index: 5; margin: 0; border: 2px solid var(--accent); border-radius: 2px; background: rgba(255,255,255,.96);
  resize: none; outline: none; overflow: hidden; box-sizing: border-box; color: var(--ink); }
.editor.drawing .stage .page-wrap, .editor.drawing .stage .el { cursor: crosshair; }
.overlay svg.ink { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.chart-tile { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.chart-tile svg { position: static; width: 100%; height: auto; flex: 1; }
.chart-tile small { font-size: 10px; color: var(--ink-2); }
.pen-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.pen-tile.sel, .pen-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.pen-sample svg { width: 60px; height: 24px; display: block; }
.hint-box { background: var(--accent-soft); color: var(--accent-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.anim-grid { gap: 6px; }
.anim-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; overflow: hidden; }
.anim-tile.sel, .anim-tile:hover { border-color: var(--accent); }
.anim-tile small { font-size: 10px; color: var(--ink-2); }
.anim-demo { font: 700 18px var(--font); color: var(--accent-2); display: inline-block; }
.anim-tile:hover .anim-demo.anim { animation-iteration-count: infinite; animation-duration: 1.4s; }
.anim-tile .anim-demo.anim { animation-play-state: paused; }
.anim-tile:hover .anim-demo.anim { animation-play-state: running; }

/* entrance animations (Present mode + previews) */
.anim { animation-duration: .8s; animation-timing-function: cubic-bezier(.2,.7,.2,1); animation-fill-mode: both; }
.anim-fade { animation-name: hs-fade; }
.anim-rise { animation-name: hs-rise; }
.anim-pan { animation-name: hs-pan; }
.anim-pop { animation-name: hs-pop; animation-timing-function: cubic-bezier(.3,1.6,.5,1); }
.anim-wipe { animation-name: hs-wipe; }
.anim-drift { animation-name: hs-drift; animation-duration: 1.6s; }
.anim-breathe { animation-name: hs-breathe; animation-duration: 1.2s; }
.anim-baseline { animation-name: hs-baseline; }
.anim-tumble { animation-name: hs-tumble; }
@keyframes hs-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hs-rise { from { opacity: 0; transform: translateY(12%); } to { opacity: 1; transform: none; } }
@keyframes hs-pan { from { opacity: 0; transform: translateX(-14%); } to { opacity: 1; transform: none; } }
@keyframes hs-pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
@keyframes hs-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes hs-drift { from { opacity: 0; transform: translateY(5%) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes hs-breathe { 0% { opacity: 0; transform: scale(.92); } 60% { opacity: 1; transform: scale(1.03); } 100% { transform: none; } }
@keyframes hs-baseline { from { clip-path: inset(0 0 100% 0); transform: translateY(30%); } to { clip-path: inset(0); transform: none; } }
@keyframes hs-tumble { from { opacity: 0; transform: rotate(-25deg) scale(.6); } to { opacity: 1; transform: none; } }

/* present: stacked slides with transitions, notes, timer */
.present-stage { position: relative; width: 100vw; height: 100vh; display: grid; place-items: center; overflow: hidden; }
.present-stage .slide { position: absolute; left: 50%; top: 50%; translate: -50% -50%; overflow: hidden; }
.present-stage .slide > canvas { display: block; }
.slide.tr-in, .slide.tr-out { animation-duration: .6s; animation-fill-mode: both; animation-timing-function: cubic-bezier(.4,0,.2,1); }
.slide.tr-out { z-index: 0; } .slide.tr-in { z-index: 1; }
.slide.tr-in.tr-dissolve { animation-name: hs-fade; }
.slide.tr-out.tr-dissolve { animation-name: hs-fade; animation-direction: reverse; }
.slide.tr-in.tr-slide { animation-name: hs-slide-in; }
.slide.tr-in.tr-slide.back { animation-name: hs-slide-in-back; }
.slide.tr-out.tr-slide { opacity: 1; }
.slide.tr-in.tr-push { animation-name: hs-slide-in; }
.slide.tr-out.tr-push { animation-name: hs-push-out; }
.slide.tr-in.tr-push.back { animation-name: hs-slide-in-back; }
.slide.tr-out.tr-push.back { animation-name: hs-push-out-back; }
.slide.tr-in.tr-zoom { animation-name: hs-pop; }
.slide.tr-out.tr-zoom { animation-name: hs-fade; animation-direction: reverse; }
.slide.tr-in.tr-flip { animation-name: hs-flip-in; }
.slide.tr-out.tr-flip { animation-name: hs-flip-out; }
@keyframes hs-slide-in { from { transform: translateX(100vw); } to { transform: none; } }
@keyframes hs-slide-in-back { from { transform: translateX(-100vw); } to { transform: none; } }
@keyframes hs-push-out { to { transform: translateX(-100vw); } }
@keyframes hs-push-out-back { to { transform: translateX(100vw); } }
@keyframes hs-flip-in { 0%, 50% { transform: perspective(1200px) rotateY(-90deg); } 100% { transform: none; } }
@keyframes hs-flip-out { 0% { transform: none; } 50%, 100% { transform: perspective(1200px) rotateY(90deg); } }
.present-notes { position: fixed; left: 50%; bottom: 44px; translate: -50% 0; width: min(760px, 90vw); max-height: 30vh; overflow: auto; z-index: 3;
  background: rgba(20,18,32,.92); color: #f4f2ff; border-radius: 10px; padding: 12px 16px; white-space: pre-wrap; font-size: 16px; line-height: 1.5; cursor: auto; }
.present-timer { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .anim, .slide.tr-in, .slide.tr-out { animation: none !important; } }

/* chart data editor */
.data-grid { display: grid; gap: 4px; max-height: 46vh; overflow: auto; align-items: center; }
.data-grid input { width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: var(--surface); color: var(--ink); font: inherit; }
.data-grid .dg-head { display: flex; gap: 2px; align-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.data-grid .dg-head input { font-weight: 600; }
.icon-btn.tiny { width: 26px; height: 26px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }
.csv-box, .notes-box { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 13px/1.4 var(--font); background: var(--surface); color: var(--ink); resize: vertical; }

/* grid view + magic resize */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 60vh; overflow: auto; padding: 4px; min-width: min(640px, 80vw); }
.page-card { border: 2px solid transparent; background: var(--bg); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: grab; color: var(--ink); }
.page-card.sel { border-color: var(--accent); }
.page-card.over { border-color: var(--accent-2); border-style: dashed; }
.page-card .thumb { width: 100%; background: var(--surface); border-radius: 6px; overflow: hidden; display: grid; place-items: center; }
.page-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.page-card span { font-size: 12px; font-weight: 600; }
.mr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.mr-opt { display: flex; align-items: center; gap: 4px; }

/* ---------- v4: QR codes ---------- */
.qr-tile { display: grid; place-items: center; padding: 8px; }
.qr-tile svg { position: static; width: 64px; height: 64px; }
.qr-modal .field > span { width: 90px; }
.qr-input { flex: 1; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--ink); font: 14px var(--font); min-width: 280px; }
.qr-preview { width: 180px; height: 180px; flex: none; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.el.qr .inner svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- v4: export progress ---------- */
.progress { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 8px; min-width: 300px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }

/* ---------- v4: stock photos ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip-row .chip { padding: 4px 10px; font-size: 12px; }
.photo-grid { columns: 2; column-gap: 8px; margin-top: 10px; }
.photo-item { break-inside: avoid; margin: 0 0 8px; }
.photo-tile { display: block; width: 100%; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; position: relative; }
.photo-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-tile:hover, .photo-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.photo-tile.busy::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.55); }
.photo-item figcaption { font-size: 11px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-item figcaption a, .photo-credit a, .photo-byline a { color: inherit; }
.photo-status:empty { display: none; }
.photo-credit { font-size: 11px; margin-top: 10px; }
.photo-byline { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
