/* ============================================================
   PaperPhone — Premium Design System v2
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Brand */
  --green:        #07C160;
  --green-d:      #05A050;
  --green-l:      #34D576;
  --green-glow:   rgba(7, 193, 96, 0.35);

  /* Backgrounds */
  --bg:           #F2F2F7;
  --surface:      #FFFFFF;
  --surface-2:    #F8F8FA;
  --topbar-bg:    rgba(255,255,255,0.82);
  --tab-bg:       rgba(255,255,255,0.88);

  /* Text */
  --text:         #0D0D0D;
  --text-2:       #48484A;
  --text-muted:   #8E8E93;

  /* UI */
  --border:       rgba(0,0,0,0.08);
  --divider:      rgba(0,0,0,0.06);
  --red:          #FF3B30;
  --blue:         #007AFF;
  --purple:       #AF52DE;
  --orange:       #FF9500;

  /* Chat bubbles */
  --bubble-out:   #07C160;
  --bubble-out-text: #FFFFFF;
  --bubble-in:    #FFFFFF;
  --bubble-in-text: #0D0D0D;

  /* Shadows */
  --shadow-sm:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);

  /* Shape */
  --radius:       14px;
  --radius-sm:    10px;
  --radius-xs:    6px;

  /* Safe area */
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --topbar-h:     calc(54px + var(--safe-top));
  --tab-h:        calc(60px + var(--safe-bottom));

  font-size: 16px;
}

/* ── Dark Mode ─────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #000000;
    --surface:      #1C1C1E;
    --surface-2:    #2C2C2E;
    --topbar-bg:    rgba(28,28,30,0.88);
    --tab-bg:       rgba(28,28,30,0.92);
    --text:         #F2F2F7;
    --text-2:       #AEAEB2;
    --text-muted:   #636366;
    --border:       rgba(255,255,255,0.07);
    --divider:      rgba(255,255,255,0.05);
    --bubble-out:   #07C160;
    --bubble-out-text: #FFFFFF;
    --bubble-in:    #2C2C2E;
    --bubble-in-text: #F2F2F7;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
    --shadow:       0 4px 20px rgba(0,0,0,.5);
    --shadow-lg:    0 16px 50px rgba(0,0,0,.7);
  }
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont,
    'PingFang SC', 'Noto Sans CJK SC', 'Noto Sans KR', 'Noto Sans JP',
    'Helvetica Neue', sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Top Bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--topbar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  align-items: center;
  padding: var(--safe-top) 12px 0;
  height: var(--topbar-h);
  border-bottom: .5px solid var(--border);
}
.topbar-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  color: var(--green);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-xs);
  transition: background .15s, color .15s;
}
.topbar-btn:active { background: var(--border); }
.topbar-back { justify-content: flex-start; }
.topbar-action { justify-content: flex-end; }

/* ── Tab Bar ───────────────────────────────────────────────── */
.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: var(--tab-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  border-top: .5px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: var(--tab-h);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  transition: color .2s;
  position: relative;
}
.tab-item.active { color: var(--green); }
.tab-item svg { width: 24px; height: 24px; fill: currentColor; transition: transform .2s; }
.tab-item.active svg { transform: scale(1.08); }
.tab-label { font-size: 10px; font-weight: 500; }
.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid var(--tab-bg);
}
.tab-icon { position: relative; }

/* ── Page Shell ────────────────────────────────────────────── */
.page {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
.page::-webkit-scrollbar { display: none; }

/* ── List Items ────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  cursor: pointer;
  gap: 12px;
  transition: background .12s;
  position: relative;
}
.list-item:active { background: var(--surface-2); }
.list-item + .list-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 72px;
  right: 0;
  height: .5px;
  background: var(--divider);
}

/* ── Avatar ────────────────────────────────────────────────── */
.avatar {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.5px;
}
.avatar-sm { width: 38px; height: 38px; font-size: 14px; border-radius: 9px; }
.avatar-lg { width: 70px; height: 70px; font-size: 26px; border-radius: 16px; box-shadow: var(--shadow); }

/* Online dot */
.avatar-wrap { position: relative; display: inline-block; }
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ── Search Bar ────────────────────────────────────────────── */
.search-wrap {
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: .5px solid var(--border);
}
.search-input {
  width: 100%;
  padding: 9px 16px 9px 36px;
  background: var(--surface);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-sm);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%238E8E93'%3E%3Cpath d='M21 21l-4.35-4.35M17 11A6 6 0 1 1 5 11a6 6 0 0 1 12 0z' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: box-shadow .2s;
}
.search-input:focus { box-shadow: 0 0 0 3px var(--green-glow), var(--shadow-sm); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Section Header ────────────────────────────────────────── */
.section-header {
  padding: 20px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--bg);
}

/* ── Settings / Card Group ─────────────────────────────────── */
.card-group {
  background: var(--surface);
  border-radius: var(--radius);
  margin: 0 16px 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-group + .card-group { margin-top: 0; }
.settings-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  gap: 14px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.settings-item:active { background: var(--surface-2); }
.settings-item + .settings-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 56px;
  right: 0;
  height: .5px;
  background: var(--divider);
}
.settings-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.settings-label { flex: 1; font-size: 16px; font-weight: 400; }
.settings-value { font-size: 14px; color: var(--text-muted); }
.settings-chevron {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  margin-left: 4px;
}

/* ── Chat List Page ────────────────────────────────────────── */
.chat-meta { flex: 1; min-width: 0; }
.chat-name-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.chat-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; margin-left: 6px; }
.chat-preview-row { display: flex; justify-content: space-between; align-items: center; }
.chat-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
  margin-left: 6px;
}

/* ── Chat Window ───────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.chat-messages::-webkit-scrollbar { display: none; }

.msg-row {
  display: flex;
  align-items: flex-end;
  padding: 3px 14px;
  gap: 8px;
  animation: msgIn .18s cubic-bezier(.2,.8,.4,1);
}
.msg-row.out { flex-direction: row-reverse; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble {
  max-width: min(72vw, 340px);
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.msg-row.in  .bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-radius: 4px 20px 20px 20px;
  box-shadow: var(--shadow-sm);
}
.msg-row.out .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-radius: 20px 4px 20px 20px;
}

.bubble-image {
  max-width: 220px;
  max-height: 280px;
  border-radius: 14px;
  display: block;
  cursor: zoom-in;
  object-fit: cover;
}
.bubble-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 90px;
}
.voice-play-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}
.voice-dur { font-size: 13px; opacity: .8; }

.msg-time-sep {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
  font-weight: 500;
}

/* ── Input Toolbar ─────────────────────────────────────────── */
.input-toolbar {
  background: var(--surface);
  border-top: .5px solid var(--border);
  padding: 8px 10px;
  padding-bottom: max(8px, var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.input-toolbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  color: var(--text-muted);
  font-size: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  transition: color .15s, background .15s;
}
.input-toolbar-btn:active { background: var(--surface-2); color: var(--green); }
#chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 130px;
  padding: 9px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color .2s;
}
#chat-input:focus { border-color: var(--green); }
#chat-input::placeholder { color: var(--text-muted); }
.send-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--green-glow);
  transition: background .15s, transform .12s, box-shadow .15s;
}
.send-btn:active { background: var(--green-d); transform: scale(.9); }

/* ── Typing Indicator ──────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 22px;
  min-height: 28px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dot-bounce 1.3s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Voice Overlay ─────────────────────────────────────────── */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  gap: 20px;
}
.voice-pulse {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  box-shadow: 0 0 0 0 var(--green-glow);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--green-glow); }
  70%  { box-shadow: 0 0 0 20px rgba(7,193,96,0); }
  100% { box-shadow: 0 0 0 0 rgba(7,193,96,0); }
}
.voice-overlay p { color: rgba(255,255,255,.85); font-size: 15px; font-weight: 500; }

/* ── Image Viewer ──────────────────────────────────────────── */
.img-viewer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.img-viewer img { max-width: 100%; max-height: 100dvh; object-fit: contain; }
.img-viewer-close {
  position: absolute;
  top: max(20px, calc(var(--safe-top) + 10px));
  right: 20px;
  color: rgba(255,255,255,.9);
  font-size: 30px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.4);
  border-radius: 50%;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: max(calc(var(--tab-h) + 16px), 96px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,20,.88);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  backdrop-filter: blur(8px);
  white-space: nowrap;
  animation: toastIn .22s cubic-bezier(.2,.8,.4,1);
  box-shadow: var(--shadow);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Auth Screen ───────────────────────────────────────────── */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 48px 24px max(32px, var(--safe-bottom));
  position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(7,193,96,.18) 0%, transparent 60%),
    var(--bg);
  gap: 0;
}
.auth-logo-wrap {
  width: 96px;
  height: 96px;
  border-radius: 26px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px var(--green-glow), 0 2px 8px rgba(0,0,0,.1);
  margin-bottom: 20px;
  animation: authPop .5s cubic-bezier(.2,1.6,.4,1);
}
.auth-logo-wrap img, .auth-logo-wrap span { width: 56px; height: 56px; font-size: 52px; }
@keyframes authPop {
  from { transform: scale(.5) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.auth-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 8px;
  animation: authFade .4s .1s both;
}
.auth-tagline {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 36px;
  animation: authFade .4s .15s both;
}
@keyframes authFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: authFade .4s .2s both;
}
.auth-field {
  position: relative;
}
.auth-input {
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--shadow-sm);
}
.auth-input::placeholder { color: var(--text-muted); }
.auth-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow), var(--shadow-sm);
}
.auth-btn {
  margin-top: 6px;
  padding: 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--green);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--green-glow);
  transition: background .2s, transform .12s, box-shadow .2s;
}
.auth-btn:hover { background: var(--green-l); }
.auth-btn:active { transform: scale(.97); box-shadow: 0 2px 8px var(--green-glow); }
.auth-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.auth-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  min-height: 16px;
  font-weight: 500;
  animation: authFade .2s;
}
.auth-toggle {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  animation: authFade .4s .25s both;
}
.auth-toggle span { color: var(--green); font-weight: 500; }
.auth-notice {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: .7;
  text-align: center;
}

/* ── Profile Page ──────────────────────────────────────────── */
.profile-hero {
  padding: 24px 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  margin-bottom: 8px;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-username { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.profile-enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 10px;
  background: rgba(7,193,96,.12);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.2px;
}
.profile-arrow { color: var(--text-muted); font-size: 20px; }

/* ── Discover Page ─────────────────────────────────────────── */
.discover-group {
  background: var(--surface);
  border-radius: var(--radius);
  margin: 0 16px 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.discover-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.discover-item:active { background: var(--surface-2); }
.discover-item + .discover-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 62px;
  right: 0;
  height: .5px;
  background: var(--divider);
}
.discover-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.discover-label { flex: 1; font-size: 16px; font-weight: 400; }
.discover-chevron { color: var(--text-muted); font-size: 16px; }

/* ── Language Picker ───────────────────────────────────────── */
.lang-picker {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
}
.lang-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
}
.lang-picker-sheet {
  position: relative;
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding-bottom: max(16px, var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: slideUp .28s cubic-bezier(.2,.9,.4,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.lang-picker-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 16px;
}
.lang-picker-title {
  padding: 0 20px 12px;
  font-size: 17px;
  font-weight: 600;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background .12s;
}
.lang-option:active { background: var(--surface-2); }
.lang-option.selected { color: var(--green); }
.lang-flag { font-size: 24px; }
.lang-name { flex: 1; font-size: 16px; font-weight: 400; }
.lang-check { color: var(--green); font-size: 18px; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  gap: 10px;
  text-align: center;
}
.empty-icon { font-size: 52px; margin-bottom: 4px; opacity: .6; }
.empty-title { font-size: 17px; font-weight: 600; }
.empty-hint { font-size: 14px; color: var(--text-muted); }

/* ── Skeleton ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Btn pill ──────────────────────────────────────────────── */
.btn-pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.btn-pill:active { transform: scale(.95); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 2px 8px var(--green-glow); }
.btn-outline { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); }

.flex-1   { flex: 1; min-width: 0; }
.hidden   { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }

/* ── Bubble Timestamp ──────────────────────────────────────── */
.bubble-ts {
  font-size: 10px;
  color: var(--text-muted);
  margin: 1px 14px 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}
.bubble-ts-out {
  justify-content: flex-end;
}
.msg-row.in  .bubble-ts { justify-content: flex-start; padding-left: 48px; }
.msg-row.out .bubble-ts { justify-content: flex-end; }

/* ── Message Status (✓ sent, ✓✓ delivered) ─────────────────── */
.msg-status {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  transition: color .3s;
}
.msg-status-sent      { color: var(--text-muted); }
.msg-status-delivered { color: var(--green); }

/* ── Tab Badge (contacts red dot) ──────────────────────────── */
.tab-badge-sm {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--tab-bg);
}

/* ══════════════════════════════════════════════════════════════
   Call UI
   ══════════════════════════════════════════════════════════════ */

/* Overlay root */
#pp-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
}

/* ── Base screen ──────────────────────────────────────────── */
.call-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  user-select: none;
}

.call-screen.call-minimized {
  height: auto;
  bottom: 0;
  top: auto;
  border-radius: 16px 16px 0 0;
  position: fixed;
  width: 100%;
}

/* ── Calling / Incoming backgrounds ──────────────────────── */
.call-incoming,
.call-calling {
  background: linear-gradient(160deg, #0d0f1a 0%, #0a2a1f 55%, #07C160 150%);
}
.call-bg-blur {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% 30%, rgba(7,193,96,.25), transparent);
  pointer-events: none;
}

.call-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding-top: max(80px, calc(var(--safe-top) + 60px));
  gap: 8px;
}

/* ── Avatar ───────────────────────────────────────────────── */
.call-avatar-wrap { display: flex; align-items: center; justify-content: center; }
.avatar-call {
  width: 100px; height: 100px; border-radius: 50%;
  font-size: 40px; font-weight: 700;
  box-shadow: 0 0 0 8px rgba(255,255,255,.15), 0 0 40px rgba(7,193,96,.4);
  animation: callAvatarPulse 2s ease-in-out infinite;
}
.avatar-call-lg {
  width: 130px; height: 130px; border-radius: 50%;
  font-size: 52px; font-weight: 700;
  box-shadow: 0 0 0 10px rgba(255,255,255,.1);
}
@keyframes callAvatarPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(255,255,255,.15), 0 0 40px rgba(7,193,96,.4); }
  50%       { box-shadow: 0 0 0 16px rgba(255,255,255,.07), 0 0 60px rgba(7,193,96,.6); }
}

.call-name     { font-size: 26px; font-weight: 700; letter-spacing: -.5px; margin-top: 16px; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.call-subtitle { font-size: 14px; opacity: .75; margin-top: 4px; }
.call-pulse    { animation: subtitlePulse 1.4s ease-in-out infinite; }
@keyframes subtitlePulse {
  0%,100% { opacity: .5; } 50% { opacity: 1; }
}

/* ── Incoming buttons ─────────────────────────────────────── */
.call-actions-incoming {
  position: absolute;
  bottom: max(60px, calc(var(--safe-bottom) + 40px));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 28px;
}
.call-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
}
.call-action-btn > svg,
.call-action-btn > span:first-child { /* icon */
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.call-reject  > svg { background: var(--red);  box-shadow: 0 4px 20px rgba(255,59,48,.5); }
.call-accept  > svg { background: var(--green); box-shadow: 0 4px 20px rgba(7,193,96,.5);  }
.call-accept-voice > svg { background: #636366; }

.call-action-btn:active > svg { transform: scale(.92); }

/* ── Active call — video ──────────────────────────────────── */
.call-active {
  background: #000;
}

/* Remote video grid */
.call-remote-grid {
  flex: 1;
  display: grid;
  background: #1a1a1a;
  overflow: hidden;
}
.call-remote-grid[data-count="0"] { background: #000; }
.call-remote-grid[data-count="1"] { grid-template-columns: 1fr; }
.call-remote-grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
.call-remote-grid[data-count="3"],
.call-remote-grid[data-count="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.call-remote-grid[data-count="5"],
.call-remote-grid[data-count="6"] { grid-template-columns: 1fr 1fr 1fr; }

.call-remote-slot { position: relative; overflow: hidden; background: #222; }
.call-remote-video { width:100%; height:100%; object-fit:cover; display:block; }

/* Local PiP */
.call-pip-wrap {
  position: absolute;
  right: 14px;
  bottom: calc(var(--safe-bottom) + 130px);
  width: 100px;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
  z-index: 10;
  border: 2px solid rgba(255,255,255,.2);
}
.call-pip-video { width:100%; height:100%; object-fit:cover; display:block; }
.call-pip-switch {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(0,0,0,.5); border: none; border-radius: 50%;
  width: 26px; height: 26px; font-size: 13px;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Voice-only mode */
.call-voice-only .call-remote-grid { background: linear-gradient(160deg, #0d0f1a, #0a2a1f); }
.call-voice-avatar {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}

/* ── Topbar (in-call) ─────────────────────────────────────── */
.call-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: max(16px, calc(var(--safe-top) + 8px)) 12px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
  z-index: 5;
}
.call-topbar-back {
  background: none; border: none; color: rgba(255,255,255,.8);
  font-size: 22px; cursor: pointer; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content:center;
  border-radius: 50%;
  transform: rotate(-90deg);
}
.call-topbar-name  { font-size: 16px; font-weight: 600; }
.call-topbar-timer { font-size: 13px; opacity: .7; }

/* ── Controls bar ─────────────────────────────────────────── */
.call-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px 24px max(28px, calc(var(--safe-bottom) + 16px));
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 100%);
  z-index: 5;
}
.call-ctrl-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; color: #fff; font-family: inherit;
  transition: transform .12s;
}
.call-ctrl-btn:active { transform: scale(.88); }
.ctrl-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  transition: background .15s;
}
.call-ctrl-btn.ctrl-active .ctrl-icon { background: rgba(255,255,255,.35); }
.ctrl-label { font-size: 11px; font-weight: 500; opacity: .85; }
.call-ctrl-end .ctrl-icon { background: var(--red); box-shadow: 0 3px 12px rgba(255,59,48,.45); }

/* ── Chat topbar call buttons ─────────────────────────────── */
.topbar-call-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
