:root {
  color-scheme: dark;
  --bg: #0b0d13;
  --surface: #141720;
  --surface-raised: #1a1e29;
  --border: #292e3d;
  --text: #f5f7fb;
  --muted: #969dad;
  --accent: #7c6cff;
  --accent-bright: #a89eff;
  --cyan: #52d9d0;
  --green: #57d69b;
  --yellow: #ffc86b;
  --red: #ff667d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 82% -8%, rgba(124, 108, 255, .16), transparent 28rem),
    radial-gradient(circle at -10% 70%, rgba(82, 217, 208, .07), transparent 25rem),
    var(--bg);
}

button,
input { font: inherit; }

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

a { color: inherit; }

.landing {
  display: grid;
  place-items: center;
  padding: 2rem;
  overflow: hidden;
}

.landing::before,
.landing::after {
  position: fixed;
  z-index: -1;
  width: 20rem;
  height: 20rem;
  border: 1px solid rgba(255, 255, 255, .055);
  border-radius: 50%;
  content: "";
}

.landing::before { top: -9rem; left: -8rem; }
.landing::after { right: -7rem; bottom: -10rem; width: 29rem; height: 29rem; }

.hero {
  width: min(49rem, 100%);
  text-align: center;
}

.brand-mark {
  display: flex;
  width: 4.7rem;
  height: 4.7rem;
  margin: 0 auto 2rem;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 1.45rem;
  background: linear-gradient(145deg, var(--accent), #5141dd);
  box-shadow: 0 1.3rem 3rem rgba(80, 64, 220, .28);
}

.brand-mark span {
  width: .25rem;
  border-radius: 1rem;
  background: white;
  animation: bars 1.3s ease-in-out infinite alternate;
}

.brand-mark span:nth-child(1) { height: .85rem; animation-delay: -.4s; }
.brand-mark span:nth-child(2) { height: 1.7rem; animation-delay: -.8s; }
.brand-mark span:nth-child(3) { height: 1.2rem; animation-delay: -.2s; }
.brand-mark span:nth-child(4) { height: 2rem; animation-delay: -.6s; }

@keyframes bars { to { transform: scaleY(.52); } }

.eyebrow,
.step-label {
  margin: 0 0 .5rem;
  color: var(--accent-bright);
  font-size: .73rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(3.4rem, 10vw, 7rem);
  line-height: .91;
  letter-spacing: -.075em;
}

.hero-copy {
  max-width: 42rem;
  margin: 2rem auto;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
  line-height: 1.65;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem 1.3rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: .78rem;
}

.feature-row span::before {
  margin-right: .45rem;
  color: var(--green);
  content: "●";
  font-size: .55rem;
}

.button {
  display: inline-flex;
  min-height: 2.9rem;
  align-items: center;
  justify-content: center;
  padding: .72rem 1.1rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  cursor: pointer;
  font-weight: 760;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { opacity: .58; cursor: wait; }

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), #6253ef);
  box-shadow: 0 .7rem 1.8rem rgba(98, 83, 239, .2);
}

.button-secondary,
.button-danger {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-raised);
}

.button-secondary:hover,
.button-danger:hover { border-color: #444b61; }
.button-secondary.active { border-color: var(--red); color: #ff9cac; }
.button-danger { color: #ff9cac; }
.button-large { min-height: 3.4rem; padding-inline: 1.55rem; }
.button-full { width: 100%; }

.app-shell {
  width: min(68rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.wordmark {
  font-size: .9rem;
  font-weight: 850;
  letter-spacing: -.02em;
  text-decoration: none;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .78rem;
}

.connection-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 .25rem rgba(255, 200, 107, .08);
}

.connection[data-state="online"] .connection-dot { background: var(--green); box-shadow: 0 0 0 .25rem rgba(87, 214, 155, .08); }
.connection[data-state="offline"] .connection-dot { background: var(--red); box-shadow: 0 0 0 .25rem rgba(255, 102, 125, .08); }

.setup-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: rgba(20, 23, 32, .92);
  box-shadow: 0 1.2rem 3rem rgba(0, 0, 0, .13);
}

.setup-card {
  display: grid;
  grid-template-columns: minmax(13rem, .7fr) minmax(22rem, 1.3fr);
  gap: 2rem;
  align-items: center;
  padding: 1.25rem;
  border-color: rgba(124, 108, 255, .34);
  background: linear-gradient(120deg, rgba(124, 108, 255, .1), rgba(20, 23, 32, .96) 52%);
}

.setup-card h1,
.panel h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -.025em;
}

.setup-copy > p:not(.step-label) {
  margin: .4rem 0 0;
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.5;
}

.copy-row {
  display: flex;
  gap: .55rem;
}

.copy-row input {
  min-width: 0;
  min-height: 2.9rem;
  flex: 1;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  outline: none;
  color: var(--text);
  background: #0d1017;
}

.copy-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(124, 108, 255, .11); }

.link-readiness {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  margin-top: .6rem;
  color: var(--yellow);
  font-size: .74rem;
  line-height: 1.4;
}

.link-readiness::before {
  width: .44rem;
  height: .44rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  content: "";
  box-shadow: 0 0 0 .2rem color-mix(in srgb, currentColor 10%, transparent);
}

.link-readiness span { flex: 0 0 auto; font-weight: 800; }
.link-readiness small { color: var(--muted); font-size: .7rem; }
.link-readiness[data-state="ready"] { color: var(--green); }
.link-readiness[data-state="blocked"] { color: var(--red); }

.presence-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .65rem;
}

.presence-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--green);
  font-size: .76rem;
  font-weight: 700;
}

.presence-badge::before {
  width: .44rem;
  height: .44rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.presence-badge.offline { color: var(--muted); }

.text-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: none;
  cursor: pointer;
  font-size: .73rem;
  text-decoration: underline;
  text-underline-offset: .2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(15rem, .7fr);
  gap: 1rem;
  margin-top: 1rem;
}

.panel { padding: 1.25rem; }

.panel-topline,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .025);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.live-badge::before {
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.live-badge[data-state="waiting"] { color: var(--yellow); border-color: rgba(255, 200, 107, .26); }
.live-badge[data-state="live"] { color: var(--green); border-color: rgba(87, 214, 155, .3); }

.source-status {
  min-height: 2.7rem;
  margin: .65rem 0 1rem;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.55;
}

.meter-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .85rem;
  background: #0d1017;
}

.meter-track {
  height: .72rem;
  overflow: hidden;
  border-radius: 999px;
  background: #252a37;
}

.meter-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green) 62%, var(--yellow) 84%, var(--red));
  box-shadow: 0 0 1.2rem rgba(82, 217, 208, .32);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 60ms linear;
}

.meter-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .65rem;
  color: var(--muted);
  font-size: .7rem;
  font-variant-numeric: tabular-nums;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1rem;
}

.browser-hint,
.hint,
.legal-note {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.55;
}

.browser-hint { margin: 1rem 0 0; }
.form-error { min-height: 1.2em; margin: .55rem 0 0; color: #ff93a3; font-size: .8rem; }

.panel-heading output {
  color: var(--accent-bright);
  font-size: 1.45rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.volume-slider { width: 100%; margin: 2.15rem 0 1.85rem !important; }
.output-panel .hint { margin: .9rem 0 0; }

.instructions {
  display: grid;
  grid-template-columns: minmax(11rem, .55fr) minmax(0, 1.45fr);
  gap: 2rem;
  align-items: center;
  margin-top: 1rem;
}

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

.instructions li {
  display: flex;
  min-width: 0;
  gap: .65rem;
  align-items: center;
}

.instructions li > span {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: .55rem;
  color: var(--accent-bright);
  background: var(--surface-raised);
  font-size: .72rem;
  font-weight: 850;
}

.instructions strong,
.instructions small { display: block; }
.instructions strong { font-size: .78rem; }
.instructions small { margin-top: .2rem; color: var(--muted); font-size: .67rem; line-height: 1.35; }
.legal-note { margin: 1.25rem 0 0; text-align: center; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  opacity: 0;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, .3);
  pointer-events: none;
  transform: translateY(.5rem);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.visible { opacity: 1; transform: translateY(0); }

.receiver-page {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.receiver-shell {
  position: fixed;
  inset: 0;
  display: flex;
  min-width: 240px;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: clamp(1rem, 5vw, 3rem);
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(124, 108, 255, .18), transparent 38%),
    #0b0d13;
}

.receiver-visual {
  position: relative;
  display: grid;
  width: clamp(4.5rem, 16vw, 7rem);
  height: clamp(4.5rem, 16vw, 7rem);
  place-items: center;
}

.receiver-rings span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(124, 108, 255, .22);
  border-radius: 50%;
  animation: receiver-pulse 2.5s ease-out infinite;
}

.receiver-rings span:nth-child(2) { animation-delay: -.8s; }
.receiver-rings span:nth-child(3) { animation-delay: -1.6s; }

@keyframes receiver-pulse {
  0% { opacity: 0; transform: scale(.45); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.35); }
}

.receiver-mark {
  position: relative;
  z-index: 1;
  display: flex;
  width: 3.4rem;
  height: 3.4rem;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 1.05rem;
  background: linear-gradient(145deg, var(--accent), #5141dd);
  box-shadow: 0 1rem 2.5rem rgba(80, 64, 220, .3);
}

.receiver-mark i {
  width: .18rem;
  border-radius: 1rem;
  background: white;
  animation: bars 1.2s ease-in-out infinite alternate;
}

.receiver-mark i:nth-child(1) { height: .6rem; animation-delay: -.3s; }
.receiver-mark i:nth-child(2) { height: 1.25rem; animation-delay: -.7s; }
.receiver-mark i:nth-child(3) { height: .8rem; animation-delay: -.1s; }
.receiver-mark i:nth-child(4) { height: 1.45rem; animation-delay: -.5s; }

.receiver-kicker {
  margin: .9rem 0 .35rem;
  color: var(--accent-bright);
  font-size: clamp(.55rem, 1.8vw, .72rem);
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.receiver-shell h1 {
  max-width: 90%;
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.2rem, 4.8vw, 2rem);
  letter-spacing: -.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receiver-shell > p:not(.receiver-kicker) {
  max-width: 31rem;
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: clamp(.64rem, 2vw, .82rem);
  line-height: 1.45;
}

.receiver-state {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-top: .85rem;
  padding: .38rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, .22);
  font-size: clamp(.56rem, 1.8vw, .7rem);
}

.receiver-state span {
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--yellow);
}

.receiver-shell[data-state="live"] .receiver-state { color: var(--green); border-color: rgba(87, 214, 155, .25); }
.receiver-shell[data-state="live"] .receiver-state span { background: var(--green); box-shadow: 0 0 .7rem var(--green); }
.receiver-shell[data-state="muted"] .receiver-state { color: var(--red); border-color: rgba(255, 102, 125, .25); }
.receiver-shell[data-state="muted"] .receiver-state span,
.receiver-shell[data-state="error"] .receiver-state span { background: var(--red); }
.receiver-shell[data-state="live"] .receiver-rings span { border-color: rgba(82, 217, 208, .25); animation-duration: 1.7s; }

.receiver-shell.audio-only { background: transparent; }
.receiver-shell.audio-only > :not(#remote-audio):not(.autoplay-help) { display: none; }

#remote-audio { position: absolute; width: 1px; height: 1px; opacity: 0; }

.autoplay-help {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: min(90%, 24rem);
  padding: 1rem;
  border: 1px solid var(--accent);
  border-radius: .7rem;
  color: white;
  background: rgba(13, 16, 23, .97);
  cursor: pointer;
  transform: translate(-50%, -50%);
}

@media (max-width: 780px) {
  .setup-card,
  .instructions { grid-template-columns: 1fr; gap: 1rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .instructions ol { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 1rem, 68rem); }
  .copy-row { flex-direction: column; }
  .copy-row .button { width: 100%; }
  .presence-row { align-items: flex-start; flex-direction: column; gap: .55rem; }
  .link-readiness { align-items: flex-start; flex-direction: column; gap: .2rem; }
}

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