/* ==========================================================================
   CamTok — Level page + Paid Call UI styles. Loaded only where needed
   (level.html always; call.js injects a <link> to it on the messages page).
   Uses the shared design tokens from style.css. Responsive: phone / tablet / PC.
   ========================================================================== */

/* ---- Level badge gradients by tier (shared) ---------------------------- */
.lv-badge-big, .lv-lad-badge, .ct-lvl-badge {
  --g1: #9aa0ac; --g2: #6b7280;
}
[data-l="0"] { --g1:#b7bcc6; --g2:#8b93a1; }
[data-l="1"] { --g1:#d08b5b; --g2:#a4632f; }
[data-l="2"] { --g1:#c3ccd6; --g2:#8a97a6; }
[data-l="3"] { --g1:#f3c14b; --g2:#d99a1c; }
[data-l="4"] { --g1:#7fe0d4; --g2:#37a99a; }
[data-l="5"] { --g1:#7ad0ff; --g2:#3b8ff0; }
[data-l="6"] { --g1:#9a8bff; --g2:#6d5efc; }
[data-l="7"] { --g1:#c78bff; --g2:#9333ea; }
[data-l="8"] { --g1:#ff9ec4; --g2:#ff4d8d; }
[data-l="9"] { --g1:#ffd36b; --g2:#ff8a3d; }
[data-l="10"]{ --g1:#ffe08a; --g2:#ff4d8d; }

/* ---- Level page -------------------------------------------------------- */
.lv-wrap { max-width: 720px; width: 100%; margin: 0 auto; padding: 16px; box-sizing: border-box; overflow-x: hidden; }
.lv-body { display: flex; flex-direction: column; gap: 14px; max-width: 100%; }
.lv-body * { box-sizing: border-box; }
.lv-card, .lv-hero { max-width: 100%; }

.lv-hero {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px; box-shadow: 0 6px 20px rgba(20,20,40,.05);
}
.lv-badge-big {
  flex: 0 0 auto; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  box-shadow: 0 8px 22px rgba(0,0,0,.18), inset 0 2px 6px rgba(255,255,255,.35);
  position: relative;
}
.lv-badge-big::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--g1); opacity: .35;
}
.lv-badge-num { font-size: 34px; font-weight: 900; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.25); }
.lv-hero-name { font-size: 22px; font-weight: 900; color: var(--ink); }
.lv-hero-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.lv-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: 0 6px 20px rgba(20,20,40,.05);
}
.lv-card-t { font-size: 17px; font-weight: 800; color: var(--ink); margin: 0 0 6px; }
.lv-muted { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; line-height: 1.5; }

.lv-prog { margin-bottom: 14px; }
.lv-prog:last-child { margin-bottom: 0; }
.lv-prog-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.lv-prog-l { font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.lv-prog-v { font-weight: 800; font-size: 13px; color: var(--brand-1); }
.lv-bar { height: 10px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.lv-bar-fill { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2)); transition: width .5s ease; }
.lv-maxed .lv-card-t { color: var(--brand-1); }

/* Rate picker */
.lv-rate-now {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  background: linear-gradient(135deg, rgba(109,94,252,.08), rgba(255,77,141,.08));
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.lv-rate-now-main { font-size: 15px; color: var(--ink); }
.lv-rate-dia { font-size: 26px; font-weight: 900; color: var(--brand-1); }
.lv-rate-per { color: var(--muted); font-size: 13px; margin-left: 4px; }
.lv-rate-now-sub { color: var(--ink-soft); font-size: 13px; }
.lv-rate-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.lv-rate-row { display: flex; gap: 8px; align-items: stretch; }
.lv-select {
  flex: 1 1 auto; min-width: 0;   /* min-width:0 so the long option text can't push the Save button off-screen */
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 15px;
  font-family: var(--font); background: #fff; color: var(--ink); outline: none; -webkit-appearance: none; appearance: none;
  text-overflow: ellipsis;
}
.lv-rate-row .lv-btn { flex: 0 0 auto; }
.lv-select:focus { border-color: var(--brand-1); }
.lv-btn {
  border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 800; font-size: 15px; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); font-family: var(--font);
}
.lv-btn:disabled { opacity: .6; cursor: default; }
.lv-rate-hint { margin-top: 10px; font-size: 13px; color: var(--next); font-weight: 700; }

/* Ladder */
.lv-ladder { display: flex; flex-direction: column; gap: 8px; }
.lv-lad {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fbfbfe; opacity: .72;
}
.lv-lad.is-unlocked { opacity: 1; background: #fff; }
.lv-lad.is-current { border-color: var(--brand-1); box-shadow: 0 0 0 2px rgba(109,94,252,.18); }
.lv-lad-badge {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 16px; background: linear-gradient(135deg, var(--g1), var(--g2));
}
.lv-lad-mid { flex: 1; min-width: 0; }
.lv-lad-name { font-weight: 800; font-size: 15px; color: var(--ink); }
.lv-lad-you { font-size: 11px; font-weight: 800; color: #fff; background: var(--brand-1); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.lv-lad-req { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lv-lad-rate { flex: 0 0 auto; text-align: right; font-size: 13px; color: var(--ink-soft); }
.lv-lad-rate b { font-size: 16px; color: var(--brand-1); }
.lv-lad-rate span { color: var(--muted); font-size: 11px; }
.lv-lad-mark { flex: 0 0 auto; width: 22px; height: 22px; color: var(--muted); }
.lv-lad.is-unlocked .lv-lad-mark { color: var(--next); }
.lv-lad-mark svg { width: 100%; height: 100%; }

/* ---- Small round level badge next to a name (shared across the app) ---- */
.ct-lvl-badge {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 18px; height: 18px; border-radius: 50%; color: #fff; font-weight: 900;
  font-size: 10px; line-height: 1; margin-right: 5px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  box-shadow: inset 0 1px 2px rgba(255,255,255,.4);
}
.ct-lvl-badge.sm { width: 15px; height: 15px; font-size: 9px; }

/* ==========================================================================
   Call button in the DM header
   ========================================================================== */
.dm-call-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: inline-grid; place-items: center; color: var(--brand-1); background: rgba(109,94,252,.1);
  margin-left: 6px;
}
.dm-call-btn:active { transform: scale(.94); }
.dm-call-btn svg { width: 20px; height: 20px; }
.dm-call-btn[disabled] { opacity: .45; cursor: default; }

/* ==========================================================================
   Incoming-call NOTIFICATION card (slides in on ANY page; not full-screen)
   ========================================================================== */
.call-note {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%) translateY(-160%); z-index: 5200;
  width: min(410px, 94vw); background: #14141f; color: #fff; border-radius: 16px;
  padding: 12px 14px; box-shadow: 0 16px 44px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px; font-family: var(--font);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.call-note.show { transform: translateX(-50%) translateY(0); }
.call-note-av { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); display: grid; place-items: center; font-weight: 900; }
.call-note-mid { flex: 1; min-width: 0; }
.call-note-name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-note-sub { font-size: 12px; color: #cfcfe0; margin-top: 1px; }
.call-note-btns { display: flex; gap: 8px; flex: 0 0 auto; }
.call-note-b { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; }
.call-note-b svg { width: 20px; height: 20px; }
.call-note-b:active { transform: scale(.92); }
.call-note-dec { background: var(--danger); }
.call-note-acc { background: var(--next); animation: callPulse 1.6s ease-in-out infinite; }

/* ==========================================================================
   Paid Call — full-screen overlay (outgoing ring + active call)
   ========================================================================== */
.call-root {
  position: fixed; inset: 0; z-index: 4000; background: #0d0d14; color: #fff;
  display: flex; flex-direction: column; font-family: var(--font);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.call-root[hidden] { display: none; }

/* Inner column fills the overlay (constrained + centered on desktop). Without
   flex here the stage collapses to 0 height -> a black screen. */
.call-inner { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; position: relative; }

/* All circular avatars must clip their image to the circle (no distortion). */
.call-top-av, .call-remote-av, .call-ring-av, .call-note-av, .call-top-av img, .call-remote-av img, .call-ring-av img, .call-note-av img { overflow: hidden; }
.call-top-av img, .call-remote-av img, .call-ring-av img, .call-note-av img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}

/* Video stage */
.call-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #14141f; }
/* Blurred background fill layer — hidden on phones (zero cost); enabled on desktop/
   tablet so a portrait video shows whole (no crop) without black bars. */
.call-remote-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.call-remote-off {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #cfcfe0; background: linear-gradient(160deg, #1a1a28, #0d0d14);
}
.call-root[data-remote="off"] .call-remote-off { display: flex; }
.call-remote-av { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); display: grid; place-items: center; font-size: 40px; font-weight: 900; }
/* Connecting spinner over the big frame, until the remote video's first frame. */
.call-wait { position: absolute; inset: 0; display: none; place-items: center; }
.call-root[data-conn="1"] .call-wait { display: grid; }
.call-root[data-conn="1"] .call-remote-off { display: none; }   /* not "camera off" — just connecting */
.call-wait-spin { width: 46px; height: 46px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: callSpin 1s linear infinite; }
.call-local {
  position: absolute; right: 14px; bottom: 104px; width: 104px; height: 150px; border-radius: 14px;
  background: #14141f; box-shadow: 0 6px 18px rgba(0,0,0,.5); z-index: 8; overflow: hidden;
  border: 2px solid rgba(255,255,255,.16); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  pointer-events: auto;   /* always tappable/draggable — nothing overlays it */
}
.call-local:active { cursor: grabbing; }
/* PiP only during the active call — never leaking over the ring / ended screens.
   A camera-off call still shows it (with the avatar placeholder). */
.call-local { display: none; }
.call-root[data-state="active"] .call-local { display: block; }
.call-local-vid { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
/* When the PiP's stream has no video (no camera / camera off), show an avatar
   placeholder INSTEAD of hiding the frame, so it stays draggable + swappable. */
.call-local-off { position: absolute; inset: 0; display: none; place-items: center; background: #14141f; pointer-events: none; }
.call-local[data-off="1"] .call-local-off { display: grid; }
.call-local[data-off="1"] .call-local-vid { visibility: hidden; }
.call-local-av { width: 54px; height: 54px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 22px; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); }
.call-local-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* Top bar: who + timer + cost */
.call-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding: 16px 16px 26px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), transparent); display: flex; align-items: center; gap: 12px;
  pointer-events: none;   /* info only — never blocks the draggable PiP near the top */
}
.call-top-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); display: grid; place-items: center; font-weight: 900; }
.call-top-meta { min-width: 0; flex: 1; }
.call-top-name { font-weight: 800; font-size: 17px; display: flex; align-items: center; }
.call-top-sub { font-size: 13px; color: #cfcfe0; margin-top: 2px; }
.call-timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.call-cost {
  flex: 0 0 auto; text-align: right; background: rgba(0,0,0,.4); border-radius: 12px; padding: 6px 10px;
}
.call-cost-n { font-weight: 900; font-size: 15px; }
.call-cost-l { font-size: 10px; color: #cfcfe0; display: block; }

/* Incoming ring card (centered) */
.call-ring { position: absolute; inset: 0; z-index: 6; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(160deg, #1a1a28, #0d0d14); text-align: center; padding: 24px; }
.call-root[data-state="ringing-in"] .call-ring,
.call-root[data-state="ringing-out"] .call-ring { display: flex; }
.call-ring-av { width: 118px; height: 118px; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); display: grid; place-items: center; font-size: 48px; font-weight: 900; animation: callPulse 1.6s ease-in-out infinite; }
@keyframes callPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(109,94,252,.5); } 50% { box-shadow: 0 0 0 22px rgba(109,94,252,0); } }
.call-ring-name { font-size: 24px; font-weight: 900; margin-top: 12px; }
.call-ring-sub { color: #cfcfe0; font-size: 14px; }
.call-ring-rate { margin-top: 4px; font-size: 13px; color: #ffd36b; font-weight: 700; }
.call-ring-actions { display: flex; gap: 40px; margin-top: 30px; }

.call-cbtn { border: 0; cursor: pointer; display: inline-grid; place-items: center; border-radius: 50%; color: #fff; }
.call-cbtn svg { width: 26px; height: 26px; }
.call-cbtn-lbl { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #cfcfe0; white-space: nowrap; }
.call-cbtn-wrap { position: relative; }
.call-accept { width: 66px; height: 66px; background: var(--next); box-shadow: 0 8px 22px rgba(34,197,94,.4); }
.call-decline, .call-end { width: 66px; height: 66px; background: var(--danger); box-shadow: 0 8px 22px rgba(239,68,68,.4); }
.call-accept svg, .call-decline svg { width: 30px; height: 30px; }

/* Bottom controls during an active call */
.call-controls {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 5; padding: 20px 16px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.6), transparent); display: none; align-items: center; justify-content: center; gap: 12px;
}
.call-root[data-state="active"] .call-controls { display: flex; }
/* Only the buttons capture pointer events — the empty strip lets the draggable
   PiP (and anything else) receive taps/drag through it. */
.call-controls { pointer-events: none; }
.call-controls .call-ctrl { pointer-events: auto; }
/* Smaller icons so all five (mic / cam / filter / gift / end) fit a phone row. */
.call-ctrl { width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; display: inline-grid; place-items: center; color: #fff; background: rgba(255,255,255,.16); flex: 0 0 auto; }
.call-ctrl svg { width: 22px; height: 22px; }
.call-ctrl:active { transform: scale(.94); }
.call-ctrl.is-off { background: #fff; color: #0d0d14; }
.call-ctrl.is-on { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); }
.call-ctrl-end { background: var(--danger); }
.call-ctrl-gift { background: linear-gradient(135deg, var(--brand-2), #ff7ab0); }

/* Reconnecting overlay — a CENTERED CARD, not a full-screen backdrop, so the top
   bar and the bottom controls (End / mic / cam / gift) stay clickable while the
   call is reconnecting. Either party can end during a reconnect; billing stays
   frozen (data-reco="1" freezes the timer/cost). */
.call-reco { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(13,13,20,.9); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.45); text-align: center; padding: 22px 26px; max-width: calc(100% - 48px); }
.call-root[data-reco="1"] .call-reco { display: flex; }
.call-reco-ring { width: 46px; height: 46px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: callSpin 1s linear infinite; }
@keyframes callSpin { to { transform: rotate(360deg); } }
.call-reco-t { font-weight: 800; font-size: 16px; }
.call-reco-s { color: #cfcfe0; font-size: 13px; }

/* Low-balance / info toast inside the call */
.call-toast {
  position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%); z-index: 8;
  background: rgba(0,0,0,.82); border: 1px solid rgba(255,255,255,.14); border-radius: 14px;
  padding: 12px 14px; max-width: 90%; width: 340px; text-align: center; display: none;
}
.call-toast.show { display: block; }
.call-toast-t { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.call-toast-b { display: inline-block; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 800; font-size: 14px; color: #fff; cursor: pointer; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); font-family: var(--font); }
.call-toast-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.call-toast-x svg { width: 15px; height: 15px; }
.call-toast-x:hover { background: rgba(255,255,255,.22); }

/* Gift overlay inside a call (reuses the full-screen gift look) */
.call-gift-layer { position: absolute; inset: 0; z-index: 9; pointer-events: none; display: grid; place-items: center; }
.call-gift-layer video, .call-gift-layer img { max-width: 78%; max-height: 78%; }

/* Ended splash */
.call-ended { position: absolute; inset: 0; z-index: 10; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #0d0d14; text-align: center; padding: 24px; }
.call-root[data-state="ended"] .call-ended { display: flex; }
.call-ended-t { font-size: 20px; font-weight: 900; }
.call-ended-s { color: #cfcfe0; font-size: 14px; }
.call-ended-btn { margin-top: 16px; border: 0; border-radius: 12px; padding: 12px 26px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); cursor: pointer; font-family: var(--font); font-size: 15px; }

/* Gift picker sheet inside the call */
.call-gift-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 11; background: #14141f; border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(110%); transition: transform .25s ease; max-height: 62%; overflow-y: auto; }
.call-gift-sheet.open { transform: translateY(0); }
.call-gift-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.call-gift-cell { position: relative; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 8px 4px; text-align: center; cursor: pointer; }
.call-gift-cell img { width: 46px; height: 46px; object-fit: contain; }
.call-gift-cell .cg-price { font-size: 12px; font-weight: 800; color: #ffd36b; margin-top: 4px; }
/* While a gift send is in flight, show a spinner over the tapped cell. The send
   is a server round-trip and the "not enough coins — recharge" reply can take a
   moment, so this gives instant feedback. Purely visual; the whole grid is made
   non-interactive meanwhile so a second gift can't be fired until the first
   resolves (reuses the existing callSpin keyframes). */
.call-gift-grid.is-busy .call-gift-cell { pointer-events: none; }
.call-gift-cell.is-sending img,
.call-gift-cell.is-sending .cg-price { opacity: .22; }
.call-gift-cell.is-sending::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 26px; height: 26px;
  margin: -13px 0 0 -13px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: callSpin 1s linear infinite;
}
.call-gift-sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.call-gift-sheet-h b { font-size: 16px; }
.call-gift-sheet-h span { font-size: 13px; color: #cfcfe0; }

/* Camera picker (PC may have OBS / Snap virtual cameras) */
.call-cam-pick { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.4); pointer-events: auto; }
.call-cam-pick svg { width: 20px; height: 20px; }
.call-cam-pick:active { transform: scale(.94); }
.call-cam-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 11; background: #14141f; border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(110%); transition: transform .25s ease; max-height: 62%; overflow-y: auto; }
.call-cam-sheet.open { transform: translateY(0); }
.call-cam-sheet-h { margin-bottom: 12px; }
.call-cam-sheet-h b { font-size: 16px; color: #fff; }
.call-cam-grid { display: flex; flex-direction: column; gap: 8px; }
.call-cam-row { text-align: left; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: #fff; border-radius: 12px; padding: 13px 14px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-cam-row.is-cur { border-color: var(--brand-1); background: rgba(109,94,252,.25); }
.call-cam-empty { color: #cfcfe0; font-size: 14px; text-align: center; padding: 16px; }

/* ---- Filter sheet (presets + sliders) ---------------------------------- */
.call-filter-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 12; background: #14141f; border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(110%); transition: transform .25s ease; max-height: 72%; overflow-y: auto; }
.call-filter-sheet.open { transform: translateY(0); }
.call-filter-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.call-filter-h b { font-size: 16px; color: #fff; }
.call-filter-toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; background: rgba(255,255,255,.1); color: #fff; border-radius: 999px; padding: 6px 12px 6px 8px; font-family: var(--font); font-size: 13px; font-weight: 700; }
.call-filter-toggle .cft-dot { width: 22px; height: 22px; border-radius: 50%; background: #6b6b80; transition: background .2s; position: relative; }
.call-filter-toggle .cft-dot::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff; }
.call-filter-toggle.is-on { background: rgba(109,94,252,.28); }
.call-filter-toggle.is-on .cft-dot { background: var(--brand-1); }
.call-filter-presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.call-filter-chip { flex: 0 0 auto; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font); }
.call-filter-chip.is-on { border-color: var(--brand-1); background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); }
.call-filter-sliders { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.call-filter-srow { display: flex; flex-direction: column; gap: 6px; }
.call-filter-shead { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #cfcfe0; }
.call-filter-shead .val { font-variant-numeric: tabular-nums; color: #fff; font-weight: 700; }
.call-filter-range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: rgba(255,255,255,.18); outline: none; }
.call-filter-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--brand-1); cursor: pointer; border: 2px solid #fff; }
.call-filter-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-1); cursor: pointer; border: 2px solid #fff; }
.call-filter-foot { display: flex; gap: 10px; margin-top: 16px; }
.call-filter-reset, .call-filter-done { flex: 1; border: 0; border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 800; cursor: pointer; font-family: var(--font); }
.call-filter-reset { background: rgba(255,255,255,.1); color: #fff; }
.call-filter-done { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; }

/* ---- Minimized floating call window (over the inbox etc.) --------------- */
/* Phone / tablet DEFAULT position: top-left, just below the top bar (profile line).
   Draggable anywhere after that (JS sets inline left/top). Desktop keeps its own
   position via the media query below. */
.call-root[data-min="1"] {
  inset: auto; left: 12px; top: 64px; right: auto; bottom: auto; width: 116px; height: 176px;
  border-radius: 16px; overflow: hidden; box-shadow: 0 12px 34px rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.2); z-index: 4000; padding: 0;
  touch-action: none; cursor: grab;   /* let the window be dragged on touch, not scroll the page */
}
.call-root[data-min="1"]:active { cursor: grabbing; }
/* touch-action applies to the element the finger LANDS on. The touch starts on the
   inner video/stage, so those need it too — otherwise the browser tries to scroll
   at the same time as our drag and the window trembles. */
.call-root[data-min="1"] .call-inner,
.call-root[data-min="1"] .call-stage,
.call-root[data-min="1"] .call-remote,
.call-root[data-min="1"] .call-remote-off { touch-action: none; }
.call-root[data-min="1"] .call-inner { border-radius: 14px; }
.call-root[data-min="1"] .call-remote { cursor: pointer; }
.call-root[data-min="1"] .call-remote-av { width: 54px; height: 54px; font-size: 22px; }
.call-root[data-min="1"] .call-remote-off span { display: none; }
.call-root[data-min="1"] .call-top,
.call-root[data-min="1"] .call-controls,
.call-root[data-min="1"] .call-local,
.call-root[data-min="1"] .call-toast,
.call-root[data-min="1"] .call-gift-sheet,
.call-root[data-min="1"] .call-cam-sheet,
.call-root[data-min="1"] .call-filter-sheet,
.call-root[data-min="1"] .call-gift-layer { display: none !important; }
.call-root[data-min="1"] .call-timer { display: none; }
/* Expand button — shown ONLY while minimized; tap it to restore the full call. */
.call-min-expand {
  position: absolute; top: 6px; right: 6px; z-index: 9; display: none;
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  place-items: center; color: #fff; background: rgba(0,0,0,.55); padding: 0;
}
.call-min-expand svg { width: 17px; height: 17px; }
.call-min-expand:active { transform: scale(.9); }
.call-root[data-min="1"] .call-min-expand { display: grid; }

/* ---- Tablet / desktop ---------------------------------------------------- */
@media (min-width: 780px) {
  /* Desktop = a real landscape call: remote video fills the whole screen, the
     self-view is a floating PiP in the corner (Google-Meet style). No phone frame. */
  .call-inner { width: 100%; }
  /* PC ONLY: the self-view PiP is PORTRAIT (phone-style) instead of the old wide
     200x150 landscape — narrower width, taller height, matching the phone frame's
     shape. Scoped to min-width:780px only; phone/tablet keep their own 104x150. */
  .call-local { width: 150px; height: 218px; right: 24px; bottom: 116px; }
  .call-root[data-state="active"] .call-controls { gap: 18px; }
  .call-ctrl { width: 54px; height: 54px; }
  .call-ctrl svg { width: 24px; height: 24px; }
  /* Desktop keeps the existing minimized position (bottom-right). PC ONLY: the
     minimized floating window is a touch larger than the phone's 116×176 so it's
     comfortable to watch on a big screen (same portrait aspect, so cover-crop is
     unchanged). Scoped to min-width:780px + [data-min="1"], so phone/tablet AND
     the full-screen call are completely untouched. */
  .call-root[data-min="1"] { left: auto; top: auto; right: 12px; bottom: 90px; width: 150px; height: 224px; }
  .call-root[data-min="1"] .call-remote-av { width: 64px; height: 64px; font-size: 26px; }
  /* No-crop remote: show the WHOLE video (contain) with a blurred, zoomed copy of
     the same video filling the sides instead of black bars (TikTok / Meet style). */
  /* background transparent so the CONTAIN letterbox reveals the blurred bg behind
     it instead of a solid dark fill. */
  .call-remote { object-fit: contain; background: transparent; }
  /* Blur is the costly part, so keep the radius moderate + downscale the layer (render
     at ~55% then scale up) so the blur shader processes far fewer pixels -> cheap even
     on a modest laptop/tablet GPU, with no visible loss (it's blurred anyway). */
  .call-remote-bg {
    display: block; inset: auto; top: 50%; left: 50%; width: 56%; height: 56%;
    transform: translate(-50%, -50%) scale(2); filter: blur(12px) brightness(.6);
  }
  /* The minimized floating window is small -> keep it a clean crop, no blur layer. */
  .call-root[data-min="1"] .call-remote { object-fit: cover; }
  .call-root[data-min="1"] .call-remote-bg { display: none; }
  /* Bottom sheets (gift / camera / filter) are full-width on phones; on a wide desktop
     that stretches the cards absurdly wide. Constrain them to a centered panel. The
     centering uses auto side-margins (with left:0/right:0 + a fixed width, per the
     absolute-centering rule) — NOT transform — so the slide-up translateY animation
     stays exactly as-is. */
  .call-gift-sheet, .call-cam-sheet, .call-filter-sheet {
    width: 480px; max-width: calc(100% - 32px); margin-left: auto; margin-right: auto;
  }
}

/* ==========================================================================
   DM GIFT SHEET — send a gift from inside a chat (no call). Reuses the call
   gift GRID + CELL + spinner styles above; only the sheet shell + the in-chat
   gift bubble are new here. Everything is namespaced with a distinct "dm-gift"
   prefix so it can never collide with the call UI or the rest of the DM page.
   The sheet is a bottom sheet ABOVE the composer, shown only while picking a
   gift — the partner's messages always stay visible above the gift button.
   ========================================================================== */
.dm-gift-scrim { position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,.5); display: none; }
.dm-gift-scrim.open { display: block; }
.dm-gift-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%);
  width: min(520px, 100%); z-index: 5001; background: #14141f; color: #fff;
  border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  transition: transform .24s cubic-bezier(.2,.9,.25,1);
}
.dm-gift-scrim.open .dm-gift-sheet { transform: translate(-50%, 0); }
.dm-gift-sheet-h { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 15px; margin-bottom: 12px; }
.dm-gift-sheet-h span { color: #ffd36b; font-weight: 800; }
/* A gift shown inside a chat bubble: the gift's icon + its coin price. */
.dm-bubble.dm-gift-msg { display: inline-flex; align-items: center; gap: 8px; }
.dm-gift-msg .dm-gift-ic { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }
.dm-gift-msg .dm-gift-price { font-weight: 800; color: #ffd36b; }
/* The composer gift button matches the photo (attach) button EXACTLY (.dm-attach
   is 42x42 round, faint fill, ink icon) so the composer stays visually balanced. */
.dm-gift-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.06); color: var(--ink); }
.dm-gift-btn svg { width: 20px; height: 20px; }
/* In-chat "not enough coins — recharge" notice (client-only; sender sees it in
   the chat flow, it is never written to RTDB / sent to the partner). */
.dm-sys { display: flex; justify-content: center; margin: 8px 0; }
.dm-sys-recharge-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; max-width: 82%; padding: 10px 16px; border: 1px solid rgba(255,211,107,.55); border-radius: 14px; background: rgba(255,211,107,.12); color: inherit; font: inherit; cursor: pointer; text-align: center; }
.dm-sys-recharge-btn .dm-sys-t { font-size: 13px; opacity: .85; }
.dm-sys-recharge-btn .dm-sys-cta { font-size: 13px; font-weight: 800; color: #b8791f; }
.dm-sys-recharge-btn:active { transform: scale(.98); }

/* ======================================================================
   CALL RESUME BAR — a small fixed top banner shown (on the top window only)
   when a live call was PAUSED by navigating away / reloading. Lets the user
   Resume (reconnect to the same call) or End it. Body-level + very high
   z-index so it rides above every page's own topbar without touching them.
   ====================================================================== */
.call-rbar { position: fixed; top: 0; left: 0; right: 0; z-index: 2147483500;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #2b2440, #3a2140); color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.28); font-family: inherit;
  animation: callRbarIn .22s ease; }
@keyframes callRbarIn { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.call-rbar-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto;
  background: #35d07f; box-shadow: 0 0 0 0 rgba(53,208,127,.6); animation: callRbarPulse 1.4s infinite; }
@keyframes callRbarPulse { 0% { box-shadow: 0 0 0 0 rgba(53,208,127,.55); } 70% { box-shadow: 0 0 0 8px rgba(53,208,127,0); } 100% { box-shadow: 0 0 0 0 rgba(53,208,127,0); } }
.call-rbar-tx { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.call-rbar-tx b { display: block; font-size: 13.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-rbar-tx span { display: block; font-size: 11.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-rbar button { flex: 0 0 auto; border: 0; border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; }
.call-rbar-end { background: rgba(255,255,255,.14); color: #fff; }
.call-rbar-end:active { transform: scale(.96); }
.call-rbar-go { color: #fff; background: linear-gradient(135deg, #6d5efc, #ff4d8d); }
.call-rbar-go:active { transform: scale(.96); }
