/* FA "Studio" design system (FA 1.15 redesign, direction A: glass studio).
   Loaded after styles.css. One place for the tokens (colour, glass, radius, space, type, motion) and the shared
   components (.ib icon buttons, .btn, .chip, .seg, fields, menus, dialogs, panels, tool rail, options bar).
   It only restyles: no element, id or behaviour depends on this file, so the app still works without it.
   Rules: transitions name their properties (never `all`); nested radii follow outer = inner + padding;
   numbers that change use tabular figures; hit areas stay >= 32px in bars and >= 40px on the tool rail.
   Layout stays the grid of styles.css (the stage keeps its own cell: Tab / F and panel docking measure it). */
@import url("fonts/fonts.css");

:root, [data-theme="dark"] {
  /* brand (owner's palette) */
  --accent: #5cc8e0; --accent2: #3aa6c8; --brandA: #79d7ea; --brandB: #3fa0d0; --onAccent: #0e1a22;
  --text: #e6e9ee; --muted: #98a2ae; --faint: #6b7480;
  /* surfaces: the stage is the darkest; floating glass sits above it */
  --bg: #0f1114; --stage: #0f1114; --dot: #20242a;
  --panel: #191c21; --panel2: #1f2329; --panel3: #262b32; --line: #2c3139; --line2: #3a414b;
  --glass: rgba(25, 28, 33, .80); --glassStrong: rgba(25, 28, 33, .94); --glassLine: rgba(255, 255, 255, .08);
  --glassHi: inset 0 1px 0 rgba(255, 255, 255, .05);
  --blur: blur(18px) saturate(1.3);
  --hover: rgba(255, 255, 255, .06); --press: rgba(255, 255, 255, .10);
  --accentBg: rgba(92, 200, 224, .14); --accentLine: rgba(92, 200, 224, .5);
  --shadow: 0 14px 40px rgba(0, 0, 0, .45); --shadowLg: 0 30px 80px rgba(0, 0, 0, .55);
  /* shape + space */
  --r-xs: 6px; --r-sm: 8px; --r-md: 11px; --r-lg: 14px; --r-xl: 18px; --radius: 11px;
  --edge: 10px;
  /* type */
  --font: 'IBM Plex Sans Arabic', "Segoe UI", Tahoma, system-ui, sans-serif;
  /* motion */
  --fast: 120ms; --ease: cubic-bezier(.2, .7, .2, 1);
}
[data-theme="light"] {
  --accent: #1b8db3; --accent2: #137696; --onAccent: #ffffff;
  --text: #1b1f24; --muted: #5d6773; --faint: #8a939e;
  --bg: #dfe3e8; --stage: #dfe3e8; --dot: #cbd1d8;
  --panel: #f6f7f9; --panel2: #ffffff; --panel3: #eef1f4; --line: #d6dbe1; --line2: #c3cad3;
  --glass: rgba(250, 251, 252, .84); --glassStrong: rgba(250, 251, 252, .95); --glassLine: rgba(20, 30, 40, .10);
  --glassHi: inset 0 1px 0 rgba(255, 255, 255, .7);
  --hover: rgba(20, 30, 40, .06); --press: rgba(20, 30, 40, .10);
  --accentBg: rgba(27, 141, 179, .12); --accentLine: rgba(27, 141, 179, .5);
  --shadow: 0 14px 40px rgba(30, 40, 50, .14); --shadowLg: 0 30px 80px rgba(30, 40, 50, .22);
}

html, body { font-family: var(--font); font-size: 13px; }
button, input, select, textarea { font-family: var(--font); }
output, .num, .hudval, #statusbar span { font-variant-numeric: tabular-nums; }
::selection { background: var(--accentBg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shared components ---------- */
.ib { border-radius: var(--r-sm); transition-property: background-color, color, box-shadow, transform; transition-duration: var(--fast); transition-timing-function: var(--ease); }
.ib:hover { background: var(--hover); color: var(--text); }
.ib:active { background: var(--press); transform: scale(.96); }
.ib.active { background: var(--accentBg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accentLine); }

.btn { border-radius: var(--r-md); padding: 7px 16px; font-weight: 500; background: var(--panel3); border: 1px solid var(--line);
  transition-property: background-color, border-color, color, transform, filter; transition-duration: var(--fast); transition-timing-function: var(--ease); }
.btn:hover { background: var(--panel3); border-color: var(--line2); filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--brandA), var(--brandB)); border-color: transparent; color: var(--onAccent); font-weight: 600; box-shadow: 0 6px 18px -8px rgba(92, 200, 224, .6); }
.btn.primary:hover { background: linear-gradient(135deg, var(--brandA), var(--brandB)); filter: brightness(1.07); }
[data-theme="light"] .btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); }

.chip { border-radius: 999px; padding: 4px 11px; background: var(--panel2); transition-property: background-color, border-color, color; transition-duration: var(--fast); }
.chip:hover { background: var(--hover); }
.chip.active, .chip.on { background: var(--accentBg); border-color: var(--accentLine); color: var(--accent); }

.seg { border: 1px solid var(--line); border-radius: var(--r-md); padding: 2px; gap: 2px; background: var(--bg); overflow: visible; }
.seg button { border-radius: var(--r-sm); padding: 4px 10px; transition-property: background-color, color, box-shadow; transition-duration: var(--fast); }
.seg button + button { border-inline-start: 0; }
.seg button:hover { color: var(--text); background: var(--hover); }
.seg button.active { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }

.opt select, .field select, .field input[type="text"], .field input[type="number"], .opt input[type="number"], input.num, input.hex, input.bsearch, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 5px 8px; outline: none;
  transition-property: border-color, box-shadow; transition-duration: var(--fast); }
.opt select:focus, .field input:focus, .field select:focus, input.num:focus, input.hex:focus, input.bsearch:focus, textarea:focus { border-color: var(--accentLine); box-shadow: 0 0 0 3px var(--accentBg); }
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- shell: one dark studio floor, glass islands floating on it ----------
   The bars and docks keep their grid cells; they get an inner margin + glass so they read as floating over the
   dotted floor, which now runs behind every cell (#workspace) instead of only the stage. */
#app { grid-template-rows: 30px 54px 1fr 26px; background: var(--bg); }
#menubar { background: var(--bg); border-bottom: 0; padding-inline: 8px; }
#workspace { grid-template-columns: 66px var(--altW, 0px) minmax(0, 1fr) var(--mainW, 312px);
  background-color: var(--stage); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; }
body.panels-hidden #workspace { grid-template-columns: 66px 0 minmax(0, 1fr) 0; }
#stage { background: transparent; }
#paper { box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .04); }

/* top bar: file actions, the tool's options and the view switches as three glass groups */
#topbar { background: var(--bg); border-bottom: 0; padding: 6px 8px; gap: 8px; }
#topbar > .tgroup, #topbar > .brand { height: 42px; padding: 0 5px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
#topbar > .brand { padding: 0 10px 0 8px; margin: 0; }
#topbar > .sep { display: none; }
#topbar .ib { width: 34px; height: 34px; }
#toolOptions { height: 42px; padding: 0 12px; gap: 14px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
#toolOptions:empty { display: none; }
.opt { color: var(--muted); font-size: 12px; gap: 8px; }
.opt input[type="range"] { width: 110px; }
.brushchip { height: 32px; padding: 3px 12px 3px 8px; border-radius: var(--r-md); border-color: var(--accentLine); background: var(--accentBg); font-weight: 600; max-width: 220px; }
.rbrush { width: 50px; height: 28px; border-radius: var(--r-sm); background: var(--bg); }

/* tool rail: a glass column with grouped tools, the pen sliders and the colour pair */
#toolbar { margin: 8px 8px 8px 6px; padding: 8px 0; gap: 6px; border-radius: var(--r-xl); background: var(--glass); border: 1px solid var(--glassLine);
  border-inline-end: 1px solid var(--glassLine); box-shadow: var(--glassHi), var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); scrollbar-width: none; }
#tools { gap: 4px; }
#tools .ib { width: 40px; height: 40px; border-radius: var(--r-md); }
#tools .ib .ic { width: 20px; height: 20px; }
#tools .tsep { height: 1px; width: 26px; margin: 5px auto; background: var(--glassLine); }
.quick { margin-top: 8px; padding: 10px 0; width: 40px; gap: 10px; border-radius: 20px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.vslider input { height: 104px; }
.vslider output { color: var(--muted); font-size: 10.5px; }
.vslider input:disabled + output { opacity: .4; }
.swatchpair { width: 42px; height: 42px; margin-bottom: 6px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line2); transition-property: transform; transition-duration: var(--fast); }
.sw:hover { transform: scale(1.06); }
.sw.cur { box-shadow: 0 0 0 1px var(--line2), 0 0 0 3px var(--accentBg); }

/* docks: glass cards with soft section rules */
.dock { background: transparent; }
.dock.main, .dock.alt { border: 0; }
/* the card is drawn inside the dock's own box (transparent border = the gap), so the dock keeps its exact grid width:
   panel resizing / docking measure it (narrowest 200 px). No blur here: the docks sit on the floor, not on the art. */
#panels:not(.empty), #dockAlt:not(.empty) { border: 8px solid transparent; border-radius: calc(var(--r-xl) + 8px); background: var(--glassStrong);
  background-clip: padding-box; box-shadow: inset 0 0 0 1px var(--glassLine), var(--glassHi); }
#panels:not(.empty) { border-inline-start-width: 6px; }
.panel { border-bottom: 1px solid var(--glassLine); }
.phead { padding: 11px 12px 9px; font-size: 13px; letter-spacing: 0; color: var(--text); gap: 8px; }
.phead > span { font-weight: 600; }
.pcollapse { color: var(--faint); border-radius: var(--r-xs); }
.pcollapse:hover { color: var(--text); background: var(--hover); }
.pbody { padding: 0 12px 12px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }

/* view controls + status */
#viewHud { bottom: 14px; padding: 4px 6px; gap: 2px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.hudval { border-radius: var(--r-xs); }
.hudval:hover { background: var(--hover); }
.hsep { background: var(--glassLine); }
#statusbar { background: var(--bg); border-top: 1px solid rgba(255, 255, 255, .04); color: var(--faint); font-size: 11.5px; gap: 16px; }
#zenExit { background: var(--glass); border: 1px solid var(--glassLine); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: var(--r-md); }
#diagPanel { background: var(--glassStrong); border-color: var(--glassLine); border-radius: var(--r-lg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }

/* pen sliders: a slim glass capsule on the canvas edge, next to the rail (moved here by main.js setupQuick) */
.pen-quick { position: absolute; top: 96px; right: 10px; z-index: 6; margin: 0; width: 40px; padding: 12px 0; gap: 10px;
  border-radius: 20px; background: var(--glass); border: 1px solid var(--glassLine); box-shadow: var(--glassHi), var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); direction: rtl; }
body.zen .pen-quick { display: none; }
/* short windows: the rail's 18 tools must fit without scrolling */
@media (max-height: 1000px) {
  #tools { gap: 2px; }
  #tools .ib { width: 36px; height: 36px; }
  #tools .tsep { margin: 3px auto; }
  #toolbar { padding: 6px 0; }
}
@media (max-height: 820px) {
  #tools .ib { width: 32px; height: 32px; }
  #tools .ib .ic { width: 18px; height: 18px; }
}

/* ---------- panel contents ---------- */
/* brushes: categories wrap (two lines max, then scroll), rows are cards with a wide preview */
.cats { flex-wrap: wrap; overflow: hidden auto; max-height: 62px; gap: 6px; padding-bottom: 8px; }
.cats.srcs { max-height: none; }
input.bsearch { width: 100%; margin-bottom: 8px; }
.blist { gap: 6px; }
.brow { padding: 8px 10px; border-radius: var(--r-md); background: var(--panel2); border: 1px solid var(--line);
  transition-property: background-color, border-color; transition-duration: var(--fast); }
.brow:hover { background: var(--panel3); }
.brow.active { background: var(--accentBg); border-color: var(--accentLine); }
.brow .bname { font-size: 12.5px; }
.brow.active .bname { font-weight: 600; }
.brow canvas { height: 38px; }
.brow .bbtns .ib { width: 26px; height: 24px; }
/* colour: bigger picker, numbers folded (colorPanel.js numbersBox) */
#svBox { height: 136px; border-radius: var(--r-md); }
#hueBar { border-radius: var(--r-md); }
.cwrap { grid-template-columns: 1fr 16px; gap: 10px; }
.crow { gap: 8px; margin-top: 10px; }
.crow input { background: var(--bg); border-radius: var(--r-xs); padding: 5px; }
.cpair { height: 34px; flex-basis: 84px; border-radius: var(--r-md); }
.cnums { margin-top: 10px; border-radius: var(--r-md); border: 1px solid var(--line); }
.cnums-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; color: var(--muted); font-size: 12px; text-align: start; border-radius: var(--r-md); }
.cnums-toggle:hover { color: var(--text); background: var(--hover); }
.cnums-toggle .ic { width: 13px; height: 13px; transition-property: transform; transition-duration: var(--fast); }
.cnums-toggle .ic { transform: rotate(-90deg); }
[dir="rtl"] .cnums-toggle .ic { transform: rotate(90deg); }
.cnums.open .cnums-toggle .ic { transform: none; } /* closed: points to the text; open: down */
.cnums-body { display: none; padding: 0 10px 10px; }
.cnums.open .cnums-body { display: block; }
.cnums-body .crow:first-child { margin-top: 2px; }
.swatches { gap: 6px; margin-top: 8px; }
.swatches button { width: 24px; height: 24px; border-radius: var(--r-xs); transition-property: transform; transition-duration: var(--fast); }
.subhead { margin-top: 14px; font-size: 11.5px; color: var(--muted); }
/* layers: larger thumbnails, roomier rows */
.lbar { padding: 2px; border-radius: var(--r-md); background: var(--bg); margin-bottom: 8px; }
.lbar .ib { height: 30px; border-radius: var(--r-sm); }
.llist { gap: 4px; }
.lrow { grid-template-columns: 28px 52px minmax(0, 1fr) auto; gap: 8px; padding: 5px 6px; border-radius: var(--r-md);
  transition-property: background-color, border-color; transition-duration: var(--fast); }
.lrow:hover { background: var(--hover); }
.lrow .thumb { width: 52px; height: 38px; border-radius: var(--r-xs); }
.lrow .gicon { width: 52px; height: 38px; }
.lrow .lname { font-size: 12.5px; }
.lrow.active .lname { font-weight: 600; }
.lrow .lname small { font-size: 10.5px; margin-top: 1px; }
.lprops { border-top-color: var(--glassLine); padding-top: 10px; margin-top: 8px; gap: 8px; }

/* ---------- smart selection: the object bar (smartSelect.js renderObjBar) ---------- */
.objbar { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); z-index: 7; direction: rtl; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-xl); background: var(--glassStrong); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); white-space: nowrap;
  animation: objbar-in 160ms var(--ease); }
[dir="ltr"] .objbar { direction: ltr; }
@keyframes objbar-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.objbar .seg button { padding: 6px 14px; font-size: 13px; }
.objbar .seg button.active { background: var(--accent); color: var(--onAccent); box-shadow: none; font-weight: 600; }
.objbar-hint { color: var(--faint); font-size: 11.5px; padding: 0 4px; }
.objbar .btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; }
.objbar .btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.objbar .btn.quiet:hover { color: var(--text); background: var(--hover); }
.objbar kbd { font: 600 10.5px/1 var(--font); padding: 3px 6px; border-radius: 5px; background: rgba(0, 0, 0, .18); color: inherit; opacity: .8; }
.objbar .btn.quiet kbd { background: var(--hover); }
.objbar-busy { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); padding: 0 6px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .objbar { animation: none; } .spin { animation-duration: 2s; } }
body.zen .objbar { display: none; }

/* ---------- windows: dialogs, menus, tooltips, toasts, home ---------- */
dialog:not(.welcome-mode) { background: var(--glassStrong); border: 1px solid var(--glassLine); border-radius: var(--r-xl);
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
dialog:not(.welcome-mode)[open] { animation: dlg-in 160ms var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(6, 8, 11, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.light::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; }
.dlg > header { padding: 16px 20px 8px; font-size: 16px; font-weight: 700; text-wrap: balance; }
.dlg .dbody { padding: 6px 20px 14px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.dlg > footer { padding: 12px 20px 16px; border-top-color: var(--glassLine); gap: 10px; }
.field { gap: 6px; margin: 12px 0; font-size: 12px; }
.note { color: var(--muted); text-wrap: pretty; }
.kbdlist kbd, .menuitem .mkey, #tooltip kbd { font-family: var(--font); font-variant-numeric: tabular-nums; }
.kbdlist kbd { background: var(--bg); border-color: var(--line2); }
.recent { border-radius: var(--r-md); background: var(--panel2); transition-property: border-color, background-color; transition-duration: var(--fast); }
.curve { background: var(--bg); border-radius: var(--r-md); }

/* menus */
#menubar #btnHome { border-radius: var(--r-xs); }
.menubtn { border-radius: var(--r-xs); padding: 4px 10px; font-size: 12.5px; transition-property: background-color, color; transition-duration: var(--fast); }
.menubtn:hover, .menubtn.open, .menubtn:focus-visible { background: var(--hover); color: var(--text); }
.menulist { padding: 5px; border-radius: var(--r-lg); background: var(--glassStrong); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: menu-in 110ms var(--ease); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menuitem { padding: 7px 10px; border-radius: var(--r-sm); font-size: 13px; }
.menuitem:hover:not(:disabled), .menuitem:focus-visible, .menuitem.hassub.open { background: var(--accentBg); color: var(--text); }
.menuitem .mkey { color: var(--faint); font-size: 11.5px; direction: ltr; }
.menusep { background: var(--glassLine); margin: 5px 8px; }

/* tooltip + toast */
#tooltip { padding: 6px 10px; border-radius: var(--r-sm); background: rgba(11, 13, 16, .94); border: 1px solid rgba(255, 255, 255, .08); font-size: 12px; font-weight: 500; }
#tooltip kbd { background: rgba(92, 200, 224, .14); color: #a9e6f3; border-radius: 4px; padding: 1px 6px; }
#toast { bottom: 44px; padding: 10px 18px; border-radius: var(--r-lg); background: var(--glassStrong); border: 1px solid var(--glassLine); font-weight: 500;
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: toast-in 180ms var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
#toast.error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
#toast.warn { border-color: color-mix(in srgb, var(--warn) 60%, transparent); }
#stSave.saved { color: var(--ok); }
#stSave.unsaved { color: var(--warn); }

/* home */
#home { inset: 30px 0 0 0; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; }
.homeinner { padding: 36px 28px 48px; }
.homehead h1 { font-size: 26px; font-weight: 700; text-wrap: balance; }
.homeactions { gap: 12px; margin-bottom: 26px; }
.homebtn { padding: 16px 22px; border-radius: var(--r-lg); background: var(--glassStrong); border-color: var(--glassLine); font-weight: 600;
  transition-property: border-color, background-color, transform; transition-duration: var(--fast); }
.homebtn:hover { border-color: var(--line2); transform: translateY(-1px); }
.homebtn.primary { background: linear-gradient(135deg, var(--brandA), var(--brandB)); color: var(--onAccent); border-color: transparent; box-shadow: 0 10px 30px -12px rgba(92, 200, 224, .6); }
[data-theme="light"] .homebtn.primary { background: var(--accent); color: #fff; }
.homerecover { border-radius: var(--r-lg); background: var(--glassStrong); }
.homerecenthead h2 { font-size: 16px; font-weight: 700; }
.homerecenthead input { background: var(--glassStrong); border-radius: var(--r-md); padding: 8px 12px; }
.homegrid { gap: 16px; }
.homecard { border-radius: var(--r-lg); background: var(--glassStrong); border-color: var(--glassLine); transition-property: border-color, transform, box-shadow; transition-duration: var(--fast); }
.homecard:hover, .homecard:focus-visible { border-color: var(--accentLine); transform: translateY(-2px); box-shadow: var(--shadow); }
.homecard img, .homecard .nothumb { height: 140px; background: var(--panel2); }
.homecardinfo { padding: 10px 12px; }
.homecardacts .ib { background: var(--glassStrong); }

/* liquify panel, dialog close button focus */
.lqpanel { border-radius: var(--r-xl); background: var(--glassStrong); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.dlg > header .ib:focus-visible { outline: 1px solid var(--line2); outline-offset: 0; } /* the dialog focuses it on open: no loud ring */

/* ---------- smaller windows: the canvas and the tool's options keep priority ---------- */
#toolOptions { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#toolOptions::-webkit-scrollbar { display: none; }
#toolOptions > * { flex-shrink: 0; }
.brushchip { flex-shrink: 0; min-width: 120px; }
@media (max-width: 1500px) {
  #btnRecent, #btnSaveAs, #btnImport { display: none; } /* still in the File menu */
  #topbar > .brand b { display: none; }
}
@media (max-width: 1300px) {
  #btnDiag, #btnFull, #btnPanels { display: none; } /* Window / View menus, Tab, F11 */
  .opt input[type="range"] { width: 84px; }
  #toolOptions { gap: 10px; }
}
@media (max-height: 760px) {
  #tools { gap: 1px; }
  #tools .ib { width: 30px; height: 30px; border-radius: var(--r-sm); }
  #tools .ib .ic { width: 17px; height: 17px; }
  #tools .tsep { margin: 2px auto; }
  .swatchpair { width: 36px; height: 36px; }
  .sw { width: 24px; height: 24px; }
  .pen-quick { top: 70px; }
  .vslider input { height: 84px; }
}
#btnLang { padding: 0 10px; margin-inline: 2px; }

/* floating panels (dragged out of a dock, or opened from the Window menu) */
.floatwin { border-radius: var(--r-xl); background: var(--glassStrong); border: 1px solid var(--glassLine); overflow: hidden;
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.floatwin .panel { border-bottom: 0; }
.tabbar { gap: 2px; padding: 6px 8px 0; }
.ptab { border-radius: var(--r-sm) var(--r-sm) 0 0; padding: 6px 12px; font-weight: 600; color: var(--muted); transition-property: background-color, color; transition-duration: var(--fast); }
.ptab:hover { color: var(--text); background: var(--hover); }
.ptab.active { color: var(--text); background: var(--panel3); }
.hsplit, .vsplit { transition-property: background-color; transition-duration: var(--fast); }
.hsplit:hover, .vsplit:hover { background: var(--accentLine); }

/* ---------- audit pass: one field style everywhere, glass for every floating overlay ---------- */
input[type="text"], input[type="number"], input[type="search"], input:not([type]), select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--text);
  transition-property: border-color, box-shadow; transition-duration: var(--fast); }
input[type="text"]:focus, input[type="number"]:focus, input[type="search"]:focus, input:not([type]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accentLine); box-shadow: 0 0 0 3px var(--accentBg); }
.crow input { background: var(--bg); }
.lrow input.rename { background: var(--bg); border-color: var(--accentLine); border-radius: var(--r-xs); }
.sizehud, .colorwheel, .bpop, .dragghost, .qmenu .qitem {
  background: var(--glassStrong); border: 1px solid var(--glassLine); box-shadow: var(--glassHi), var(--shadowLg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.sizehud { border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.colorwheel { border-radius: 20px; }
.bpop { border-radius: var(--r-lg); }
.dragghost { border-radius: var(--r-md); border-color: var(--accentLine); }
.qmenu .qitem { transition-property: background-color, color, transform; transition-duration: var(--fast); }
.qmenu .qitem:hover, .qmenu .qitem.hot { background: var(--accent); color: var(--onAccent); }
.tabbar { background: transparent; border-bottom-color: var(--glassLine); }
.lqtools { background: var(--bg); border-radius: var(--r-md); }
.previewbox, .curve, .curveed, .irowmain canvas, .nopv, .recent img { background: var(--bg); border-radius: var(--r-md); }
.scmsg { background: var(--bg); border-radius: var(--r-md); }
.refcmp figure { background: var(--panel2); border-radius: var(--r-md); }
/* how-to hints in the options bar: a small (?) — the sentence is in its tooltip (main.js hintButton) */
.opthint { width: 28px; height: 28px; color: var(--faint); border: 1px dashed var(--line2); border-radius: 50%; }
.opthint:hover { color: var(--accent); border-color: var(--accentLine); background: var(--accentBg); }
#tooltip { white-space: normal; max-width: min(420px, 80vw); line-height: 1.6; }

/* ---------- performance rule (measured): no backdrop blur over a canvas that redraws ----------
   A blurred element over the drawing is re-blurred every frame the drawing changes: Face Liquify's live preview lost
   ~20 ms a frame under the glass Liquify panel. Everything that floats over the stage uses the same glass at a higher
   opacity instead (looks the same on the dark floor). Blur stays only where the drawing is still: dialogs, menus. */
.lqpanel, .objbar, .pen-quick, #viewHud, .floatwin, .colorwheel, .bpop, .sizehud, .qmenu .qitem, #zenExit, #diagPanel,
#topbar > .tgroup, #topbar > .brand, #toolOptions, #toolbar, #toast {
  -webkit-backdrop-filter: none; backdrop-filter: none; }
.pen-quick, #viewHud, .objbar, .lqpanel, .floatwin { background: var(--glassStrong); }

/* ---------- owner's review (10 Oct): overlaps + selection modes the Photoshop way ---------- */
/* the language button holds a word: it must not be squeezed into a 34 px icon slot (it overlapped the next icon) */
#topbar .ib.lang { width: auto; min-width: 34px; padding: 0 10px; }
/* two full rows of categories (the second row was cut under the first brush card), then the rows scroll */
.cats:not(.srcs) { max-height: 76px; padding-bottom: 6px; scrollbar-width: thin; }
.cats .chip { line-height: 1.4; }

/* selection modes: icon + name; the chosen one in brand colour; the one a held key asks for lights up */
.selmodes button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; }
.selmodes .smic { display: inline-grid; width: 16px; height: 16px; }
.selmodes button.active { background: var(--accentBg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accentLine); }
body.selmod-add .selmodes .selmode-add, body.selmod-subtract .selmodes .selmode-subtract, body.selmod-intersect .selmodes .selmode-intersect {
  background: var(--accent); color: var(--onAccent); box-shadow: none; }
/* the cursor tells the next drag's mode: + add (Shift), − subtract (Alt), × intersect (Shift+Alt) */
body.selmod-add #stage.tool-select { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><path d='M10 1v18M1 10h18' stroke='%23000' stroke-width='3'/><path d='M10 1v18M1 10h18' stroke='%23fff' stroke-width='1.2'/><circle cx='22' cy='22' r='7' fill='%235cc8e0' stroke='%23000'/><path d='M22 18v8M18 22h8' stroke='%230e1a22' stroke-width='2'/></svg>") 10 10, crosshair; }
body.selmod-subtract #stage.tool-select { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><path d='M10 1v18M1 10h18' stroke='%23000' stroke-width='3'/><path d='M10 1v18M1 10h18' stroke='%23fff' stroke-width='1.2'/><circle cx='22' cy='22' r='7' fill='%23e57373' stroke='%23000'/><path d='M18 22h8' stroke='%23200a0a' stroke-width='2'/></svg>") 10 10, crosshair; }
body.selmod-intersect #stage.tool-select { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><path d='M10 1v18M1 10h18' stroke='%23000' stroke-width='3'/><path d='M10 1v18M1 10h18' stroke='%23fff' stroke-width='1.2'/><circle cx='22' cy='22' r='7' fill='%23f4b63f' stroke='%23000'/><path d='M19 19l6 6M25 19l-6 6' stroke='%231a1405' stroke-width='2'/></svg>") 10 10, crosshair; }
/* a selection edge that reads on any colour: white line + black marching ants, both thicker */
#selOutline path, #selOutline rect, #selOutline polyline, #selOutline polygon { stroke-width: 1.6; }
#selOutline .ants { stroke: #0b0d10; stroke-width: 1.6; stroke-dasharray: 6 5; }
/* exact chip height so the box shows two whole rows and nothing of a third (28 + 6 + 28; + 6 px breathing room) */
.cats .chip { height: 28px; line-height: 26px; padding-block: 0; }
.cats:not(.srcs) { max-height: 68px; padding-bottom: 6px; }

/* ---------- tool groups (toolFlyout.js) + tool descriptions ---------- */
/* a small corner triangle: this rail button holds a group (right-click / hold) — like Photoshop */
#tools .ib.has-flyout::after { content: ""; position: absolute; bottom: 4px; inset-inline-start: 4px; width: 0; height: 0;
  border-style: solid; border-width: 0 0 5px 5px; border-color: transparent transparent currentColor transparent; opacity: .55; }
[dir="rtl"] #tools .ib.has-flyout::after { border-width: 0 5px 5px 0; border-color: transparent currentColor currentColor transparent; border-color: transparent transparent currentColor transparent; transform: scaleX(-1); }
.toolflyout { position: fixed; z-index: 130; min-width: 190px; padding: 6px; border-radius: var(--r-lg); background: var(--glassStrong); border: 1px solid var(--glassLine);
  box-shadow: var(--glassHi), var(--shadowLg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: menu-in 110ms var(--ease); }
.tfhead { padding: 4px 10px 6px; font-size: 11px; color: var(--faint); }
.tfitem { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); text-align: start; color: var(--text);
  transition-property: background-color; transition-duration: var(--fast); }
.tfitem:hover, .tfitem:focus-visible { background: var(--hover); outline: none; }
.tfitem.on { background: var(--accentBg); color: var(--accent); }
.tfitem .tfic .ic { width: 20px; height: 20px; }
.tfitem kbd { font: 600 11px/1 var(--font); color: var(--faint); }
/* tooltip: name + key on the first line, what the tool does on a quieter second line */
#tooltip .tipdesc { margin-top: 3px; font-size: 11.5px; font-weight: 400; color: #aab3bd; }
#tools .ib.has-flyout::after, [dir="rtl"] #tools .ib.has-flyout::after { border: 0; transform: none; width: 6px; height: 6px; bottom: 4px; right: 4px; left: auto; inset-inline-start: auto;
  background: currentColor; clip-path: polygon(100% 0, 100% 100%, 0 100%); opacity: .6; }

/* ---- Resolution + orientation (New canvas / Image size) ---- */
.dlg .sizerow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.dlg .dpirow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dlg .dpirow .chip { min-width: 44px; justify-content: center; font-variant-numeric: tabular-nums; }
.dlg .orientseg button { width: 38px; padding: 0; display: inline-grid; place-items: center; }
.dlg .printsize { color: var(--accent); margin-top: 2px; font-variant-numeric: tabular-nums; }
.dlg .resamplechk .check { font-size: 12px; opacity: .9; }
