/* Presentable defaults for demos and screen recording: high contrast, large type, calm motion */

:root {
  color-scheme: light;
  --bg0: #ffffff;
  --bg1: #eef2f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-elevated: #ffffff;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --muted: #475569;
  --dim: #64748b;
  --accent: #0284c7;
  --accent-dim: rgba(2, 132, 199, 0.12);
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --max-w: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  background: var(--bg0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(129, 140, 248, 0.08), transparent),
    radial-gradient(ellipse 70% 50% at 100% 50%, rgba(16, 185, 129, 0.04), transparent),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
}

#root {
  min-height: 100vh;
  min-height: 100dvh;
}

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

code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.12em 0.35em;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ——— App shell ——— */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  display: block;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: linear-gradient(145deg, #818cf8, #6366f1 55%, #10b981);
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.topbar-sep {
  width: 1px;
  height: 1.25rem;
  background: var(--border-strong);
}

.topbar-tagline {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.topbar-spacer {
  flex: 1;
  min-width: 0.5rem;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(100%, 28rem);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.35;
}

.session-chip--live {
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.06);
}

.session-chip--warn {
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
}

.session-chip--error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

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

.status-dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  color: rgba(56, 189, 248, 0.55);
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5);
  animation: pulse-dot 2.4s ease-out infinite;
}

.status-dot.warn {
  color: rgba(251, 191, 36, 0.5);
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45);
}

.status-dot.error {
  color: rgba(248, 113, 113, 0.55);
  background: var(--bad);
  animation: none;
  box-shadow: none;
}

/* ——— Mode bar (below topbar) ——— */

.mode-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 15, 0.5);
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mode-toggle-label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--dim);
  transition: color 0.2s;
}

.mode-toggle-label--active {
  font-weight: 600;
  color: var(--text);
}

.mode-toggle-btn {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--dim);
  border: none;
  cursor: pointer;
  transition: background 0.25s;
  flex-shrink: 0;
  padding: 0;
}

.mode-toggle-btn--on {
  background: #6366f1;
}

.mode-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: left 0.25s;
}

.mode-toggle-btn--on .mode-toggle-thumb {
  left: 23px;
}

.connect-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.connect-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
  transition: opacity 0.15s;
}

.connect-btn:hover {
  opacity: 0.88;
}

.connect-device {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--good);
}

.connect-samples {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ——— Main layout ——— */

.main {
  flex: 1;
  width: min(var(--max-w), 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ——— Stage (waveform + hero metrics) ——— */

.stage {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: stretch;
}

.stage-video-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.waveform-chrome {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.video-chrome-corners {
  position: absolute;
  inset: 0;
  margin: 0.75rem;
  border-radius: calc(var(--radius-lg) - 10px);
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(129, 140, 248, 0.15),
    inset 0 0 40px rgba(0, 0, 0, 0.2);
}

.waveform-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.video-label {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
}

.video-label-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
  animation: rec-blink 1.6s step-end infinite;
}

.stage-hint {
  margin: 0;
  color: var(--dim);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 36rem;
}

/* ——— Readouts ——— */

.readouts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.bpm-block {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.bpm-label {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.bpm-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.bpm-number {
  font-size: clamp(3.5rem, 10vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bpm-unit {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--muted);
}

.bpm-sub {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* ——— Calm scale ——— */

.calm-scale {
  margin-top: 0.75rem;
}

.calm-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
}

.calm-label-alert {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bad);
}

.calm-label-calm {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--good);
}

/* ——— Meters ——— */

.meter-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.meter-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
}

.band-range {
  font-size: 0.75rem;
  color: var(--dim);
}

.meter-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease-out;
}

.meter-fill--delta {
  background: linear-gradient(90deg, #4f46e5, #818cf8);
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
}

.meter-fill--theta {
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.meter-fill--alpha {
  background: linear-gradient(90deg, #059669, #34d399);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.meter-fill--beta {
  background: linear-gradient(90deg, #d97706, #fbbf24);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.meter-fill--gamma {
  background: linear-gradient(90deg, #e11d48, #f43f5e);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

/* ——— Chips ——— */

.chip-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.chip {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border);
  min-width: 0;
}

.chip-key {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.chip-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
}

.deck {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: 40rem;
  align-self: center;
}

.native-tools {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.native-tools-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 42rem;
}

.native-tools-eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.native-tools-title {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.native-tools-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.native-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.native-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background:
    linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(15, 23, 42, 0.42)),
    var(--surface);
  box-shadow: var(--shadow);
}

.native-card-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--good);
}

.native-card-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.native-card-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.native-card-paths {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.native-card-paths code {
  width: fit-content;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ——— Disclosure panels ——— */

.panel-disclosure {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.panel-disclosure summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.panel-disclosure summary::-webkit-details-marker {
  display: none;
}

.panel-disclosure summary::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

.panel-disclosure[open] summary::before {
  transform: rotate(45deg);
}

.panel-disclosure summary:hover {
  background: rgba(15, 23, 42, 0.04);
}

.panel-inner {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1.25rem;
  padding-top: 1rem;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-row--wide {
  grid-column: 1 / -1;
}

.stat-key {
  font-size: 0.78rem;
  color: var(--dim);
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.footer {
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--dim);
  letter-spacing: 0.02em;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }

  70% {
    box-shadow: 0 0 0 10px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes rec-blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .readouts {
    order: -1;
  }

  .chip-row {
    grid-template-columns: 1fr;
  }

  .session-chip {
    max-width: 100%;
    white-space: normal;
  }

  .session-chip-text {
    white-space: normal;
  }

  .waveform-chrome {
    aspect-ratio: 16 / 7;
  }

  .native-tools-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar-sep,
  .topbar-tagline {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
