/* ==========================================================================
   Lens Dataset Collector — warm monochrome, utilitarian UI
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --surface-hover: #f2f1ee;
  --border: #eaeaea;
  --border-strong: #dcdbd6;

  --text: #111111;
  --text-2: #2f3437;
  --muted: #6f6e69;
  --faint: #a5a49f;

  --ink: #111111;
  --ink-hover: #2e2e2d;
  --on-ink: #ffffff;
  --focus: #1f6c9f;

  --red-bg: #fdebec;
  --red: #9f2f2d;
  --blue-bg: #e1f3fe;
  --blue: #1f6c9f;
  --green-bg: #edf3ec;
  --green: #346538;
  --yellow-bg: #fbf3db;
  --yellow: #956400;

  --switch-off: #8f8e89;
  --stage: #141413;
  --shadow-pop: 0 1px 2px rgba(17, 17, 17, 0.04), 0 10px 28px rgba(17, 17, 17, 0.07);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --font-sans: "Geist", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --z-hud: 2;
  --z-flash: 3;
  --z-message: 4;
  --z-popover: 20;
  --z-topbar: 30;
  --z-toast: 40;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #191918;
    --surface: #1f1f1e;
    --surface-2: #232322;
    --surface-hover: #2a2a29;
    --border: #2e2e2c;
    --border-strong: #3b3b39;

    --text: #ededec;
    --text-2: #d3d3d0;
    --muted: #9b9a97;
    --faint: #6f6e6a;

    --ink: #ededec;
    --ink-hover: #ffffff;
    --on-ink: #111111;
    --focus: #6cb6ea;

    --red-bg: rgba(229, 83, 75, 0.14);
    --red: #f19c96;
    --blue-bg: rgba(82, 164, 226, 0.14);
    --blue: #92c9f1;
    --green-bg: rgba(91, 170, 99, 0.14);
    --green: #93cf99;
    --yellow-bg: rgba(214, 166, 58, 0.14);
    --yellow: #e5c473;

    --switch-off: #6f6e6a;
    --stage: #0e0e0d;
    --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.45);
  }
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p {
  margin: 0;
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

[tabindex="-1"]:focus {
  outline: none;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.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;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: calc(var(--z-toast) + 1);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  margin: 0;
  padding: 12px 16px;
  background: var(--yellow-bg);
  color: var(--yellow);
  font-size: 13px;
  text-align: center;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 15px;
  height: 15px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
}

.topbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
}

.brand__text {
  min-width: 0;
}

.brand__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.brand__sub {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.conn:hover {
  background: var(--surface-hover);
}

.conn__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.conn[data-state="loading"] .conn__dot {
  animation: blink 1.2s ease-in-out infinite;
}

.conn[data-state="online"] .conn__dot {
  background: #3f9a4a;
}

.conn[data-state="offline"] {
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
  color: var(--red);
}

.conn[data-state="offline"] .conn__dot {
  background: #d0453f;
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 24px;
  align-items: start;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------- Viewport ---------- */

.viewport {
  --ar: 1.7778;
  --chrome: 236px; /* height taken by the top bar, controls and gaps */
  position: relative;
  width: min(100%, max(calc((100vh - var(--chrome)) * var(--ar)), calc(200px * var(--ar))));
  /* svh: stays put when a mobile browser toolbar shows or hides */
  width: min(100%, max(calc((100svh - var(--chrome)) * var(--ar)), calc(200px * var(--ar))));
  aspect-ratio: var(--ar);
  margin: 0 auto;
  border-radius: var(--radius-lg);
  background: var(--stage);
  overflow: hidden;
  isolation: isolate;
}

.viewport video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--stage);
}

.viewport video.is-mirrored {
  transform: scaleX(-1);
}

.viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.viewport[data-state="loading"] video,
.viewport[data-state="error"] video {
  opacity: 0;
}

.viewport[data-state="loading"] canvas,
.viewport[data-state="error"] canvas,
.viewport[data-state="loading"] .hud,
.viewport[data-state="error"] .hud {
  visibility: hidden;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  z-index: var(--z-hud);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  pointer-events: none;
}

.hud--top {
  top: 0;
}

.hud--bottom {
  bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(17, 17, 17, 0.58);
  color: #f3f3f1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.pill > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill__dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #a5a49f;
}

.pill[data-tone="rec"] .pill__dot {
  background: #ef5a52;
  animation: blink 1.1s ease-in-out infinite;
}

.pill[data-tone="good"] .pill__dot {
  background: #6cc779;
}

.pill[data-tone="warn"] .pill__dot {
  background: #e8b54a;
}

.pill[data-tone="bad"] .pill__dot {
  background: #ef5a52;
}

.pill[data-tone="rec"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.pill--path {
  font-family: var(--font-mono);
  max-width: 70%;
}

.pill--mono {
  font-family: var(--font-mono);
  color: rgba(243, 243, 241, 0.75);
}

.countdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-hud);
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity 0.2s;
}

.countdown span {
  display: block;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  transform: scaleX(0);
  transform-origin: left center;
}

.viewport[data-running="true"] .countdown {
  opacity: 1;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: var(--z-flash);
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.is-active {
  animation: flash 0.32s var(--ease);
}

.viewport__message {
  position: absolute;
  inset: 0;
  z-index: var(--z-message);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: #f3f3f1;
  text-align: center;
}

.viewport[data-state="loading"] .viewport__message,
.viewport[data-state="error"] .viewport__message {
  display: flex;
}

.viewport__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.viewport__icon .icon {
  width: 20px;
  height: 20px;
}

.viewport__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.viewport__text {
  max-width: 46ch;
  color: rgba(243, 243, 241, 0.65);
  font-size: 13px;
  line-height: 1.55;
  text-wrap: pretty;
}

.viewport__message .btn {
  margin-top: 8px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s, transform 0.15s var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--lg {
  height: 44px;
  padding: 0 16px;
  font-size: 14px;
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn--icon {
  width: 30px;
  padding: 0;
}

.btn--primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn--primary:hover:not(:disabled) {
  background: var(--ink-hover);
}

.btn--primary kbd {
  border-color: color-mix(in srgb, var(--on-ink) 22%, transparent);
  background: color-mix(in srgb, var(--on-ink) 12%, transparent);
  color: color-mix(in srgb, var(--on-ink) 72%, transparent);
}

.btn--primary[data-running="true"] {
  border-color: color-mix(in srgb, var(--red) 25%, transparent);
  background: var(--red-bg);
  color: var(--red);
}

.btn--primary[data-running="true"]:hover:not(:disabled) {
  background: color-mix(in srgb, var(--red-bg) 70%, var(--red) 12%);
}

.btn--primary[data-running="true"] kbd {
  border-color: color-mix(in srgb, var(--red) 25%, transparent);
  background: transparent;
  color: var(--red);
}

.btn--secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-2);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn--light {
  background: #f3f3f1;
  color: #111111;
}

.btn--light:hover:not(:disabled) {
  background: #ffffff;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s;
}

.link-btn:hover {
  color: var(--text);
}

.link-btn--danger {
  color: var(--red);
  text-decoration-color: color-mix(in srgb, var(--red) 35%, transparent);
}

.link-btn--danger:hover {
  color: var(--red);
  text-decoration-color: currentColor;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.controls__primary,
.controls__settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.setting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.setting__label {
  color: var(--muted);
  font-size: 12.5px;
}

.stepper {
  display: inline-flex;
  align-items: stretch;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.stepper__btn {
  width: 30px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s;
}

.stepper__btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.stepper__btn:disabled {
  color: var(--faint);
  cursor: not-allowed;
}

.stepper__btn:focus-visible {
  outline-offset: -2px;
}

.stepper__value {
  display: grid;
  place-items: center;
  min-width: 56px;
  border-inline: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 6px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch__track {
  position: relative;
  width: 30px;
  height: 18px;
  flex: none;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background-color 0.2s;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s var(--ease), background-color 0.2s;
}

.switch input:checked + .switch__track {
  background: var(--ink);
}

.switch input:checked + .switch__track::after {
  background: var(--on-ink);
  transform: translateX(12px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.select {
  height: 36px;
  max-width: 220px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23787774' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  font-size: 13px;
  text-overflow: ellipsis;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.select:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.shortcuts > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Cards ---------- */

.card {
  position: relative;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card:focus-within {
  z-index: var(--z-popover);
}

.card--flush {
  padding: 0;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card__title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- Fields ---------- */

.field + .field {
  margin-top: 16px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input--mono {
  font-family: var(--font-mono);
  font-size: 13.5px;
}

.input::placeholder {
  color: var(--muted);
}

.input:hover {
  border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted));
}

.input:focus {
  outline: none;
  border-color: var(--text-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent);
}

.input[aria-invalid="true"] {
  border-color: #d0453f;
  box-shadow: 0 0 0 3px color-mix(in srgb, #d0453f 14%, transparent);
}

.field__hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field__hint[data-tone="error"] {
  color: var(--red);
}

.field__hint code {
  font-family: var(--font-mono);
  color: var(--text-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag--green {
  background: var(--green-bg);
  color: var(--green);
}

.tag--blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.tag--yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

/* ---------- Combobox ---------- */

.combo {
  position: relative;
}

.combo__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-popover);
  max-height: 248px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop-in 0.16s var(--ease);
}

.combo__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 13.5px;
  cursor: pointer;
}

.combo__option:hover {
  background: var(--surface-hover);
}

.combo__option[aria-selected="true"] {
  background: color-mix(in srgb, var(--ink) 9%, var(--surface));
  box-shadow: inset 2px 0 0 var(--ink);
}

.combo__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#class-list .combo__label {
  font-family: var(--font-mono);
  font-size: 13px;
}

.combo__meta {
  flex: none;
  color: var(--muted);
  font-size: 11.5px;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  height: 28px;
  max-width: 100%;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.15s var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.chip:active {
  transform: scale(0.97);
}

.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--on-ink);
}

/* ---------- Destination ---------- */

.dest {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.dest__label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11.5px;
}

.dest__path {
  display: block;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-word;
}

.dest__sep {
  margin: 0 5px;
  color: var(--faint);
}

.dest__empty {
  color: var(--muted);
  font-style: italic;
}

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-hover);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.07);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- Scenario wizard ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 14px;
}

.steps__seg {
  position: relative;
  height: 16px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.steps__seg::before,
.steps__seg::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 4px;
  border-radius: 2px;
}

.steps__seg::before {
  background: var(--border);
}

.steps__seg::after {
  background: var(--ink);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
  transition: transform 0.4s var(--ease);
}

.steps__seg[aria-current="step"]::before {
  background: color-mix(in srgb, var(--ink) 22%, var(--border));
}

.steps__seg[data-done="true"]::after {
  background: var(--green);
}

.steps__seg:focus-visible {
  outline-offset: 0;
  border-radius: 3px;
}

.scenario__meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.eyebrow {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.scenario__title {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-wrap: balance;
}

.scenario__desc {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.6;
  text-wrap: pretty;
}

.scenario__tip {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 12.5px;
  line-height: 1.55;
}

.scenario__tip .icon {
  margin-top: 1px;
}

.scenario__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.scenario__count {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.scenario__nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

#btn-reset-progress {
  margin-top: 14px;
}

.free-note {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  min-width: 0;
}

.stat + .stat {
  border-left: 1px solid var(--border);
}

.stat__label {
  color: var(--muted);
  font-size: 11.5px;
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat__value[data-tone="good"]:not([data-zero="true"]) {
  color: var(--green);
}

.stat__value[data-tone="bad"]:not([data-zero="true"]) {
  color: var(--red);
}

.stat__value[data-zero="true"] {
  color: var(--muted);
}

/* ---------- Recent captures ---------- */

.recent {
  display: flex;
  flex-direction: column;
  max-height: 440px;
  margin: -6px 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.recent__item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  animation: fade-up 0.4s var(--ease);
}

.recent__item + .recent__item {
  border-top: 1px solid var(--border);
}

.recent__thumb {
  width: 56px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-xs);
  background: var(--surface-hover);
  object-fit: cover;
}

.recent__body {
  min-width: 0;
}

.recent__name,
.recent__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent__name {
  font-family: var(--font-mono);
  font-size: 12px;
}

.recent__meta {
  color: var(--muted);
  font-size: 11.5px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.status .icon {
  width: 14px;
  height: 14px;
}

.status[data-status="success"] {
  background: var(--green-bg);
  color: var(--green);
}

a.status[data-status="success"]:hover {
  background: color-mix(in srgb, var(--green-bg) 80%, var(--green) 10%);
}

.status[data-status="uploading"] {
  background: var(--blue-bg);
  color: var(--blue);
}

.status[data-status="pending"] {
  background: var(--surface-hover);
  color: var(--muted);
}

.status[data-status="failed"] {
  background: var(--red-bg);
  color: var(--red);
  cursor: pointer;
}

.status[data-status="failed"]:hover {
  background: color-mix(in srgb, var(--red-bg) 80%, var(--red) 10%);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 8px 12px;
  text-align: center;
}

.empty__icon {
  width: 22px;
  height: 22px;
  margin-bottom: 6px;
  color: var(--faint);
}

.empty__title {
  font-size: 13px;
  font-weight: 500;
}

.empty__text {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- Spinner ---------- */

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--light {
  width: 18px;
  height: 18px;
  border-width: 2px;
  color: rgba(255, 255, 255, 0.8);
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(calc(100vw - 32px), 440px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #1c1c1b;
  color: #f3f3f1;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  animation: toast-in 0.35s var(--ease);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease forwards;
}

.toast .icon {
  margin-top: 1px;
}

.toast[data-tone="success"] .icon {
  color: #8fd197;
}

.toast[data-tone="warn"] .icon {
  color: #ebc46b;
}

.toast[data-tone="error"] .icon {
  color: #f19c96;
}

@media (prefers-color-scheme: dark) {
  .toast {
    border: 1px solid var(--border-strong);
    background: #2a2a29;
  }
}

/* ---------- Motion ---------- */

.reveal {
  animation: fade-up 0.6s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes flash {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 0;
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (min-width: 1101px) {
  /* Keep the camera in view while the side panel scrolls. */
  .stage {
    position: sticky;
    top: 81px;
  }
}

@media (min-width: 1101px) and (max-width: 1365px) {
  /* Controls wrap onto two rows here. */
  .viewport {
    --chrome: 290px;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 880px;
  }

  .viewport {
    --chrome: 250px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .topbar__inner {
    padding: 10px 16px;
  }

  .brand__sub,
  .conn__label {
    display: none;
  }

  .layout {
    padding: 16px 16px 40px;
    gap: 16px;
  }

  .controls__primary {
    width: 100%;
  }

  .controls__primary .btn {
    flex: 1 1 0;
  }

  .controls__primary kbd,
  .shortcuts {
    display: none;
  }

  .controls__settings {
    width: 100%;
    justify-content: space-between;
  }

  .select {
    max-width: 100%;
    flex: 1;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .viewport {
    --chrome: 270px;
  }

  html {
    scroll-padding-top: 72px;
  }

  .setting:last-child {
    flex: 1 1 100%;
  }

  .card:not(.card--flush) {
    padding: 16px;
  }

  .stat {
    padding: 12px;
  }

  .stat__value {
    font-size: 18px;
  }

  .input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }
}
