/* ===================================================================
   Ometell — Modern Video Chat Prototype
   styles.css
=================================================================== */

:root {
  /* Palette */
  --bg-0: #1c0e11;
  --bg-1: #2e161b;
  --bg-2: #5a2a30;
  --surface: rgba(46, 22, 27, 0.62);
  --surface-2: rgba(64, 31, 37, 0.72);
  --stroke: rgba(255, 235, 230, 0.10);
  --stroke-strong: rgba(255, 235, 230, 0.20);

  --text: #f6ece9;
  --text-dim: #c8b3b0;
  --text-faint: #9a8480;

  --accent: #c43d54;
  --accent-2: #d98a4e;
  --accent-grad: linear-gradient(135deg, #c43d54 0%, #d98a4e 100%);
  --pink: #e0668a;
  --gold: #e6b85c;
  --green: #3ddc84;
  --danger: #ff5c6c;

  /* Spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;

  --r-xxs: 4px;
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;

  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 18px 50px rgba(0, 0, 0, 0.5);
  --blur: 20px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dock-h: 68px;          /* reduced ~16px for a more compact dock */
  --header-h: 64px;
  --gap-work: 4px;         /* spacing between workspace and header / dock */
}

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

html, body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  user-select: none;
}

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

.hidden { display: none !important; }

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

/* ---------- Static background (no animation) ---------- */
.bg-static {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(900px 600px at 82% -8%, rgba(196, 61, 84, 0.20) 0%, transparent 60%),
    radial-gradient(800px 600px at 12% 108%, rgba(217, 138, 78, 0.14) 0%, transparent 60%),
    linear-gradient(160deg, #170b0e 0%, var(--bg-1) 45%, var(--bg-0) 100%);
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  border: 1px solid var(--stroke);
}

/* ===================================================================
   HEADER
=================================================================== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s5);
  padding-top: env(safe-area-inset-top);
  border-left: 0; border-right: 0; border-top: 0;
  border-radius: 0;
}
.brand { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }
.brand-mark { display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -0.4px; }
.brand-name .dot {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 700;
}

.header-stats { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--stroke);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.stat-pill[role="button"] { cursor: pointer; }
.stat-pill[role="button"]:hover { transform: translateY(-1px); border-color: var(--stroke-strong); }
.stat-pill .stat-label { color: var(--text-faint); font-weight: 500; }
.stat-pill .ico { font-size: 14px; }
.coins { color: var(--gold); }
.gifts-pill { color: var(--pink); }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,220,132,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(61,220,132,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); }
}

.header-actions { display: flex; gap: var(--s2); flex-shrink: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.2s var(--ease), border-color 0.2s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--stroke-strong); }
.avatar-mini {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-grad); font-weight: 800; font-size: 13px; color: #fff;
}

/* ===================================================================
   STAGE / VIDEO
=================================================================== */
.stage {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top) + var(--gap-work));
  left: var(--s4); right: var(--s4);
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + var(--gap-work));
  z-index: 1;
}
.card { border-radius: var(--r-xs); overflow: hidden; box-shadow: var(--shadow-lift); }

.remote-video {
  position: absolute; inset: 0;
  border: 1px solid var(--stroke);
  background: #05060c;
}
.video-fill { position: absolute; inset: 0; }

/* ---- Camera preview (prototype-only, remove with the CAM module) ---- */
.cam-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;             /* fill the card, no distortion */
  display: none;                 /* shown only while a stream is live */
  z-index: 1;                    /* above gradient fill, below badges/overlays */
  background: #05060c;
  aspect-ratio: 4 / 3;             /* maintain a 4:3 aspect ratio */
  object-fit: contain;   
}
body.cam-on .cam-video { display: block; }
.cam-video.cam-local { transform: scaleX(-1); }   /* mirror your own camera */

.cam-fallback {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  z-index: 6; display: none;
  padding: 5px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: rgba(8, 10, 20, 0.7); border: 1px solid var(--stroke); color: var(--text-dim);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
body.cam-failed .cam-fallback { display: block; }

.icon-btn.on { background: var(--accent-grad); border-color: transparent; }
.remote-fill {
  background:
    linear-gradient(135deg, rgba(196,61,84,0.10), transparent 55%),
    radial-gradient(120% 120% at 30% 20%, #3a2230 0%, #241318 45%, #160b0e 100%);
}

.video-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.45) 0%, transparent 22%, transparent 70%, rgba(0,0,0,0.55) 100%);
}
.video-scrim.soft { background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.45) 100%); }

/* Badges */
.video-badge {
  position: absolute; z-index: 5;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(8, 10, 20, 0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  font-size: 13px; font-weight: 600;
}
.video-badge.top-left { top: var(--s2); left: var(--s2); }
.video-badge.bottom-left { bottom: var(--s3); left: var(--s3); }
.video-badge.small { padding: 5px 10px; font-size: 12px; }
.badge-state { width: 8px; height: 8px; border-radius: 50%; }
.badge-state.idle { background: var(--text-faint); }
.badge-state.searching { background: var(--gold); animation: pulse-s 1s infinite; }
.badge-state.connecting { background: var(--accent-2); animation: pulse-s 0.7s infinite; }
.badge-state.connected { background: var(--green); }
@keyframes pulse-s { 50% { opacity: 0.35; } }
.flag { font-size: 15px; }

/* Status overlay */
.status-overlay {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s3); text-align: center; padding: var(--s5);
  transition: opacity 0.4s var(--ease);
}
.status-overlay.searching .start-btn,
.status-overlay.connecting .start-btn { display: none; }
.status-spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
  display: none;
}
.status-overlay.searching .status-spinner,
.status-overlay.connecting .status-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.status-sub { color: var(--text-dim); font-size: 14px; }
.start-btn {
  margin-top: var(--s2);
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 14px 28px; border-radius: 999px; font-size: 15px; font-weight: 700;
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 12px 34px rgba(196,61,84,0.45);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 42px rgba(196,61,84,0.6); }
.start-btn:active { transform: translateY(0) scale(0.98); }

/* Stranger info card */
.stranger-info {
  position: absolute; bottom: var(--s4); left: var(--s4); z-index: 5;
  display: flex; align-items: center; gap: var(--s3);
border-radius: var(--r-xs);
  /* padding: 10px 14px 10px 10px;  */
  background: rgba(8,10,20,0.55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  /* border: 1px solid var(--stroke); */
  animation: slideUp 0.4s var(--ease);
}
.stranger-avatar {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ff5c8a, #ffb15c); font-weight: 800; font-size: 18px; color: #fff;
}
.stranger-name { font-weight: 700; font-size: 15px; }
.stranger-name .age { color: var(--text-dim); font-weight: 500; }
.stranger-loc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.report-btn {
   width: 32px; height: 32px; border-radius: 10px;
   /* margin-left: var(--s2); */
  background: rgba(255,92,108,0.14); color: var(--danger); font-size: 14px;
}

/* Micro controls */
.micro-controls { position: absolute; z-index: 5; display: flex; gap: var(--s2); }
.micro-controls.top-right { top: var(--s4); right: var(--s4); }
.micro-btn {
  width: 38px; height: 38px; border-radius: 12px; font-size: 15px;
  background: rgba(8,10,20,0.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  transition: transform 0.15s var(--ease), background 0.2s;
}
.micro-btn:hover { transform: translateY(-1px); background: rgba(8,10,20,0.75); }
.micro-btn.off { opacity: 0.55; }

/* Local PiP video */
.local-video {
  position: absolute; z-index: 8;
  width: 220px; height: 150px;
  right: var(--s4); 
  /* bottom: var(--s4); */
  border: 1.5px solid var(--stroke-strong);
  background: #06080f;
  transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.local-video:hover { transform: scale(1.03); box-shadow: 0 22px 60px rgba(0,0,0,0.6); }
.local-fill {
  background:
    linear-gradient(135deg, rgba(217,138,78,0.12), transparent 55%),
    radial-gradient(120% 120% at 70% 30%, #3d2a22 0%, #281a14 50%, #160d0a 100%);
}
.local-off, .local-muted {
  position: absolute; z-index: 4;
}
.local-off {
  inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: rgba(6,8,15,0.85); color: var(--text-dim); font-size: 13px;
}
.local-off span:first-child { font-size: 26px; }
.local-muted {
  top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 13px;
  background: rgba(255,92,108,0.85);
}

/* ===================================================================
   DESKTOP VIDEO LAYOUT TOGGLE — PiP <-> Split (normal video mode only)
   The button and the split layout are scoped to confirmed desktop sizes
   via the media query below, so mobile (portrait + short landscape) and
   whiteboard mode are never affected.
=================================================================== */
.layout-toggle {
  position: absolute; z-index: 5;
  top: 48px; left: var(--s3);   /* top-left area, below the status badge */
  display: none;                /* shown only on desktop, non-board (see media query) */
  align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 12px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: rgba(8,10,20,0.5);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  transition: transform 0.15s var(--ease), background 0.2s;
  z-index: 9;  /* above the local PiP video */
}
.layout-toggle:hover { transform: translateY(-1px); background: rgba(8,10,20,0.75); }
.layout-toggle .lt-ico { font-size: 15px; line-height: 1; }

@media (min-width: 901px) and (min-height: 521px) {
  /* Toggle is available only in desktop normal-video mode (not whiteboard) */
  body:not(.board-mode) .layout-toggle { display: inline-flex; }

  /* Split mode: remote + local become two equal side-by-side halves.
     Only PiP-specific positioning is overridden; card styling is kept. */
  body.video-split-mode .remote-video {
    right: auto; width: calc(50% - 3px);   /* left half (inset:0 keeps top/bottom/left) */
  }
  body.video-split-mode .local-video {
    top: 0; bottom: 0; left: auto; right: 0;
    width: calc(50% - 3px); height: auto;
    transform: none;
  }
  body.video-split-mode .local-video:hover { transform: none; }
}

/* ===================================================================
   WHITEBOARD
=================================================================== */
.whiteboard {
  position: absolute; inset: 0; z-index: 7;
}

/* ---- 3-column grid (desktop): left 480 · flexible square · right 480 ---- */
.board-grid {
  display: grid;
  grid-template-columns: clamp(320px, 26vw, 480px) minmax(0, 1fr) clamp(320px, 26vw, 480px);
  gap: var(--s3);
  height: 100%;
  min-height: 0; min-width: 0;
}
.board-col {
  display: flex; flex-direction: column; gap: var(--s3);
  min-height: 0; min-width: 0;
}

/* Video card in board columns — square, max 480, shrinks on small desktops */
.board-video {
  position: relative;
  width: 100%; aspect-ratio: 1 / 1;
  max-width: 480px; max-height: 480px;
  align-self: center;
  border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--stroke); box-shadow: var(--shadow-soft);
  background: #06080f;
  flex-shrink: 0;
}

/* Tool / emoji panels fill the rest of the column */
.board-panel {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s4);
  border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--stroke);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  overflow-y: auto;
}
.board-panel-title { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.board-sub { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; margin-top: var(--s1); }

.tool-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tool-btn {
  width: 44px; height: 44px; border-radius: 13px; font-size: 18px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.15s var(--ease), background 0.2s;
}
.tool-btn:hover { transform: translateY(-1px); }
.tool-btn.active { background: var(--accent-grad); border-color: transparent; }
.tool-btn.warn { background: rgba(255,92,108,0.16); color: var(--danger); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.brush-row { display: flex; align-items: center; gap: var(--s3); }
#brushSize { flex: 1; accent-color: var(--accent); }
.brush-preview {
  width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center;
}
.brush-preview::after {
  content: ""; width: var(--dot, 8px); height: var(--dot, 8px);
  border-radius: 50%; background: var(--swatch, #fff);
}
.brush-num {
  min-width: 26px; flex-shrink: 0; text-align: right;
  font-size: 13px; font-weight: 700; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---- Unified color chip (shared by desktop sidebar + mobile sheet) ---- */
.color-swatches, .color-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s1);
}
.color {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--stroke);
  transition: transform 0.12s var(--ease), box-shadow 0.15s;
}
.color[data-color="#ffffff"] { border-color: rgba(0, 0, 0, 0.45); }
.color:hover { transform: scale(1.1); }
.color.active { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); transform: scale(1.1); }

.board-exit { margin-top: auto; flex: none; }

/* Emoji palette */
.emoji-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2);
  margin-top: var(--s1);
}
.emoji-btn {
  aspect-ratio: 1 / 1; border-radius: 14px; font-size: 26px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.12s var(--ease), background 0.2s, border-color 0.2s;
}
.emoji-btn:hover { transform: translateY(-2px); background: rgba(196,61,84,0.12); }
.emoji-btn.active { border-color: var(--accent); background: rgba(196,61,84,0.2); transform: scale(1.05); }

/* Center square canvas */
.board-center {
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
}
.board-canvas-wrap {
  position: relative;
  width: 100%; height: 100%;       /* JS sets a square px size on desktop */
  border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--stroke); box-shadow: var(--shadow-lift);
}
#board {
  width: 100%; height: 100%; display: block;
  cursor: crosshair; touch-action: none;
  background:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 28px 28px,
    #0e1322;
}
.board-canvas-wrap.placing #board { cursor: cell; }

/* ===================================================================
   BOTTOM DOCK #0e1322
=================================================================== */
.dock {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--s1) + env(safe-area-inset-bottom));
  height: var(--dock-h);
  display: flex; align-items: center; gap: 3px;
  padding: 0 10px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-lift);
  max-width: calc(100vw - 24px);
}
.dock-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 52px; height: 48px; padding: 0 8px; border-radius: 15px;
  color: var(--text-dim); font-size: 10px; font-weight: 600;
  transition: background 0.2s, color 0.2s, transform 0.15s var(--ease);
}
.dock-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); transform: translateY(-2px); }
.dock-btn.active { color: var(--text); background: rgba(196,61,84,0.16); }
.dock-ico { font-size: 18px; line-height: 1; }
.dock-btn.search {
  background: var(--accent-grad); color: #fff; min-width: 64px;
  box-shadow: 0 10px 26px rgba(196,61,84,0.45);
}
.dock-btn.search:hover { transform: translateY(-2px) scale(1.02); }
.dock-btn.search.searching { background: linear-gradient(135deg, #ffb15c, #ffd23f); color: #1a1a1a; }
.dock-btn.toggle.off { color: var(--danger); background: rgba(255,92,108,0.12); }
.dock-sep { width: 1px; height: 28px; background: var(--stroke); margin: 0 3px; flex-shrink: 0; }
.dock-dot {
  position: absolute; top: 6px; right: 10px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--pink);
  border: 2px solid var(--bg-1);
}

/* ===================================================================
   PANELS / BOTTOM SHEETS
=================================================================== */
.backdrop {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(4,6,12,0.5);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.backdrop.show { opacity: 0; } /* opacity: 1; */

.panel {
  position: fixed; z-index: 50;
  top: calc(var(--header-h) + env(safe-area-inset-top) + 8px);
  right: var(--s4);
  width: 380px; max-width: calc(100vw - 32px);
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + var(--s3));
  display: flex; flex-direction: column;
  background: var(--surface);
  backdrop-filter: blur(26px) saturate(150%); -webkit-backdrop-filter: blur(26px) saturate(150%);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lift);
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
  overflow: hidden;
}
.panel.open { transform: translateX(0); opacity: 1; }

.panel-grip { display: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4) var(--s5) var(--s3);
  flex-shrink: 0;
}
.panel-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.panel-close {
  width: 34px; height: 34px; border-radius: 50%; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: background 0.2s, transform 0.15s var(--ease);
}
.panel-close:hover { background: rgba(255,255,255,0.12); transform: rotate(90deg); }
.panel-hint { padding: 0 var(--s5) var(--s2); color: var(--text-dim); font-size: 13px; }

/* ---- Chat ---- */
.chat-body {
  flex: 1; overflow-y: auto; padding: var(--s3) var(--s5);
  display: flex; flex-direction: column; gap: 10px;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }
.msg {
  max-width: 78%; padding: 10px 14px; border-radius: 18px;
  font-size: 14px; line-height: 1.4; word-wrap: break-word;
  animation: msgIn 0.3s var(--ease);
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg.in {
  align-self: flex-start; background: var(--surface-2);
  border: 1px solid var(--stroke); border-bottom-left-radius: 6px;
}
.msg.out {
  align-self: flex-end; background: var(--accent-grad); color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.system {
  align-self: center; background: transparent; color: var(--text-faint);
  font-size: 12px; padding: 4px 10px;
}
.msg .time { display: block; font-size: 10px; opacity: 0.6; margin-top: 3px; }

.typing-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 var(--s5) var(--s2); color: var(--text-faint); font-size: 12px;
}
.typing-bubble {
  display: inline-flex; gap: 3px; padding: 8px 12px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--stroke);
}
.typing-bubble span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim);
  animation: typing 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: var(--s3) var(--s4); flex-shrink: 0;
  border-top: 1px solid var(--stroke);
}
.chat-emoji { font-size: 20px; width: 38px; height: 38px; border-radius: 50%; transition: background 0.2s; }
.chat-emoji:hover { background: rgba(255,255,255,0.08); }
.chat-input input {
  flex: 1; height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text);
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.chat-input input:focus { border-color: var(--accent); }
.chat-send {
  width: 42px; height: 42px; border-radius: 50%; font-size: 16px; color: #fff;
  background: var(--accent-grad); flex-shrink: 0;
  transition: transform 0.15s var(--ease);
}
.chat-send:hover { transform: scale(1.08); }
.chat-send:active { transform: scale(0.95); }

/* ---- Gifts ---- */
.wallet-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 var(--s5) var(--s3); padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--stroke);
}
.wallet-coins { font-size: 14px; }
.wallet-coins strong { color: var(--gold); font-size: 16px; }
.btn-soft {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(196,61,84,0.18); color: #f0c9c0; border: 1px solid rgba(196,61,84,0.3);
  transition: background 0.2s;
}
.btn-soft:hover { background: rgba(196,61,84,0.3); }
.gift-grid {
  flex: 1; overflow-y: auto; padding: 0 var(--s5) var(--s5);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3);
}
.gift-grid::-webkit-scrollbar { width: 6px; }
.gift-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }
.gift-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.18s var(--ease), border-color 0.2s, background 0.2s;
}
.gift-card:hover { transform: translateY(-3px); border-color: var(--stroke-strong); background: rgba(196,61,84,0.12); }
.gift-card:active { transform: scale(0.96); }
.gift-emoji { font-size: 32px; line-height: 1; }
.gift-img { width: 54px; height: 54px; object-fit: contain; display: block; border-radius: 10px; }
.gift-name { font-size: 12px; font-weight: 600; }
.gift-price { font-size: 11px; color: var(--gold); font-weight: 700; }

/* ---- Profile ---- */
.profile-card { flex: 1; overflow-y: auto; padding: 0 var(--s5) var(--s5); }
.profile-cover {
  height: 96px; border-radius: var(--r-sm); margin-bottom: -42px;
  background: linear-gradient(120deg, #c43d54, #d98a4e 55%, #e0668a);
}
.profile-avatar {
  width: 84px; height: 84px; border-radius: 26px; margin: 0 auto;
  display: grid; place-items: center; position: relative;
  background: var(--accent-grad); font-size: 34px; font-weight: 800; color: #fff;
  border: 4px solid var(--bg-1); box-shadow: var(--shadow-soft);
}
.profile-name { text-align: center; font-size: 19px; font-weight: 800; margin-top: var(--s3); }
.lvl-badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; vertical-align: middle;
  background: rgba(255,210,63,0.18); color: var(--gold); font-weight: 700;
}
.profile-loc { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.profile-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2);
  margin: var(--s4) 0; padding: var(--s4) 0;
  border-top: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke);
}
.pstat { text-align: center; }
.pstat strong { display: block; font-size: 20px; font-weight: 800; }
.pstat span { font-size: 11px; color: var(--text-faint); }
.login-prompt {
  margin: var(--s4) 0; padding: var(--s4); border-radius: var(--r-md);
  background: rgba(196,61,84,0.1); border: 1px solid rgba(196,61,84,0.25);
  text-align: center;
}
.login-prompt p { font-size: 13px; color: var(--text-dim); margin-bottom: var(--s3); }
.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border-radius: 14px; font-weight: 600; font-size: 14px;
  background: #fff; color: #1a1a1a;
  transition: transform 0.15s var(--ease);
}
.btn-google:hover { transform: translateY(-1px); }
.g-ico {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#ea4335, #fbbc05, #34a853, #4285f4); color: #fff; font-weight: 800; font-size: 13px;
}
.profile-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.btn-primary, .btn-ghost {
  flex: 1; padding: 13px; border-radius: 14px; font-weight: 700; font-size: 14px;
  transition: transform 0.15s var(--ease), background 0.2s;
}
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 22px rgba(196,61,84,0.35); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--stroke); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

/* ---- Interests ---- */
.interest-input { display: flex; gap: 8px; padding: 0 var(--s5) var(--s3); }
.interest-input input {
  flex: 1; height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text);
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.interest-input input:focus { border-color: var(--accent); }
.interest-input button {
  width: 42px; height: 42px; border-radius: 50%; font-size: 20px; color: #fff;
  background: var(--accent-grad); flex-shrink: 0; transition: transform 0.15s var(--ease);
}
.interest-input button:hover { transform: scale(1.08); }
.tag-section { padding: 0 var(--s5) var(--s3); }
.tag-section-title { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: var(--s2); font-weight: 700; }
.selected-tags, .suggested-tags { display: flex; flex-wrap: wrap; gap: 8px; min-height: 34px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.15s var(--ease), background 0.2s;
  animation: msgIn 0.25s var(--ease);
}
.pill.selected { background: rgba(196,61,84,0.18); border-color: rgba(196,61,84,0.4); color: #f0c9c0; }
.pill.suggested { cursor: pointer; }
.pill.suggested:hover { background: rgba(196,61,84,0.14); transform: translateY(-1px); }
.pill .x { cursor: pointer; opacity: 0.6; font-size: 14px; }
.pill .x:hover { opacity: 1; }
.interest-actions { display: flex; gap: var(--s2); padding: var(--s3) var(--s5) var(--s5); margin-top: auto; border-top: 1px solid var(--stroke); }

/* ===================================================================
   GIFT FX + TOAST
=================================================================== */
.gift-fx { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.gift-particle {
  position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%);
  font-size: 90px; will-change: transform, opacity;
  animation: giftPop 2.2s var(--ease) forwards;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.5));
}
.gift-particle-img { width: 170px; height: 170px; object-fit: contain; display: block; }
@keyframes giftPop {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.25) rotate(4deg); opacity: 1; }
  40%  { transform: translate(-50%, -55%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(0.7) rotate(0deg); opacity: 0; }
}
.gift-spark {
  position: absolute; font-size: 24px; left: 50%; top: 55%;
  animation: spark 1.6s ease-out forwards;
}
@keyframes spark {
  0% { transform: translate(-50%,-50%) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1); opacity: 0; }
}

.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 70;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  padding: 11px 20px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(18,22,38,0.92); border: 1px solid var(--stroke-strong);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  animation: toastIn 0.35s var(--ease), toastOut 0.35s var(--ease) 2.4s forwards;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px) scale(0.95); } }

@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } }

/* ===================================================================
   BOARD MODE
   Desktop: the 3-column grid carries its own 480² videos, so the
   normal stage videos are hidden. (Stacked layout re-shows a PiP below.)
=================================================================== */
body.board-mode .remote-video,
body.board-mode .local-video { display: none; }

/* ---- Board stacked layout: tablets & narrow screens (<= 900px) ---- */
@media (max-width: 900px) {
  .board-grid {
    display: flex; flex-direction: column; gap: var(--s2);
    height: 100%;
  }
  .board-video { display: none; }            /* use a floating PiP instead */
  .board-center { order: 0; flex: 1 1 0; min-height: 140px; }
  .board-col { order: 1; flex: 0 0 auto; flex-direction: column; gap: var(--s2); }
  .board-right { order: 2; }
  /* drawing tools move into the bottom-sheet, so hide the in-column tools */
  .board-left { display: none; }
  /* fab visibility is handled in the .board-fab section below (see note there) */
  .board-panel {
    padding: var(--s2) var(--s3);
    overflow-x: auto; overflow-y: hidden;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    background: var(--surface-2);
  }
  .board-panel-title, .board-sub, .board-exit, .brush-row { display: none; }
  .tool-row { flex-wrap: nowrap; }
  .color-swatches { display: flex; flex-wrap: nowrap; gap: 6px; margin-top: 6px; }
  .swatch { width: 28px; height: 28px; flex: 0 0 auto; max-width: none; }
  .emoji-grid { display: flex; flex-wrap: nowrap; gap: 6px; }
  .emoji-btn { width: 46px; flex: 0 0 auto; font-size: 24px; }

  /* one stranger PiP stays visible while drawing */
  body.board-mode .remote-video {
    display: block;
    inset: auto; top: var(--s3); right: var(--s3); left: auto; bottom: auto;
    width: 116px; height: 116px; z-index: 9; border-radius: var(--r-md);
  }
  body.board-mode .remote-video .status-overlay,
  body.board-mode .remote-video .micro-controls,
  body.board-mode .remote-video .stranger-info,
  body.board-mode .remote-video .video-badge { display: none; }
}

/* ===================================================================
   MOBILE DRAWING TOOLS — floating brush button + bottom-sheet panel
   Desktop is untouched: the fab and this panel are hidden above 900px.
=================================================================== */
.board-fab {
  /* anchored to the visible #whiteboard container (position:absolute; inset:0) */
  position: absolute; top: 12px; left: 12px; z-index: 1000;
  width: 48px; height: 48px; border-radius: 50%;
  display: none;                         /* base: hidden (overridden for board mode below) */
  align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; color: #fff;
  background: var(--accent-grad);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 8px 22px rgba(196, 61, 84, 0.45);
  transition: transform 0.15s var(--ease);
}
.board-fab:active { transform: scale(0.92); }

/* Show the fab whenever the board is open — at ANY width. This intentionally does
   NOT rely on a max-width media query matching, so it can't silently fail on devices
   whose CSS width sits near the breakpoint. It is declared AFTER the base rule and has
   higher specificity (body.board-mode .board-fab), so it always wins in board mode. */
body.board-mode .board-fab { display: flex; }

/* Keep the DESKTOP 3-column board untouched: there the tools live in the left column,
   so hide the fab on confirmed desktop widths only. */
@media (min-width: 901px) {
  body.board-mode .board-fab { display: none; }
}

.dt-body { padding: 0 var(--s5) var(--s3); overflow-y: auto; }
.dt-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
.dt-tool {
  flex: 1 1 auto; min-width: 64px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 46px; padding: 0 10px; border-radius: 14px;
  font-size: 18px; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--stroke);
  transition: transform 0.12s var(--ease), background 0.2s;
}
.dt-tool span { font-size: 12px; }
.dt-tool:active { transform: scale(0.96); }
.dt-tool.active { background: var(--accent-grad); border-color: transparent; }
.dt-tool.warn { background: rgba(255, 92, 108, 0.16); color: var(--danger); }
.dt-tool:disabled { opacity: 0.4; }
.dt-exit { margin: var(--s1) var(--s5) var(--s4); flex: none; }

/* Mobile drawing-tools sheet: brush row + colors (labels NOT using .board-sub
   so they survive the <=900px hide rule) */
.dt-brush {
  display: flex; align-items: center; gap: var(--s3);
  margin-bottom: var(--s3);
}
.dt-brush input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.dt-brush-label, .dt-colors-label {
  font-size: 11px; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.6px; font-weight: 700; flex-shrink: 0;
}
.dt-colors-label { display: block; margin-bottom: var(--s2); }

/* Belt-and-braces: never show the mobile tools sheet on desktop */
@media (min-width: 901px) {
  #panel-drawingTools { display: none !important; }
}

/* ===================================================================
   RESPONSIVE — TABLET
=================================================================== */
@media (max-width: 980px) {
  .panel { width: 360px; }
}

/* ===================================================================
   RESPONSIVE — MOBILE (portrait & general small screens)
=================================================================== */
@media (max-width: 720px) {
  :root { --dock-h: 72px; --header-h: 56px; }

  .brand-name { font-size: 17px; }
  /* .stat-pill.gifts-pill { display: none; } */
  .app-header { gap: var(--s2); padding: 0 var(--s3); }
  .header-stats { gap: 6px; }
  .stat-pill { padding: 6px 10px; font-size: 12px; }

  .desktop-only { display: none !important; }

  /* Stage: stacked videos top/bottom */
  .stage {
    left: var(--s2); right: var(--s2);
    bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + var(--s2));
  }
  .remote-video {
    inset: auto; top: 0; left: 0; right: 0; height: calc(50% - 5px);
    border-radius: var(--r-xs);
  }
  .local-video {
    position: absolute;
    inset: auto; bottom: 0; left: 0; right: 0;
    width: auto; height: calc(50% - 5px);
    border-radius: var(--r-xs);
  }
  .local-video:hover { transform: none; }

  .status-title { font-size: 17px; }
  .status-sub { font-size: 12px; }
  .start-btn { padding: 12px 22px; font-size: 14px; }
  .stranger-info { bottom: var(--s2); left: var(--s2); padding: 8px 10px 8px 8px; }
  .stranger-avatar { width: 38px; height: 38px; }

  /* Dock becomes app nav bar, full width */
  .dock {
    left: var(--s2); right: var(--s2); transform: none;
    width: auto; max-width: none;
    border-radius: var(--r-xs);
    justify-content: space-around; gap: 0; padding: 0 6px;
  }
  .dock-sep { display: none; }
  .dock-btn { min-width: 0; flex: 1; }
  .dock-btn.search { flex: 1.2; }
  .dock-label { font-size: 10px; }
  .dock-ico { font-size: 20px; }

  /* Panels become bottom sheets */
  .panel {
    top: auto;  bottom: 0;  left: var(--s2); right: var(--s2);  
    
    width: auto; 
    max-width: 100%;

    max-height: 82vh; max-height: 82dvh;
    height: auto;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.open { transform: translateY(0); }
  .panel-grip {
    display: block; width: 42px; height: 5px; border-radius: 99px;
    background: rgba(255,255,255,0.22); margin: 10px auto 2px;
  }
  .panel-head { padding-top: var(--s2); }
  #panel-chat { height: 70vh; height: 70dvh; }
  .gift-grid { grid-template-columns: repeat(3, 1fr); }

  .toast-wrap { bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 20px); }
  .board-palette { gap: 6px; padding: 8px 10px; }
  .tool-btn { width: 38px; height: 38px; font-size: 15px; }
  #brushSize { width: 60px; }
}

/* ===================================================================
   RESPONSIVE — MOBILE LANDSCAPE (short height)
=================================================================== */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 960px) {
  :root { --dock-h: 60px; --header-h: 48px; }
  /* Side-by-side videos in landscape */
  .remote-video {
    inset: auto; top: 0; left: 0; bottom: 0; right: auto;
    width: calc(60% - 4px); height: auto;
  }
  .local-video {
    inset: auto; top: 0; bottom: 0; right: 0; left: auto;
    width: calc(40% - 4px); height: auto;
  }
  .dock-label { display: none; }
  .dock-btn { height: 46px; }
  .panel { max-height: 92vh; max-height: 92dvh; }
  .gift-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.05ms !important; }
}

/* ---- Integration additions (auto-search toggle + whiteboard remote-lock) ---- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; cursor: pointer; inset: 0; background: rgba(255,255,255,0.18); border-radius: 26px; transition: .3s; }
.switch-slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.switch input:checked + .switch-slider { background: var(--accent, #c43d54); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

.board-lock-status {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 6; display: none; padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none;
  background: rgba(8,10,20,0.75); border: 1px solid var(--stroke, rgba(255,255,255,0.12)); color: #ffd23f;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
