:root {
  --bg: #1b1b1e;
  --stage: #121214;
  --panel: #252528;
  --panel2: #2e2e33;
  --panel3: #37373d;
  --line: #3a3a41;
  --text: #e4e4e8;
  --dim: #9b9ba5;
  --accent: #4f8cff;
  --accent-2: #2f6fe8;
  --danger: #ff5a5a;
  --ui-scale: 1;
  color-scheme: dark;
  font-size: calc(12px * var(--ui-scale));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template:
    "bar bar bar" 32px
    "options options options" 38px
    "tools tabs dock" 30px
    "tools stage dock" 1fr
    "status status status" 24px / 46px 1fr 300px;
  background: var(--bg); color: var(--text);
  font: 1rem/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
body.busy, body.busy * { cursor: progress !important; }
body.dropping #stage::after { content: 'Drop to place or open'; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 10px; display: grid; place-items: center; color: var(--accent); font-size: 1.4rem; pointer-events: none; background: rgba(79, 140, 255, .06); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 5px; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); }
input[type=number], input[type=text], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; min-width: 0;
}
input[type=number]:focus, input[type=text]:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
kbd { font: inherit; color: var(--dim); }
.dim { color: var(--dim); }
.grow { flex: 1; }
.pad { padding: 10px 12px; }
svg.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- menu bar ---------- */
#bar { grid-area: bar; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 650; margin-right: 10px; }
.brand svg { width: 18px; height: 18px; color: var(--accent); }
#menus { display: flex; }
.menu { position: relative; }
.menu-title { padding: 5px 9px; }
.menu-title:hover, .menu.open .menu-title { background: var(--panel3); }
.menu-list { display: none; position: absolute; top: 100%; left: 0; z-index: 100; min-width: 250px; padding: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px #000a; }
.menu.open > .menu-list, .menu-sub:hover > .menu-list, .context-menu { display: block; }
.menu-list button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 10px; text-align: left; white-space: nowrap; }
.menu-list button span:not(.check) { flex: 1; }
.menu-list button:hover { background: var(--accent); color: #fff; }
.menu-list button:hover kbd { color: #fff; }
.menu-list .check { width: 12px; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu-sub { position: relative; }
.menu-list.sub { top: -5px; left: 100%; }
.menu-empty { padding: 6px 10px; color: var(--dim); }
.context-menu { position: fixed; top: 0; left: 0; }

/* ---------- options bar ---------- */
.options-bar { grid-area: options; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; }
.opt-tool { display: flex; align-items: center; gap: 6px; padding-right: 10px; border-right: 1px solid var(--line); font-weight: 600; }
.opt, .opt-group { display: flex; align-items: center; gap: 6px; }
.opt-group { gap: 10px; }
.opt .num { width: 58px; }
.opt.range input[type=range] { width: 90px; }
.opt .unit { color: var(--dim); margin-left: -3px; }
.opt.check { gap: 4px; }
.opt-sep { width: 1px; align-self: stretch; margin: 8px 0; background: var(--line); }
.opt-hint { color: var(--dim); }
.opt-title { font-weight: 600; }
.opt-btn { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border: 1px solid var(--line); background: var(--panel2); }
.opt-btn:hover { border-color: var(--accent); }
.opt-btn.on, .opt-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt .dash { width: 70px; }
.font { max-width: 170px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel2); }
.seg button { padding: 4px 8px; border-radius: 0; display: grid; place-items: center; min-height: 24px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--panel3); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.vertical { flex-direction: column; }
.seg.vertical button + button { border-left: 0; border-top: 1px solid var(--line); }
.brush-preview { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.brush-preview span { background: var(--text); border-radius: 50%; }
.grad-chip { width: 110px; height: 22px; border: 1px solid var(--line); }

/* ---------- toolbar ---------- */
#tools { grid-area: tools; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.tool { position: relative; width: 36px; height: 30px; display: grid; place-items: center; color: var(--dim); flex: none; }
.tool:hover { background: var(--panel3); color: var(--text); }
.tool.on { background: var(--accent); color: #fff; }
.tool.has-flyout::after { content: ''; position: absolute; right: 3px; bottom: 3px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .7; }
.sep { width: 26px; border-top: 1px solid var(--line); margin: 4px 0; flex: none; }
.flyout { position: fixed; z-index: 120; min-width: 210px; padding: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px #000a; }
.flyout button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; }
.flyout button span { flex: 1; text-align: left; }
.flyout button:hover, .flyout button.on { background: var(--accent); color: #fff; }
.colors, .paints { position: relative; width: 38px; height: 44px; flex: none; margin-top: 4px; }
.color-chip { position: absolute; width: 22px; height: 22px; border: 2px solid var(--text); border-radius: 3px; box-shadow: 0 0 0 1px #000; }
.color-chip.fg { left: 2px; top: 2px; z-index: 1; }
.color-chip.bg { left: 13px; top: 13px; }
.colors .mini, .paints .mini { position: absolute; width: 14px; height: 14px; display: grid; place-items: center; color: var(--dim); }
.colors .mini:nth-of-type(3) { right: -2px; top: 0; }
.colors .mini:nth-of-type(4) { left: 0; bottom: 0; }
.paint-box { position: absolute; width: 22px; height: 22px; border-radius: 3px; }
.paint-box.fill { left: 2px; top: 2px; border: 1px solid #000; box-shadow: 0 0 0 1px var(--text); }
.paint-box.stroke { left: 13px; top: 13px; border: 6px solid; background: transparent; box-shadow: 0 0 0 1px var(--text), inset 0 0 0 1px var(--text); }
.paint-box.front { z-index: 2; }
.paints .mini { right: -2px; top: 0; }
.none-slash { position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1px), var(--danger) calc(50% - 1px), var(--danger) calc(50% + 1px), transparent calc(50% + 1px)); }

/* ---------- tabs ---------- */
.tabs { grid-area: tabs; display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { display: flex; align-items: center; gap: 4px; padding: 0 6px 0 12px; border-right: 1px solid var(--line); cursor: default; max-width: 260px; white-space: nowrap; color: var(--dim); }
.tab .tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab .close { width: 18px; height: 18px; display: grid; place-items: center; opacity: .6; }
.tab .close:hover { opacity: 1; background: var(--panel3); }
.tab-new { padding: 0 10px; color: var(--dim); display: grid; place-items: center; }
.tab-new:hover { color: var(--text); }

/* ---------- stage ---------- */
#stage { grid-area: stage; position: relative; overflow: hidden; background: var(--stage);
  display: grid; grid-template: "corner rh" 18px "rv view" 1fr / 18px 1fr; }
#stage.no-rulers { grid-template: "view" 1fr / 1fr; }
#stage.no-rulers .ruler { display: none; }
.ruler { width: 100%; height: 100%; display: block; }
.ruler.corner { grid-area: corner; background: var(--panel); }
.ruler.h { grid-area: rh; cursor: row-resize; }
.ruler.v { grid-area: rv; cursor: col-resize; }
#view { grid-area: view; width: 100%; height: 100%; display: block; touch-action: none; }
#stage.no-rulers #view { grid-area: view; }
#textedit { position: absolute; left: 0; top: 0; z-index: 5; margin: 0; padding: 0; border: 0; outline: 1px dashed var(--accent); background: transparent; color: transparent; caret-color: var(--accent); resize: none; overflow: hidden; white-space: pre-wrap; }
#textedit::selection { background: rgba(79, 140, 255, .35); }

/* ---------- welcome ---------- */
.welcome { position: absolute; inset: 0; display: grid; place-items: center; background: var(--stage); z-index: 10; overflow: auto; padding: 24px; }
.welcome-card { width: min(640px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px #0008; }
.welcome-head { display: flex; align-items: center; gap: 14px; }
.welcome-head h1 { margin: 0; font-size: 1.8rem; }
.welcome-head p { margin: 2px 0 0; }
.logo { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #4f8cff, #8b5cf6); color: #fff; }
.welcome-actions { display: flex; gap: 10px; margin: 22px 0 10px; }
.welcome h3 { margin: 18px 0 8px; font-size: .95rem; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
button.big { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; font-size: 1.05rem; }
button.big:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-2); }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); text-align: left; }
.preset:hover { border-color: var(--accent); }
.preset-shape { width: 26px; max-height: 32px; background: var(--panel3); border: 1px solid var(--dim); border-radius: 2px; flex: none; }
.recent-list { display: grid; gap: 2px; }
.recent-list button { display: flex; gap: 8px; align-items: center; padding: 6px 8px; text-align: left; }
.recent-list button:hover { background: var(--panel3); }

/* ---------- dock ---------- */
#dock { grid-area: dock; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); overflow: hidden; min-height: 0; }
body.no-doc #dock, body.no-doc #options { opacity: .6; }
.dock-group { display: flex; flex-direction: column; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 0; flex: 0 1 auto; max-height: 34%; }
.dock-group.grow { flex: 1 1 auto; max-height: none; min-height: 220px; }
.dock-group.collapsed { flex: none; }
.dock-group.collapsed .dock-body { display: none; }
.dock-tabs { display: flex; align-items: stretch; background: var(--panel2); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: none; }
.dock-tabs::-webkit-scrollbar { display: none; }
.dock-tabs button { padding: 6px 8px; color: var(--dim); border-radius: 0; white-space: nowrap; flex: none; }
.dock-tabs .dock-collapse { position: sticky; right: 0; background: var(--panel2); padding: 0 6px; }
.dock-tabs button.on { color: var(--text); background: var(--panel); box-shadow: inset 0 -2px 0 var(--accent); }
.dock-collapse { display: grid; place-items: center; }
.dock-body { overflow-y: auto; min-height: 0; flex: 1; }
.panel-sub { padding: 6px 12px 0; color: var(--dim); }
.panel-actions { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.panel-actions button, .btn-row button { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--line); background: var(--panel2); }
.panel-actions button:hover, .btn-row button:hover { border-color: var(--accent); }
.btn-row { display: flex; gap: 4px; }
.btn-row.wrap { flex-wrap: wrap; }
.icon-btn { display: grid; place-items: center; width: 26px; height: 24px; color: var(--dim); }
.icon-btn:hover { color: var(--text); background: var(--panel3); }
.icon-btn.on { color: var(--accent); }

.color-panel { padding: 10px; display: grid; gap: 8px; }
.color-panel .chips { position: relative; height: 34px; }
.color-chip.big { width: 26px; height: 26px; }
.color-panel .chips .mini { position: absolute; left: 48px; top: 8px; color: var(--dim); }
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(20px, 1fr)); gap: 3px; padding: 10px; }
.swatch { width: 100%; aspect-ratio: 1; min-width: 18px; border: 1px solid #0006; border-radius: 3px; box-shadow: inset 0 0 0 1px #fff2; }
.swatch.big { width: 42px; height: 22px; aspect-ratio: auto; }
.swatch.none { background: linear-gradient(to top right, #fff 45%, var(--danger) 45%, var(--danger) 55%, #fff 55%) !important; }

.prop-section { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.prop-section h4 { margin: 0; font-size: .85rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.prop { display: flex; align-items: center; gap: 6px; min-width: 0; }
.prop .lbl { color: var(--dim); min-width: 42px; }
.prop .num { width: 100%; min-width: 0; }
.prop select, .prop input[type=text] { width: 100%; }
.prop.wide { display: grid; grid-template-columns: 42px 1fr; }
.prop textarea { width: 100%; resize: vertical; }
.prop .unit { color: var(--dim); }
.prop .val { color: var(--text); }
.prop.check { gap: 6px; }
.scrub { cursor: ew-resize; }

.layer-controls { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.layer-controls select { flex: 1; }
.layer-controls .prop .num { width: 52px; }
.layer-controls .prop .lbl { min-width: 0; }
.layer-list { overflow-y: auto; }
.layer-row { display: flex; align-items: center; gap: 4px; min-height: 40px; padding-right: 8px; border-bottom: 1px solid #0003; position: relative; }
.layer-row.object { min-height: 26px; }
.layer-row:hover { background: var(--panel2); }
.layer-row.on { background: #33415c; }
.layer-row.hidden-layer .name, .layer-row.hidden-layer .thumb { opacity: .45; }
.layer-row[data-drop=above]::before, .layer-row[data-drop=below]::after { content: ''; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); }
.layer-row[data-drop=above]::before { top: -1px; }
.layer-row[data-drop=below]::after { bottom: -1px; }
.layer-row[data-drop=into] { box-shadow: inset 0 0 0 2px var(--accent); }
.layer-row .eye { width: 22px; height: 22px; display: grid; place-items: center; color: var(--dim); flex: none; }
.layer-row .eye:hover { color: var(--text); }
.layer-row .chev { width: 14px; height: 18px; display: grid; place-items: center; color: var(--dim); flex: none; }
.thumb { width: 40px; height: 30px; flex: none; border: 1px solid var(--line); background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 8px 8px; border-radius: 2px; }
.thumb.mask { background: #000; }
.thumb.active-part { box-shadow: 0 0 0 2px var(--text); }
.thumb.disabled { opacity: .4; }
.layer-row .kind { width: 40px; height: 30px; display: grid; place-items: center; color: var(--dim); flex: none; }
.layer-row .kind.small { width: auto; height: auto; }
.layer-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .rename { flex: 1; }
.layer-row .fx { font-style: italic; font-weight: 700; color: var(--dim); padding: 0 4px; }
.layer-row .lock, .layer-row .lock-btn { color: var(--dim); display: grid; place-items: center; }
.layer-row.object .lock-btn { opacity: 0; }
.layer-row.object:hover .lock-btn { opacity: 1; }
.layer-row .clip-arrow { color: var(--dim); display: grid; }
.obj-swatch { width: 14px; height: 14px; border-radius: 3px; border: 2px solid transparent; flex: none; box-shadow: 0 0 0 1px var(--line); }
.layer-footer { display: flex; justify-content: flex-end; gap: 2px; padding: 4px 8px; border-top: 1px solid var(--line); background: var(--panel); position: sticky; bottom: 0; }
.dock-group.grow .dock-body[data-panel=layers] { display: flex; flex-direction: column; }
.dock-group.grow .dock-body[data-panel=layers] .layer-list { flex: 1; }

.history-list { display: grid; }
.history-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; text-align: left; border-radius: 0; }
.history-row:hover { background: var(--panel2); }
.history-row.on { background: #33415c; }
.history-row.future { opacity: .45; }

.info-grid { display: grid; grid-template-columns: 30px 1fr 30px 1fr; gap: 4px 8px; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.info-swatch { margin: 0 12px 12px; height: 20px; border-radius: 4px; border: 1px solid var(--line); }
.navigator { display: block; margin: 10px auto 6px; background: var(--stage); border-radius: 4px; cursor: pointer; }
.nav-zoom { display: flex; align-items: center; gap: 6px; padding: 0 12px 10px; color: var(--dim); }
.nav-zoom input { flex: 1; }

/* ---------- status ---------- */
#status { grid-area: status; display: flex; align-items: center; gap: 16px; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--line); color: var(--dim); white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.zoom-field { display: flex; align-items: center; gap: 2px; }
.zoom-field input { width: 56px; padding: 0 4px; height: 18px; }

/* ---------- popovers and pickers ---------- */
.popover { position: fixed; z-index: 200; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; box-shadow: 0 16px 40px #000b; }
.pk { display: grid; gap: 8px; width: 240px; }
.pk canvas { width: 220px; border-radius: 4px; cursor: crosshair; display: block; }
.pk-sv { height: 160px; }
.pk-hue, .pk-alpha { height: 12px; }
.pk-row { display: flex; align-items: center; gap: 6px; }
.pk-preview { display: flex; width: 44px; height: 22px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); flex: none; }
.pk-preview span { flex: 1; }
.pk-hex { flex: 1; width: 90px; font-family: ui-monospace, monospace; }
.pk-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 6px; }
.pk-fields label { display: flex; align-items: center; gap: 4px; color: var(--dim); }
.pk-fields input { width: 100%; padding: 2px 4px; }
.pk-swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.pk-title { font-weight: 600; margin-bottom: 8px; }
.pk-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.pk-actions button, .dlg-actions button, .ge-row button { padding: 5px 12px; border: 1px solid var(--line); background: var(--panel3); }
.pk-actions button.primary, .dlg-actions button.primary { background: var(--accent); border-color: var(--accent); }
.pp { width: 260px; }
.pp .seg { margin-bottom: 8px; width: 100%; }
.pp .seg button { flex: 1; }
.ge { display: grid; gap: 8px; }
.ge-wrap { position: relative; padding-bottom: 16px; }
.ge-bar { width: 100%; height: 22px; border-radius: 4px; display: block; }
.ge-handles { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; cursor: copy; }
.ge-stop { position: absolute; bottom: 0; width: 12px; height: 14px; margin-left: -6px; border: 2px solid var(--text); border-radius: 2px 2px 6px 6px; cursor: grab; }
.ge-stop.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ge-row label { display: flex; align-items: center; gap: 4px; color: var(--dim); }
.ge-row input[type=number] { width: 52px; }
.ge-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.ge-preset { width: 26px; height: 18px; border: 1px solid var(--line); border-radius: 3px; }

/* ---------- dialogs ---------- */
dialog.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 18px; max-width: calc(100vw - 40px); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 24px 64px #000c; }
dialog.dlg::backdrop { background: #0002; }
.drag-handle { cursor: move; }
.dlg-body button:not(.swatch):not(.primary):not(.ge-stop):not(.ge-preset):not(.anchor-grid button), .ls-detail .row button:not(.swatch) { padding: 3px 10px; border: 1px solid var(--line); background: var(--panel3); }
dialog.dlg h2 { margin: 0 0 14px; font-size: 1.15rem; }
.dlg-body { display: grid; gap: 10px; }
.dlg-body.compact { gap: 6px; }
.dlg-body h3 { margin: 6px 0 0; font-size: .9rem; color: var(--dim); }
.dlg-body .row { display: grid; grid-template-columns: 100px 1fr auto auto; align-items: center; gap: 8px; }
.dlg-body .row.number { grid-template-columns: 100px 90px auto; }
.dlg-body .row.range input[type=number] { width: 64px; }
.dlg-body .row.check { display: flex; gap: 8px; }
.dlg-body .row.col { display: grid; grid-template-columns: 1fr; }
.dlg-body .lbl { color: var(--dim); }
.dlg-body .unit { color: var(--dim); }
.dlg-body .note { margin: 0; color: var(--dim); line-height: 1.5; user-select: text; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.anchor-grid { display: grid; grid-template-columns: repeat(3, 22px); gap: 3px; }
.anchor-grid button { width: 22px; height: 22px; border: 1px solid var(--line); background: var(--bg); }
.anchor-grid button.on { background: var(--accent); }
.histogram, .curves { width: 100%; background: #111; border-radius: 4px; display: block; }
.levels, .curves-field { display: grid; gap: 6px; }
.levels-slider { position: relative; height: 16px; margin: 0 6px; background: linear-gradient(to right, #000, #fff); border-radius: 3px; }
.lv-marker { position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; clip-path: polygon(50% 0, 100% 100%, 0 100%); cursor: ew-resize; border: 0; }
.lv-marker.black { background: #000; outline: 1px solid #fff; }
.lv-marker.gray { background: #888; }
.lv-marker.white { background: #fff; }
.levels-nums { display: grid; grid-template-columns: 70px 1fr 70px; gap: 6px; }
.levels-nums input:nth-child(2) { justify-self: center; width: 70px; }
.levels-nums input:last-child { justify-self: end; }
.levels .row, .curves-field .row { display: flex; gap: 8px; align-items: center; }
.curves { cursor: crosshair; aspect-ratio: 1; }
.grad-preview { height: 18px; border-radius: 4px; }
.shortcut-sheet { max-height: 60vh; overflow: auto; user-select: text; }
table.keys { width: 100%; border-collapse: collapse; }
table.keys td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
table.keys td:last-child { text-align: right; }

dialog.layer-style { width: 720px; }
.ls-body { display: grid; grid-template-columns: 190px 1fr; gap: 16px; min-height: 360px; }
.ls-list { display: grid; align-content: start; gap: 2px; border-right: 1px solid var(--line); padding-right: 10px; }
.ls-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: default; }
.ls-item:hover { background: var(--panel2); }
.ls-item.on { background: #33415c; }
.ls-detail { display: grid; align-content: start; gap: 10px; }
.ls-detail h3 { margin: 0; }
.ls-detail .row { display: grid; grid-template-columns: 100px 1fr auto auto; align-items: center; gap: 8px; }
.ls-detail .row.col { grid-template-columns: 1fr; }
.ls-detail .lbl { color: var(--dim); }

dialog.liquify { width: auto; }
.liquify-body { display: flex; gap: 16px; }
.liquify-stage { position: relative; overflow: hidden; background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 16px 16px; cursor: none; }
.liquify-canvas { display: block; }
.liquify-cursor { position: absolute; border: 1px solid #fff; outline: 1px solid #000; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.liquify-side { width: 230px; display: grid; align-content: start; gap: 12px; }
.liquify-side .row { display: grid; grid-template-columns: 1fr; gap: 4px; }

#toast { position: fixed; left: 50%; bottom: 40px; translate: -50% 0; z-index: 300; background: #000e; color: #fff; padding: 8px 14px; border-radius: 8px; max-width: 70vw; box-shadow: 0 8px 24px #0008; }

@media (max-width: 900px) {
  body { grid-template-columns: 46px 1fr 240px; }
}

/* ---------- develop, symbols ---------- */
dialog.develop { width: min(1400px, calc(100vw - 40px)); }
.dev-layout { display: grid; grid-template-columns: 1fr 320px; gap: 14px; height: min(720px, calc(100vh - 160px)); }
.dev-stage { display: grid; place-items: center; background: repeating-conic-gradient(#2a2a2e 0 25%, #222226 0 50%) 0 0 / 20px 20px; border-radius: 8px; overflow: hidden; }
.develop-canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.dev-panel { overflow-y: auto; padding-right: 4px; }
.dev-top { display: flex; gap: 6px; margin-bottom: 8px; }
.dev-top select { flex: 1; }
.dev-top button, .dlg-actions button:not(.primary) { padding: 5px 12px; border: 1px solid var(--line); background: var(--panel3); }
.dev-top button, .dlg-actions button { display: inline-flex; align-items: center; gap: 4px; }
.dev-section { border-bottom: 1px solid var(--line); }
.dev-section summary { padding: 8px 2px; font-weight: 600; cursor: pointer; }
.dev-body { display: grid; gap: 6px; padding-bottom: 10px; }
.dev-body h5 { margin: 6px 0 0; color: var(--dim); font-weight: 600; font-size: .85rem; }
.dev-body .row { display: grid; grid-template-columns: 84px 1fr 56px; align-items: center; gap: 8px; }
.dev-body .row input[type=number] { width: 56px; }
.dev-body .row .lbl { color: var(--dim); }
.symbol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; padding: 10px; }
.symbol { display: grid; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); text-align: center; }
.symbol:hover { border-color: var(--accent); }
.symbol-thumb { width: 100%; height: auto; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px; border-radius: 4px; }
.smart-head { min-height: 20px; }

.hist-source { width: 18px; height: 18px; display: grid; place-items: center; color: transparent; border: 1px solid var(--line); border-radius: 3px; flex: none; }
.hist-source.on { color: var(--text); }
.history-list.snapshots { border-bottom: 1px solid var(--line); }
div.history-row { cursor: default; }

.action-set summary { display: flex; align-items: center; gap: 6px; padding: 6px 10px; cursor: default; list-style: none; }
.action-set summary::-webkit-details-marker { display: none; }
.action-set summary:hover { background: var(--panel2); }
.action-steps { padding: 0 10px 6px 28px; display: grid; gap: 2px; }
.action-step { display: flex; align-items: center; gap: 6px; }
.action-step.off span { opacity: .5; }
.icon-btn.rec { color: #d33; }
.icon-btn.rec.on { color: #fff; background: #d33; border-radius: 4px; }

.stack { display: grid; gap: 4px; }
.stack-row { display: flex; align-items: center; gap: 6px; }
.stack-row .num { width: 48px; }
.stack-row .swatch.big { width: 30px; }

.style-sample { width: 28px; text-align: center; font-size: 16px; }

.frames { display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
.frame { display: grid; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); position: relative; flex: none; }
.frame.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.frame-thumb { width: 96px; height: 64px; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px; border-radius: 3px; }
.frame-no { position: absolute; left: 7px; top: 6px; font-size: 10px; background: #000a; color: #fff; padding: 0 4px; border-radius: 3px; }
.frame select { font-size: 11px; padding: 1px 2px; }

.gs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; padding: 10px; }
.gs { display: grid; justify-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); font-size: 10px; }
.gs:hover { border-color: var(--accent); }
.gs-thumb { width: 48px; height: 48px; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 8px 8px; border-radius: 4px; }

.swatch.global { position: relative; }
.swatch.global::after { content: ''; position: absolute; right: 0; bottom: 0; border: 4px solid transparent; border-right-color: #fff; border-bottom-color: #fff; }
.swatch.spot::before { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #0008; }
.swatch.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch-group { padding: 6px 10px 0; font-size: 11px; color: var(--dim); }
.tint-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
.tint-row input { flex: 1; }

.pk-gamut { display: inline-flex; align-items: center; gap: 3px; padding: 1px 3px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel3); }
.pk-gamut-icon { display: inline-grid; place-items: center; width: 14px; height: 14px; background: #f5c400; color: #000; font-weight: 700; font-size: 10px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pk-gamut-chip { width: 14px; height: 14px; border: 1px solid #0006; }
.pk-fields.cmyk { grid-template-columns: repeat(4, 1fr); }
