:root {
  --bg: #0a0a0a;
  --bg-panel: #111111;
  --cyan: #05d1c4;
  --cyan-dim: #0a7d75;
  --teal-bar: #00c4b4;
  --pink: #ff6b9d;
  --text: #ffffff;
  --text-dim: #9a9a9a;
  --border: #2a2a2a;
  --danger: #ff5563;
  --pane-bg: #1a2a2e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden { display: none !important; }

/* Visibility helpers */
.desktop-only { display: none !important; }
.mobile-only { display: flex; }

/* ========== PROFILE ========== */
#screen-profile {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}
.profile-wrap { width: 100%; max-width: 380px; }
.logo-top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px; font-weight: 700; font-size: 20px;
}
#screen-profile h1 { font-size: 28px; font-weight: 700; line-height: 1.2; margin-bottom: 10px; }
.sub { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin-bottom: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--text-dim); }
input[type="text"] {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; color: var(--text); font-size: 15px; outline: none; width: 100%;
}
input:focus { border-color: var(--cyan); }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-dim); margin: 18px 0 24px; line-height: 1.4; }
.checkbox input { margin-top: 2px; accent-color: var(--cyan); }
.btn-primary {
  width: 100%; background: var(--cyan); color: #04120a; border: none; border-radius: 12px;
  padding: 15px 18px; font-weight: 700; font-size: 15px; cursor: pointer;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); }

/* ========== MAIN SCREEN ========== */
.screen-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: #000;
  position: relative;
}

/* Desktop topnav — hidden on mobile */
.desktop-topnav {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--teal-bar);
  padding: 0 24px;
  height: 52px;
  flex: none;
  z-index: 20;
}
.dtn-logo {
  display: flex; align-items: center; gap: 8px;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 20px;
}
.dtn-links { display: flex; align-items: center; gap: 22px; }
.dtn-links a {
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 500; opacity: 0.95;
}
.dtn-links a:hover { opacity: 1; text-decoration: underline; }
.dtn-join {
  background: #fff !important; color: #0a0a0a !important;
  padding: 8px 18px; border-radius: 6px; font-weight: 700 !important;
  opacity: 1 !important; text-decoration: none !important;
}

/* Mobile watermark logo — top left corner */
.mobile-watermark {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  opacity: 0.85;
}
.mobile-watermark span {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.2px;
}

/* Mobile header */
.app-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex: none;
  z-index: 10;
}
.icon-btn {
  background: transparent; border: none; color: #ccc; padding: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: #fff; }
.brand-right {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 17px;
}

/* Main layout: column on mobile, row on desktop */
.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.video-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Partner area */
.partner-area {
  flex: 1 1 42%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1518;
  overflow: hidden;
}
.partner-status {
  display: flex; flex-direction: column; align-items: center; gap: 16px; z-index: 2;
}
.gender-circle {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(5, 209, 196, 0.12);
  display: flex; align-items: center; justify-content: center;
}
.status-main {
  font-size: 14px; color: #bbb; text-align: center; max-width: 260px; line-height: 1.4;
}
.remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; z-index: 1;
}
.noise-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; mix-blend-mode: screen; opacity: 0.45;
}
.noise-canvas.flicker { animation: flicker 0.6s steps(6) infinite; }
@keyframes flicker {
  0% { opacity: 0.12; } 20% { opacity: 0.5; } 35% { opacity: 0.18; }
  50% { opacity: 0.55; } 65% { opacity: 0.22; } 80% { opacity: 0.45; } 100% { opacity: 0.15; }
}
.pane-logo {
  position: absolute; top: 10px; right: 12px; z-index: 5;
  display: flex; align-items: center; gap: 4px; opacity: 0.7;
  font-size: 12px; font-weight: 600; color: var(--cyan); pointer-events: none;
}

/* Status bar (mobile) */
.status-bar {
  flex: none;
  display: none; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: #0a0a0a;
  border-top: 1px solid #1a1a1a; border-bottom: 1px solid #1a1a1a;
  min-height: 40px;
}
.status-left { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccc; }
.status-emoji { font-size: 16px; }
.flag-btn { color: #888; }
.flag-btn:hover { color: var(--danger); }

/* Self area */
.self-area {
  flex: 1 1 44%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1518;
  overflow: hidden;
}
.local-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; z-index: 1;
}
.local-video.mirrored { transform: scaleX(-1); }
.camera-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 18px; z-index: 2;
}
.self-gender { background: rgba(5, 209, 196, 0.1); }
.btn-start-camera {
  background: transparent; color: var(--cyan);
  border: 1.5px solid var(--cyan); border-radius: 10px;
  padding: 10px 22px; font-weight: 600; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.btn-start-camera:hover { background: rgba(5, 209, 196, 0.12); }
.btn-start-camera:active { transform: scale(0.97); }

.gender-fab {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: #ccc;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; cursor: pointer; z-index: 5; padding: 6px;
}
.gender-fab:hover { color: #fff; }
.gender-fab span { color: #aaa; }

/* Mobile nav row */
.nav-row {
  flex: none; display: flex; gap: 12px; padding: 10px 16px 6px; background: #0a0a0a;
}
.btn-nav {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: #ddd; border: 1.5px solid #333; border-radius: 10px;
  padding: 12px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-nav:hover:not(:disabled) { border-color: #555; background: #111; }
.btn-nav:disabled { opacity: 0.35; cursor: default; }

/* Mobile bottom nav */
.bottom-nav {
  flex: none; display: flex; align-items: center; justify-content: space-around;
  padding: 6px 4px 10px; background: #0d0d0d; border-top: 1px solid #1a1a1a;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: none; color: #888; font-size: 10px;
  cursor: pointer; padding: 4px 8px; min-width: 52px;
}
.nav-item:hover { color: #ccc; }
.nav-item.nav-plus { color: var(--cyan); }

/* Chat column — hidden on mobile by default */
.chat-column {
  display: none;
  flex-direction: column;
  background: #0a0a0a;
  min-height: 0;
  border-left: 1px solid #1a1a1a;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #1a1a1a; flex: none;
}
.chat-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #ddd; }
.gender-select-btn {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1.5px solid var(--cyan); border-radius: 20px;
  padding: 6px 12px; color: #fff; font-size: 13px; cursor: pointer;
}
.gender-select-btn:hover { background: rgba(5, 209, 196, 0.1); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; min-height: 0;
}
.chat-msg {
  margin-bottom: 10px; font-size: 14px; line-height: 1.4;
  padding: 8px 12px; border-radius: 10px; max-width: 85%;
}
.chat-msg.me { background: rgba(5, 209, 196, 0.15); margin-left: auto; text-align: right; }
.chat-msg.them { background: #1a1a1a; }
.chat-footer {
  flex: none; padding: 10px 12px 14px; border-top: 1px solid #1a1a1a;
  display: flex; flex-direction: column; gap: 10px;
}
.btn-next-desk {
  align-self: flex-start;
  background: #3a3a3a; color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; font-size: 13px; cursor: pointer;
  letter-spacing: 0.5px;
}
.btn-next-desk:hover { background: #4a4a4a; }
.btn-next-desk:disabled { opacity: 0.4; cursor: default; }
.chat-input-row {
  display: flex; align-items: center; gap: 6px;
  background: #151515; border: 1px solid #2a2a2a; border-radius: 24px;
  padding: 6px 8px 6px 16px;
}
.chat-input-row input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #fff; font-size: 14px; padding: 6px 0;
}
.chat-icon-btn {
  background: transparent; border: none; color: #888; cursor: pointer;
  padding: 4px; font-size: 16px; display: flex; align-items: center;
}
.chat-icon-btn:hover { color: #ccc; }
.chat-send-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--cyan); color: #04120a; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-send-btn:hover { opacity: 0.9; }

.btn-tap-audio {
  position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: rgba(5, 209, 196, 0.15); color: var(--cyan);
  border: 1.5px solid var(--cyan); border-radius: 10px;
  padding: 10px 20px; font-weight: 600; font-size: 13px; cursor: pointer;
}

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; border: 1px solid #333; color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; z-index: 50;
  max-width: 90vw; text-align: center;
}

@media (max-height: 640px) {
  .gender-circle { width: 56px; height: 56px; }
  .status-main { font-size: 13px; }
  .btn-start-camera { padding: 8px 18px; font-size: 14px; }
}

/* ================================================================
   DESKTOP (≥ 900px) — Camgo split layout
   ================================================================ */
@media (min-width: 900px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: flex !important; }
  .mobile-watermark { display: none !important; }

  .desktop-topnav { display: flex; }

  .screen-main { background: #0a0a0a; }

  .main-layout {
    flex-direction: row;
    flex: 1;
    min-height: 0;
  }

  .video-column {
    flex: 0 0 42%;
    max-width: 480px;
    border-right: 1px solid #1a1a1a;
  }

  .partner-area {
    flex: 1 1 50%;
    background: #1a2a2e;
    border-bottom: 1px solid #0d1518;
  }
  .self-area {
    flex: 1 1 50%;
    background: #1a2a2e;
  }

  .chat-column {
    display: flex;
    flex: 1;
    min-width: 0;
  }

  .status-main { color: #a0c0c0; }
  .gender-circle {
    background: rgba(5, 209, 196, 0.15);
    width: 80px; height: 80px;
  }

  .btn-tap-audio { bottom: 80px; }
}

/* Extra wide desktops */
@media (min-width: 1200px) {
  .video-column { flex: 0 0 38%; max-width: 520px; }
}

/* ================= Connected-with badge (top-right of partner video) ============= */
.connected-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 6;
  max-width: 70%;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(5, 209, 196, 0.16);
  border: 1px solid rgba(5, 209, 196, 0.5);
  color: #eafffb;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connected-badge::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #05d1c4; box-shadow: 0 0 8px #05d1c4; flex: none;
}
@media (min-width: 900px) {
  .connected-badge { top: 12px; right: 14px; font-size: 13px; }
}

/* ================= Chat message name + body ============= */
.chat-msg { display: flex; flex-direction: column; gap: 2px; }
.chat-name {
  font-size: 11px; font-weight: 700; letter-spacing: .2px; opacity: .85;
  color: var(--cyan);
}
.chat-msg.me .chat-name { color: #7fe9df; }
.chat-body { font-size: 14px; line-height: 1.4; word-break: break-word; }

/* Unread dot on the mobile Chat button */
.nav-item.has-unread { position: relative; }
.nav-item.has-unread::after {
  content: ""; position: absolute; top: 2px; right: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pink); box-shadow: 0 0 6px var(--pink);
}

/* ================= Mobile chat overlay popup ============= */
.chat-overlay {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  height: 72vh;
  height: 72dvh;
  display: flex;
  flex-direction: column;
  background: #0b0b0b;
  border-top: 1px solid #1f1f1f;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
  animation: chatSlideUp .22s ease-out;
}
@keyframes chatSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.chat-overlay-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #1a1a1a;
}
.chat-overlay-name {
  font-size: 15px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.chat-overlay-name::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #05d1c4; box-shadow: 0 0 8px #05d1c4;
}
.chat-overlay-close {
  background: transparent; border: none; color: #999; cursor: pointer; padding: 4px;
  display: flex; align-items: center;
}
.chat-overlay-close:hover { color: #fff; }
.chat-overlay-messages {
  flex: 1; overflow-y: auto; padding: 14px 16px; min-height: 0;
  display: flex; flex-direction: column;
}
.chat-overlay-messages .chat-msg {
  margin-bottom: 10px; padding: 8px 12px; border-radius: 12px; max-width: 85%;
}
.chat-overlay-messages .chat-msg.me { background: rgba(5, 209, 196, 0.16); margin-left: auto; }
.chat-overlay-messages .chat-msg.them { background: #1a1a1a; }
.chat-overlay-input-row {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #1a1a1a; background: #0b0b0b;
}
.chat-overlay-input-row input {
  flex: 1; background: #161616; border: 1px solid #2a2a2a; border-radius: 22px;
  padding: 12px 16px; color: #fff; font-size: 15px; outline: none;
}
.chat-overlay-input-row input:focus { border-color: var(--cyan); }

/* The overlay is a mobile affordance; never show it on the desktop split layout. */
@media (min-width: 900px) {
  .chat-overlay { display: none !important; }
}
