/* Obrys — editor chrome. Layout: dark top bar, layers left, canvas centre, properties right, floating toolbar bottom. */
:root {
  --bg: #EDEDF0;
  --panel: #FFFFFF;
  --panel-2: #F4F4F6;
  --panel-3: #E9E9ED;
  --line: #E3E3E8;
  --fg: #1C1C22;
  --fg-2: #66667A;
  --fg-3: #9C9CAA;
  --acc: #0D99FF;
  --acc-2: #0A84DB;
  --acc-fg: #FFFFFF;
  --acc-soft: rgba(13, 153, 255, 0.12);
  --purple: #9747FF;
  --purple-soft: rgba(151, 71, 255, 0.12);
  --danger: #E5484D;
  --canvas: #F2F2F4;
  --topbar: #1E1E24;
  --topbar-2: #2B2B33;
  --topbar-fg: #F1F1F4;
  --topbar-fg-2: #A9A9B6;
  --ruler-bg: #FAFAFB;
  --ruler-fg: #8B8B99;
  --ruler-line: #E1E1E6;
  --label-fg: #6E6E7E;
  --checker: repeating-conic-gradient(#D9D9DE 0% 25%, #FFFFFF 0% 50%) 50% / 8px 8px;
  --shadow: 0 8px 28px rgba(20, 20, 35, 0.16), 0 0 0 1px rgba(20, 20, 35, 0.06);
  --shadow-sm: 0 2px 8px rgba(20, 20, 35, 0.10), 0 0 0 1px rgba(20, 20, 35, 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141417; --panel: #1F1F24; --panel-2: #29292F; --panel-3: #33333A; --line: #34343B;
    --fg: #ECECF1; --fg-2: #A6A6B4; --fg-3: #6F6F7C; --acc-soft: rgba(13, 153, 255, 0.2); --purple-soft: rgba(151, 71, 255, 0.22);
    --canvas: #19191C; --topbar: #111114; --topbar-2: #222228; --ruler-bg: #1B1B1F; --ruler-fg: #7A7A88; --ruler-line: #2E2E35; --label-fg: #9A9AA8;
    --checker: repeating-conic-gradient(#3A3A42 0% 25%, #26262C 0% 50%) 50% / 8px 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.07);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.07);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141417; --panel: #1F1F24; --panel-2: #29292F; --panel-3: #33333A; --line: #34343B;
  --fg: #ECECF1; --fg-2: #A6A6B4; --fg-3: #6F6F7C; --acc-soft: rgba(13, 153, 255, 0.2); --purple-soft: rgba(151, 71, 255, 0.22);
  --canvas: #19191C; --topbar: #111114; --topbar-2: #222228; --ruler-bg: #1B1B1F; --ruler-fg: #7A7A88; --ruler-line: #2E2E35; --label-fg: #9A9AA8;
  --checker: repeating-conic-gradient(#3A3A42 0% 25%, #26262C 0% 50%) 50% / 8px 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.07);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.07);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--fg); font: 12px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.ic { flex: none; display: block; }
.ic-sp { width: 14px; flex: none; }

#app {
  display: grid; height: 100%;
  grid-template-rows: 44px minmax(0, 1fr);
  grid-template-columns: 248px minmax(0, 1fr) 272px;
  grid-template-areas: "top top top" "left canvas right";
}

/* ---------- top bar ---------- */
#topbar {
  grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 8px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--topbar); color: var(--topbar-fg); min-width: 0;
}
.tb-l, .tb-r { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tb-l { flex: 1 1 0; }
.tb-r { flex: 1 1 0; justify-content: flex-end; }
.tb-c { flex: 0 1 auto; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; font-size: 12.5px; }
.tb-c .slash { color: var(--topbar-fg-2); }
#doc-name { font-weight: 600; cursor: text; padding: 4px 6px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
#doc-name:hover { background: var(--topbar-2); }
#page-name { color: var(--topbar-fg-2); overflow: hidden; text-overflow: ellipsis; max-width: 16vw; }
#save-state { color: var(--topbar-fg-2); font-size: 11px; opacity: 0; transition: opacity .3s; }
#save-state.on { opacity: 1; }
.logo { display: grid; place-items: center; width: 34px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--topbar-fg); }
.logo:hover { background: var(--topbar-2); }
.logo svg { width: 22px; height: 22px; }
.logo .logo-mark { width: 28px; height: 28px; display: block; }
#menubar { display: flex; gap: 0; min-width: 0; overflow: hidden; }
.mb-item { border: 0; background: transparent; color: var(--topbar-fg); padding: 6px 8px; border-radius: 5px; white-space: nowrap; font-size: 12.5px; }
.mb-item:hover, .mb-item.open { background: var(--topbar-2); }
#topbar .ib { color: var(--topbar-fg); }
#topbar .ib:hover { background: var(--topbar-2); }
.zoom-ctl { display: flex; align-items: center; gap: 2px; border: 0; background: transparent; color: var(--topbar-fg); padding: 6px 6px 6px 8px; border-radius: 5px; font-variant-numeric: tabular-nums; min-width: 66px; justify-content: flex-end; }
.zoom-ctl:hover { background: var(--topbar-2); }
/* language switch: same transparent chrome as the other top-bar buttons (the browser default gave it a white face) */
.lang-ctl { display: inline-flex; align-items: center; gap: 4px; height: 28px; border: 0; border-radius: var(--r); background: transparent; color: var(--topbar-fg); padding: 0 7px; font-size: 11px; font-weight: 600; letter-spacing: .03em; appearance: none; -webkit-appearance: none; }
.lang-ctl:hover { background: var(--topbar-2); }
.mob { display: none !important; }
input.rename.doc { background: var(--topbar-2); color: var(--topbar-fg); border: 1px solid var(--acc); border-radius: 4px; padding: 3px 6px; width: 220px; }

/* ---------- buttons ---------- */
.ib { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r); background: transparent; color: var(--fg-2); flex: none; }
.ib:hover { background: var(--panel-2); color: var(--fg); }
.ib.on { background: var(--acc-soft); color: var(--acc); }
.ib:disabled { opacity: .35; cursor: default; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 5px 10px; border-radius: var(--r); white-space: nowrap; min-height: 28px; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-weight: 600; }
.btn.primary:hover { background: var(--acc-2); }
.btn.wide { width: 100%; margin-top: 6px; }
.link { border: 0; background: none; color: var(--acc); padding: 0; text-decoration: underline; }

/* ---------- panels ---------- */
#left, #right { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
#left { grid-area: left; border-right: 1px solid var(--line); }
#right { grid-area: right; border-left: 1px solid var(--line); }
.ptabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex: none; }
.ptabs button { border: 0; background: transparent; padding: 5px 9px; border-radius: 5px; font-weight: 600; color: var(--fg-3); }
.ptabs button.on { color: var(--fg); background: var(--panel-2); }
.ptabs button:hover { color: var(--fg); }
#lp-layers, #lp-assets { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#lp-assets { overflow: auto; padding-bottom: 12px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 12px; font-weight: 600; color: var(--fg); }
.pages { border-bottom: 1px solid var(--line); flex: none; max-height: 30%; overflow: auto; padding-bottom: 6px; }
.pg-row { display: flex; align-items: center; gap: 8px; padding: 5px 12px; color: var(--fg-2); cursor: default; border-radius: 0; }
.pg-row:hover { background: var(--panel-2); }
.pg-row.on { color: var(--fg); font-weight: 600; }
.pg-row .pg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-chk { color: var(--acc); }
#layers-list { flex: 1; overflow: auto; padding: 4px 0 80px; min-height: 0; }
.ly { display: flex; align-items: center; gap: 4px; height: 30px; padding-left: calc(6px + var(--d) * 14px); padding-right: 6px; color: var(--fg); cursor: default; user-select: none; position: relative; }
.ly:hover { background: var(--panel-2); }
.ly.psel { background: var(--acc-soft); }
.ly.sel { background: var(--acc-soft); box-shadow: inset 2px 0 0 var(--acc); }
.ly.comp .ly-ic, .ly.comp .ly-name { color: var(--purple); }
.ly.hid .ly-name, .ly.hid .ly-ic { opacity: .45; }
.ly-car { width: 16px; height: 16px; display: grid; place-items: center; border: 0; background: none; color: var(--fg-3); padding: 0; flex: none; }
.ly-car.none { visibility: hidden; }
.ly-ic { color: var(--fg-2); display: grid; place-items: center; flex: none; }
.ly-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ly-b { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: none; color: var(--fg-3); border-radius: 4px; opacity: 0; flex: none; }
.ly:hover .ly-b, .ly-b.on { opacity: 1; }
.ly-b:hover { color: var(--fg); background: var(--panel-3); }
.ly.drop-b::before, .ly.drop-a::after { content: ''; position: absolute; left: calc(22px + var(--d) * 14px); right: 4px; height: 2px; background: var(--acc); }
.ly.drop-b::before { top: -1px; }
.ly.drop-a::after { bottom: -1px; }
.ly.drop-i { box-shadow: inset 0 0 0 2px var(--acc); }
.ly-empty, .as-empty, .code-empty { color: var(--fg-3); padding: 14px; line-height: 1.6; }
input.rename { flex: 1; min-width: 0; border: 1px solid var(--acc); border-radius: 4px; padding: 2px 5px; background: var(--panel); outline: none; }
.as-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 12px; }
.as-comp { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px; text-align: left; color: var(--purple); min-width: 0; }
.as-comp:hover { border-color: var(--purple); }
.as-comp > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-th { height: 64px; display: grid; place-items: center; background: var(--checker); border-radius: 4px; overflow: hidden; }
.as-th img { max-width: 100%; max-height: 100%; }
.as-sw { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px; }
#as-fonts { padding: 2px 12px; }
.as-font { padding: 4px 0; font-size: 15px; }
#lp-assets section { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
#lp-assets section > .btn { margin: 4px 12px 0; width: calc(100% - 24px); }

/* swatches */
.sw { width: 22px; height: 22px; border-radius: 5px; border: 0; padding: 0; background: linear-gradient(var(--c), var(--c)), var(--checker); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sw.big { width: 28px; height: 28px; }
.sw.add { display: grid; place-items: center; background: var(--panel-2); color: var(--fg-2); }
.sw:hover { transform: scale(1.08); }

/* ---------- properties ---------- */
#props, #code { overflow: auto; flex: 1; padding-bottom: 40px; }
.ps { border-bottom: 1px solid var(--line); padding: 8px 12px 10px; }
.ps-h { display: flex; align-items: center; justify-content: space-between; min-height: 26px; font-weight: 600; margin-bottom: 4px; }
.ps-x { display: flex; gap: 2px; align-items: center; }
.ps-type { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; font-weight: 600; color: var(--fg-2); }
.align-row { display: flex; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.align-row .ib { width: 28px; }
.row { display: flex; align-items: center; gap: 6px; margin: 4px 0; min-width: 0; }
.row > .sel, .row > .fld { flex: 1 1 0; min-width: 0; }
.row .sp, .sp { flex: 1; }
.row.note { color: var(--fg-2); flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 0; align-items: center; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 6px; margin: 4px 0; }
.btns { display: flex; justify-content: flex-end; gap: 2px; }
.fld { display: flex; align-items: center; height: 28px; border: 1px solid transparent; background: var(--panel-2); border-radius: var(--r); padding: 0 6px 0 0; min-width: 0; }
.fld:hover { border-color: var(--line); }
.fld:focus-within { border-color: var(--acc); background: var(--panel); }
.fld .fl { display: flex; align-items: center; justify-content: center; min-width: 24px; padding: 0 4px 0 7px; color: var(--fg-3); white-space: nowrap; user-select: none; font-size: 11px; }
.fld .fl.scrub { cursor: ew-resize; }
.fld input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none; padding: 0; height: 100%; font-variant-numeric: tabular-nums; }
.fld em { font-style: normal; color: var(--fg-3); padding-left: 2px; }
.fld.op { flex: 0 0 76px; padding-left: 7px; }
.fld.op .ic { color: var(--fg-3); margin-right: 4px; }
.sel { height: 28px; border: 1px solid transparent; background: var(--panel-2); border-radius: var(--r); padding: 0 4px; min-width: 0; outline: none; }
.sel:hover { border-color: var(--line); }
.sel:focus { border-color: var(--acc); }
.sel.mini { height: 24px; max-width: 120px; font-size: 11px; }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { accent-color: var(--acc); margin: 0; }
.pr { display: flex; align-items: center; gap: 4px; margin: 4px 0; }
.pr.off { opacity: .5; }
.swb { width: 28px; height: 28px; border: 0; background: none; padding: 3px; border-radius: var(--r); flex: none; }
.swb:hover { background: var(--panel-2); }
.chk-bg, .swb .chk { display: block; width: 22px; height: 22px; border-radius: 4px; background: var(--checker); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swb .chk span { display: block; width: 100%; height: 100%; }
.hexin { flex: 1; min-width: 0; height: 28px; border: 1px solid transparent; background: var(--panel-2); border-radius: var(--r); padding: 0 8px; text-transform: uppercase; font-variant-numeric: tabular-nums; outline: none; }
.hexin:focus { border-color: var(--acc); background: var(--panel); }
.hexin::placeholder { text-transform: none; color: var(--fg-3); }
.plabel { flex: 1; min-width: 0; height: 28px; text-align: left; border: 1px solid transparent; background: var(--panel-2); border-radius: var(--r); padding: 0 8px; }
.plabel:hover { border-color: var(--line); }
.fontin { flex: 1; min-width: 0; height: 28px; border: 1px solid transparent; background: var(--panel-2); border-radius: var(--r); padding: 0 8px; outline: none; }
.fontin:focus { border-color: var(--acc); background: var(--panel); }
.fx { border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 4px; }
.fx:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.fx.off { opacity: .5; }
input[type="color"] { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: var(--r); padding: 2px; background: var(--panel); flex: none; }
.selcols { display: flex; flex-wrap: wrap; gap: 6px; }
.presets { display: flex; flex-direction: column; }
.preset { display: flex; justify-content: space-between; border: 0; background: none; text-align: left; padding: 6px 4px; border-radius: 4px; color: var(--fg); }
.preset:hover { background: var(--panel-2); }
.preset em { font-style: normal; color: var(--fg-3); font-variant-numeric: tabular-nums; }
pre.code { margin: 0; font: 11px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; background: var(--panel-2); border-radius: var(--r); padding: 8px; max-height: 360px; overflow: auto; user-select: text; }

/* ---------- canvas ---------- */
#canvas { grid-area: canvas; position: relative; overflow: hidden; background: var(--page-bg, var(--canvas)); touch-action: none; min-width: 0; outline: none; }
#stage, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage { user-select: none; }
#overlay { pointer-events: none; overflow: visible; }
#overlay [data-h] { pointer-events: all; }
#overlay .frame-label { font: 500 11px var(--font); user-select: none; cursor: default; }
#overlay .hrot { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M18.5 12a6.5 6.5 0 1 1-2-4.7' fill='none' stroke='white' stroke-width='4'/%3E%3Cpath d='M18.5 12a6.5 6.5 0 1 1-2-4.7' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M17 3.5v4.5h-4.5' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") 12 12, alias; }
#stage.outline #doc-root * { fill: none !important; stroke: var(--fg) !important; stroke-width: 1px !important; stroke-opacity: .85 !important; vector-effect: non-scaling-stroke; filter: none !important; opacity: 1 !important; mix-blend-mode: normal !important; }
#stage.outline #doc-root [stroke="transparent"] { stroke: transparent !important; }
.ruler { position: absolute; z-index: 2; }
#ruler-x { left: 20px; top: 0; right: 0; height: 20px; width: calc(100% - 20px); cursor: ns-resize; }
#ruler-y { left: 0; top: 20px; bottom: 0; width: 20px; height: calc(100% - 20px); cursor: ew-resize; }
#ruler-corner { left: 0; top: 0; width: 20px; height: 20px; background: var(--ruler-bg); border-right: 1px solid var(--ruler-line); border-bottom: 1px solid var(--ruler-line); }
#text-editor { position: absolute; left: 0; top: 0; z-index: 4; transform-origin: 0 0; background: transparent; border: 0; outline: none; padding: 0; margin: 0; resize: none; overflow: hidden; caret-color: var(--acc); box-shadow: none; }
#text-editor.floating { background: var(--panel); color: var(--fg) !important; border: 1px solid var(--acc); border-radius: 6px; padding: 6px 8px; font-size: 14px !important; line-height: 1.4 !important; letter-spacing: 0 !important; text-transform: none !important; text-decoration: none !important; box-shadow: var(--shadow-sm); }
#toolbar {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }
.tb-grp { display: flex; align-items: center; border-radius: 8px; flex: none; }
.tb-btn { width: 38px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: var(--fg); flex: none; }
.tb-btn:hover { background: var(--panel-2); }
.tb-grp.on { background: var(--acc); }
.tb-grp.on .tb-btn, .tb-grp.on .tb-more { color: var(--acc-fg); }
.tb-grp.on .tb-btn:hover, .tb-grp.on .tb-more:hover { background: var(--acc-2); }
.tb-more { width: 14px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; padding: 0; color: var(--fg-3); border-radius: 0 8px 8px 0; margin-left: -4px; flex: none; }
.tb-more:hover { color: var(--fg); background: var(--panel-2); }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; flex: none; }
#tool-options {
  position: absolute; left: 50%; top: 30px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow-sm);
  max-width: calc(100% - 48px); overflow-x: auto; white-space: nowrap; scrollbar-width: thin;
}
.to-name { font-weight: 600; }
.to-f { display: flex; align-items: center; gap: 6px; color: var(--fg-2); }
.to-f input[type="number"] { width: 64px; height: 26px; border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; background: var(--panel-2); }
.to-f select { height: 26px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); }
.to-f em { font-style: normal; color: var(--fg-3); }
.to-f input[type="color"] { width: 26px; height: 26px; }
.to-hint { color: var(--fg-3); }
#statusbar { position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 3; color: var(--fg-3); font-variant-numeric: tabular-nums; font-size: 11px; pointer-events: none; }

/* ---------- menus ---------- */
.menu { position: fixed; z-index: 1000; min-width: 220px; max-width: 360px; max-height: calc(100vh - 16px); overflow: auto; padding: 6px; background: var(--topbar); color: var(--topbar-fg); border-radius: 8px; box-shadow: var(--shadow); font-size: 12.5px; }
.mi { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; cursor: default; white-space: nowrap; }
.mi:hover { background: var(--acc); color: #fff; }
.mi.dis { opacity: .4; pointer-events: none; }
.mi-l { flex: 1; }
.mi-k { color: var(--topbar-fg-2); font-size: 11.5px; margin-left: 16px; }
.mi:hover .mi-k { color: rgba(255, 255, 255, .8); }
.mi-sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 5px 4px; }

/* ---------- dialogs ---------- */
.dlg-back, .pal-back { position: fixed; inset: 0; z-index: 900; background: rgba(10, 10, 20, .32); display: grid; place-items: center; padding: 16px; }
.dlg { width: min(400px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); }
.dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px 16px; font-weight: 700; font-size: 13.5px; }
.dlg-b { padding: 6px 16px 10px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.dlg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dlg-row > span:first-child { color: var(--fg-2); }
.dlg-in { display: flex; align-items: center; gap: 4px; }
.dlg-in input, .dlg-row select { width: 130px; height: 30px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 8px; background: var(--panel-2); outline: none; }
.dlg-in input:focus, .dlg-row select:focus { border-color: var(--acc); }
.dlg-in em { font-style: normal; color: var(--fg-3); width: 16px; }
.dlg-f { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-text { color: var(--fg-2); line-height: 1.6; }
.dlg-text code { font-family: var(--mono); background: var(--panel-2); padding: 1px 4px; border-radius: 3px; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px 20px; }
.dlg:has(.keys) { width: min(980px, 100%); }
.keys-g h4 { margin: 4px 0 6px; font-size: 12px; color: var(--fg-2); text-transform: uppercase; letter-spacing: .04em; }
.keys-r { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line); }
kbd { font: 11px var(--mono); color: var(--fg-2); white-space: nowrap; }
.pal { width: min(560px, 100%); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; align-self: start; margin-top: 12vh; }
.pal-in { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--fg-3); }
.pal-in input { flex: 1; border: 0; outline: none; background: transparent; font-size: 15px; color: var(--fg); }
.pal-list { max-height: 50vh; overflow: auto; padding: 6px; }
.pal-it { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 6px; cursor: default; }
.pal-it em { font-style: normal; color: var(--fg-3); margin-right: 8px; }
.pal-it.on { background: var(--acc); color: #fff; }
.pal-it.on em, .pal-it.on .mi-k { color: rgba(255, 255, 255, .8); }
.pal-it.dis { opacity: .45; }
.pal-empty { padding: 14px; color: var(--fg-3); }
#toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%) translateY(8px); z-index: 1100; background: var(--topbar); color: var(--topbar-fg); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: min(560px, calc(100vw - 32px)); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* ---------- color picker ---------- */
.picker { position: fixed; z-index: 950; width: 252px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px 10px; }
.pk-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pk-tabs { display: flex; gap: 2px; }
.pk-tabs button { width: 30px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--fg-2); }
.pk-tabs button.on { background: var(--panel-2); color: var(--fg); }
.sw-ic { width: 14px; height: 14px; border-radius: 3px; display: block; border: 1px solid var(--fg-2); }
.sw-ic.solid { background: var(--fg-2); }
.sw-ic.lin { background: linear-gradient(90deg, transparent, var(--fg-2)); }
.sw-ic.rad { background: radial-gradient(circle, var(--fg-2), transparent 75%); border-radius: 50%; }
.pk-sv { position: relative; height: 150px; border-radius: 6px; overflow: hidden; cursor: crosshair; touch-action: none; }
.pk-sv canvas { width: 100%; height: 100%; display: block; }
.pk-svh { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); pointer-events: none; }
.pk-sl { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; }
.pk-bars { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.pk-hue, .pk-alpha { position: relative; height: 12px; border-radius: 6px; cursor: pointer; touch-action: none; }
.pk-hue { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.pk-alpha { background: var(--checker); }
.pk-alpha-c { position: absolute; inset: 0; border-radius: 6px; }
.pk-hue i, .pk-alpha i { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); pointer-events: none; }
.pk-vals { display: flex; align-items: center; gap: 4px; }
.pk-vals select { height: 26px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); font-size: 11px; width: 58px; flex: none; }
.pk-fields { flex: 1; display: flex; gap: 3px; min-width: 0; }
.pk-fields input { flex: 1; min-width: 0; width: 100%; height: 26px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); padding: 0 4px; text-align: center; font-variant-numeric: tabular-nums; outline: none; }
.pk-fields input.hex { text-transform: uppercase; }
.pk-fields input:focus, .pk-op input:focus { border-color: var(--acc); }
.pk-op { display: flex; align-items: center; gap: 2px; flex: none; }
.pk-op input { width: 40px; height: 26px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); text-align: center; outline: none; }
.pk-op em { font-style: normal; color: var(--fg-3); }
.pk-sw { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.pk-swl { color: var(--fg-3); margin-bottom: 6px; }
.pk-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.pk-swatches .sw { width: 20px; height: 20px; }
.pk-grad { position: relative; height: 34px; margin-bottom: 4px; }
.pk-gbar { position: absolute; left: 7px; right: 7px; top: 4px; height: 14px; border-radius: 4px; cursor: copy; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.pk-gstops { position: absolute; left: 7px; right: 7px; top: 20px; height: 14px; }
.pk-stop { position: absolute; top: 0; width: 14px; height: 14px; margin-left: -7px; padding: 0; border: 2px solid #fff; border-radius: 3px; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); cursor: ew-resize; touch-action: none; }
.pk-stop.on { box-shadow: 0 0 0 2px var(--acc); }
.pk-gtools { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.pk-hint { color: var(--fg-3); font-size: 11px; margin-left: 4px; }
.pk-img { height: 120px; display: grid; place-items: center; background: var(--checker); border-radius: 6px; overflow: hidden; margin-bottom: 4px; }
.pk-img img { max-width: 100%; max-height: 100%; }
.pk-noimg { color: var(--fg-3); }
.pk-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--fg-2); }
.pk-row select, .pk-row input { height: 26px; width: 110px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); padding: 0 4px; }

/* ---------- present ---------- */
.present { position: fixed; inset: 0; z-index: 1200; background: #0B0B0E; display: flex; flex-direction: column; }
.pr-stage { flex: 1; display: grid; place-items: center; padding: 24px; min-height: 0; cursor: pointer; }
.pr-stage svg { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.pr-bar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); color: #ddd; }
.pr-bar button { border: 0; background: #23232A; color: #eee; width: 34px; height: 30px; border-radius: 6px; font-size: 18px; display: grid; place-items: center; }
.pr-bar button:hover { background: #33333C; }
.pr-n { min-width: 160px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- variants ---------- */
body.noui #app { grid-template-columns: 0 minmax(0, 1fr) 0; }
body.noui #left, body.noui #right { display: none; }
@media (max-width: 1100px) {
  #app { grid-template-columns: 220px minmax(0, 1fr) 248px; }
  .mb-item { padding: 6px 6px; }
}
@media (max-width: 900px) {
  #menubar { display: none; }
}
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "canvas"; }
  #left, #right { position: fixed; top: calc(44px + env(safe-area-inset-top, 0px)); bottom: 0; width: min(300px, 88vw); z-index: 30; box-shadow: var(--shadow); transition: transform .2s ease; }
  #left { left: 0; transform: translateX(-105%); }
  #right { right: 0; transform: translateX(105%); }
  body.show-left #left, body.show-right #right { transform: none; }
  .mob { display: inline-grid !important; }
  .tb-c { display: none; }
  .tb-l { flex: 0 0 auto; }
  .tb-r { flex: 1 1 auto; }
  #btn-export { padding: 5px 7px; }
  #btn-export .lbl { display: none; }
  #btn-present, #btn-theme, #btn-palette { display: none; }
  .zoom-ctl { min-width: 0; }
  #tool-options { top: 26px; max-width: calc(100% - 32px); }
  #statusbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
