/* Pixelfish - image editor theme (matches the GameDB platform: near-black greys, orange accent) */
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --bg1: #101012;
  --bg2: #151517;
  --bg3: #1b1b1e;
  --bg4: #222226;
  --bg5: #2b2b30;
  --bg6: #36363c;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .12);
  --line3: rgba(255, 255, 255, .22);
  --text: #e8e8ea;
  --text2: #c8c8cc;
  --dim: #9c9ca3;
  --muted: #6e6e75;
  --accent: #ff5707;
  --accent2: #ff7a3d;
  --accent-soft: rgba(255, 87, 7, .15);
  --accent-line: rgba(255, 87, 7, .55);
  --on-accent: #140800;
  --green: #2fcf7c;
  --red: #ff3b6b;
  --blue: #4b8dff;
  --yellow: #ffd23f;
  --pasteboard: #1e1e21;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .06);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --menubar-h: 32px;
  --options-h: 40px;
  --status-h: 24px;
  --toolbar-w: 46px;
  --dock-w: 300px;
  --tabs-h: 30px;
  --ruler: 18px;
}
:root[data-theme="gray"] {
  --bg: #262628; --bg1: #2c2c2f; --bg2: #323235; --bg3: #38383c; --bg4: #3f3f44; --bg5: #48484e; --bg6: #55555c;
  --pasteboard: #3a3a3e; --dim: #b0b0b6; --muted: #85858c;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #d8d8db; --bg1: #e4e4e7; --bg2: #ececee; --bg3: #f4f4f5; --bg4: #fafafa; --bg5: #ffffff; --bg6: #e0e0e4;
  --line: rgba(0, 0, 0, .08); --line2: rgba(0, 0, 0, .14); --line3: rgba(0, 0, 0, .26);
  --text: #18181b; --text2: #2c2c31; --dim: #55555c; --muted: #808088; --pasteboard: #bdbdc2;
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, .35), 0 0 0 1px rgba(0, 0, 0, .1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 12px/1.35 var(--font); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; user-select: none; touch-action: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea { user-select: text; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
a { color: var(--accent2); }
.icon { flex: none; display: block; }
.hidden { display: none !important; }
kbd { font: 11px var(--mono); color: var(--dim); background: var(--bg4); border: 1px solid var(--line2); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg6); border-radius: 10px; border: 2px solid var(--bg2); }
::-webkit-scrollbar-corner { background: transparent; }

/* ------------------------------------------------------------------ boot */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 35%, #1b0e06 0%, var(--bg) 62%); z-index: 1000; transition: opacity .35s; }
.boot.out { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.boot-logo { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #ff3d00, #ff5707 55%, #ff9a1f); box-shadow: 0 0 60px rgba(255, 87, 7, .35); }
.boot h1 { margin: 0 0 6px; font: 600 24px var(--font); letter-spacing: .02em; }
.boot p { margin: 0; color: var(--dim); }
.boot-bar { width: 220px; height: 3px; margin: 20px auto 0; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 3px; animation: bootbar 1.1s ease-in-out infinite; }
@keyframes bootbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(330%); } }

/* ------------------------------------------------------------------ layout */
#app { display: grid; grid-template-rows: var(--menubar-h) var(--options-h) minmax(0, 1fr) var(--status-h); height: 100vh; height: 100dvh; }
#app.no-options { grid-template-rows: var(--menubar-h) 0 minmax(0, 1fr) var(--status-h); }
#app.no-options .optionsbar { display: none; }
.workspace { display: grid; grid-template-columns: var(--toolbar-w) minmax(0, 1fr) 5px var(--dock-w); min-height: 0; }
.workspace.no-dock { grid-template-columns: var(--toolbar-w) minmax(0, 1fr) 0 0; }
.workspace.no-dock .dock, .workspace.no-dock .dock-resizer { display: none; }
.workspace.no-tools { grid-template-columns: 0 minmax(0, 1fr) 5px var(--dock-w); }
.workspace.no-tools .toolbar { display: none; }
.workspace.no-tools.no-dock { grid-template-columns: 0 minmax(0, 1fr) 0 0; }
.center { display: grid; grid-template-rows: var(--tabs-h) minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--pasteboard); }
.dock-resizer { background: var(--bg); cursor: col-resize; position: relative; }
.dock-resizer::after { content: ""; position: absolute; inset: 0 1px; transition: background .12s; }
.dock-resizer:hover::after, .dock-resizer.active::after { background: var(--accent-line); }

/* ------------------------------------------------------------------ menu bar */
.menubar { display: flex; align-items: center; gap: 2px; padding: 0 8px 0 6px; background: var(--bg1); border-bottom: 1px solid var(--line); min-width: 0; }
.menubar .brand { display: flex; align-items: center; gap: 7px; padding: 0 10px 0 4px; font-weight: 650; letter-spacing: .02em; color: var(--text); white-space: nowrap; }
.menubar .brand .mark { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #ff3d00, #ff5707 55%, #ff9a1f); }
.menubar .menus { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.menubar .menu-top { height: 26px; padding: 0 9px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text2); white-space: nowrap; }
.menubar .menu-top:hover, .menubar .menu-top.open { background: var(--bg4); color: var(--text); }
.menubar .spacer { flex: 1; }
.menubar .doc-title { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; padding: 0 10px; }
.top-btn { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border: 1px solid var(--line2); border-radius: var(--radius-sm); background: var(--bg3); color: var(--text2); text-decoration: none; white-space: nowrap; }
.top-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ------------------------------------------------------------------ menus */
.menu { position: fixed; z-index: 500; min-width: 210px; max-height: calc(100vh - 12px); overflow-y: auto; padding: 5px; background: var(--bg3); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu-item { display: flex; align-items: center; gap: 6px; width: 100%; height: 26px; padding: 0 8px 0 4px; border: 0; border-radius: 4px; background: transparent; text-align: left; color: var(--text); white-space: nowrap; }
.menu-item:hover:not(.disabled), .menu-item.open { background: var(--accent); color: var(--on-accent); }
.menu-item:hover:not(.disabled) .menu-key, .menu-item.open .menu-key { color: var(--on-accent); }
.menu-item.disabled { color: var(--muted); cursor: default; }
.menu-item.danger { color: var(--red); }
.menu-check { width: 18px; display: grid; place-items: center; color: inherit; }
.menu-label { flex: 1; }
.menu-key { color: var(--muted); font-size: 11px; padding-left: 18px; }
.menu-arrow { opacity: .8; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line2); }
.menu-header { padding: 6px 10px 3px 26px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--radius-sm); background: var(--bg4); color: var(--text); white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--bg5); border-color: var(--line3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); }
.btn.danger { color: var(--red); }
.btn.small { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text2); }
.icon-btn:hover:not(:disabled) { background: var(--bg5); color: var(--text); }
.icon-btn.on, .icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent2); border-color: var(--accent-line); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.small { width: 22px; height: 22px; }
.input, select.input { height: 24px; padding: 0 6px; border: 1px solid var(--line2); border-radius: var(--radius-sm); background: var(--bg1); color: var(--text); min-width: 0; }
.input:focus { border-color: var(--accent-line); }
textarea.input { height: auto; padding: 6px; resize: vertical; }
select.input { padding-right: 18px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 9px) 50%, calc(100% - 5px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
select.input option { background: var(--bg3); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; color: var(--text2); }
.check input { accent-color: var(--accent); margin: 0; }
.num { display: inline-flex; align-items: center; height: 24px; border: 1px solid var(--line2); border-radius: var(--radius-sm); background: var(--bg1); overflow: hidden; }
.num:focus-within { border-color: var(--accent-line); }
.num .num-label { padding: 0 6px; color: var(--dim); cursor: ew-resize; white-space: nowrap; height: 100%; display: flex; align-items: center; background: var(--bg3); border-right: 1px solid var(--line); }
.num input { width: 48px; height: 100%; border: 0; background: transparent; padding: 0 5px; text-align: right; }
.num .num-unit { padding-right: 6px; color: var(--muted); font-size: 11px; }
.num .num-drop { width: 18px; height: 100%; border: 0; border-left: 1px solid var(--line); background: var(--bg3); color: var(--dim); display: grid; place-items: center; padding: 0; }
.num .num-drop:hover { color: var(--text); background: var(--bg5); }
.range { position: relative; display: flex; align-items: center; height: 22px; cursor: pointer; touch-action: none; }
.range .track { position: relative; flex: 1; height: 4px; border-radius: 4px; background: var(--bg5); }
.range .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.range .thumb { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.range.bipolar .fill { background: var(--accent2); }
.range:hover .thumb { transform: scale(1.12); }
.slider-row { display: grid; grid-template-columns: minmax(70px, auto) 1fr 64px; align-items: center; gap: 8px; min-height: 26px; }
.slider-row > label { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider-row .num input { width: 100%; }
.slider-row .num { width: 64px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg1); }
.seg button { display: grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text2); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--bg4); }
.seg button.on { background: var(--accent-soft); color: var(--accent2); }
.swatch-btn { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line3); border-radius: 4px; cursor: pointer; background-image: linear-gradient(45deg, #888 25%, transparent 25%), linear-gradient(-45deg, #888 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #888 75%), linear-gradient(-45deg, transparent 75%, #888 75%); background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0; position: relative; overflow: hidden; }
.swatch-btn i { position: absolute; inset: 0; }
.angle-dial { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line3); background: var(--bg1); position: relative; cursor: grab; flex: none; }
.angle-dial i { position: absolute; left: 50%; top: 50%; width: 11px; height: 2px; margin-top: -1px; background: var(--accent); transform-origin: 0 50%; border-radius: 2px; }
.field { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.field > label { color: var(--dim); }
.grad-preview { height: 20px; border-radius: 4px; border: 1px solid var(--line3); cursor: pointer; position: relative; overflow: hidden; background-image: linear-gradient(45deg, #777 25%, transparent 25%), linear-gradient(-45deg, #777 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #777 75%), linear-gradient(-45deg, transparent 75%, #777 75%); background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0; }
.grad-preview i { position: absolute; inset: 0; }

/* ------------------------------------------------------------------ tooltips, toasts, popovers */
.tooltip { position: fixed; z-index: 900; pointer-events: none; padding: 5px 8px; border-radius: 5px; background: #000; color: #eee; font-size: 11.5px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); opacity: 0; transition: opacity .12s; max-width: 320px; }
.tooltip.show { opacity: 1; }
.toasts { position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 950; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; background: var(--bg4); color: var(--text); box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: min(560px, 90vw); }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left: 3px solid var(--red); }
.toast.ok { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--accent); }
.popover { position: fixed; z-index: 600; padding: 10px; border-radius: var(--radius); background: var(--bg3); box-shadow: var(--shadow); max-height: calc(100vh - 20px); overflow: auto; }

/* ------------------------------------------------------------------ options bar */
.optionsbar { display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: thin; }
.optionsbar .tool-badge { display: flex; align-items: center; gap: 6px; padding-right: 10px; border-right: 1px solid var(--line2); height: 26px; color: var(--text2); font-weight: 600; }
.optionsbar .sep { width: 1px; height: 22px; background: var(--line2); flex: none; }
.optionsbar .hint { color: var(--muted); font-style: italic; }
.optionsbar .field select.input { max-width: 170px; }

/* ------------------------------------------------------------------ toolbar */
.toolbar { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; background: var(--bg2); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.tool-btn { position: relative; display: grid; place-items: center; width: 36px; height: 32px; flex: none; border: 0; border-radius: 6px; background: transparent; color: var(--text2); }
.tool-btn:hover { background: var(--bg4); color: var(--text); }
.tool-btn.on { background: var(--accent); color: var(--on-accent); }
.tool-btn.group::after { content: ""; position: absolute; right: 3px; bottom: 3px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .55; }
.toolbar .tsep { width: 26px; height: 1px; margin: 4px 0; background: var(--line2); flex: none; }
.colors { position: relative; width: 38px; height: 40px; margin: 6px 0 2px; flex: none; }
.colors .fg, .colors .bg { position: absolute; width: 24px; height: 24px; border-radius: 4px; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line3); cursor: pointer; }
.colors .fg { left: 0; top: 0; z-index: 1; }
.colors .bg { right: 0; bottom: 0; }
.colors .mini { position: absolute; width: 14px; height: 14px; padding: 0; border: 0; background: transparent; color: var(--dim); display: grid; place-items: center; }
.colors .mini:hover { color: var(--text); }
.colors .swap { right: -1px; top: -1px; }
.colors .reset { left: -1px; bottom: -1px; }
.flyout { position: fixed; z-index: 520; padding: 5px; border-radius: var(--radius); background: var(--bg3); box-shadow: var(--shadow); min-width: 210px; }
.flyout button { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; color: var(--text); text-align: left; }
.flyout button:hover { background: var(--bg5); }
.flyout button.on { color: var(--accent2); }
.flyout button .k { margin-left: auto; color: var(--muted); }

/* ------------------------------------------------------------------ document tabs and view */
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 6px; background: var(--bg1); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px; border-radius: 6px 6px 0 0; background: var(--bg3); color: var(--dim); cursor: pointer; white-space: nowrap; max-width: 260px; border: 1px solid transparent; border-bottom: 0; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--pasteboard); color: var(--text); border-color: var(--line2); }
.tab .name { overflow: hidden; text-overflow: ellipsis; }
.tab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tab .x { width: 18px; height: 18px; border: 0; border-radius: 4px; background: transparent; color: var(--dim); display: grid; place-items: center; padding: 0; }
.tab .x:hover { background: var(--bg6); color: var(--text); }
.tab-new { width: 24px; height: 24px; margin-bottom: 1px; border: 0; border-radius: 5px; background: transparent; color: var(--dim); display: grid; place-items: center; }
.tab-new:hover { background: var(--bg4); color: var(--text); }
.viewwrap { position: relative; overflow: hidden; min-height: 0; display: grid; grid-template-columns: var(--ruler) minmax(0, 1fr); grid-template-rows: var(--ruler) minmax(0, 1fr); }
.viewwrap.no-rulers { grid-template-columns: 0 minmax(0, 1fr); grid-template-rows: 0 minmax(0, 1fr); }
.viewwrap.no-rulers .ruler, .viewwrap.no-rulers .ruler-corner { display: none; }
.ruler-corner { background: var(--bg2); border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2); }
.ruler { background: var(--bg2); display: block; width: 100%; height: 100%; }
.ruler.h { border-bottom: 1px solid var(--line2); cursor: s-resize; }
.ruler.v { border-right: 1px solid var(--line2); cursor: e-resize; }
.view { position: relative; overflow: hidden; touch-action: none; }
.view canvas { position: absolute; left: 0; top: 0; display: block; }
.view .overlay { pointer-events: none; }
.view .text-edit { position: absolute; z-index: 5; margin: 0; padding: 0; border: 1px dashed var(--accent); background: rgba(0, 0, 0, 0); color: transparent; caret-color: var(--accent); resize: none; overflow: hidden; outline: none; white-space: pre; transform-origin: 0 0; line-height: 1.2; }
.view .text-edit.box { white-space: pre-wrap; }
.view .text-edit::selection { background: rgba(75, 141, 255, .35); }
.view.drop-target::after { content: "Drop images to open them"; position: absolute; inset: 14px; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(255, 87, 7, .08); color: var(--text); font-size: 16px; font-weight: 600; pointer-events: none; }
.view .pixel-readout { position: absolute; z-index: 6; pointer-events: none; padding: 3px 7px; border-radius: 5px; background: rgba(0, 0, 0, .78); color: #fff; font: 11px var(--mono); white-space: nowrap; }

/* ------------------------------------------------------------------ welcome page */
.welcome { position: absolute; inset: 0; overflow: auto; padding: 36px clamp(16px, 5vw, 64px); background: radial-gradient(ellipse at 20% 0%, rgba(255, 87, 7, .08), transparent 55%), var(--pasteboard); }
.welcome h1 { margin: 0 0 4px; font-size: 26px; font-weight: 650; display: flex; align-items: center; gap: 12px; }
.welcome .lead { color: var(--dim); margin: 0 0 24px; font-size: 13px; }
.welcome .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.welcome .actions .btn { height: 36px; padding: 0 16px; font-size: 13px; }
.welcome h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line2); border-radius: 10px; background: var(--bg2); cursor: pointer; text-align: left; color: var(--text); position: relative; }
.card:hover { border-color: var(--accent-line); background: var(--bg3); }
.card .thumb { aspect-ratio: 4 / 3; border-radius: 6px; background: var(--bg1) center / contain no-repeat; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.card .thumb canvas, .card .thumb img { max-width: 100%; max-height: 100%; }
.card .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--muted); font-size: 11px; }
.card .card-x { position: absolute; top: 6px; right: 6px; opacity: 0; }
.card:hover .card-x { opacity: 1; }
.preset-thumb { border: 2px solid var(--dim); border-radius: 3px; background: var(--bg4); }

/* ------------------------------------------------------------------ dock and panels */
.dock { display: flex; flex-direction: column; min-height: 0; background: var(--bg2); border-left: 1px solid var(--line); }
.pgroup { display: flex; flex-direction: column; min-height: 30px; border-bottom: 1px solid var(--line); }
.pgroup.grow { flex: 1 1 0; min-height: 120px; }
.pgroup.collapsed { flex: 0 0 auto !important; min-height: 0; }
.pgroup.collapsed .pbody { display: none; }
.ptabs { display: flex; align-items: center; gap: 1px; height: 28px; padding: 0 4px; background: var(--bg1); border-bottom: 1px solid var(--line); flex: none; overflow: hidden; }
.ptab { height: 22px; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; color: var(--dim); white-space: nowrap; font-size: 11.5px; }
.ptab:hover { color: var(--text); background: var(--bg3); }
.ptab.on { color: var(--text); background: var(--bg3); box-shadow: inset 0 -2px 0 var(--accent); }
.ptabs .grow { flex: 1; }
.pbody { flex: 1; min-height: 0; overflow: auto; position: relative; }
.pgroup-resizer { height: 5px; flex: none; cursor: row-resize; background: var(--bg); position: relative; }
.pgroup-resizer:hover, .pgroup-resizer.active { background: var(--accent-line); }
.panel { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.panel.flush { padding: 0; gap: 0; }
.panel-row { display: flex; align-items: center; gap: 6px; }
.panel-row.wrap { flex-wrap: wrap; }
.panel-foot { display: flex; align-items: center; justify-content: flex-end; gap: 2px; padding: 3px 6px; border-top: 1px solid var(--line); background: var(--bg1); position: sticky; bottom: 0; }
.panel-foot .grow { flex: 1; }
.empty { color: var(--muted); padding: 14px; text-align: center; font-style: italic; }
.section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 4px 0 0; font-weight: 600; }

/* layers */
.layers-panel { display: flex; flex-direction: column; height: 100%; }
.layers-head { display: grid; gap: 5px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.layers-head .row { display: flex; align-items: center; gap: 6px; }
.layers-head select.input { flex: 1; min-width: 0; }
.layers-head .num input { width: 34px; }
.layers-head .locks { display: flex; align-items: center; gap: 1px; }
.layers-head .locks label { color: var(--dim); margin-right: 4px; }
.layer-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 0; min-height: 40px; }
.layer { display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 6px 0 2px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.layer:hover { background: var(--bg3); }
.layer.selected { background: var(--bg5); }
.layer.active { background: rgba(255, 87, 7, .18); box-shadow: inset 2px 0 0 var(--accent); }
.layer .eye { width: 22px; height: 26px; border: 0; background: transparent; color: var(--text2); display: grid; place-items: center; padding: 0; flex: none; }
.layer .eye.off { color: var(--muted); opacity: .5; }
.layer .twist { width: 14px; height: 20px; border: 0; background: transparent; color: var(--dim); display: grid; place-items: center; padding: 0; flex: none; }
.layer .clip-arrow { width: 12px; color: var(--dim); flex: none; display: grid; place-items: center; }
.layer .thumb { width: 34px; height: 30px; flex: none; border-radius: 3px; border: 1px solid var(--line3); background-color: #fff; background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%); background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0; display: grid; place-items: center; overflow: hidden; color: #333; }
.layer .thumb canvas { display: block; max-width: 100%; max-height: 100%; }
.layer .thumb.icon-thumb { background: var(--bg4); color: var(--text2); }
.layer .thumb.target { box-shadow: 0 0 0 2px var(--accent); border-color: transparent; }
.layer .chain { width: 12px; color: var(--muted); flex: none; display: grid; place-items: center; }
.layer .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.layer .name input { width: 100%; height: 22px; }
.layer .badges { display: flex; align-items: center; gap: 2px; color: var(--dim); flex: none; }
.layer .badges .fxb { font: italic 700 11px Georgia, serif; color: var(--text2); padding: 0 3px; }
.layer.hidden-layer .name { color: var(--muted); }
.layer.drop-above::before, .layer.drop-below::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 2; }
.layer.drop-above::before { top: -1px; }
.layer.drop-below::after { bottom: -1px; }
.layer.drop-into { box-shadow: inset 0 0 0 2px var(--accent); }
.layer-fx { display: flex; align-items: center; gap: 6px; height: 22px; padding-left: 64px; color: var(--dim); font-size: 11px; cursor: pointer; }
.layer-fx:hover { color: var(--text); }
.layer-fx .eye { width: 18px; height: 18px; border: 0; background: transparent; color: inherit; padding: 0; display: grid; place-items: center; }

/* history, channels, paths, actions lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 10px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--text2); }
.list-item:hover { background: var(--bg3); color: var(--text); }
.list-item.on { background: rgba(255, 87, 7, .18); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.list-item.future { color: var(--muted); }
.list-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .thumb { width: 36px; height: 26px; border: 1px solid var(--line3); border-radius: 3px; background: #888; overflow: hidden; display: grid; place-items: center; }
.list-item .thumb canvas { max-width: 100%; max-height: 100%; }
.list-item .k { color: var(--muted); font-size: 11px; }

/* color panel */
.picker { display: grid; gap: 8px; }
.sv { position: relative; height: 150px; border-radius: 5px; cursor: crosshair; touch-action: none; overflow: hidden; }
.sv .w { position: absolute; inset: 0; background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0)); }
.sv .b { position: absolute; inset: 0; background: linear-gradient(0deg, #000, rgba(0, 0, 0, 0)); }
.sv .knob, .hue-strip .knob, .alpha-strip .knob { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(0, 0, 0, .3); pointer-events: none; }
.hue-strip { position: relative; height: 12px; border-radius: 6px; background: linear-gradient(90deg, red, #ff0, lime, cyan, blue, #f0f, red); cursor: pointer; touch-action: none; }
.hue-strip .knob { top: 50%; }
.picker .vals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.picker .vals .num input { width: 100%; }
.picker .vals .num { width: 100%; }
.picker .hexrow { display: flex; gap: 6px; align-items: center; }
.picker .hexrow .input { flex: 1; font-family: var(--mono); }
.color-compare { display: flex; height: 26px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line3); flex: none; width: 52px; }
.color-compare i { flex: 1; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(18px, 1fr)); gap: 3px; }
.swatches button { aspect-ratio: 1; border: 1px solid var(--line2); border-radius: 3px; padding: 0; min-width: 0; }
.swatches button:hover { transform: scale(1.18); border-color: #fff; z-index: 1; }
.recent-colors { display: flex; gap: 3px; flex-wrap: wrap; }
.recent-colors button { width: 16px; height: 16px; border: 1px solid var(--line2); border-radius: 3px; padding: 0; }

/* navigator, histogram, info */
.nav-view { position: relative; background: var(--pasteboard); border-radius: 4px; display: grid; place-items: center; height: 150px; overflow: hidden; cursor: pointer; }
.nav-view canvas { max-width: 100%; max-height: 100%; }
.nav-view .vp { position: absolute; border: 2px solid var(--red); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.histo canvas { width: 100%; height: 110px; display: block; background: var(--bg1); border-radius: 4px; }
.info-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 10px; font-family: var(--mono); font-size: 11px; }
.info-grid .k { color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 2px 8px; font-size: 11px; color: var(--dim); }
.stat-grid b { color: var(--text2); font-weight: 500; font-family: var(--mono); }

/* brushes, gradients, patterns, shapes pickers */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.picker-grid button { display: grid; place-items: center; gap: 2px; aspect-ratio: 1; padding: 3px; border: 1px solid var(--line2); border-radius: 5px; background: var(--bg1); color: var(--text2); min-width: 0; overflow: hidden; }
.picker-grid button:hover { border-color: var(--line3); background: var(--bg4); }
.picker-grid button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.picker-grid button canvas { max-width: 100%; max-height: 100%; }
.picker-grid.wide { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.picker-grid.wide button { aspect-ratio: 2 / 1; }
.picker-grid .lbl { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.adj-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.adj-grid button { display: grid; place-items: center; height: 30px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg1); color: var(--text2); padding: 0; }
.adj-grid button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* properties */
.props { display: grid; gap: 8px; }
.props .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.props .grid2 .num { width: 100%; }
.props .grid2 .num input { width: 100%; }
.props h4 { margin: 2px 0 0; font-size: 11.5px; color: var(--text); display: flex; align-items: center; gap: 6px; }

/* curves / levels editors */
.curve-box { position: relative; width: 100%; aspect-ratio: 1; background: var(--bg1); border-radius: 4px; border: 1px solid var(--line2); touch-action: none; cursor: crosshair; }
.curve-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.levels-box canvas { width: 100%; height: 100px; display: block; background: var(--bg1); border-radius: 4px 4px 0 0; }
.levels-sliders { position: relative; height: 16px; background: var(--bg1); border-radius: 0 0 4px 4px; margin-bottom: 6px; touch-action: none; }
.levels-sliders .h { position: absolute; top: 2px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid; margin-left: -6px; cursor: ew-resize; }
.out-grad { height: 10px; border-radius: 3px; background: linear-gradient(90deg, #000, #fff); }

/* ------------------------------------------------------------------ dialogs */
.modal-wrap { position: fixed; inset: 0; z-index: 700; display: grid; place-items: center; background: rgba(0, 0, 0, .45); padding: 12px; }
.modal-wrap.no-dim { background: transparent; pointer-events: none; }
.modal-wrap.no-dim .modal { pointer-events: auto; }
.modal { display: flex; flex-direction: column; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); background: var(--bg2); border-radius: 12px; box-shadow: var(--shadow); min-width: min(360px, calc(100vw - 24px)); position: relative; }
.modal-head { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); cursor: move; flex: none; }
.modal-head h3 { margin: 0; font-size: 13px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-body { padding: 14px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); flex: none; }
.modal-foot .grow { flex: 1; }
.form { display: grid; gap: 9px; }
.form-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; }
.form-row > label { color: var(--text2); }
.form-row .num input { width: 70px; }
.form-row .input { width: 100%; }
.form-row .inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.form-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-top: 4px; }
.modal-text { margin: 0; color: var(--text2); line-height: 1.55; }
.dlg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview-box { position: relative; background: var(--pasteboard); border-radius: 6px; overflow: hidden; display: grid; place-items: center; min-height: 200px; }
.preview-box canvas { max-width: 100%; max-height: 100%; }
.anchor-grid { display: grid; grid-template-columns: repeat(3, 22px); gap: 3px; }
.anchor-grid button { width: 22px; height: 22px; border: 1px solid var(--line2); border-radius: 3px; background: var(--bg1); padding: 0; }
.anchor-grid button.on { background: var(--accent); border-color: var(--accent); }
.fx-layout { display: grid; grid-template-columns: 190px minmax(320px, 1fr); gap: 14px; }
.fx-list { display: flex; flex-direction: column; gap: 1px; }
.fx-list .fx-item { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px; border-radius: 5px; cursor: pointer; color: var(--text2); }
.fx-list .fx-item:hover { background: var(--bg4); }
.fx-list .fx-item.on { background: var(--accent-soft); color: var(--text); }
.fx-list .fx-item input { accent-color: var(--accent); margin: 0; }
.fx-list .fx-item.head { font-weight: 600; color: var(--text); }
.tabs-mini { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs-mini button { height: 28px; padding: 0 12px; border: 0; background: transparent; color: var(--dim); box-shadow: inset 0 -2px 0 transparent; }
.tabs-mini button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.kbd-table { display: grid; grid-template-columns: 1fr auto; gap: 3px 18px; font-size: 12px; }
.kbd-table .k { font-family: var(--mono); color: var(--accent2); text-align: right; }
.kbd-cols { columns: 2 280px; column-gap: 28px; }
.kbd-cols h4 { margin: 10px 0 4px; break-after: avoid; color: var(--text); }
.grad-editor .bar { position: relative; height: 28px; border-radius: 4px; border: 1px solid var(--line3); margin: 18px 6px; }
.grad-editor .stops { position: relative; height: 18px; margin: 0 6px; }
.grad-editor .stop { position: absolute; top: 0; width: 12px; height: 16px; margin-left: -6px; cursor: ew-resize; border: 1px solid var(--line3); border-radius: 2px 2px 3px 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.grad-editor .stop.on { outline: 2px solid var(--accent); }
.grad-editor .stops.top .stop { top: 2px; }

/* ------------------------------------------------------------------ status bar and busy overlay */
.statusbar { display: flex; align-items: center; gap: 14px; padding: 0 10px; background: var(--bg1); border-top: 1px solid var(--line); color: var(--dim); font-size: 11.5px; white-space: nowrap; overflow: hidden; }
.statusbar .zoom-field { width: 58px; height: 18px; padding: 0 4px; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg2); text-align: right; font-size: 11px; }
.statusbar .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.statusbar .mono { font-family: var(--mono); }
/* the platform's Impressum and privacy policy: in the status bar and the About dialog */
.statusbar .legal-links { display: flex; gap: 10px; }
.legal-links a { color: var(--dim); text-decoration: none; }
.legal-links a:hover { color: var(--text); text-decoration: underline; }
.busy { position: fixed; inset: 0; z-index: 980; display: grid; place-items: center; background: rgba(0, 0, 0, .35); }
.busy-box { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 12px; background: var(--bg3); box-shadow: var(--shadow); min-width: 240px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--bg6); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 4px; border-radius: 4px; background: var(--bg5); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  :root { --dock-w: 260px; }
  .menubar .doc-title { display: none; }
}
@media (max-width: 700px) {
  .workspace { grid-template-columns: var(--toolbar-w) minmax(0, 1fr) 0 0; }
  .workspace .dock { position: fixed; right: 0; top: calc(var(--menubar-h) + var(--options-h)); bottom: var(--status-h); width: min(320px, 88vw); z-index: 300; box-shadow: var(--shadow); }
  .workspace.no-dock .dock { display: none; }
  .dock-resizer { display: none; }
  .menubar .brand span { display: none; }
  .fx-layout, .dlg-cols { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 4px; }
}
