/* Styles for the /simple pattern getter only. Loaded on top of styles.css,
   which owns the tokens, reset, and fonts. This page is deliberately more
   immersive than the rest of the site: a full-height, one-thing-per-screen
   flow. */

[hidden] { display: none !important; }

.sw {
  min-height: 100svh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Top bar: back + progress dots ===== */
.sw-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.sw-back {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--bg2);
  color: var(--ink2);
  font-size: 18px;
  cursor: pointer;
  text-decoration: none;
}
.sw-back:hover { border-color: var(--bg4); color: var(--ink); text-decoration: none; }
.sw-top-spacer { width: 40px; }

/* Progress bar scales past the 3-dot phase into the full 7-step chain. */
.sw-progress {
  flex: 1;
  max-width: 340px;
  height: 4px;
  border-radius: 999px;
  background: var(--bg4);
  overflow: hidden;
}
.sw-progress > span {
  display: block; height: 100%;
  background: var(--accent);
  transition: width 220ms ease;
}

.sw-dots { display: flex; gap: 8px; }
.sw-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg4);
  transition: background 160ms, transform 160ms;
}
.sw-dot.is-done { background: var(--dim); }
.sw-dot.is-on { background: var(--accent); transform: scale(1.35); }

/* ===== Stage: fills the remaining height and centres its content ===== */
.sw-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ===== Step 1: choice cards, each showing its own pattern ===== */
.sw-choose {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.sw-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--rule);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--bg2);
  transition: border-color 160ms, transform 160ms;
}
.sw-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.sw-card-bg {
  position: absolute; inset: 0;
  line-height: 0;
}
.sw-card-canvas {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}
/* Scrim so the label stays readable over a white patch edge. */
.sw-card-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.15) 42%, rgba(0,0,0,0) 70%);
}
.sw-card-label {
  position: absolute;
  left: 20px; bottom: 16px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

/* Bring-your-own-pattern pilot: a quieter secondary entry under the main cards.
   It is a widening of the front door, not a peer of the presets, so it reads as
   a text link, not a fourth card. */
.sw-byo-entry {
  display: block; width: 100%; margin: 16px 0 0;
  text-align: left; cursor: pointer;
  background: var(--bg2); border: 1px dashed var(--rule); border-radius: 12px;
  padding: 14px 16px; color: var(--ink2);
  font-family: var(--font-mono); font-size: 14px; font-weight: 600;
  transition: border-color 160ms, color 160ms;
}
.sw-byo-entry:hover { border-color: var(--accent); color: var(--ink); }
.sw-byo-entry small {
  display: block; margin-top: 4px;
  font-family: var(--font-sans, inherit); font-weight: 400; font-size: 12px;
  color: var(--dim); letter-spacing: 0;
}
.sw-byo-tag {
  display: inline-block; vertical-align: middle;
  margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
/* The pilot flow reuses the wizard's own classes; only its caption tag needs to
   sit inline with the heading text. */
.sw-pilot .sw-caption { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }

/* ===== Step 2: resolution ===== */
.sw-caption {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
  color: var(--ink);
}
.sw-res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}
.sw-res-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--bg2);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms, background 140ms, transform 140ms;
}
.sw-res-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.sw-res-btn.is-on { border-color: var(--accent); background: var(--accent-bg); }
.sw-res-dim {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  font-weight: 400;
}
.sw-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin: 18px auto 0;
  flex-wrap: wrap;
}
.sw-custom input {
  width: 110px;
  background: var(--bg3); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 10px 12px; font-family: var(--font-mono); font-size: 15px;
  text-align: center;
}
.sw-x { color: var(--faint); }
.sw-use {
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--accent-border);
  background: var(--accent-bg); color: var(--accent);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ===== Step 3: download ===== */
.sw-download {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.sw-thumb {
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  max-width: 100%;
  line-height: 0;
}
.sw-thumb-canvas { display: block; max-width: 100%; height: auto; }
.sw-dl {
  padding: 15px 30px;
  border-radius: 12px;
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
}
.sw-dl:hover { background: rgba(56,139,253,0.28); border-color: var(--accent); }
.sw-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
  margin: 0;
}

/* ===== Onward text button ===== */
.sw-next {
  margin-top: 8px;
  background: none;
  border: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}
.sw-next:hover { text-decoration: underline; }
.sw-next.is-muted { color: var(--muted); font-weight: 500; }
.sw-next.is-muted:hover { color: var(--fg); }

/* Advanced (measured .cube) tucked under a disclosure so the smooth cube leads. */
.sw-advanced { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 10px; }
.sw-advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 4px 0;
  list-style: revert;
}
.sw-advanced > summary:hover { color: var(--fg); }
.sw-advanced[open] > summary { margin-bottom: 6px; }

/* Blend slider between the smooth and measured cubes. */
.sw-blend { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }
.sw-blend-label { display: block; font-family: var(--font-mono); font-size: 13px; color: var(--fg); margin-bottom: 8px; }
.sw-blend-row { display: flex; align-items: center; gap: 12px; }
.sw-blend-row input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.sw-blend-end { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.sw-blend-read { margin-top: 6px; }

/* LUT preview: drop an image, drag a before/after split. */
.sw-preview { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }
.sw-seg { display: inline-flex; gap: 2px; margin: 4px 0 12px; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.sw-seg-opt { font-family: var(--font-mono); font-size: 13px; color: var(--muted); padding: 6px 14px; cursor: pointer; user-select: none; }
.sw-seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sw-seg-opt.is-on { background: rgba(56,139,253,0.20); color: var(--fg); }
.sw-seg-opt:hover { color: var(--fg); }
.sw-preview-stage { position: relative; display: block; width: 100%; touch-action: none; cursor: ew-resize; border-radius: 8px; overflow: hidden; line-height: 0; }
.sw-preview-stage canvas { width: 100%; height: auto; display: block; }
.sw-preview-handle { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,0.4); pointer-events: none; }
.sw-preview-handle::after { content: ''; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; transform: translate(-50%,-50%); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,0.4); }
.sw-preview-tag { position: absolute; top: 8px; font-family: var(--font-mono); font-size: 11px; color: #fff; background: rgba(0,0,0,0.55); padding: 2px 7px; border-radius: 4px; pointer-events: none; }
.sw-preview-tag-l { left: 8px; }
.sw-preview-tag-r { right: 8px; }

/* ===== Step 4: shoot checklist ===== */
.sw-shoot { display: flex; flex-direction: column; align-items: center; }
.sw-checklist {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  max-width: 420px;
  width: 100%;
  display: grid;
  gap: 10px;
}
.sw-checklist li {
  position: relative;
  padding: 14px 16px 14px 44px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--ink2);
  font-size: 15px;
}
.sw-checklist li::before {
  content: "";
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent);
}

/* ===== Step 5: upload ===== */
.sw-upload { display: flex; flex-direction: column; align-items: center; }
.sw-field { display: grid; gap: 6px; max-width: 420px; width: 100%; margin-bottom: 16px; }
.sw-field > span { font-size: 13px; color: var(--ink2); }
.sw-field select {
  background: var(--bg3); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 11px 12px; font-family: var(--font-ui); font-size: 15px;
  /* Without this a <select> sizes to its widest OPTION, and the device catalogue
     has very long names, so it overflowed its container. Fill the field instead
     and clip the closed label. */
  width: 100%; min-width: 0; max-width: 100%;
  text-overflow: ellipsis;
}
.sw-drop {
  position: relative;
  overflow: hidden;
  max-width: 460px; width: 100%; min-height: 200px;
  border: 1px dashed var(--bg4); border-radius: 12px;
  background: var(--bg);
  padding: 30px 20px;
  display: grid; gap: 6px; justify-items: center; align-content: center; text-align: center;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}
.sw-drop.is-over, .sw-drop:hover { border-color: var(--accent); }
/* The dim thumbnail of the expected pattern, behind the prompt. */
.sw-drop-bg { position: absolute; inset: 0; opacity: 0.16; pointer-events: none; line-height: 0; }
.sw-drop-canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.sw-drop.is-over .sw-drop-bg, .sw-drop:hover .sw-drop-bg { opacity: 0.24; }
.sw-drop-main { position: relative; z-index: 1; color: var(--ink); font-size: 15px; font-weight: 600; }
.sw-drop-sub { position: relative; z-index: 1; color: var(--dim); font-size: 12px; max-width: 40ch; }
.sw-status {
  margin-top: 14px; max-width: 420px; width: 100%;
  padding: 10px 12px; border-radius: 8px; background: var(--bg3);
  font-size: 13px; color: var(--ink2);
}
.sw-status.is-error { border-left: 3px solid var(--red); color: var(--ink); }

/* ===== Step 6: box ===== */
.sw-boxstep { display: flex; flex-direction: column; align-items: center; }
.sw-hint { color: var(--dim); font-size: 14px; margin: 0 0 16px; text-align: center; }
.sw-stage-img { position: relative; display: inline-block; max-width: 100%; touch-action: none; line-height: 0; }
.sw-stage-img canvas {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--rule); border-radius: 10px; cursor: crosshair;
}
.sw-marquee {
  position: absolute; pointer-events: none;
  border: 1px solid var(--accent);
  background: rgba(88,166,255,0.14);
}

/* Registration mode toggle: Box (axis-aligned) vs Corners (four-corner homography). */
.sw-regmode {
  display: flex; width: fit-content; margin: 0 auto 12px;
  border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
}
.sw-regmode button {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--bg2); color: var(--dim); border: 0;
  padding: 7px 16px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px;
}
.sw-regmode button small { font-size: 9px; color: var(--faint); }
.sw-regmode button + button { border-left: 1px solid var(--rule); }
.sw-regmode button.is-on { background: var(--accent-bg); color: var(--accent); }
.sw-regmode button.is-on small { color: var(--accent); opacity: 0.75; }

/* Four-corner overlay: an SVG quad plus draggable handles, over the preview. */
.sw-corners { position: absolute; inset: 0; }
.sw-corners-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sw-corners-svg polygon {
  fill: rgba(88,166,255,0.10);
  stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke;
}
.sw-corner {
  position: absolute; width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--accent); border-radius: 50%;
  background: rgba(13,17,23,0.55);
  cursor: grab; touch-action: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}
.sw-corner::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 4px; height: 4px; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--accent);
}
.sw-corner:active { cursor: grabbing; }
.sw-corners-read { margin: 0 auto 4px; }

/* Warped ROI marker: a dot at each patch's projected centre, filled with the
   colour read there (box mode uses rectangles; a quad cannot be axis-aligned). */
.sw-roi-dot {
  position: absolute; width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(255,255,255,0.7);
  /* draggable: re-enable pointer events (the .sw-roi layer disables them) */
  pointer-events: auto; cursor: grab; touch-action: none;
}
.sw-roi-dot:hover { box-shadow: 0 0 0 2px var(--accent, #7aa2ff), inset 0 0 0 1px rgba(255,255,255,0.8); }
.sw-roi-dot.is-dragging { cursor: grabbing; box-shadow: 0 0 0 2px var(--accent, #7aa2ff), inset 0 0 0 1px rgba(255,255,255,0.9); z-index: 3; }
.sw-roi-dot.is-clipped { box-shadow: 0 0 0 2px var(--red), inset 0 0 0 1px rgba(255,255,255,0.7); }
.sw-roi-dot.is-outoforder { box-shadow: 0 0 0 2px var(--amber), inset 0 0 0 1px rgba(0,0,0,0.5); }
/* A rung the detector could not see: placed but flagged for a manual nudge. */
.sw-roi-dot.is-uncertain { box-shadow: 0 0 0 2px var(--amber), 0 0 8px 1px var(--amber), inset 0 0 0 1px rgba(0,0,0,0.5); animation: sw-pulse 1.4s ease-in-out infinite; }
@keyframes sw-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* The "string" threading the sample dots in order, so the row reads as one ladder
   and a point dragged out of sequence is obvious. Non-interactive. */
.sw-roi-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.sw-roi-svg polyline {
  fill: none; stroke: rgba(255,255,255,0.55); stroke-width: 1;
  vector-effect: non-scaling-stroke; stroke-dasharray: 4 3;
}

/* ROI confirmation: one swatch per detected patch, filled with the colour we
   actually read there. Sits over the preview; percentage-positioned so it tracks
   the canvas at any CSS scale. */
.sw-roi { position: absolute; inset: 0; pointer-events: none; }
.sw-roi-cell {
  position: absolute;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(255,255,255,0.65);
  border-radius: 2px;
  /* draggable: re-enable pointer events (the .sw-roi layer disables them) */
  pointer-events: auto; cursor: grab; touch-action: none;
}
.sw-roi-cell:hover { box-shadow: 0 0 0 2px var(--accent, #7aa2ff), inset 0 0 0 1px rgba(255,255,255,0.8); }
.sw-roi-cell.is-dragging { cursor: grabbing; box-shadow: 0 0 0 2px var(--accent, #7aa2ff), inset 0 0 0 1px rgba(255,255,255,0.9); z-index: 3; }
.sw-roi-cell.is-clipped {
  box-shadow: 0 0 0 2px var(--red), inset 0 0 0 1px rgba(255,255,255,0.65);
}
.sw-confirm {
  max-width: 460px; width: 100%; margin: 16px auto 0;
  display: grid; gap: 12px; justify-items: center;
}
.sw-confirm-line { margin: 0; text-align: center; font-size: 13px; color: var(--ink2); }
.sw-confirm-line.is-warn { color: var(--amber); }
.sw-confirm-snap { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--ink3, var(--ink2)); }
.sw-confirm-snap.is-warn { color: var(--amber); }
.sw-confirm-levels { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--amber); }
.sw-confirm-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.sw-confirm-redo {
  background: none; border: 1px solid var(--rule); border-radius: 8px;
  color: var(--ink2); font-family: var(--font-mono); font-size: 13px;
  padding: 10px 18px; cursor: pointer;
}
.sw-confirm-redo:hover { border-color: var(--accent); color: var(--ink); }
.sw-confirm-go {
  border: 1px solid var(--accent-border);
  background: var(--accent-bg); color: var(--accent); border-radius: 8px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 10px 18px; cursor: pointer;
}
.sw-confirm-go:hover { background: rgba(56,139,253,0.28); border-color: var(--accent); }

/* ===== Format note (informational, not a warning) =====
   8-bit is a first-class path here (D34), so this is a quiet neutral note, not
   an amber alarm. */
.sw-warn {
  max-width: 460px; width: 100%; margin: 0 auto 16px;
  border-left: 2px solid var(--bg4);
  padding: 2px 0 2px 12px; color: var(--dim); font-size: 12px; line-height: 1.5;
}

/* ===== Step 7: results ===== */
.sw-results { max-width: 1080px; margin: 0 auto; width: 100%; }
/* The findings/numbers report stays a readable single column even when the lab
   above it goes full width. */
.sw-report { max-width: 620px; margin: 0 auto; width: 100%; }

/* Colour pass results: a reading column with the vectorscope at the top. */
.sw-colour { max-width: 620px; }
.sw-vscope-wrap {
  max-width: 460px; width: 100%; margin: 0 auto 10px;
  border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
  background: #0d1117; line-height: 0;
}
.sw-vscope-wrap canvas { display: block; width: 100%; height: auto; }

/* The annotated frame - the visual half of the result. */
.sw-annot {
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  margin: 0 auto 10px;
  max-width: 100%;
  background: var(--bg);
}
.sw-annot canvas { display: block; max-width: 100%; height: auto; }
.sw-legend {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--dim);
  margin: 0 0 20px;
}
.sw-key {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 2px solid;
  vertical-align: middle;
  margin-right: 4px;
}
.sw-key-ok { border-color: var(--accent); }
.sw-key-clip { border-color: var(--red); }

/* ===== Clipping nudge: prominent, actionable re-shoot guidance ===== */
.sw-clipnudge {
  max-width: 620px; width: 100%; margin: 0 auto 16px;
  border: 1px solid var(--amber); border-left-width: 3px; border-radius: 10px;
  padding: 12px 14px; background: rgba(210,153,34,0.08);
  color: var(--ink2); font-size: 13px; line-height: 1.5;
}
.sw-clipnudge b { color: var(--ink); }

/* Curve/footage mismatch nudge: a question, not an alarm, with a way back to
   the encoding selector. Distinct border from the clip nudge so a frame that
   trips both reads as two separate things. */
.sw-mismatch {
  max-width: 620px; width: 100%; margin: 0 auto 16px;
  border: 1px solid var(--accent); border-left-width: 3px; border-radius: 10px;
  padding: 12px 14px; background: rgba(80,140,220,0.08);
  color: var(--ink2); font-size: 13px; line-height: 1.5;
}
.sw-mismatch b { color: var(--ink); display: block; margin-bottom: 2px; }
.sw-mismatch-fix {
  margin-top: 10px; display: inline-block;
  border: 1px solid var(--accent); border-radius: 8px;
  background: transparent; color: var(--accent);
  padding: 6px 12px; font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.sw-mismatch-fix:hover { background: rgba(80,140,220,0.12); }

/* Locked frame drop: the camera encoding has not been picked yet, so upload is
   held shut and the target reads as inert rather than clickable. */
.sw-drop.is-locked { cursor: not-allowed; opacity: 0.72; border-style: solid; }
.sw-drop.is-locked:hover { border-color: var(--bg4); }
.sw-drop.is-locked .sw-drop-main { color: var(--dim); }

/* A brief shake to point at the encoding selector when someone tries to upload
   before choosing one. */
.sw-shake { animation: sw-shake 0.4s; }
@keyframes sw-shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-4px); }
  40%,80% { transform: translateX(4px); }
}

/* The encoding best-guess hint on the confirm step (D67). */
.sw-guess {
  max-width: 560px; width: 100%; margin: 0 auto 16px;
  border: 1px solid var(--accent); border-left-width: 3px; border-radius: 10px;
  padding: 11px 14px; background: rgba(88,166,255,0.07);
  color: var(--ink2); font-size: 13px; line-height: 1.5;
}
.sw-guess-unknown { border-color: var(--amber); background: rgba(210,153,34,0.06); }
.sw-staged-name { text-align: center; color: var(--dim); font-size: 13px; margin: 0 0 14px; }

/* Display-only thumbnail of the dropped frame on the confirm-encoding step. */
.sw-confirm-preview { display: flex; justify-content: center; margin: 0 0 16px; }
.sw-confirm-preview canvas {
  max-width: 100%; max-height: 300px; height: auto;
  border-radius: 10px; border: 1px solid var(--rule);
  background: var(--bg1, #000);
}

/* ===== Processor route (Deliverable B) ===== */
.sw-proc-pick { margin-bottom: 14px; }
.sw-procstep {
  border: 1px solid var(--rule); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; background: var(--bg2);
}
.sw-procstep h4 { margin: 0 0 6px; font-size: 15px; }
.sw-procstep p { margin: 0; color: var(--ink2); font-size: 14px; }
.sw-proc-where {
  font-family: var(--font-mono); font-size: 12px !important;
  color: var(--accent) !important; margin-bottom: 4px !important;
}
.sw-proc-fields {
  font-family: var(--font-mono); font-size: 12px !important;
  color: var(--dim) !important; margin-bottom: 6px !important;
}
.sw-proc-caveat { color: var(--dim); font-size: 12px; margin: 6px 0 0; }

/* Generic "your device" control picker (device-agnostic Deliverable B). */
.sw-device-lede { color: var(--ink2); font-size: 13px; margin: 0 0 12px; max-width: 62ch; }
.sw-device-pick { margin-bottom: 12px; max-width: 100%; }
.sw-ctl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-bottom: 14px; }
.sw-ctl {
  display: flex; align-items: flex-start; gap: 8px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 8px; padding: 9px 11px;
  background: var(--bg); font-size: 13px; color: var(--ink2); transition: border-color 120ms, background 120ms;
}
.sw-ctl:hover { border-color: var(--bg4); }
.sw-ctl.is-on { border-color: var(--accent); background: rgba(88,166,255,0.06); color: var(--ink); }
.sw-ctl input { margin-top: 2px; accent-color: var(--accent); }
.sw-ctl-tag { font-style: normal; font-size: 11px; color: var(--green); font-family: var(--font-mono); }
.sw-ctl-tag.sw-ctl-unk { color: var(--dim); }
.sw-ctl-tag.sw-ctl-lacks { color: var(--faint); }
/* A control this device does not document: dimmed, still tickable. */
.sw-ctl.is-lacks { opacity: 0.5; }
.sw-ctl.is-lacks:hover { opacity: 0.75; }
.sw-ctl.is-lacks.is-on { opacity: 1; }
/* The device's own field/menu name under a verified control. */
.sw-ctl-field { display: block; margin-top: 3px; font-size: 11px; color: var(--dim); font-family: var(--font-mono); }
/* The honest note when a device documents a colour menu but not its fields. */
.sw-device-undoc {
  font-size: 12.5px; color: var(--ink2); line-height: 1.5;
  border-left: 3px solid var(--amber); padding: 8px 12px; margin: 0 0 12px;
  background: rgba(210,153,34,0.06); border-radius: 0 8px 8px 0;
}
.sw-device-context {
  border-left: 3px solid var(--bg4); padding: 8px 12px; margin: 0 0 12px;
  background: var(--bg2); border-radius: 0 8px 8px 0;
}
.sw-device-context p { margin: 0 0 4px; font-size: 12px; color: var(--ink2); }
.sw-device-context p:last-child { margin-bottom: 0; }
.sw-device-none { color: var(--dim); font-size: 13px; margin: 4px 0 12px; }
.sw-device-unfix { border: 1px solid var(--amber); border-left-width: 3px; border-radius: 10px; padding: 10px 14px; margin: 6px 0 12px; background: rgba(210,153,34,0.06); }
.sw-subcap-sm { font-size: 13px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.sw-device-unfix ul { margin: 0; padding-left: 18px; }
.sw-device-unfix li { color: var(--ink2); font-size: 12px; line-height: 1.5; margin-bottom: 4px; }

/* ===== The lab: comparison toggle + before/after preview + handles =====
   On a wide browser the visual (preview + scopes) and the controls (bars +
   handles) sit side by side; they stack under 900px. */
.sw-lab-grid { display: grid; gap: 26px; align-items: start; }
@media (min-width: 900px) {
  .sw-lab-grid { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); }
}
.sw-lab-visual, .sw-lab-controls { min-width: 0; }
.sw-lab-controls { display: grid; gap: 4px; align-content: start; }

.sw-compare {
  display: flex;
  width: fit-content;
  margin: 0 auto 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.sw-cmp {
  background: var(--bg2);
  color: var(--dim);
  border: 0;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}
.sw-cmp + .sw-cmp { border-left: 1px solid var(--rule); }
.sw-cmp.is-on { background: var(--accent-bg); color: var(--accent); }
.sw-cmp.is-gated { color: var(--faint); }
.sw-lock { font-size: 10px; opacity: 0.8; margin-left: 2px; }

/* Best-achievable gate: a modal nudge to pick an output method first. */
.sw-modal[hidden] { display: none; }
.sw-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.sw-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.sw-modal-card {
  position: relative;
  max-width: 460px; width: 100%;
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}
.sw-modal-card h3 { margin: 0 0 10px; font-size: 17px; color: var(--ink); }
.sw-modal-card p { margin: 0 0 10px; color: var(--ink2); font-size: 14px; line-height: 1.5; }
.sw-modal-fine { color: var(--dim) !important; font-size: 12.5px !important; }
.sw-modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.sw-modal-cancel {
  background: none; border: 0; color: var(--dim);
  font-family: var(--font-mono); font-size: 13px; cursor: pointer; padding: 8px;
}
.sw-modal-cancel:hover { color: var(--ink2); text-decoration: underline; }

/* Brief highlight on the gate when the modal sends you there. */
.sw-flash { animation: sw-flash 1.2s ease-out; border-radius: 12px; }
@keyframes sw-flash {
  0% { box-shadow: 0 0 0 3px var(--accent-bg); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

/* ===== The output gate: "what display is this?", up top ===== */
.sw-gate { max-width: 620px; margin: 0 auto 24px; width: 100%; }
.sw-gate-q { font-size: 20px; font-weight: 700; color: var(--ink); text-align: center; margin: 0 0 12px; }
.sw-gate-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sw-gate-btn {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--rule); background: var(--bg2); color: var(--ink);
  cursor: pointer; transition: border-color 140ms, background 140ms, transform 140ms;
}
.sw-gate-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.sw-gate-btn.is-on { border-color: var(--accent); background: var(--accent-bg); }
.sw-gate-btn-t { font-family: var(--font-mono); font-size: 15px; font-weight: 700; }
.sw-gate-btn.is-on .sw-gate-btn-t { color: var(--accent); }
.sw-gate-btn-s { font-size: 12px; color: var(--dim); }
.sw-output-wait {
  color: var(--dim); font-size: 14px; text-align: center;
  padding: 18px; border: 1px dashed var(--rule); border-radius: 12px;
}
@media (max-width: 560px) { .sw-gate-choices { grid-template-columns: 1fr; } }

/* Results are tall, so they align to the top; shorter steps stay centred. */
.sw-stage:has(.sw-results) { justify-content: flex-start; padding-top: 8px; }

.sw-lab {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  margin: 0 auto 10px;
  max-width: 100%;
  background: var(--bg);
  touch-action: none;
  user-select: none;
}
.sw-lab canvas { display: block; max-width: 100%; height: auto; width: 100%; }
.sw-divider {
  position: absolute; top: 0; bottom: 0;
  width: 2px; margin-left: -1px;
  background: rgba(255,255,255,0.85);
  cursor: ew-resize;
}
.sw-divider-grip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(13,17,23,0.85);
  border: 2px solid #fff;
}
.sw-divider-grip::before {
  content: "\2194"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; line-height: 1;
}
.sw-lab-tag {
  position: absolute; bottom: 10px;
  font-family: var(--font-mono); font-size: 11px;
  color: #fff; background: rgba(13,17,23,0.7);
  padding: 3px 8px; border-radius: 4px; line-height: 1.4;
}
.sw-lab-tag-l { left: 10px; }
.sw-lab-tag-r { right: 10px; }

.sw-handles {
  max-width: 460px; width: 100%; margin: 0 auto 18px;
  display: grid; gap: 12px;
}
.sw-adjust-cap { margin: 2px 0 2px; }
.sw-adjust-cap small { display: block; font-size: 11px; font-weight: 400; color: var(--dim); letter-spacing: 0; text-transform: none; }
/* Inside the controls column the handles and bars fill the column instead of
   sitting in a narrow centred strip. */
.sw-lab-controls .sw-handles,
.sw-lab-controls .sw-bars { max-width: none; margin-left: 0; margin-right: 0; }
.sw-slider { display: grid; gap: 6px; }
.sw-slider > span { font-size: 13px; color: var(--ink2); display: flex; justify-content: space-between; }
.sw-slider b { font-family: var(--font-mono); color: var(--accent); font-weight: 500; }
.sw-slider input[type=range] { width: 100%; accent-color: var(--accent); }
.sw-reset {
  justify-self: start;
  background: none; border: 1px solid var(--rule); border-radius: 8px;
  color: var(--ink2); font-family: var(--font-mono); font-size: 12px;
  padding: 8px 14px; cursor: pointer;
}
.sw-reset:hover { border-color: var(--accent); color: var(--ink); }

/* ===== Correction-model toggle (simple vs full measured curve) ===== */
.sw-model { margin-bottom: 14px; }
.sw-model .sw-subcap { margin: 0 0 8px; }
.sw-model-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sw-model-tabs button {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  background: var(--bg2); color: var(--ink2);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 9px 12px; cursor: pointer;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  text-align: left;
}
.sw-model-tabs button small { font-family: var(--font-mono); font-size: 10px; color: var(--faint); font-weight: 400; }
.sw-model-tabs button.is-on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.sw-model-tabs button.is-on small { color: var(--accent); opacity: 0.8; }
.sw-model-tabs button:disabled { opacity: 0.5; cursor: not-allowed; }

.sw-curvenote {
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; background: var(--bg2);
}
.sw-curvenote p { margin: 0; font-size: 13px; color: var(--ink2); }
.sw-curvenote-dim { margin-top: 8px !important; color: var(--dim) !important; font-size: 12px !important; }

/* ===== Bipolar channel bars (the diagnosis) ===== */
.sw-bars { max-width: 460px; width: 100%; margin: 0 auto 18px; }
.sw-bar { display: grid; grid-template-columns: 18px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 8px; }
.sw-bar-label { font-family: var(--font-mono); font-size: 13px; color: var(--ink2); text-align: center; }
.sw-bar-track { position: relative; height: 16px; background: var(--bg2); border: 1px solid var(--rule); border-radius: 4px; }
.sw-bar-center { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--faint); }
.sw-bar-fill { position: absolute; top: 2px; bottom: 2px; border-radius: 2px; }
.sw-bar-val { font-family: var(--font-mono); font-size: 12px; color: var(--dim); text-align: right; }
.sw-bar-val.is-strong { color: var(--ink); }

/* ===== Scopes (as-shot vs corrected, from videoscope's code) ===== */
.sw-scopes { width: 100%; margin: 12px 0 8px; }
.sw-scope-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sw-scope-head .sw-subcap { margin: 0; }
.sw-scope-tabs { display: flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.sw-scope-tabs button { background: var(--bg2); color: var(--dim); border: 0; padding: 5px 12px; font-family: var(--font-mono); font-size: 11px; cursor: pointer; }
.sw-scope-tabs button + button { border-left: 1px solid var(--rule); }
.sw-scope-tabs button.is-on { background: var(--accent-bg); color: var(--accent); }
.sw-scope-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sw-scope-cell { margin: 0; text-align: center; }
.sw-scope-cell canvas { width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; background: #000; display: block; }
.sw-scope-cell figcaption { font-family: var(--font-mono); font-size: 11px; color: var(--dim); margin-top: 5px; }

/* Full-width band below the preview/controls grid: the target-vs-best-effort
   scopes span the whole width, and the adjustments sit under them in two columns. */
.sw-lab-wide { margin-top: 22px; display: grid; gap: 20px; }
.sw-lab-wide .sw-scopes { margin: 0; }
.sw-lab-wide .sw-scope-cell canvas { max-height: 340px; }
/* The adjustment handles fill the wide band and lay the sliders out two-up; the
   reset button (a sibling after the grid) spans the full width beneath them. */
.sw-lab-wide .sw-handles { max-width: none; margin: 0; }
.sw-adjust-grid { display: grid; grid-template-columns: 1fr; gap: 12px 32px; }
@media (min-width: 640px) { .sw-adjust-grid { grid-template-columns: 1fr 1fr; } }
.sw-subcap { font-size: 14px; font-weight: 700; color: var(--ink); margin: 22px 0 8px; }
.sw-conf {
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  background: var(--bg2); border-left: 3px solid var(--bg4);
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
}
.sw-conf.is-high { border-left-color: var(--green); }
.sw-conf.is-medium { border-left-color: var(--amber); }
.sw-conf.is-low, .sw-conf.is-none { border-left-color: var(--red); }
.sw-conf ul { margin: 8px 0 0; padding-left: 18px; color: var(--dim); font-size: 12px; text-transform: none; letter-spacing: 0; }

/* The analyzeTargets coverage report (pilot step 1): a chip per distinct target,
   neutrals first then chromatics by hue, above the plain-language earned-corrections note. */
.sw-targets { margin: 4px 0 16px; }
.sw-target-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.sw-target-chip {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--bg4); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.sw-target-chip.is-clipped { outline: 2px solid var(--red); outline-offset: 1px; }
.sw-finding {
  border: 1px solid var(--rule); border-left-width: 3px;
  border-radius: 10px; padding: 13px 14px; margin-bottom: 10px; background: var(--bg2);
}
.sw-finding.is-good { border-left-color: var(--green); }
.sw-finding.is-info { border-left-color: var(--accent); }
.sw-finding.is-warning { border-left-color: var(--amber); }
.sw-finding.is-error { border-left-color: var(--red); }
.sw-finding h4 { margin: 0 0 6px; font-size: 15px; }
.sw-finding p { margin: 0; color: var(--ink2); font-size: 14px; }
.sw-fix { color: var(--dim) !important; font-size: 13px !important; margin-top: 6px !important; }
.sw-numbers { border-collapse: collapse; width: 100%; margin-top: 10px; }
.sw-numbers th, .sw-numbers td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); }
.sw-numbers th { font-weight: 500; color: var(--ink2); font-size: 14px; }
.sw-numbers td { font-family: var(--font-mono); font-size: 14px; color: var(--ink); }
/* Per-sample detail: before/after chips + a scrollable table of the values fed to the LUT */
.sw-chip { display: inline-block; width: 13px; height: 13px; border-radius: 2px; margin-right: 6px; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.sw-detail { margin: 16px 0; }
.sw-detail > summary { cursor: pointer; font-weight: 600; color: var(--ink2); padding: 8px 0; }
.sw-detail-scroll { max-height: 440px; overflow: auto; border: 1px solid var(--rule); border-radius: 6px; margin-top: 8px; }
.sw-detail-table { margin-top: 0; }
.sw-detail-table th, .sw-detail-table td { padding: 5px 12px; border-bottom: 1px solid var(--rule); font-size: 12px; white-space: nowrap; }
.sw-detail-table thead th { position: sticky; top: 0; background: var(--panel, #161b22); z-index: 1; }
.sw-detail-table .sw-cell-num { font-family: var(--font-mono); color: var(--ink); }
.sw-detail-table tr.is-clipped .sw-cell-num { color: var(--red, #e5534b); }
.sw-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; flex-wrap: wrap; }

/* Film pool: the accumulated-patterns list in the pilot results step. */
.sw-pool { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line, rgba(128, 128, 128, 0.25)); }
.sw-pool-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sw-pool-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); }
.sw-pool-n { font-family: var(--font-mono); font-size: 13px; color: var(--dim); }
.sw-pool-x { margin-left: auto; border: 0; background: none; color: var(--dim); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 6px; }
.sw-pool-x:hover { color: var(--ink); }
/* The draggable box for marking the 18% card on the reference frame. */
.sw-refbox { position: absolute; border: 2px solid var(--accent, #7aa2ff); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.6); background: rgba(122, 162, 255, 0.12); pointer-events: none; z-index: 2; }
/* film-neutralize: three simultaneous labelled boxes (black/grey/white) on one frame */
.sw-refbox-tag { position: absolute; top: -1px; left: -1px; transform: translateY(-100%); font: 600 11px/1.4 var(--font-mono, monospace); color: #0d1117; padding: 1px 5px; white-space: nowrap; border-radius: 2px 2px 0 0; }
.sw-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
[data-pilot-ref-stage] canvas { cursor: crosshair; }
/* Live registration feedback: a dot per source target, filled with the sent
   colour, projected onto the capture. Non-interactive so it never blocks the
   corner handles above it. */
.sw-tgt-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sw-tgt-dot { position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.95), 0 0 0 3px rgba(0, 0, 0, 0.55); }
.sw-tgt-dot.is-clipped { box-shadow: 0 0 0 2px var(--red, #e5534b), 0 0 0 3.5px rgba(0, 0, 0, 0.55); }

@media (max-width: 560px) {
  .sw-choose { grid-template-columns: 1fr; }
  .sw-card { aspect-ratio: 16 / 9; }
  .sw-card-label { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
