/* ============================================================
   Pulse Lab — Design Tokens
   ============================================================ */
:root {
  /* Neutrals — warm */
  --bg:           oklch(0.985 0.004 60);
  --bg-elev:      oklch(0.995 0.003 60);
  --bg-sunken:    oklch(0.965 0.005 60);
  --line:         oklch(0.92 0.006 60);
  --line-strong:  oklch(0.86 0.008 60);
  --text:         oklch(0.22 0.012 60);
  --text-muted:   oklch(0.48 0.01 60);
  --text-subtle:  oklch(0.62 0.008 60);

  /* Accent — coral */
  --accent:       oklch(0.68 0.18 25);
  --accent-soft:  oklch(0.95 0.04 25);
  --accent-ink:   oklch(0.45 0.16 25);
  --accent-glow:  oklch(0.68 0.18 25 / 0.18);

  /* State */
  --ok:           oklch(0.68 0.12 155);
  --warn:         oklch(0.78 0.13 80);
  --warn-ink:     oklch(0.55 0.13 70);
  --warn-soft:    oklch(0.96 0.04 80);
  --fail:         oklch(0.55 0.02 60);

  /* Secondary accent — biomarkers (deeper rose) */
  --rose:         oklch(0.55 0.13 10);
  --rose-soft:    oklch(0.96 0.025 10);
  --rose-ink:     oklch(0.42 0.12 10);

  /* Type */
  --font-sans:    "Geist", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "Geist Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Spacing rhythm */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono    { font-family: var(--font-mono); }

button { font-family: inherit; }

/* ============================================================
   Layout
   ============================================================ */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 64px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
}
.brand-mark {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-name {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
}
.brand-sub {
  color: var(--text-muted); font-size: 14px;
  letter-spacing: -0.005em;
}

/* Card */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px;
}

/* ============================================================
   Upload zone
   ============================================================ */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: 56px 24px;
  text-align: center;
  background: var(--bg-sunken);
  transition: all .18s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--line);
  background: var(--bg-elev);
  padding: 16px 24px;
}
.dropzone-glyph {
  width: 44px; height: 44px;
  margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.dropzone.is-active .dropzone-glyph,
.dropzone.has-file .dropzone-glyph {
  color: var(--accent);
  border-color: oklch(0.85 0.07 25);
}
.dropzone h3 {
  margin: 0 0 6px; font-size: 17px; font-weight: 500; letter-spacing: -0.01em;
}
.dropzone p {
  margin: 0; color: var(--text-muted); font-size: 14px;
}
.dropzone .file-meta {
  margin-top: 10px; font-size: 13px; color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.constraints {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.constraints .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-subtle);
  display: inline-block; margin: 0 8px; vertical-align: middle;
}
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--accent-ink); font-size: 13px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: oklch(0.85 0.08 25);
}
.link-btn:hover { text-decoration-color: var(--accent); }

.howitworks {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}
.howitworks-step {
  display: inline-flex; align-items: center; gap: 8px;
}
.howitworks-num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.howitworks-arrow {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Action row */
.actions {
  display: flex; justify-content: flex-end; gap: 12px;
  margin-top: 28px;
}
.btn {
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: all .15s ease;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: oklch(0.6 0.18 25);
  box-shadow: 0 1px 0 0 oklch(0.55 0.18 25 / 0.4) inset, 0 1px 2px oklch(0.5 0.18 25 / 0.18);
}
.btn-primary:hover:not(:disabled) {
  background: oklch(0.65 0.19 25);
}
.btn-primary:disabled {
  background: var(--bg-sunken);
  color: var(--text-subtle);
  border-color: var(--line);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); }
.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover {
  border-color: var(--line-strong);
  background: var(--bg-sunken);
}

/* ============================================================
   Processing view
   ============================================================ */
.proc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.proc-thumb {
  width: 88px; height: 64px;
  border-radius: 8px;
  background: linear-gradient(135deg, oklch(0.4 0.02 60), oklch(0.25 0.02 60));
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.proc-thumb::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 38%, oklch(0.7 0.04 50 / 0.45), transparent 55%),
    radial-gradient(ellipse at 50% 70%, oklch(0.6 0.05 30 / 0.35), transparent 55%);
}
.proc-thumb-rec {
  position: absolute; top: 6px; left: 6px;
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: white;
  font-variant-numeric: tabular-nums;
}
.proc-thumb-rec::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.proc-meta {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.proc-meta-label {
  font-size: 11px; color: var(--text-subtle);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.proc-meta-value {
  font-size: 14px; color: var(--text);
}

.running-avg {
  text-align: right;
}
.running-avg-label {
  font-size: 11px; color: var(--text-subtle);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.running-avg-num {
  font-size: 44px; font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.running-avg-unit {
  font-size: 13px; color: var(--text-muted);
  font-weight: 400; letter-spacing: 0;
}
.running-avg.is-pulsing .running-avg-num {
  animation: pulse var(--pulse-period, 0.8s) ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  18%      { transform: scale(1.025); }
  36%      { transform: scale(1); }
}

/* Chunk timeline */
.timeline-wrap {
  margin-top: 28px;
}
.timeline-axis {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-subtle);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
  margin-bottom: 8px;
  padding: 0 2px;
}
.chunks {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  height: 84px;
}
.chunk {
  position: relative;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  padding: 6px 4px;
  overflow: hidden;
  transition: all .25s ease;
}
.chunk-fill {
  position: absolute;
  inset: auto 0 0 0;
  background: linear-gradient(180deg, var(--accent-soft), oklch(0.92 0.07 25));
  border-top: 1.5px solid var(--accent);
  height: 0;
  transition: height .5s cubic-bezier(.2,.8,.2,1);
}
.chunk-bpm {
  position: relative; z-index: 1;
  font-size: 13px;
  color: var(--accent-ink);
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.chunk-idx {
  position: relative; z-index: 1;
  font-size: 9px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  text-align: center;
  margin-top: 2px;
}
.chunk.is-pending .chunk-bpm { opacity: 0; }
.chunk.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.chunk.is-active .chunk-fill {
  height: 25%;
  background: repeating-linear-gradient(
    -45deg,
    oklch(0.95 0.04 25),
    oklch(0.95 0.04 25) 4px,
    oklch(0.92 0.06 25) 4px,
    oklch(0.92 0.06 25) 8px
  );
  animation: shift 1s linear infinite;
}
@keyframes shift {
  from { background-position: 0 0; }
  to   { background-position: 16px 0; }
}
.chunk.is-failed {
  background: var(--bg-sunken);
  border-color: var(--line);
}
.chunk.is-failed .chunk-bpm {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 14px;
}

.chunk-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 10;
  font-variant-numeric: tabular-nums;
}
.chunk-tooltip::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
}
.chunk:hover .chunk-tooltip { opacity: 1; }

.proc-status {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}
.proc-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-right: 8px;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ============================================================
   Results view
   ============================================================ */
.results-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 1.6fr;
  gap: 48px;
  align-items: start;
}
.result-num {
  font-size: 88px;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.95;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.result-num-unit {
  font-size: 16px; color: var(--text-muted);
  font-weight: 400; letter-spacing: 0;
}
.result-num.is-pulsing {
  animation: pulse var(--pulse-period, 0.8s) ease-in-out infinite;
  transform-origin: left center;
}
.result-label {
  font-size: 11px; color: var(--text-subtle);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.result-caption {
  margin-top: 14px;
  font-size: 13px; color: var(--text-muted);
  max-width: 220px;
  line-height: 1.5;
}

/* Chart */
.chart {
  width: 100%;
  height: 220px;
  position: relative;
}
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-axis-y {
  position: absolute; left: 0; top: 0; bottom: 24px;
  width: 32px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10px; color: var(--text-subtle);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
  pointer-events: none;
}
.chart-axis-x {
  position: absolute; left: 32px; right: 0; bottom: 0;
  height: 18px;
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-subtle);
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
  pointer-events: none;
}
.chart-hover-card {
  position: absolute;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  z-index: 5;
}
.chart-hover-card .hc-row {
  display: flex; justify-content: space-between; gap: 12px;
}
.chart-hover-card .hc-label {
  color: oklch(0.7 0.01 60);
}

/* Perf strip */
.perf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.perf-card {
  padding: 16px 18px;
  background: var(--bg-sunken);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.perf-label {
  font-size: 11px; color: var(--text-subtle);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.perf-value {
  font-size: 22px; font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.perf-unit {
  font-size: 12px; color: var(--text-muted);
  margin-left: 4px; font-weight: 400;
}

.results-footer {
  margin-top: 28px;
  display: flex; justify-content: flex-end;
}

/* ============================================================
   Failure card
   ============================================================ */
.failure {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 36px;
  text-align: center;
}
.failure-glyph {
  width: 44px; height: 44px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.failure h3 {
  margin: 0 0 6px;
  font-size: 17px; font-weight: 500;
  letter-spacing: -0.01em;
}
.failure p {
  margin: 0 0 20px;
  font-size: 14px; color: var(--text-muted);
  max-width: 380px; margin-left: auto; margin-right: auto;
  line-height: 1.55;
}
.failure-actions {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}

/* ============================================================
   Section headings (handoff sections below prototype)
   ============================================================ */
.handoff {
  margin-top: 96px;
  border-top: 1px solid var(--line);
  padding-top: 64px;
}
.section-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.section-title {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.section-lede {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 32px;
  max-width: 540px;
  line-height: 1.55;
}

/* Component table */
.cmp-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-elev);
}
.cmp-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
}
.cmp-row:first-child { border-top: none; }
.cmp-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}
.cmp-name-sub {
  font-family: var(--font-sans);
  display: block;
  color: var(--text-subtle);
  font-size: 12px;
  margin-top: 2px;
}
.cmp-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}
.cmp-props {
  margin-top: 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.cmp-prop {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
}

/* Token grid */
.tokens {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.token-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.token-card h4 {
  margin: 0 0 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-weight: 500;
}
.swatch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
}
.swatch-row:first-of-type { border-top: none; padding-top: 0; }
.swatch-chip {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid oklch(0.4 0 0 / 0.08);
  flex-shrink: 0;
}
.swatch-name {
  font-family: var(--font-mono);
  font-size: 12px;
  flex: 1;
}
.swatch-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}

.code {
  background: oklch(0.18 0.01 60);
  color: oklch(0.92 0.01 60);
  border-radius: 12px;
  padding: 22px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.code .k  { color: oklch(0.78 0.12 25); }
.code .s  { color: oklch(0.82 0.1 155); }
.code .c  { color: oklch(0.55 0.01 60); font-style: italic; }
.code .n  { color: oklch(0.78 0.12 80); }

/* Subtle ECG decoration in header */
.ecg {
  width: 220px; height: 24px;
  color: var(--accent);
  opacity: 0.85;
}

/* Misc utilities */
.spacer-32 { height: 32px; }
.spacer-48 { height: 48px; }

/* ============================================================
   v2 — Segmented control (Upload / Record now)
   ============================================================ */
.seg {
  display: inline-flex;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 24px;
  position: relative;
}
.seg-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-muted);
  padding: 7px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
  letter-spacing: -0.005em;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.seg-btn.is-active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 2px oklch(0.2 0.01 60 / 0.06);
}
.seg-btn:not(.is-active):hover { color: var(--text); }

/* ============================================================
   v2 — Webcam capture
   ============================================================ */
.webcam {
  border-radius: var(--r-md);
  overflow: hidden;
  background: linear-gradient(135deg, oklch(0.32 0.02 60), oklch(0.20 0.015 60));
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
}
.webcam::after {
  /* faint scene gradient */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 45% 55% at 50% 42%, oklch(0.7 0.04 50 / 0.5), transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 75%, oklch(0.55 0.04 30 / 0.35), transparent 60%);
  pointer-events: none;
}
.webcam video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.webcam-roi {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 0 2px oklch(0.68 0.18 25 / 0.18);
  pointer-events: none;
  z-index: 2;
}
.webcam-roi-corner {
  position: absolute;
  width: 10px; height: 10px;
  border: 1.5px solid var(--accent);
}
.webcam-roi-corner.tl { top: -1.5px; left: -1.5px; border-right: none; border-bottom: none; }
.webcam-roi-corner.tr { top: -1.5px; right: -1.5px; border-left: none; border-bottom: none; }
.webcam-roi-corner.bl { bottom: -1.5px; left: -1.5px; border-right: none; border-top: none; }
.webcam-roi-corner.br { bottom: -1.5px; right: -1.5px; border-left: none; border-top: none; }

.webcam-record-btn {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  cursor: pointer;
  z-index: 3;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  transition: all .15s ease;
}
.webcam-record-btn:hover { border-color: var(--accent); }
.webcam-record-btn-inner {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: all .25s ease;
}
.webcam-record-btn.is-recording { width: 76px; height: 76px; }
.webcam-record-btn.is-recording .webcam-record-btn-inner {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--accent);
}
.webcam-record-ring {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  width: 76px; height: 76px;
  pointer-events: none;
  z-index: 4;
}
.webcam-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  z-index: 2;
}

/* Webcam permission / denied states */
.webcam.webcam-permission {
  display: flex;
  align-items: center;
  justify-content: center;
}
.webcam-permission-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  z-index: 2;
  position: relative;
}
.webcam-permission-content p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

.webcam-chips {
  display: flex; align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.webcam-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.webcam-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
}
.webcam-chip.is-warn { background: var(--warn-soft); border-color: oklch(0.85 0.07 80); color: var(--warn-ink); }
.webcam-chip.is-warn .webcam-chip-dot { background: var(--warn); }
.webcam-chip-label { color: var(--text-subtle); font-family: var(--font-mono); font-size: 11px; }

/* ============================================================
   v2 — Live waveform
   ============================================================ */
.waveform {
  position: relative;
  width: 100%;
  height: 72px;
  margin: 18px 0 22px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.waveform svg { width: 100%; height: 100%; display: block; }
.waveform-fade {
  position: absolute; left: 0; top: 0; bottom: 0; width: 64px;
  background: linear-gradient(90deg, var(--bg-sunken), transparent);
  pointer-events: none;
}
.waveform-tickers {
  display: flex; align-items: center; gap: 18px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
}
.waveform-tickers .sep { color: oklch(0.8 0.005 60); }

/* ============================================================
   v2 — Source thumbnail in results (frozen waveform mini)
   ============================================================ */
.source-snapshot {
  display: flex; align-items: center; gap: 14px;
  margin-top: 28px;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.source-snapshot .proc-thumb {
  width: 64px; height: 48px;
}
.source-snapshot-meta { flex: 1; min-width: 0; }
.source-snapshot-mini {
  width: 220px;
  height: 36px;
  flex-shrink: 0;
  position: relative;
  background: var(--bg-elev);
  border-radius: 6px;
  border: 1px solid var(--line);
  overflow: hidden;
}

/* ============================================================
   v2 — Confidence interval on overall BPM
   ============================================================ */
.result-num-wrap {
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap;
}
.ci-badge {
  font-size: 22px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ci-badge.is-warn { color: var(--warn-ink); }
.ci-badge-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

/* ============================================================
   v2 — Biomarker panel
   ============================================================ */
.biomarkers {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 720px) {
  .biomarkers { grid-template-columns: repeat(2, 1fr); }
}
.biomarker-card {
  position: relative;
  padding: 16px 18px 16px 22px;
  background: var(--rose-soft);
  border: 1px solid oklch(0.9 0.025 10);
  border-radius: 10px;
  overflow: hidden;
}
.biomarker-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--rose);
}
.biomarker-label {
  font-size: 11px;
  color: var(--rose-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 500;
}
.biomarker-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.biomarker-unit {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 400;
}
.biomarker-caption {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: -0.005em;
}
.strip-title {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-top: 32px;
  margin-bottom: 4px;
  display: block;
}
.strip-title + .perf,
.strip-title + .biomarkers {
  margin-top: 12px;
  padding-top: 0;
  border-top: none;
}

/* ============================================================
   v2 — Source ROI on processing thumbnail (animated bbox)
   ============================================================ */
.proc-thumb-roi {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 0 1px oklch(0.68 0.18 25 / 0.25);
  transition: all 0.6s cubic-bezier(.4,.6,.2,1);
  z-index: 1;
}
.proc-thumb-roi.is-lost {
  border-color: oklch(0.65 0.005 60);
  box-shadow: none;
  animation: roi-flash .4s ease;
}
@keyframes roi-flash {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
.proc-thumb-rec.is-dim { opacity: 0.4; }

/* ============================================================
   v2 — link-btn and btn-primary color-mix updates
   ============================================================ */
.link-btn {
  text-decoration-color: color-mix(in oklch, var(--accent) 35%, transparent);
}
.link-btn:hover { text-decoration-color: var(--accent); }

.btn-primary {
  border-color: color-mix(in oklch, var(--accent) 88%, black);
  box-shadow: 0 1px 0 0 color-mix(in oklch, var(--accent) 40%, transparent) inset, 0 1px 2px color-mix(in oklch, var(--accent) 18%, transparent);
}

.dropzone.is-active .dropzone-glyph,
.dropzone.has-file .dropzone-glyph {
  border-color: color-mix(in oklch, var(--accent) 30%, var(--bg));
}

/* ============================================================
   v2 — Segmented control: 3-option (Sample / Upload / Record)
   ============================================================ */
/* ModeToggle already styled via .seg / .seg-btn — no new rules needed */

/* ============================================================
   v2 — Sample-first hero player
   ============================================================ */
.sample-hero {
  position: relative;
  width: 100%;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  background: linear-gradient(135deg, oklch(0.32 0.02 60), oklch(0.18 0.015 60));
  border: 1px solid var(--line);
  border-bottom: none;
}
.sample-hero video {
  display: block;
  width: 100%;
  border-radius: 0;
  /* aspect-ratio preserved by the video's own dimensions */
}
/* .sample-hero-poster removed — not needed with native controls */
.sample-hero-roi {
  position: absolute;
  left: 38%; top: 18%;
  width: 26%; height: 56%;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 0 0 1px oklch(0 0 0 / 0.25);
  z-index: 5;
  opacity: 0;
  transition: opacity .25s ease;
}
.sample-hero.is-playing .sample-hero-roi { opacity: 0.85; }
.sample-hero-roi::before, .sample-hero-roi::after,
.sample-hero-roi > span {
  content: ""; position: absolute;
  width: 10px; height: 10px;
  border: 1.5px solid var(--accent);
}
.sample-hero-roi::before { top: -1.5px; left: -1.5px; border-right: none; border-bottom: none; }
.sample-hero-roi::after  { top: -1.5px; right: -1.5px; border-left: none; border-bottom: none; }
.sample-hero-roi > span:first-child { bottom: -1.5px; left: -1.5px; border-right: none; border-top: none; }
.sample-hero-roi > span:last-child  { bottom: -1.5px; right: -1.5px; border-left: none; border-top: none; }

/* .sample-hero-play removed — native controls handle play/pause */

.sample-hero-tag {
  position: absolute; left: 12px; top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: oklch(0.99 0 0 / 0.92);
  background: oklch(0 0 0 / 0.5);
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 6;
  pointer-events: none;
}
.sample-hero-duration {
  position: absolute; right: 12px; bottom: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: white;
  background: oklch(0 0 0 / 0.55);
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 5;
  font-variant-numeric: tabular-nums;
}
.sample-hero-progress {
  width: 100%;
  height: 3px;
  background: var(--line);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  margin-bottom: 18px;
}
.sample-hero-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .15s linear;
}

.sample-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.sample-meta-title {
  display: flex; flex-direction: column; gap: 2px;
}
.sample-meta-title h3 {
  margin: 0; font-size: 16px; font-weight: 500; letter-spacing: -0.01em;
}
.sample-meta-title p {
  margin: 0; font-size: 13px; color: var(--text-muted);
}
.sample-meta-actions {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.sample-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 28px 0 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-subtle);
}
.sample-divider::before, .sample-divider::after {
  content: ""; flex: 1;
  height: 1px; background: var(--line);
}

/* ============================================================
   v2 — Alt upload tiles (Upload video / Record with webcam)
   ============================================================ */
.alt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.alt-tile {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  text-align: left;
  font-family: inherit;
}
.alt-tile:hover {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.alt-tile-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}
.alt-tile-head svg { color: var(--accent); }
.alt-tile-sub {
  font-size: 12px; color: var(--text-muted);
  margin-left: 26px;
  line-height: 1.45;
}

/* ============================================================
   v2 — Video preview thumbnail inside dropzone (file-picked state)
   ============================================================ */
.dropzone-preview {
  position: relative;
  width: 220px;
  aspect-ratio: 16 / 9;
  margin: 0 auto 14px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, oklch(0.32 0.02 60), oklch(0.20 0.015 60));
  border: 1px solid var(--line);
  cursor: pointer;
}
.dropzone-preview::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 45% 55% at 50% 42%, oklch(0.7 0.04 50 / 0.5), transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 75%, oklch(0.55 0.04 30 / 0.35), transparent 60%);
  pointer-events: none;
}
.dropzone-play {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  background: oklch(0.99 0 0 / 0.92);
  border: 1px solid oklch(0.4 0 0 / 0.1);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  color: var(--text);
  transition: transform .15s ease;
}
.dropzone-preview:hover .dropzone-play { transform: translate(-50%, -50%) scale(1.06); }
.dropzone-duration {
  position: absolute; right: 8px; bottom: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: white;
  background: oklch(0 0 0 / 0.55);
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
}

/* ============================================================
   v2 — Video preview modal
   ============================================================ */
.video-modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0.18 0.01 60 / 0.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 32px;
}
.video-modal {
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 18px;
  max-width: 720px; width: 100%;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px oklch(0.2 0.01 60 / 0.18);
}
.video-modal-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, oklch(0.32 0.02 60), oklch(0.20 0.015 60));
  border-radius: 10px;
  overflow: hidden;
}
.video-modal-frame::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 45% 55% at 50% 42%, oklch(0.7 0.04 50 / 0.55), transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 75%, oklch(0.55 0.04 30 / 0.35), transparent 60%);
}
.video-modal-mock {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: oklch(0.95 0 0 / 0.85);
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 2;
  gap: 6px;
}
.video-modal-controls {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px;
  padding: 0 4px;
}
.video-modal-controls .scrubber {
  flex: 1;
  height: 3px;
  background: var(--bg-sunken);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.video-modal-controls .scrubber-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 32%;
  background: var(--accent);
  border-radius: 999px;
}
.video-modal-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.video-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.video-modal-head h4 {
  margin: 0; font-size: 14px; font-weight: 500;
  letter-spacing: -0.01em;
}
.video-modal-close {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px; font-size: 13px;
  border-radius: 6px;
}
.video-modal-close:hover { background: var(--bg-sunken); color: var(--text); }
