/*
 * Swing Lab: one stylesheet.
 *
 * Tokens first, then controls, then each screen. Colors come only from the
 * tokens, so light and dark stay in step. Text sizes are rem steps of the
 * root size, which follows the iOS text size setting.
 */

/* Angle labels use Inter so the readout looks the same on screen and in saved images. */
@font-face { font-family: SwingLabAngles; src: url('/fonts/Inter-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --raised: #ffffff;
  --text: #191c21;
  --muted: #5c6169;
  --border: #cbced2;
  --separator: #dee0e2;
  --accent: #0261ca;
  --accent-text: #0261ca;
  --on-accent: #ffffff;
  --selected: #d9e8fc;
  --control: #e5e6e9;
  --control-hover: #dadce0;
  --danger: #a12f27;
  --danger-soft: #fbe8e5;
  --trim: #d99a06;
  --on-trim: #1d1503;
  --stage: #0f1113;
  --scrim: rgb(12 14 17 / .42);
  --shadow: 0 10px 32px rgb(12 14 17 / .2), 0 1px 3px rgb(12 14 17 / .14);
  /* Labels over the video are always light on dark, whatever the theme. */
  --on-stage: #ebedef;
  --stage-chip: rgb(6 7 9 / .72);
  --snap: #6ba6f8;
  --on-snap: #0a1b31;

  --text-caption: .8125rem;
  --text-small: .875rem;
  --text-body: 1rem;
  --text-title: 1.25rem;
  --text-large: 1.75rem;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 16px;
  --tap: 44px;
  --bar-h: 52px;
  --gutter: 16px;
  --rail-width: clamp(352px, 34vw, 420px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  color-scheme: light;
}

/* Theater mode is dark in both appearances, like the video stage. */
.review-screen[data-theater=true],
:root[data-appearance=dark] {
  --bg: #0f1113;
  --surface: #1a1c1f;
  --raised: #232528;
  --text: #ebedef;
  --muted: #b2b6be;
  --border: #37393e;
  --separator: #2a2d31;
  --accent: #6ba6f8;
  --accent-text: #97c0fb;
  --on-accent: #0a1b31;
  --selected: #1f3656;
  --control: #26282b;
  --control-hover: #2f3236;
  --danger: #ffb4a9;
  --danger-soft: #3b201c;
  --trim: #f5ca56;
  --on-trim: #2a1f04;
  --stage: #060608;
  --scrim: rgb(0 0 0 / .55);
  --shadow: 0 12px 36px rgb(0 0 0 / .5), 0 1px 3px rgb(0 0 0 / .4);
  color-scheme: dark;
}

/* Before the app sets an appearance, follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-appearance]) {
    --bg: #0f1113; --surface: #1a1c1f; --raised: #232528; --text: #ebedef; --muted: #b2b6be; --border: #37393e; --separator: #2a2d31;
    --accent: #6ba6f8; --accent-text: #97c0fb; --on-accent: #0a1b31; --selected: #1f3656; --control: #26282b; --control-hover: #2f3236;
    --danger: #ffb4a9; --danger-soft: #3b201c; --trim: #f5ca56; --on-trim: #2a1f04; --stage: #060608; --scrim: rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* On iPhone and iPad the root size follows Settings › Display & Brightness › Text Size. */
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--text-body);
  line-height: 1.4;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body[data-screen=review] { overflow: hidden; overscroll-behavior: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent-text); text-underline-offset: 3px; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--on-accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--text-small); line-height: 1.45; }
.icon { width: 24px; height: 24px; flex: none; display: block; }
.spacer { flex: 1; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ---------- Buttons ---------- */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--control);
  color: var(--text);
  font: inherit;
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:disabled, .button:has(input:disabled) { opacity: .4; cursor: default; }
@media (hover: hover) {
  button:hover:not(:disabled), .button:hover { background: var(--control-hover); }
}
button:active:not(:disabled), .button:active { filter: brightness(.94); }
:root[data-appearance=dark] button:active:not(:disabled), .review-screen[data-theater=true] button:active:not(:disabled) { filter: brightness(1.15); }

button.primary, .button.primary { background: var(--accent); color: var(--on-accent); }
@media (hover: hover) {
  button.primary:hover:not(:disabled), .button.primary:hover { background: var(--accent); filter: brightness(1.06); }
}
button.danger { color: var(--danger); }
button.secondary { background: var(--control); }

.text-button {
  min-width: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--accent-text);
  font-weight: 500;
}
@media (hover: hover) { .text-button:hover:not(:disabled) { background: var(--control); } }
.text-button.edit-done { font-weight: 650; }

.icon-only { width: var(--tap); padding: 0; background: transparent; color: var(--text); border-radius: 50%; }
.icon-only.danger { color: var(--danger); }
.icon-only[aria-pressed=true] { background: var(--selected); color: var(--accent-text); }

/* A file input inside a label button is the tap target, so iOS opens the picker directly. */
.button { position: relative; overflow: hidden; }
.button > input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--selected);
  color: var(--accent-text);
  font-size: var(--text-small);
}

/* ---------- Form controls ---------- */

input, select, textarea {
  font: inherit;
  /* 16 px or more keeps iOS from zooming into a field. */
  font-size: max(16px, var(--text-body));
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  min-height: var(--tap);
  padding: 8px 12px;
  max-width: 100%;
  caret-color: var(--accent);
}
textarea { resize: vertical; line-height: 1.45; width: 100%; }
input[type=search] { -webkit-appearance: none; appearance: none; }
input[type=color] { width: var(--tap); padding: 4px; cursor: pointer; }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); min-height: var(--tap); width: 100%; }
input[type=checkbox]:not([role=switch]) { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

/* An iOS-style switch, still a native checkbox. */
input[role=switch] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  transition: background-color .2s;
}
input[role=switch]::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / .25);
  transition: translate .2s;
}
input[role=switch]:checked { background: var(--accent); }
input[role=switch]:checked::before { translate: 20px 0; }
input[role=switch]:disabled { opacity: .4; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--tap);
  cursor: pointer;
}
.toggle-text { display: grid; gap: 2px; }
.toggle-text small { color: var(--muted); font-size: var(--text-small); line-height: 1.4; }

.field { display: grid; gap: 6px; margin: 0 0 16px; min-width: 0; }
.field-label { font-size: var(--text-small); font-weight: 600; color: var(--muted); }
.field input:not([type=range]) { width: 100%; }

/* A row of choices, like UISegmentedControl. */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--control);
  max-width: 100%;
}
.segmented button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: var(--text-small);
  font-weight: 550;
}
.segmented button[aria-pressed=true] { background: var(--raised); box-shadow: 0 1px 3px rgb(0 0 0 / .14); font-weight: 650; }
:root[data-appearance=dark] .segmented button[aria-pressed=true], .review-screen[data-theater=true] .segmented button[aria-pressed=true] { background: #3d4044; }
@media (hover: hover) { .segmented button:hover:not(:disabled):not([aria-pressed=true]) { background: var(--control-hover); } }

/* ---------- Chips ---------- */

.chip {
  flex: none;
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-caption);
  font-weight: 600;
}
.chip .icon { width: 16px; height: 16px; }
.chip[aria-pressed=true] { background: var(--selected); border-color: var(--accent); color: var(--accent-text); }
.chip-code { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 650; }
.chip[aria-pressed=true] .chip-code { color: inherit; }

/* ---------- Screens and bars ---------- */

.screen { display: flex; flex-direction: column; min-height: 100dvh; }
.review-screen { height: 100dvh; min-height: 0; overflow: hidden; }

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--bar-h) + var(--safe-top));
  padding: var(--safe-top) max(8px, var(--safe-right)) 0 max(8px, var(--safe-left));
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
}
.bar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.bar .icon-only { color: var(--accent-text); }
.bar .icon-only[aria-pressed=true] { background: var(--selected); }
.bar-title { font-size: 1.0625rem; font-weight: 650; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title.large { font-size: clamp(1.5rem, 7.5vw, var(--text-large)); font-weight: 750; letter-spacing: -.02em; text-align: left; }
.bar-back { justify-self: start; min-width: 0; padding: 0 8px 0 0; background: transparent; color: var(--accent-text); font-weight: 500; gap: 0; }
.bar-back .icon { width: 28px; height: 28px; }
@media (hover: hover) { .bar-back:hover:not(:disabled) { background: transparent; text-decoration: underline; } }
.bar-title-button {
  justify-self: center;
  max-width: 100%;
  min-width: 0;
  padding: 0 8px;
  background: transparent;
  font-size: 1.0625rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The title opens Details; a small chevron says it can be tapped. */
.bar-title-button::after {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  margin: -4px 0 0 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  rotate: 45deg;
}
.library-screen .bar {
  grid-template-columns: minmax(0, 1fr) auto;
  /* On wide screens the title lines up with the list below it. */
  padding-left: max(var(--gutter), var(--safe-left), calc((100% - 760px) / 2 + var(--gutter)));
  padding-right: max(8px, var(--safe-right), calc((100% - 760px) / 2 + 8px));
  border-bottom-color: transparent;
}
.settings-screen .bar { grid-template-columns: 1fr auto 1fr; }

/* Toasts sit just under the header, over the top of the video rather than the controls. */
.toast-host { position: sticky; top: calc(var(--bar-h) + var(--safe-top)); z-index: 30; height: 0; }
.stage-column > .toast-host { position: absolute; top: 0; left: 0; right: 0; }
.toasts { position: absolute; top: 8px; left: 0; right: 0; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: min(560px, 100%);
  min-height: 48px;
  padding: 4px 4px 4px 16px;
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid var(--separator);
  font-size: var(--text-small);
  line-height: 1.4;
}
.toast p { flex: 1; padding: 8px 0; }
.toast.error { border-color: var(--danger); }
.toast.error p { color: var(--danger); }
.toast-action { min-height: 40px; padding: 0 12px; background: transparent; color: var(--accent-text); font-size: var(--text-small); font-weight: 650; }
.toast-close { width: 40px; min-width: 40px; min-height: 40px; color: var(--muted); }
.toast-close .icon { width: 18px; height: 18px; }
@media (prefers-reduced-motion: no-preference) {
  .toast { transition: opacity .2s, translate .2s; }
  @starting-style { .toast { opacity: 0; translate: 0 -8px; } }
}

/* ---------- Menus, popovers, alerts and sheets ---------- */

.menu, .popover-panel {
  position: fixed;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
  overscroll-behavior: contain;
}
.menu { min-width: 240px; max-width: min(340px, calc(100vw - 16px)); }
.menu-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-s);
  background: transparent;
  font-weight: 500;
  text-align: left;
}
.menu-item .icon { width: 22px; height: 22px; }
.menu-item:focus-visible { outline-offset: -2px; }
@media (hover: hover) { .menu-item:hover:not(:disabled) { background: var(--control); } }
.menu-item.danger { color: var(--danger); }
.menu-label { overflow: hidden; text-overflow: ellipsis; }
.menu-hint { color: var(--muted); font-size: var(--text-caption); font-weight: 400; }
.menu-check { width: 20px; color: var(--accent-text); }
.menu-check .icon { width: 20px; height: 20px; }
.menu-separator { height: 1px; margin: 4px 8px; background: var(--separator); }
.menu-heading { padding: 8px 12px 4px; color: var(--muted); font-size: var(--text-caption); line-height: 1.35; max-width: 300px; }

.popover-panel { padding: 16px; width: min(360px, calc(100vw - 16px)); }
.panel-label { margin: 12px 0 8px; font-size: var(--text-caption); font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.panel-label:first-child { margin-top: 0; }
.popover-panel .muted.small { margin: 6px 0 4px; }
.popover-panel .segmented { display: flex; }
.popover-panel .toggle-row { margin-top: 8px; }

dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); }

dialog.alert {
  width: min(340px, calc(100vw - 32px));
  padding: 20px;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--raised);
  box-shadow: var(--shadow);
}
.alert h2 { font-size: 1.0625rem; margin-bottom: 8px; }
.alert p { color: var(--muted); font-size: var(--text-small); line-height: 1.5; }
.alert input { width: 100%; margin: 4px 0 0; }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.alert-actions button.danger { background: var(--danger-soft); }

dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 640px;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--bg);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
dialog.sheet[open] { display: flex; flex-direction: column; }
.sheet-header {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  min-height: 56px;
  padding: 0 8px;
  border-bottom: 1px solid var(--separator);
}
.sheet-title { grid-column: 2; font-size: 1.0625rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-done { grid-column: 3; justify-self: end; min-width: 0; padding: 0 8px; background: transparent; color: var(--accent-text); font-weight: 650; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px max(var(--gutter), var(--safe-right)) calc(24px + var(--safe-bottom)) max(var(--gutter), var(--safe-left)); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sheet-actions > * { flex: 1 1 140px; }
@media (min-width: 700px) and (min-height: 560px) {
  dialog.sheet { inset: 0; height: fit-content; max-height: min(720px, 90dvh); border-radius: var(--radius-l); }
  .sheet-body { padding-bottom: 24px; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { transition: translate .28s cubic-bezier(.2, .8, .2, 1); }
  @starting-style { dialog.sheet[open] { translate: 0 100%; } }
  @media (min-width: 700px) and (min-height: 560px) {
    dialog.sheet[open] { transition: opacity .18s, scale .18s; }
    @starting-style { dialog.sheet[open] { translate: none; opacity: 0; scale: .97; } }
  }
}

/* ---------- Library ---------- */

.library-screen { padding-bottom: 0; }
.library-tools, .library-list, .library-empty, .picking, .deleted-link { width: 100%; max-width: 760px; margin-inline: auto; }
.library-tools { display: grid; gap: 8px; padding: 4px max(var(--gutter), var(--safe-right)) 8px max(var(--gutter), var(--safe-left)); }
.library-tools input[type=search] { width: 100%; min-height: 40px; border: 0; border-radius: 10px; background: var(--control); padding: 8px 12px; }
.library-filters { display: flex; align-items: center; gap: 8px; }
.library-filters .segmented { flex: 1; }
.library-filters .icon-only { flex: none; }
.library-filters .icon-only[aria-pressed=true] { background: var(--selected); color: var(--accent-text); }

.picking {
  width: calc(100% - 2 * var(--gutter));
  max-width: 728px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 8px 8px 16px;
  background: var(--selected);
  color: var(--accent-text);
  font-size: var(--text-small);
  font-weight: 600;
}
.picking p { flex: 1; }

.library-list { flex: 1; padding: 0 max(var(--gutter), var(--safe-right)) 16px max(var(--gutter), var(--safe-left)); }
.section-heading { margin: 20px 4px 8px; font-size: var(--text-small); font-weight: 650; color: var(--muted); }
.section-heading:first-child { margin-top: 8px; }
.rows { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.row-wrap { position: relative; overflow: hidden; }
.row-wrap + .row-wrap .swing-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 92px;
  right: 0;
  height: 1px;
  background: var(--separator);
}
.swipe-action {
  position: absolute;
  inset: 0 0 0 auto;
  visibility: hidden;
  width: 88px;
  min-width: 0;
  border-radius: 0;
  background: #c8372d;
  color: #fff;
  font-size: var(--text-small);
}
.swing-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  touch-action: pan-y;
}
/* The action shows only while a row is swiped, so it never tints the rounded corners. */
.row-wrap:has(> .swing-row[style*=translate]) .swipe-action { visibility: visible; }
@media (hover: hover) { .swing-row:hover:not(:disabled) { background: var(--surface); filter: brightness(.98); } }
:root[data-appearance=dark] .swing-row:hover:not(:disabled) { filter: brightness(1.12); }
.swing-row:focus-visible { outline-offset: -2px; }
.swing-row[role=checkbox][aria-checked=true] { background: var(--selected); }
.thumb {
  position: relative;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--stage);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: grid; place-items: center; width: 100%; height: 100%; color: #7d838c; }
.thumb .badge {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgb(6 7 9 / .78);
  color: #f5ca56;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--text-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta .reference { color: var(--trim); flex: none; }
.row-meta .reference .icon { width: 14px; height: 14px; fill: currentColor; }
.row-note { color: var(--muted); font-size: var(--text-small); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.chevron { flex: none; color: var(--muted); opacity: .7; }
.chevron .icon { width: 20px; height: 20px; }
.check {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  color: var(--on-accent);
}
.check .icon { width: 16px; height: 16px; stroke-width: 2.5; }
.check:has(svg) { background: var(--accent); border-color: var(--accent); }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 24px;
  text-align: center;
}
.empty h2 { font-size: var(--text-title); }
.empty p { color: var(--muted); line-height: 1.5; }
.empty .muted.small { margin-top: -4px; }
.import-link { margin-top: 8px; }

.row-link {
  justify-content: space-between;
  width: 100%;
  min-height: var(--tap);
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  text-align: left;
}
.row-link .count { margin-left: auto; color: var(--muted); }
.row-link .icon { width: 20px; height: 20px; color: var(--muted); }
@media (hover: hover) { .row-link:hover:not(:disabled) { background: transparent; color: var(--accent-text); } }
.deleted-link {
  gap: 8px;
  width: calc(100% - 2 * var(--gutter));
  max-width: 728px;
  margin: 0 auto 16px;
  padding: 0 12px 0 16px;
  border-radius: var(--radius);
  background: var(--surface);
}

.dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px max(var(--gutter), var(--safe-right)) calc(12px + var(--safe-bottom)) max(var(--gutter), var(--safe-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--separator);
}
.dock > * { flex: 1; max-width: 360px; min-height: 52px; }
.dock { justify-content: center; }
#record-session { flex: 0 1 auto; padding: 0 20px; }
#record-session .icon { color: #d2453a; }
.import-button { font-size: 1.0625rem; }
.select-dock #select-count { flex: 1; min-height: 0; font-weight: 600; }
.select-dock button { flex: 0 1 auto; padding: 0 20px; }

.deleted-row { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--separator); }
.deleted-row:last-child { border-bottom: 0; }
.deleted-row button { min-height: 40px; padding: 0 14px; font-size: var(--text-small); }
.deleted-sheet .muted.small { margin-bottom: 8px; }
.tag-sheet .segmented { display: flex; }

/* ---------- Review layout ---------- */

.review-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
}
.stage-column { position: relative; min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--stage); container: stage / inline-size; }
.rail {
  min-width: 0;
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px max(12px, var(--safe-right)) calc(4px + var(--safe-bottom)) max(12px, var(--safe-left));
  background: var(--bg);
  container: rail / inline-size;
}

/* Landscape phones, and any screen wide enough, put the controls beside the video. */
@media (orientation: landscape) and (max-height: 540px), (min-width: 900px) {
  .review-layout { grid-template-columns: minmax(0, 1fr) var(--rail-width); grid-template-rows: minmax(0, 1fr); }
  .rail { max-height: none; height: 100%; border-left: 1px solid var(--separator); padding-left: 12px; padding-top: 8px; }
  .stage-column { padding-left: var(--safe-left); }
  .review-bar { border-bottom: 1px solid var(--separator); }
}
@media (orientation: landscape) and (max-height: 540px) {
  :root { --bar-h: 44px; --rail-width: calc(clamp(340px, 44vw, 400px) + var(--safe-right)); }
  .review-screen .bar-title-button { font-size: 1rem; }
}

/* ---------- Video panes ---------- */

.panes {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  gap: 2px;
  background: var(--stage);
}
.panes.compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panes.compare.stack { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.panes.compare.overlay { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.panes.overlay > .pane { grid-area: 1 / 1; }
.panes.overlay > .pane[data-slot=B] .frame-stage { background: transparent; }
.panes.overlay > .pane[data-slot=B] .image-space { opacity: var(--overlay-opacity, .5); translate: var(--overlay-x, 0) var(--overlay-y, 0); scale: var(--overlay-scale, 1); }
/* Only the swing being drawn on takes touches; the other shows through. */
.panes.overlay > .pane[data-active=false] { pointer-events: none; }
.panes.overlay > .pane[data-active=false] .pane-badge { pointer-events: auto; }
.panes.overlay > .pane[data-slot=B] .pane-badge { left: auto; right: 8px; }
.panes.overlay > .pane[data-slot=B] .readouts { left: auto; right: calc(var(--tap) + 16px); align-items: flex-end; }

.pane { position: relative; min-width: 0; min-height: 0; display: flex; }
.frame-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--stage);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.frame-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.frame-stage video, .frame-stage canvas, .frame-stage svg { -webkit-user-drag: none; }
/* The swing being drawn on carries a ring while two are shown. */
.frame-stage::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; border: 2px solid transparent; }
.panes.compare:not(.overlay) .pane[data-active=true] .frame-stage::after { border-color: var(--accent); }

.image-space { position: relative; flex: none; transform-origin: center; }
.image-space > canvas, .image-space > video { display: block; width: 100%; height: 100%; object-fit: contain; }
.image-space > svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.image-space > svg.armed { cursor: crosshair; }
.pane[data-zoomed=true] .image-space > svg:not(.armed) { cursor: grab; }
.drawing-handle { cursor: grab; }

.endpoint-lens {
  position: absolute;
  top: 8px;
  z-index: 4;
  width: 104px;
  height: 104px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgb(0 0 0 / .55);
  pointer-events: none;
  background: var(--stage);
}

.pane-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  max-width: calc(100% - 16px);
  min-height: 32px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--stage-chip);
  color: var(--on-stage);
  font-size: var(--text-caption);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 32px;
}
.pane-badge[aria-pressed=true] { background: var(--snap); color: var(--on-snap); }
/* A bigger tap area than the label shows. */
.pane-badge::before { content: ''; position: absolute; inset: -6px; }

/* The frame number, with the tempo above it once it shows. */
.readouts {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
}
.frame-label {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--stage-chip);
  color: var(--on-stage);
  font-size: var(--text-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
}

.conflict-banner {
  position: absolute;
  inset: auto 8px 8px;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--danger);
  box-shadow: var(--shadow);
  font-size: var(--text-small);
}
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conflict-actions button { flex: 1 1 auto; min-height: 40px; font-size: var(--text-small); white-space: normal; }

.focus-chip {
  position: absolute;
  top: 8px;
  left: 50%;
  translate: -50% 0;
  z-index: 4;
  max-width: calc(100% - 32px);
  min-height: 36px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: var(--stage-chip);
  color: var(--on-stage);
  font-size: var(--text-caption);
  font-weight: 600;
}
.focus-chip .icon { width: 16px; height: 16px; color: #f5ca56; fill: currentColor; }
.focus-chip span { overflow: hidden; text-overflow: ellipsis; }
.comparing .focus-chip { display: none; }

/* ---------- Compare bar ---------- */

.compare-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 4px max(12px, var(--safe-right)) 4px max(12px, var(--safe-left));
  background: var(--bg);
  border-top: 1px solid var(--separator);
  overflow-x: auto;
  scrollbar-width: none;
}
.compare-bar::-webkit-scrollbar { display: none; }
.sync-points, .nudge { display: flex; align-items: center; gap: 6px; flex: none; }
.bar-label { font-size: var(--text-caption); font-weight: 650; color: var(--muted); padding: 0 2px; }
.nudge { margin-left: auto; }
.nudge .icon-only { width: 40px; min-width: 40px; min-height: 40px; background: var(--control); }
.compare-bar > .icon-only { flex: none; color: var(--accent-text); }
/* On a phone the labels go; each button keeps its spoken name. */
@container stage (max-width: 520px) {
  .compare-bar { gap: 6px; padding-inline: max(8px, var(--safe-left)) max(8px, var(--safe-right)); }
  .compare-bar .bar-label, .compare-bar .chip .label { display: none; }
  .compare-bar .chip { padding: 0 9px; font-size: .75rem; }
  .sync-points, .nudge { gap: 4px; }
  .nudge .icon-only { width: 36px; min-width: 36px; min-height: 36px; }
}

/* ---------- The control rail ---------- */

/* The row above the tools: a hint while drawing, the selection bar while a drawing is selected. */
.edit-row { display: flex; align-items: center; gap: 2px; min-height: 48px; }
.edit-hint {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: var(--text-small);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.edit-row[data-state=drawing] .edit-hint { color: var(--text); }
.selection-bar { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 2px; min-width: 0; }
.ground-bar { justify-content: flex-start; }
.ground-bar .edit-hint { color: var(--text); }
.swatch-button { width: var(--tap); padding: 0; background: transparent; border-radius: 50%; }
.swatch {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25), 0 0 0 2px var(--bg), 0 0 0 3px var(--border);
}
.swatch-button[aria-pressed=true] .swatch { box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25), 0 0 0 2px var(--raised), 0 0 0 4px var(--accent); }
.width-button { width: var(--tap); padding: 0; background: transparent; border-radius: 50%; }
.width-preview { display: block; width: 24px; height: var(--width); min-height: 1px; border-radius: 4px; background: currentColor; }
.width-button[aria-pressed=true] { background: var(--selected); color: var(--accent-text); }
.angle-stepper { display: flex; align-items: center; border-radius: 999px; background: var(--control); }
.angle-stepper .icon-only { width: 40px; min-width: 40px; }
.angle-stepper .icon { width: 20px; height: 20px; }
.angle-readout {
  width: 4.2em;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.angle-readout:focus { background: var(--surface); border-radius: 6px; }

.tool-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.tool-button {
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 54px;
  padding: 4px 2px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 550;
}
.tool-button .icon { width: 24px; height: 24px; }
.tool-button .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: max(11px, .6875rem); }
.tool-button[aria-pressed=true] { background: var(--selected); color: var(--accent-text); }

.positions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  margin: 0 -12px;
  padding: 0 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding: 0 12px;
  scrollbar-width: none;
}
.positions::-webkit-scrollbar, .trim-picks::-webkit-scrollbar, .loop-picks::-webkit-scrollbar { display: none; }
.positions[data-set=key] .chip:not(.chip-more) { flex: 1 0 auto; }
.positions .chip[data-state=unset] { border-style: dashed; color: var(--muted); background: transparent; }
.positions .chip[data-state=partial] { border-style: dashed; border-color: var(--accent); }
.chip-more { width: 36px; padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--muted); }
.chip-more .icon { width: 20px; height: 20px; }
/* Compact chips fit five across a phone; the dashed outline says "not set" without a plus sign. */
.positions { gap: 4px; }
.positions .chip { padding: 0 8px; font-size: .75rem; }
.positions .chip[data-state=unset] .icon { display: none; }
.positions .chip-more { width: 32px; padding: 0; }
/* All ten positions sit in two rows of five, as P numbers; the name shows when there is room and on the video's frame label. */
.positions[data-set=all] { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; padding-block: 4px; overflow: visible; }
.positions[data-set=all] .chip:not(.chip-more) { justify-content: center; }
.positions[data-set=all] .chip-name { display: none; }
.positions[data-set=all] .chip-code { color: inherit; }
.positions[data-set=all] .chip-more { grid-column: 6; grid-row: 1 / span 2; align-self: center; }
@container rail (min-width: 520px) {
  .positions { gap: 6px; }
  .positions .chip { padding: 0 12px; font-size: var(--text-caption); }
  .positions .chip[data-state=unset] .icon { display: block; }
  .positions[data-set=all] .chip-name { display: inline; }
  .positions[data-set=all] .chip-code { color: var(--muted); }
}

/* One timeline. The track is a tall touch target around a thin rail. */
.scrubber { position: relative; padding: 0 8px; }
.scrub-track {
  position: relative;
  height: 44px;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.scrub-track:focus-visible { outline-offset: 0; border-radius: var(--radius-s); }
.scrub-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 6px;
  translate: 0 -50%;
  border-radius: 3px;
  background: var(--control);
}
.scrub-fill { position: absolute; left: 0; top: 50%; height: 6px; translate: 0 -50%; border-radius: 3px; background: var(--accent); pointer-events: none; }
.scrub-bands { position: absolute; inset: 0; pointer-events: none; }
.loop-band { position: absolute; top: 50%; height: 14px; translate: 0 -50%; border-radius: 4px; }
.loop-band { height: 10px; background: color-mix(in srgb, var(--accent) 22%, transparent); outline: 1px dashed color-mix(in srgb, var(--accent) 70%, transparent); }
.scrub-ticks { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; top: 6px; width: 2px; height: 10px; translate: -50% 0; border-radius: 1px; background: var(--muted); }
.note-mark { position: absolute; bottom: 6px; width: 6px; height: 6px; translate: -50% 0; border-radius: 50%; background: var(--accent-text); }
.scrub-thumb {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 30px;
  translate: -50% -50%;
  border-radius: 3px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 2px 6px rgb(0 0 0 / .3);
  pointer-events: none;
}
.scrub-track[data-dragging=play] .scrub-thumb { width: 8px; height: 36px; }
.scrub-mode {
  position: absolute;
  bottom: 100%;
  left: 50%;
  translate: -50% 0;
  z-index: 5;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: var(--text-caption);
  font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
}
.scrub-mode:empty { display: none; }
.scrubber[data-fine=true] .scrub-track::before { background: repeating-linear-gradient(90deg, var(--control) 0 6px, var(--border) 6px 7px); }

/* Trim: the kept range and its two handles. */
.trim-band { position: absolute; top: 4px; bottom: 4px; border: 3px solid var(--trim); border-radius: 6px; pointer-events: none; }
.trim-handle {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 22px;
  translate: -50% 0;
  z-index: 3;
  border-radius: 6px;
  background: var(--trim);
  cursor: ew-resize;
  touch-action: none;
}
.trim-handle::after { content: ''; position: absolute; left: 50%; top: 30%; bottom: 30%; width: 2px; translate: -50% 0; border-radius: 1px; background: var(--on-trim); opacity: .55; }
.trim-handle::before { content: ''; position: absolute; inset: 0 -11px; }
.trim-handle:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.scrubber[data-trimming=true] .scrub-fill { display: none; }
.scrubber[data-trimming=true] .scrub-thumb { z-index: 4; }
/* A loop section uses the same handles in the accent color, so it never reads as a trim. */
.scrubber[data-section=loop] .trim-band { border-color: var(--accent); }
.scrubber[data-section=loop] .trim-handle { background: var(--accent); }
.scrubber[data-section=loop] .trim-handle::after { background: var(--on-accent); }

.transport { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; }
.step-group { display: flex; align-items: center; gap: 4px; }
.transport .segmented button { min-width: var(--tap); padding: 0 6px; font-variant-numeric: tabular-nums; }
.step-frame .icon { width: 26px; height: 26px; }
.play-button { width: 56px; height: 56px; min-width: 56px; padding: 0; border-radius: 50%; }
.play-button .icon { width: 28px; height: 28px; }
.play-button .icon path[d^="M7 4.5"] { translate: 1px 0; }
@container rail (max-width: 340px) {
  .step-group { gap: 0; }
  .play-button { width: 48px; height: 48px; min-width: 48px; }
}

.utility { display: flex; align-items: center; gap: 4px; min-height: 48px; border-top: 1px solid var(--separator); padding-top: 2px; }
.utility-button {
  min-width: 0;
  min-height: var(--tap);
  padding: 0 10px;
  gap: 6px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: var(--text-small);
  font-weight: 550;
}
.utility-button .icon { width: 20px; height: 20px; }
.utility-button[aria-pressed=true] { background: var(--selected); color: var(--accent-text); }
.tempo {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--stage-chip);
  color: var(--on-stage);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.tempo[hidden] { display: none; }
.tempo-label { font-size: var(--text-caption); opacity: .8; font-weight: 600; }
.tempo strong { font-size: var(--text-small); }
.panes.overlay > .pane[data-slot=B] .tempo { display: none; }

/* Trim and a loop section share one layout: header, chips, handles, then Start here and End here. */
.trim-header, .loop-header { display: flex; align-items: center; gap: 4px; min-height: 48px; }
:is(.trim-header, .loop-header) .edit-hint { color: var(--text); }
.trim-picks, .loop-picks { display: flex; align-items: center; gap: 6px; min-height: 48px; margin: 0 -12px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
@media (pointer: fine) { .trim-picks, .loop-picks { scrollbar-width: thin; } :is(.trim-picks, .loop-picks)::-webkit-scrollbar { display: block; height: 6px; } }
.trim-actions, .loop-actions { justify-content: space-between; }
.review-screen:is([data-trimming=true], [data-loop-section=true]) .rail { gap: 4px; }

/* Short phone screens, such as Safari with its toolbars showing: every review control keeps its 44 points, but the room around them goes to the video. */
@media (orientation: portrait) and (max-height: 800px) {
  .review-screen { --bar-h: 44px; }
  .edit-row, .positions, .utility { min-height: var(--tap); }
  .utility { padding-top: 0; }
  .tool-button { min-height: 48px; }
  .transport { min-height: 56px; }
}

/* ---------- Theater mode ---------- */

/* The button sits on the video's bottom-right corner, in reach of the thumb, in both modes. A faint ring keeps it round where it overlaps both the video and the black around it. */
.theater-toggle { position: absolute; right: 8px; bottom: 8px; z-index: 4; background: var(--stage-chip); color: var(--on-stage); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--on-stage) 18%, transparent); }
.theater-toggle[aria-pressed=true] { background: var(--stage-chip); color: var(--on-stage); }
@media (hover: hover) { .theater-toggle:hover:not(:disabled) { background: var(--stage-chip); } }
.theater-toggle .icon { width: 22px; height: 22px; }

/* Only the timeline and transport stay, under a video that runs up to the status bar. */
.review-screen[data-theater=true] { background: var(--bg); }
.review-screen[data-theater=true] :is(.review-bar, .edit-row, .tool-strip, .positions, .utility, .compare-bar, .focus-chip) { display: none; }
.review-screen[data-theater=true] .review-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.review-screen[data-theater=true] .stage-column { padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); }
.review-screen[data-theater=true] .stage-column > .toast-host { top: var(--safe-top); }
.review-screen[data-theater=true] .rail {
  max-height: none;
  height: auto;
  border-left: 0;
  padding: 4px max(12px, var(--safe-right)) calc(4px + var(--safe-bottom)) max(12px, var(--safe-left));
}
/* With room, they share one row: the timeline, then speed and the frame steps with play nearest the right thumb. */
@media (min-width: 600px) {
  .review-screen[data-theater=true] .rail { flex-direction: row; align-items: center; gap: 16px; }
  .review-screen[data-theater=true] .scrubber { flex: 1; min-width: 0; }
}
/* Where the controls sit beside the video, a tall or square one keeps the column, with the controls at its foot. */
@media (orientation: landscape) and (max-height: 540px), (min-width: 900px) {
  .review-screen[data-theater=true][data-wide=false] .review-layout { grid-template-columns: minmax(0, 1fr) var(--rail-width); grid-template-rows: minmax(0, 1fr); }
  .review-screen[data-theater=true][data-wide=false] .stage-column { padding-right: 0; }
  .review-screen[data-theater=true][data-wide=false] .rail { flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 2px; height: 100%; padding-left: 12px; border-left: 1px solid var(--separator); }
  .review-screen[data-theater=true][data-wide=false] .scrubber { flex: none; }
}
/* The switch is quick, since the page takes no taps while it animates. */
::view-transition-group(*) { animation-duration: .2s; animation-timing-function: cubic-bezier(.2, 0, 0, 1); }

/* ---------- Sheets and panels on the review screen ---------- */

.composer { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--separator); }
.composer-actions { display: flex; align-items: center; gap: 12px; }
.composer-actions .toggle-row { flex: 1; font-size: var(--text-small); }
.note-list { display: grid; gap: 0; }
.note { padding: 12px 0; border-bottom: 1px solid var(--separator); }
.note.pinned { margin: 8px -8px 0; padding: 12px 8px; border-radius: var(--radius); background: var(--selected); border-bottom: 0; }
.note-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: var(--text-caption); }
.note-meta .chip { min-height: 32px; }
.note-meta .icon-only { width: 40px; min-width: 40px; min-height: 40px; }
.note-meta .icon-only .icon { width: 20px; height: 20px; }
.note.pinned .note-meta .icon-only:not(.danger) { color: #c8920a; }
.note.pinned .note-meta .icon-only:not(.danger) .icon { fill: currentColor; }
.note textarea { border-color: transparent; background: transparent; padding: 4px 0; min-height: 0; }
.note textarea:focus { border-color: var(--border); background: var(--surface); padding: 4px 8px; }
.empty-note { padding: 32px 8px; text-align: center; color: var(--muted); font-size: var(--text-small); }

.details-sheet .segmented { display: flex; }
.details-sheet .toggle-row { margin: 4px 0 12px; }
.details-sheet .muted.small { overflow-wrap: anywhere; }

.compare-setup .overlay-fit { margin: 12px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--separator); }
.overlay-fit legend { padding: 0; font-size: var(--text-small); font-weight: 650; }
.overlay-fit .field { grid-template-columns: 7.5em minmax(0, 1fr); align-items: center; margin: 0; }
.overlay-fit .text-button { margin-top: 4px; }
.compare-setup > button:last-child { width: 100%; margin-top: 16px; }
.compare-setup > button:last-child .icon { width: 20px; height: 20px; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tap), 1fr)); gap: 4px; }
.custom-color { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: var(--text-small); cursor: pointer; }
.widths { display: flex; gap: 4px; }
.widths .width-button { flex: 1; border-radius: 10px; background: var(--control); }
.widths .width-button[aria-pressed=true] { background: var(--selected); box-shadow: inset 0 0 0 2px var(--accent); }
.point-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; padding: 0; border: 0; }
.point-row legend { padding: 0 0 4px; font-size: var(--text-small); font-weight: 650; }
.point-row label { display: flex; align-items: center; gap: 6px; font-size: var(--text-small); color: var(--muted); }
.point-row input { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }

/* ---------- Settings ---------- */

.settings-body { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px max(var(--gutter), var(--safe-right)) calc(32px + var(--safe-bottom)) max(var(--gutter), var(--safe-left)); }
.group { margin-bottom: 28px; }
.group-title { margin: 0 16px 8px; font-size: var(--text-caption); font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.group-rows { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.group-rows > * { position: relative; padding: 10px 16px; }
.group-rows > * + *::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--separator); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 52px; }
.row-label { flex: 1 0 auto; font-weight: 500; }
.row > .segmented { flex: 1 1 auto; min-width: min(100%, 15rem); }
.row-detail { flex-basis: 100%; color: var(--muted); font-size: var(--text-small); line-height: 1.45; overflow-wrap: anywhere; }
.row > .row-detail:first-child { flex: 1 1 12rem; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.row-buttons > * { flex: 1 1 10rem; }
.row > button:not(.row-link) { flex: 0 1 auto; }
.group-rows .toggle-row { padding-block: 10px; }
details.row { display: block; min-height: 0; }
details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--tap);
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ''; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: 45deg; translate: 0 -2px; transition: rotate .15s; }
details[open] > summary::after { rotate: 225deg; translate: 0 2px; }
details.row > p { margin-bottom: 8px; }
.developer > p, .developer > .row-buttons { margin: 0 0 12px; }
.developer > .row-buttons button { font-size: var(--text-small); }
.developer > summary { color: var(--muted); }

/* ---------- Recording ---------- */

dialog.recording {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0 0 var(--safe-bottom);
  border: 0;
  background: var(--bg);
}
dialog.recording[open] { display: flex; flex-direction: column; }
.recording .sheet-header { padding-top: var(--safe-top); min-height: calc(56px + var(--safe-top)); }
.recording > :not(.sheet-header) { margin-inline: max(var(--gutter), var(--safe-left)); }
.recording > :not(.sheet-header):not(:first-child) { margin-top: 12px; }
#record-guide-setup { margin-top: 12px; }
.record-guide-picker { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 500; }
.record-guide-picker select { flex: 1; min-width: 10rem; }
#record-guide-help { margin-top: 6px; }
#record-preview-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 160px;
  max-height: 56dvh;
  aspect-ratio: var(--record-ratio, 1.777778);
  align-self: center;
  max-width: calc(100% - 2 * var(--gutter));
  border-radius: var(--radius);
  background: var(--stage);
  overflow: hidden;
}
#record-preview { display: block; width: 100%; height: 100%; object-fit: contain; }
#record-framing-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; fill: none; stroke: #fff; stroke-width: 1.5; filter: drop-shadow(0 1px 1px #000); overflow: visible; }
#record-framing-guide > * { vector-effect: non-scaling-stroke; }
.record-guide-boundary { stroke-dasharray: 8 6; }
.record-guide-level, .record-guide-center { stroke-dasharray: 4 5; }
.record-guide-face-on { display: none; }
#record-framing-guide[data-view=face-on] .record-guide-center { display: none; }
#record-framing-guide[data-view=face-on] .record-guide-face-on { display: block; }
#record-camera-settings { font-variant-numeric: tabular-nums; }
.record-controls { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 64px; }
#record-time { min-width: 4ch; font-size: var(--text-title); font-weight: 650; font-variant-numeric: tabular-nums; }
.record-controls .primary { min-width: 160px; min-height: 52px; }
.record-start { background: #c8372d !important; color: #fff !important; }
#record-status { min-height: 1.4em; text-align: center; color: var(--muted); font-size: var(--text-small); }
#record-status.error { color: var(--danger); }
.record-audio { padding: 4px 0; }
.record-capture-help summary { font-size: var(--text-small); }
.record-capture-help p { margin: 4px 0 10px; color: var(--muted); font-size: var(--text-small); }
@media (min-width: 700px) and (min-height: 600px) {
  dialog.recording { width: min(640px, calc(100vw - 48px)); height: auto; max-height: calc(100dvh - 48px); margin: auto; padding-bottom: 16px; border-radius: var(--radius-l); box-shadow: var(--shadow); }
  .recording .sheet-header { padding-top: 0; min-height: 56px; }
  #record-preview-stage { max-height: 50dvh; }
}

/* ---------- File drop ---------- */

.file-drop {
  position: fixed;
  inset: 12px;
  z-index: 100;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--accent-text);
  font-size: var(--text-title);
  font-weight: 650;
  pointer-events: none;
}

/* ---------- Busy, motion and print ---------- */

body.busy .import-button, body.busy #record-session { opacity: .5; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .chip[aria-pressed=true], .tool-button[aria-pressed=true], .segmented button[aria-pressed=true] { outline: 2px solid Highlight; }
}
