:root {
  --bg: #0d0f13;
  --panel: #15181f;
  --raised: #1c2029;
  --raised-2: #232834;
  --line: #272c38;
  --line-soft: #1f2430;
  --text: #e7eaf0;
  --muted: #8d95a7;
  --faint: #626a7c;
  --accent: #7d5fff;
  --accent-hi: #947bff;
  --accent-soft: rgba(125, 95, 255, 0.16);
  --teal: #2fd3c7;
  --warn: #ffb454;
  --danger: #ff5d6c;
  --ok: #4fd28a;
  --radius: 8px;
  --ui: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 var(--ui); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-hi); }
::selection { background: rgba(125, 95, 255, 0.45); }
* { scrollbar-width: thin; scrollbar-color: #343a49 transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #303645; border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #454c5f; background-clip: content-box; border: 2px solid transparent; }

/* ---- shell ---- */
#app { display: grid; height: 100vh; height: 100dvh; grid-template-columns: 316px minmax(0, 1fr) 344px; grid-template-rows: 52px minmax(0, 1fr) auto; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.left { grid-column: 1; grid-row: 2; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; display: flex; }
.center { grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; position: relative; }
.right { grid-column: 3; grid-row: 2 / 4; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; }
.bottom { grid-column: 1 / 3; grid-row: 3; background: var(--panel); border-top: 1px solid var(--line); min-width: 0; }

.boot { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); }
.boot-card { width: 74px; height: 102px; border-radius: 9px; border: 2px solid var(--accent); background: linear-gradient(135deg, rgba(125, 95, 255, 0.35), rgba(47, 211, 199, 0.2)); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-5px) rotate(-3deg); opacity: 0.7; } }
.fatal { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-content: center; gap: 10px; text-align: center; padding: 24px; }

/* ---- top bar ---- */
.brand { display: flex; align-items: center; gap: 8px; margin-right: 6px; white-space: nowrap; color: inherit; text-decoration: none; }
.logo { display: block; width: 30px; height: 30px; object-fit: contain; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-tag { display: inline-flex; align-items: center; gap: 7px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.brand-dot { width: 5px; height: 5px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e4f1ff, #5aa8ff 45%, #7d5fff); box-shadow: 0 0 4px rgba(90, 168, 255, 0.8); }
.project-name { width: 190px; flex: 0 1 190px; min-width: 110px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; color: var(--text); font-weight: 600; }
.project-name:hover { border-color: var(--line); }
.project-name:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1px solid var(--line-soft); }
.spacer { flex: 1; }
.saved { color: var(--faint); font-size: 12px; white-space: nowrap; }
.saved.warn { color: var(--warn); }
.zoom-label { min-width: 48px; background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 6px 4px; font-variant-numeric: tabular-nums; }
.zoom-label:hover { background: var(--raised); color: var(--text); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--raised); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 500; transition: background 0.12s, border-color 0.12s, transform 0.05s; }
.btn:hover { background: var(--raised-2); border-color: #363d4d; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.wide { width: 100%; }
.btn:disabled, .icon-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.on { color: var(--accent-hi); background: var(--accent-soft); }
.icon-btn.sm { width: 24px; height: 24px; border-radius: 5px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ico { flex: none; }

/* ---- left panel ---- */
.side { display: flex; width: 100%; min-height: 0; }
.side-tabs { display: flex; flex-direction: column; gap: 2px; padding: 8px 5px; border-right: 1px solid var(--line-soft); background: #12151b; }
.side-tab { display: grid; justify-items: center; gap: 3px; width: 58px; padding: 9px 2px 7px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-size: 10.5px; }
.side-tab:hover { color: var(--text); background: var(--raised); }
.side-tab.on { color: #fff; background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.side-body { flex: 1; min-width: 0; overflow-y: auto; padding: 12px 12px 24px; }
.side-h { font-size: 12.5px; font-weight: 650; letter-spacing: 0.01em; color: var(--text); margin: 18px 0 8px; }
.side-h:first-child { margin-top: 2px; }
.side-note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.side-note.rights { color: var(--warn); }
.empty { color: var(--faint); font-size: 12px; padding: 8px 2px; }
.muted { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.tpl-thumb { position: relative; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); background: #000; line-height: 0; }
.tpl-thumb canvas { width: 100% !important; height: auto !important; display: block; }
.tpl-actions { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 8px; background: rgba(10, 12, 16, 0.78); opacity: 0; transition: opacity 0.12s; line-height: 1.3; }
.tpl:hover .tpl-actions, .tpl:focus-within .tpl-actions { opacity: 1; }
.tpl-name { font-weight: 600; margin-top: 6px; font-size: 12.5px; }
.tpl-blurb { color: var(--faint); font-size: 11px; line-height: 1.3; }

.el-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.el-tile { display: grid; gap: 4px; justify-items: center; padding: 6px 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: repeating-conic-gradient(#191d25 0% 25%, #151920 0% 50%) 50% / 16px 16px; color: var(--muted); cursor: grab; font-size: 11px; overflow: hidden; }
.el-tile:hover { border-color: var(--accent); color: var(--text); }
.el-tile canvas { max-width: 100%; }
.el-tile > span { display: inline-flex; align-items: center; gap: 4px; line-height: 1.2; }
/* member pack: the drawing still shows (it is the pitch), the tile reads as locked and cannot be dragged */
.el-tile.locked { cursor: pointer; border-style: dashed; }
.el-tile.locked canvas { opacity: 0.72; }
.el-tile.locked:hover canvas { opacity: 1; }

.up-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin: 10px 0; }
.up-tile { position: relative; aspect-ratio: 1; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); cursor: grab; background: repeating-conic-gradient(#20242d 0% 25%, #181b22 0% 50%) 50% / 12px 12px; }
.up-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up-tile:hover { border-color: var(--accent); }
.up-actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; padding: 2px; background: rgba(10, 12, 16, 0.82); opacity: 0; transition: opacity 0.12s; }
.up-tile:hover .up-actions, .up-tile:focus-within .up-actions { opacity: 1; }
.up-actions .icon-btn { width: 20px; height: 22px; color: #d8dce6; }
.font-list { margin-top: 8px; display: grid; gap: 4px; }
.font-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px 10px; border-radius: 6px; background: var(--raised); font-size: 15px; }

.sym-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sym-chip { display: grid; justify-items: center; gap: 1px; width: 100%; padding: 5px 2px 3px; border-radius: 8px; border: 1px solid transparent; background: var(--raised); color: var(--muted); cursor: pointer; font-size: 10px; font-family: ui-monospace, Consolas, monospace; overflow: hidden; }
.sym-chip:hover { border-color: var(--accent); color: var(--text); }
.sym-chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-cell { position: relative; }
.sym-cell.editing .sym-chip { border-color: var(--teal); }
.sym-edit { position: absolute; top: -4px; right: -4px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--raised-2); color: var(--text); cursor: pointer; opacity: 0; transition: opacity 0.1s; }
.sym-cell:hover .sym-edit, .sym-edit:focus-visible, .sym-cell.editing .sym-edit { opacity: 1; }
.sym-edit:hover { background: var(--accent); border-color: var(--accent); }
.sym-box { container-type: inline-size; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; margin: 4px 0 14px; padding: 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); }
.sym-box .side-h { margin: 0; }
.sym-box .side-note { margin: 0; }
.sym-editor { border-color: var(--teal); }
.sym-strip { display: flex; gap: 6px; }
.ink-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.sym-custom { position: relative; }
.sym-custom .sym-del { top: auto !important; bottom: 14px; }
.sym-custom > .icon-btn { position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; border-radius: 50%; background: var(--raised-2); border: 1px solid var(--line); }
.sym-form { container-type: inline-size; margin-top: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.sym-form .side-h { margin: 0; }
.sym-preview { width: 72px; height: 72px; flex: none; border-radius: 8px; background: repeating-conic-gradient(#2a2f3b 0% 25%, #20242e 0% 50%) 50% / 14px 14px; }
.sym-spin { cursor: grab; touch-action: none; }
.sym-spin:active { cursor: grabbing; }
.sym-spin-stage { display: flex; justify-content: center; padding: 4px 0; border-radius: 8px; background: repeating-conic-gradient(#2a2f3b 0% 25%, #20242e 0% 50%) 50% / 14px 14px; }
.sym-spin-box { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.form-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.grow { flex: 1; min-width: 0; display: grid; gap: 6px; }
label.inline { display: grid; grid-template-columns: 50px 1fr; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
label.stack { display: grid; gap: 4px; color: var(--muted); font-size: 11.5px; min-width: 0; }
label.stack.grow { flex: 1; }
label.check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row.end { justify-content: flex-end; }
.row > .field { flex: 1; min-width: 0; }

/* ---- form controls ---- */
input[type="text"], input[type="number"], select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; min-height: 31px; color: var(--text); min-width: 0; width: 100%; }
input[type="text"]:hover, input[type="number"]:hover, select:hover, textarea:hover { border-color: #363d4d; }
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; line-height: 1.4; font-size: 13px; }
select { padding-right: 2px; }
input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { opacity: 0.35; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 18px; background: none; width: 100%; min-width: 0; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: #2c3240; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: #2c3240; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
input[type="color"] { -webkit-appearance: none; appearance: none; width: 30px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; flex: none; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }

/* ---- right panel ---- */
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 6px 8px 6px 14px; font-weight: 650; font-size: 14px; border-bottom: 1px solid var(--line-soft); flex: none; }
.panel-titles { display: grid; min-width: 0; }
.panel-sub { font-weight: 400; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .tools { display: flex; gap: 1px; }
.panel-head .icon-btn { width: 28px; height: 28px; }
.inspector { flex: 1 1 62%; min-height: 0; display: flex; flex-direction: column; }
.inspector-body { overflow-y: auto; min-height: 0; flex: 1; padding: 8px 8px 16px; display: grid; gap: 7px; align-content: start; }
.layers-panel { flex: 0 1 38%; min-height: 150px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.layer-list { position: relative; overflow-y: auto; flex: 1; padding: 4px; }

/* Accordion sections: one open at a time. The header says what the section is and what it is for. */
.sec { border: 1px solid var(--line); border-radius: 11px; background: #12151b; }
.sec-head { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; text-align: left; }
.sec-head:hover { background: var(--raised); }
.sec-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--raised-2); color: var(--muted); }
.sec-titles { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sec-title { font-size: 13.5px; font-weight: 650; letter-spacing: 0.005em; }
.sec-desc { font-size: 11.5px; line-height: 1.3; color: var(--muted); }
.sec-chev { flex: none; color: var(--faint); display: grid; transition: transform 0.15s; transform: rotate(-90deg); }
.sec-body { display: none; gap: 12px; padding: 4px 13px 15px; }
.sec.open { border-color: rgba(125, 95, 255, 0.55); background: var(--raised); box-shadow: 0 0 0 1px rgba(125, 95, 255, 0.18), 0 8px 24px rgba(0, 0, 0, 0.28); }
.sec.open > .sec-head { position: sticky; top: -8px; z-index: 3; background: var(--raised); border-radius: 10px 10px 0 0; border-bottom: 1px solid var(--line-soft); margin-bottom: 8px; }
.sec.open .sec-ico { background: var(--accent); color: #fff; }
.sec.open .sec-chev { transform: none; color: var(--text); }
.sec.open > .sec-body { display: grid; }
.group { display: grid; gap: 9px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.sec-body > .group:first-child { border-top: 0; padding-top: 2px; }
.group-h { font-size: 12px; font-weight: 650; color: #c3c9d6; }
.field { display: flex; align-items: center; gap: 9px; min-width: 0; }
.field .lab { flex: none; width: 74px; color: #aab1c0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > .field .lab { width: auto; min-width: 26px; max-width: 74px; }
.num-field .lab { cursor: ew-resize; user-select: none; touch-action: none; }
.num-field .lab:hover { color: var(--text); }
.unit { color: var(--faint); font-size: 11px; flex: none; }
.val { flex: none; width: 40px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
input.hex { width: 78px !important; flex: 0 1 78px; min-width: 60px; padding-left: 6px; padding-right: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.color-field .lab:empty { display: none; }
.color-field .lab { flex-shrink: 1; min-width: 44px; }
/* too narrow for label and control side by side (the smallest desktop layout): label on its own line */
@container (max-width: 160px) {
  .field { flex-wrap: wrap; row-gap: 3px; }
  .field .lab, .row > .field .lab { flex: 1 0 100%; width: auto; max-width: none; }
  .field input[type="range"] { flex: 1 1 0; }
}
.text-field { display: block; }
.note { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.note.warn { color: var(--warn); }
.segs { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 2px; gap: 2px; flex: 1; min-width: 0; }
.seg { flex: 1; display: grid; place-items: center; height: 24px; min-width: 24px; padding: 0 6px; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.seg:hover { color: var(--text); }
.seg.on { background: var(--raised-2); color: #fff; box-shadow: 0 0 0 1px #3a4152; }
.toggle-field { cursor: pointer; gap: 8px; }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-field .lab { width: auto !important; max-width: none !important; }
.switch { flex: none; width: 28px; height: 16px; border-radius: 16px; background: #2c3240; position: relative; transition: background 0.12s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #aab1c2; transition: transform 0.12s, background 0.12s; }
.toggle-field input:checked + .switch { background: var(--accent); }
.toggle-field input:checked + .switch::after { transform: translateX(12px); background: #fff; }
.toggle-field input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-row { display: flex; gap: 2px; flex-wrap: wrap; }
.paint { display: grid; gap: 10px; }
.paint-extra { display: grid; gap: 10px; }

/* gradient editor: preview bar with colour stops underneath */
.grad { display: grid; gap: 10px; }
.grad-editor { padding: 0 9px; }
.grad-bar { height: 28px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.22); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45); cursor: copy; touch-action: none; }
.grad-track { position: relative; height: 24px; margin-top: 1px; cursor: copy; touch-action: none; }
.grad-stop { position: absolute; top: 0; width: 18px; height: 24px; margin-left: -9px; padding: 0; border: 0; background: none; cursor: grab; touch-action: none; }
.grad-stop::before { content: ""; position: absolute; left: 50%; top: 0; margin-left: -5px; border: 5px solid transparent; border-top: 0; border-bottom-color: #aab1c0; }
.grad-chip { position: absolute; left: 1px; top: 5px; width: 16px; height: 16px; border-radius: 4px; border: 2px solid #aab1c0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); }
.grad-stop:hover .grad-chip { border-color: #fff; }
.grad-stop.on { z-index: 2; }
.grad-stop.on .grad-chip { border-color: #fff; box-shadow: 0 0 0 2px var(--accent), 0 1px 4px rgba(0, 0, 0, 0.7); }
.grad-stop.on::before { border-bottom-color: #fff; }
.grad-stop.away { opacity: 0.3; }
.grad-stop:focus-visible { outline: none; }
.grad-stop:focus-visible .grad-chip { box-shadow: 0 0 0 2px var(--teal); }

/* image chooser */
.pick { display: grid; gap: 14px; }
.pick-bar { align-items: center; }
.pick-bar .note { margin: 0; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; max-height: 56vh; overflow-y: auto; padding: 2px; }
.pick-tile { display: grid; gap: 5px; padding: 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); cursor: pointer; font-size: 11px; text-align: center; }
.pick-tile:hover { border-color: var(--accent); color: var(--text); }
.pick-tile img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 6px; background: repeating-conic-gradient(#20242d 0% 25%, #181b22 0% 50%) 50% / 12px 12px; }
.pick-tile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatches { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.sw { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.18); cursor: pointer; padding: 0; }
.sw:hover { transform: scale(1.15); border-color: #fff; }

.layer-row { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 2px; border-radius: 6px; cursor: default; user-select: none; touch-action: none; }
.layer-row:hover { background: var(--raised); }
.layer-row.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(125, 95, 255, 0.5); }
.layer-row.hidden-layer .name, .layer-row.hidden-layer .type { opacity: 0.4; }
.layer-row.dragging { opacity: 0.4; }
.layer-row .grip { color: var(--faint); cursor: grab; display: grid; }
.layer-row .type { color: var(--muted); display: grid; }
.layer-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .icon-btn { opacity: 0.35; }
.layer-row:hover .icon-btn, .layer-row .icon-btn.on { opacity: 1; }
.rename { height: 24px; padding: 2px 6px !important; }
.drop-marker { position: absolute; background: var(--teal); border-radius: 2px; pointer-events: none; z-index: 5; }
.drop-marker.v { height: 2px; }
.drop-marker.h { width: 3px; }

/* ---- stage ---- */
.stage { position: absolute; inset: 0; overflow: hidden; outline: none; touch-action: none; cursor: default;
  background-color: #0b0d11; background-image: radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px); background-size: 22px 22px; }
.stage.on-selection { cursor: move; } /* a drag here moves the selected layer, even under other layers */
.stage.panning { cursor: grab; }
.stage-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.card-canvas { display: block; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06); background: #000; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.sel-box { position: absolute; box-sizing: border-box; border: 1.5px solid var(--accent-hi); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); pointer-events: none; }
.sel-box.hover { border: 1px solid rgba(255, 255, 255, 0.75); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.sel-box.locked { border-style: dashed; border-color: var(--muted); }
.sel-box.crop { border-color: var(--teal); border-style: dashed; }
.handle { position: absolute; width: 11px; height: 11px; margin: -6px 0 0 -6px; background: #fff; border: 1.5px solid var(--accent); border-radius: 3px; pointer-events: auto; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); touch-action: none; }
.handle::after { content: ""; position: absolute; inset: -9px; }
.h-nw { left: 0; top: 0; cursor: nwse-resize; }
.h-n { left: 50%; top: 0; cursor: ns-resize; }
.h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.h-e { left: 100%; top: 50%; cursor: ew-resize; }
.h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.h-s { left: 50%; top: 100%; cursor: ns-resize; }
.h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.h-w { left: 0; top: 50%; cursor: ew-resize; }
.h-rot { left: 50%; top: -30px; border-radius: 50%; cursor: grab; }
.rot-stem { position: absolute; left: 50%; top: -30px; width: 1.5px; height: 30px; margin-left: -0.75px; background: var(--accent-hi); }
.flag { position: absolute; right: -11px; top: -11px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--danger); color: #fff; font-weight: 700; font-size: 12px; pointer-events: auto; cursor: help; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.size-chip { position: absolute; left: 50%; bottom: -30px; transform: translateX(-50%); padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.snap-line { position: absolute; background: var(--teal); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.5); }
.stage-hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); max-width: 80%; padding: 7px 14px; border-radius: 20px; background: rgba(18, 21, 28, 0.9); border: 1px solid var(--line); color: var(--muted); font-size: 12px; pointer-events: none; opacity: 0; transition: opacity 0.2s; text-align: center; }
.stage-hint.show { opacity: 1; }
.drop-veil { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(125, 95, 255, 0.12); display: none; place-items: center; font-size: 16px; font-weight: 600; pointer-events: none; z-index: 10; }
.drop-veil.show { display: grid; }

/* ---- deck strip ---- */
.deck { display: flex; align-items: stretch; gap: 10px; padding: 8px 12px 4px; min-width: 0; }
.deck-tools { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; flex: none; }
.deck-tools .icon-btn { display: inline-grid; }
.deck-tools { flex-flow: row wrap; width: 104px; align-content: flex-start; }
.deck-list { position: relative; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 6px; flex: 1; min-width: 0; }
.deck-card { position: relative; flex: none; display: grid; gap: 3px; padding: 3px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; user-select: none; touch-action: pan-x; }
.deck-card canvas { display: block; border-radius: 4px; background: #000; }
.deck-card:hover { border-color: #394052; }
.deck-card.on { border-color: var(--accent); background: var(--accent-soft); }
.deck-card.dragging { opacity: 0.4; }
.deck-name { max-width: 76px; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.deck-num { position: absolute; top: 6px; left: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 10px; display: grid; place-items: center; }
.deck-tag { position: absolute; top: 6px; right: 6px; padding: 0 5px; border-radius: 8px; background: var(--teal); color: #062a27; font-size: 9.5px; font-weight: 700; }
.fineprint { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 2px 12px 7px; color: var(--faint); font-size: 10.5px; }
.fineprint a { color: var(--muted); text-decoration: none; }
.fineprint a:hover { color: var(--text); text-decoration: underline; }

/* ---- modal, toasts ---- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(5, 6, 9, 0.66); backdrop-filter: blur(3px); }
.modal { width: min(440px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7); }
.modal.wide { width: min(780px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line-soft); }
.modal h2 { font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.modal.busy, .modal-wrap.busy .modal { pointer-events: none; }
.modal-wrap.busy .btn { opacity: 0.5; }
.menu-list { display: grid; gap: 8px; }
.export { display: grid; gap: 18px; }
.export section { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); justify-items: start; }
.export h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 2px 0 0; accent-color: var(--accent); }
.choice b { display: block; font-weight: 600; }
.choice small { display: block; color: var(--muted); font-size: 11px; }
.export-status { min-height: 18px; color: var(--teal); font-size: 12px; }
.legalish { color: var(--faint); }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 0 8px; }
.help h3:not(:first-child) { margin-top: 18px; }
.help ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: #cfd4df; }
.keys { border-collapse: collapse; width: 100%; }
.keys td { padding: 4px 8px 4px 0; vertical-align: top; color: #cfd4df; }
.keys td:first-child { white-space: nowrap; width: 1%; }
kbd { display: inline-block; margin-right: 3px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--raised); font: 11px ui-monospace, Consolas, monospace; color: var(--text); }

#toasts { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; pointer-events: none; justify-items: center; }
.toast { max-width: min(560px, 90vw); padding: 9px 16px; border-radius: 10px; background: #232834; border: 1px solid #394052; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); animation: toast-in 0.18s ease-out; transition: opacity 0.35s, transform 0.35s; }
.toast.ok { border-color: rgba(79, 210, 138, 0.6); }
.toast.warn { border-color: rgba(255, 180, 84, 0.7); }
.toast.error { border-color: rgba(255, 93, 108, 0.8); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---- smaller screens ---- */
@media (max-width: 1180px) {
  #app { grid-template-columns: 262px minmax(0, 1fr) 286px; }
  .brand-tag, .saved { display: none; }
  .tpl-grid, .el-grid { gap: 8px; }
}
/* ---- membership: tier chip, lock tags, plans, developer switch ---- */
.tier-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 12px; }
.tier-chip b { color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.tier-chip:hover { border-color: var(--accent); color: var(--text); }
.tier-chip.member { color: var(--ok); border-color: rgba(79, 210, 138, 0.45); }
.dev-switch[hidden] { display: none; }
.dev-switch { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 7px; border: 1px dashed var(--warn); color: var(--warn); font-size: 11px; white-space: nowrap; }
.dev-switch select { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px; font-size: 11.5px; }
.lock-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 6px 1px 5px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hi); font-size: 10.5px; font-weight: 600; vertical-align: middle; letter-spacing: 0.01em; }
.choice.locked { opacity: 0.75; }
.locked-box { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; padding: 10px 12px; border-radius: 9px; border: 1px solid rgba(125, 95, 255, 0.35); background: var(--accent-soft); color: var(--accent-hi); }
.locked-box .grow { display: grid; gap: 2px; color: var(--text); }
.locked-box small { color: var(--muted); }
.upsell { display: grid; gap: 14px; }
.upsell-lead { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.upsell-lead svg { color: var(--accent-hi); flex: none; }
.upsell-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 5px 16px; }
.upsell-list li { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.upsell-list li svg { color: var(--ok); flex: none; }
.upsell-list li.on { color: var(--text); font-weight: 600; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.plan-card { position: relative; display: grid; gap: 6px; align-content: start; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); }
.plan-card.best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-card h4 { margin: 0; font-size: 14px; }
.plan-price { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.plan-blurb { color: var(--accent-hi); font-weight: 600; }
.plan-card .note { min-height: 3em; }
.plan-card .btn { margin-top: 4px; }
.plan-flag { position: absolute; top: -10px; right: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; }
.dev-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border-radius: 8px; border: 1px dashed var(--warn); color: var(--warn); font-size: 12px; }

/* ---- backup reminder ---- */
.backup-banner { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 10px; width: min(760px, calc(100% - 24px)); padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 180, 84, 0.65); background: #241f17; color: var(--text); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5); font-size: 12.5px; }
.backup-banner > svg { color: var(--warn); flex: none; }
.backup-banner .grow { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .dev-switch span, .tier-chip span { display: none; }
  .backup-banner { flex-wrap: wrap; }
}

/* ---- account: sign in / sign up / account panel ---- */
.account-btn { gap: 6px; padding: 0 10px 0 6px; }
.account-btn .avatar { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #2fb8d3); color: #fff; font-size: 11px; font-weight: 700; }
.auth, .af-form { display: grid; gap: 12px; }
.af { display: grid; gap: 5px; }
.af-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.af-input { width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }
.af-input:focus { outline: none; border-color: var(--accent); }
.af-hint { color: var(--faint); font-size: 11.5px; }
.af-error { color: var(--danger); font-size: 12.5px; min-height: 0; }
.af-error:empty { display: none; }
.af-reason { padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--text); }
.af-check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.af-check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.af-switch { color: var(--muted); font-size: 12.5px; text-align: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-hi); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.rules-box { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); }
.rules-box h4 { margin: 0 0 6px; font-size: 13px; }
.rules-box ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 4px; font-size: 12.5px; line-height: 1.4; }
.af-done { display: grid; gap: 10px; justify-items: start; }
.af-done > svg { color: var(--ok); }
.af-done h3 { font-size: 16px; }
.buy-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 15px; }
.buy-price { font-size: 22px; font-weight: 700; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 10px; }
.pack-card { display: grid; gap: 4px; justify-items: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.pack-card:hover { border-color: var(--accent); }
.pack-card small { color: var(--muted); }
.acct { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.acct > .af-error { grid-column: 1 / -1; }
.acct-card { display: grid; gap: 8px; align-content: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--raised); }
.acct-card h4 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 13px; }
.acct-card h4 svg { color: var(--accent-hi); }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.ok-tag, .warn-tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.ok-tag { background: rgba(79, 210, 138, 0.14); color: var(--ok); }
.warn-tag { background: rgba(255, 180, 84, 0.14); color: var(--warn); }
.btn-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.danger { border-color: rgba(255, 93, 108, 0.55); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 93, 108, 0.12); }
.cloud-list { display: grid; gap: 6px; }
.cloud-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); }
.cloud-row .grow { gap: 2px; }
a.btn { text-decoration: none; }

/* ---- AI art panel ---- */
.ai-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ai-panel > *, .ai-balance-wrap > * { min-width: 0; }
.ai-panel .dev-note { flex-wrap: wrap; }
.ai-balance .btn { white-space: normal; height: auto; min-height: 27px; }
.ai-card { display: grid; gap: 8px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); }
.ai-card.rules h4 { margin: 0; font-size: 13px; }
.ai-card.rules ol { margin: 0; padding-left: 18px; display: grid; gap: 5px; font-size: 12px; line-height: 1.4; color: var(--text); }
.ai-balance-wrap { display: grid; gap: 6px; }
.ai-balance { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 9px; background: var(--accent-soft); }
.ai-balance .btn { margin-left: auto; }
.ai-form { display: grid; gap: 10px; }
.ai-prompt { width: 100%; resize: vertical; min-height: 84px; font-size: 13px; line-height: 1.4; }
.ai-count { justify-self: end; }
.ai-notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border-radius: 9px; font-size: 12.5px; line-height: 1.4; }
.ai-notice.block { border: 1px solid rgba(255, 180, 84, 0.6); background: rgba(255, 180, 84, 0.08); }
.ai-notice.error { border: 1px solid rgba(255, 93, 108, 0.6); background: rgba(255, 93, 108, 0.08); }
.ai-notice .grow { display: grid; gap: 4px; justify-items: start; }
.ai-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ai-tile { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); aspect-ratio: 2 / 3; }
.ai-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-tile:hover .up-actions, .ai-tile:focus-within .up-actions { opacity: 1; }
.ai-tag { position: absolute; top: 6px; left: 6px; padding: 1px 6px; border-radius: 999px; background: rgba(10, 12, 16, 0.8); color: var(--warn); font-size: 10px; font-weight: 600; }
.ai-preview { max-width: 100%; max-height: 260px; border-radius: 8px; justify-self: center; }
@media (hover: none) { .ai-tile .up-actions, .up-tile .up-actions { opacity: 1; } }

/* ---- narrow desktop / landscape tablet: compact top bar ---- */
@media (max-width: 1500px) {
  .brand-tag { display: none; }
}
@media (min-width: 901px) and (max-width: 1320px) {
  .topbar { gap: 6px; }
  .project-name { width: auto; flex: 0 1 160px; min-width: 100px; }
  .account-label, .tier-chip:not(.member) > span, .tier-chip.member > span { display: none; }
  .topbar > .btn:not(.primary):not(.account-btn) span { display: none; }
  .topbar > .btn:not(.primary):not(.account-btn) { padding: 0 9px; }
  .tb-zoom .icon-btn[title^="Zoom"] { display: none; }
  .dev-switch > span { display: none; }
}

/* ---- phone and small tablet layout: the card fills the screen, panels are slide-up sheets ---- */
.mobile-nav, .more-btn, .sheet-close { display: none; }
@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  /* clip, not just hidden: scrollIntoView on something in a closed sheet must never scroll the whole editor */
  #app { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; height: var(--app-h, 100dvh); overflow: hidden; overflow: clip; }
  .topbar { grid-column: 1; grid-row: 1; gap: 6px; padding: 6px 8px; height: auto; min-height: 50px; }
  .brand { margin-right: 0; }
  .brand-name, .brand-tag, .saved, .dev-switch, .tb-zoom, .tb-view, .topbar > .btn:not(.primary):not(.account-btn), .topbar > .icon-btn[title^="Help"] { display: none; }
  .project-name { flex: 1 1 60px; width: auto; min-width: 40px; }
  .topbar .tb-group { padding: 0; border: 0; }
  .topbar .btn.primary span, .account-label { display: none; }
  .topbar .btn.primary { width: 38px; padding: 0; }
  .account-btn { padding: 0 6px; }
  .tier-chip { padding: 0 8px; }
  .tier-chip.member span { display: none; }
  .more-btn { display: inline-grid; }
  .center { grid-column: 1; grid-row: 2; }
  .mobile-nav { grid-column: 1; grid-row: 3; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 40; }
  .mnav-btn { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 11px; cursor: pointer; }
  .mnav-btn.on { color: var(--text); background: var(--accent-soft); }
  .mnav-btn.on svg { color: var(--accent-hi); }
  .mnav-btn.hint::after { content: ""; position: absolute; top: 5px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
  /* the three panels become sheets above the bottom bar */
  .left, .right, .bottom { position: absolute; left: 0; right: 0; bottom: var(--nav-h, 58px); z-index: 30; display: flex; flex-direction: column; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; background: var(--panel); box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.55); transform: translateY(110%); transition: transform 0.22s ease; visibility: hidden; grid-column: auto; grid-row: auto; }
  .left, .right { height: min(58%, 600px); }
  /* while a sheet is open you edit settings; the card above is a live preview without drag handles */
  body[data-sheet] .handle, body[data-sheet] .rot-stem { display: none; }
  .bottom { max-height: 46%; }
  body[data-sheet="left"] .left, body[data-sheet="right"] .right, body[data-sheet="bottom"] .bottom { transform: none; visibility: visible; }
  .sheet-close { display: grid; justify-items: center; gap: 2px; flex: none; width: 100%; padding: 6px 0 2px; border: 0; background: none; color: var(--faint); cursor: pointer; }
  .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: #3a4150; }
  .left { flex-direction: column; }
  .left > .side { flex: 1; min-height: 0; }
  .right .inspector, .right .layers-panel { flex: 1; min-height: 0; }
  body[data-right-view="inspector"] .right .layers-panel, body:not([data-right-view]) .right .layers-panel { display: none; }
  body[data-right-view="layers"] .right .inspector { display: none; }
  .inspector-body { max-height: none; }
  .layer-list { max-height: none; }
  .bottom .deck { flex: none; }
  .help { grid-template-columns: 1fr; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .backup-banner { top: 8px; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .left, .right, .bottom { transition: none; }
}

/* phones: roomier touch targets and full-width dialogs */
@media (pointer: coarse) {
  .handle { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 6px; }
  .icon-btn.sm { width: 30px; height: 30px; }
  .up-actions .icon-btn { width: 28px; height: 28px; }
}
@media (max-width: 560px) {
  .modal-wrap { padding: 8px; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 92dvh; border-radius: 16px; }
  .modal-body { padding: 14px 14px 18px; }
  .modal header { padding: 10px 8px 10px 14px; }
  .plan-price { font-size: 22px; }
  .acct, .plan-grid, .pack-grid, .upsell-list { grid-template-columns: minmax(0, 1fr); }
  .export .choices { flex-wrap: wrap; }
}
/* ---- walkthrough (js/ui/tour.js) ---- */
.tour { position: fixed; inset: 0; z-index: 150; }
.tour-block { position: absolute; inset: 0; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(5, 6, 9, 0.66), 0 0 0 2px var(--accent) inset, 0 0 24px rgba(125, 95, 255, 0.45); pointer-events: none; transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease; }
.tour.centred .tour-spot { box-shadow: 0 0 0 9999px rgba(5, 6, 9, 0.66); }
.tour-pop { position: fixed; width: min(340px, calc(100vw - 16px)); padding: 16px 16px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7); font-size: 13.5px; transition: left 0.25s ease, top 0.25s ease; }
.tour.centred .tour-pop { width: min(400px, calc(100vw - 16px)); }
.tour-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.tour-head h3 { font-size: 16px; }
.tour-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; color: #fff; background: linear-gradient(135deg, var(--accent), #2fb8d3); }
.tour-pop p { color: #c3c9d6; line-height: 1.55; }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.tour-count { color: var(--faint); font-size: 12px; white-space: nowrap; }
.tour-skip { font-size: 12px; }
.plan-price s.was, s.was { color: var(--faint); font-weight: 400; margin-right: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
