/* ============================================
   Kto-to.me — Native App UI
   ============================================ */

:root {
  color-scheme: dark;
  --bg: #07060d;
  --bg-2: #0d0b16;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.1);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.08);
  --fg: #f5f3f7;
  --fg-dim: rgba(245, 243, 247, 0.6);
  --muted: rgba(245, 243, 247, 0.4);
  --accent: #7c5cfc;
  --accent-2: #5eead4;
  --accent-glow: rgba(124, 92, 252, 0.4);
  --accent-2-glow: rgba(94, 234, 212, 0.3);
  --danger: #ff4d6d;
  --danger-glow: rgba(255, 77, 109, 0.3);
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --phone-w: 400px;
  --phone-h: 860px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.light {
  color-scheme: light;
  --bg: #f0eef5;
  --bg-2: #e8e4f0;
  --surface: rgba(0, 0, 0, 0.03);
  --surface-2: rgba(0, 0, 0, 0.05);
  --surface-3: rgba(0, 0, 0, 0.08);
  --glass: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(0, 0, 0, 0.08);
  --fg: #1a1726;
  --fg-dim: rgba(26, 23, 38, 0.6);
  --muted: rgba(26, 23, 38, 0.4);
  --accent: #6d4aff;
  --accent-2: #0d9488;
  --accent-glow: rgba(109, 74, 255, 0.25);
  --accent-2-glow: rgba(13, 148, 136, 0.2);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

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

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================
   Animated Background
   ============================================ */

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: drift 20s ease-in-out infinite;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: var(--accent);
  top: -100px;
  left: -80px;
  animation-delay: 0s;
}

.blob-2 {
  width: 350px;
  height: 350px;
  background: var(--accent-2);
  bottom: -80px;
  right: -60px;
  animation-delay: -7s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: var(--accent);
  top: 40%;
  left: 50%;
  opacity: 0.25;
  animation-delay: -14s;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.1); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ============================================
   Phone Frame
   ============================================ */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.phone {
  position: relative;
  width: var(--phone-w);
  height: var(--phone-h);
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--glass-border),
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 120px var(--accent-glow);
}

@media (max-width: 440px), (max-height: 880px) {
  .phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ============================================
   Status Bar
   ============================================ */

.site-announcement {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-2));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  flex-shrink: 0;
}

.site-announcement[hidden] {
  display: none;
}

.site-announcement p {
  flex: 1;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.site-announcement-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -4px -6px -4px 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--fg-dim);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.site-announcement-close:hover {
  color: var(--fg);
  background: var(--glass);
}

.site-announcement:not([hidden]) + .status-bar {
  padding-top: 8px;
}

.status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  padding-top: calc(8px + var(--safe-top));
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-dim);
  flex-shrink: 0;
}

.status-time {
  justify-self: start;
  font-variant-numeric: tabular-nums;
}

.status-icons {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

#onlineCount {
  color: var(--accent-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Top Nav
   ============================================ */

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
  flex-shrink: 0;
}

.brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-logo {
  display: block;
  height: 56px;
  width: auto;
}

.brand-logo-up {
  height: 56px;
}

.brand-logo-bottom {
  height: 64px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-dim);
  transition: color var(--transition);
}

.nav-links a:hover {
  color: var(--fg);
}

.theme-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--fg-dim);
  transition: all var(--transition);
}

.theme-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
  transform: scale(1.05);
}

.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: block; }
body.light .theme-btn .icon-sun { display: block; }
body.light .theme-btn .icon-moon { display: none; }

/* ============================================
   Views Container
   ============================================ */

.views {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.view::-webkit-scrollbar { display: none; }

.view.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ============================================
   Home / Setup
   ============================================ */

.home-hero {
  padding: 20px 24px 8px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 20px;
}

.live-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
  animation: blink 1.5s ease-in-out infinite;
}

.hero-title {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

.hero-sub {
  font-size: 14px;
  color: var(--fg-dim);
  line-height: 1.5;
}

/* Filter sheet */
.filter-sheet {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}

.chat-ad-label {
  position: sticky;
  z-index: 3;
  top: 0;
  display: block;
  padding: 5px 10px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.side-ad-slot [id^="yandex_rtb_"] {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.side-ad-slot iframe {
  max-width: 100% !important;
}

.side-ad-slot {
  position: fixed;
  z-index: 2;
  top: 50%;
  left: calc(50% + 240px);
  display: none;
  width: 320px;
  height: min(600px, calc(100vh - 40px));
  min-height: 250px;
  overflow: hidden;
  transform: translateY(-50%);
  contain: strict;
  isolation: isolate;
  clip-path: inset(0 round 14px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--bg-2);
  opacity: 0;
  transition: opacity 180ms ease;
}

@media (min-width: 1280px) {
  .side-ad-slot:not([hidden]) {
    display: block;
  }

  .side-ad-slot[data-rendered="true"] {
    opacity: 1;
  }
}

/* Keep the single RTB unit beside the expanded call UI on wide desktops. */
@media (min-width: 1440px) {
  body[data-layout="desktop-call"] .phone {
    transform: translateX(-180px);
  }

  body[data-layout="desktop-call"] .side-ad-slot {
    left: calc(50% + 360px);
  }
}

.filter-group {
  margin-bottom: 4px;
}

.filter-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.filter-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 16px 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  padding: 8px 16px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-dim);
  transition: all var(--transition);
  white-space: nowrap;
}

.chip:hover {
  background: var(--surface-2);
  color: var(--fg);
  transform: translateY(-1px);
}

.chip:active {
  transform: scale(0.95);
}

.chip.selected {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.chip-row.is-disabled .chip {
  opacity: 0.35;
  pointer-events: none;
}

/* CTA bar */
.cta-bar {
  padding: 12px 20px calc(16px + var(--safe-bottom));
  flex-shrink: 0;
}

.cta-hint {
  font-size: 12px;
  color: var(--fg-dim);
  text-align: center;
  margin-bottom: 10px;
  min-height: 16px;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 24px var(--accent-glow);
  transition: all var(--bounce);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--fg-dim);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.btn-ghost:active {
  transform: scale(0.97);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), color-mix(in srgb, var(--danger) 70%, #c4002a));
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px var(--danger-glow);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-text {
  font-size: 12px;
  color: var(--danger);
  text-align: center;
  min-height: 16px;
  margin-top: 8px;
}

/* ============================================
   Search Screen
   ============================================ */

.search-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 16px;
}

.radar {
  position: relative;
  width: 180px;
  height: 180px;
  margin-bottom: 8px;
}

.radar-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent-2);
  border-radius: 50%;
  opacity: 0;
  animation: radar-pulse 2s ease-out infinite;
}

.radar-ring.r1 { animation-delay: 0s; }
.radar-ring.r2 { animation-delay: 0.6s; }
.radar-ring.r3 { animation-delay: 1.2s; }

@keyframes radar-pulse {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}

.radar-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-2-glow);
  animation: core-pulse 1.5s ease-in-out infinite;
}

@keyframes core-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.radar-sweep {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2));
  transform-origin: left center;
  animation: sweep 2s linear infinite;
  border-radius: 2px;
}

@keyframes sweep {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.state-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}

.state-timer {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.search-summary {
  font-size: 12px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.4;
}

/* ============================================
   Call Screen
   ============================================ */

.call-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.call-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.conn-quality {
  display: flex;
  gap: 3px;
  align-items: flex-end;
}

.qdot {
  width: 4px;
  border-radius: 2px;
  background: var(--muted);
  transition: all var(--transition);
}

.qdot:nth-child(1) { height: 6px; }
.qdot:nth-child(2) { height: 9px; }
.qdot:nth-child(3) { height: 12px; }

.qdot.active {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.qdot.warn { background: var(--warn); }
.qdot.bad { background: var(--danger); }

.call-timer {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(5, 7, 11, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.call-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 12px;
  position: relative;
  z-index: 1;
}

/* Avatar orb */
.avatar-orb {
  position: relative;
  width: 160px;
  height: 160px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.avatar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: avatar-ring 3s ease-out infinite;
}

.avatar-ring.a1 { inset: 0; animation-delay: 0s; }
.avatar-ring.a2 { inset: 0; animation-delay: 1s; }
.avatar-ring.a3 { inset: 0; animation-delay: 2s; }

@keyframes avatar-ring {
  0% { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 0; }
}

.avatar-core {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--glass-border);
  display: grid;
  place-items: center;
  color: var(--accent);
  box-shadow: 0 0 40px var(--accent-glow);
  transition: all var(--transition);
}

.avatar-orb.speaking .avatar-core {
  box-shadow: 0 0 60px var(--accent-glow), 0 0 80px var(--accent-2-glow);
  transform: scale(1.05);
}

.wave-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent-2);
  opacity: 0;
  transition: opacity 200ms;
}

.avatar-orb.speaking .wave-ring {
  opacity: 0.4;
  animation: wave-expand 600ms ease-out infinite;
}

@keyframes wave-expand {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.3); opacity: 0; }
}

.peer-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
}

.call-status {
  font-size: 13px;
  color: var(--fg-dim);
  font-weight: 500;
}

/* Video container */
.video-container {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  background: #000;
}

.video-container.active {
  display: block;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#remoteVideo {
  display: block;
}

.local-preview {
  position: absolute;
  left: 20px;
  bottom: calc(112px + var(--safe-bottom));
  width: 100px;
  height: 140px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--glass-border);
  background: #05070b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  overflow: hidden;
  z-index: 5;
  display: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.local-preview.visible {
  display: block;
}

.local-preview.dragging {
  transition: none;
  cursor: grabbing;
  border-color: color-mix(in srgb, var(--accent) 70%, var(--glass-border));
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.44), 0 0 0 1px var(--accent-glow);
}

.local-preview.positioned:not(.dragging) {
  transition: left 180ms ease-out, top 180ms ease-out;
}

.video-offer-preview {
  width: min(100%, 360px);
  aspect-ratio: 16 / 10;
  margin: 0 auto 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: #05070b;
  overflow: hidden;
  display: none;
}

.video-offer-preview.visible {
  display: block;
}

#localVideo,
#videoOfferVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#localVideo.visible,
#videoOfferVideo.visible { display: block; }

.local-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  color: var(--fg-dim);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
}

.local-video-placeholder[hidden] {
  display: none;
}

.video-container.active #remoteVideo { display: block; }

/* Call actions */
.call-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px calc(20px + var(--safe-bottom));
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}

.call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--fg);
  transition: all var(--bounce);
}

.call-btn svg {
  display: block;
  flex-shrink: 0;
}

.call-btn:hover {
  background: var(--surface-2);
  transform: translateY(-2px);
}

.call-btn:active {
  transform: scale(0.92);
}

.call-btn-label {
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  color: var(--fg-dim);
}

.call-btn .ic-mic-off { display: none; }
.call-btn.muted .ic-mic { display: none; }
.call-btn.muted .ic-mic-off { display: block; }
.call-btn.muted {
  background: var(--danger-glow);
  border-color: var(--danger);
  color: var(--danger);
}

.call-btn.video-active,
.call-btn.video-active:hover {
  background: var(--danger-glow);
  border-color: var(--danger);
  color: var(--danger);
}

.call-btn.video-active .call-btn-label {
  color: var(--danger);
}

.call-btn.video-active:focus-visible {
  outline-color: var(--danger);
}

.call-btn.video-pending {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.call-btn.video-pending .call-btn-label {
  color: var(--accent);
}

.call-btn.locked {
  opacity: 0.5;
  position: relative;
}

.lock-badge {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 6px;
  line-height: 1;
  white-space: nowrap;
}

.call-btn.locked .lock-badge {
  display: block;
}

.call-btn.locked:hover {
  transform: none;
  background: var(--surface-2);
}

.call-hint {
  display: none;
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--fg-dim);
  font-size: 13px;
  text-align: center;
  animation: hintFade 0.3s ease;
}

.call-hint.show {
  display: inline-block;
}

@keyframes hintFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.call-btn-warn {
  color: var(--warn);
}

.call-btn-end {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 20px var(--danger-glow);
}

.call-btn-end:hover {
  background: color-mix(in srgb, var(--danger) 85%, #fff);
}

.call-btn-end:active {
  transform: scale(0.92) rotate(135deg);
}

/* ============================================
   Post-Call Screen
   ============================================ */

.post-call-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 12px;
}

.post-call-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  margin-bottom: 8px;
  animation: pop-in var(--bounce);
}

@keyframes pop-in {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.post-call-sub {
  font-size: 14px;
  color: var(--fg-dim);
  margin-bottom: 20px;
}

.post-call-actions {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================
   Doc Pages
   ============================================ */

.doc {
  padding: 20px 24px;
}

.back-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 20px;
  transition: opacity var(--transition);
}

.back-btn:hover { opacity: 0.7; }
.back-btn:active { transform: scale(0.95); }

.doc-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.doc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-list li {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-dim);
}

.doc-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-dim);
  margin-bottom: 12px;
}

.doc-subtitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-top: 20px;
  margin-bottom: 8px;
}

/* ============================================
   Dock
   ============================================ */

.dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px calc(10px + var(--safe-bottom));
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
  border-top: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.dock-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

/* State-specific dock colors */
.app[data-state="searching"] .dock-pulse {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: blink 1s ease-in-out infinite;
}

.app[data-state="call"] .dock-pulse {
  background: var(--accent-2);
  box-shadow: 0 0 6px var(--accent-2);
}

.app[data-state="postCall"] .dock-pulse {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}

.dock-tg-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  color: #a887ff;
  background: rgba(138, 99, 255, 0.08);
  border: 1px solid rgba(138, 99, 255, 0.2);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}

.dock-tg-btn:hover {
  background: rgba(138, 99, 255, 0.15);
  border-color: rgba(138, 99, 255, 0.4);
}

.dock-tg-btn svg {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .dock-tg-btn {
    padding: 4px 10px;
    font-size: 10px;
    gap: 5px;
  }

  .dock-tg-btn svg {
    width: 12px;
    height: 12px;
  }
}

/* ============================================
   Bottom Sheet Modals
   ============================================ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 200ms ease;
}

.sheet[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-card {
  width: var(--phone-w);
  max-width: 100vw;
  padding: 24px 20px calc(28px + var(--safe-bottom));
  background: var(--bg-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.4);
  animation: slide-up var(--bounce);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  margin: 0 auto 16px;
}

.sheet-card h2 {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reason-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.reason-grid button {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-dim);
  transition: all var(--transition);
}

.reason-grid button:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.reason-grid button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.reason-grid button:disabled:hover {
  background: var(--surface);
  color: var(--fg-dim);
}

.reason-grid button.selected {
  background: var(--danger-glow);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 380px) {
  .status-text { display: none; }
  .hero-title { font-size: 28px; }
  .call-btn { width: 64px; height: 64px; }
  .call-btn svg { width: 20px; height: 20px; }
  .local-preview {
    left: 18px;
    bottom: calc(100px + var(--safe-bottom));
    width: 88px;
    height: 124px;
  }
}

@media (max-height: 700px) {
  .home-hero { padding: 12px 24px 4px; }
  .hero-title { font-size: 26px; }
  .hero-badge { margin-bottom: 12px; }
  .avatar-orb { width: 130px; height: 130px; }
  .avatar-core { width: 80px; height: 80px; }
  .radar { width: 140px; height: 140px; }
  .local-preview {
    bottom: calc(96px + var(--safe-bottom));
    width: 88px;
    height: 124px;
  }
}

/* ============================================
   Call Overlay (fullscreen, outside .phone)
   ============================================ */

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 400ms;
}

.call-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
}

.call-overlay-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
  opacity: 0;
  transform: scale(1.02);
  filter: blur(12px);
  transition: opacity 500ms ease, transform 500ms cubic-bezier(0.22, 1, 0.36, 1), filter 500ms ease;
}

.call-overlay-video.active {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.call-overlay-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-overlay-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 30%, var(--accent-glow), transparent 60%),
    var(--bg-2);
}

.call-overlay-ui {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  flex: 1;
  pointer-events: none;
}

.call-overlay.active .call-overlay-ui > * {
  pointer-events: auto;
}

.call-overlay-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  flex-shrink: 0;
}

.call-overlay-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.call-overlay-video.active ~ .call-overlay-ui .call-overlay-stage {
  background: transparent;
}

.call-overlay-local {
  position: absolute;
  right: 20px;
  top: calc(60px + var(--safe-top));
  width: 120px;
  height: 170px;
  border-radius: var(--radius);
  border: 2px solid var(--glass-border);
  background: #05070b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 15;
  display: none;
  transition: all var(--bounce);
}

.call-overlay-local.visible {
  display: block;
}

.call-overlay-local video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.call-overlay-local video.visible {
  display: block;
}

.call-overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px calc(24px + var(--safe-bottom));
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

/* Connecting state: hide controls, show only avatar + status */
.call-overlay.connecting .call-overlay-actions {
  opacity: 0.3;
  pointer-events: none;
}

.call-overlay.connecting .call-overlay-header {
  opacity: 0.5;
}

/* Phone morph for call-active state */
.app.call-active .phone {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.app.call-active .bg-mesh {
  opacity: 0;
  transition: opacity 300ms ease;
}

/* ============================================
   Desktop Call Overlay (≥900px)
   ============================================ */

@media (min-width: 900px) {
  .call-overlay-local {
    width: 180px;
    height: 240px;
    right: 32px;
    top: calc(80px + var(--safe-top));
    border-radius: var(--radius-lg);
  }

  .call-overlay-actions {
    gap: 16px;
    padding: 24px 20px calc(32px + var(--safe-bottom));
  }

  .call-overlay-actions .call-btn {
    width: 80px;
    height: 80px;
  }

  .call-overlay-actions .call-btn svg {
    width: 28px;
    height: 28px;
  }

  .call-overlay-stage .avatar-orb {
    width: 200px;
    height: 200px;
  }

  .call-overlay-stage .avatar-core {
    width: 120px;
    height: 120px;
  }

  .call-overlay-stage .peer-label {
    font-size: 22px;
  }

  .call-overlay-stage .call-status {
    font-size: 15px;
  }

  .call-overlay-header .call-timer {
    font-size: 16px;
  }
}

/* ============================================
   Desktop Modal Fix
   ============================================ */

@media (min-width: 900px) {
  .sheet {
    align-items: center;
  }

  .sheet-card {
    width: 480px;
    max-width: 90vw;
    border-radius: var(--radius-lg);
    padding: 32px 28px calc(32px + var(--safe-bottom));
  }

  @keyframes slide-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}

/* ============================================
   Desktop Tablet Call Mode
   ============================================ */

/* Background ambience intensifies during desktop calls */
.bg-mesh {
  transition: filter 600ms ease, transform 600ms ease;
}

body[data-layout="desktop-call"] .bg-mesh {
  filter: blur(24px) brightness(0.55);
  transform: scale(1.08);
}

/* Phone morphs into a tablet-like device frame on desktop calls */
@media (min-width: 900px) {
  body[data-layout="desktop-call"] .phone {
    width: min(1000px, 95vw);
    height: min(680px, 90vh);
    border-radius: 32px;
    box-shadow:
      0 0 0 1px var(--glass-border),
      0 40px 100px rgba(0, 0, 0, 0.55),
      0 0 160px var(--accent-glow);
  }

  /* Tablet layout for the call screen: remote video + floating local preview.
     The right column is auto-sized, so it collapses to 0 when .local-preview is hidden. */
  body[data-layout="desktop-call"] #call .call-screen {
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "header header"
      "stage local"
      "actions actions";
    height: 100%;
  }

  body[data-layout="desktop-call"] #call .call-header {
    grid-area: header;
  }

  body[data-layout="desktop-call"] #call .call-stage {
    grid-area: stage;
  }

  body[data-layout="desktop-call"] #call .video-container {
    grid-area: stage;
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
  }

  body[data-layout="desktop-call"] #call #remoteVideo {
    object-fit: contain;
  }

  body[data-layout="desktop-call"] #call .video-container:not(.active) {
    display: none;
  }

  body[data-layout="desktop-call"] #call .local-preview {
    grid-area: local;
    position: relative;
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    width: 280px;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin: 0;
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 400ms ease, transform 400ms ease;
    touch-action: auto;
    cursor: default;
  }

  body[data-layout="desktop-call"] #call .local-preview.visible {
    opacity: 1;
    transform: translateX(0);
  }

  /* Glassmorphism bottom controls */
  body[data-layout="desktop-call"] #call .call-actions {
    grid-area: actions;
    gap: 16px;
    padding: 16px 24px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    border-radius: 0;
  }
}

/* ============================================
   Phone Morph Transition
   ============================================ */

.phone {
  transition:
    width 600ms cubic-bezier(0.22, 1, 0.36, 1),
    height 600ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 600ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 600ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 600ms ease,
    opacity 300ms ease;
}

/* ============================================
   Utility
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  animation: hintFade 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 360px;
  width: calc(100% - 48px);
  text-align: center;
}

.modal-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 14px;
  color: var(--fg-dim);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .btn-primary,
.modal-actions .btn-ghost {
  width: 100%;
  justify-content: center;
}

/* ============================================
   Support Button & Modal
   ============================================ */

/* Support button in the center of the status bar */
.status-support-btn {
  width: clamp(156px, 44vw, 190px);
  min-height: 36px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 12px;
  background: rgba(124, 92, 252, 0.08);
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(124, 92, 252, 0.3);
  color: var(--accent);
  transition: all var(--transition);
}

.status-support-btn:hover {
  background: rgba(124, 92, 252, 0.15);
  border-color: rgba(124, 92, 252, 0.5);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(124, 92, 252, 0.2);
}

/* Support modal (uses .sheet from existing styles) */
.support-card {
  position: relative;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.support-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--fg-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.support-close:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.support-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(124, 92, 252, 0.15), rgba(94, 234, 212, 0.15));
  border: 1px solid rgba(124, 92, 252, 0.3);
  color: var(--accent);
}

.support-text {
  font-size: 16px;
  color: var(--fg-dim);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 20px;
}

.support-recipient {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.4;
}

.support-recipient-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.support-recipient strong {
  color: var(--fg);
  font-size: 15px;
}

.support-recipient a {
  width: fit-content;
  margin-top: 3px;
  color: var(--accent-2);
  font-weight: 600;
  text-decoration: none;
}

.support-recipient a:hover {
  text-decoration: underline;
}

.support-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.support-amount {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.support-amount:hover {
  background: var(--surface-2);
  border-color: rgba(124, 92, 252, 0.4);
}

.support-amount.selected {
  background: linear-gradient(135deg, rgba(124, 92, 252, 0.2), rgba(94, 234, 212, 0.15));
  border-color: var(--accent);
  color: var(--fg);
  box-shadow: 0 0 12px rgba(124, 92, 252, 0.25);
}

.support-amount-custom {
  grid-column: span 3;
  font-size: 14px;
  color: var(--fg-dim);
}

.support-custom-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--glass-border);
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 16px;
}

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

.support-submit {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.support-submit:hover {
  box-shadow: 0 0 20px rgba(124, 92, 252, 0.4);
  transform: translateY(-1px);
}

.support-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}

/* ============================================
   Turnstile verification overlay
   ============================================ */
.turnstile-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 16, 0.95);
  backdrop-filter: blur(12px);
}

.turnstile-overlay[hidden] {
  display: none;
}

.turnstile-card {
  background: var(--card, #13131a);
  border: 1px solid var(--border, #222230);
  border-radius: 20px;
  padding: 40px 32px;
  width: 360px;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.turnstile-icon {
  color: var(--accent, #6366f1);
  margin-bottom: 20px;
}

.turnstile-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.turnstile-card p {
  font-size: 14px;
  color: var(--muted, #71717a);
  margin-bottom: 24px;
}

#turnstileWidget {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.turnstile-card .error-text {
  margin-top: 16px;
  font-size: 13px;
  color: var(--danger, #ef4444);
}
