/* ═══════════════════════════════════════════════════════════════════════
   Redshift demo widget — embeddable, vanilla
   Self-contained CSS. Light + dark via prefers-color-scheme.
   Brand red #C73F3C, peach #E89B85, Inter via system, JetBrains Mono via system.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --rs:        #C73F3C;
  --rs-dark:   #A63330;
  --rs-light:  #D85855;
  --peach:     #E89B85;
  --peach-2:   #F2BBA8;

  /* Surface tokens (light by default) */
  --bg-0:      #FBFAF8;
  --bg-1:      #F3F1ED;
  --bg-2:      #E8E4DE;
  --surface:   #FFFFFF;
  --surface-2: #F8F6F2;
  --line:      rgba(20, 14, 10, 0.10);
  --line-2:    rgba(20, 14, 10, 0.06);
  --ink-1:     #1A1714;
  --ink-2:     #4A4540;
  --ink-3:     #756E66;
  --ink-4:     #AAA29A;
  --on-rs:     #FFFFFF;

  /* Effects */
  --rs-glow:   rgba(199, 63, 60, 0.22);
  --peach-glow:rgba(232, 155, 133, 0.22);

  /* Type */
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Motion */
  --t-fast:  140ms cubic-bezier(.2,.7,.2,1);
  --t-med:   240ms cubic-bezier(.2,.7,.2,1);
  --t-slow:  420ms cubic-bezier(.2,.7,.2,1);

  /* iOS sub-tokens */
  --ios-bezel:    #14110F;
  --ios-screen:   #FBFAF8;
  --ios-status:   #1A1714;

  /* CLI tokens */
  --cli-bg:       #0E0E10;
  --cli-fg:       #E8E4DE;
  --cli-dim:      #9A938A;
  --cli-accent:   #E89B85;

  /* Mac chrome */
  --mac-chrome:   #E8E4DE;
  --mac-chrome-2: #DBD5CD;
  --mac-side:     #F3F1ED;
  --mac-body:     #FBFAF8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-0:      #050404;
    --bg-1:      #0A0908;
    --bg-2:      #100E0C;
    --surface:   #221E19;
    --surface-2: #16130F;
    --line:      rgba(255, 240, 230, 0.14);
    --line-2:    rgba(255, 240, 230, 0.07);
    --ink-1:     #F4EFE8;
    --ink-2:     #C7BFB3;
    --ink-3:     #8A8074;
    --ink-4:     #585146;
    --on-rs:     #FFFFFF;

    --rs:        #E55552;
    --rs-dark:   #C73F3C;
    --rs-light:  #F07875;
    --rs-glow:   rgba(229, 85, 82, 0.34);
    --peach-glow:rgba(232, 155, 133, 0.24);

    --ios-bezel:  #050405;
    --ios-screen: #050505;
    --ios-status: #F4EFE8;

    --cli-bg:     #06060A;
    --cli-fg:     #F4EFE8;
    --cli-dim:    #8A8074;

    --mac-chrome:   #15130F;
    --mac-chrome-2: #1A1714;
    --mac-side:     #110F0C;
    --mac-body:     #0A0908;
  }
}

/* Explicit overrides via data-theme (so the parent page can pin a theme) */
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"]  { color-scheme: dark; }
/* (token redeclarations not strictly needed — handled via prefers-color-scheme.) */

/* ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
svg { display: block; }

/* ─── STAGE ─────────────────────────────────────────────────────────── */
.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  isolation: isolate;
}

.stage__bg {
  position: absolute; inset: 0; z-index: -1;
  background: var(--bg-0);
  overflow: hidden;
}
.bg__wash {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 40% at 18% 25%, var(--rs-glow), transparent 70%),
    radial-gradient(50% 50% at 84% 75%, var(--peach-glow), transparent 70%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}
.bg__glow {
  position: absolute;
  width: 50%; height: 60%;
  filter: blur(48px);
  opacity: 0.4;
  pointer-events: none;
  transition: opacity var(--t-slow);
}
.bg__glow--left  { left: -10%; top: 10%; background: radial-gradient(circle, var(--rs-glow), transparent 60%); }
.bg__glow--right { right: -10%; bottom: 0%; background: radial-gradient(circle, var(--peach-glow), transparent 60%); }

/* Glow pulses with the timeline — brightest while sending */
body[data-stage="sending"] .bg__glow,
body[data-stage="p2p-ready"] .bg__glow { opacity: 0.7; }
body[data-stage="complete"] .bg__glow { opacity: 0.55; }

/* ─── DEVICES ROW ───────────────────────────────────────────────────── */
.devices {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(160px, 2fr) 1fr;
  align-items: center;
  justify-items: center;
  padding: 24px 32px 8px;
  min-height: 0;
  gap: 0;
}
@media (max-width: 800px) {
  .devices { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .devices > .wire { display: none; }
}

.device {
  position: relative;
  display: flex;
  align-items: center; justify-content: center;
}

/* Switch which receiver shows based on body[data-variant] */
body[data-variant="phone-phone"] .receiver--ios   { display: flex; }
body[data-variant="phone-phone"] .receiver--cli,
body[data-variant="phone-phone"] .receiver--mac   { display: none; }

body[data-variant="phone-cli"]   .receiver--cli   { display: flex; }
body[data-variant="phone-cli"]   .receiver--ios,
body[data-variant="phone-cli"]   .receiver--mac   { display: none; }

body[data-variant="phone-mac"]   .receiver--mac   { display: flex; }
body[data-variant="phone-mac"]   .receiver--ios,
body[data-variant="phone-mac"]   .receiver--cli   { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   iOS device — bezel + screen + app content
   ═══════════════════════════════════════════════════════════════════ */
.ios {
  --ios-w: 280px;
  --ios-h: 580px;
  width: var(--ios-w);
  height: var(--ios-h);
  position: relative;
  flex-shrink: 0;
}

@media (max-height: 640px) {
  .ios { --ios-w: 240px; --ios-h: 500px; }
}
@media (max-height: 540px) {
  .ios { --ios-w: 210px; --ios-h: 440px; }
}

.ios__bezel {
  position: absolute; inset: 0;
  background: var(--ios-bezel);
  border-radius: calc(var(--ios-w) * 0.16);
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.5),
    0 30px 60px -20px rgba(0,0,0,0.55),
    0 12px 24px -8px rgba(0,0,0,0.35),
    inset 0 0 0 2px rgba(255,255,255,0.04);
  padding: 8px;
}

.ios__screen {
  position: relative;
  width: 100%; height: 100%;
  background: var(--ios-screen);
  border-radius: calc(var(--ios-w) * 0.13);
  overflow: hidden;
  display: flex; flex-direction: column;
}

.ios__notch {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  width: 28%; height: 22px;
  background: #000;
  border-radius: 14px;
  z-index: 10;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px;
}
.ios__cam {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 1px #2a2a2e;
}

.ios__statusbar {
  position: relative;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px 6px;
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  color: var(--ios-status);
  letter-spacing: -0.01em;
}
.ios__statusbar .ios__icons {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ios-status);
}
.ios__statusbar svg { width: 13px; height: 9px; fill: currentColor; }
.ios__statusbar .i-wifi  { width: 14px; height: 10px; }
.ios__statusbar .i-battery {
  position: relative;
  display: inline-block;
  width: 22px; height: 10px;
  border: 1px solid currentColor;
  border-radius: 2.5px;
  padding: 1px;
  opacity: 0.92;
}
.ios__statusbar .i-battery::after {
  content: '';
  position: absolute; top: 2px; right: -3px;
  width: 2px; height: 4px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
}
.ios__statusbar .i-battery__fill {
  display: block;
  width: 75%; height: 100%;
  background: currentColor;
  border-radius: 1px;
}

.ios__home {
  position: absolute;
  bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 32%; height: 4px;
  background: rgba(0,0,0,0.55);
  border-radius: 4px;
  z-index: 5;
}
@media (prefers-color-scheme: dark) {
  .ios__home { background: rgba(255,255,255,0.55); }
}

/* ═══════════════════════════════════════════════════════════════════
   iOS app — REAL APP MATCH
   Peachy-red blurred background · big centered icon · white-on-color
   ═══════════════════════════════════════════════════════════════════ */

/* Wallpaper-like background inside the iOS screen */
.ios-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 20% 12%, #E8B0A0 0%, transparent 60%),
    radial-gradient(50% 45% at 78% 22%, #C97570 0%, transparent 60%),
    radial-gradient(70% 60% at 50% 90%, #9B3E3C 0%, transparent 70%),
    radial-gradient(40% 40% at 85% 70%, #D9907E 0%, transparent 60%),
    linear-gradient(160deg, #BC6764 0%, #8F3F3B 100%);
  filter: saturate(110%);
  z-index: 0;
}
@media (prefers-color-scheme: dark) {
  .ios-bg {
    background:
      radial-gradient(60% 50% at 20% 12%, #6F2D2C 0%, transparent 60%),
      radial-gradient(55% 45% at 80% 30%, #4A1817 0%, transparent 65%),
      radial-gradient(70% 60% at 50% 90%, #0E0506 0%, transparent 70%),
      radial-gradient(35% 35% at 85% 70%, #5A1F1E 0%, transparent 60%),
      linear-gradient(160deg, #3D1413 0%, #0B0303 100%);
    filter: saturate(105%);
  }
}

/* Chrome — top row + central stage + bottom CTA */
.ios-chrome {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  z-index: 2;
  padding: 36px 14px 16px;       /* leave room for status bar at top, home indicator at bottom */
  color: #fff;
}

.ios-chrome__top {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 2px;
}

/* P2P pill — translucent dark, top-left, conditional */
.ios-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px;
  border-radius: 13px;
  font: 600 11px/1 var(--sans);
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
}
.ios-pill svg { width: 13px; height: 10px; opacity: 0.9; }
/* Show during connected states */
#sender[data-scene="sending"] .ios-pill--p2p,
#sender[data-scene="complete"] .ios-pill--p2p,
.receiver--ios[data-scene="recv-receiving"] .ios-pill--p2p,
.receiver--ios[data-scene="recv-complete"] .ios-pill--p2p { opacity: 1; }

/* Gear button — translucent circle, top-right */
.ios-gear {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  color: #fff;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
}
.ios-gear svg { width: 16px; height: 16px; }

/* Central stage */
.ios-stage {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 4px;
  min-height: 0;
  position: relative;
}

/* Hero icon — large, centered, with translucent halo */
.ios-hero {
  position: relative;
  width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  flex-shrink: 0;
}
.ios-hero__ring {
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  z-index: 0;
}
.ios-hero__icon {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  z-index: 1;
  box-shadow:
    0 12px 32px -10px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}
/* Green check ring (overlay) — visible on complete state */
.ios-hero__check {
  position: absolute; inset: -8px;
  width: calc(100% + 16px); height: calc(100% + 16px);
  color: #34C759;
  opacity: 0;
  z-index: 2;
  pointer-events: none;
}
#sender[data-scene="complete"] .ios-hero__check,
.receiver--ios[data-scene="recv-complete"] .ios-hero__check { opacity: 1; }

/* Slight dim on the icon during transit (matches real app's "darker" feel during sending) */
#sender[data-scene="sending"] .ios-hero__icon,
.receiver--ios[data-scene="recv-receiving"] .ios-hero__icon { opacity: 0.88; }

@media (max-height: 640px) {
  .ios-hero { width: 96px; height: 96px; margin-bottom: 14px; }
}
@media (max-height: 540px) {
  .ios-hero { width: 80px; height: 80px; margin-bottom: 10px; }
}

/* Captions / scene content */
.app--sender .scene,
.app--receiver .scene { display: none; }

#sender[data-scene="idle"]      .scene--idle,
#sender[data-scene="file"]      .scene--file,
#sender[data-scene="code"]      .scene--file,    /* code phase reuses file scene */
#sender[data-scene="joining"]   .scene--joining,
#sender[data-scene="sending"]   .scene--sending,
#sender[data-scene="complete"]  .scene--complete,
.receiver--ios[data-scene="recv-idle"]      .scene--idle,
.receiver--ios[data-scene="recv-code"]      .scene--code-entered,
.receiver--ios[data-scene="recv-joining"]   .scene--joining,
.receiver--ios[data-scene="recv-receiving"] .scene--receiving,
.receiver--ios[data-scene="recv-complete"]  .scene--complete {
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
}

.ios-title {
  margin: 0;
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
  max-width: 90%;
  text-wrap: balance;
}
@media (max-height: 540px) { .ios-title { font-size: 14px; } }

.ios-status-line {
  margin-top: 16px;
  font-size: 12px; color: rgba(255,255,255,0.78);
  font-weight: 500;
}

/* File pill — translucent backdrop */
.ios-filepill {
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  max-width: 90%;
}
.ios-filepill__ico {
  width: 18px; height: 18px;
  color: #fff;
  flex-shrink: 0;
  display: inline-flex; align-items: center;
}
.ios-filepill__ico svg { width: 100%; height: 100%; }
.ios-filepill__meta {
  display: flex; flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.ios-filepill__meta strong {
  font: 600 13px/1.2 var(--sans);
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ios-filepill__meta em {
  font-style: normal;
  font: 500 11px/1.2 var(--sans);
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

/* Code label + huge code text */
.ios-code-label {
  margin-top: 16px;
  font: 600 11px/1 var(--sans);
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.02em;
}
.ios-code {
  margin-top: 6px;
  font: 700 22px/1.1 var(--sans);
  color: #fff;
  letter-spacing: -0.015em;
  text-align: center;
  word-break: break-word;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
  max-width: 90%;
}
@media (max-height: 640px) { .ios-code { font-size: 19px; } }
@media (max-height: 540px) { .ios-code { font-size: 16px; } }

/* Three action buttons under code */
.ios-actions {
  margin-top: 12px;
  display: inline-flex; gap: 8px;
}
.ios-action {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 0;
  border-radius: 12px;
  color: #fff;
}
.ios-action svg { width: 18px; height: 18px; }
@media (max-height: 540px) {
  .ios-action { width: 36px; height: 36px; border-radius: 10px; }
  .ios-action svg { width: 16px; height: 16px; }
}

.ios-share-hint {
  margin-top: 8px;
  font-size: 11px; color: rgba(255,255,255,0.65);
  font-weight: 500;
}

/* Bytes counter */
.ios-bytes {
  margin-top: 14px;
  font: 500 12px/1 var(--sans);
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.01em;
}

/* Progress bar — thin white pill on translucent track */
.ios-progress {
  margin-top: 10px;
  width: 80%;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.ios-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 3px;
  transition: width 0.12s linear;
}

/* Input + "Start Receiving" button */
.ios-input {
  margin-top: 18px;
  width: 90%;
  height: 44px;
  display: flex; align-items: center;
  padding: 0 10px 0 14px;
  gap: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  color: rgba(255,255,255,0.65);
  font: 500 13px/1 var(--sans);
  overflow: hidden;
}
.ios-input__placeholder {
  flex: 1;
  color: rgba(255,255,255,0.6);
  white-space: nowrap; overflow: hidden;
  font-size: 12px;
}
.ios-input__value {
  flex: 1;
  color: #fff;
  font: 600 12.5px/1 var(--mono);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden;
  min-width: 0;
}
.ios-input__caret {
  width: 2px; height: 16px;
  background: #5BA9FF;
  flex-shrink: 0;
  animation: ios-blink 1s steps(1) infinite;
}
@keyframes ios-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.ios-input__qr, .ios-input__clear {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
}
.ios-input__qr svg { width: 15px; height: 15px; }
.ios-input__clear svg { width: 18px; height: 18px; color: #fff; }

.ios-start-btn {
  margin-top: 8px;
  width: 90%;
  height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border-radius: 12px;
  border: 0;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  color: rgba(255,255,255,0.5);
  font: 600 13.5px/1 var(--sans);
  white-space: nowrap;
}
.ios-start-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.ios-start-btn--ready {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* Bottom CTA — "Ready to send/receive? Tap here" */
.ios-bottom-cta {
  text-align: center;
  font: 500 13px/1 var(--sans);
  color: rgba(255,255,255,0.78);
  padding: 6px 0 4px;
  opacity: 0;
}
/* Show on idle/code/complete scenes */
#sender[data-scene="idle"] .ios-bottom-cta,
#sender[data-scene="complete"] .ios-bottom-cta,
.receiver--ios[data-scene="recv-idle"] .ios-bottom-cta,
.receiver--ios[data-scene="recv-code"] .ios-bottom-cta,
.receiver--ios[data-scene="recv-complete"] .ios-bottom-cta { opacity: 1; }

/* Status bar — make it white on the colored bg */
.ios__statusbar {
  position: relative; z-index: 3;
  color: #fff;
}
.ios__statusbar .ios__icons { color: #fff; }
.ios__statusbar .i-battery { opacity: 0.95; }

/* Home indicator — white on dark bg */
.ios__home { background: rgba(255,255,255,0.7); }

/* Hide all the OLD app classes that no longer apply inside the new iOS layout */
.app__header { display: none; }
.brand-glyph,
.brand-word,
.app__settings,
.hero-glyph,
.hero-glyph__halo,
.hero-glyph__chip,
.scene__title,
.scene__sub,
.scene__hint,
.scene__cta,
.cta__icon,
.file-pill,
.code-card,
.handshake,
.spin,
.dots,
.generating,
.progress-card,
.recv-label,
.recv-input,
.complete,
.complete__ring,
.complete__title,
.complete__sub,
.rs-link,
.pill,
.share-btn { /* These now have iOS-specific replacements; default to inherit */ }

/* Kill the OLD scene-visibility rules — superseded by id-scoped ones above */
[data-scene="idle"]      .scene--idle,
[data-scene="file"]      .scene--file,
[data-scene="code"]      .scene--code,
[data-scene="joining"]   .scene--joining,
[data-scene="sending"]   .scene--sending,
[data-scene="complete"]  .scene--complete,
[data-scene="recv-idle"]         .scene--idle,
[data-scene="recv-code"]         .scene--code-entered,
[data-scene="recv-joining"]      .scene--joining,
[data-scene="recv-receiving"]    .scene--receiving,
[data-scene="recv-complete"]     .scene--complete { display: none; }

/* Re-enable for the iOS sender + receiver via id-scoped selectors (above) */
#sender[data-scene="idle"]      .scene--idle,
#sender[data-scene="file"]      .scene--file,
#sender[data-scene="code"]      .scene--file,
#sender[data-scene="joining"]   .scene--joining,
#sender[data-scene="sending"]   .scene--sending,
#sender[data-scene="complete"]  .scene--complete,
.receiver--ios[data-scene="recv-idle"]      .scene--idle,
.receiver--ios[data-scene="recv-code"]      .scene--code-entered,
.receiver--ios[data-scene="recv-joining"]   .scene--joining,
.receiver--ios[data-scene="recv-receiving"] .scene--receiving,
.receiver--ios[data-scene="recv-complete"]  .scene--complete {
  display: flex !important;
}
.brand-glyph {
  width: 22px; height: 22px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 35% 30%, var(--peach-2) 0%, var(--peach) 40%, var(--rs) 80%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.18),
    0 2px 6px -2px rgba(199,63,60,0.4);
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center; justify-content: center;
}
.brand-glyph svg {
  width: 62%; height: 62%;
  color: #fff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
}
.brand-word {
  font-weight: 600; font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--ink-1);
}
.app__settings {
  background: none; border: 0;
  color: var(--ink-3); font-size: 18px;
  padding: 4px 8px; line-height: 1;
  border-radius: 6px;
}

/* ─── Scene visibility ──────────────────────────────────────────────── */
.app .scene { display: none; }

/* Sender scenes */
.app--sender { /* scoped */ }
[data-scene="idle"]      .scene--idle,
[data-scene="file"]      .scene--file,
[data-scene="code"]      .scene--code,
[data-scene="joining"]   .scene--joining,
[data-scene="sending"]   .scene--sending,
[data-scene="complete"]  .scene--complete { display: flex; flex-direction: column; }

/* Receiver scenes */
[data-scene="recv-idle"]         .scene--idle,
[data-scene="recv-code"]         .scene--code-entered,
[data-scene="recv-joining"]      .scene--joining,
[data-scene="recv-receiving"]    .scene--receiving,
[data-scene="recv-complete"]     .scene--complete { display: flex; flex-direction: column; }

/* ─── Sender idle scene ─────────────────────────────────────────────── */
.scene--idle {
  flex: 1;
  align-items: center; justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 8px 4px;
}

.hero-glyph {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, var(--peach-2) 0%, var(--peach) 35%, var(--rs) 80%);
  box-shadow:
    0 14px 40px -8px var(--rs-glow),
    inset 0 0 0 1px rgba(255,255,255,0.2);
  isolation: isolate;
}
.hero-glyph svg {
  width: 56%; height: 56%;
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}
.hero-glyph__halo {
  position: absolute; inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--rs-glow), transparent 60%);
  filter: blur(12px);
  z-index: -1;
  animation: heropulse 4s ease-in-out infinite;
}
@keyframes heropulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.65; transform: scale(1.08); }
}
.hero-glyph__chip { display: none; }

.scene__title {
  margin: 8px 0 0;
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--ink-1);
  max-width: 90%;
}
.scene__sub {
  margin: 0;
  font-size: 11px; color: var(--ink-3);
  line-height: 1.4;
}
.scene__hint {
  margin: 4px 0 0;
  font-size: 10.5px; color: var(--ink-3);
  text-wrap: balance;
}

.scene__cta {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: 38px; padding: 0 18px;
  background: var(--rs); color: var(--on-rs);
  border: 0; border-radius: 12px;
  font: 600 13px/1 var(--sans);
  letter-spacing: -0.01em;
  margin-top: 4px;
  box-shadow: 0 6px 18px -6px var(--rs-glow);
  transition: transform var(--t-fast);
}
.scene__cta--ghost {
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.scene__cta--ghost[disabled] { opacity: 0.5; }
.scene__cta:not([disabled]):active { transform: scale(0.97); }
.cta__icon svg { width: 14px; height: 14px; }

/* ─── File pill ─────────────────────────────────────────────────────── */
.file-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 1px 0 var(--line-2);
  margin: 8px 0;
}
.file-pill--small { padding: 8px 10px; }
.file-pill__ico {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--rs);
  flex-shrink: 0;
}
.file-pill__ico svg { width: 16px; height: 16px; }
.file-pill__meta {
  display: flex; flex-direction: column;
  line-height: 1.2; flex: 1; min-width: 0;
}
.file-pill__name {
  font-size: 13px; font-weight: 600;
  color: var(--ink-1);
  font-family: var(--mono);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-pill__size {
  font-style: normal;
  font-size: 11px; color: var(--ink-3);
}

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

.generating {
  display: inline-flex; align-items: center; gap: 8px;
  align-self: center;
  font-size: 12px; color: var(--ink-3);
  margin-top: 8px;
}
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--rs);
  animation: dots 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dots {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* ─── Code card (sender) ────────────────────────────────────────────── */
.code-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 14px 12px;
  margin-top: 6px;
  box-shadow: 0 6px 20px -10px rgba(199,63,60,0.18);
}
.code-card__label {
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.code-card__value {
  font-family: var(--mono);
  font-size: 17px; font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.01em;
  word-break: break-word;
  margin-bottom: 12px;
}

.code-card__share {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.share-btn {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 8px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 10.5px; font-weight: 500;
  color: var(--ink-2);
  cursor: default;
}
.share-btn svg { width: 14px; height: 14px; color: var(--rs); }

.rs-link {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  text-align: center;
  word-break: break-all;
}

/* ─── Handshake / joining ──────────────────────────────────────────── */
.scene--joining { gap: 10px; padding-top: 4px; }
.handshake {
  margin-top: 4px;
  padding: 12px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 11px;
  color: var(--ink-2);
}
.handshake__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 8px;
}
.spin {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--rs);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.handshake__log {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.5;
}
.handshake__log li {
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, color 0.18s ease-out;
}
.handshake__log li.is-on { opacity: 1; transform: translateX(0); }
.handshake__log li.is-on[data-step="connect"] { color: var(--rs); font-weight: 600; }

/* ─── Sender / Receiver progress ────────────────────────────────────── */
.scene--sending,
.scene--receiving { gap: 10px; padding-top: 6px; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.progress-card__head {
  display: flex; align-items: center; gap: 10px;
}
.progress-card__meta {
  display: flex; flex-direction: column;
  line-height: 1.2; flex: 1; min-width: 0;
}
.progress-card__meta strong {
  font-size: 13px; font-weight: 600;
  font-family: var(--mono);
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.progress-card__meta em {
  font-style: normal;
  font-size: 10.5px; color: var(--ink-3);
}
.progress-card__pct {
  font-family: var(--mono);
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--rs);
}
.progress-card__bar {
  height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.progress-card__bar i {
  display: block;
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--rs), var(--peach));
  border-radius: 2px;
  transition: width 0.12s linear;
  box-shadow: 0 0 8px var(--rs-glow);
}
.progress-card__foot {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.pill__dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--rs);
  box-shadow: 0 0 0 3px rgba(199,63,60,0.18);
}
.pill__dot--enc { background: var(--peach); box-shadow: 0 0 0 3px rgba(232,155,133,0.22); }
.pill--p2p { color: var(--rs); }
.pill--enc { color: var(--peach); }

/* ─── Complete ─────────────────────────────────────────────────────── */
.scene--complete { align-items: center; justify-content: center; gap: 12px; padding: 12px 4px; }
.complete {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.complete__ring {
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  color: var(--rs);
  filter: drop-shadow(0 6px 14px var(--rs-glow));
}
.complete__ring svg { width: 100%; height: 100%; }
.complete__circle { fill: none; stroke: currentColor; }
.complete__check  { fill: none; stroke: currentColor; }
.complete__title {
  margin: 4px 0 0;
  font-size: 15px; font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.015em;
}
.complete__sub {
  margin: 0;
  font-size: 11px; color: var(--ink-3);
}

/* ═══════════════════════════════════════════════════════════════════
   iOS Receiver — recv input
   ═══════════════════════════════════════════════════════════════════ */
.scene--idle .recv-label,
.scene--code-entered .recv-label {
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
  margin: 12px 0 8px;
}
.recv-input {
  display: flex; align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 14px;
  min-height: 44px;
  position: relative;
}
.recv-input--empty {
  color: var(--ink-3);
}
.recv-input__placeholder { color: var(--ink-3); }
.recv-input__value {
  color: var(--ink-1);
  font-weight: 500;
}
.recv-input--locked {
  background: var(--surface-2);
  border-color: var(--rs);
  box-shadow: 0 0 0 3px var(--rs-glow);
}
.caret {
  display: inline-block;
  width: 2px; height: 16px;
  margin-left: 4px;
  background: var(--rs);
  opacity: 0;
  animation: blink 1s steps(1) infinite;
}
.caret--active { opacity: 1; }
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
.scene--code-entered .scene__cta { margin-top: 10px; align-self: stretch; }
.scene--code-entered .scene__cta--primary { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════
   CLI device
   ═══════════════════════════════════════════════════════════════════ */
.cli {
  width: 360px; height: 380px;
  background: var(--cli-bg);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow:
    0 24px 60px -16px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.06);
  font-family: var(--mono);
}
@media (max-height: 640px) {
  .cli { width: 320px; height: 320px; }
}
@media (max-height: 540px) {
  .cli { width: 280px; height: 280px; }
}

.cli__chrome {
  background: linear-gradient(180deg, #232128, #1a181d);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.cli__lights { display: inline-flex; gap: 6px; }
.cli__light {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #4a4a4e;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.4);
}
.cli__light:nth-child(1) { background: #ff5f57; }
.cli__light:nth-child(2) { background: #febc2e; }
.cli__light:nth-child(3) { background: #28c840; }
.cli__title {
  flex: 1;
  text-align: center;
  font-size: 11px; color: var(--cli-dim);
  font-family: var(--sans); font-weight: 500;
  letter-spacing: 0.02em;
}

.cli__screen {
  flex: 1;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--cli-fg);
  overflow: hidden;
  position: relative;
}
.cli__lines {
  display: flex; flex-direction: column;
  gap: 1px;
  white-space: pre-wrap;
  word-break: break-word;
}
.cli__line {
  display: block;
  font-family: var(--mono);
  color: var(--cli-fg);
}
.cli__prompt { color: var(--peach); margin-right: 6px; }
.cli__typed  { color: var(--cli-fg); }
.cli__line .cli__dim { color: var(--cli-dim); }
.cli__line .cli__accent { color: var(--peach); font-weight: 600; }
.cli__line .cli__ok { color: #6BE08B; }
.cli__line .cli__warn { color: #FFC107; }
.cli__line .caret { background: var(--peach); height: 13px; }
.cli__bar {
  display: inline-block;
  font-family: var(--mono);
  color: var(--peach);
  letter-spacing: 0;
}
.cli__bar .cli__bar-fill { color: var(--rs); }
.cli__bar .cli__bar-empty { color: var(--cli-dim); }

/* ═══════════════════════════════════════════════════════════════════
   Mac receiver — window chrome + sidebar + main
   ═══════════════════════════════════════════════════════════════════ */
.macwin {
  width: 540px; height: 380px;
  background: var(--mac-body);
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow:
    0 30px 60px -18px rgba(0,0,0,0.45),
    0 0 0 1px var(--line);
}
@media (max-height: 640px) { .macwin { width: 480px; height: 340px; } }
@media (max-height: 540px) { .macwin { width: 420px; height: 300px; } }
@media (max-width: 1100px) { .macwin { width: 460px; } }

.macwin__chrome {
  height: 38px;
  background: var(--mac-chrome);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 12px;
  gap: 12px;
}
.macwin__lights { display: inline-flex; gap: 8px; }
.macwin__light {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.2);
}
.macwin__light--close { background: #ff5f57; }
.macwin__light--min   { background: #febc2e; }
.macwin__light--max   { background: #28c840; }
.macwin__title {
  flex: 1;
  text-align: center;
  font-size: 12px; font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -0.005em;
}
.macwin__filler { width: 60px; }

.macwin__body {
  flex: 1; display: grid;
  grid-template-columns: 168px 1fr;
  min-height: 0;
}

.macsidebar {
  background: var(--mac-side);
  border-right: 1px solid var(--line);
  padding: 12px 8px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.macsidebar__brand {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--line-2);
}
.macsidebar__brand .brand-glyph { width: 20px; height: 20px; border-radius: 5px; }
.macsidebar__brand .brand-word { font-size: 13px; }

.macsidebar__list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.macsidebar__item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  position: relative;
  cursor: default;
}
.macsidebar__item svg {
  width: 15px; height: 15px;
  flex-shrink: 0;
  color: var(--ink-3);
}
.macsidebar__item--active {
  background: var(--rs);
  color: #fff;
  box-shadow: 0 1px 0 var(--line-2);
}
.macsidebar__item--active svg { color: #fff; }
.macsidebar__item--disabled {
  color: var(--ink-4);
  opacity: 0.7;
}
.macsidebar__item--disabled svg { color: var(--ink-4); }
.macsidebar__dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--peach);
  box-shadow: 0 0 0 3px rgba(232,155,133,0.32);
}
.macsidebar__pill {
  margin-left: auto;
  font-size: 9.5px;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.macsidebar__foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-2);
}
.macsidebar__user {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 8px;
}
.macsidebar__avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--peach), var(--rs));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.macmain {
  padding: 24px 28px;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--mac-body);
  position: relative;
}
.macmain .scene { display: none; }
[data-scene="mac-idle"]      .macmain .scene--idle,
[data-scene="mac-code"]      .macmain .scene--code-entered,
[data-scene="mac-joining"]   .macmain .scene--joining,
[data-scene="mac-receiving"] .macmain .scene--receiving,
[data-scene="mac-complete"]  .macmain .scene--complete { display: flex; flex-direction: column; gap: 12px; }

.macmain__title {
  font-size: 18px; font-weight: 700;
  color: var(--ink-1);
  letter-spacing: -0.015em;
  margin: 0;
}
.macmain__sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 4px;
  line-height: 1.5;
}
.macmain__sub code {
  font-family: var(--mono);
  font-size: 12px; padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-1);
}

.maccode {
  display: flex; gap: 8px;
  margin-top: 4px;
}
.maccode__input {
  flex: 1;
  height: 32px; padding: 0 12px;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-1);
  outline: none;
}
[data-scene="mac-code"] .maccode__input {
  border-color: var(--rs);
  box-shadow: 0 0 0 3px var(--rs-glow);
}
.maccode__btn {
  height: 32px; padding: 0 14px;
  background: var(--rs); color: var(--on-rs);
  border: 0; border-radius: 7px;
  font: 600 12.5px/1 var(--sans);
}
.maccode__btn[disabled] {
  background: var(--surface-2);
  color: var(--ink-3);
  box-shadow: inset 0 0 0 1px var(--line);
}
.maccode__btn--ready { animation: cta-pulse 1s ease-out 1; }
@keyframes cta-pulse {
  0%   { box-shadow: 0 0 0 0 var(--rs-glow); }
  100% { box-shadow: 0 0 0 8px transparent; }
}

.macmain__hint {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
.macmain__hint svg { width: 14px; height: 14px; }
.macmain__hint--ready { color: var(--rs); }
.macmain__hint--ready svg { color: var(--rs); }

.macprog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.macprog__row { display: flex; align-items: center; gap: 10px; }
.macprog__row .file-pill__ico { width: 32px; height: 32px; }
.macprog__row .file-pill__ico svg { width: 18px; height: 18px; }
.macprog__meta { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.macprog__meta strong { font-family: var(--mono); font-size: 13.5px; color: var(--ink-1); font-weight: 600; }
.macprog__meta em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.macprog__meta em [data-pct-mac] { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--rs); font-weight: 600; }

.complete--mac { margin-top: 12px; }
.complete--mac .complete__title { font-size: 17px; }
.complete--mac .complete__sub { font-size: 12.5px; }

/* ═══════════════════════════════════════════════════════════════════
   Wire — encryption visualization between devices
   ═══════════════════════════════════════════════════════════════════ */
.wire {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 12px 0;
  gap: 10px;
}

.wire__chip--mode {
  position: relative;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}
body[data-stage="p2p-ready"] .wire__chip--mode,
body[data-stage="sending"] .wire__chip--mode,
body[data-stage="settling"] .wire__chip--mode {
  opacity: 1; transform: translateY(0);
  color: var(--rs); border-color: var(--rs);
  box-shadow: 0 0 0 4px var(--rs-glow);
}
body[data-stage="complete"] .wire__chip--mode {
  opacity: 1; transform: translateY(0); color: var(--rs); border-color: var(--rs);
}

/* The flow region — horizontal channel with scrolling lines */
.wire__flow {
  position: relative;
  width: 100%;
  height: 96px;
  overflow: hidden;
  border-radius: 8px;
  opacity: 0;
  -webkit-mask: linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
  mask:          linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
}
body[data-stage="sending"] .wire__flow,
body[data-stage="settling"] .wire__flow { opacity: 1; }

.wire__lane {
  position: absolute;
  left: 0;
  width: 200%;             /* double-wide so the seamless loop has room */
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  animation: lane-flow 4s linear infinite;
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-3);
  will-change: transform;
}
.wire__lane span { display: inline-block; }
.wire__lane .pt { color: var(--ink-3); }
.wire__lane .ct { color: var(--rs); font-weight: 700; }
.wire__lane.l0 { top: 8px;  animation-duration: 3.6s; }
.wire__lane.l1 { top: 28px; animation-duration: 4.2s; animation-delay: -0.6s; opacity: 0.85; }
.wire__lane.l2 { top: 48px; animation-duration: 3.9s; animation-delay: -1.4s; opacity: 0.95; }
.wire__lane.l3 { top: 68px; animation-duration: 4.4s; animation-delay: -2.1s; opacity: 0.75; }
@keyframes lane-flow {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.wire__zones {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  opacity: 0;
}
.wire__zones > span {
  text-align: center; line-height: 1;
}
.wire__zones .wire__zlabel--mid { color: var(--rs); }
body[data-stage="sending"] .wire__zones,
body[data-stage="settling"] .wire__zones,
body[data-stage="p2p-ready"] .wire__zones { opacity: 1; }

/* Hide the old absolute lines and zones from previous design */
.wire__line, .wire__zone, .wire__label { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   Controls row
   ═══════════════════════════════════════════════════════════════════ */
.controls {
  display: grid;
  /* play | restart | scrub (flex) | variants — gear column removed
     when the demo-settings toggle was retired. */
  grid-template-columns: auto auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 28px 20px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg-0) 92%, transparent));
  position: relative;
}
@media (max-width: 800px) {
  .controls {
    grid-template-columns: auto auto auto;
    grid-template-areas:
      "play restart variants"
      "scrub scrub  scrub";
    padding: 10px 14px;
  }
  .controls .ctrl--play    { grid-area: play; }
  .controls .ctrl--restart { grid-area: restart; }
  .controls .scrub-wrap    { grid-area: scrub; }
  .controls .variants      { grid-area: variants; }
}

.ctrl {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-1);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.ctrl:hover { background: var(--surface-2); border-color: var(--rs); color: var(--rs); }
.ctrl svg { width: 16px; height: 16px; }
.ctrl--play .ic-play  { display: none; }
.ctrl--play .ic-pause { display: block; }
body[data-playing="false"] .ctrl--play .ic-play  { display: block; }
body[data-playing="false"] .ctrl--play .ic-pause { display: none; }

.scrub-wrap {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.scrub {
  flex: 1;
  appearance: none; -webkit-appearance: none;
  height: 4px;
  background: linear-gradient(to right,
    var(--rs) 0%, var(--rs) var(--p, 0%),
    var(--line) var(--p, 0%), var(--line) 100%);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rs);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rs) 22%, transparent), 0 2px 4px rgba(0,0,0,0.18);
  border: 0;
  cursor: pointer;
}
.scrub::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rs);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rs) 22%, transparent);
  border: 0; cursor: pointer;
}
.scrub:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--rs); outline-offset: 2px; }

.time {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  white-space: nowrap;
  min-width: 92px;
  text-align: right;
}
@media (max-width: 800px) { .time { display: none; } }

.variants {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.variant {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 0; border-radius: 9px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.variant svg { width: 14px; height: 14px; color: var(--ink-3); }
.variant:hover { color: var(--ink-1); }
.variant--active {
  background: var(--rs); color: #fff;
}
.variant--active svg { color: #fff; }
@media (max-width: 540px) {
  .variant { padding: 6px 8px; font-size: 11px; }
  .variant svg { display: none; }
}

.ctrl--gear { /* same as ctrl */ }

/* ─── Settings popover ─────────────────────────────────────────────── */
.settings {
  position: absolute;
  bottom: 84px; right: 28px;
  width: 280px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,0.18);
  z-index: 30;
}
.settings[hidden] { display: none; }
.settings__row {
  display: flex; flex-direction: column;
  gap: 6px;
}
.settings__label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.settings input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-1);
  outline: none;
  width: 100%;
}
.settings input:focus { border-color: var(--rs); box-shadow: 0 0 0 3px var(--rs-glow); }
.settings__hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.45;
}
.settings__hint code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--ink-1);
}

/* ─── Screen-reader live region ────────────────────────────────────── */
.sr-live {
  position: absolute;
  width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ─── prefers-reduced-motion fallback ──────────────────────────────── */
.reduced { display: none; }

@media (prefers-reduced-motion: reduce) {
  /* Kill timeline-driven CSS animation everywhere */
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .devices, .controls { display: none; }
  .reduced {
    display: flex;
    align-items: center; justify-content: center;
    padding: 32px;
    height: 100%;
  }
  .reduced__panel {
    max-width: 720px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px;
  }
  .reduced__title {
    font-size: 22px; font-weight: 700;
    letter-spacing: -0.015em;
    margin-bottom: 16px;
    color: var(--ink-1);
  }
  .reduced__steps {
    padding-left: 22px;
    margin: 0;
    display: flex; flex-direction: column; gap: 12px;
    color: var(--ink-2);
    font-size: 15px; line-height: 1.55;
  }
  .reduced__steps strong { color: var(--ink-1); }
  .reduced__steps code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 1px 5px;
    border-radius: 4px;
  }
}
