/* noamart.
 *
 * The chrome is deliberately neutral grey. This is a colour-correction tool:
 * a tinted or saturated UI sits in the user's peripheral vision and drags
 * every white-balance judgement they make with it. The only saturated colour
 * in the app is the Complete Finalizing banner, which is meant to nag.
 */

:root {
  --bg: #17181a;
  --surface: #202225;
  --surface-2: #2a2d31;
  --line: #34383d;
  --text: #e6e8ea;
  --muted: #9aa0a6;
  --accent: #4c8dff;
  --danger: #e2564a;
  --check: #46c17e;
  --radius: 7px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 13px;
  cursor: pointer;
}
button:hover { background: #33373c; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.danger { color: var(--danger); border-color: transparent; }
button:disabled { opacity: .45; cursor: default; }

a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* --- Complete Finalizing --------------------------------------------------
 * Pulses rather than strobes: a hard flash is genuinely unpleasant to sit in
 * front of for 388 photos, and can be a real problem for photosensitive
 * viewers. Under prefers-reduced-motion it holds still.
 */
.finalizing {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 9px 16px;
  background: #b3341f;
  color: #fff;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 12.5px;
  animation: finalizing-pulse 1.2s ease-in-out infinite;
}
.finalizing-count { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .85; }
@keyframes finalizing-pulse {
  0%, 100% { background: #b3341f; }
  50%      { background: #e05a3d; }
}
@media (prefers-reduced-motion: reduce) {
  .finalizing { animation: none; background: #b3341f; }
}

/* --- top bar -------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; letter-spacing: .02em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge-admin {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 3px 7px; border-radius: 999px; color: var(--muted);
}

.search { position: relative; display: flex; align-items: center; gap: 10px; flex: 1; max-width: 460px; }
.search input {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 7px 30px 7px 11px;
}
.search input:focus { outline: none; border-color: var(--accent); }
#search-clear {
  position: absolute; right: 96px; background: none; border: none;
  color: var(--muted); padding: 0 6px; font-size: 17px;
}
#search-count { white-space: nowrap; font-size: 12px; min-width: 78px; }

/* --- grid ----------------------------------------------------------------- */
.grid {
  display: grid; gap: 14px; padding: 18px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.tile { border-radius: var(--radius); }
.tile:focus { outline: 2px solid var(--accent); outline-offset: 3px; }
.tile.is-hidden { opacity: .38; }
.tile[hidden] { display: none; }

.tile-link {
  position: relative; display: block; aspect-ratio: 1;
  /* Letterbox colour, darker than the surface so the bars read as empty space
     rather than as part of the tile. */
  background: #0e0f10; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
/* `contain`, not `cover`. The thumbnail is already the cropped picture, and
   cover would crop it a second time to fill a square tile -- so a photo would
   show LESS in the grid than the crop the user actually chose. Bars are the
   honest answer: the whole edited picture, whatever shape it ended up. */
.tile-link img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}

.check {
  position: absolute; top: 7px; right: 7px;
  width: 23px; height: 23px; border-radius: 50%;
  background: var(--check); color: #10241a;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
}
.hidden-badge {
  position: absolute; left: 7px; top: 7px;
  background: rgba(0,0,0,.72); color: #fff;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 4px;
}
.sel-dot {
  position: absolute; left: 7px; bottom: 7px;
  width: 19px; height: 19px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.75); background: rgba(0,0,0,.3);
  display: none;
}
body.selecting .sel-dot { display: block; }
.tile.selected .sel-dot { background: var(--accent); border-color: #fff; }
.tile.selected .tile-link { outline: 2px solid var(--accent); outline-offset: -2px; }

.tile-meta { display: flex; flex-direction: column; padding: 6px 2px 0; min-height: 34px; }
.tile-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; color: var(--muted);
}
.empty { grid-column: 1/-1; color: var(--muted); padding: 40px; text-align: center; }

/* --- login ---------------------------------------------------------------- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(360px, 90vw); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 30px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card label { display: block; margin: 14px 0 5px; font-size: 12px; color: var(--muted); }
.login-card input {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 11px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { width: 100%; margin-top: 20px; background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- editor --------------------------------------------------------------- */
.editor-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }

.name-field { display: flex; align-items: center; gap: 9px; flex: 1; max-width: 560px; }
.name-field label { font-size: 11px; letter-spacing: .07em; color: var(--muted); }
.name-field input {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 7px 11px;
}
.name-field input:focus { outline: none; border-color: var(--accent); }
.orig-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}

.stage {
  position: relative; display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background:
    repeating-conic-gradient(#1b1c1e 0% 25%, #202124 0% 50%) 50%/22px 22px;
}
.stage-inner {
  flex: 1; position: relative; display: grid; place-items: center;
  min-height: 0; padding: 22px;
}
.warp-box { position: relative; overflow: hidden; }
.warp-box canvas {
  display: block; transform-origin: 0 0; will-change: transform;
  max-width: none;
}
.stage-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 9px; border-top: 1px solid var(--line); background: var(--surface);
}

.crop-overlay, .corner-overlay { position: absolute; inset: 0; pointer-events: none; }
/* The trim box dims everything outside itself with a 100vmax spread shadow.
 * Without clipping, that shadow covers the whole viewport -- including the
 * wizard panel, which goes visibly grey and looks disabled. Clip it to the
 * picture area, which is the only place the dimming is meant to apply. */
.crop-overlay { overflow: hidden; }
.crop-overlay[hidden], .corner-overlay[hidden] { display: none; }

.crop-rect {
  position: absolute; pointer-events: auto; cursor: move;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.55);
  outline: 1px solid rgba(255,255,255,.9);
}
.crop-rect::before, .crop-rect::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.33%, rgba(255,255,255,.28) 33.33% calc(33.33% + 1px),
      transparent calc(33.33% + 1px) 66.66%, rgba(255,255,255,.28) 66.66% calc(66.66% + 1px), transparent calc(66.66% + 1px));
}
.crop-rect::after {
  background:
    linear-gradient(to bottom, transparent 33.33%, rgba(255,255,255,.28) 33.33% calc(33.33% + 1px),
      transparent calc(33.33% + 1px) 66.66%, rgba(255,255,255,.28) 66.66% calc(66.66% + 1px), transparent calc(66.66% + 1px));
}
.crop-rect i {
  position: absolute; width: 13px; height: 13px; background: #fff;
  border-radius: 2px; pointer-events: auto;
}
.crop-rect i[data-h=nw]{left:-7px;top:-7px;cursor:nwse-resize}
.crop-rect i[data-h=n] {left:calc(50% - 6px);top:-7px;cursor:ns-resize}
.crop-rect i[data-h=ne]{right:-7px;top:-7px;cursor:nesw-resize}
.crop-rect i[data-h=w] {left:-7px;top:calc(50% - 6px);cursor:ew-resize}
.crop-rect i[data-h=e] {right:-7px;top:calc(50% - 6px);cursor:ew-resize}
.crop-rect i[data-h=sw]{left:-7px;bottom:-7px;cursor:nesw-resize}
.crop-rect i[data-h=s] {left:calc(50% - 6px);bottom:-7px;cursor:ns-resize}
.crop-rect i[data-h=se]{right:-7px;bottom:-7px;cursor:nwse-resize}

.corner-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.corner-overlay polygon { fill: rgba(76,141,255,.14); stroke: var(--accent); stroke-width: 1.5; }
.corner-overlay i {
  position: absolute; width: 19px; height: 19px; margin: -10px 0 0 -10px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
  pointer-events: auto; cursor: grab; box-shadow: 0 1px 6px rgba(0,0,0,.5);
}

/* --- panel ---------------------------------------------------------------- */
.panel {
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: none; border-radius: 0;
  padding: 11px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 14px; }
.tab-body[hidden] { display: none; }

.slider { display: block; margin-bottom: 11px; }
.slider > span {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 4px;
}
.slider b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.slider.changed > span { color: var(--text); }

.row { display: flex; gap: 8px; margin-top: 12px; }
.row.stacked { flex-direction: column; align-items: stretch; }
.ratios { display: flex; gap: 5px; flex-wrap: wrap; }
.ratios button { padding: 4px 9px; font-size: 12px; }
.ratios button.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.panel-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }

.wizard-bar { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.wizard-bar[hidden] { display: none; }
.wizard-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 11px; padding: 0; counter-reset: s; }
.wizard-steps li {
  flex: 1; font-size: 11.5px; color: var(--muted); text-align: center;
  padding: 5px 2px; border-bottom: 2px solid var(--line);
}
.wizard-steps li.is-active { color: var(--text); border-bottom-color: var(--accent); }
.wizard-steps li.is-done { color: var(--check); border-bottom-color: var(--check); }
.wizard-actions { display: flex; gap: 8px; }
.wizard-actions .primary { margin-left: auto; }

/* --- toast ---------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 16px; z-index: 100;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .panel { border-left: none; border-top: 1px solid var(--line); max-height: 46vh; }
  .orig-file { display: none; }
}

/* --- grouping -------------------------------------------------------------
 * A group is one artwork photographed more than once. In the grid it collapses
 * to a single tile under the parent's name, with a chip that opens the rest.
 */
.group-title { font-size: 13px; color: var(--muted); }

.tile.is-group .tile-link {
  /* the stacked edge that says "there is more behind this one" */
  box-shadow: 3px 3px 0 -1px var(--surface), 3px 3px 0 0 var(--line),
              6px 6px 0 -1px var(--surface), 6px 6px 0 0 var(--line);
}
.folder-chip {
  position: absolute; right: 9px; bottom: 9px;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,.72); color: #fff;
  border-radius: 999px; padding: 3px 9px 3px 7px;
  font-size: 11.5px; font-weight: 600;
  backdrop-filter: blur(3px);
}
/* The chip is a label now; the whole tile is the link, so it lights up with
   the tile rather than on its own. */
.tile:hover .folder-chip { background: var(--accent); }
.folder-chip svg { width: 13px; height: 13px; fill: currentColor; }
.tile { position: relative; }

.group-state {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px; margin-bottom: 12px;
  font-size: 13px;
}
.group-state .muted { font-size: 12px; }
.group-state .row { margin-top: 9px; }
.group-thumbs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.group-thumbs img {
  width: 42px; height: 42px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--line);
}

.grouplabel { font-size: 11px; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; }
#group-q {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 11px;
}
#group-q:focus { outline: none; border-color: var(--accent); }

.group-results { display: flex; flex-direction: column; gap: 3px; margin-top: 8px;
  max-height: 300px; overflow-y: auto; }
.group-results button {
  display: flex; align-items: center; gap: 9px; text-align: left;
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  padding: 5px 7px; width: 100%;
}
.group-results button:hover { background: var(--surface-2); border-color: var(--line); }
.group-results img {
  width: 34px; height: 34px; object-fit: cover; border-radius: 4px; flex: none;
}
.group-results .r-name { font-size: 12.5px; }
.group-results .r-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; color: var(--muted); display: block;
}

/* --- wizard ---------------------------------------------------------------
 * Four steps, opened automatically on the first unfinished photo. The panel
 * becomes the wizard while it runs, so there is one thing to answer at a time.
 */
.wizard-progress { margin: 8px 0 0; font-size: 11.5px; }

.wizard-actions {
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.wizard-actions[hidden] { display: none; }
.wizard-actions .primary { margin-left: auto; }
.wizard-actions button { padding: 6px 11px; font-size: 12.5px; }

.wiz-name {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; font-size: 15px;
  margin-top: 5px;
}
.wiz-name:focus { outline: none; border-color: var(--accent); }
.wiz-name:disabled { opacity: .45; }

#wiz-group-q {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 11px; margin-top: 4px;
}
#wiz-group-q:focus { outline: none; border-color: var(--accent); }

.or-rule {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 12px; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}
.or-rule::before, .or-rule::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.warn { color: #e0a33d; }

.tile.is-deferred .tile-link { outline: 1px dashed var(--muted); outline-offset: -1px; }
.later-badge {
  position: absolute; left: 7px; bottom: 7px;
  background: rgba(0,0,0,.7); color: #e0a33d;
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 6px; border-radius: 4px;
}

/* The HTML `hidden` attribute only sets display:none via the UA stylesheet, so
 * any author rule that sets display wins and the element stays on screen. Every
 * element this app hides with .hidden = true needs its own [hidden] rule. */
.tabs[hidden],
.wizard-actions[hidden],
.finalizing[hidden] { display: none; }

/* ==========================================================================
 * WIZARD — designed for someone who is not a software person.
 *
 * Bigger than the rest of the app, but only a little. The first attempt at
 * this scaled everything up hard and the result was worse, not kinder: less
 * fits on screen, so there is more scrolling, and scrolling is the part that
 * actually loses people.
 *
 * The rules that matter:
 *   - one question per screen, stated as a sentence, not a field label;
 *   - the panel is on the LEFT, because that is where reading starts;
 *   - buttons say what they do in words rather than showing an icon;
 *   - the next action is always on screen without scrolling;
 *   - range inputs keep their NATIVE appearance (see the note below);
 *   - nothing important is carried by colour alone.
 * ========================================================================== */

.editor.is-wizard { grid-template-columns: 350px 1fr; }
.editor.is-wizard .panel {
  order: -1;                       /* panel first: reading starts on the left */
  border-left: none;
  border-right: 1px solid var(--line);
  font-size: 14.5px;
  /* The panel is a fixed frame: head, a scrolling middle, and a footer that
     is always visible. Sticky positioning was doing this before, and the
     footer sat ON TOP of the last sliders and ate their pointer events -- so
     the bottom controls could not be grabbed at all. */
  overflow: hidden;
}
.editor.is-wizard .wizard-head { flex: none; }
.editor.is-wizard .tab-body:not([hidden]) {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
}
.editor.is-wizard .wizard-foot { flex: none; position: static; }

.editor.is-wizard .wizard-head { order: 0; }
.editor.is-wizard .tab-body    { order: 1; }
.editor.is-wizard .wizard-foot { order: 99; }

.wizard-head { padding: 13px 16px 11px; border-bottom: 1px solid var(--line); }
.wizard-head[hidden] { display: none; }
.wiz-count {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.wiz-count b { color: var(--text); }
.wiz-bar {
  height: 4px; border-radius: 99px; background: var(--surface-2);
  margin: 7px 0 10px; overflow: hidden;
}
.wiz-bar i {
  display: block; height: 100%; width: 25%; border-radius: 99px;
  background: var(--accent); transition: width .25s ease;
}
.wizard-head h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
.wizard-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.editor.is-wizard .tab-body { padding: 14px 16px 18px; }

.big-label { display: block; font-size: 13.5px; font-weight: 600; margin: 0 0 5px; }
.help { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.editor.is-wizard .wiz-name,
.editor.is-wizard #wiz-group-q {
  font-size: 14.5px; padding: 9px 11px; min-height: 40px;
}
.wiz-name, #wiz-group-q {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 11px;
}
.wiz-name:focus, #wiz-group-q:focus { outline: none; border-color: var(--accent); }
.wiz-name:disabled { opacity: .45; }

.or-rule { margin: 16px 0 13px; font-size: 11px; }
.or-small { text-align: center; color: var(--muted); font-size: 12.5px; margin: 11px 0 8px; }

.wizard-foot { padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.wizard-foot[hidden] { display: none; }
button.big { width: 100%; min-height: 44px; font-size: 15.5px; font-weight: 650; border-radius: 8px; }
.wiz-secondary { display: flex; gap: 6px; margin-top: 9px; }
.wiz-secondary button {
  flex: 1; min-height: 34px; font-size: 12px; padding: 5px 6px;
  background: transparent; border-color: var(--line); color: var(--muted);
}
.wiz-secondary button:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.wiz-secondary button:disabled { opacity: .35; }

/* This has to read as a BUTTON, not a coloured banner. A flat filled block
 * with words in it is something people scroll past; the raised edge, the icon
 * and the chevron are what say "press me", and it visibly depresses when
 * pressed so the click is acknowledged. */
.wide-action {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left; padding: 12px 14px;
  min-height: 56px; border-radius: 10px;
  background: var(--accent); color: #fff;
  border: 1px solid #6ba1ff;
  box-shadow: 0 2px 0 #2f6bd8, 0 4px 12px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.wide-action:hover { background: #5d99ff; box-shadow: 0 2px 0 #2f6bd8, 0 6px 16px rgba(0,0,0,.42); }
.wide-action:active { transform: translateY(2px); box-shadow: 0 0 0 #2f6bd8, 0 2px 6px rgba(0,0,0,.35); }
.wa-icon {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-size: 15px;
}
.wa-text { flex: 1; min-width: 0; }
.wide-action b { display: block; font-size: 15.5px; line-height: 1.2; margin-bottom: 2px; }
.wa-text > span { display: block; font-size: 12px; opacity: .92; line-height: 1.3; }
.wa-go { flex: none; font-size: 24px; line-height: 1; opacity: .8; }
.wide-half { flex: 1; min-height: 40px; font-size: 13.5px; }

.shape-group { margin-bottom: 18px; }
.shape-group:last-child { margin-bottom: 2px; }
.shape-group h3 {
  margin: 0 0 3px; font-size: 14px; font-weight: 650;
  padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.editor.is-wizard .shape-group button { min-height: 38px; font-size: 13.5px; }
.editor.is-wizard .ratios button { min-height: 30px; font-size: 12px; padding: 4px 9px; }

/* Range inputs keep their NATIVE appearance on purpose.
 *
 * Setting -webkit-appearance:none and styling ::-webkit-slider-thumb makes the
 * thumb align to the top of the track box rather than its centre, so the
 * handle is drawn offset from the strip you actually drag -- it looks
 * misaligned and feels unholdable. accent-color recolours the native control
 * with none of that, and the native thumb is already a proper hit target. */
/* Eleven sliders in a column: the gaps between them were pure scrolling. */
.editor.is-wizard .slider { margin-bottom: 2px; }
.editor.is-wizard .slider > span { font-size: 12.5px; margin-bottom: 0; }
.editor.is-wizard .slider input[type=range] {
  height: 20px; margin: 0; accent-color: var(--accent); display: block;
}
.editor.is-wizard .sliders { margin-top: 4px; }
/* The tilt and lean sliders are alone on their steps and keep their room. */
.editor.is-wizard .big-slider { margin-bottom: 14px; }
.editor.is-wizard .big-slider > span { margin-bottom: 3px; }
.editor.is-wizard .big-slider input[type=range] { height: 26px; }

.summary-card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 13px 15px; font-size: 14px; line-height: 1.5;
}
.summary-card .srow { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.summary-card .srow:last-child { border-bottom: none; }
.summary-card .skey { color: var(--muted); min-width: 82px; font-size: 12.5px; }
.summary-card .sval { flex: 1; }

/* These two are drag targets on the photograph itself, not panel chrome, so
   they stay generous -- but not the oversized ones from the first pass. */
.editor.is-wizard .corner-overlay i { width: 22px; height: 22px; margin: -12px 0 0 -12px; }
.editor.is-wizard .crop-rect i { width: 15px; height: 15px; }
.editor.is-wizard .crop-rect i[data-h=nw]{left:-8px;top:-8px}
.editor.is-wizard .crop-rect i[data-h=n] {left:calc(50% - 7px);top:-8px}
.editor.is-wizard .crop-rect i[data-h=ne]{right:-8px;top:-8px}
.editor.is-wizard .crop-rect i[data-h=w] {left:-8px;top:calc(50% - 7px)}
.editor.is-wizard .crop-rect i[data-h=e] {right:-8px;top:calc(50% - 7px)}
.editor.is-wizard .crop-rect i[data-h=sw]{left:-8px;bottom:-8px}
.editor.is-wizard .crop-rect i[data-h=s] {left:calc(50% - 7px);bottom:-8px}
.editor.is-wizard .crop-rect i[data-h=se]{right:-8px;bottom:-8px}

/* Focus must be obvious for keyboard users, and never removed. */
.editor.is-wizard button:focus-visible,
.editor.is-wizard input:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* During the wizard the panel owns the name field, so the top bar's copy is a
 * second box asking the same question -- confusing, and the kind of thing that
 * makes someone think they filled it in wrong. Hide it, and hide the
 * destructive reset: nothing in a guided flow should offer to wipe the work. */
body.wizard-running .name-field { display: none; }
body.wizard-running .panel-foot { display: none; }

@media (max-width: 900px) {
  .editor.is-wizard { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .editor.is-wizard .panel { border-right: none; border-bottom: 1px solid var(--line); max-height: 60vh; }
}

/* --- guide grid -----------------------------------------------------------
 * Shown on the tilt and lean steps only. Judging "is this straight?" against
 * nothing is genuinely hard; against a grid it is immediate. Sits above the
 * picture and takes no pointer events. */
.guide-grid {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  /* Each line is a light line with a dark one a pixel below it. That reads on
     a pale mount and on a dark painting alike, without mix-blend-mode, which
     inverts the artwork's colours and makes it harder to judge, not easier. */
  /* Two densities: a fine 16x16 mesh to judge small angles against, and a
     brighter 4x4 over the top so the eye still has strong reference lines.
     6.25 divides into 25 exactly, so the two grids line up. */
  background-image:
    linear-gradient(to right,  rgba(255,255,255,.60) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.60) 1px, transparent 1px),
    linear-gradient(to right,  transparent 1px, rgba(0,0,0,.42) 1px, transparent 2px),
    linear-gradient(to bottom, transparent 1px, rgba(0,0,0,.42) 1px, transparent 2px),
    linear-gradient(to right,  rgba(255,255,255,.26) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.26) 1px, transparent 1px),
    linear-gradient(to right,  transparent 1px, rgba(0,0,0,.20) 1px, transparent 2px),
    linear-gradient(to bottom, transparent 1px, rgba(0,0,0,.20) 1px, transparent 2px);
  background-size:
    25% 25%, 25% 25%, 25% 25%, 25% 25%,
    6.25% 6.25%, 6.25% 6.25%, 6.25% 6.25%, 6.25% 6.25%;
}
.guide-grid[hidden] { display: none; }

/* --- portrait / landscape -------------------------------------------------
 * The shape is shown, not just named: a small box in the actual proportion
 * says more at a glance than the words do. */
.shape-choice { display: flex; gap: 10px; margin: 4px 0 14px; }
.shape-choice button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 14px 10px; min-height: 96px; font-size: 13.5px;
}
.shape-choice button.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.shape-box {
  display: block; border: 2px solid currentColor; border-radius: 3px;
  background: rgba(255,255,255,.10);
}
.shape-box.portrait  { width: 30px; height: 40px; }
.shape-box.landscape { width: 40px; height: 30px; }

/* With the ratio locked, the edge handles cannot express anything a corner
 * cannot, and four extra targets is four more chances to grab the wrong one. */
.editor.is-wizard .crop-rect i[data-h=n],
.editor.is-wizard .crop-rect i[data-h=s],
.editor.is-wizard .crop-rect i[data-h=e],
.editor.is-wizard .crop-rect i[data-h=w] { display: none; }

hr.soft { border: none; border-top: 1px solid var(--line); margin: 18px 0 14px; }

.slider .ends {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-top: 3px;
}
#v-keystone { font-weight: 600; color: var(--text); }

/* --- edited / not edited filter ------------------------------------------ */
.filters { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.chip:hover { background: #33373c; color: var(--text); }
.chip b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.chip.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chip.is-active b { color: #fff; }

@media (max-width: 1100px) {
  .filters .chip b { display: none; }
}

/* Reachable from any photo opened directly, not only from the grid. */
.run-wizard {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius);
  border: 1px solid var(--accent); color: var(--accent);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.run-wizard:hover { background: var(--accent); color: #fff; }

/* Untouched photo: the same control, wearing the state it is about. */
.run-wizard.is-unedited { border-color: var(--danger); color: var(--danger); gap: 8px; }
.run-wizard.is-unedited:hover { background: var(--danger); color: #fff; }
.run-wizard.is-unedited:hover .rw-pill { background: #fff; color: var(--danger); }
.rw-pill {
  background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 650; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}

/* Untouched photos say so. The checkmark alone marks what is done but leaves
 * what is outstanding to be inferred from its absence, which is the harder
 * thing to see across a grid of 253. The wording matches the "Not edited"
 * filter chip, so the badge and the filter are plainly the same thing. */
.need-edit {
  position: absolute; top: 7px; right: 7px;
  background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 650;
  letter-spacing: .04em; text-transform: lowercase;
  padding: 3px 9px; border-radius: 999px;
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
  white-space: nowrap;
}

/* The way back out. It was a ghost link and read as decoration; leaving the
 * editor is a thing people look for, so it looks like a button. */
.home-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; min-height: 42px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.home-btn:hover { background: #33373c; border-color: var(--muted); }

/* --- group filmstrip ------------------------------------------------------
 * The other shots of the same artwork, under the picture. A group is one
 * artwork photographed more than once, so the rest of it is context you want
 * while working on any single frame -- and it is the quickest way between
 * them, which the prev/next arrows are not (they step through the whole set).
 */
.filmstrip {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 14px 9px;
  flex: none;
}
.filmstrip-label {
  display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.filmstrip-row {
  display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px;
  /* `safe center` centres a short strip but falls back to start-aligned when
     the group is long enough to scroll -- plain `center` would push the first
     thumbnails off the left edge, out of reach. */
  justify-content: center;
  justify-content: safe center;
}
.filmstrip-label { text-align: center; }
.film {
  flex: none; width: 60px; height: 60px; border-radius: 5px;
  overflow: hidden; background: #0e0f10;
  border: 2px solid transparent; opacity: .72;
}
.film img { width: 100%; height: 100%; object-fit: contain; display: block; }
.film:hover { opacity: 1; border-color: var(--muted); }
/* The current frame is marked by more than colour -- it stays fully opaque and
   keeps a visible ring, so it reads without relying on hue. */
.film.is-current { opacity: 1; border-color: var(--accent); cursor: default; }
