/* SPDX-FileCopyrightText: 2026 RAGTUX LLC
   SPDX-License-Identifier: MIT */

/* Interface face: Fira Sans — a humanist sans drawn for OS UI, so it holds up at the 11–13px
   of the panels and the log. Self-hosted (latin subset, web/fonts) so the app needs no network;
   the system stack stays behind it as the fallback. SIL OFL 1.1. */
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-sans-400.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fira-sans-600.woff2) format('woff2'); }
@font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fira-sans-700.woff2) format('woff2'); }
@font-face { font-family: 'Fira Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/fira-mono-400.woff2) format('woff2'); }
/* type scale: xs uppercase section headings + log, sm captions and secondary chrome, md body,
   row the panel and save-card rows (the densest reading in the app, so a step up from body),
   lg canvas overlays (chips, zoom bar, pane labels), xl display numbers (frame counter,
   progress mark) */
:root { --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-row: 14px; --fs-lg: 15px; --fs-xl: 22px; --font: 'Fira Sans', system-ui, sans-serif; --font-logo: var(--font); --font-mono: 'Fira Mono', ui-monospace, monospace;
  --bg:#1e1e22; --panel:#26262b; --border:#3a3a42; --border-strong:#737380; --widget:#34343c; --accent:#3b82f6; --pop:#ff7a30; --c-source:#f0862a; --c-stack:#3b82f6; --c-depth:#22a55a; --text:#e6e6e6; --dim:#9a9aa3; --head:#b9b9c4; --glass:rgba(20,20,22,.75); --glass-border:rgba(255,255,255,.12); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs-md); overflow: hidden; }
body { display: flex; flex-direction: column; }
button { background: var(--widget); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 10px; cursor: pointer; font: inherit; }
button:hover:not(:disabled) { border-color: #666; }
button:disabled { opacity: .4; cursor: default; }
/* one focus ring for every control, drawn only for keyboard focus; the panel's steppers
   move it to the whole [- value +] group (below) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* reduced motion: the progress bar's barber pole stands still — its red/white stripes still
   mark the running state — and the hover and toast transitions snap */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
button.accent, button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
input { font: inherit; }
select { background: var(--widget); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.dim { color: var(--dim); } .small { font-size: var(--fs-xs); } .spacer { flex: 1; } .sep { width: 12px; display: inline-block; }
#toolbar { align-items: center; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--border); }
/* wordmark: all caps, tracked out, and the one place the display font is used */
#toolbar .title { font-family: var(--font-logo); font-size: 21px; font-weight: 600; line-height: 1; text-transform: uppercase; letter-spacing: .13em; padding-right: 14px; }
/* toolbar: [file + run] [steps] [ ]; equal outer columns keep the steps centered */
#toolbar { display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(0, 1fr); column-gap: 10px; }
#toolbar button { white-space: nowrap; }
#tb-left, #tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
#tb-right { justify-content: flex-end; }
/* a link dressed as a button, for the support link: the plain button's box, no underline */
a.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--widget); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 10px; text-decoration: none; white-space: nowrap; }
a.btn:hover { border-color: #666; }
#support .heart { color: var(--pop); font-size: 13px; line-height: 1; }
#runwrap { position: relative; display: inline-flex; }
#runseg { border-color: var(--accent); } #runseg button { padding: 3px 12px; } #run-more { padding: 3px 7px; border-left: 1px solid rgba(255,255,255,.35); }
#runseg button:disabled { opacity: 1; background: var(--widget); border-color: var(--border); color: var(--dim); }
#cancel { min-width: 96px; }
.menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 320px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 6px; }
.menu .tog { justify-content: flex-start; }
.menu label.stepper { display: flex; justify-content: space-between; align-items: center; }
.menu #dslab-ctl[hidden] { display: none; }
.menu .menu-sep { border-top: 1px solid var(--border); margin: 4px 0; }
.menu label.sel { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.menu #split-ctl[hidden], .menu #split-ctl label[hidden] { display: none; }
.menu .row { display: flex; align-items: center; gap: 6px; }
#sv-actions .grow { flex: 1; }
/* the filmstrip's stack headers (the batch split) and the batch banner while one is in hand */
.fs-group { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 8px 4px 2px; font-size: var(--fs-xs); color: var(--head); border-top: 1px solid var(--border); }
.fs-group:first-child { border-top: 0; padding-top: 2px; }
.fs-group .st { color: var(--dim); white-space: nowrap; }
.fs-group .st.ok { color: #6c6; } .fs-group .st.bad { color: #e66; } .fs-group .st.run { color: var(--accent); }
.fs-batch { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 4px; background: var(--widget); font-size: var(--fs-xs); }
.fs-batch b { color: var(--head); }
.fs-batch button { align-self: flex-start; padding: 1px 8px; font-size: var(--fs-xs); }
#main { flex: 1; display: flex; min-height: 0; }
#left { width: 176px; flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--border); }
#filmstrip { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
#filmstrip { scrollbar-width: none; }
#filmstrip::-webkit-scrollbar { display: none; }
#fs-foot { flex: none; padding: 6px; border-top: 1px solid var(--border); }
#fs-foot .tog { width: 100%; box-sizing: border-box; justify-content: flex-start; }
#filmstrip .empty { padding: 12px; text-align: center; }
.thumb { border: 2px solid transparent; border-radius: 4px; padding: 3px; cursor: pointer; background: var(--widget); position: relative; }
/* an excluded frame: dashed, dimmed, in its place; its tools stay visible so the way back is seen */
.thumb.missing .ph { color: #e66; font-size: var(--fs-xs); }   /* a project's frame not yet found */
.fs-batch .bad { color: #e66; }
.thumb.off { border-style: dashed; border-color: var(--border); cursor: default; }
.thumb.off canvas, .thumb.off .ph, .thumb.off .name { opacity: .4; }
.thumb.dragging { opacity: .35; }
.thumb.drop-before { box-shadow: 0 -4px 0 -1px var(--accent); } .thumb.drop-after { box-shadow: 0 4px 0 -1px var(--accent); }
.thumb .fx { position: absolute; top: 5px; right: 5px; display: flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.thumb:hover .fx, .thumb.off .fx { opacity: 1; }
.thumb .fx button { padding: 0; width: 20px; height: 20px; line-height: 18px; font-size: 12px; background: rgba(0, 0, 0, .7); border-color: #555; color: #eee; }
.thumb .fx button:hover { background: var(--accent); border-color: var(--accent); }
/* the Results section: one row per kept result — its name (a button: show it), a note, and drop */
.kept { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: var(--fs-xs); }
.kept .kl { flex: 1; min-width: 0; text-align: left; padding: 2px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kept.on .kl { border-color: var(--accent); }
.kept .kn { flex: none; color: var(--dim); white-space: nowrap; }
.kept .kx { flex: none; padding: 0 6px; }
#subseg button.kept { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 0 2px; font-size: var(--fs-xs); color: var(--dim); }
.fs-tools span { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-tools button { padding: 0 6px; font-size: var(--fs-xs); }
.thumb.sel { border-color: var(--accent); }
.thumb.slab { background: color-mix(in srgb, var(--accent) 22%, var(--widget)); }   /* a frame of the slab the brush paints from */
.thumb canvas, .thumb .ph { width: 100%; height: 100px; object-fit: contain; display: block; background: #111; border-radius: 2px; }
.thumb .ph { display: flex; align-items: center; justify-content: center; color: var(--dim); }
.thumb .name { font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.thumb .sim { font-size: var(--fs-xs); color: var(--dim); white-space: nowrap; overflow: hidden; }
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#vwrap { flex: 1; position: relative; overflow: hidden; background: #141416; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#view.drag { cursor: grabbing; }
#divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; opacity: .8; cursor: ew-resize; }
#divider::after { content: ""; position: absolute; left: -6px; right: -6px; top: 0; bottom: 0; }
/* viewer header: floats over the canvas as glass chips (like the zoom bar), so the image gets
   the full height and the controls read against dark glass in larger type. Layer + context
   controls stack down the left edge in one fixed-width column, every chip the full column
   width in the same lg type (segmented controls become vertical stacks); vs sits at the top center and the compare partner + its controls
   run in a row to its right. Equal outer grid columns keep vs at the exact horizontal center
   of the canvas. Only the chips take the pointer, so the canvas stays draggable around them. */
#vhead { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; column-gap: 10px; font-size: var(--fs-lg); pointer-events: none; }
#vhead * { pointer-events: auto; }
#vh-left, #vh-right { display: flex; gap: 8px; min-width: 0; pointer-events: none; }
#vh-right { flex-wrap: wrap; align-items: center; }
#vh-left { flex-direction: column; align-items: stretch; width: 160px; }
#vhead .seg, #vhead .ctx { flex: none; }
/* the movable context groups and the compare group flow as individual items so the columns wrap cleanly */
#vhead #view-ctx, #vhead #cmp-ctx, #vhead #ctx-compare { display: contents; }
/* every chip in the header is 34px tall on the same glass */
#vhead .seg, #vhead .tog, #vhead .stepper { height: 34px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 8px; backdrop-filter: blur(4px); }
#vhead .seg button { background: transparent; padding: 0 14px; font-size: var(--fs-lg); border-right-color: var(--glass-border); }
#vhead .seg button.on { background: var(--gc, var(--accent)); }
/* layer groups are color-coded so what is on screen reads at a glance: Source orange, Stack blue,
   Depth green. data-group on a chip (or a container of chips) picks the group color; it tints the
   selected button, the chip border and the toggle box, and the pane labels below */
[data-group=source] { --gc: var(--c-source); } [data-group=stack] { --gc: var(--c-stack); } [data-group=depth] { --gc: var(--c-depth); }
#vhead .seg[data-group], #vhead [data-group] .seg, #vhead [data-group] .tog, #vhead [data-group] .stepper { border-color: color-mix(in srgb, var(--gc) 65%, var(--glass-border)); }
#vhead #viewseg button:not(.on):not(:disabled), #vhead .drop[data-group] > button { color: var(--gc); }
/* the compare partner picker is a chip with its own drop-down list (a native select cannot color
   its rows: Chrome paints the popup's hover/selected rows with the system highlight), each row in
   its layer's color, the hovered and current rows filled with it */
#vhead .drop { position: relative; overflow: visible; }
#vhead .drop > .menu { left: 0; width: max-content; min-width: 100%; padding: 4px; gap: 2px; }
#vhead .drop .menu button { background: transparent; border: 0; border-radius: 5px; text-align: left; padding: 6px 12px; font-size: var(--fs-lg); color: var(--gc, var(--text)); white-space: nowrap; }
#vhead .drop .menu button:hover, #vhead .drop .menu button.on { background: var(--gc, var(--accent)); color: #fff; }
#vhead [data-group] .tog:has(input:checked) { border-color: var(--gc); } #vhead [data-group] .tog input { accent-color: var(--gc); }
#vhead .seg.sub button { padding: 0 11px; }
#vhead .tog { padding: 0 11px; gap: 7px; } #vhead .tog input { width: 15px; height: 15px; }
#vhead .stepper { gap: 0; } #vhead .stepper button { height: 100%; padding: 0 11px; background: transparent; border: 0; }
#vhead #peakthr { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
/* the Retouch button sits at the right end of the right column, whatever else is in it */
#vhead #rtseg { margin-left: auto; }
/* the left column: segmented controls stack their buttons, context groups stack their chips */
#vhead #vh-left .sep { display: none; }
#vhead #vh-left .seg { flex-direction: column; height: auto; }
#vhead #vh-left .seg button { height: 34px; text-align: left; border-right: 0; border-bottom: 1px solid var(--glass-border); }
#vhead #vh-left .seg button:not(:has(~ button:not([hidden]))) { border-bottom: 0; }
#vhead #vh-left .seg.sub { margin: 0; } #vhead #vh-left .seg.sub button { padding: 0 14px; }
#vhead #vh-left #ctx-source, #vhead #vh-left #ctx-depth { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
#vhead #vh-left .stepper { justify-content: space-between; } #vhead #vh-left .stepper > span { flex: 1; }
.vs { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 34px; border-radius: 8px; border: 2px solid var(--pop); background: var(--glass); backdrop-filter: blur(4px); color: var(--pop); font-weight: 700; font-size: var(--fs-lg); cursor: pointer; user-select: none; }
.vs input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.vs:hover:has(input:not(:disabled)) { background: rgba(255,122,48,.25); }
.vs:has(input:checked) { background: var(--pop); color: #fff; box-shadow: 0 0 0 3px rgba(255,122,48,.3); }
.vs:has(input:disabled) { opacity: .35; cursor: default; }
#vhead button, #vhead label { white-space: nowrap; }
#vhead .ctx { display: inline-flex; align-items: center; gap: 8px; }
/* step panels: every row is [label text | control] on one grid so checkboxes, steppers,
   selects and values share a single right edge; rows are a fixed 28px so the rhythm does not
   depend on the control. Section headings ride a hairline that divides the groups, and sit
   closer to their own rows than to the group above; the first one is flush with the top. */
.panel { width: 288px; flex: none; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--border); padding: 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.panel label, .panel .row { font-size: var(--fs-row); }
.panel .small { font-size: var(--fs-sm); line-height: 1.45; }
.panel .section { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--head); margin: 14px 0 4px; padding-top: 10px; border-top: 1px solid var(--border); }
/* the heading wrapper carries no type of its own: it is there so the panel can be walked by
   heading, and the button inside it keeps the hairline and the uppercase */
.sec-h { margin: 0; font: inherit; display: flex; align-items: stretch; }
.panel > .section:first-child, .panel > .sec-h:first-child > *, #brush > .sec-h:first-child > *, #brush[hidden] + .sec-h > * { margin-top: 0; padding-top: 0; border-top: 0; }
/* the parameter panel's sections collapse: the heading is the toggle (a button, so it keeps the
   heading's own hairline and type) and the rows under it live in the .sec-body it hides, so a
   squished panel can be cut down to the groups in use. The collapsed set is remembered. */
#params button.section { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; cursor: pointer; }
#params button.section:hover { color: var(--text); }
#params button.section::after { content: "▾"; font-size: var(--fs-sm); color: var(--dim); }
#params button.section.collapsed::after { content: "▸"; }
/* each section that holds settings keeps a reset beside its toggle (made in app.js): it carries
   the same hairline and margins, so the rule still runs unbroken across the panel, and it is
   disabled while the section is at its defaults — the heading then also says which groups have
   been changed. */
#params .sec-h > button.section { width: auto; flex: 1 1 auto; min-width: 0; }
#params .sec-reset { flex: 0 0 auto; background: transparent; color: var(--head); border: 0; border-top: 1px solid var(--border); border-radius: 0; margin: 14px 0 4px; padding: 10px 0 0 10px; font-size: var(--fs-sm); line-height: 1.1; }
#params .sec-reset:hover:not(:disabled) { color: var(--pop); border-color: var(--border); }
#params .sec-reset:disabled { color: var(--dim); opacity: .3; }
#params .sec-body { display: flex; flex-direction: column; gap: 3px; }
#brush .sec-body { gap: 2px; }
#params .sec-body.collapsed { display: none; }
/* the two surfaces that scroll with a visible scrollbar (the filmstrip and the log hide theirs),
   so both get a dark one: the default is painted light over this dark chrome */
#params, #savepage { scrollbar-width: thin; scrollbar-color: #4a4a55 transparent; }
/* the brush block joins the panel's column while retouch mode is on */
#brush { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
#brush[hidden] { display: none; }
.panel label { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; min-height: 28px; }
.panel label > input, .panel label > select, .panel label > span { justify-self: end; order: 1; }
.panel label > input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
/* a stepper is one control, not two buttons around a number: [- value +] in a single bordered
   group, the +/- borderless inside it. The old per-button hairline sat at 1.3:1 against the
   panel, so nothing read as clickable until hover. The value is the spinbutton (app.js gives
   it the role, the arrow keys and the value semantics), so the ring goes round the group. */
.panel label.stepper > span, .menu label.stepper > span { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--widget); overflow: hidden; }
.panel label.stepper > span > span, .menu label.stepper > span > span { min-width: 42px; padding: 0 2px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.panel .stepper button, .menu .stepper button { padding: 0 8px; height: 24px; background: transparent; border: 0; border-radius: 0; color: var(--dim); }
.panel .stepper button:hover:not(:disabled), .menu .stepper button:hover:not(:disabled) { background: rgba(255,255,255,.08); color: var(--text); }
.panel label.stepper > span:has(> span:focus-visible), .menu label.stepper > span:has(> span:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel label.stepper > span > span:focus-visible, .menu label.stepper > span > span:focus-visible { outline: none; }
.panel select { height: 24px; padding: 0 4px; }
/* a select never widens its row past the panel: a long option is cut, not scrolled to */
.panel label > select { max-width: 176px; }
/* log strip: [vertical toolbar + status bar][log]; the strip is panel gray like the rest of the
   chrome and the log itself keeps its black well; collapsed leaves just the toolbar row, so all
   gray, and the status bar stretches out along it */
#logwrap { flex: none; display: flex; align-items: stretch; background: var(--panel); border-top: 1px solid var(--border); }
#logbar { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 5px 5px; border-right: 1px solid var(--border); }
#logbar button { padding: 1px 6px; font-size: var(--fs-sm); line-height: 1.3; color: var(--dim); background: transparent; }
#logbar button:hover:not(:disabled) { color: var(--text); background: var(--widget); }
#log { flex: 1; min-width: 0; height: 120px; margin: 0; padding: 6px 10px; overflow-y: auto; background: #151518; font: var(--fs-xs) var(--font-mono); color: var(--dim); white-space: pre-wrap; overflow-wrap: anywhere; }
#log { scrollbar-width: none; }
#log::-webkit-scrollbar { display: none; }
body.log-collapsed #log { display: none; }
body.log-collapsed #logbar { flex-direction: row; border-right: 0; }
/* status bar: it shares the log strip with the log, so it takes whatever shape the strip leaves
   free. With the log open the well wants the whole width, so the status bar is a square at the
   foot of the left toolbar (the bottom-left corner of the window) showing only the barber pole /
   check / cross, its stage text in the tooltip (setStatus). Collapsed, the strip is an empty row,
   so it stretches to the full bar with the text inside, anchored to the right end.
   .running = red/white barber pole fill, .done = green check, .error = red cross. */
#progress { position: relative; flex: none; width: 24px; height: 24px; margin-top: auto; border-radius: 6px; background: var(--widget); border: 1px solid var(--border); overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; opacity: 0; transition: width .15s linear; }
/* the square is too small for the full bar's 10px stripes: half the period, so a few stripes
   read as a pole rather than one diagonal */
#progress.running #fill { opacity: 1; background: repeating-linear-gradient(-45deg, #e23b3b 0 5px, #f4f4f4 5px 10px); background-size: 14.14px 14.14px; animation: pole-sm .3s linear infinite; }
@keyframes pole-sm { to { background-position: 14.14px 0; } }
#mark { position: relative; z-index: 1; display: none; font-size: var(--fs-lg); font-weight: 700; line-height: 1; }
#progress.done #mark { display: inline; color: #2ecc71; } #progress.done #mark::before { content: "✓"; }
#progress.error #mark { display: inline; color: #e23b3b; } #progress.error #mark::before { content: "✕"; }
#status { display: none; position: relative; z-index: 1; font-size: var(--fs-sm); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 8px; }
#progress.running #status { color: #fff; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000; }
#progress.done #status { color: var(--text); }
/* collapsed: the toolbar takes the whole width so the auto margin can push the bar to the right */
body.log-collapsed #logbar { flex: 1; }
body.log-collapsed #progress { width: 240px; height: 26px; margin: 0 0 0 auto; border-radius: 7px; }
body.log-collapsed #status { display: inline; }
body.log-collapsed #mark { font-size: var(--fs-xl); }
body.log-collapsed #progress.running #fill { background: repeating-linear-gradient(-45deg, #e23b3b 0 10px, #f4f4f4 10px 20px); background-size: 28.3px 28.3px; animation: pole .5s linear infinite; }
@keyframes pole { to { background-position: 28.3px 0; } }
.drop #main { outline: 2px dashed var(--accent); outline-offset: -4px; }
#toasts { position: fixed; right: 16px; bottom: 136px; transition: bottom .1s linear; display: flex; flex-direction: column; gap: 8px; max-width: 460px; z-index: 10; }
body.log-collapsed #toasts { bottom: 46px; }
.toast { background: #3a2a2a; border: 1px solid #a05050; border-radius: 6px; padding: 10px 32px 10px 12px; position: relative; line-height: 1.4; }
.toast button { position: absolute; top: 4px; right: 4px; padding: 0 6px; }
.thumb .pct { color: #e88; }
.thumb .sim.low { color: #e88; }
.fs-tools input.cull { width: 3.2em; padding: 0 2px; font-size: var(--fs-xs); }
/* viewer header: segmented controls + compact toggles */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--border); padding: 3px 12px; }
.seg button:last-child { border-right: 0; }
.seg.sub { margin-left: -2px; } .seg.sub button { padding: 3px 9px; font-size: var(--fs-sm); }
.seg button[hidden] { display: none; }
.tog { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; background: var(--widget); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; user-select: none; }
.tog:has(input:checked) { border-color: var(--accent); color: #fff; }
.tog:has(input:disabled) { opacity: .4; cursor: default; }
.tog input { margin: 0; accent-color: var(--accent); }
.ctx { display: inline-flex; align-items: center; gap: 8px; }
#peakstep { display: inline-flex; align-items: center; }
/* compare side by side / retouch: two panes */
#vwrap.split { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
#vwrap.split canvas { position: relative; inset: auto; width: 100%; height: 100%; cursor: grab; }
#vwrap.paint canvas { cursor: none; }
/* ctrl is zoom: it takes the wheel off the scrub and zooms about the pointer */
#vwrap.zoom canvas { cursor: zoom-in; }
/* shift is pan (it suspends the brush): the move cursor stands in for grab, for zoom-in
   above and for the brush's own cursor: none — a drag pans whatever the wheel would do.
   The pick crosshair below still wins over both. */
#vwrap.shift canvas { cursor: move; }
/* ctrl+G: pick the frame that won a pixel */
#vwrap.pick canvas { cursor: crosshair; }
#vwrap.croptool canvas { cursor: crosshair; }
#cropseg #cropclear { padding: 0 6px; }
/* except in retouch mode, where all three are drawn into both panes instead: the pick
   cross, the pan arrows and the zoom lens (paintMarks) */
#vwrap.marks canvas { cursor: none; }
#corner-br { position: absolute; right: 10px; bottom: 10px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
#pickhint { padding: 6px 12px; border-radius: 8px; background: rgba(20,20,22,.85); border: 1px solid var(--accent); font-size: var(--fs-lg); white-space: nowrap; }
/* keyboard shortcut card: opaque panel (not glass) so the list stays legible over any image;
   the title row is the collapse toggle and is all that remains when collapsed */
#keys { pointer-events: auto; min-width: 170px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,.45); color: var(--text); font-size: var(--fs-md); overflow: hidden; }
#keys-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 5px 10px; background: transparent; border: 0; border-radius: 0; color: var(--dim); font-size: var(--fs-sm); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
#keys-toggle:hover { color: var(--text); background: rgba(255,255,255,.06); }
#keys-list { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 5px; padding: 2px 10px 9px; }
#keys-list > div { display: contents; }
#keys-list > div > span:first-child { display: inline-flex; gap: 3px; justify-content: flex-end; }
#keys-list > div > span:last-child { white-space: nowrap; line-height: 20px; }
#keys kbd { display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 4px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); box-shadow: 0 1px 0 rgba(0,0,0,.5); color: #fff; font: 600 var(--fs-sm)/18px var(--font); text-align: center; }
#keys.collapsed #keys-list { display: none; }
/* pane labels: block letters floating over every visible image (pane centers when split,
   hugging the divider in swipe, centered when a single image fills the canvas); draw() keeps
   them below the header row. White letters on a box filled with the layer's group color
   (Source orange, Stack blue, Depth green; dark gray for a neutral label), stroked in white
   and hugging the letters. A hint ("drag to paint", "loading full res") sits under the name in
   smaller mixed case */
#panelabels { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.plab { position: absolute; top: 8px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 5px 10px 7px; border: 3px solid #fff; border-radius: 6px; background: var(--gc, #333); color: #fff; font-size: 34px; font-weight: 700; line-height: 1; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
.plab.l { align-items: flex-start; } .plab.r { align-items: flex-end; }
.plab .hint { font-size: var(--fs-lg); font-weight: 600; line-height: 1.2; text-transform: none; letter-spacing: 0; }
/* frame scrubber: vertical slider overlaid on the canvas, centered on its left edge; frame 1
   at the top like the filmstrip, so wheel-down and slider-down both advance. The frame
   counter (e.g. 49/100) is the more useful readout, so it gets its own large box directly
   below the track. Its default height is min(50%, 420px); layoutScrub() overrides top and
   height inline when the chip column above would otherwise overlap it. */
#scrub { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); height: min(50%, 420px); min-height: 120px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: default; }
#scrubtrack, #scrubname { border-radius: 8px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(4px); }
#scrubtrack { flex: 1; min-height: 0; display: flex; padding: 8px 6px; }
/* the slider is drawn by hand: a thin neutral rail with a round accent thumb and no
   progress fill above the thumb, which the native control would paint in accent blue */
#scrubber { flex: 1; min-height: 0; width: 16px; writing-mode: vertical-lr; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: ns-resize; }
#scrubber::-webkit-slider-runnable-track { width: 4px; height: 100%; border-radius: 2px; background: rgba(255,255,255,.28); }
#scrubber::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-left: -6px; border-radius: 50%; border: none; background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
#scrubber::-moz-range-track { width: 4px; border-radius: 2px; background: rgba(255,255,255,.28); }
#scrubber::-moz-range-progress { background: transparent; }
#scrubber::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: none; background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
#scrubname { flex: none; padding: 3px 10px; font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; color: #fff; }
/* zoom readout + Fit/100% as an overlay in the canvas corner; same 34px chips and lg type as the header */
#zoombar { position: absolute; left: 10px; bottom: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 12px; border-radius: 8px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(4px); cursor: default; font-size: var(--fs-lg); }
#zoombar:empty, #zoombar #zoom:empty { display: none; }
#zoombar #zoom { min-width: 40px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
#zoombar .seg, #cmpbar .seg { background: transparent; height: 32px; } #zoombar .seg button, #cmpbar .seg button, #cmpbar > button { padding: 0 14px; }
#cmpbar > button { height: 32px; border-radius: 6px; }
/* compare mode + flip, centered at the bottom of the canvas under the split */
#cmpbar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2; display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 8px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(4px); cursor: default; font-size: var(--fs-lg); }
/* workflow steps + step panels */
.steps button { padding: 4px 16px; } .steps button b { font-weight: 600; opacity: .6; margin-right: 6px; } .steps button.on b { opacity: 1; }
.panel input[type=range] { width: 100%; accent-color: var(--accent); margin: 0 0 8px; }
.panel input[type=text] { width: 150px; height: 22px; background: var(--widget); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font: inherit; }
.panel .row { display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 2px 0; }
.panel .row button { flex: none; white-space: nowrap; }
.panel .row .small { min-width: 0; }
.panel .val { color: var(--text); }
.panel .dim button { height: 20px; padding: 0 7px; margin-left: 6px; font-size: var(--fs-xs); vertical-align: middle; }
/* Save step: body.step-save hides the filmstrip, canvas, panel and log; #savepage fills #main
   and centers one card that reuses the panel's row grid at a wider measure */
body.step-save #left, body.step-save #center, body.step-save #logwrap { display: none; }
body.step-save #toasts { bottom: 16px; }
#savepage { flex: 1; min-width: 0; overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 48px 24px; }
#savecard { flex: none; width: min(100%, 720px); overflow: visible; border: 1px solid var(--border); border-radius: 10px; padding: 24px 28px 28px; box-shadow: 0 8px 32px rgba(0,0,0,.35); }
#savecard h2 { margin: 0 0 4px; font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; }
#savecard .section { margin-top: 22px; }
#savecard label { min-height: 30px; }
#savecard input[type=text], #savecard select { width: 240px; height: 26px; }
#savecard .row { min-height: 30px; }
#savecard #sv-image { padding: 6px 18px; }
#savecard .check { display: flex; justify-content: flex-start; gap: 8px; }
#savecard .check > input { order: 0; justify-self: start; }
#savecard .check > span:last-child:not(:nth-child(2)) { margin-left: auto; }
#fn-tokens { display: flex; flex-direction: column; }
#fn-preview { min-height: 18px; font-family: var(--font-mono); }
#savecard .sv-head { display: flex; justify-content: space-between; align-items: center; }
#savecard .sv-head .check { min-height: 0; font-weight: 400; text-transform: none; letter-spacing: normal; }
/* the file list: [checkbox][thumb][name + description][state] */
#sv-files { display: flex; flex-direction: column; gap: 4px; }
.svf { display: grid; grid-template-columns: auto 96px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--widget); cursor: pointer; }
.svf.on { border-color: var(--accent); }
.svf.off { opacity: .45; cursor: default; }
.svf input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.svf canvas { width: 96px; height: 64px; display: block; background: #111; border-radius: 3px; }
.svf .fname { font-family: var(--font-mono); font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svf .desc { font-size: var(--fs-sm); color: var(--dim); margin-top: 3px; }
.svf .state { font-size: var(--fs-sm); color: var(--dim); white-space: nowrap; }
#an-info.warn { color: #e88; }
#savecard a { color: var(--accent); }
#sv-actions { margin-top: 18px; }
#sv-progress { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
