:root {
  --bg: #0a0b0e;
  --stage: #07080a;
  --surface: #111318;
  --surface-2: #171a20;
  --surface-3: #1e222a;
  --surface-4: #262b35;
  --line: #232832;
  --line-strong: #323946;
  --text: #edeff4;
  --text-2: #b9c0cc;
  --muted: #7e8796;
  --accent: #f6c445;
  --accent-2: #ffd978;
  --accent-ink: #1f1500;
  --accent-soft: rgba(246, 196, 69, 0.13);
  --accent-line: rgba(246, 196, 69, 0.45);
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.icon { display: inline-flex; flex: none; }

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121419, #0e1014);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.2px; font-size: 15px; }
.logo { filter: drop-shadow(0 4px 10px rgba(246, 170, 60, 0.25)); }
.doc { color: var(--muted); font-size: 12.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc b { color: var(--text-2); font-weight: 500; }
.actions { display: flex; align-items: center; gap: 6px; }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-3);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: var(--surface-4); border-color: #3d4554; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line); color: var(--text); }
.btn.accent { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-ink); font-weight: 600; box-shadow: 0 6px 18px rgba(246, 196, 69, 0.18); }
.btn.accent:hover:not(:disabled) { background: linear-gradient(180deg, #ffe08f, #f8cc58); }
.btn.small { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.big { height: 42px; padding: 0 20px; font-size: 14px; border-radius: 11px; }
.btn.wide { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 340px;
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 9px 2px 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rail-item:hover { color: var(--text); background: var(--surface-2); }
.rail-item.active { color: var(--accent); background: var(--accent-soft); }
.rail-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.rail-item .badge {
  position: absolute;
  top: 6px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}

/* Stage */
.stage-wrap { position: relative; min-height: 0; background: radial-gradient(ellipse at 50% 40%, #12141a 0%, var(--stage) 70%); }
.stage { position: absolute; inset: 0; display: flex; overflow: auto; padding: 28px 28px 84px; }
.viewport { position: relative; margin: auto; }
#view {
  display: block;
  border-radius: 4px;
  background: repeating-conic-gradient(#24272d 0% 25%, #191b20 0% 50%) 50% / 18px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
#view.brushing { cursor: none; touch-action: none; }
#view.panning:not(.brushing) { cursor: grab; touch-action: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
/* Properly downsampled copy of #view shown when the photo is displayed smaller than its pixels. */
/* Marks the person whose own settings are being edited. */
.person-ring { position: absolute; border: 2px dashed var(--accent); border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
#display { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 4px; pointer-events: none; }
/* Zoomed in past the working copy: the part on screen rendered from the full-size photo (1:1). Opaque, with
   #view's checkerboard (lined up from main.js), so a transparent background does not show #view through it. */
#loupe { position: absolute; pointer-events: none; background: repeating-conic-gradient(#24272d 0% 25%, #191b20 0% 50%) 0 0 / 18px 18px; }

.brush {
  position: absolute;
  border: 1.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.split { position: absolute; top: 0; width: 0; cursor: ew-resize; touch-action: none; z-index: 3; }
.split::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.split::after { content: ""; position: absolute; top: 0; bottom: 0; left: -14px; width: 28px; }
.split-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.split-knob::before, .split-knob::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  transform: translateY(-50%);
}
.split-knob::before { left: 6px; border-right-color: #333; }
.split-knob::after { right: 6px; border-left-color: #333; }
.split-tag {
  position: absolute;
  top: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 11, 14, 0.72);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.split-tag.left { right: 12px; }
.split-tag.right { left: 12px; }

.empty, .busy { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; }
.empty-card {
  max-width: 470px;
  padding: 36px 34px 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background: rgba(17, 19, 24, 0.75);
  text-align: center;
  transition: border-color .2s, background .2s;
}
.stage-wrap.drag .empty-card { border-color: var(--accent); background: rgba(246, 196, 69, 0.06); }
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty h1 { margin: 0 0 8px; font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
.empty p { margin: 0 auto 20px; max-width: 380px; color: var(--muted); }
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.features { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 22px 0 0; padding: 0; list-style: none; }
.features li { padding: 5px 11px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 12px; }

.busy { background: rgba(7, 8, 10, 0.55); backdrop-filter: blur(3px); z-index: 6; }
.busy-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--surface-4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-tools {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(23, 26, 32, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 4;
}
.tool {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background .15s, color .15s;
}
.tool:hover { background: var(--surface-3); color: var(--text); }
.tool.active { background: var(--accent-soft); color: var(--accent); }
.zoom-label { min-width: 58px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tools-divider { width: 1px; height: 20px; margin: 0 4px; background: var(--line-strong); }

.toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border: 1px solid #5a2a31;
  border-radius: 10px;
  background: #2a1519;
  box-shadow: var(--shadow);
  z-index: 7;
}

/* Panel */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panes { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
.pane { display: none; padding: 10px 10px 16px; }
.pane.active { display: grid; gap: 8px; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }

.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 0 10px 0 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.group-title { flex: 1; }
.group-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity .15s; }
.group.changed .group-head .dot { opacity: 1; }
.group-reset { width: 26px; height: 26px; opacity: 0; pointer-events: none; }
.group.changed .group-reset { opacity: 1; pointer-events: auto; }
.group-head > .icon:last-child { color: var(--muted); transition: transform .2s; }
.group.collapsed .group-head > .icon:last-child { transform: rotate(-90deg); }
.group-body { display: grid; gap: 12px; padding: 2px 14px 14px; }
.group.collapsed .group-body { display: none; }

.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.label { margin: 2px 0 -4px; color: var(--muted); font-size: 12px; }
.note { margin: 0; padding: 10px 12px; border: 1px solid #4a3f1e; border-radius: 10px; background: #221d10; color: #f3d98a; font-size: 12.5px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.stack { display: grid; gap: 10px; }

/* Sliders */
.sliders { display: grid; gap: 14px; }
.sliders:empty { display: none; }
.slider { --lo: 0%; --hi: 0%; display: grid; gap: 7px; cursor: default; }
.slider-head { display: flex; justify-content: space-between; color: var(--text-2); font-size: 12.5px; }
.slider-head output { min-width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.slider.changed .slider-head output { color: var(--accent); }
.slider input {
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.slider input:focus { outline: none; }
.slider input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-4) var(--lo), var(--accent) var(--lo), var(--accent) var(--hi), var(--surface-4) var(--hi));
}
.slider input::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-4) var(--lo), var(--accent) var(--lo), var(--accent) var(--hi), var(--surface-4) var(--hi));
}
.slider input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.04);
  transition: transform .12s;
}
.slider input::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }
.slider input:active::-webkit-slider-thumb { transform: scale(1.18); }
.slider.bipolar input::-webkit-slider-runnable-track {
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) 50% 50% / 2px 10px no-repeat,
    linear-gradient(90deg, var(--surface-4) var(--lo), var(--accent) var(--lo), var(--accent) var(--hi), var(--surface-4) var(--hi));
}

/* Choices, chips, swatches */
.choices { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.choices.wrap { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.choices button {
  min-height: 30px;
  padding: 5px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.choices button:hover { color: var(--text); }
.choices button.active { background: var(--surface-4); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }

.chip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.chip-card {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.chip-card .icon { color: var(--accent); }
.chip-card:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-3); }
.chip-card.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--accent); }
.swatch.custom {
  display: grid;
  place-items: center;
  background: conic-gradient(from 0deg, #ff5d5d, #ffd25d, #6dff8a, #5dd3ff, #8c6dff, #ff5dcf, #ff5d5d);
  color: #fff;
}
.swatch.custom.active { background: var(--c); }
.swatch.custom .icon { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mini-swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }

.bands { display: flex; justify-content: space-between; }
.band {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: var(--c);
  cursor: pointer;
  transition: transform .12s;
}
.band:hover { transform: scale(1.1); }
.band.active { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--c); }

.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile {
  position: relative;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(170deg, var(--a, #333), var(--b, #111));
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform .12s, box-shadow .15s;
}
.tile.radial { background: radial-gradient(circle at 50% 40%, var(--a), var(--b) 85%); }
.tile.off { background: repeating-linear-gradient(45deg, var(--surface-3) 0 6px, var(--surface) 6px 12px); }
.tile:hover { transform: translateY(-1px); }
.tile.active { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--accent); }
.tile span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 6px 5px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
}

.look-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 6px; }
.look { display: grid; gap: 5px; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; }
.look-swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform .12s, box-shadow .15s;
}
.look:hover .look-swatch { transform: translateY(-1px); }
.look.active .look-swatch { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--accent); }
.look-name { color: var(--muted); font-size: 11px; line-height: 1.2; }
.look.active .look-name { color: var(--text); }

.tool-list { display: grid; gap: 6px; }
.tool-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tool-card:hover { border-color: var(--line-strong); background: var(--surface-3); }
.tool-card.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.tool-text { display: grid; gap: 1px; }
.tool-text b { color: var(--text); font-weight: 600; font-size: 13px; }
.tool-text small { color: var(--muted); font-size: 11.5px; }

.text-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
}
.text-input:focus { border-color: var(--accent-line); }
.custom-list { display: grid; gap: 6px; }
.custom-row { display: flex; gap: 4px; align-items: center; }
.custom-apply {
  flex: 1;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.custom-apply:hover { border-color: var(--accent-line); }
.ref-thumb { display: block; max-width: 100%; max-height: 110px; border-radius: 8px; }
.blemish-info { display: grid; gap: 10px; padding-top: 4px; border-top: 1px dashed var(--line); }
.check { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* Filmstrip */
.strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 84px;
  padding: 10px 16px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: thin;
}
.thumb {
  position: relative;
  flex: none;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-3);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform .12s, box-shadow .15s;
}
.thumb:hover { transform: translateY(-1px); }
.thumb.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb .badges { position: absolute; left: 3px; bottom: 3px; display: grid; gap: 2px; }
.thumb .badges b { padding: 0 5px; border-radius: 4px; background: rgba(214, 48, 60, 0.9); color: #fff; font-size: 9.5px; font-weight: 600; }
.thumb .remove {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity .15s;
}
.thumb:hover .remove { opacity: 1; }
.thumb.add {
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.thumb.add:hover { color: var(--accent); border-color: var(--accent-line); }
.strip-hint { color: var(--muted); font-size: 12px; }
.strip-queue { color: var(--muted); font-size: 12px; white-space: nowrap; animation: ai-pulse 1.4s ease-in-out infinite; }
.thumb .ai-pending { position: absolute; right: 4px; bottom: 4px; padding: 0 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: 0.02em; animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .strip-queue, .thumb .ai-pending { animation: none; } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 72px minmax(0, 1fr) 300px; }
  .doc { display: none; }
  .topbar { grid-template-columns: auto 1fr; }
  .actions { justify-content: flex-end; }
}

@media (max-width: 820px) {
  body { display: block; height: auto; }
  .topbar { position: sticky; top: 0; z-index: 10; height: auto; padding: 10px 12px; gap: 8px; }
  .brand span { display: none; }
  .actions .divider { display: none; }
  .actions .btn { padding: 0 10px; }
  .actions .btn-text { display: none; }
  .actions { gap: 2px; }
  .layout { display: flex; flex-direction: column; }
  .stage-wrap { order: 1; height: 56vh; }
  .rail {
    order: 2;
    flex-direction: row;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail-item { flex: none; width: 64px; }
  .rail-item.active::before { left: 12px; right: 12px; top: auto; bottom: -8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .panel { order: 3; border-left: 0; }
  .panes { overflow: visible; }
  .stage { padding: 16px 16px 76px; }
  .empty-card { padding: 22px 18px; border-radius: 18px; }
  .empty-icon { width: 48px; height: 48px; margin-bottom: 10px; }
  .empty h1 { font-size: 18px; }
  .empty p { margin-bottom: 16px; font-size: 12.5px; }
  .features { display: none; }
}

.stage.hand, .stage.hand #view { cursor: grab !important; }
.stage.grabbing, .stage.grabbing #view { cursor: grabbing !important; }
.stage.scrubbing, .stage.scrubbing #view { cursor: zoom-in !important; }

/* Tone curve */
.curve-tabs button.active { color: var(--c); }
.curve-box {
  position: relative;
  aspect-ratio: 1;
  margin: 8px 0 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(to top, rgba(255, 255, 255, 0.05), transparent), var(--surface);
  overflow: hidden;
}
.curve-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.curve-box::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(to right, #000, #fff);
  opacity: 0.6;
  pointer-events: none;
}

/* AI auto-edit */
.field { display: grid; gap: 5px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.ai-style { width: 100%; resize: vertical; min-height: 64px; font: inherit; margin-bottom: 10px; }
.ai-status { display: grid; gap: 4px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 12.5px; line-height: 1.45; }
.ai-status small { color: var(--text-2); }
.ai-status.error { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.45); }
.btn.wide + .btn.wide { margin-top: 8px; }
select.text-input {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b9c0cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  text-overflow: ellipsis;
}
select.text-input option { background: var(--surface-2); color: var(--text); }

/* Per-photo settings: strip actions and "edited" marker */
.strip-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; padding-left: 12px; flex-shrink: 0; }
.strip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}
.strip-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent-line); }
.strip-btn:disabled { opacity: 0.4; cursor: default; }
.strip-mode { height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.thumb.edited::after { content: ''; position: absolute; top: 5px; left: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45); }
@media (max-width: 720px) { .strip-btn span { display: none; } }

/* Per-person scope bar */
.people-scope { padding: 12px 14px 4px; }
.people-scope .check { margin-top: 8px; }
.people-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; }
.person-chip {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 66px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.person-chip img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; }
.person-chip .person-all { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--surface-4); font-size: 11.5px; font-weight: 600; }
.person-chip.active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.person-chip .person-dot { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: none; }
.person-chip.edited .person-dot { display: block; }
.person-chip.skipped img { filter: grayscale(1); opacity: 0.55; }

/* Automatic per-person analysis report */
.auto-report { display: grid; gap: 8px; margin-top: 10px; }
.auto-person { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.45; }
.auto-person img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.auto-person div { display: grid; gap: 3px; }
.auto-person small { color: var(--text-2); }
.auto-person.scene { background: var(--accent-soft); border-color: var(--accent-line); }

/* While a batch or analysis runs, the panels cannot change the photo the batch is working on. */
.busy-lock .panel, .busy-lock .strip, .busy-lock .rail, .busy-lock .topbar .actions { pointer-events: none; opacity: 0.6; }

/* Camera panel */
.folder-row { display: grid; grid-template-columns: 82px 1fr auto; align-items: center; gap: 8px; margin: 8px 0; font-size: 12.5px; }
.folder-row > span:first-child { color: var(--text-2); }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.camera-log { display: grid; gap: 6px; margin-top: 8px; }
.camera-row { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }
.camera-row small { color: var(--text-2); }
.camera-row.warn { border-color: rgba(255, 107, 107, 0.45); }
.live-view { width: 100%; border-radius: 10px; margin: 8px 0; background: #000; }
pre.code { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; white-space: pre-wrap; user-select: all; }
.camera-log, .camera-row, .folder-row, .folder-row > * { min-width: 0; }
.camera-row b, .camera-row small { overflow-wrap: anywhere; }

/* Look Hub */
.hub-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.hub-chip {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.hub-chip:hover { border-color: var(--line-strong); color: var(--text); }
.hub-chip.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; }
.hub-card {
  display: grid;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hub-card[hidden] { display: none; }
.hub-thumb {
  position: relative;
  display: block;
  aspect-ratio: var(--ar, 4 / 5);
  overflow: hidden;
  border-radius: 9px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.15s, transform 0.15s;
}
.hub-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hub-thumb img:not([src]) { visibility: hidden; }
.hub-thumb.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: hub-shimmer 1.3s linear infinite;
}
@keyframes hub-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.hub-card:hover .hub-thumb { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--line-strong); }
.hub-card.active .hub-thumb { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.hub-name { color: var(--text-2); font-size: 12px; line-height: 1.3; }
.hub-card.active .hub-name { color: var(--text); font-weight: 600; }
.hub-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(10, 11, 14, 0.72);
  color: var(--accent-2);
  font-size: 10.5px;
  font-weight: 600;
}
.hub-card.auto .hub-badge { display: block; }
.hub-progress { margin-top: 10px; color: var(--accent-2); }
.hub-progress:empty { display: none; }
.hub-status { min-height: 1.4em; margin-top: 10px; }
