:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f6f3ee;
  color: #171717;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(246, 243, 238, 0.9)),
    url("https://images.unsplash.com/photo-1516280440614-37939bbacd81?auto=format&fit=crop&w=1800&q=80")
      center / cover;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 10px;
}

.stage {
  width: 100%;
  min-height: calc(100dvh - 20px);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(260px, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 16px 46px rgba(23, 23, 23, 0.14);
  backdrop-filter: blur(14px);
}

.stage.in-call {
  border-radius: 0;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.96);
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.eyebrow,
.mini-label {
  margin: 0 0 6px;
  color: #68706a;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 14vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-pill {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 999px;
  background: #ffffff;
  color: #525852;
  font-size: 0.94rem;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a4aba3;
}

.status-pill.live .status-dot {
  background: #0a8f62;
  box-shadow: 0 0 0 5px rgba(10, 143, 98, 0.14);
}

.status-pill.error .status-dot {
  background: #d33d27;
}

.language-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  border-radius: 8px;
  background: rgba(246, 243, 238, 0.76);
}

.pairing-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.join-row input {
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(23, 23, 23, 0.14);
  border-radius: 8px;
  background: #ffffff;
  color: #171717;
}

.room-message,
.debug-message {
  margin: 0;
  color: #4a514a;
  font-size: 0.93rem;
  line-height: 1.35;
}

.debug-message {
  color: #68706a;
  font-size: 0.82rem;
}

.language-panel label {
  display: grid;
  gap: 8px;
  color: #4a514a;
  font-weight: 700;
}

.language-panel label span {
  font-size: 0.84rem;
}

select {
  width: 100%;
  min-height: 46px;
  padding: 0 40px 0 14px;
  border: 1px solid rgba(23, 23, 23, 0.14);
  border-radius: 8px;
  background: #ffffff;
  color: #171717;
}

.primary-button,
.swap-button,
.secondary-button,
.audio-button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: #171717;
  color: #ffffff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.swap-button,
.secondary-button,
.audio-button {
  border: 1px solid rgba(23, 23, 23, 0.16);
  background: #ffffff;
  color: #171717;
}

.swap-button:active,
.secondary-button:active,
.audio-button:active {
  transform: translateY(1px);
}

.audio-button {
  border-color: rgba(211, 61, 39, 0.26);
  color: #9d2e1e;
}

.conversation-actions {
  display: grid;
  gap: 10px;
}

.qr-card,
.peer-card {
  margin: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  border-radius: 8px;
  background: #ffffff;
}

.qr-card img {
  width: min(190px, 100%);
  height: auto;
  justify-self: center;
  border-radius: 8px;
}

.qr-card figcaption {
  display: grid;
  gap: 3px;
  text-align: center;
  color: #343934;
  font-weight: 800;
}

.qr-card small {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #68706a;
  font-size: 0.74rem;
  font-weight: 600;
}

.peer-card strong {
  color: #171717;
  font-size: 1.18rem;
}

.peer-card p {
  margin: 0;
  color: #4a514a;
  font-size: 0.93rem;
}

.hidden {
  display: none !important;
}

.button-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #35e0a1;
  box-shadow: 0 0 0 5px rgba(53, 224, 161, 0.2);
}

.lyrics-panel {
  position: relative;
  min-height: 300px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(23, 23, 23, 0.11);
  border-radius: 8px;
  background:
    radial-gradient(circle at top left, rgba(51, 120, 115, 0.16), transparent 38%),
    linear-gradient(145deg, #101312, #232825);
  color: #ffffff;
}

.conversation-meta {
  position: absolute;
  inset: 14px 14px auto 14px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.listening-ring {
  position: absolute;
  inset: auto auto 18px 18px;
  height: 38px;
  display: flex;
  align-items: end;
  gap: 5px;
  opacity: 0.38;
}

.listening-ring.active {
  opacity: 1;
}

.listening-ring span {
  width: 6px;
  height: 12px;
  border-radius: 999px;
  background: #35e0a1;
  transform-origin: bottom;
}

.listening-ring.active span {
  animation: meter 0.72s ease-in-out infinite alternate;
}

.listening-ring.active span:nth-child(2) {
  animation-delay: 0.12s;
}

.listening-ring.active span:nth-child(3) {
  animation-delay: 0.24s;
}

.caption-stack {
  width: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 18px 14px;
}

.caption-placeholder,
.caption-line {
  margin: 0;
  text-align: center;
}

.caption-placeholder {
  color: rgba(255, 255, 255, 0.48);
  font-size: clamp(1.35rem, 8vw, 2.6rem);
  font-weight: 800;
}

.caption-line {
  color: rgba(255, 255, 255, 0.44);
  font-size: clamp(1rem, 5vw, 1.6rem);
  font-weight: 800;
  line-height: 1.15;
  transition:
    opacity 260ms ease,
    transform 260ms ease,
    color 260ms ease;
}

.caption-line.current {
  color: #ffffff;
  font-size: clamp(1.75rem, 10vw, 4.6rem);
  overflow-wrap: anywhere;
}

.caption-line.fading {
  opacity: 0;
  transform: translateY(-16px);
}

.brand-footer {
  color: #68706a;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.brand-footer a {
  color: #171717;
  text-decoration: none;
}

.brand-footer a:focus,
.brand-footer a:hover {
  text-decoration: underline;
}

@keyframes meter {
  from {
    transform: scaleY(0.65);
  }
  to {
    transform: scaleY(2.25);
  }
}

@media (min-width: 640px) {
  .app-shell {
    padding: 20px;
  }

  .stage {
    min-height: calc(100dvh - 40px);
    padding: 22px;
    gap: 16px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .status-pill {
    width: auto;
    min-width: 114px;
  }

  .language-panel {
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: end;
  }

  .pairing-panel {
    grid-template-columns: 150px minmax(0, 1fr);
    align-items: center;
  }

  .room-message,
  .debug-message {
    grid-column: 1 / -1;
  }

  .conversation-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .primary-button {
    grid-column: 1 / -1;
  }

  .audio-button {
    width: auto;
  }
}

@media (min-width: 920px) {
  .app-shell {
    padding: 32px;
  }

  .stage {
    width: min(1060px, 100%);
    min-height: min(760px, calc(100vh - 64px));
    padding: 28px;
    gap: 18px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 24px 70px rgba(23, 23, 23, 0.16);
  }

  .language-panel {
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 14px;
    padding: 14px;
  }

  .pairing-panel {
    grid-template-columns: 150px minmax(260px, 1fr) minmax(0, 1.4fr);
    gap: 14px;
    padding: 14px;
  }

  .room-message,
  .debug-message {
    grid-column: auto;
  }

  .primary-button {
    grid-column: auto;
  }

  .stage.in-call {
    width: 100%;
    min-height: calc(100vh - 64px);
  }

  .lyrics-panel {
    min-height: 360px;
  }

  .listening-ring {
    inset: auto auto 28px 28px;
  }

  .caption-stack {
    width: min(820px, 88%);
    min-height: 250px;
    padding: 0;
  }
}
