/* FA — charcoal dark theme (default) and a matching light theme. */
:root, [data-theme="dark"] {
  --bg: #121418; --stage: #0f1114; --dot: #22262c;
  --panel: #191c21; --panel2: #1f2329; --panel3: #262b32; --line: #2c3139; --line2: #3a414b;
  --text: #e6e9ee; --muted: #98a2ae; --faint: #6b7480;
  --accent: #5cc8e0; --accent2: #3aa6c8; --accentBg: rgba(92, 200, 224, .14); --accentLine: rgba(92, 200, 224, .55);
  --danger: #e57373; --warn: #e8b04a; --ok: #6cc59a;
  --shadow: 0 18px 60px rgba(0, 0, 0, .55); --radius: 10px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #e9ecf0; --stage: #dfe3e8; --dot: #cdd3da;
  --panel: #f6f7f9; --panel2: #ffffff; --panel3: #eef1f4; --line: #d6dbe1; --line2: #c3cad3;
  --text: #1b1f24; --muted: #5d6773; --faint: #8a939e;
  --accent: #1b8db3; --accent2: #137696; --accentBg: rgba(27, 141, 179, .12); --accentLine: rgba(27, 141, 179, .55);
  --shadow: 0 18px 50px rgba(30, 40, 50, .22);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.45 "Segoe UI", "Segoe UI Variable", Tahoma, system-ui, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
#app { display: grid; grid-template-rows: 28px 46px 1fr 26px; height: 100vh; }

/* ---------- top bar ---------- */
#topbar { display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; margin-inline-end: 6px; }
.brand .logo { width: 28px; height: 28px; }
.brand b { font-size: 15px; letter-spacing: .5px; direction: ltr; }
.tgroup { display: flex; align-items: center; gap: 2px; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.spacer { flex: 1; }
.ib { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); transition: background .12s, color .12s; position: relative; }
.ib.sm { width: 26px; height: 26px; }
.ib.sm .ic { width: 15px; height: 15px; }
.ib:hover { background: var(--panel3); color: var(--text); }
.ib.active { background: var(--accentBg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accentLine); }
.ib:disabled { opacity: .35; pointer-events: none; }
.ib.lang { width: auto; padding: 0 8px; font-size: 12px; font-weight: 600; }
.tool-options { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; white-space: nowrap; }
.opt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.opt input[type="range"] { width: 92px; }
.opt output { min-width: 34px; color: var(--text); font-variant-numeric: tabular-nums; }
.opt select, .field select, .field input[type="text"], .field input[type="number"], .opt input[type="number"] {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; color: var(--text); outline: none; }
.opt select:focus, .field input:focus, .field select:focus { border-color: var(--accentLine); }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip:hover { color: var(--text); border-color: var(--line2); }
.chip.active { background: var(--accentBg); color: var(--accent); border-color: var(--accentLine); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 4px 9px; color: var(--muted); font-size: 12px; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.active { background: var(--accentBg); color: var(--accent); }
.btn { padding: 6px 14px; border-radius: 8px; background: var(--panel3); border: 1px solid var(--line); color: var(--text); }
.btn:hover { border-color: var(--line2); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: var(--danger); }
.brushchip { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 8px; border: 1px solid var(--line); color: var(--text); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.brushchip:hover { border-color: var(--accentLine); }
.recentbrushes { display: flex; gap: 4px; align-items: center; }
.rbrush { width: 54px; height: 26px; padding: 2px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); overflow: hidden; display: grid; place-items: center; }
.rbrush:hover { border-color: var(--accentLine); }
.rbrush.active { border-color: var(--accent); background: var(--accentBg); }
.rbrush canvas { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* ---------- workspace ---------- */
#workspace { position: relative; display: grid; grid-template-columns: 54px var(--altW, 0px) minmax(0, 1fr) var(--mainW, 296px); min-height: 0; }
/* fixed cells: a hidden dock (display: none) takes no cell, so auto-placement slid the canvas into a 0-wide column
   (Tab / F showed a black screen) */
#toolbar { grid-row: 1; grid-column: 1; } #dockAlt { grid-row: 1; grid-column: 2; } #stage { grid-row: 1; grid-column: 3; } #panels { grid-row: 1; grid-column: 4; }
#menubar { grid-row: 1; } #topbar { grid-row: 2; } #workspace { grid-row: 3; } #statusbar { grid-row: 4; } /* the same for the rows (F: full screen) */
body.panels-hidden #workspace { grid-template-columns: 54px 0 minmax(0, 1fr) 0; }
body.panels-hidden .dock, body.panels-hidden #floatHost { display: none; }
body.zen #app { grid-template-rows: 0 0 1fr 0; }
body.zen #menubar, body.zen #topbar, body.zen #statusbar, body.zen #toolbar, body.zen #panels, body.zen #viewHud { display: none; }
body.zen #workspace { grid-template-columns: 0 0 1fr 0; }
body.zen .dock, body.zen #floatHost { display: none; }
body.zen #zenExit { display: grid !important; }
#zenExit { position: absolute; top: 10px; inset-inline-end: 10px; background: var(--panel); box-shadow: var(--shadow); z-index: 20; }

#toolbar { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; background: var(--panel); border-inline-end: 1px solid var(--line); overflow: hidden auto; }
#tools { display: flex; flex-direction: column; gap: 3px; }
#tools .ib { width: 38px; height: 38px; }
#tools .ib .ic { width: 20px; height: 20px; }
#tools .tsep { height: 1px; background: var(--line); margin: 4px 6px; }
.quick { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; align-items: center; }
.vslider { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vslider input { writing-mode: vertical-lr; direction: rtl; width: 22px; height: 110px; margin: 0; }
.vslider output { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.swatchpair { position: relative; width: 40px; height: 40px; margin-top: auto; margin-bottom: 4px; }
.sw { position: absolute; width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line2); }
.sw.cur { top: 0; left: 0; z-index: 1; }
.sw.prev { bottom: 0; right: 0; }

/* ---------- stage ---------- */
#stage { position: relative; overflow: hidden; direction: ltr; touch-action: none; background-color: var(--stage); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 20px 20px; }
#stage.tool-paint { cursor: none; }
#stage.tool-pick { cursor: crosshair; }
#stage.tool-select { cursor: crosshair; }
#stage.tool-move { cursor: move; }
#stage.tool-fill { cursor: var(--cur-fill, crosshair); }
#stage.tool-lassofill { cursor: var(--cur-lassofill, crosshair); }
#stage.tool-gradient { cursor: var(--cur-gradient, crosshair); }
#stage.tool-shape { cursor: var(--cur-shape, crosshair); }
#stage.tool-text { cursor: text; }
.fa-text-editor { caret-color: currentColor; }
#stage.tool-hand, #stage.panning { cursor: grab; }
#stage.panning:active { cursor: grabbing; }
#paper { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 10px 50px rgba(0, 0, 0, .45), 0 0 0 1px rgba(0, 0, 0, .25);
  background-color: #fff; background-image: linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%), linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
#layerHost { position: absolute; inset: 0; isolation: isolate; }
#layerHost canvas, #layerHost .lgroup { position: absolute; inset: 0; width: 100%; height: 100%; }
#paper.pixelated canvas { image-rendering: pixelated; }
#selTint { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .55; }
#selOutline { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
/* every outline shape: a closed lasso is a <polygon>, and SVG fills shapes black by default */
#selOutline path, #selOutline rect, #selOutline polyline, #selOutline polygon { fill: none; stroke: #fff; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
#selOutline .ants { stroke: #111; stroke-dasharray: 5 5; animation: ants .6s linear infinite; }
@keyframes ants { to { stroke-dashoffset: -10; } }
#floatCanvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
#screenOverlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#screenOverlay .box { fill: none; stroke: var(--accent); stroke-width: 1.4; }
#screenOverlay .handle { fill: var(--panel2); stroke: var(--accent); stroke-width: 1.6; }
#screenOverlay .rot { fill: var(--accent); }
#brushCursor { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .9); box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); transform: translate(-50%, -50%); z-index: 5; }
#brushCursor.ghost { -webkit-backdrop-filter: blur(var(--gblur)); backdrop-filter: blur(var(--gblur)); background: rgba(255, 255, 255, calc(.03 + .07 * var(--ghost))); } /* hover preview of a blend brush: the ring softens what is under it, more with more strength */
.blendprev { flex-basis: 100%; display: flex; } .blendprev canvas { width: 100%; max-width: 230px; height: auto; border-radius: 6px; } /* touch UI: live blend preview under Blend strength */
#brushCursor::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: rgba(255, 255, 255, .95); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
#viewHud { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px 6px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 6; backdrop-filter: blur(6px); }
.hudval { min-width: 48px; padding: 3px 6px; border-radius: 6px; color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.hudval:hover { background: var(--panel3); }
.hsep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
#diagPanel { position: absolute; top: 12px; left: 12px; width: 300px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 8; direction: inherit; font-size: 12px; }
#diagPanel h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
#diagPanel table { width: 100%; border-collapse: collapse; }
#diagPanel td { padding: 3px 0; color: var(--muted); }
#diagPanel td:last-child { color: var(--text); text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
#diagPanel .bar { height: 6px; border-radius: 3px; background: var(--panel3); overflow: hidden; margin: 2px 0 6px; }
#diagPanel .bar i { display: block; height: 100%; background: var(--accent); width: 0; }
#diagPanel .ok { color: var(--ok) !important; } #diagPanel .warn { color: var(--warn) !important; }

/* ---------- panels ---------- */
.dock { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); overflow: hidden; }
.dock.main { border-inline-start: 1px solid var(--line); }
.dock.alt { border-inline-end: 1px solid var(--line); }
.dock.empty { border: 0; }
.panel { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); min-height: 0; min-width: 0; }



.phead { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-weight: 600; font-size: 12px; letter-spacing: .3px; color: var(--muted); cursor: pointer; }
.phead span { flex: 1; }
.pcollapse { width: 18px; height: 18px; display: grid; place-items: center; color: var(--faint); transition: transform .15s; }
.pcollapse .ic { width: 14px; height: 14px; }
.panel.collapsed .pcollapse { transform: rotate(90deg); }
[dir="rtl"] .panel.collapsed .pcollapse { transform: rotate(-90deg); }
.panel.collapsed .pbody { display: none; }
.pactions { display: flex; gap: 2px; }
.pbody { padding: 0 10px 10px; overflow: auto; min-height: 0; }
.panel.grow .pbody { flex: 1; display: flex; flex-direction: column; }

/* brushes */
.cats { display: flex; gap: 4px; padding-bottom: 6px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; } /* one row; visibly scrollable (wheel scrolls it sideways) */
.blist { display: flex; flex-direction: column; gap: 2px; }
.brow { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.brow:hover { background: var(--panel3); }
.brow.active { background: var(--accentBg); border-color: var(--accentLine); }
.brow .bname { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.brow .bname .mod { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.brow canvas { display: block; width: 100%; height: 34px; }
.brow .bmeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brow .bbtns { display: flex; flex-direction: column; gap: 0; opacity: 0; }
.brow:hover .bbtns, .brow.active .bbtns { opacity: 1; }
.brow .bbtns .ib { width: 24px; height: 22px; }
.brow .bbtns .ib .ic { width: 14px; height: 14px; }
.star.on { color: var(--warn); opacity: 1; }
.star.on .ic { fill: currentColor; }

/* color */
.cwrap { display: grid; grid-template-columns: 1fr 18px; gap: 8px; direction: ltr; }
#svBox, #hueBar { position: relative; border-radius: 8px; overflow: hidden; touch-action: none; cursor: crosshair; }
#svBox { height: 132px; }
#svBox canvas, #hueBar canvas { width: 100%; height: 100%; display: block; }
.knob { position: absolute; width: 14px; height: 14px; margin: -7px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
#hueBar .knob { left: 50%; width: 22px; height: 8px; margin: -4px -11px; border-radius: 4px; }
.crow { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.crow label { display: flex; flex-direction: column; font-size: 10px; color: var(--muted); gap: 2px; }
.crow input { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; direction: ltr; text-align: center; min-width: 0; }
.crow input.hex { text-transform: lowercase; }
.cpair { display: flex; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px var(--line2); height: 28px; flex: 0 0 72px; }
.cpair button { flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.swatches button { width: 20px; height: 20px; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2), 0 0 0 1px var(--line); }
.swatches button:hover { transform: scale(1.12); }
.swatches .add { display: grid; place-items: center; color: var(--muted); box-shadow: 0 0 0 1px var(--line2); }
.swatches .add .ic { width: 13px; height: 13px; }
.subhead { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.subhead select { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; min-width: 0; }

/* layers */
.lbar { display: flex; justify-content: space-between; gap: 2px; margin-bottom: 6px; min-width: 0; }
.lbar .ib { flex: 1 1 0; min-width: 22px; max-width: 30px; height: 30px; } /* shrink to fit the panel */
.llist { flex: 1; overflow: auto; min-height: 60px; display: flex; flex-direction: column; gap: 2px; }
.lrow { display: grid; grid-template-columns: 26px 44px minmax(0, 1fr) auto; min-width: 0; align-items: center; gap: 6px; padding: 3px 5px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.lrow:hover { background: var(--panel3); }
.lrow.active { background: var(--accentBg); border-color: var(--accentLine); }
.lrow.sel { background: var(--accentBg); border-color: transparent; }
.lrow.child { margin-inline-start: 16px; }
.lrow.hiddenl .lname, .lrow.hiddenl .thumb { opacity: .45; }
.lrow.drop-above { box-shadow: 0 -2px 0 var(--accent); }
.lrow.drop-below { box-shadow: 0 2px 0 var(--accent); }
.lrow.drop-into { box-shadow: inset 0 0 0 2px var(--accent); }
.lrow .thumb { width: 44px; height: 32px; border-radius: 5px; background-color: #fff; background-image: linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%), linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%); background-size: 8px 8px; background-position: 0 0, 4px 4px; box-shadow: 0 0 0 1px var(--line); object-fit: contain; }
.lrow .gicon { width: 44px; height: 32px; display: grid; place-items: center; color: var(--muted); }
.lrow .lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.lrow .lname small { display: block; color: var(--faint); font-size: 10px; }
.lrow .ib { width: 24px; height: 24px; }
.lrow .ib .ic { width: 14px; height: 14px; }
.lrow .flags { display: flex; gap: 0; }
.lrow .flags .ib { color: var(--faint); }
.lrow .flags .ib.on { color: var(--warn); }
.lrow input.rename { width: 100%; background: var(--panel2); border: 1px solid var(--accentLine); border-radius: 5px; padding: 2px 4px; }
.lprops { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 6px; display: grid; gap: 6px; }
.lprops .opt input[type="range"] { flex: 1; width: auto; }
.lprops .opt select { flex: 1; }

/* status bar */
#statusbar { display: flex; align-items: center; gap: 16px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; }
#statusbar span { font-variant-numeric: tabular-nums; }
#stDoc { color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
#stSave.unsaved { color: var(--warn); }
#stSave.saved { color: var(--ok); }
#stMsg.error { color: var(--danger); }

/* tooltip, toast */
#tooltip { position: fixed; z-index: 100; padding: 5px 9px; background: #0b0d10; color: #eef2f6; border-radius: 7px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); white-space: nowrap; }
#tooltip kbd { margin-inline-start: 8px; padding: 0 5px; border-radius: 4px; background: #262b33; color: #9fd8e6; font: 11px Consolas, monospace; direction: ltr; display: inline-block; }
#toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 90; padding: 8px 16px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); box-shadow: var(--shadow); }
#toast.error { border-color: var(--danger); color: var(--danger); }
#toast.warn { border-color: var(--warn); max-width: min(560px, 90vw); white-space: normal; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 14px; padding: 0; box-shadow: var(--shadow); max-width: min(92vw, 760px); max-height: 90vh; }
dialog::backdrop { background: rgba(5, 7, 10, .55); }
.dlg { display: flex; flex-direction: column; max-height: 90vh; }
.dlg > header { padding: 14px 18px 8px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dlg > header .ib { margin-inline-start: auto; }
.dlg .dbody { padding: 6px 18px 12px; overflow: auto; }
.dlg > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 4px; margin: 10px 0; font-size: 12px; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field select { width: 100%; padding: 7px 9px; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.presetgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0; line-height: 1.6; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; color: var(--text); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.kbdlist { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.kbdlist kbd { font: 12px Consolas, monospace; background: var(--panel3); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); direction: ltr; justify-self: start; }
.help p { margin: 0 0 10px; line-height: 1.7; }
.recentlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; min-width: 520px; }
.recent { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); text-align: start; }
.recent:hover { border-color: var(--accentLine); background: var(--panel3); }
.recent img { width: 100%; height: 96px; object-fit: contain; background: var(--panel2); border-radius: 6px; }
.recent small { color: var(--faint); }
.curve { width: 100%; height: 120px; background: var(--panel2); border-radius: 8px; border: 1px solid var(--line); }

/* brush studio */
.studio { display: grid; grid-template-columns: 300px 340px; gap: 18px; }
.studio .sliders { display: grid; gap: 2px; }
.srow { display: grid; grid-template-columns: minmax(0, 110px) minmax(0, 1fr) minmax(44px, max-content); align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.srow output { color: var(--text); text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
details.adv { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
details.adv summary { cursor: pointer; color: var(--text); font-size: 12px; padding: 4px 0; }
details.adv h5 { margin: 10px 0 4px; font-size: 11px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.pad { position: relative; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px var(--line2); background: #fff; touch-action: none; cursor: crosshair; }
.pad canvas { display: block; width: 100%; }
.previewbox { border-radius: 10px; background: var(--panel2); box-shadow: 0 0 0 1px var(--line); padding: 6px; margin-bottom: 10px; }
.previewbox canvas { display: block; width: 100%; }

/* updates */
.updbox { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 6px; display: grid; gap: 6px; }
.updbox input[type="text"] { width: 100%; padding: 6px 8px; }
.updbox pre { white-space: pre-wrap; max-height: 140px; overflow: auto; }

/* layer masks & clipping */
.lrow { grid-template-columns: 26px auto minmax(0, 1fr) auto; } /* minmax: a long layer name must not widen the panel */
.thumbs { display: flex; align-items: center; gap: 3px; }
.thumbs .thumb { width: 40px; height: 30px; cursor: pointer; }
.thumbs .thumb.target { box-shadow: 0 0 0 2px var(--accent); }
.thumbs .thumb.adjthumb { display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2, transparent); color: var(--text); }
.thumbs .thumb.adjthumb svg { width: 18px; height: 18px; }
.thumbs .thumb.mask.off { opacity: .4; outline: 1px dashed var(--danger); }
.clipmark { color: var(--accent); font-size: 15px; width: 12px; text-align: center; }
.maskrow { flex-wrap: wrap; gap: 6px; }
.maskrow .check { margin: 0; }
.maskhint { margin: 0; color: var(--accent); }

/* brush library & import */
.bsearch { width: 100%; margin-bottom: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; color: var(--text); outline: none; }
.bsearch:focus { border-color: var(--accentLine); }
.bcoll { display: flex; align-items: center; gap: 4px; margin: 8px 2px 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
.bcoll span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel.dropping { box-shadow: inset 0 0 0 2px var(--accent); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge.sm { padding: 0 5px; font-size: 9.5px; }
.st-full { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.st-partial { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.st-tip-only { color: var(--accent); border-color: var(--accentLine); }
.st-unsupported, .st-corrupt { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.importbox { width: 680px; max-width: 100%; }
.pbar { height: 8px; border-radius: 4px; background: var(--panel3); overflow: hidden; margin: 8px 0 4px; }
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.imphead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.impopts { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 8px; }
.impopts pre { white-space: pre-wrap; max-height: 120px; overflow: auto; }
.ilist { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.igroup + .igroup { margin-top: 10px; }
.igrouphead { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 4px; border-bottom: 1px solid var(--line); }
.field.inline { display: flex; align-items: center; gap: 6px; margin: 0; }
.field.inline input { width: 220px; padding: 4px 7px; }
.irow { border-radius: 8px; }
.irow:hover { background: var(--panel3); }
.irow.disabled { opacity: .7; }
.irowmain { display: grid; grid-template-columns: 20px 200px minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 4px 6px; cursor: pointer; }
.irowmain canvas { background: var(--panel2); border-radius: 6px; }
.nopv { width: 200px; height: 36px; display: grid; place-items: center; color: var(--faint); background: var(--panel2); border-radius: 6px; }
.iname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.rdetails { padding: 2px 34px 8px; font-size: 12px; }
.rdetails p { margin: 3px 0; line-height: 1.6; }
.rk-unsupported b, .rk-missing b { color: var(--danger); } .rk-approximated b { color: var(--warn); } .rk-imported b { color: var(--ok); }
.errline { color: var(--danger); font-weight: 600; }
.dfoot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.studio h5 { margin: 12px 0 4px; font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .4px; }
.curves { display: flex; gap: 8px; flex-wrap: wrap; }
.curves > div { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.curveed { width: 150px; height: 90px; background: var(--panel2); border-radius: 6px; cursor: crosshair; touch-action: none; }
.resrow { display: flex; gap: 14px; margin-bottom: 6px; }
.resrow small { display: block; color: var(--faint); margin-bottom: 2px; }
.resthumb { width: 64px; height: 64px; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }
.studio .sliders, .studio details { max-width: 300px; }
.studio > div:first-child { max-height: 64vh; overflow-y: auto; overflow-x: hidden; padding-inline-end: 6px; } /* settings never need sideways scrolling */
.studio .srow select { max-width: 100%; }

@media (max-width: 1100px) {
  #workspace { grid-template-columns: 50px var(--altW, 0px) minmax(0, 1fr) var(--mainW, 250px); }
  .opt input[type="range"] { width: 70px; }
}

/* import: original app preview vs FA preview */
.refcmp { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 8px; }
.refcmp figure { margin: 0; flex: 1 1 260px; min-width: 0; background: #262626; border-radius: 8px; padding: 6px; }
.refcmp img, .refcmp canvas { display: block; width: 100%; height: 90px; object-fit: contain; }
.refcmp figcaption { font-size: 11px; color: #b9c2cc; margin-top: 4px; }

/* menu bar (File, Edit, …) */
#menubar { display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; overflow: hidden; }
#menubar #btnHome { width: 24px; height: 24px; margin-inline-end: 4px; }
#menus { display: flex; gap: 0; min-width: 0; }
.menubtn { padding: 3px 9px; border-radius: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.menubtn:hover, .menubtn.open, .menubtn:focus-visible { background: var(--panel3); color: var(--text); outline: none; }
.menulist { position: fixed; z-index: 120; min-width: 230px; padding: 4px; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; box-shadow: var(--shadow); }
.menuitem { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; text-align: start; color: var(--text); }
.menuitem:hover:not(:disabled), .menuitem:focus-visible { background: var(--accentBg); outline: none; }
.menuitem:disabled { color: var(--faint); cursor: default; }
.menuitem .mcheck { color: var(--accent); font-size: 12px; }
.menuitem .mkey { color: var(--faint); font-size: 11px; }
.menuitem.hassub .mkey { font-size: 15px; line-height: 1; }
.menuitem.hassub.open { background: var(--accentBg); }
.menusep { height: 1px; margin: 4px 6px; background: var(--line); }
/* Window menu: hidden panels (not collapsed — their content and settings are kept) */
.panel.off { display: none !important; }


/* Home (over the editor; the document behind it stays open) */
#home { position: fixed; inset: 28px 0 0 0; z-index: 60; overflow: auto; background: var(--bg); }
#home[hidden] { display: none; }
body.home-on #btnHome { color: var(--accent); }
.homeinner { max-width: 1100px; margin: 0 auto; padding: 28px 24px 40px; }
.homehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.homehead h1 { font-size: 22px; margin: 0; }
.homeactions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.homebtn { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; }
.homebtn:hover { border-color: var(--line2); background: var(--panel2); }
.homebtn.primary { border-color: var(--accentLine); background: var(--accentBg); color: var(--accent); }
.homebtn .hic .ic { width: 20px; height: 20px; }
.homerecover { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid var(--warn); border-radius: 12px; background: var(--panel); }
.homerecover small { display: block; color: var(--muted); margin-top: 2px; }
.homerecenthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.homerecenthead h2 { font-size: 15px; margin: 0; }
.homerecenthead input { width: min(280px, 50vw); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text); }
.homegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.homecard { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; cursor: pointer; }
.homecard:hover, .homecard:focus-visible { border-color: var(--accentLine); outline: none; }
.homecard img, .homecard .nothumb { width: 100%; height: 130px; object-fit: contain; background: var(--panel3); }
.homecardinfo { padding: 8px 10px; min-width: 0; }
.homecardinfo b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.homecardinfo small { color: var(--muted); font-size: 11px; }
.homecardacts { position: absolute; top: 6px; inset-inline-end: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.homecard:hover .homecardacts, .homecard:focus-within .homecardacts { opacity: 1; }
.homecardacts .ib { background: var(--panel2); }
.homecardacts .pin.on { color: var(--warn); opacity: 1; }
.homecard .homecardacts:has(.pin.on) { opacity: 1; }
.homecard.missing { cursor: default; opacity: .6; }
.homecard.missing .homecardinfo small { color: var(--warn); }
.homeempty { color: var(--muted); padding: 30px 0; }
.recent.missing { opacity: .55; }

/* layer properties: one line for 'blend mode' with the longer Arabic — English names */
.lprops .opt > span { white-space: nowrap; }
.lprops .opt .blendsel { flex: 1 1 0; width: 0; min-width: 0; } /* a <select> is as wide as its longest option otherwise */

/* brush size drag: value under the size circle */
.sizehud { position: absolute; transform: translateX(-50%); z-index: 30; padding: 2px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line2); color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; direction: ltr; }
.sizehud[hidden] { display: none; }

/* gradient tool */
.gradswatch { width: 74px; height: 22px; border-radius: 6px; border: 1px solid var(--line2); flex-shrink: 0; }
.gradswatch.sm { width: 56px; height: 18px; }
#paper canvas.gradprev { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#screenOverlay .gradline { stroke: #fff; stroke-width: 1.5; filter: drop-shadow(0 0 1px #000); }
#screenOverlay .gradend { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.gradeditor { width: min(460px, 80vw); }
.gradbarwrap { position: relative; padding-bottom: 18px; margin: 4px 7px 6px; direction: ltr; }
.gradbar { height: 34px; border-radius: 8px; border: 1px solid var(--line2); cursor: copy; }
.gradmarks { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.gradmark { position: absolute; bottom: 0; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--panel2); box-shadow: 0 0 0 1px var(--line2); cursor: ew-resize; }
.gradmark.sel { box-shadow: 0 0 0 2px var(--accent); }
.gradrow { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.gradrow input[type=text] { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); }
.gradpresets { display: flex; flex-wrap: wrap; gap: 6px; min-height: 22px; }
.gradpreset { display: flex; align-items: center; gap: 2px; }
#toolOptions .seg { flex-shrink: 0; }

/* import: library section per brush */
.catsel { max-width: 130px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; color: var(--text); }
.irow.needcat .catsel { border-color: var(--warn); color: var(--warn); }
/* duplicate brushes (import) */
.irow.isdup .irowmain { opacity: .6; }
.dupline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 34px 6px; font-size: 12px; color: var(--muted); }
.dupline.exact { color: var(--warn); }
.dupsum { font-weight: 600; }
.duplist { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.duplist .dupline { padding: 4px 0; }
.brow.flash { outline: 2px solid var(--accent); outline-offset: -2px; transition: outline-color .4s; }
.catneed { color: var(--warn); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.catneed[hidden] { display: none; }
.catneed select { font-size: 12px; }

/* shortcuts & buttons */
.scbox { width: min(760px, 86vw); max-width: 100%; } /* was as wide as the whole dialog: in Arabic the "+" buttons sat under the scrollbar */
.scprof { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.scprof input { width: 130px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.scsearch { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text); margin: 4px 0; }
.scmsg { padding: 6px 10px; border-radius: 8px; background: var(--panel2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.scmsg[hidden] { display: none; }
.scmsg.warn { border: 1px solid var(--warn); } .scmsg.ok { border: 1px solid var(--ok); }
.sclist { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.sccat { margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.scrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; }
.scrow:hover { background: var(--panel3); }
.scrow.rec { background: var(--accentBg); }
.scrow.changed .sclabel::after { content: ' •'; color: var(--accent); }
.sclabel small { color: var(--faint); }
.sckeys { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.sckeys kbd { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel2); font-size: 11.5px; }
.sckeys kbd.recording { border-color: var(--accent); color: var(--accent); }
.sckeys kbd .x { color: var(--faint); font-size: 12px; line-height: 1; }
.sckeys kbd .x:hover { color: var(--danger); }
.sckeys .none { color: var(--faint); font-size: 12px; }
.scacts { display: flex; gap: 4px; }
.scmouse { margin-top: 8px; } .scmouse summary { cursor: pointer; font-weight: 600; }
.scgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }

/* ---------- workspace: docks, sections, tabs, splitters, floating panels ---------- */
.slot { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--line); }
.slot > .panel { flex: 1 1 auto; border-bottom: 0; }
.slot > .panel.collapsed { flex: 0 0 auto; }
.panel.tabhidden { display: none !important; }
.panel .pbody { flex: 1 1 auto; }
.tabbar { display: flex; gap: 2px; padding: 4px 6px 0; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.ptab { padding: 4px 10px; border-radius: 7px 7px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ptab.active { background: var(--panel2); color: var(--text); }
.slot:has(.tabbar) > .panel > .phead { display: none; }
.hsplit { flex: 0 0 6px; margin: -3px 0; position: relative; z-index: 5; cursor: row-resize; }
.vsplit { position: absolute; top: 0; bottom: 0; width: 7px; z-index: 6; cursor: col-resize; }
.dock.main > .vsplit { inset-inline-start: -3px; }
.dock.alt > .vsplit { inset-inline-end: -3px; }
.hsplit:hover, .hsplit.drag { background: linear-gradient(transparent 2px, var(--accent) 2px, var(--accent) 4px, transparent 4px); }
.vsplit:hover, .vsplit.drag { background: linear-gradient(90deg, transparent 2px, var(--accent) 2px, var(--accent) 4px, transparent 4px); }
body.resizing-h, body.resizing-h * { cursor: col-resize !important; user-select: none; }
body.resizing-v, body.resizing-v * { cursor: row-resize !important; user-select: none; }
.dock .phead { cursor: grab; }
#floatHost { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.floatwin { position: absolute; display: flex; flex-direction: column; pointer-events: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; resize: both; min-width: 200px; min-height: 120px; }
.floatwin > .panel { flex: 1 1 auto; border: 0; }
.floatwin .phead { cursor: move; }
.floatwin.docking { opacity: .6; outline: 2px solid var(--accent); }
body.paneldrag, body.paneldrag * { cursor: grabbing !important; user-select: none; }
.dragghost { position: fixed; z-index: 200; padding: 4px 10px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--accentLine); font-size: 12px; pointer-events: none; }
.dropind { position: fixed; z-index: 190; pointer-events: none; border-radius: 6px; background: color-mix(in srgb, var(--accent) 22%, transparent); border: 2px solid var(--accent); }
.dropind.line { background: var(--accent); border: 0; border-radius: 2px; }
.dropind.float { border-style: dashed; }
.dropind[hidden] { display: none; }

/* rulers, guides, grid (screen overlay: never in the pixels or exports) */
#aidsCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.ruler { position: absolute; z-index: 8; display: none; direction: ltr; }
body.rulers-on .ruler { display: block; }
.ruler.h { top: 0; left: 0; height: 20px; cursor: s-resize; border-bottom: 1px solid var(--line2); }
.ruler.v { top: 0; left: 0; width: 20px; cursor: e-resize; border-inline-end: 1px solid var(--line2); }
#stage.guide-hover { cursor: var(--guide-cursor, move) !important; }

/* ColorDrop */
.dropghost { position: fixed; z-index: 9999; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 3px 10px rgba(0,0,0,.45); transform: translate(-50%, -50%); pointer-events: none; }
.drophud { position: absolute; z-index: 30; transform: translateX(-50%); padding: 4px 9px; border-radius: 7px; background: rgba(0,0,0,.78); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; }
.fillprev { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; image-rendering: pixelated; }
body.colordrop, body.colordrop * { cursor: copy !important; }
.cfsw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -2px; box-shadow: 0 0 0 1px var(--line2); }

/* Sort brushes automatically */
.bsortlist { display: grid; gap: 2px; max-height: 260px; overflow: auto; margin: 6px 0; }
.bsortrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.bsortrow:nth-child(odd) { background: var(--panel3); }
.bsortrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsortrow small { color: var(--muted); }

/* Colour mixer & reference images panels */
.mixcanvas { display: block; width: 100%; aspect-ratio: 480 / 300; border-radius: 8px; box-shadow: 0 0 0 1px var(--line2); cursor: crosshair; touch-action: none; }
.mixcanvas.picking, .refview.picking { cursor: copy; }
.mixbar { display: flex; justify-content: center; margin: 8px 0 2px; }
.refview { display: block; width: 100%; height: 240px; border-radius: 8px; background: var(--panel3); box-shadow: 0 0 0 1px var(--line); cursor: grab; touch-action: none; }
.refbar { display: flex; justify-content: center; gap: 2px; margin: 6px 0; }
.refbar .ib.on { color: var(--accent); background: var(--panel3); }
.refstrip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.refthumb { flex: 0 0 auto; border-radius: 5px; background: var(--panel3); cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.refthumb.active { box-shadow: 0 0 0 2px var(--accent); }
.refempty { text-align: center; padding: 14px 6px; color: var(--muted); font-size: 12px; }

/* QuickMenu */
.qmenu { position: fixed; z-index: 9000; width: 0; height: 0; direction: ltr; }
.pickring { position: absolute; z-index: 30; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; overflow: hidden; pointer-events: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .55), 0 0 0 4px rgba(255, 255, 255, .9), 0 6px 18px rgba(0, 0, 0, .35);
  -webkit-mask: radial-gradient(circle, transparent 36px, #000 37px); mask: radial-gradient(circle, transparent 36px, #000 37px); }
.pickring i { position: absolute; left: 0; width: 100%; height: 50%; }
.pickring .pr-new { top: 0; } .pickring .pr-old { bottom: 0; }
.pickring .pr-new.none { background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 12px 12px !important; }
.navwrap { position: relative; margin: 4px auto; cursor: grab; touch-action: none; background-color: #fff; background-image: linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%), linear-gradient(45deg, #d9dde2 25%, transparent 25%, transparent 75%, #d9dde2 75%); background-size: 10px 10px; background-position: 0 0, 5px 5px; box-shadow: 0 0 0 1px var(--line2); }
.navwrap:active { cursor: grabbing; }
.navimg { display: block; width: 100%; height: 100%; pointer-events: none; }
.navsvg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.navbox { fill: rgba(80, 180, 220, .12); stroke: #e0473a; stroke-width: 1.6; }
.hlist { display: flex; flex-direction: column; gap: 1px; max-height: 260px; overflow: auto; }
.hrow { display: grid; grid-template-columns: 26px 1fr; gap: 6px; align-items: center; text-align: start; padding: 4px 6px; border-radius: 6px; color: var(--text); font-size: 12px; }
.hrow:hover { background: var(--panel3); }
.hrow.current { background: var(--accentBg); box-shadow: inset 0 0 0 1px var(--accentLine); }
.hrow.future { opacity: .45; }
.hrow .hnum { color: var(--muted); font-variant-numeric: tabular-nums; }
.colorwheel { position: fixed; z-index: 9000; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 12px 40px rgba(0, 0, 0, .45); direction: ltr; }
.cw-wheel { position: relative; touch-action: none; }
.cw-wheel canvas { position: absolute; left: 0; top: 0; }
.cw-sq { border-radius: 4px; cursor: crosshair; }
.cw-ring { cursor: crosshair; }
.cw-row { display: flex; gap: 5px; align-items: center; margin-top: 10px; flex-wrap: wrap; max-width: 196px; }
.cw-now { width: 26px; height: 26px; border-radius: 8px; box-shadow: 0 0 0 2px var(--accent); }
.cw-sw { width: 18px; height: 18px; border-radius: 5px; box-shadow: 0 0 0 1px var(--line2); }
.cw-sw:hover { box-shadow: 0 0 0 2px var(--accent); }
.qmenu::before { content: ''; position: absolute; left: -128px; top: -128px; width: 256px; height: 256px; border-radius: 50%; background: color-mix(in srgb, var(--panel) 55%, transparent); backdrop-filter: blur(3px); pointer-events: none; }
.qitem { position: absolute; transform: translate(-50%, -50%); min-width: 84px; max-width: 120px; padding: 7px 10px; border-radius: 999px; background: var(--panel2); color: var(--text); border: 1px solid var(--line2); box-shadow: var(--shadow); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qitem:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.qitem:disabled { opacity: .45; }
.qitem.empty { opacity: .35; }
.qcenter { position: absolute; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; background: var(--panel3); color: var(--muted); border: 1px solid var(--line2); font-size: 16px; }
.qcenter:hover { color: var(--text); }
.qmgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.opt.sm input[type="range"] { width: 60px; }
#toolOptions { overflow-x: auto; scrollbar-width: none; } /* many options in a narrow window: scroll instead of cutting them off */
#mixerPanel .srow { grid-template-columns: auto minmax(0, 1fr) 44px; }
.opt output, .srow output { unicode-bidi: plaintext; } /* "+1 px", "28 px" read left-to-right inside the Arabic layout */
/* selection tools: model / quick-selection preview and prompt points (interface overlay, never part of the drawing) */
#paper canvas.selpreview { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#paper svg.selpoints { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.selpoints circle { stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.selpoints circle.pin { fill: #2ea862; } .selpoints circle.pout { fill: #d6453d; }
.selpoints rect.pbox { fill: none; stroke: #2896ff; stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.objstatus { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); max-width: 46ch; }
.segdl .pbar { margin: 8px 0; }
.refine { display: flex; flex-direction: column; gap: 8px; min-width: 300px; }
input.num { width: 64px; }
/* brush sections (import / library) */
.badge.blendbadge { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); margin-inline-start: 6px; }
.needgroup { border: 1px dashed var(--warn); border-radius: 8px; padding: 4px; }
.needline { display: flex; align-items: center; gap: 8px; padding: 0 34px 6px; flex-wrap: wrap; }
.needline .tipthumb { border-radius: 4px; border: 1px solid var(--line); }
.iname input.mark { margin-inline-end: 6px; vertical-align: middle; }
/* brush pop-up (right click on the canvas) */
.bpop { position: fixed; z-index: 60; width: 300px; max-height: min(560px, calc(100vh - 16px)); display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .45); }
.bpop .cats { display: flex; gap: 4px; overflow-x: auto; flex: none; }
.bpop-num { display: grid; grid-template-columns: 70px 1fr 54px; align-items: center; gap: 6px; font-size: 12px; }
.bpop-val { text-align: end; color: var(--muted); unicode-bidi: plaintext; direction: ltr; }
.bpop-list { overflow-y: auto; min-height: 120px; display: flex; flex-direction: column; gap: 2px; }
.bpop-head { font-size: 11px; color: var(--muted); padding: 6px 4px 2px; }
.bpop-row { padding: 4px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.bpop-row:hover { background: var(--panel3); }
.bpop-row.active { background: var(--accentBg); border-color: var(--accentLine); }
.bpop-name { font-size: 12px; margin-bottom: 2px; }
.bpop-row canvas { width: 100%; height: 34px; display: block; }
/* Liquify: frozen areas (interface overlay, never part of the drawing) */
#paper canvas.lqfreeze { position: absolute; left: 0; top: 0; pointer-events: none; }
.lqtitle { font-weight: 600; }
.lqnum input[type=range] { width: 90px; }
.lqpanel { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 24px); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center;
  padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .35); }
.lqpanel .opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.lqacts { display: inline-flex; gap: 6px; align-items: center; }
.lqpanel { gap: 8px 14px; padding: 8px 14px; }
.lqtools { display: inline-flex; gap: 2px; background: var(--panel2); border-radius: 8px; padding: 2px; }
.lqtools .ib { width: 32px; height: 32px; }
.lqtools .ib.active { background: var(--accentBg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accentLine); }
.lqgrid { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 16px; }
.lqnum { display: grid; grid-template-columns: 76px 110px 52px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lqchecks { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.lqchk { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.lqsep { width: 1px; align-self: stretch; background: var(--line); }
/* Face-aware Liquify (FA 1.15): the face part of the Liquify panel */
.lqface { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.lqfacebar, .lqfacetabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lqfacetabs .chip.changed::after { content: '•'; margin-inline-start: 4px; color: var(--accent); }
.lqfacegrid { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 16px; justify-content: start; }
.lqfacegrid .lqchk, .lqfacesub { grid-column: 1 / -1; }
.lqfacesub { font-size: 12px; font-weight: 600; margin-top: 2px; }
.lqfacehint { font-size: 12px; color: var(--muted); }
.lqfacegrid .lqnum input[type=range] { direction: ltr; } /* −100 on the left, + on the right, in both languages */
/* Liquify brush cursor: outer ring = size, inner ring = edge density */
.lqcursor { position: absolute; z-index: 15; pointer-events: none; transform: translate(-50%, -50%); border-radius: 50%; border: 1px solid rgba(255, 255, 255, .9); box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); display: grid; place-items: center; }
.lqcursor i { border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .8); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }

/* ---- FA 1.13: adjustments (live preview dialog), canvas size, symmetry ---- */
dialog.light::backdrop { background: transparent; }
dialog.light { margin: 70px 24px auto auto; }
[dir="rtl"] dialog.light { margin: 70px auto auto 24px; }
.adjbox { min-width: 300px; }
.adjbox .srow { margin: 6px 0; }
.anchorgrid { display: grid; grid-template-columns: repeat(3, 28px); gap: 3px; direction: ltr; }
.anchorgrid button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2, transparent); color: inherit; cursor: pointer; }
.anchorgrid button.active { background: var(--accent); border-color: var(--accent); }
/* FA 1.13: where a brush came from */
.badge.src { font-size: 9.5px; padding: 0 5px; border-radius: 4px; margin-inline-start: 6px; font-weight: 600; letter-spacing: .3px; border: 1px solid currentColor; opacity: .85; }
.src-photoshop { color: #31a8ff; } .src-procreate { color: #c7c7d1; } .src-csp { color: #f5b041; } .src-fa { color: var(--accent); } .src-other { color: var(--muted); }
.cats.srcs .chip.active { background: var(--accentBg); }
#btnBrushSources.active { color: var(--accent); }
.badge.cost { margin-inline-start: 6px; font-size: 10px; padding: 0 6px; border-radius: 4px; }
.badge.cost.heavy { color: #e8a23a; border: 1px solid #e8a23a; }
.badge.cost.veryHeavy { color: #ff5d5d; border: 1px solid #ff5d5d; }
.costask h3 { margin: 0 0 8px; }

/* ---- 1.15 welcome (src/ui/welcome.js): frosted-glass window with the owner's illustrations ----
   Always the dark look: the illustrations are painted on dark paper (#181b20). The picture's art sits on the left and
   fades into the glass; the text and buttons sit on the glass on the right (physical sides, in both languages). */
#dlg.welcome-mode { background: rgba(20, 23, 28, .58); -webkit-backdrop-filter: blur(24px) saturate(1.35); backdrop-filter: blur(24px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, .10); border-radius: 20px; max-width: min(92vw, 780px); overflow: hidden; color: #e6e9ee;
  box-shadow: 0 36px 90px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .07); }
#dlg.welcome-mode::backdrop { background: rgba(6, 8, 11, .38); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
#dlg.welcome-mode .dlg { min-width: 0 !important; max-height: none; }
#dlg.welcome-mode .dlg > header { display: none; }
#dlg.welcome-mode .dlg .dbody { padding: 0; overflow: hidden; }
.wl { position: relative; width: min(780px, 92vw); aspect-ratio: 3 / 2; max-height: 86vh; user-select: none; }
.wl-art { position: absolute; inset: 0; }
.wl-art img { position: absolute; left: 0; top: 5%; width: 90%; height: 90%; object-fit: cover; object-position: left center; opacity: 0; transform: scale(1.025);
  transform-origin: left center; transition: opacity .5s ease, transform .9s cubic-bezier(.2, .7, .2, 1);
  /* the art (left ~65% of each picture) ends before the text column; every edge fades into the glass */
  -webkit-mask-image: linear-gradient(to right, #000 55%, rgba(0, 0, 0, .5) 68%, transparent 82%), linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, #000 55%, rgba(0, 0, 0, .5) 68%, transparent 82%), linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-composite: intersect; }
.wl-art img.on { opacity: 1; transform: none; }
.wl-text { position: absolute; right: 30px; top: 46px; bottom: 86px; width: 35%; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: start; }
.wl-text h2 { margin: 0; font-size: 30px; line-height: 1.3; font-weight: 800; color: #fff; text-wrap: balance; text-shadow: 0 2px 18px rgba(0, 0, 0, .35); }
.wl-text p { margin: 0; font-size: 15.5px; line-height: 1.85; color: #c9d0d8; }
.wl-text ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.wl-text li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; line-height: 1.6; color: #dfe4ea;
  padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .07); }
.wl-text kbd { margin-inline-start: auto; font: 600 12px/1 ui-monospace, Consolas, monospace; padding: 5px 8px; border-radius: 7px; color: #bfeefa;
  background: rgba(92, 200, 224, .12); border: 1px solid rgba(92, 200, 224, .35); }
.wl-text .wl-note { font-size: 13px; color: #98a2ae; }
.wl-text.swap { animation: wl-in .45s cubic-bezier(.2, .7, .2, 1); }
@keyframes wl-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wl-foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 18px 28px 22px;
  background: linear-gradient(to top, rgba(14, 16, 20, .55), transparent); border: 0; }
.wl-grow { flex: 1; }
.wl-dots { display: flex; gap: 7px; }
.wl-dots span { width: 8px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .22); transition: width .3s ease, background .3s ease; }
.wl-dots span.on { width: 22px; background: #5cc8e0; }
.wl-btn { font: inherit; font-size: 14.5px; font-weight: 600; padding: 9px 20px; border-radius: 11px; cursor: pointer; color: #e6e9ee; }
.wl-btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); }
.wl-btn.ghost:hover { background: rgba(255, 255, 255, .11); }
.wl-btn.primary { background: linear-gradient(135deg, #79d7ea, #3fa0d0); border: 0; color: #0e1a22; box-shadow: 0 8px 24px -8px rgba(92, 200, 224, .6); }
.wl-btn.primary:hover { background: linear-gradient(135deg, #79d7ea, #3fa0d0); filter: brightness(1.07); }
.wl-btn:focus-visible, .wl-x:focus-visible { outline: 2px solid #f4b63f; outline-offset: 3px; }
.wl-x { position: absolute; top: 14px; left: 14px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: #c9d0d8;
  background: rgba(20, 23, 28, .45); border: 1px solid rgba(255, 255, 255, .12); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); z-index: 2; }
.wl-x:hover { color: #fff; background: rgba(40, 45, 54, .6); }
@media (prefers-reduced-motion: reduce) { .wl-art img, .wl-dots span { transition: none; } .wl-text.swap { animation: none; } }

/* Browser build only (src/ui/webNotice.js): "trial version in the browser" card */
#webNotice { position: fixed; z-index: 9000; inset-inline: 16px; bottom: 16px; margin-inline: auto; max-width: 440px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; background: var(--glassStrong); border: 1px solid var(--glassLine); border-radius: var(--r-lg); box-shadow: var(--shadowLg); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); color: var(--text); line-height: 1.7; }
#webNotice b { font-size: 15px; }
#webNotice p { margin: 0; font-size: 13.5px; color: var(--muted); }
#webNotice .btn { align-self: flex-start; min-height: 44px; padding-inline: 18px; }

/* Blending state chip (blendState.js): top centre of the canvas, clear of the side sliders */
#blendState { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 7; display: inline-flex; align-items: center; gap: 6px;
  background: var(--accentBg); color: var(--accent); border-color: var(--accentLine); font-weight: 600; }
#blendState[hidden] { display: none; }
#blendState .ic { width: 14px; height: 14px; }
