/* Afterimage: engineering-graphics interface.
   Layout: a familiar editor (menu bar, tool options, tool strip, canvas with rulers, panel stack, status bar),
   each region a flat white sheet on a grey desk: 1px black rules, hard offset shadows, dotted section rules,
   dense bordered lists, a red LED for state, yellow and green action buttons. Single light theme by choice. */
:root {
  --desk: #a9a9a9;
  --paper: #ffffff;
  --ink: #000000;
  --rule: #888888;
  --faint: #d9d9d9;
  --soft: #f1f1f1;
  --mute: #6b6b6b;
  --drop: #bbbbbb;              /* hard shadow on paper */
  --desk-drop: rgba(0, 0, 0, 0.28);
  --pasteboard: #bdbdbd;
  --yellow: #fcc400;
  --yellow-tint: #fff3bf;
  --green: #006e50;
  --red: #d8343a;
  --blue: #002dce;
  --font-sans: "Univers LT Pro", "Univers", "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Berkeley Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@supports (color: color(display-p3 1 1 1)) {
  :root { --yellow: color(display-p3 0.985 0.766 0); --green: color(display-p3 0 0.43 0.316); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--desk); color: var(--ink); font: 400 13px/1.4 var(--font-sans); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
kbd { font: 11px var(--font-mono); }

.app {
  height: 100%;
  display: grid; gap: 8px; padding: 8px;
  grid-template-columns: 46px minmax(0, 1fr) 348px;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "menu menu menu" "opts opts opts" "tools view panels" "tools strip panels" "status status status";
}
.sheet, .menubar, .optionsbar, .tools, .viewport, .panel, .statusbar {
  background: var(--paper); border: 1px solid var(--rule); box-shadow: 2px 2px 0 var(--desk-drop);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--drop);
  padding: 3px 11px; min-height: 24px; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--yellow-tint); }
.btn:active, .btn[aria-pressed=true] { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--drop); }
.btn-yellow { background: var(--yellow); font-weight: 500; }
.btn-yellow:hover { background: var(--yellow); filter: brightness(1.06); }
.btn-green { background: var(--green); color: #fff; font-weight: 500; }
.btn-green:hover { background: var(--green); filter: brightness(1.15); }
.btn-sm { padding: 1px 7px; min-height: 20px; font-size: 12px; box-shadow: 1px 1px 0 var(--drop); }
.arrow { font-family: var(--font-mono); }
.btn-group { display: inline-flex; gap: 6px; }
.led { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cfcfcf; border: 1px solid rgba(0,0,0,.35); flex: none; }
.btn-led[aria-pressed=true] .led, .before-tag .led { background: var(--red); }
.led.busy { background: var(--yellow); }

/* ---------- menu bar ---------- */
.menubar { grid-area: menu; display: flex; align-items: center; gap: 18px; padding: 7px 12px; flex-wrap: wrap; }
.wordmark { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.menus { display: flex; gap: 8px; }
.menu { position: relative; }
.menu-btn {
  min-width: 64px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--drop);
  padding: 2px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.menu-btn:hover { background: var(--yellow-tint); }
.menu-btn[aria-expanded=true]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 1px solid rgba(0,0,0,.35); }
.menu-pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--desk-drop);
  padding: 4px 0; display: flex; flex-direction: column;
}
.menu-pop button {
  display: flex; justify-content: space-between; gap: 24px; align-items: center;
  background: none; border: 0; padding: 4px 12px; text-align: left; font-size: 13px;
}
.menu-pop button:hover, .menu-pop button:focus-visible { background: var(--yellow); outline: none; }
.menu-pop kbd { color: var(--mute); }
.menu-pop hr { border: 0; border-top: 1px dotted var(--ink); margin: 4px 8px; }
.calib { margin-left: auto; display: flex; gap: 14px; }
.calib-row { display: flex; gap: 2px; }
.calib i { width: 15px; height: 6px; background: var(--c); display: block; }

/* ---------- tool options ---------- */
.optionsbar { grid-area: opts; display: flex; align-items: center; gap: 12px; padding: 6px 12px; flex-wrap: wrap; }
.opt-tool { font-weight: 700; min-width: 64px; }
.opt-sep { width: 1px; align-self: stretch; background: var(--faint); }
.opt-hint { color: var(--mute); }
.opt-grow { flex: 1; }

/* ---------- tool strip ---------- */
.tools { grid-area: tools; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 7px 0; }
.tools hr { width: 28px; border: 0; border-top: 1px dotted var(--ink); margin: 2px 0; }
.tool {
  position: relative; width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--drop); padding: 0;
}
.tool:hover { background: var(--yellow-tint); }
.tool[aria-pressed=true] { background: var(--yellow); transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--drop); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; }
.tool svg .fill { fill: var(--ink); }
.tool-key { position: absolute; right: 1px; bottom: 0; font: 8px/1 var(--font-mono); }

/* ---------- canvas + rulers ---------- */
.viewport { grid-area: view; position: relative; min-width: 0; min-height: 0; display: grid; grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: 18px minmax(0, 1fr); }
.viewport.no-rulers { grid-template-columns: 0 minmax(0, 1fr); grid-template-rows: 0 minmax(0, 1fr); }
.viewport.no-rulers .ruler, .viewport.no-rulers .ruler-corner { display: none; }
.viewport > .stage { grid-column: 2; grid-row: 2; }   /* stays in its cell when the rulers are hidden */
.ruler-corner { font: 8px/18px var(--font-mono); text-align: center; background: var(--soft); border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.ruler { display: block; width: 100%; height: 100%; }
.stage {
  position: relative; overflow: auto; min-width: 0; min-height: 0;
  background: radial-gradient(circle, rgba(0,0,0,.14) 0.7px, transparent 1px) 0 0 / 6px 6px, var(--pasteboard);
  cursor: default; overscroll-behavior: contain;
}
.stage[data-tool=hand] { cursor: grab; }
.stage.grabbing { cursor: grabbing; }
.stage[data-tool=zoom] { cursor: zoom-in; }
.stage[data-tool=compare] { cursor: crosshair; }
.pasteboard { position: relative; display: grid; place-items: center; min-width: 100%; min-height: 100%; width: max-content; height: max-content; padding: 20px; }
.pasteboard canvas { display: block; outline: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--desk-drop); touch-action: none; }
.before-tag {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--drop); padding: 3px 10px; font-weight: 700; pointer-events: none;
}
.drop { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.7); pointer-events: none; z-index: 5; }
.drop-box { border: 2px dashed var(--ink); background: var(--paper); padding: 22px 34px; text-align: center; font-weight: 700; font-size: 16px; box-shadow: 4px 4px 0 var(--desk-drop); }
.drop-box small { font: 400 11px var(--font-mono); color: var(--mute); }

/* ---------- panels ---------- */
.panels { grid-area: panels; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; padding: 0 4px 4px 0; }
.panel { padding: 9px 12px 12px; }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; margin: 0; font-size: 13px; font-weight: 700; }
.panel-h::after { content: none; }
.panel-meta { font: 400 11px var(--font-mono); color: var(--mute); }
.panel-h + * { margin-top: 14px; }
.panel-h { position: relative; padding-bottom: 8px; }
.panel-h::before { /* halftone band under the heading */
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 7px;
  background: radial-gradient(circle, #000 0.55px, transparent 0.9px) 0 0 / 3px 3px; opacity: .55;
}
.sub-h { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; font-size: 13px; font-weight: 700; padding-bottom: 5px; border-bottom: 1px dotted var(--ink); }
.sub-actions { display: flex; gap: 6px; }

/* histogram */
.hist { display: block; width: 100%; height: 108px; border: 1px solid var(--ink); }
.hist-axis { display: flex; justify-content: space-between; font: 10px var(--font-mono); color: var(--mute); margin-top: 2px; }
.hist-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 8px 0 0; border: 1px solid var(--rule); box-shadow: 2px 2px 0 var(--faint); }
.hist-stats div { padding: 4px 7px; border-left: 1px solid var(--faint); }
.hist-stats div:first-child { border-left: 0; }
.hist-stats dt { font-size: 11px; color: var(--mute); }
.hist-stats dd { margin: 0; font: 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.hist-stats dd.warn { color: var(--red); }

/* looks list: a bordered, dense table of rows */
.rows { border: 1px solid var(--rule); border-left-width: 2px; box-shadow: 2px 2px 0 var(--faint); }
.rows:empty { display: none; }
.row-item {
  width: 100%; display: grid; grid-template-columns: 10px 40px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 4px 8px; background: var(--paper); border: 0; border-top: 1px solid var(--faint); text-align: left; font-size: 13px;
}
.rows > :first-child .row-item, .rows > .row-item:first-child { border-top: 0; }
.row-item:hover { background: var(--yellow-tint); }
.row-item .led { width: 8px; height: 8px; visibility: hidden; background: var(--red); }
.row-item[aria-pressed=true] { font-weight: 700; }
.row-item[aria-pressed=true] .led { visibility: visible; }
.row-item .sw { height: 11px; outline: 1px solid rgba(0,0,0,.4); }
.row-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .tag { font: 400 11px var(--font-mono); color: var(--mute); }
.urow { position: relative; }
.urow .row-item { padding-right: 70px; }
.urow .del {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: var(--paper); border: 1px solid var(--ink); font-size: 11px; line-height: 1; padding: 2px 6px;
}
.urow .del:hover { background: var(--yellow-tint); }
.urow .del.armed { background: var(--red); color: #fff; border-color: var(--red); }
.empty { margin: 0; padding: 8px 10px; font-size: 12px; color: var(--mute); border-left: 2px solid var(--rule); background: var(--soft); }
.saveform { display: flex; gap: 8px; margin-top: 10px; }
.saveform input { flex: 1; min-width: 0; border: 1px solid var(--ink); padding: 3px 7px; box-shadow: inset 1px 1px 0 var(--faint); }

/* adjustments: "This look" (default) shows only the sections the look uses; "All settings" shows every one */
#adjust:not(.all) .adj[data-used="0"] { display: none; }
#adjust .adj:not([open]) { display: none; }   /* one section at a time; the tabs switch between them */
.adj-reset { margin-left: auto; }
.look-title:empty::before { content: "Look settings"; }
.sec-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.sec-tab { padding: 3px 9px; background: none; border: 1px solid var(--rule); cursor: pointer; }
.sec-tab[aria-selected=true], .sec-more[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.sec-more { margin-left: auto; }
#settingsPanel:not(:has(.adj.changed)) .adj-reset { display: none; }   /* only when something differs from the look */
.sec-reset { margin-left: 8px; font-size: 11px; padding: 0 6px; background: none; border: 1px solid currentColor; cursor: pointer; }
.adj:not(.changed) .sec-reset { display: none; }
.adj { margin-top: 10px; }
.adj:first-child { margin-top: 0; }
.adj summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-weight: 700; padding: 4px 0; }
.adj summary::-webkit-details-marker { display: none; }
.adj summary::before { content: "▸"; font: 10px var(--font-mono); transition: transform .12s; }
.adj[open] summary::before { transform: rotate(90deg); }
.adj-rule { flex: 1; border-bottom: 1px dotted var(--ink); transform: translateY(2px); }
.params { display: flex; flex-direction: column; }
.param { display: grid; grid-template-columns: 86px minmax(0, 1fr) 72px; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dotted var(--faint); }
.param:last-child { border-bottom: 0; }
.param label { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.param.changed label { font-weight: 700; }
.param.changed label::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-right: 5px; vertical-align: 1px; }
.param select { grid-column: 2 / -1; }
.num { display: flex; align-items: center; gap: 3px; }
.num input {
  width: 100%; min-width: 0; border: 1px solid var(--ink); padding: 1px 4px; text-align: right;
  font: 12px var(--font-mono); font-variant-numeric: tabular-nums; box-shadow: inset 1px 1px 0 var(--faint);
}
.num input:focus { background: var(--yellow-tint); outline: none; }
.num i { font: normal 10px var(--font-mono); color: var(--mute); width: 16px; }

select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--ink); background: var(--paper); box-shadow: 2px 2px 0 var(--drop);
  padding: 2px 24px 2px 7px; font-size: 13px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px; background-repeat: no-repeat;
}

/* range: outlined meter with a black fill and a square thumb */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border: 1px solid var(--ink); background: linear-gradient(90deg, var(--ink) var(--p), var(--paper) var(--p)); }
input[type=range]::-moz-range-track { height: 6px; border: 1px solid var(--ink); background: linear-gradient(90deg, var(--ink) var(--p), var(--paper) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 16px; margin-top: -6px; background: var(--paper); border: 1px solid var(--ink); border-radius: 0; box-shadow: 2px 2px 0 var(--drop); }
input[type=range]::-moz-range-thumb { width: 9px; height: 16px; background: var(--paper); border: 1px solid var(--ink); border-radius: 0; box-shadow: 2px 2px 0 var(--drop); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { background: var(--yellow); }
input[type=range]:focus-visible::-moz-range-thumb { background: var(--yellow); }

/* gradient map */
.ramp { height: 16px; border: 1px solid var(--ink); margin: 4px 0 8px; }
.stops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.stops label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.stops label.changed span { font-weight: 700; }
.stops input { width: 100%; height: 26px; border: 1px solid var(--ink); padding: 1px; background: var(--paper); box-shadow: 2px 2px 0 var(--drop); cursor: pointer; }
.stops code { font: 10px var(--font-mono); color: var(--mute); }

/* ---------- status bar ---------- */
.statusbar { grid-area: status; display: flex; align-items: stretch; flex-wrap: wrap; font: 11.5px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.cell { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-left: 1px solid var(--faint); white-space: nowrap; }
.cell:first-child { border-left: 0; }
.cell b { font: 700 11px var(--font-sans); }
.cell-grow { flex: 1; min-width: 0; overflow: hidden; }
.cell-grow span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- toast & shortcuts window ---------- */
.toast {
  position: fixed; right: 20px; bottom: calc(52px + env(safe-area-inset-bottom, 0px)); z-index: 40; max-width: min(420px, calc(100vw - 32px));
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--desk-drop); padding: 7px 12px 7px 28px; font-size: 13px;
}
.toast::before { content: ""; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--red); border: 1px solid rgba(0,0,0,.35); }
.window { padding: 0; border: 1px solid var(--ink); box-shadow: 5px 5px 0 var(--desk-drop); min-width: min(440px, calc(100vw - 32px)); }
.window::backdrop { background: rgba(120, 120, 120, 0.45); }
.window-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 8px; border-bottom: 1px solid var(--ink);
  background: repeating-linear-gradient(180deg, var(--ink) 0 1px, var(--paper) 1px 3px);
}
.window-title span { background: var(--paper); padding: 0 8px; font-weight: 700; }
.keytable { width: 100%; border-collapse: collapse; }
.keytable td { padding: 5px 12px; border-top: 1px solid var(--faint); }
.keytable tr:first-child td { border-top: 0; }
.keytable td:last-child { text-align: right; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
  .app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "menu" "opts" "tools" "view" "strip" "panels" "status"; }
  .tools { flex-direction: row; justify-content: flex-start; padding: 6px 8px; }
  .tools hr { width: 1px; height: 24px; border-top: 0; border-left: 1px dotted var(--ink); }
  .viewport { height: 62vh; }
  .panels { overflow: visible; padding: 0; }
  .calib { display: none; }
  .opt-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- empty canvas ---------- */
.empty-canvas {
  width: min(420px, 100%); background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--desk-drop);
  padding: 20px 22px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; cursor: default;
}
.empty-title { margin: 0; font-weight: 700; font-size: 14px; width: 100%; padding-bottom: 10px; position: relative; }
.empty-title::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 7px;
  background: radial-gradient(circle, #000 0.55px, transparent 0.9px) 0 0 / 3px 3px; opacity: .55;
}
.empty-text { margin: 4px 0 4px; }
.empty-formats { margin: 4px 0 0; font: 11px var(--font-mono); color: var(--mute); }

/* ---------- module switches, colour rows, frames ---------- */
.stage[data-tool=frame] { cursor: crosshair; }
.tool svg .thin { stroke-width: 1; }
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span {
  width: 30px; height: 15px; border: 1px solid var(--ink); background: var(--paper); box-shadow: 1px 1px 0 var(--drop); position: relative;
}
.switch span::after { /* the knob, with a LED that lights when on */
  content: ""; position: absolute; top: 2px; left: 2px; width: 9px; height: 9px; border-radius: 50%;
  background: #cfcfcf; border: 1px solid rgba(0,0,0,.35); transition: left .12s;
}
.switch input:checked + span { background: var(--yellow); }
.switch input:checked + span::after { left: 16px; background: var(--red); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.adj.off .params, .adj.off .ramp, .adj.off .stops { opacity: .45; }
.adj.off .adj-t { color: var(--mute); }
.param-color { grid-template-columns: 86px 44px minmax(0, 1fr); }
.param-color input[type=color] { width: 44px; height: 20px; border: 1px solid var(--ink); padding: 1px; background: var(--paper); box-shadow: 1px 1px 0 var(--drop); cursor: pointer; }
.param-color code { font: 11px var(--font-mono); color: var(--mute); }
.frames-ctl { margin-top: 6px; }
.frames-info { margin: 0 0 6px; font-size: 12px; color: var(--mute); }
.frames-btns { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- look strip: tiles under the photo ---------- */
.lookstrip { grid-area: strip; min-width: 0; }
.strip-scroll { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 8px; scroll-snap-type: x proximity; overscroll-behavior: contain; }
.strip-set { display: flex; gap: 8px; }
.strip-set:empty { display: none; }
.strip-set + .strip-set { padding-left: 12px; border-left: 1px solid var(--rule); }
.lookstrip .row-item, .lookstrip .urow { flex: none; }
.lookstrip .row-item { width: 108px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 0; border: 0; background: none; text-align: left; scroll-snap-align: start; }
.lookstrip .th { display: block; height: 64px; background: var(--thumb, linear-gradient(135deg, #888, #444)) center / cover; outline: 1px solid var(--rule); }
.lookstrip .row-item .led, .lookstrip .row-item .tag { display: none; }
.lookstrip .row-item .sw { height: 3px; }
.lookstrip .row-item .nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lookstrip .row-item[aria-pressed=true] .th { outline: 2px solid var(--ink); }
.lookstrip .urow { position: relative; }
.lookstrip .urow .del { top: 4px; right: 4px; }
.lookstrip .empty { display: none; }
.strip-meta { margin: 0 2px; font-size: 11px; color: var(--mute); }
.strip-cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 2px 2px; }
.strip-cat { padding: 2px 8px; background: none; border: 1px solid var(--rule); cursor: pointer; font-size: 12px; }
.strip-cat[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.strip-cat .n { opacity: 0.6; }
.th { display: none; }
.lookstrip .th { display: block; }

/* ---------- visual pickers (pickers.js): Texture and LUT swatches under their row ---------- */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; padding: 6px 0 10px; }
.pick-grid[hidden] { display: none; }
.pick-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--mute); }
.pick-close { background: none; border: 0; cursor: pointer; color: inherit; }
.pick-sw { display: flex; flex-direction: column; gap: 3px; padding: 0; background: none; border: 0; cursor: pointer; text-align: left; font-size: 11px; color: inherit; }
.pick-sw canvas { width: 100%; height: auto; aspect-ratio: 176 / 118; outline: 1px solid var(--rule); }
.pick-sw[aria-selected=true] canvas { outline: 2px solid var(--ink); }
.pick-sw.busy canvas { opacity: 0.4; }
.pick-grid.missing::after { content: "The Analog kit isn't installed (assets/analog)."; grid-column: 1 / -1; font-size: 12px; color: var(--mute); }
.has-picker select { cursor: pointer; }

.pick-sw { position: relative; }
.pick-del { position: absolute; top: 3px; right: 3px; padding: 0 5px; line-height: 16px; font-size: 10px; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; opacity: 0; }
.pick-sw:hover .pick-del { opacity: 1; }
.pick-add .plus { display: grid; place-items: center; aspect-ratio: 176 / 118; font-size: 22px; outline: 1px dashed var(--rule); }

/* ---------- crop tool ---------- */
.crop-ui { position: absolute; z-index: 3; overflow: hidden; cursor: crosshair; touch-action: none; }
.crop-ui[hidden] { display: none; }
.crop-box { position: absolute; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.55); outline: 1px solid #fff; cursor: move; }
.crop-thirds { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.67% - .5px), rgba(255,255,255,.45) calc(66.67% - .5px) calc(66.67% + .5px), transparent calc(66.67% + .5px)),
              linear-gradient(180deg, transparent calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.67% - .5px), rgba(255,255,255,.45) calc(66.67% - .5px) calc(66.67% + .5px), transparent calc(66.67% + .5px)); }
.crop-box i { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.crop-box i[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; } .crop-box i[data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
.crop-box i[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; } .crop-box i[data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop-box i[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; } .crop-box i[data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop-box i[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; } .crop-box i[data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }
.crop-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.crop-opts[hidden] { display: none; }
.crop-opts .btn[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.crop-size { font-size: 12px; color: var(--mute); min-width: 90px; text-align: center; }
.stage[data-tool=crop] { cursor: default; }
.optionsbar:has(#cropOpts:not([hidden])) .opt-hint { display: none; }

/* ---------- overlays and border ---------- */
.overlay-canvas { position: absolute; z-index: 2; pointer-events: none; }
.overlay-canvas[hidden], .border-ui[hidden] { display: none; }
.border-ui { position: absolute; z-index: 0; pointer-events: none; }
.pasteboard canvas#gl { position: relative; z-index: 1; }
.pasteboard.bordered canvas#gl { outline: 0; box-shadow: none; }

/* ---------- guided editing ---------- */
.lookstrip { position: relative; }
.guide-toggle { position: absolute; right: 2px; top: 2px; z-index: 2; }
.lookstrip.guided .strip-cats, .lookstrip.guided .strip-scroll, .lookstrip.guided .strip-meta { display: none; }
.guide[hidden] { display: none; }
.guide-steps { display: flex; flex-wrap: wrap; gap: 4px; padding-right: 80px; }
.guide-step { display: flex; align-items: baseline; gap: 6px; padding: 4px 9px; background: none; border: 1px solid var(--rule); cursor: pointer; }
.guide-step b { font-weight: 500; opacity: 0.6; }
.guide-step small { opacity: 0.7; font-size: 11px; }
.guide-step[aria-current=true] { background: var(--ink); color: var(--paper); }
.guide-hint { margin: 6px 2px; font-size: 12px; color: var(--mute); }
.guide-opts { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.guide-opts::-webkit-scrollbar { display: none; }
.guide-opt { flex: none; min-width: 96px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px; background: none; border: 1px solid var(--rule); cursor: pointer; text-align: left; }
.guide-opt i { display: block; width: 100%; height: 6px; }
.guide-opt small { font-size: 10px; opacity: 0.6; }
.guide-opt[aria-pressed=true] { border-color: var(--ink); outline: 1px solid var(--ink); }
.guide-nav { display: flex; gap: 6px; justify-content: flex-end; }
.pasteboard canvas.overlay-canvas { outline: 0; box-shadow: none; }

/* ---------- export dialog ---------- */
.export-win { width: min(560px, calc(100vw - 32px)); }
.export-form { display: grid; gap: 2px; padding: 8px 12px 12px; }
.ex-row { display: grid; grid-template-columns: 9.5em 1fr; align-items: center; min-height: 36px; gap: 12px; }
.ex-row[hidden] { display: none; }
.ex-label { font-size: 14px; }
.ex-seg { display: flex; gap: 2px; flex-wrap: wrap; }
.ex-seg label { position: relative; cursor: pointer; }
.ex-seg input, .ex-checks input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ex-seg span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--rule); }
.ex-seg input:checked + span { background: var(--yellow); }
.ex-seg input:focus-visible + span, .ex-checks input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.ex-range { display: flex; align-items: center; gap: 10px; }
.ex-range input[type=range] { flex: 1; }
.ex-range input[type=number], .ex-size input { width: 6ch; text-align: right; }
.ex-size { display: flex; gap: 10px; align-items: center; }
.ex-size select { flex: 1; }
.ex-checks { display: grid; gap: 4px; }
.ex-checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ex-checks span::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border: 1px solid currentColor; }
.ex-checks input:checked + span::before { background: currentColor; box-shadow: inset 0 0 0 2px var(--paper); }
.ex-checks input:disabled + span { opacity: 0.4; cursor: default; }
.ex-name { display: flex; align-items: baseline; gap: 2px; }
.ex-name input { flex: 1; min-width: 0; }
.ex-summary { margin: 10px 0 0; font-size: 13px; color: var(--mute); }
.ex-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- basic dials, Advanced ---------- */
.basic[hidden], .param.basic-row[hidden] { display: none; }
.adv-toggle { display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 6px 0; background: none; border: 0; border-top: 1px solid var(--rule); cursor: pointer; text-align: left; }
.adv-toggle::after { content: ""; width: 7px; height: 7px; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 0.18s; }
.adv-toggle[aria-expanded=true]::after { transform: rotate(-135deg); }
.adv-meta { font-size: 12px; color: var(--mute); }
#settingsPanel:not(.adv-open) #secTabs, #settingsPanel:not(.adv-open) #adjust { display: none; }

/* ---------- split tone pairs ---------- */
.tone-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; padding: 6px 0 8px; }
.tone-sw { display: flex; flex-direction: column; gap: 4px; padding: 0; background: none; border: 0; cursor: pointer; text-align: left; font-size: 11px; color: inherit; }
.tone-sw i { display: block; height: 22px; outline: 1px solid var(--rule); }
.tone-sw span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tone-sw[aria-selected=true] i { outline: 2px solid var(--ink); }

/* ---------- split before / after ---------- */
.split-canvas { position: absolute; z-index: 2; pointer-events: none; outline: 0 !important; box-shadow: none !important; }
.split-canvas[hidden], .split-ui[hidden] { display: none; }
.split-ui { position: absolute; z-index: 3; pointer-events: none; }
.split-line { position: absolute; top: 0; bottom: 0; width: 28px; margin-left: -14px; cursor: ew-resize; pointer-events: auto; touch-action: none; outline: none; }
.split-line::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.split-grip { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.split-grip::before, .split-grip::after { content: ""; position: absolute; top: 9px; border: 4px solid transparent; }
.split-grip::before { left: 2px; border-right-color: #333; }
.split-grip::after { right: 2px; border-left-color: #333; }
.split-line:focus-visible .split-grip { outline: 2px solid var(--blue); outline-offset: 2px; }
.split-tag { position: absolute; top: 10px; padding: 2px 8px; font-size: 12px; background: rgba(0, 0, 0, 0.45); color: #fff; }
.split-tag-before { left: 10px; }
.split-tag-after { right: 10px; }

/* ---------- room for the photo ---------- */
.panel-fold { cursor: pointer; user-select: none; }
.panel-fold::after { content: ""; width: 7px; height: 7px; margin-left: 10px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 0.18s; flex: none; }
.panel-fold[aria-expanded=true]::after { transform: rotate(-135deg); }
#histPanel.folded > :not(.panel-h) { display: none; }
#histPanel.folded .panel-h { margin-bottom: 0; }
@media (min-width: 901px) { .app.panels-off { grid-template-columns: 0 minmax(0, 1fr) 0; column-gap: 0; } }
.app.panels-off > .tools, .app.panels-off > .panels { display: none; }

/* ---------- favourites, hidden categories, vary ---------- */
.lookstrip .row-item { position: relative; }
.lookstrip .row-item .fav { position: absolute; top: 4px; left: 4px; z-index: 2; width: 22px; height: 22px; display: grid; place-items: center; font-size: 13px; line-height: 1; opacity: 0; cursor: pointer; background: rgba(0, 0, 0, 0.4); color: #fff; }
.lookstrip .row-item:hover .fav, .lookstrip .row-item.is-fav .fav { opacity: 1; }
.lookstrip .row-item.is-fav .fav { color: #ffd34d; }
.vary-btn { margin-left: 10px; }
.vary-btn[hidden] { display: none; }

/* ---------- open photos (tool rail), status bar ---------- */
.photo-strip { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 1 0; min-height: 0; overflow-y: auto; margin-top: 10px; padding: 4px 0; scrollbar-width: none; }
.photo-strip[hidden] { display: none; }
.photo-tile { position: relative; flex: none; width: 40px; height: 40px; padding: 0; overflow: hidden; display: grid; place-items: center; background: var(--faint); border: 1px solid var(--rule); cursor: pointer; font-size: 9px; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile[aria-current=true] { outline: 2px solid var(--ink); outline-offset: 1px; }
.photo-x { position: absolute; top: 0; right: 0; width: 14px; height: 14px; display: grid; place-items: center; font-size: 11px; line-height: 1; background: rgba(0, 0, 0, 0.55); color: #fff; opacity: 0; }
.photo-tile:hover .photo-x { opacity: 1; }
.photo-add { font-size: 18px; background: none; border-style: dashed; }
.statusbar .cell:has(#sPrev), .statusbar .cell:has(#sPos), .statusbar .cell:has(#sSeed) { display: none; }
#trySample[hidden] { display: none; }

/* ---------- gradient map palettes ---------- */
.param[hidden] { display: none; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; padding: 6px 0 8px; }
.pal-sw { display: flex; flex-direction: column; gap: 4px; padding: 0; background: none; border: 0; cursor: pointer; text-align: left; font-size: 11px; color: inherit; }
.pal-sw i { display: block; height: 18px; outline: 1px solid var(--rule); }
.pal-sw span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-sw[aria-selected=true] i { outline: 2px solid var(--ink); }

/* ---------- texture over the edit ---------- */
.tex-rows { margin-top: 2px; }
.tex-rows[hidden] { display: none; }

/* ---------- the sequence bar ---------- */
.seq-tabs { display: flex; gap: 2px; margin: 0 2px 6px; overflow-x: auto; scrollbar-width: none; }
.seq-tab { flex: none; display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 6px; align-items: baseline; padding: 4px 10px; background: none; border: 1px solid var(--rule); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.seq-tab .seq-n { grid-row: 1 / 3; font-size: 11px; color: var(--mute); }
.seq-tab[aria-current=true] { background: var(--ink); color: var(--paper); }
.seq-head[hidden], .seq-opts[hidden] { display: none; }
.seq-head { display: flex; align-items: center; gap: 12px; margin: 0 2px 4px; }
.seq-nav { display: flex; gap: 6px; margin-left: auto; }
.seq-opts { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 8px; scroll-snap-type: x proximity; overscroll-behavior: contain; scrollbar-width: none; }
.seq-opt { flex: none; width: 108px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 0; background: none; border: 0; text-align: left; cursor: pointer; font: inherit; color: inherit; scroll-snap-align: start; }
.seq-opt .th { display: block; height: 64px; background: var(--thumb, linear-gradient(135deg, #888, #444)) center / cover; outline: 1px solid var(--rule); }
.seq-opt .nm { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-opt[aria-pressed=true] .th { outline: 2px solid var(--ink); }
.seq-opt.seq-act .th { background: var(--faint); }
.lookstrip.seq-step .strip-cats, .lookstrip.seq-step .strip-scroll, .lookstrip.seq-step .empty { display: none; }

/* ---------- stage 1: a neutral surround, a foldable strip, full screen and lights ---------- */
.seq-tab.edited .seq-name::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 6px; vertical-align: 3px; border-radius: 50%; background: currentColor; }
.lookstrip.folded .seq-head, .lookstrip.folded .seq-opts, .lookstrip.folded .strip-cats, .lookstrip.folded .strip-scroll, .lookstrip.folded .empty { display: none !important; }
.lookstrip.folded .seq-tabs { margin-bottom: 0; }
.app.focus-full { grid-template-columns: 0 minmax(0, 1fr) 0; grid-template-rows: 0 0 minmax(0, 1fr) 0 0; gap: 0; padding: 0; }
.app.focus-full > :not(.viewport) { display: none; }
.app.focus-full .viewport { background: #000; }
body.lights-dim .app > :not(.viewport), body.lights-dim .viewport .ruler, body.lights-dim .viewport .ruler-corner { opacity: 0.18; transition: opacity 0.25s; }
body.lights-out .app > :not(.viewport) { opacity: 0; transition: opacity 0.25s; }
body.lights-out .viewport { background: #000; }

/* ---------- stage 2: the side panel follows the step ---------- */
#advToggle { display: none; }
#settingsPanel.overview-mode #secTabs, #settingsPanel.overview-mode #adjust { display: none; }
.sec-empty { align-self: center; padding: 0 6px; font-size: 12px; color: var(--mute); }
