/* Graphican Editor — Figma-style layout: layers left, canvas centre, properties right, tool dock bottom. */
@font-face { font-family:"iBrand"; src:url("/assets/fonts/ibrand.otf") format("opentype"); font-display:swap; }

:root {
  --bg:#ffffff;
  --bg2:#f5f5f5;
  --bg3:#ebebeb;
  --canvas:#f5f5f5;
  --text:#1e1e1e;
  --muted:#6b6b6b;
  --dim:#a0a0a0;
  --line:#e6e6e6;
  --line2:#d6d6d6;
  --acc:#6d56fa;        /* brand violet = selection / primary */
  --acc-soft:rgba(109,86,250,.12);
  --v1:#e7e3fd; --v2:#a497ff; --v3:#816dfb; --v4:#34229e;
  --shadow:0 2px 6px rgba(0,0,0,.08), 0 10px 30px -8px rgba(0,0,0,.18);
  --lw:240px;
  --rw:248px;
  --r:6px;
}
[data-theme="dark"] {
  --bg:#2c2c2c;
  --bg2:#383838;
  --bg3:#444444;
  --canvas:#1e1e1e;
  --text:#f2f2f2;
  --muted:#b3b3b3;
  --dim:#7a7a7a;
  --line:#3d3d3d;
  --line2:#4d4d4d;
  --acc-soft:rgba(129,109,251,.22);
  --shadow:0 2px 6px rgba(0,0,0,.35), 0 10px 30px -8px rgba(0,0,0,.6);
}

* { box-sizing:border-box; margin:0; padding:0; }
html, body { height:100%; overflow:hidden; background:var(--canvas); color:var(--text); font:400 11.5px/1.4 "Inter", system-ui, sans-serif; -webkit-font-smoothing:antialiased; }
button, input, select { font:inherit; color:inherit; }
button { background:none; border:0; cursor:pointer; }
button:disabled { opacity:.35; cursor:default; }
[hidden] { display:none !important; }
:focus-visible { outline:2px solid var(--acc); outline-offset:1px; }
svg.i { width:16px; height:16px; display:block; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; flex:none; }

.app { display:flex; height:100%; }

/* ---------- shared bits ---------- */
.ib { width:28px; height:28px; display:grid; place-items:center; border-radius:5px; flex:none; color:var(--text); }
.ib:hover:not(:disabled) { background:var(--bg2); }
.ib.on { background:var(--acc-soft); color:var(--acc); }
.btn-primary { height:30px; padding:0 12px; border-radius:6px; background:var(--acc); color:#fff; font-weight:600; }
.btn-primary:hover { filter:brightness(1.08); }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; height:28px; padding:0 10px; border-radius:5px; border:1px solid var(--line2); font-weight:500; white-space:nowrap; }
.btn:hover { background:var(--bg2); }
.btn.acc { border-color:transparent; background:var(--acc-soft); color:var(--acc); font-weight:600; }
.btn.full { width:100%; }
.grow { flex:1; }
.pw { position:relative; }
.menu { position:absolute; top:calc(100% + 6px); left:0; z-index:60; min-width:200px; padding:6px; border-radius:8px; background:#1e1e1e; color:#f2f2f2; box-shadow:var(--shadow); }
.menu.r { left:auto; right:0; }
.menu.up { top:auto; bottom:calc(100% + 8px); }
.menu > button, .menu .mi { display:flex; align-items:center; justify-content:space-between; gap:14px; width:100%; padding:7px 10px; border-radius:4px; text-align:left; color:#f2f2f2; }
.menu > button:hover, .menu .mi:hover { background:var(--acc); }
.menu i { font-style:normal; color:#a0a0a0; font-size:11px; }
.menu > button:hover i { color:#fff; }
.menu .mt { padding:6px 10px 4px; font-size:10.5px; letter-spacing:.04em; text-transform:uppercase; color:#8a8a8a; }
.menu .sep { height:1px; background:#3a3a3a; margin:5px 4px; }
.menu .row2 { display:flex; gap:6px; padding:4px 6px 6px; }
.menu select { flex:1; height:28px; border-radius:4px; background:#2c2c2c; border:1px solid #444; color:#f2f2f2; padding:0 6px; }

/* ---------- left panel ---------- */
.lp { width:var(--lw); flex:none; display:flex; flex-direction:column; background:var(--bg); border-right:1px solid var(--line); min-height:0; z-index:10; }
.lp-head { display:flex; align-items:center; justify-content:space-between; padding:10px 10px 4px; }
.logo { display:flex; align-items:center; gap:8px; padding:6px 8px 6px 6px; border-radius:6px; color:var(--text); text-decoration:none; font:400 16px/1 "iBrand", "Inter", sans-serif; }
.logo:hover { background:var(--bg2); }
.orb { width:13px; height:13px; border-radius:50%; background:radial-gradient(circle at 35% 30%, #fff, #a497ff 40%, #34229e 85%); box-shadow:0 0 8px #816dfb; }
.lp-file { padding:2px 10px 10px; border-bottom:1px solid var(--line); }
.file-name { width:100%; height:28px; padding:0 6px; border-radius:5px; border:1px solid transparent; background:transparent; font-weight:600; font-size:13px; }
.file-name:hover { border-color:var(--line2); }
.file-name:focus { outline:none; border-color:var(--acc); background:var(--bg); }
.saved { display:block; padding:0 7px; font-size:11px; color:var(--dim); }
.lp-tabs { display:flex; gap:2px; padding:8px 8px 6px; border-bottom:1px solid var(--line); }
.lp-tabs button { flex:1; height:28px; border-radius:5px; font-weight:600; color:var(--muted); }
.lp-tabs button:hover { color:var(--text); background:var(--bg2); }
.lp-tabs button.on { color:var(--text); background:var(--bg2); }
.lp-body { flex:1; overflow-y:auto; padding:8px 8px 40px; }
.sec-t { display:flex; align-items:center; justify-content:space-between; margin:14px 4px 8px; font-weight:600; font-size:11.5px; }
.sec-t:first-child { margin-top:4px; }
.sec-t span { font-weight:400; color:var(--dim); }
.note { font-size:11px; line-height:1.5; color:var(--muted); margin:6px 4px; }

/* layers tree */
.ly { display:flex; align-items:center; gap:6px; height:30px; padding:0 4px 0 calc(6px + var(--d, 0) * 14px); border-radius:5px; cursor:default; user-select:none; }
.ly:hover { background:var(--bg2); }
.ly.on { background:var(--acc-soft); }
.ly.frame { font-weight:600; }
.ly.drag { opacity:.4; }
.ly.over { box-shadow:inset 0 2px 0 var(--acc); }
.ly .li { width:16px; color:var(--muted); display:grid; place-items:center; }
.ly .ln { flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ly .ln input { width:100%; height:22px; border:1px solid var(--acc); border-radius:3px; padding:0 4px; background:var(--bg); }
.ly .la { display:flex; opacity:0; }
.ly:hover .la, .ly .la .on { opacity:1; }
.ly .la .ib { width:22px; height:22px; color:var(--muted); }
.ly .la .ib svg.i { width:13px; height:13px; }
.ly.hid .ln, .ly.hid .li { opacity:.4; }
.ly-empty { padding:16px 8px; color:var(--muted); line-height:1.5; }

/* add tab */
.tx-p { display:block; width:100%; text-align:left; padding:9px 10px; margin-bottom:6px; border-radius:6px; background:var(--bg2); border:1px solid transparent; line-height:1.15; }
.tx-p:hover { border-color:var(--acc); }
.tx-p.h { font-size:19px; font-weight:700; } .tx-p.s { font-size:14px; font-weight:600; } .tx-p.b { font-size:11.5px; }
.pair { display:block; width:100%; text-align:left; padding:10px; margin-bottom:6px; border-radius:6px; background:var(--bg2); border:1px solid transparent; }
.pair:hover { border-color:var(--acc); }
.pair b { display:block; font-size:16px; line-height:1.15; margin-bottom:3px; }
.pair span { display:block; font-size:11px; color:var(--muted); }
.grid3 { display:grid; grid-template-columns:repeat(3, 1fr); gap:6px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.tile { aspect-ratio:1; display:grid; place-items:center; border-radius:6px; background:var(--bg2); border:1px solid transparent; }
.tile:hover { border-color:var(--acc); }
.tile svg { width:44%; height:44%; fill:var(--v3); }
.thumb { aspect-ratio:1; border-radius:6px; background:var(--bg2) center/cover no-repeat; border:1px solid var(--line); }
.thumb:hover { border-color:var(--acc); }
.sw-row { display:flex; flex-wrap:wrap; gap:5px; }
.sw { width:22px; height:22px; border-radius:4px; border:1px solid rgba(0,0,0,.12); flex:none; }
.sw:hover { transform:scale(1.1); }
.pal { margin-bottom:8px; }
.pal-n { font-size:10.5px; color:var(--muted); margin:0 0 4px 2px; }
.pal .sw-row { gap:3px; }
.pal .sw { flex:1; height:20px; width:auto; border-radius:3px; }

/* templates & sizes */
.tpl { display:flex; flex-direction:column; align-items:flex-start; gap:6px; padding:8px; border-radius:6px; background:var(--bg2); border:1px solid transparent; text-align:left; }
.tpl:hover { border-color:var(--acc); }
.tpl-prev { position:relative; display:block; border-radius:3px; overflow:hidden; box-shadow:0 2px 8px -3px rgba(0,0,0,.4); }
.tpl-prev i { position:absolute; left:14%; right:14%; height:10%; border-radius:2px; }
.tpl-prev i:first-child { top:30%; height:16%; }
.tpl-prev i:last-child { top:56%; }
.tpl b { font-size:11px; font-weight:600; line-height:1.25; }
.tpl span:not(.tpl-prev) { font-size:10.5px; color:var(--muted); }
.size-row { display:flex; align-items:center; gap:10px; width:100%; padding:7px 8px; border-radius:5px; text-align:left; }
.size-row:hover { background:var(--bg2); }
.size-row .sz-shape { border:1.5px solid var(--muted); border-radius:2px; flex:none; }
.size-row b { flex:1; font-weight:500; }
.size-row span { color:var(--dim); font-size:11px; }

/* ---------- stage ---------- */
.stage { position:relative; flex:1; min-width:0; background:var(--canvas); overflow:hidden; }
.stage .canvas-container { position:absolute !important; inset:0; }
.hint { position:absolute; left:50%; top:16px; transform:translateX(-50%); z-index:5; padding:8px 14px; border-radius:8px; background:var(--bg); box-shadow:var(--shadow); color:var(--muted); font-size:12px; white-space:nowrap; pointer-events:none; }
.hint b { color:var(--text); }
.dropzone { position:absolute; inset:12px; z-index:40; display:grid; place-items:center; border:2px dashed var(--acc); border-radius:12px; background:var(--acc-soft); pointer-events:none; }
.dropzone span { padding:10px 16px; border-radius:8px; background:var(--bg); font-weight:600; box-shadow:var(--shadow); }

/* bottom tool dock + contextual bar (Figma UI3) */
.dock, .ctxbar { position:absolute; left:50%; transform:translateX(-50%); z-index:20; display:flex; align-items:center; gap:2px; padding:5px; border-radius:12px; background:var(--bg); box-shadow:var(--shadow); border:1px solid var(--line); }
.dock { bottom:16px; }
.ctxbar { bottom:74px; max-width:calc(100% - 24px); overflow-x:auto; scrollbar-width:none; }
.ctxbar::-webkit-scrollbar { display:none; }
.tool { position:relative; height:36px; min-width:36px; padding:0 8px; display:inline-flex; align-items:center; justify-content:center; gap:6px; border-radius:8px; color:var(--text); white-space:nowrap; }
.tool svg.i { width:18px; height:18px; }
.tool:hover { background:var(--bg2); }
.tool.on { background:var(--acc); color:#fff; }
.tool .caret { width:10px; height:10px; margin-left:-3px; opacity:.6; }
.tool .kbd { display:none; }
.dock .sep, .ctxbar .sep { width:1px; height:22px; background:var(--line2); margin:0 4px; flex:none; }
.ctxbar .tool { height:32px; font-weight:500; font-size:11.5px; }
.ctxbar .tool.ok { background:var(--acc); color:#fff; }
.ctx-lbl { padding:0 8px; color:var(--muted); white-space:nowrap; }

/* ---------- right panel ---------- */
.rp { width:var(--rw); flex:none; display:flex; flex-direction:column; background:var(--bg); border-left:1px solid var(--line); min-height:0; z-index:10; }
.rp-head { display:flex; align-items:center; gap:4px; height:48px; padding:0 8px; border-bottom:1px solid var(--line); }
.zoom { height:28px; padding:0 6px; border-radius:5px; font-weight:500; font-variant-numeric:tabular-nums; }
.zoom:hover { background:var(--bg2); }
#ed-help { font-weight:700; font-size:13px; }
.rp-body { flex:1; overflow-y:auto; padding-bottom:40px; }

.ps { padding:12px 12px 14px; border-bottom:1px solid var(--line); }
.ps:last-child { border-bottom:0; }
.ps-h { display:flex; align-items:center; justify-content:space-between; min-height:24px; margin-bottom:8px; font-weight:600; }
.ps-h .acts { display:flex; gap:2px; }
.ps-h .ib { width:24px; height:24px; color:var(--muted); }
.ps-h .ib:hover { color:var(--text); }
.ps-l { font-size:10.5px; color:var(--muted); margin:8px 0 4px; }
.ps-l:first-of-type { margin-top:0; }
.r2 { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.r3 { display:grid; grid-template-columns:1fr 1fr auto; gap:6px; align-items:center; }
.rowf { display:flex; align-items:center; gap:6px; }
.rowf > * { min-width:0; }
.seg { display:flex; gap:2px; padding:2px; border-radius:6px; background:var(--bg2); }
.seg button { flex:1; height:24px; display:grid; place-items:center; border-radius:4px; color:var(--muted); }
.seg button:hover { color:var(--text); }
.seg button.on { background:var(--bg); color:var(--text); box-shadow:0 1px 2px rgba(0,0,0,.12); }
.seg svg.i { width:15px; height:15px; }

/* number / text fields with a small leading label, like Figma */
.nf { position:relative; display:flex; align-items:center; height:28px; border-radius:5px; background:var(--bg2); border:1px solid transparent; }
.nf:hover { border-color:var(--line2); }
.nf:focus-within { border-color:var(--acc); background:var(--bg); }
.nf .lb { width:24px; flex:none; text-align:center; color:var(--dim); font-size:11px; cursor:ew-resize; user-select:none; }
.nf .lb svg.i { width:13px; height:13px; margin:auto; }
.nf input, .nf select { width:100%; min-width:0; height:100%; border:0; background:transparent; padding:0 6px 0 0; outline:none; font-variant-numeric:tabular-nums; }
.nf select { padding-left:6px; cursor:pointer; }
.nf.full .lb { display:none; }
.nf.full input, .nf.full select { padding-left:8px; }
.nf .unit { padding-right:6px; color:var(--dim); }

/* colour row: swatch + hex + opacity */
.cr { display:flex; align-items:center; gap:6px; }
.cr .nf { flex:1; }
.csw { position:relative; width:20px; height:20px; margin:0 4px 0 4px; border-radius:3px; border:1px solid rgba(0,0,0,.18); flex:none; overflow:hidden; background:repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0/8px 8px; }
.csw i { position:absolute; inset:0; }
.csw input { position:absolute; inset:-4px; width:30px; height:30px; opacity:0; cursor:pointer; }
.cr .op { width:62px; flex:none; }
.rm { color:var(--muted); }

.chk { display:flex; align-items:center; gap:8px; cursor:pointer; }
.chk input { accent-color:var(--acc); width:14px; height:14px; }
input[type="range"] { width:100%; accent-color:var(--acc); }
.sl { display:grid; grid-template-columns:78px 1fr 34px; align-items:center; gap:6px; margin-top:6px; font-size:11px; color:var(--muted); }
.sl b { text-align:right; color:var(--text); font-weight:500; font-variant-numeric:tabular-nums; }

.pre-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:5px; }
.pre { display:flex; flex-direction:column; align-items:center; gap:3px; padding:3px; border-radius:5px; font-size:10px; color:var(--muted); }
.pre:hover { background:var(--bg2); color:var(--text); }
.pre.on { color:var(--text); box-shadow:inset 0 0 0 1.5px var(--acc); }
.pre i { width:100%; aspect-ratio:1; border-radius:4px; background:#999 center/cover no-repeat; }
.pre-bw { filter:grayscale(1); } .pre-sepia { filter:sepia(1); } .pre-vintage { filter:sepia(.5) contrast(1.1) saturate(.8) hue-rotate(-10deg); }
.pre-kodachrome { filter:contrast(1.2) saturate(1.4) sepia(.15); } .pre-technicolor { filter:saturate(1.8) contrast(1.15); }
.pre-polaroid { filter:contrast(1.1) brightness(1.08) saturate(1.2) sepia(.1); } .pre-brownie { filter:sepia(.6) contrast(1.1) brightness(.95); }

.empty-sel { padding:16px 12px; color:var(--muted); line-height:1.6; }

/* help */
.help { width:330px; }
.kb { display:flex; justify-content:space-between; gap:14px; padding:6px 10px; }
.kb kbd { font:500 11px/1.3 "Inter", sans-serif; color:#cfc8ff; }
.kb span { color:#b3b3b3; text-align:right; }

/* toast */
.toast { position:fixed; left:50%; top:14px; transform:translate(-50%, -20px); z-index:100; padding:9px 14px; border-radius:8px; background:#1e1e1e; color:#fff; font-weight:500; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; box-shadow:var(--shadow); }
.toast.show { opacity:1; transform:translate(-50%, 0); }

.mob-only { display:none !important; }

/* ---------- small screens: panels become sheets ---------- */
@media (max-width:900px) {
  .mob-only { display:inline-flex !important; }
  .lp, .rp { position:fixed; top:0; bottom:0; z-index:50; box-shadow:var(--shadow); transform:translateX(-105%); transition:transform .25s; }
  .lp { left:0; width:min(300px, 86vw); }
  .rp { right:0; width:min(300px, 86vw); transform:translateX(105%); }
  .lp.open, .rp.open { transform:none; }
  .mob-btn { position:absolute; top:12px; z-index:15; height:34px; padding:0 12px; border-radius:8px; background:var(--bg); box-shadow:var(--shadow); font-weight:600; align-items:center; }
  .mob-btn.l { left:12px; } .mob-btn.r { right:12px; }
  .hint { top:58px; white-space:normal; width:calc(100% - 24px); text-align:center; }
  .dock { bottom:10px; max-width:calc(100% - 16px); overflow-x:auto; }
  .ctxbar { bottom:66px; }
}
