:root {
  --bg: #0b0b12;
  --panel: #14141f;
  --panel-2: #1c1c2a;
  --line: #2a2a3c;
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #7c5cff;
  --accent-2: #ff4fa3;
  --good: #2ee6a6;
  --danger: #ff4d5e;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.hidden { display: none !important; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.screen { display: none; height: 100dvh; width: 100%; }
.screen.active { display: flex; }

/* ---------- logo / pills ---------- */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 26px; letter-spacing: -.5px; }
.logo.small { font-size: 19px; }
.logo-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 18px var(--accent); }
.online-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: rgba(46,230,166,.1); color: var(--good); font-size: 14px; border: 1px solid rgba(46,230,166,.25); }
.online-pill.small { padding: 5px 11px; font-size: 13px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,230,166,.7); } 100% { box-shadow: 0 0 0 10px rgba(46,230,166,0); } }

/* ---------- landing ---------- */
#landing { align-items: center; justify-content: center; position: relative; padding: 20px; overflow: hidden; }
.landing-bg span { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .45; animation: float 14s ease-in-out infinite; }
.landing-bg span:nth-child(1) { width: 420px; height: 420px; background: var(--accent); top: -120px; left: -100px; }
.landing-bg span:nth-child(2) { width: 360px; height: 360px; background: var(--accent-2); bottom: -120px; right: -80px; animation-delay: -5s; }
.landing-bg span:nth-child(3) { width: 260px; height: 260px; background: #2bb3ff; top: 40%; left: 55%; animation-delay: -9s; opacity: .25; }
@keyframes float { 50% { transform: translate(40px, -30px) scale(1.1); } }
.landing-card { position: relative; width: 100%; max-width: 440px; padding: 34px 28px; border-radius: 28px;
  background: rgba(20,20,31,.72); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; animation: rise .6s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
.landing-card h1 { font-size: clamp(30px, 7vw, 40px); line-height: 1.08; letter-spacing: -1px; }
.sub { color: var(--muted); line-height: 1.5; }
.online-pill { align-self: flex-start; }
.field input { width: 100%; padding: 14px 16px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); outline: none; }
.field input:focus { border-color: var(--accent); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--muted); line-height: 1.45; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin-top: 1px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 16px 22px;
  border-radius: 16px; background: var(--grad); font-weight: 700; font-size: 17px; box-shadow: 0 10px 30px rgba(124,92,255,.35);
  transition: transform .15s, opacity .2s, box-shadow .2s; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(124,92,255,.5); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn-primary.sm { padding: 11px 20px; font-size: 15px; }
.btn-ghost { padding: 11px 18px; border-radius: 12px; background: var(--panel-2); }
.btn-danger { padding: 11px 18px; border-radius: 12px; background: var(--danger); font-weight: 700; }
.btn-danger:disabled { opacity: .4; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- chat screen ---------- */
#chat { flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .online-pill { margin-left: auto; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); }
.icon-btn:hover { background: var(--line); }

.stage { flex: 1; min-height: 0; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-rows: 1fr auto;
  grid-template-areas: "videos chat" "controls chat"; }
.videos { grid-area: videos; min-height: 0; position: relative; }

/* desktop SPLIT: stranger on top, you on the bottom (OmeTV style) */
.layout-split .stage { grid-template-columns: minmax(0, min(58vw, calc((100dvh - 170px) * .72))) minmax(300px, 1fr); }
.layout-split .videos { display: grid; gap: 12px; grid-template-rows: 1fr 1fr; }

/* desktop FULL: stranger fills, you float in the corner */
.layout-full .video-tile.remote { position: absolute; inset: 0; }
.layout-full .video-tile.local { position: absolute; z-index: 8; right: 16px; bottom: 16px; width: 22%; min-width: 170px; max-width: 300px;
  aspect-ratio: 4/3; border: 2px solid rgba(255,255,255,.18); box-shadow: 0 10px 30px rgba(0,0,0,.55); }

/* layout toggle icon */
#layoutBtn .ico-full { display: none; }
.layout-full #layoutBtn .ico-split { display: none; }
.layout-full #layoutBtn .ico-full { display: block; }

/* segmented control */
.seg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { padding: 8px 14px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--grad); color: #fff; font-weight: 700; }
.toggle small { color: var(--muted); font-size: 12px; }

/* nudity shield */
.video-tile.remote.shielded video { filter: blur(40px) saturate(.6); }
.overlay.nsfw { background: rgba(8,8,14,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.shield { font-size: 44px; }
.nsfw-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.video-tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 0; border: 1px solid var(--line); }
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #07070c; }
.video-tile.local video.mirror { transform: scaleX(-1); }
.video-tile.remote.blurred video { filter: blur(28px); }
.video-tile.remote.blurred::after { content: "Tap to reveal"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; z-index: 2; }
.tag { position: absolute; left: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(0,0,0,.5); backdrop-filter: blur(8px); z-index: 3; }
.cam-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: #0e0e16; font-size: 14px; }

/* overlays */
.overlay { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, #1a1630 0%, #07070c 75%); text-align: center; padding: 20px; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; } }
.overlay-title { font-size: 19px; font-weight: 700; }
.overlay-tip { font-size: 13px; color: var(--muted); min-height: 1.2em; transition: opacity .4s; }

.radar { position: relative; width: 130px; height: 130px; display: grid; place-items: center; }
.radar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: ring 2.4s cubic-bezier(.2,.6,.4,1) infinite; }
.radar i:nth-child(2) { animation-delay: .8s; border-color: var(--accent-2); }
.radar i:nth-child(3) { animation-delay: 1.6s; }
@keyframes ring { 0% { transform: scale(.3); opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }
.radar-core { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 40px var(--accent); animation: core 1.2s ease-in-out infinite alternate; }
@keyframes core { to { transform: scale(1.12); } }

.connect-anim { position: relative; width: 90px; height: 40px; }
.connect-anim span { position: absolute; top: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); animation: link 1s ease-in-out infinite alternate; }
.connect-anim span:last-child { right: 0; background: var(--accent-2); animation-direction: alternate-reverse; }
@keyframes link { from { transform: translateX(0); } to { transform: translateX(33px); } }
.connect-anim span:last-child { animation-name: link2; }
@keyframes link2 { from { transform: translateX(0); } to { transform: translateX(-33px); } }

.flash { position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--good), inset 0 0 60px rgba(46,230,166,.45); }
.flash.go { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

.toast { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -20px); z-index: 6; padding: 9px 16px; border-radius: 999px;
  background: rgba(10,10,18,.85); backdrop-filter: blur(10px); border: 1px solid var(--line); font-size: 14px; font-weight: 600;
  opacity: 0; transition: .35s; pointer-events: none; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.report-btn { position: absolute; right: 12px; top: 12px; z-index: 6; display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: 999px; background: rgba(255,77,94,.18); color: #ff8a96; border: 1px solid rgba(255,77,94,.35); font-size: 13px; font-weight: 600; backdrop-filter: blur(8px); }
.report-btn svg { width: 16px; height: 16px; }
.report-btn:hover { background: rgba(255,77,94,.3); }

/* chat panel */
.chat-panel { grid-area: chat; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; line-height: 1.4; font-size: 15px; word-wrap: break-word; animation: pop .22s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.msg.me { align-self: flex-end; background: var(--grad); border-bottom-right-radius: 5px; }
.msg.them { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.msg.system { align-self: center; background: none; color: var(--muted); font-size: 13px; text-align: center; max-width: 100%; }
.msg.system.good { color: var(--good); }
.typing { padding: 0 16px 8px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; margin-right: 6px; }
@keyframes bounce { 50% { transform: translateY(-4px); } }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid transparent; outline: none; font-size: 16px; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form input:disabled { opacity: .5; }
.send-btn { width: 46px; border-radius: 14px; background: var(--grad); display: grid; place-items: center; }
.send-btn:disabled { opacity: .35; }

/* controls */
.controls { grid-area: controls; display: flex; gap: 10px; justify-content: center; }
.ctrl { display: flex; align-items: center; justify-content: center; gap: 8px; height: 54px; padding: 0 18px; border-radius: 16px;
  background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; transition: transform .12s, background .2s; }
.ctrl:hover { background: var(--line); }
.ctrl:active { transform: scale(.95); }
.ctrl.off { background: rgba(255,77,94,.18); color: #ff8a96; border-color: rgba(255,77,94,.35); }
.ctrl.stop { color: #ff8a96; }
.ctrl.next { flex: 0 1 220px; background: var(--grad); border: 0; font-size: 17px; box-shadow: 0 8px 24px rgba(124,92,255,.35); }
.ctrl.flip { display: none; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s; }
.sheet { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: rise .25s ease; }
.sheet h3 { font-size: 20px; }
.muted { color: var(--muted); font-size: 14px; }
.reasons { display: flex; flex-direction: column; gap: 8px; }
.reasons button { text-align: left; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.reasons button.sel { border-color: var(--danger); background: rgba(255,77,94,.12); }
.sheet textarea { min-height: 70px; resize: vertical; padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); outline: none; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toggle, .select-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; cursor: pointer; }
.toggle input { display: none; }
.toggle i { width: 46px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: .2s; flex: none; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { left: 23px; }
.select-row select { max-width: 60%; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }

/* =================== MOBILE =================== */
@media (max-width: 820px) {
  .topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 20; background: linear-gradient(rgba(0,0,0,.6), transparent); border: 0; }
  .topbar .icon-btn { background: rgba(0,0,0,.35); }
  .stage { display: block !important; position: relative; padding: 0; height: 100%; }
  .videos { position: absolute; inset: 0; }
  .video-tile { border: 0; border-radius: 0; }
  .tag.stranger-tag { display: none; }
  .report-btn { top: calc(64px + var(--safe-t)); right: auto; left: 12px; z-index: 16; }
  .toast { top: calc(66px + var(--safe-t)); }

  /* chat floats over the bottom of the screen */
  .chat-panel { position: absolute; left: 0; right: 0; bottom: calc(76px + var(--safe-b)); z-index: 12; background: none; border: 0; border-radius: 0; max-height: 38%; }
  .messages { padding: 8px 12px; -webkit-mask-image: linear-gradient(transparent, #000 30%); mask-image: linear-gradient(transparent, #000 30%); }
  .msg { font-size: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
  .msg.them { background: rgba(28,28,42,.78); }
  .msg.system { background: rgba(0,0,0,.45); padding: 5px 12px; border-radius: 999px; }
  .chat-form { border: 0; padding: 6px 10px; }
  .chat-form input { background: rgba(20,20,31,.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .typing { padding-left: 14px; text-shadow: 0 1px 3px #000; }

  .controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 14; padding: 10px 10px calc(10px + var(--safe-b));
    background: linear-gradient(transparent, rgba(0,0,0,.75)); gap: 8px; }
  .ctrl { height: 52px; padding: 0 14px; background: rgba(28,28,42,.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .ctrl span { display: none; }
  .ctrl.next { flex: 1; }
  .ctrl.next span { display: inline; }
  .ctrl.flip { display: flex; }

  /* ---- mobile SPLIT: stranger top half, you bottom half ---- */
  .layout-split .videos { display: grid; grid-template-rows: 1fr 1fr; gap: 2px; background: #000; }
  .layout-split .video-tile { position: relative; }
  .layout-split .video-tile.local .tag { top: 10px; }
  .layout-split .overlay { padding-bottom: 20px; }
  .layout-split .radar { width: 100px; height: 100px; }

  /* ---- mobile FULL: stranger fills the screen, you float (draggable) ---- */
  .layout-full .video-tile.remote { position: absolute; inset: 0; }
  .layout-full .video-tile.local { position: absolute; z-index: 15; width: 30vw; max-width: 150px; min-width: 0; aspect-ratio: 3/4;
    right: 12px; bottom: auto; top: calc(64px + var(--safe-t)); border-radius: 14px; border: 2px solid rgba(255,255,255,.18);
    box-shadow: 0 8px 24px rgba(0,0,0,.5); touch-action: none; }
  .layout-full .video-tile.local .tag { display: none; }
  .layout-full .overlay { padding-bottom: 180px; }
}
@media (max-width: 380px) { .ctrl { padding: 0 11px; } }

