/* ───────────────────────── Tokens ───────────────────────── */
:root {
  color-scheme: dark;
  --bg: #08090f;
  --bg-soft: #0e101a;
  --text: #f3f4fa;
  --muted: rgba(243, 244, 250, 0.6);
  --faint: rgba(243, 244, 250, 0.34);
  --line: rgba(255, 255, 255, 0.1);
  --surface: rgba(255, 255, 255, 0.055);
  --surface-hi: rgba(255, 255, 255, 0.11);
  /* One refined accent. No multi-hue gradients. */
  --accent: #3f9ee0;
  --accent-strong: #5cb0ea;
  --accent-tint: rgba(63, 158, 224, 0.5);
  --accent-button: linear-gradient(180deg, #4ba6e6 0%, #357fc8 100%);
  --green: #25d36b;
  --red: #ff4b56;
  --radius: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  margin: 0;
}

img {
  display: block;
}

.i {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ───────────────────────── Aurora backdrop ───────────────────────── */
.aurora {
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(42% 34% at 18% 12%, rgba(63, 158, 224, 0.16), transparent 72%),
    radial-gradient(46% 40% at 86% 90%, rgba(63, 158, 224, 0.1), transparent 74%);
  filter: blur(40px);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.1);
  }
}

/* ───────────────────────── Screen system ───────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(env(safe-area-inset-top) + 26px) 22px calc(env(safe-area-inset-bottom) + 26px);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.012);
  /* No transition on the base state: leaving a screen hides it instantly so
     the outgoing screen never bleeds through while the next one fades in. */
}

.screen.active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition:
    opacity 0.4s var(--ease),
    transform 0.4s var(--ease);
}

.screen-head {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.screen-head--floating {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 18px;
  right: 18px;
  align-items: flex-start;
}

.screen-title {
  margin: 0;
  font-size: clamp(2rem, 9vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.screen-sub {
  margin: 0;
  max-width: 22em;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

/* ───────────────────────── Brand mark ───────────────────────── */
.brand-mark {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
}

.brand-mark--sm {
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 38% 52%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark > .brand-logo {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 24px 60px -20px rgba(63, 158, 224, 0.45);
}

.brand-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  animation: ripple 3.4s var(--ease) infinite;
}

.brand-ring:nth-child(2) {
  animation-delay: 1.7s;
}

@keyframes ripple {
  0% {
    transform: scale(0.74);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

/* ───────────────────────── Loading ───────────────────────── */
.loading-screen,
.ended-screen {
  justify-content: center;
}

.loading-inner,
.ended-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

/* On the ended screen the inner block shouldn't expand — let the whole group
   (thank-you + save + recap + go-home) sit centered together, no dead space. */
.ended-inner {
  flex: 0 0 auto;
}

.wordmark {
  margin: 16px 0 0;
  font-size: clamp(2.7rem, 13vw, 3.7rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
}

.loading-bar {
  margin-top: 26px;
  width: 178px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loading-bar span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  animation: loadfill 0.3s var(--ease) forwards;
}

@keyframes loadfill {
  0% {
    transform: scaleX(0.02);
  }
  100% {
    transform: scaleX(1);
  }
}

.powered-by {
  margin: 0;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 600;
}

.powered-by a {
  color: var(--muted);
  text-decoration: none;
}

/* ───────────────────────── Language picker ───────────────────────── */
.language-screen {
  justify-content: flex-start;
  gap: 24px;
  padding-top: calc(env(safe-area-inset-top) + 40px);
}

.lang-grid {
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 124px;
  padding: 16px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease);
}

.lang-btn[data-wide] {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 14px;
  min-height: 78px;
}

.lang-btn:active {
  transform: scale(0.96);
}

.lang-btn.selected {
  border-color: transparent;
  background:
    linear-gradient(var(--bg-soft), var(--bg-soft)) padding-box,
    var(--accent) border-box;
  box-shadow: 0 12px 30px -16px var(--accent-tint);
}

.lang-flag {
  font-size: 2.3rem;
  line-height: 1;
}

.lang-btn[data-wide] .lang-flag {
  font-size: 1.9rem;
}

.lang-native {
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.lang-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--faint);
}

.lang-btn[data-preview] .lang-name::after {
  content: "*";
  margin-left: 2px;
  color: var(--faint);
}

.lang-footnote {
  width: 100%;
  max-width: 460px;
  margin: -6px 0 0;
  font-size: 0.72rem;
  color: var(--faint);
  text-align: center;
}

.lang-btn[data-wide] .lang-native,
.lang-btn[data-wide] .lang-name {
  display: block;
  text-align: left;
}

/* ───────────────────────── Chips & buttons ───────────────────────── */
.ghost-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 9px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  transition: background 0.18s var(--ease);
}

.ghost-chip:active {
  background: var(--surface-hi);
}

.ghost-chip .i {
  width: 17px;
  height: 17px;
}

.cta-button {
  width: 100%;
  max-width: 460px;
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border-radius: 17px;
  background: var(--accent-button);
  color: #fff;
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 14px 32px -14px var(--accent-tint);
  transition:
    transform 0.16s var(--ease),
    filter 0.16s var(--ease);
}

.cta-button .i {
  width: 21px;
  height: 21px;
}

.cta-button:active {
  transform: scale(0.975);
}

.cta-button:disabled {
  filter: grayscale(0.7) brightness(0.66);
  box-shadow: none;
}

.cta-button.copied {
  background: var(--green);
}

/* ───────────────────────── Share screen ───────────────────────── */
.share-screen {
  justify-content: center;
  gap: 20px;
}

.qr-card {
  position: relative;
  width: 244px;
  height: 244px;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: 0 26px 60px -22px rgba(0, 0, 0, 0.85);
}

.qr-card img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.qr-card img.ready {
  opacity: 1;
}

.qr-skeleton {
  position: absolute;
  inset: 16px;
  border-radius: 8px;
  background: linear-gradient(110deg, #eef0f4 28%, #dde1e8 42%, #eef0f4 56%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}

.qr-card.ready .qr-skeleton {
  display: none;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.link-pill {
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 13px;
  border: 1px dashed var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

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

.waiting {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.waiting-dots {
  display: inline-flex;
  gap: 4px;
}

.waiting-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.4s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.waiting-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ───────────────────────── Incoming call ───────────────────────── */
.incoming-screen {
  justify-content: space-between;
  padding-top: calc(env(safe-area-inset-top) + 84px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 52px);
}

.incoming-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.caller-mark {
  position: relative;
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}

.caller-mark > .brand-logo {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 26px 70px -22px rgba(63, 158, 224, 0.5);
}

.echo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(63, 158, 224, 0.42);
  animation: ripple 2.6s var(--ease) infinite;
}

.echo-ring:nth-child(2) {
  animation-delay: 0.85s;
}

.echo-ring:nth-child(3) {
  animation-delay: 1.7s;
}

.incoming-label {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.incoming-title {
  margin: 0;
  font-size: clamp(1.7rem, 7.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.12;
  max-width: 14em;
}

.incoming-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.incoming-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.answer-button {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  box-shadow: 0 16px 44px -10px rgba(37, 211, 107, 0.7);
  animation: answer-bob 1.8s ease-in-out infinite;
}

.answer-button::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 107, 0.55);
  animation: ripple 1.8s var(--ease) infinite;
}

.answer-button .i {
  width: 38px;
  height: 38px;
}

.answer-button .i path {
  fill: currentColor;
  stroke: none;
}

.answer-button:active {
  transform: scale(0.93);
}

@keyframes answer-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

.answer-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

/* Incoming: decline + accept side by side, like a native call screen. */
.answer-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
}

.answer-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Rotate the phone glyph so decline reads as "hang up". */
.i-hangup {
  transform: rotate(135deg);
}

/* ───────────────────────── Call screen ───────────────────────── */
.call-screen {
  justify-content: space-between;
  gap: 0;
  background: var(--bg);
  padding-top: calc(env(safe-area-inset-top) + 58px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 28px);
  transition: background 0.4s var(--ease);
}

.call-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 3;
}

.call-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.call-state.connected {
  color: var(--green);
}

.call-timer {
  margin: 0;
  font-size: 2.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Same-language warning: both sides chose the same language, so translation is
   a no-op. A dismissible amber banner under the timer; doesn't block captions. */
.samelang-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 10px 12px 10px 14px;
  border-radius: 14px;
  text-align: left;
  background: rgba(245, 176, 65, 0.13);
  border: 1px solid rgba(245, 176, 65, 0.42);
  animation: samelangIn 0.35s var(--ease) both;
}

.samelang-banner[hidden] {
  display: none;
}

.samelang-icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: #f5b041;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.samelang-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.samelang-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: #ffe9c4;
}

.samelang-body {
  font-size: 0.8rem;
  color: rgba(245, 217, 168, 0.82);
}

.samelang-dismiss {
  flex: none;
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #f5d9a8;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}

.samelang-dismiss:hover {
  background: rgba(245, 176, 65, 0.16);
}

.samelang-dismiss .i {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

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

/* Unified call view: logo, hint, and live transcript are always shown */
.call-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding-top: 30px;
}

.caller-mark--call {
  width: 82px;
  height: 82px;
  flex: none;
}

.caller-mark--call .echo-ring {
  animation-duration: 3.6s;
  border-color: rgba(63, 158, 224, 0.26);
}

.call-hint {
  margin: 2px 0 4px;
  max-width: 24em;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.caption-stack {
  flex: 1;
  min-height: 0; /* required so overflow-y actually scrolls in a flex column */
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 14px 70px; /* bottom band reserved for the presence pill */
  overflow-y: auto; /* scroll back through the transcript */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.caption-stack::-webkit-scrollbar {
  width: 5px;
}

.caption-stack::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

/* Pin content to the bottom while keeping overflow scrollable. (flex-end breaks
   scroll-to-top in Chromium, so an auto-margin spacer is used instead.) */
.caption-stack::before {
  content: "";
  margin-top: auto;
}

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

.caption-placeholder {
  color: rgba(255, 255, 255, 0.32);
  font-size: clamp(1.3rem, 6vw, 2rem);
  font-weight: 700;
}

.caption-line {
  color: rgba(255, 255, 255, 0.42);
  font-size: clamp(1rem, 4.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
  transition:
    opacity 0.28s var(--ease),
    transform 0.28s var(--ease),
    color 0.28s var(--ease);
}

.caption-line.current {
  color: #ffffff;
  font-size: clamp(2rem, 9vw, 4.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

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

.listening-ring {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 34px;
  opacity: 0.32;
  transition: opacity 0.25s var(--ease);
}

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

.listening-ring span {
  width: 6px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: bottom;
}

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

.listening-ring.active span:nth-child(2) {
  animation-delay: 0.09s;
}
.listening-ring.active span:nth-child(3) {
  animation-delay: 0.18s;
}
.listening-ring.active span:nth-child(4) {
  animation-delay: 0.27s;
}
.listening-ring.active span:nth-child(5) {
  animation-delay: 0.36s;
}

@keyframes meter {
  from {
    transform: scaleY(0.6);
  }
  to {
    transform: scaleY(2.5);
  }
}

/* Call controls */
.call-controls {
  display: flex;
  gap: 38px;
  z-index: 3;
}

.control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.control-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-hi);
  border: 1px solid var(--line);
  color: var(--text);
  transition:
    transform 0.16s var(--ease),
    background 0.2s var(--ease);
}

.control-button .i {
  width: 27px;
  height: 27px;
}

.control-button:active {
  transform: scale(0.92);
}

.control-button--end {
  background: var(--red);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 14px 34px -12px rgba(255, 75, 86, 0.7);
}

.control-button--end .i {
  transform: rotate(135deg);
}

.control-button--end .i path {
  fill: currentColor;
  stroke: none;
}

.i-mic .mic-slash {
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}

#muteButton.muted {
  background: rgba(255, 75, 86, 0.16);
  border-color: rgba(255, 75, 86, 0.42);
  color: #ff8f95;
}

#muteButton.muted .mic-slash {
  opacity: 1;
}

.i-cam .cam-slash {
  opacity: 1; /* slash shows when the camera is off (the default) */
  transition: opacity 0.18s var(--ease);
}

#cameraButton.camera-on .cam-slash {
  opacity: 0;
}

#cameraButton.camera-on {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 30px -14px var(--accent-tint);
}

/* ───────────────────────── Video layer ───────────────────────── */
.call-video {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
}

.call-screen.video-on .call-video {
  display: block;
}

.call-screen.video-on .call-stage {
  display: none;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.remote-video.hidden-video {
  visibility: hidden;
}

.self-video {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 64px);
  right: 14px;
  z-index: 2;
  width: 92px;
  height: 124px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #11131c;
  transform: scaleX(-1); /* mirror the self-view */
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.85);
}

.self-video.hidden-video {
  display: none;
}

.video-subtitle {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 110px);
  transform: translateX(-50%);
  z-index: 2;
  max-width: min(92%, 760px);
  margin: 0;
  padding: 8px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: clamp(1.05rem, 4.4vw, 1.55rem);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.video-subtitle:empty {
  display: none;
}

/* Scrims so the top bar and controls stay legible over bright video */
.call-screen.video-on .call-video::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 160px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}

.call-screen.video-on .call-video::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 220px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), transparent);
}

.call-screen.video-on .call-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  justify-content: center;
}

/* ───────────────────────── Presence (peer speaking) ───────────────────────── */
/* Sits inside .call-top right under the timer. Hidden by default; fades in while
   the peer is speaking. */
.presence {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(17, 19, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px -16px rgba(0, 0, 0, 0.85);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.presence.speaking {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.presence-wave {
  display: none;
  width: 62px;
  height: 16px;
}
.presence.speaking .presence-wave {
  display: block;
}

.presence-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ───────────────────────── Debug stats (for nerds) ───────────────────────── */
.debug-button {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  z-index: 4;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  opacity: 0.55;
  transition: opacity 0.18s var(--ease), background 0.18s var(--ease);
}

.debug-button .i {
  width: 18px;
  height: 18px;
}

.debug-button.active {
  opacity: 1;
  background: var(--surface-hi);
  color: var(--text);
}

.news-button {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px 0 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.6;
  transition:
    opacity 0.18s var(--ease),
    background 0.18s var(--ease),
    color 0.18s var(--ease);
}

.news-button .i {
  width: 16px;
  height: 16px;
}

.news-label {
  white-space: nowrap;
}

.i-news circle {
  fill: currentColor;
  stroke: none;
}

.news-button.active {
  opacity: 1;
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.debug-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.debug-panel[hidden] {
  display: none;
}

.debug-head {
  margin: 0;
  padding: 6px 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
}

.debug-log {
  max-height: 84px;
  overflow-y: auto;
  padding: 6px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.debug-log::-webkit-scrollbar {
  width: 4px;
}

.debug-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.debug-line {
  margin: 0;
  padding: 1px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.control-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

/* Audio unlock overlay */
.audio-unlock {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(8, 9, 15, 0.86);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}

.audio-unlock[hidden] {
  display: none;
}

.audio-unlock .i {
  width: 30px;
  height: 30px;
  padding: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-sizing: content-box;
  color: #fff;
}

.audio-unlock .i path:first-child {
  fill: currentColor;
  stroke: none;
}

.audio-unlock .overlay-msg {
  margin: 0;
  max-width: 22em;
  padding: 0 24px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}

.audio-unlock .cta-button {
  width: min(100%, 320px);
}

/* ───────────────────────── Ended screen ───────────────────────── */
.ended-actions {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.ended-actions[hidden] {
  display: none;
}

.ended-q {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

/* ───────────────────────── Diagnostics ───────────────────────── */
.diag-line {
  position: fixed;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  z-index: 6;
  margin: 0;
  max-width: 92vw;
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--faint);
  font-size: 9px;
  font-weight: 500;
  opacity: 0.5;
  cursor: pointer;
}

body[data-screen="share"] .diag-line,
body[data-screen="call"] .diag-line {
  display: block;
}

/* ───────────────────────── Larger screens ───────────────────────── */
@media (min-width: 720px) {
  .lang-grid,
  .screen-head,
  .cta-button,
  .link-pill,
  .ended-actions {
    max-width: 480px;
  }

  .caption-stack {
    max-width: 860px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aurora,
  .brand-ring,
  .echo-ring,
  .answer-button,
  .answer-button::before,
  .waiting-dots span,
  .loading-bar span,
  .listening-ring.active span,
  .qr-skeleton {
    animation: none !important;
  }
  .screen,
  .screen.active {
    transition: none;
    transform: none;
  }
  .loading-bar span {
    transform: scaleX(1);
  }
}

/* ───────────────────────── Home (recents / contacts) ───────────────────────── */
.home-screen {
  justify-content: flex-start;
  gap: 16px;
}

.home-name {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 6px auto 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.home-name-label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.home-name-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.recents {
  width: min(100%, 460px);
  margin: 0 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.recent-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.recent-call {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
  min-width: 0;
}

.recent-call:active {
  background: var(--surface-hi);
}

.recent-avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(160deg, var(--accent-strong), #2f6fb0);
}

.recent-row.missed .recent-avatar {
  background: linear-gradient(160deg, #ff6a73, #c33);
}

.recent-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recent-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-sub {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-row.missed .recent-sub {
  color: var(--red);
}

.recent-rename {
  flex: 0 0 auto;
  width: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.05rem;
  border-left: 1px solid var(--line);
}

.recent-rename:active {
  background: var(--surface-hi);
  color: var(--text);
}

.recent-delete {
  flex: 0 0 auto;
  width: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  border-left: 1px solid var(--line);
}

.recent-delete:active {
  background: var(--surface-hi);
  color: var(--red);
}

/* Inline delete confirmation, replacing the row's contents in place. */
.recent-row--confirm {
  align-items: center;
  padding: 8px 8px 8px 14px;
  gap: 8px;
}

.recent-confirm-label {
  flex: 1 1 auto;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-confirm-cancel,
.recent-confirm-delete {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
}

.recent-confirm-cancel {
  color: var(--text);
  background: var(--surface-hi);
}

.recent-confirm-delete {
  color: #fff;
  background: var(--red);
}

.recent-confirm-delete:active,
.recent-confirm-cancel:active {
  transform: scale(0.96);
}

.recents-empty {
  width: min(100%, 360px);
  margin: 8px auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.recents-empty[hidden] {
  display: none;
}

/* Dismissible install advertisement on the home screen. */
.install-banner {
  width: min(100%, 460px);
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  border-radius: 14px;
  border: 1px solid var(--accent-tint);
  background: rgba(63, 158, 224, 0.1);
  overflow: hidden;
}

.install-banner[hidden] {
  display: none;
}

.install-main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 11px 14px;
  color: var(--text);
  font-weight: 650;
  font-size: 0.92rem;
  text-align: left;
}

.install-main .i {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.install-main:active {
  background: rgba(63, 158, 224, 0.18);
}

.install-dismiss {
  flex: 0 0 auto;
  width: 42px;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 1.3rem;
  line-height: 1;
  border-left: 1px solid var(--accent-tint);
}

.install-dismiss:active {
  color: var(--text);
}

.inline-edit {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 2px 8px;
  width: 100%;
  max-width: 220px;
}

/* ───────────────────────── Calling (outgoing) ───────────────────────── */
.answer-button--end {
  background: var(--red);
  box-shadow: 0 16px 44px -10px rgba(255, 75, 86, 0.7);
  animation: none;
}

.answer-button--end::before {
  display: none;
}

.calling-screen .incoming-title {
  margin-top: 8px;
}

/* ───────────────────────── Save contact (ended screen) ───────────────────────── */
.save-contact {
  width: min(100%, 360px);
  margin: 4px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.save-contact[hidden] {
  display: none;
}

.save-contact-q {
  font-weight: 700;
  font-size: 1rem;
}

.save-contact-input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}

.save-contact-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ───────────────────────── Recap / phrasebook ───────────────────────── */
.cta-button--soft {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}

.cta-button--soft[hidden],
.home-saved[hidden] {
  display: none;
}

.home-saved {
  margin: 10px auto 0;
}

/* Secondary home actions sit side-by-side as two compact pills instead of a
   vertical stack, so Saved phrases + Alerts read as one tidy row under New call. */
.home-actions {
  display: flex;
  gap: 0.55rem;
  width: min(100%, 460px);
  margin: 10px auto 0;
}

.home-actions .ghost-chip {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  gap: 6px;
  padding: 11px 10px;
  justify-content: center;
  text-align: center;
}

.recap-screen,
.phrasebook-screen {
  justify-content: flex-start;
  gap: 14px;
}

.recap-summary {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent-tint);
  background: rgba(63, 158, 224, 0.08);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  text-align: left;
}

.recap-summary[hidden] {
  display: none;
}

.recap-actions {
  width: min(100%, 460px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.recap-hint {
  color: var(--faint);
  font-size: 0.82rem;
  text-align: center;
  margin: 0;
}

.recap-hint[hidden] {
  display: none;
}

.transcript {
  width: min(100%, 460px);
  margin: 0 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.tline {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: left;
  color: var(--text);
  border: 1px solid transparent;
}

.tline--them {
  align-self: flex-start;
  background: var(--surface);
  border-bottom-left-radius: 4px;
}

.tline--me {
  align-self: flex-end;
  background: rgba(63, 158, 224, 0.18);
  border-bottom-right-radius: 4px;
}

.tline.saved {
  border-color: var(--green);
}

.phrasebook {
  width: min(100%, 460px);
  margin: 0 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.phrase-group {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin: 10px 0 2px;
}

.phrase-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.phrase-row--recap {
  border-color: var(--accent-tint);
  background: rgba(63, 158, 224, 0.08);
}

.phrase-text {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.phrase-del {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 1.2rem;
  line-height: 1;
}

.phrase-del:active {
  background: var(--surface-hi);
  color: var(--red);
}

/* ───────────────────────── Notifications ───────────────────────── */
.notify-toggle {
  margin: 10px auto 0;
}

.notify-toggle.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.notify-toggle[hidden] {
  display: none;
}

.notify-prompt {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 9, 0.72);
  backdrop-filter: blur(6px);
}

.notify-prompt[hidden] {
  display: none;
}

.notify-card {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  text-align: center;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

.notify-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(63, 158, 224, 0.16);
  color: var(--accent-strong);
}

.notify-icon .i {
  width: 26px;
  height: 26px;
}

.notify-title {
  font-size: 1.15rem;
  font-weight: 750;
  margin: 0;
}

.notify-body {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}

.notify-card .cta-button {
  width: 100%;
}

/* iOS install: the Safari Share glyph framed like its toolbar button. */
.ios-share-demo {
  display: flex;
  justify-content: center;
  margin: 2px 0 4px;
}

.ios-share-key {
  display: grid;
  place-items: center;
  width: 54px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-hi);
  color: var(--accent-strong);
}

.ios-share-key .i {
  width: 24px;
  height: 24px;
}
