/* Same palette and type as the percs.lol landing page: ember black, rainbow accents from --hue (lib/hue.css), Manrope. */
:root {
  --bg: #0b0705;
  --panel: #140d0a;
  --panel-2: #1d1410;
  --panel-3: #261a14;
  --field: #0d0806;
  --line: rgba(255, 236, 225, 0.08);
  --line-2: rgba(255, 236, 225, 0.15);
  --ink: #f6f5fb;
  --ink-2: rgba(246, 245, 251, 0.78);
  --ink-3: rgba(246, 245, 251, 0.58);
  --brand: oklch(0.8 0.145 var(--hue));
  --brand-hi: oklch(0.85 0.13 var(--hue));
  --coral: oklch(0.72 0.17 calc(var(--hue) - 60));
  --brand-tint: oklch(0.8 0.145 var(--hue) / 0.12);
  --brand-glow: oklch(0.8 0.145 var(--hue) / 0.45);
  --on-brand: #1a0b05;
  --danger: #ff6b7d;
  --ok: #2de6b0;
  --sel: #2de6b0;
  --on-sel: #04140f;
  --r: 12px;
  --r-sm: 8px;
  --font: 'Manrope', system-ui, sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(60vmax 50vmax at 0% 0%, oklch(0.8 0.145 var(--hue) / 0.16), transparent 70%),
    radial-gradient(50vmax 40vmax at 100% 0%, oklch(0.72 0.17 calc(var(--hue) - 60) / 0.1), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 500 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 200; pointer-events: none; opacity: .035; background-image: var(--grain);
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: .92em; background: var(--panel-3); padding: 1px 6px; border-radius: 6px; }
::selection { background: oklch(0.8 0.145 var(--hue) / .35); }

.accent {
  background: linear-gradient(100deg, var(--brand) 10%, var(--coral) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.loading {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 10px; color: var(--ink-2);
  font-size: 15px; padding: 24px; text-align: center;
}
.loading::before { content: 'percs.lol'; font-size: 28px; font-weight: 800; letter-spacing: -0.04em; color: var(--ink); }
.loading.error { color: var(--danger); }

.logo { font-weight: 800; font-size: 16px; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 36px; }
.logo span { color: var(--ink-3); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), background-color .15s, border-color .15s;
}
.btn:hover { background: var(--panel-3); border-color: rgba(255, 236, 225, .24); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 236, 225, .06); }
.btn.danger { background: transparent; border-color: rgba(255, 107, 125, .45); color: var(--danger); margin-right: auto; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: var(--r-sm); }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: rgba(255, 236, 225, .07); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.on { color: var(--brand); }

.account { display: flex; align-items: center; gap: 8px; }
.acct-avatar { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--brand); }
.acct-link { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px; border-radius: var(--r); color: var(--ink); text-decoration: none; }
.acct-link:hover { background: rgba(255, 236, 225, .06); }
.acct-initial { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-3); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--brand); font-weight: 800; }
.acct-name { color: var(--ink-2); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-note {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; cursor: help; white-space: nowrap;
  border: 1px solid var(--line-2); color: var(--ink-2); font-size: 12px; font-weight: 700;
}
.acct-note::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.save-status { margin: 0; color: var(--ink-3); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(13, 8, 6, .6); }
.seg button {
  height: 30px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-3);
  cursor: pointer; font-weight: 700; transition: color .15s, background-color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--brand-tint); color: var(--brand); box-shadow: inset 0 0 0 1px oklch(0.8 0.145 var(--hue) / .35); }

/* ---------- desktop editor: full-bleed canvas, floating panels ---------- */

.app { position: fixed; inset: 0; overflow: hidden; }

.topbar {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 6; height: 56px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 0 10px 0 16px;
  border-radius: 16px; border: 1px solid var(--line); background: rgba(20, 12, 9, .78);
  backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
  box-shadow: 0 20px 50px -24px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 236, 225, .06);
}
.topbar::after {
  content: ''; position: absolute; left: 24px; right: 24px; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, oklch(0.8 0.145 var(--hue) / .55) 30%, oklch(0.72 0.17 calc(var(--hue) - 60) / .45) 70%, transparent);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.tb-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; flex: none; }
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-left .save-status { flex: 1; min-width: 0; padding-left: 4px; }
.topbar .btn svg, .topbar .seg svg { width: 16px; height: 16px; flex: none; }
.topbar .seg button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; }
#btn-publish { padding: 0 20px; box-shadow: 0 8px 24px -10px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, .35); }
.zoom { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r); background: rgba(13, 8, 6, .6); }
.zoom .icon-btn svg { width: 15px; height: 15px; }
.zoom-label { min-width: 54px; height: 32px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 700; }
.zoom-label:hover { color: var(--brand); }
.icon-btn svg { width: 18px; height: 18px; }

.panel {
  position: absolute; top: 76px; bottom: 10px; z-index: 5; display: flex; flex-direction: column;
  border-radius: 18px; border: 1px solid var(--line); background: rgba(19, 12, 9, .95);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 236, 225, .05);
  overflow: hidden;
}
.left { left: 10px; width: 252px; }
.right { right: 10px; width: 304px; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }

.panel-block { padding: 14px 12px; border-bottom: 1px solid var(--line); }
.block-title { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; font-size: 12px; font-weight: 800; color: var(--ink-2); letter-spacing: -0.01em; }
.count { padding: 1px 7px; border-radius: 999px; background: var(--panel-3); color: var(--ink-3); font-size: 11px; font-weight: 700; }
.block-hint { margin: -6px 2px 10px; color: var(--ink-3); font-size: 11.5px; line-height: 1.35; }
.insert-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.insert {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 0; aspect-ratio: 1 / 1.05; padding: 6px 2px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); color: var(--ink-2); cursor: pointer; font-weight: 700; font-size: 11px;
  transition: transform .2s var(--ease), border-color .15s, color .15s, background-color .15s;
}
.insert svg { width: 20px; height: 20px; }
.insert span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insert:hover { color: var(--brand); border-color: oklch(0.8 0.145 var(--hue) / .45); background: var(--panel-3); transform: translateY(-1px); }
.insert:active { transform: scale(.95); }

.layers-block { border-bottom: 0; }
.layers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.layers-empty { color: var(--ink-3); padding: 6px 2px; line-height: 1.5; }
.layer { position: relative; display: flex; align-items: center; border-radius: var(--r-sm); border: 1px solid transparent; }
.layer:hover { background: rgba(255, 236, 225, .04); }
.layer.selected { background: linear-gradient(90deg, oklch(0.8 0.145 var(--hue) / .16), oklch(0.8 0.145 var(--hue) / .06)); border-color: oklch(0.8 0.145 var(--hue) / .35); }
.layer.is-hidden .layer-pick { opacity: .45; }
.layer.drop-above { box-shadow: inset 0 2px 0 var(--brand); }
.layer.drop-below { box-shadow: inset 0 -2px 0 var(--brand); }
.layer-pick {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 8px;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-align: left; font-weight: 600;
}
.layer-pick svg { flex: none; color: var(--ink-3); }
.layer.selected .layer-pick { color: var(--ink); }
.layer.selected .layer-pick svg { color: var(--brand); }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-rename { flex: 1; min-width: 0; height: 26px; padding: 0 6px; border: 1px solid var(--brand); border-radius: 6px; background: var(--field); }
.layer .icon-btn { width: 26px; height: 26px; flex: none; opacity: 0; transition: opacity .15s; }
.layer .icon-btn svg { width: 15px; height: 15px; }
.layer:hover .icon-btn, .layer:focus-within .icon-btn, .layer .icon-btn.on, .layer.is-hidden .icon-btn { opacity: 1; }

/* canvas */
.viewport {
  position: absolute; inset: 0; overflow: hidden; cursor: default; touch-action: none; user-select: none;
  background:
    radial-gradient(70% 60% at 50% 0%, oklch(0.8 0.145 var(--hue) / .1), transparent 70%),
    radial-gradient(rgba(255, 236, 225, .05) 1px, transparent 1px) 0 0 / 22px 22px,
    #080504;
}
.viewport.can-pan, .viewport.can-pan * { cursor: grab !important; }
.viewport.panning, .viewport.panning * { cursor: grabbing !important; }
.board { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.frame-label {
  position: absolute; left: 0; top: 0; transform: translateY(calc(-100% - 8px / var(--z, 1))); white-space: nowrap;
  font-size: calc(12px / var(--z, 1)); font-weight: 700; color: var(--ink-3); letter-spacing: -0.01em; pointer-events: none;
}
.frame-label b { color: var(--brand); font-weight: 800; }
.page { position: relative; box-shadow: 0 0 0 1px rgba(255, 236, 225, .1), 0 40px 100px -30px rgba(0, 0, 0, .9), 0 20px 80px -30px oklch(0.8 0.145 var(--hue) / .35); }
.page[data-view="m"] { border-radius: 6px; }
.els { position: absolute; inset: 0; }
.els .pl-el { cursor: move; }
.els .pl-el.is-locked { cursor: default; }
.els iframe { pointer-events: none; }
.overlay, .guides { position: absolute; inset: 0; pointer-events: none; }
.sel-box { position: absolute; border: 1.5px solid var(--sel); transform-origin: center; box-shadow: 0 0 0 1px rgba(4, 20, 15, .35), 0 0 18px rgba(45, 230, 176, .25); }
.sel-box.locked { border-style: dashed; border-color: var(--ink-3); box-shadow: none; }
.handle {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff;
  border: 1.5px solid var(--sel); border-radius: 3px; pointer-events: auto; box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
.rot {
  position: absolute; left: 50%; top: -30px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--sel); pointer-events: auto; cursor: grab;
}
.rot::after { content: ''; position: absolute; left: 50%; top: 11px; width: 1.5px; height: 18px; margin-left: -.75px; background: var(--sel); }
.sel-size {
  position: absolute; left: 50%; top: 100%; margin-top: 8px; transform: translateX(-50%); padding: 2px 7px; border-radius: 6px;
  background: var(--sel); color: var(--on-sel); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.guide { position: absolute; background: var(--coral); box-shadow: 0 0 6px oklch(0.72 0.17 calc(var(--hue) - 60) / .6); }
.guide.v { top: 0; bottom: 0; width: 1px; }
.guide.h { left: 0; right: 0; height: 1px; }
.marquee { position: absolute; border: 1px solid var(--sel); background: rgba(45, 230, 176, .08); border-radius: 2px; pointer-events: none; }
.vp-hint {
  position: absolute; left: var(--safe-x, 50%); bottom: 18px; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px;
  background: rgba(20, 12, 9, .85); border: 1px solid var(--line); color: var(--ink-3); font-size: 11px; white-space: nowrap; pointer-events: none;
}
kbd {
  display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px;
  background: var(--panel-2); color: var(--ink); font: 700 11px/1.4 var(--font); text-align: center;
}
.empty-hint {
  position: absolute; left: var(--safe-x, 50%); top: 52%; transform: translate(-50%, -50%); z-index: 2; display: grid; justify-items: center; gap: 10px;
  max-width: 340px; padding: 28px; text-align: center; border-radius: 20px; border: 1px dashed var(--line-2); background: rgba(19, 12, 9, .8);
}
.empty-hint p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.empty-hint .eh-title { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; color: var(--ink); }
.text-edit {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; resize: none; overflow: hidden;
  background: transparent; outline: 1.5px dashed var(--brand); outline-offset: 2px; caret-color: var(--brand); white-space: pre-wrap;
}

/* inspector */
.insp-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; }
.insp-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--brand-tint); color: var(--brand); }
.insp-icon svg { width: 18px; height: 18px; }
.insp-head-text { min-width: 0; }
.insp-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-kind { margin: 0; color: var(--ink-3); font-size: 11px; font-weight: 700; }
.tabs { display: flex; gap: 2px; margin: 0 14px 8px; padding: 3px; border-radius: var(--r); background: rgba(13, 8, 6, .7); border: 1px solid var(--line); }
.tabs button {
  flex: 1; height: 30px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-3); font-weight: 700; cursor: pointer;
  transition: color .15s, background-color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--panel-3); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255, 236, 225, .06); }
.insp-sec { border-top: 1px solid var(--line); }
.sec-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 14px; border: 0; background: transparent;
  color: var(--ink); font-size: 12px; font-weight: 800; letter-spacing: -0.01em; cursor: pointer; text-align: left;
}
.sec-head:hover { color: var(--brand); }
.sec-head svg { width: 14px; height: 14px; color: var(--ink-3); transition: transform .2s var(--ease); }
.insp-sec.collapsed .sec-head svg { transform: rotate(-90deg); }
.insp-sec.collapsed .sec-body { display: none; }
.sec-body { padding: 0 14px 14px; }
.insp-row { display: grid; gap: 8px; margin-bottom: 8px; }
.insp-row.cols-2 { grid-template-columns: 1fr 1fr; }
.insp-row:last-child { margin-bottom: 0; }
.field { display: grid; gap: 5px; min-width: 0; }
.field.inline { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.field.inline .f-label { color: var(--ink-2); font-size: 12px; }
.f-label { color: var(--ink-3); font-size: 11px; font-weight: 700; }
.f-label.scrub { cursor: ew-resize; user-select: none; }
.f-label.scrub:hover { color: var(--brand); }
.field input:not([type="checkbox"]):not([type="color"]), .field select, .field textarea, .handle-field input {
  width: 100%; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--field); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-2); }
.field textarea { height: auto; min-height: 68px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px oklch(0.8 0.145 var(--hue) / .15); }
.field input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.field.compact { position: relative; display: block; }
.field.compact .f-label {
  position: absolute; left: 1px; top: 1px; bottom: 1px; z-index: 1; display: grid; place-items: center; width: 26px;
  border-radius: 7px 0 0 7px; color: var(--ink-3); font-size: 11px; font-weight: 800;
}
.field.compact input { padding-left: 28px !important; font-variant-numeric: tabular-nums; }
.f-note { margin: 0; color: var(--danger); font-size: 11px; }
.f-note:empty { display: none; }
.color-wrap { display: grid; grid-template-columns: 32px minmax(0, 1fr) 50px auto auto; align-items: center; gap: 4px; }
.color-wrap input[type="color"] { width: 32px; height: 32px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--field); cursor: pointer; }
.color-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-wrap input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-wrap .alpha { padding: 0 4px !important; text-align: right; }
.color-wrap .pct { color: var(--ink-3); font-size: 11px; }
.mini { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; font-size: 11px; font-weight: 700; }
.mini:hover { color: var(--brand); border-color: oklch(0.8 0.145 var(--hue) / .4); }
.media-box { display: grid; gap: 8px; }
.media-show { min-height: 30px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--ink-2); overflow: hidden; }
.media-show img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line-2); }
.media-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--ink-3); }
.local-note { display: block; width: 100%; font-size: 11px; line-height: 1.4; white-space: normal; }
.icon-row { display: flex; gap: 4px; padding: 3px; border-radius: var(--r); background: rgba(13, 8, 6, .7); border: 1px solid var(--line); }
.icon-row + .icon-row { margin-top: 6px; }
.icon-row button {
  flex: 1; display: grid; place-items: center; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-row button svg { width: 17px; height: 17px; }
.icon-row button:hover:not(:disabled) { background: var(--panel-3); color: var(--brand); }
.icon-row button:disabled { opacity: .3; cursor: default; }
.btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.btn-grid .btn { min-width: 0; padding: 0 6px; }
.phone-note { margin: 0 14px 10px; padding: 12px; border-radius: var(--r); background: rgba(45, 230, 176, .07); border: 1px solid rgba(45, 230, 176, .22); }
.phone-note p { margin: 0 0 10px; color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.insp-tip { margin: 0; color: var(--ink-3); font-size: 11px; line-height: 1.5; }
.insp-tip a { color: var(--brand); }

/* ---------- dialogs ---------- */

.dlg {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 28px; border: 1px solid var(--line-2);
  border-radius: 20px; background: linear-gradient(180deg, #1b120e, var(--panel) 160px); color: var(--ink);
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, .9), 0 20px 70px -30px oklch(0.8 0.145 var(--hue) / .25);
}
.dlg:focus-visible { outline: none; }
.dlg.narrow { width: min(480px, calc(100vw - 32px)); }
.dlg.wide { width: min(1280px, calc(100vw - 32px)); padding: 18px; }
.dlg::backdrop { background: rgba(8, 5, 4, .7); backdrop-filter: blur(4px); }
.dlg h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.dlg-sub { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.dlg-sub a { color: var(--brand); font-weight: 700; }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 20px; }
.dlg-actions form { display: contents; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tpl-grid[data-view="d"] { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tpl-card {
  display: grid; gap: 10px; padding: 8px 8px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2);
  color: var(--ink); cursor: pointer; font-weight: 800; font-size: 14px; text-align: left;
  transition: transform .25s var(--ease), border-color .15s, box-shadow .25s;
}
.tpl-card span { padding: 0 4px; }
.tpl-card:hover { border-color: oklch(0.8 0.145 var(--hue) / .6); transform: translateY(-3px); box-shadow: 0 20px 40px -20px oklch(0.8 0.145 var(--hue) / .4); }
.tpl-thumb { width: 100%; aspect-ratio: 3 / 4.4; border-radius: 10px; pointer-events: none; }
.tpl-grid[data-view="d"] .tpl-thumb { aspect-ratio: 16 / 10; }
.handle-field { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--field); margin-top: 8px; transition: border-color .15s, box-shadow .15s; }
.handle-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px oklch(0.8 0.145 var(--hue) / .15); }
.handle-field span { padding: 0 2px 0 14px; color: var(--ink-3); font-size: 16px; font-weight: 700; }
.handle-field input { height: 48px !important; border: 0 !important; background: transparent !important; padding-left: 0 !important; font-size: 16px; font-weight: 700; outline: none; box-shadow: none !important; }
.msg { min-height: 20px; margin: 10px 0 0; color: var(--ink-3); font-size: 13px; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--danger); }
#pub-link { font-size: 16px; }
.agree { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; color: var(--ink-2); font-size: 13px; line-height: 1.5; cursor: pointer; }
.agree input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); }
.agree a { color: var(--brand); }
.pub-alt { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid rgba(255, 209, 102, .35); background: rgba(255, 209, 102, .08); color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.pv-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.pv-head h2 { margin: 0; font-size: 18px; }
.pv-head form { margin-left: auto; }
.preview-box { margin: 0 auto; height: min(78vh, 860px); border-radius: 16px; border: 1px solid var(--line-2); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8); }
.preview-box[data-device="phone"] { width: 390px; max-width: 100%; border-radius: 28px; }
.preview-box[data-device="desktop"] { width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: min(520px, calc(100vw - 32px)); margin: 0; padding: 12px 16px;
  border-radius: var(--r); border: 1px solid oklch(0.8 0.145 var(--hue) / .35); background: #22160f; color: var(--ink); font-size: 13px; font-weight: 600;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .8);
  opacity: 0; transform: translate(-50%, 8px); transition: opacity .2s, transform .25s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 107, 125, .55); }

/* ---------- phone flow ---------- */

.simple { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); font-size: 15px; }
.s-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px;
  margin: 0 -16px; padding: 0 16px; background: rgba(11, 7, 5, .75); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
}
.simple .btn { min-height: 44px; padding: 0 18px; font-size: 15px; }
.simple .logo { min-height: 44px; font-size: 18px; }
.s-pick h1 { margin: 28px 0 10px; font-size: 40px; font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
.s-pick p { margin: 0 0 24px; color: var(--ink-2); line-height: 1.6; }
.simple .tpl-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
.s-preview { height: 440px; margin-top: 16px; border-radius: 24px; border: 1px solid var(--line-2); box-shadow: 0 30px 70px -30px oklch(0.8 0.145 var(--hue) / .3); }
.s-bar { display: flex; gap: 8px; margin: 12px 0 24px; }
.s-bar .btn { flex: 1; }
.s-form { display: grid; gap: 20px; }
.s-field { display: grid; gap: 8px; }
.s-label, .s-link legend { color: var(--ink); font-size: 14px; font-weight: 800; letter-spacing: -0.01em; }
.s-field input, .s-field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--field); color: var(--ink); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.s-field textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.s-field input:focus, .s-field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px oklch(0.8 0.145 var(--hue) / .15); }
.s-link { display: grid; gap: 12px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.s-link legend { padding: 0 6px; }
.s-link .s-label { font-size: 13px; color: var(--ink-2); font-weight: 700; }
.s-note { margin: 0; color: var(--ink-3); font-size: 13px; }
.s-note:empty { display: none; }
.s-empty { color: var(--ink-2); }
.s-image { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.s-thumb { display: grid; place-items: center; width: 68px; height: 68px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--field); color: var(--ink-3); font-size: 11px; overflow: hidden; }
.s-thumb img { width: 100%; height: 100%; object-fit: cover; }
.s-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(11, 7, 5, .85); border-top: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
}
.s-actions .save-status { flex: 1; }
.s-actions .btn { flex: none; }
.s-actions .btn.primary { box-shadow: 0 8px 24px -10px var(--brand-glow); }

.vp-hint-touch { display: none; }
@media (pointer: coarse) {
  .layer .icon-btn { opacity: 1; }
  .icon-row button { height: 40px; }
  .vp-hint-mouse { display: none; }
  .vp-hint-touch { display: block; }
  .handle { width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 5px; }
  .rot { width: 22px; height: 22px; margin-left: -11px; top: -44px; }
  .rot::after { top: 21px; height: 22px; }
  .icon-btn { width: 40px; height: 40px; }
  .layer-pick { height: 44px; }
  .layer .icon-btn { width: 40px; height: 40px; }
  .btn, .btn.small { min-height: 40px; }
  .field input:not([type="checkbox"]):not([type="color"]), .field select { height: 40px; }
  .color-wrap input[type="color"], .mini { height: 40px; }
  .field input[type="checkbox"] { width: 22px; height: 22px; }
}

/* tablets and small laptop windows */
@media (max-width: 1280px) {
  .acct-name, .tb-left .save-status, #btn-templates span, #btn-preview span, .vp-hint { display: none !important; }
  .left { width: 228px; }
  .right { width: 280px; }
}
/* Narrow screens: the left panel becomes an icon rail so the canvas keeps its room. */
@media (max-width: 1100px) {
  .left { width: 64px; }
  .left .panel-block { padding: 10px 8px; }
  .left .block-title, .left .block-hint { display: none; }
  .left .insert-grid { grid-template-columns: 1fr; gap: 6px; }
  .left .insert { aspect-ratio: auto; height: 44px; padding: 0; }
  .left .insert span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .left .layer-pick { justify-content: center; padding: 0; height: 40px; }
  .left .layer-name, .left .layer .icon-btn { display: none; }
  .right { width: 264px; }
}
@media (max-width: 1000px) {
  .topbar { grid-template-columns: auto auto minmax(0, 1fr); padding: 0 8px 0 12px; }
  .tb-right { gap: 4px; }
  .zoom, #btn-keys, .tb-sep { display: none; }
  .topbar .seg button span { display: none; }
  .right { width: 248px; }
  .btn-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .btn, .insert, .tpl-card { transition: none; }
  .tpl-card:hover { transform: none; }
}

.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 4px 0 0; align-items: center; }
.keys dt { margin: 0; white-space: nowrap; color: var(--ink-2); font-size: 12px; }
.keys dd { margin: 0; color: var(--ink-2); font-size: 13px; }

/* Alpha key screen (editor/gate.js) */
.gate {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60vmax 50vmax at 50% 0%, oklch(0.8 0.145 var(--hue) / .14), transparent 70%), var(--bg);
}
.gate-card { width: min(420px, 100%); padding: 32px 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); text-align: center; }
.gate-logo { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.gate-logo span { color: var(--ink-3); font-weight: 700; }
.gate h1 { margin: 14px 0 8px; font-size: 34px; font-weight: 800; letter-spacing: -0.045em; line-height: 1.05; }
.gate-sub { margin: 0 0 22px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.gate-form { display: flex; gap: 8px; }
.gate-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--field); color: var(--ink); font: 700 15px/1 var(--font); letter-spacing: .05em; text-transform: uppercase;
}
.gate-form input::placeholder { color: var(--ink-3); }
.gate-form input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px oklch(0.8 0.145 var(--hue) / .15); }
.gate-form .btn { min-height: 44px; padding: 0 18px; font-size: 15px; }
.gate .msg { text-wrap: balance; }
.gate-foot { margin: 16px 0 0; color: var(--ink-3); font-size: 13px; }
.gate-foot b { color: var(--ink-2); }
.link-btn { padding: 0; border: 0; background: none; color: var(--ink-2); font: inherit; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--ink); }

.links-edit, .links-list { display: grid; gap: 8px; }
.link-item { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); }
.link-top { display: flex; align-items: center; gap: 6px; }
.link-top select { flex: 1; min-width: 0; }
.link-top .btn { flex: none; }
.link-thumb { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 7px; background: var(--panel-3); color: var(--ink-3); overflow: hidden; }
.link-thumb img { width: 20px; height: 20px; object-fit: contain; }
.link-item .f-note:empty { display: none; }
