/* ============================================================
   SHADOWCHAT — Cyberpunk / Neon Theme
   ============================================================ */

:root {
  --bg: #07070d;
  --bg-2: #0d0d18;
  --panel: rgba(15, 15, 30, 0.85);
  --panel-2: rgba(20, 20, 40, 0.9);
  --line: rgba(0, 240, 255, 0.25);

  --neon-cyan: #00f0ff;
  --neon-pink: #ff2bd6;
  --neon-purple: #b14bff;
  --neon-yellow: #f6ff00;
  --neon-green: #00ff95;
  --neon-red: #ff3860;

  --text: #d9e2ff;
  --text-dim: #7a8aab;
  /* Brighter member of the same cool-blue ramp — keeps small static labels
     (timestamps, counts, meta) crisp without a glow. Never used as an accent. */
  --text-dim2: #95a6c9;

  /* Redesign tokens — consistent radii + reusable glow/depth recipes so neon
     stays disciplined: glow lives on large/interactive surfaces, soft depth on
     bubbles, not on every small label. */
  --r-bubble: 14px;
  --r-ctl: 10px;
  --r-md: 10px;
  --r-pill: 999px;
  --msg-av: 40px;
  --glow-cyan: 0 0 12px rgba(0, 240, 255, 0.35);
  --glow-pink: 0 0 12px rgba(255, 43, 214, 0.4);
  --depth-bubble: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.35);
  --surface-card:
    linear-gradient(145deg, rgba(0, 240, 255, 0.055), transparent 36%),
    linear-gradient(315deg, rgba(255, 43, 214, 0.045), transparent 42%),
    var(--panel);
  --surface-card-quiet:
    linear-gradient(145deg, rgba(0, 240, 255, 0.04), transparent 44%),
    rgba(0, 0, 0, 0.28);
  --line-soft: rgba(0, 240, 255, 0.16);
  --shadow-panel: 0 18px 42px rgba(0, 0, 0, 0.28), 0 0 18px rgba(0, 240, 255, 0.08);

  --font-display: 'Orbitron', 'Share Tech Mono', system-ui, sans-serif;
  --font-mono: 'Share Tech Mono', ui-monospace, monospace;
}

/* Smooth scroll for in-page anchors (e.g. /coins#pro-monthly deep-links from
   the /account claim nudge). The reduced-motion media query below overrides
   to auto for users who prefer no motion. */
html { scroll-behavior: smooth; }

/* Accessibility: "skip to main content" — first focusable element, hidden off-screen
   until focused (keyboard/screen-reader users bypass the repeated topbar nav). WCAG
   2.4.1. z above the topbar (10) + drawers (220) + lock-overlay (9999). */
.skip-link {
  position: absolute; left: 0; top: 0; z-index: 10000;
  transform: translateY(-120%);
  background: var(--bg-2); color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan); border-radius: var(--r-ctl, 8px);
  padding: 0.6rem 1rem; font-family: var(--font-mono, monospace); text-decoration: none;
  transition: transform 0.15s ease;
}
.skip-link:focus, .skip-link:focus-visible {
  transform: translateY(0); outline: 2px solid var(--neon-cyan);
}

/* Persistent coin balance pill injected into .topbar by /js/header-coin-pill.js
   on logged-in app pages (chat / board / online / profile / coins / billing).
   /account already has its own #coin-balance in head-actions; the pill skips
   that page automatically. */
.header-coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.125rem;
  margin: 0 0.6rem 0 auto;
  padding: 0.32rem 0.7rem;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.header-coin-pill:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}
.header-coin-pill .pill-icon { font-size: 0.95rem; line-height: 1; }
.header-coin-pill .pill-val { font-weight: 700; }
@media (max-width: 520px) {
  /* Tighter spacing on phones so the pill, burger, and logo all fit. */
  .header-coin-pill { padding: 0.28rem 0.55rem; font-size: 0.8rem; margin-right: 0.4rem; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Accessibility: a visible keyboard-focus ring. :focus-visible matches only
 * keyboard/AT focus (not mouse clicks, so mouse UX is unchanged), and any
 * element with its own :focus style wins on specificity — this just fills the
 * gap for the many buttons and links that had no focus indicator. */
:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 2px; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

body {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(177, 75, 255, 0.25), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 240, 255, 0.18), transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 43, 214, 0.12), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

/* ---------- decorative overlays ---------- */
.scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 240, 255, 0.03) 0px,
    rgba(0, 240, 255, 0.03) 1px,
    transparent 2px,
    transparent 4px
  );
  pointer-events: none;
  z-index: 1000;
  mix-blend-mode: screen;
}
.grid-bg {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.06) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.topbar {
  position: relative;
  z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.2rem 2.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.logo {
  display: flex; flex-direction: column;
}
.logo-glitch {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  color: var(--neon-cyan);
  text-shadow:
    0 0 8px var(--neon-cyan),
    0 0 20px rgba(0, 240, 255, 0.5);
  position: relative;
  display: inline-block;
}
.logo-glitch.pink {
  color: var(--neon-pink);
  text-shadow:
    0 0 8px var(--neon-pink),
    0 0 20px rgba(255, 43, 214, 0.5);
}
.logo-glitch::before,
.logo-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.logo-glitch::before {
  color: var(--neon-pink);
  transform: translate(2px, 0);
  mix-blend-mode: screen;
  opacity: 0.6;
  animation: glitch1 3s infinite linear alternate;
}
.logo-glitch::after {
  color: var(--neon-purple);
  transform: translate(-2px, 0);
  mix-blend-mode: screen;
  opacity: 0.5;
  animation: glitch2 2.5s infinite linear alternate;
}
@keyframes glitch1 {
  0% { clip-path: inset(0 0 80% 0); }
  50% { clip-path: inset(40% 0 30% 0); }
  100% { clip-path: inset(80% 0 0 0); }
}
@keyframes glitch2 {
  0% { clip-path: inset(70% 0 0 0); }
  50% { clip-path: inset(20% 0 50% 0); }
  100% { clip-path: inset(0 0 70% 0); }
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.2em;
}

.status-pill {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--neon-green);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--neon-green);
  text-shadow: 0 0 6px var(--neon-green);
  letter-spacing: 0.1em;
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero {
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4rem;
  padding: 4rem 4rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 2rem; gap: 2rem; }
}

.title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: 0.03em;
  margin-bottom: 1.5rem;
}
.neon-pink   { color: var(--neon-pink);   text-shadow: 0 0 12px var(--neon-pink),   0 0 30px rgba(255,43,214,0.5); }
.neon-cyan   { color: var(--neon-cyan);   text-shadow: 0 0 12px var(--neon-cyan),   0 0 30px rgba(0,240,255,0.5); }
.neon-purple { color: var(--neon-purple); text-shadow: 0 0 12px var(--neon-purple), 0 0 30px rgba(177,75,255,0.5); }

.lead {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 2rem;
  line-height: 1.7;
}
.lead strong { color: var(--neon-cyan); font-weight: 400; }

.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 1.2rem;
  margin-bottom: 2rem;
}
.feat {
  font-size: 0.9rem;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 0.6rem;
}
.feat-icon {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
  font-size: 1.2rem;
}

.cta {
  display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.warn {
  font-size: 0.8rem;
  color: var(--neon-yellow);
  opacity: 0.85;
}

/* ---------- Neon Buttons ---------- */
.btn-neon {
  position: relative;
  /* inline-block so <a class="btn-neon"> gets the same reliable box model
   * as <button> (default inline-block). Without this an <a> is `inline`,
   * and the clip-path + vertical padding render inconsistently. */
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  padding: 0.85rem 1.6rem;
  border: 2px solid var(--neon-cyan);
  background: transparent;
  color: var(--neon-cyan);
  cursor: pointer;
  text-transform: uppercase;
  transition: color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.12s ease;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
  text-shadow: 0 0 8px var(--neon-cyan);
  overflow: hidden;
  isolation: isolate;
}
.btn-neon::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--neon-cyan);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: -1;
}
.btn-neon:hover {
  color: var(--bg);
  box-shadow: 0 0 20px var(--neon-cyan), inset 0 0 12px rgba(0, 240, 255, 0.4);
  text-shadow: none;
}
.btn-neon:hover::before { opacity: 1; }
.btn-neon:focus-visible {
  color: var(--bg);
  outline: 2px solid var(--neon-cyan);
  outline-offset: 4px;
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.62), inset 0 0 12px rgba(0, 240, 255, 0.42);
  text-shadow: none;
}
.btn-neon:focus-visible::before { opacity: 1; }
.btn-neon:active:not(:disabled) { transform: translateY(1px); }
.btn-neon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn-neon:disabled::before { opacity: 0; }
.btn-neon:disabled:hover {
  color: var(--neon-cyan);
  box-shadow: none;
  text-shadow: 0 0 8px var(--neon-cyan);
}
.btn-neon.btn-secondary {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
}
.btn-neon.btn-secondary::before { background: var(--neon-pink); }
/* On hover the ::before fills the button, so the text MUST flip to the
 * dark bg colour. The modifier rules below set a neon text colour at the
 * same specificity as .btn-neon:hover but later in source, which would
 * otherwise win on hover and leave neon-on-neon (invisible) text — so the
 * :hover rules here re-assert the dark colour with higher specificity. */
.btn-neon.btn-secondary:hover {
  color: var(--bg);
  box-shadow: 0 0 20px var(--neon-pink), inset 0 0 12px rgba(255,43,214,0.4);
}
.btn-neon.btn-secondary:focus-visible {
  color: var(--bg);
  outline-color: var(--neon-pink);
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.62), inset 0 0 12px rgba(255,43,214,0.42);
}
.btn-neon.btn-secondary:disabled:hover {
  color: var(--neon-pink);
  box-shadow: none;
  text-shadow: 0 0 8px var(--neon-pink);
}
/* btn-primary = the clean cyan neon look (matches base .btn-neon, pairs
 * with the pink btn-secondary). Kept simple to stay consistent with the
 * outline-neon theme — no gradient fill. Anchors don't underline
 * (text-decoration:none inherited from .btn-neon). */
.btn-neon.btn-primary { color: var(--neon-cyan); text-decoration: none; }
.btn-neon.btn-primary:hover { color: var(--bg); }
.btn-neon.full { width: 100%; }

/* ---------- Landing refresh: social economy homepage ---------- */
.landing .topbar.home-topbar {
  position: relative;
  z-index: 20;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(7, 7, 13, 0.72);
}
.landing .topnav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.landing .topnav a {
  white-space: nowrap;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  font-size: clamp(0.66rem, 1.25vw, 0.82rem);
  letter-spacing: 0.08em;
}
.landing .topnav .nav-btn {
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
}
.landing .topnav .nav-btn.primary {
  background: transparent;
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  text-shadow: 0 0 4px var(--neon-pink);
}
.landing .topnav .nav-btn.primary:hover {
  background: var(--neon-pink);
  color: var(--bg);
  text-shadow: none;
  box-shadow: 0 0 15px var(--neon-pink);
}

.home-main {
  position: relative;
  z-index: 5;
}
.home-hero {
  position: relative;
  min-height: calc(100svh - 148px);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(90deg, rgba(7, 7, 13, 0.92) 0%, rgba(7, 7, 13, 0.74) 42%, rgba(7, 7, 13, 0.26) 74%),
    linear-gradient(0deg, rgba(7, 7, 13, 0.82) 0%, rgba(7, 7, 13, 0.12) 42%, rgba(7, 7, 13, 0.66) 100%),
    url('/img/home-social-hero.webp');
  background-size: cover;
  background-position: center;
  transform: scale(1.01);
}
.home-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 43, 214, 0.035) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(90deg, black 0%, rgba(0,0,0,0.75) 44%, transparent 92%);
}
.home-hero-inner {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2.8rem, 6vw, 5.4rem) min(32vw, 400px) clamp(3.8rem, 7vw, 6rem) 0;
}
.home-kicker {
  margin: 0 0 0.9rem;
  color: var(--neon-green);
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 1vw, 0.82rem);
  letter-spacing: 0.16em;
  line-height: 1.5;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0, 255, 149, 0.65);
}
.home-title {
  max-width: 820px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 5.1rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.18;
  text-shadow:
    0 0 12px rgba(0, 240, 255, 0.45),
    0 0 28px rgba(255, 43, 214, 0.28);
}
.home-title span {
  display: block;
  padding-bottom: 0.04em;
}
.home-title span:first-child {
  color: var(--neon-cyan);
}
.home-title span:last-child {
  color: var(--neon-pink);
}
.home-copy {
  max-width: 640px;
  margin: 1.2rem 0 0;
  color: var(--text);
  font-size: clamp(0.98rem, 1.5vw, 1.12rem);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.home-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.7rem;
}
.home-inline-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.125rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.06);
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-shadow: 0 0 7px rgba(0, 240, 255, 0.55);
}
.home-inline-link:hover {
  color: var(--neon-green);
  border-color: rgba(0, 255, 149, 0.38);
  background: rgba(0, 255, 149, 0.08);
  text-shadow: 0 0 8px rgba(0, 255, 149, 0.65);
}
.home-warning {
  max-width: 640px;
  margin: 1.1rem 0 0;
  color: var(--neon-yellow);
  font-size: 0.86rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  text-shadow: 0 0 8px rgba(246, 255, 0, 0.35);
}

.home-signal-strip {
  position: relative;
  z-index: 7;
  width: min(1180px, calc(100% - 2rem));
  margin: -2.15rem auto 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.home-signal-card {
  min-height: 118px;
  padding: 1rem;
  border: 1px solid rgba(0, 240, 255, 0.34);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(15, 15, 30, 0.92), rgba(7, 7, 13, 0.82));
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.13);
}
.signal-label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
}
.home-signal-card strong {
  display: block;
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1.18;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.65);
  overflow-wrap: anywhere;
}
.signal-note {
  display: block;
  margin-top: 0.4rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.45;
}
.home-social-section {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5rem) 0 2rem;
}
.home-flow-section {
  padding-bottom: clamp(2.2rem, 5vw, 4rem);
}
.home-flow-layout {
  display: grid;
  grid-template-columns: minmax(290px, 0.85fr) minmax(0, 1.25fr);
  gap: clamp(1.2rem, 3vw, 2.4rem);
  align-items: start;
}
.home-flow-copy {
  position: sticky;
  top: 1rem;
  padding-top: 0.25rem;
}
.home-flow-copy .section-title,
.home-route-head .section-title,
.home-tier-head .section-title {
  margin: 0;
  text-align: left;
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  letter-spacing: 0;
  line-height: 1.16;
}
.home-section-copy {
  max-width: 46rem;
  margin: 0.9rem 0 1.2rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}
.section-head .section-title {
  margin: 0;
  text-align: left;
}
.home-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.home-route-head {
  grid-column: 1 / -1;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.home-card {
  min-height: 198px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 15, 30, 0.78);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.home-card:hover {
  transform: translateY(-3px);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.2);
}
.home-card-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-shadow: 0 0 8px var(--neon-cyan);
}
.home-card-icon.gold {
  border-color: var(--neon-yellow);
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(246, 255, 0, 0.8);
}
.home-card-icon.pink {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
}
.home-card strong {
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.08em;
}
.home-card span:last-child {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.65;
}
.home-play-loop {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.home-flow-copy .home-play-loop {
  grid-template-columns: 1fr;
  margin-top: 1.1rem;
}
.home-play-loop div {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.65rem;
  align-items: center;
  min-height: 76px;
  padding: 0.8rem;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  background: rgba(7, 7, 13, 0.52);
}
.home-play-loop b {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 43, 214, 0.55);
  border-radius: 6px;
  color: var(--neon-pink);
  font-family: var(--font-display);
}
.home-play-loop span {
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.45;
}

.home-safety-strip {
  width: min(1180px, calc(100% - 2rem));
  margin: 2rem auto 0;
  padding: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid rgba(255, 43, 214, 0.26);
}
.home-safety-strip span {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.home-safety-strip span:nth-child(1) { color: var(--neon-green); }
.home-safety-strip span:nth-child(2) { color: var(--neon-cyan); }
.home-safety-strip span:nth-child(3) { color: var(--neon-pink); }
.home-safety-strip span:nth-child(4) { color: var(--neon-yellow); }

.home-tier.tier-teaser {
  max-width: 1180px;
  padding-top: clamp(3rem, 7vw, 5rem);
  padding-bottom: 3rem;
}
.home-tier-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.home-tier .tier-card {
  min-height: 100%;
}

@media (max-width: 920px) {
  .landing .topbar.home-topbar {
    align-items: flex-start;
  }
  .landing .topnav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .home-hero-inner {
    padding-right: min(18vw, 170px);
  }
  .home-signal-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-flow-layout {
    grid-template-columns: 1fr;
  }
  .home-flow-copy {
    position: static;
  }
  .home-flow-copy .home-play-loop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-play-loop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .section-head {
    display: block;
  }
  .home-tier-head {
    display: block;
  }
  .section-head .home-kicker {
    margin-bottom: 0.6rem;
  }
  .home-tier-head .home-kicker,
  .home-route-head .home-kicker {
    margin-bottom: 0.6rem;
  }
}
@media (max-width: 620px) {
  .landing .topbar.home-topbar {
    padding: 0.85rem 1rem;
  }
  .landing .logo-sub {
    display: none;
  }
  .landing .topnav {
    gap: 0.38rem;
  }
  .landing .topnav a {
    padding: 0.38rem 0.44rem;
    font-size: 0.63rem;
  }
  .home-hero {
    min-height: calc(100svh - 190px);
  }
  .home-hero::before {
    background-image:
      linear-gradient(90deg, rgba(7, 7, 13, 0.94) 0%, rgba(7, 7, 13, 0.76) 62%, rgba(7, 7, 13, 0.48) 100%),
      linear-gradient(0deg, rgba(7, 7, 13, 0.88) 0%, rgba(7, 7, 13, 0.18) 46%, rgba(7, 7, 13, 0.72) 100%),
      url('/img/home-social-hero.webp');
  }
  .home-hero-inner {
    width: min(100% - 1.5rem, 1180px);
    padding: 2.1rem 0 3.2rem;
  }
  .home-title {
    font-size: clamp(2rem, 11vw, 3.3rem);
  }
  .home-copy {
    font-size: 0.95rem;
    word-break: break-word;
  }
  .home-cta {
    align-items: stretch;
    flex-direction: column;
  }
  .home-cta .btn-neon {
    flex: 0 0 auto;
    text-align: center;
    padding: 0.78rem 1rem;
    width: 100%;
  }
  .home-inline-link {
    flex: 0 0 auto;
    text-align: center;
    padding: 0.1rem 0;
  }
  .home-warning {
    font-size: 0.8rem;
    word-break: break-word;
  }
  .home-signal-strip {
    margin-top: 0.9rem;
    grid-template-columns: 1fr;
  }
  .home-signal-card {
    min-height: auto;
  }
  .home-social-section {
    padding-top: 2.6rem;
  }
  .home-card-grid {
    grid-template-columns: 1fr;
  }
  .home-play-loop,
  .home-flow-copy .home-play-loop {
    grid-template-columns: 1fr;
  }
  .home-safety-strip {
    justify-content: flex-start;
  }
}

/* ---------- Terminal mockup ---------- */
.terminal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0, 240, 255, 0.15),
    0 0 30px rgba(0, 240, 255, 0.15),
    inset 0 0 20px rgba(0, 240, 255, 0.05);
  overflow: hidden;
}
.term-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid var(--line);
}
.t-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-dim);
}
.t-dot.red { background: var(--neon-red); box-shadow: 0 0 6px var(--neon-red); }
.t-dot.yellow { background: var(--neon-yellow); box-shadow: 0 0 6px var(--neon-yellow); }
.t-dot.green { background: var(--neon-green); box-shadow: 0 0 6px var(--neon-green); }
.term-title {
  margin-left: 0.8rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.term-body {
  padding: 1.5rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
  min-height: 280px;
}
.term-line { color: var(--text); }
.term-line .ok { color: var(--neon-green); text-shadow: 0 0 4px var(--neon-green); }
.term-line .prompt { color: var(--neon-cyan); }
.term-line .prompt.blink { opacity: 0.3; }

/* ---------- Footer ---------- */
.footer {
  position: relative; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.2rem 2.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-dim);
  margin-top: 3rem;
}
.footer-r { color: var(--neon-cyan); opacity: 0.7; text-align: right; }
@media (max-width: 620px) {
  .footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 1rem;
    margin-top: 2rem;
  }
  .footer-r { text-align: left; }
}

/* ============================================================
   CHAT PAGE
   ============================================================ */

/* Lock the html element too on the chat page so no residual page scroll can
 * slide the pinned head under the browser address bar (:has is ignored where
 * unsupported — the body rules below still constrain it). */
html:has(body.chat-page) { height: 100%; overflow: hidden; }

body.chat-page {
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  /* Pin the single row to the viewport. Without an explicit row, the implicit
   * auto row grows to its tallest content (the message list), so .composer gets
   * pushed past 100vh and clipped. minmax(0,..) lets cells shrink below content
   * so .messages can scroll (needs .messages{min-height:0}) instead of growing. */
  grid-template-rows: minmax(0, 1fr);
  /* Glue the app to the visible viewport. position:fixed takes the body out of
   * the scroll flow (it can never scroll under the address bar, so the head
   * stays pinned), while height:100dvh sizes it to the *visible* viewport so
   * the composer sits at the visible bottom instead of being clipped below the
   * bar (inset:0's bottom is the layout-viewport bottom, which sits under the
   * visible area). min-height:0 defeats the global body{min-height:100vh}. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  /* clip (not just hidden) so nothing creates a horizontal scroll area */
  overflow-x: clip;
  overscroll-behavior: none;
}

/* Installed-app (standalone) sizing. In a browser, 100dvh matches the area
 * fixed positioning uses; but in a standalone PWA 100dvh can run taller than
 * that, pushing the composer below the screen edge. Anchor top + bottom there
 * instead so the body spans exactly the app's usable height. */
@media (display-mode: standalone) {
  body.chat-page { height: auto; bottom: 0; }
}

.sidebar, .userlist, .chat-main {
  position: relative;
  z-index: 5;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  backdrop-filter: blur(6px);
}
.userlist {
  border-right: none;
  border-left: 1px solid var(--line);
}
/* Grid items default to min-width:auto, which lets the chat column grow to its
 * content's min-content width and overflow the viewport on phones (the header's
 * fixed-width button row). min-width:0 keeps it within its grid track so the
 * header can shrink/ellipsise instead. */
.chat-main { min-width: 0; position: relative; }

.sidebar {
  padding: 1.2rem;
  overflow-y: auto;
}

.sb-logo {
  display: flex; align-items: center; gap: 0.3rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: 0.1em;
  font-size: 1.1rem;
}

.me-card {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 240, 255, 0.05);
  margin-bottom: 1.5rem;
  /* Tappable — opens your own profile popup (see chat.js me-card handler). */
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.me-card:hover {
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.09);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.18);
}
.me-avatar {
  width: 42px; height: 42px;
  border-radius: 4px;
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  flex-shrink: 0;
  overflow: hidden;
  background: rgba(0, 240, 255, 0.08);
}
.me-info { flex: 1; min-width: 0; }
.me-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.me-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
  overflow-wrap: anywhere;
}
/* 32x32 square icon buttons — shared shell, distinct character.
 * .icon-btn (header ⟳ regen-identity): pink + rotates on hover, larger glyph.
 * .notify-btn (header 🔕/🔇 toggles): text-dim default, cyan hover, .on=pink.
 * The shared block only carries properties BOTH originally had, so neither's
 * pixel-layout shifts. Per-class rules below add the personality. */
.icon-btn, .notify-btn {
  background: transparent;
  border: 1px solid var(--line);
  width: 40px; height: 40px;
  border-radius: var(--r-ctl);
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn { color: var(--neon-pink); font-size: 1.2rem; }
.icon-btn:hover {
  box-shadow: 0 0 10px var(--neon-pink);
  border-color: var(--neon-pink);
  transform: rotate(180deg);
}

.sb-section { margin-bottom: 1.5rem; }
/* Section label flanked by neon gradient rules (drawn in CSS, no literal
 * ━ glyphs). Shared by the sidebar + userlist titles. */
.sb-title, .ul-title {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  /* Borderline display type: keep a faint glow for the HUD feel but trim it so
     the small label stays sharp. The gradient rules below carry most of it. */
  color: var(--neon-cyan); text-shadow: 0 0 3px rgba(0, 240, 255, 0.5);
  margin-bottom: 0.9rem;
}
.sb-title::before, .sb-title::after,
.ul-title::before, .ul-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.55));
}
.sb-title::after, .ul-title::after {
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.55), transparent);
}

.room-list { display: flex; flex-direction: column; gap: 0.4rem; }
.room-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.02);
}
.room-item:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  transform: translateX(2px);
}
.room-item.active {
  border-color: var(--neon-pink);
  background: rgba(255, 43, 214, 0.08);
  box-shadow: 0 0 8px rgba(255, 43, 214, 0.4);
}
.room-icon {
  color: var(--neon-purple);
  text-shadow: 0 0 6px var(--neon-purple);
  font-size: 1.1rem;
}
.room-info { flex: 1; min-width: 0; }
.room-name {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 700;
}
.room-count {
  font-size: 0.7rem;
  color: var(--text-dim2);
}
.room-badge {
  background: var(--neon-pink);
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

/* Footer menu items (บัญชีของฉัน / กลับหน้าแรก) — themed list rows that
 * light up on hover instead of plain centered text. */
.back-link {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: all 0.18s;
}
.back-link + .back-link { margin-top: 0.35rem; }
.back-link:hover {
  color: var(--neon-cyan);
  border-color: var(--line);
  background: rgba(0, 240, 255, 0.06);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

/* Sidebar nav links styled as buttons: bordered, dim at rest, with a neon glow
 * + slight slide on hover. The .danger variant (logout) glows pink instead. */
.sb-menu-btn {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 240, 255, 0.03);
  color: var(--text-dim);
  font-size: 0.84rem;
  text-decoration: none;
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}
.sb-menu-btn + .sb-menu-btn { margin-top: 0.4rem; }
.sb-menu-btn:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
  transform: translateX(3px);
}
.sb-menu-btn.danger:hover {
  color: var(--neon-pink);
  border-color: var(--neon-pink);
  background: rgba(255, 43, 214, 0.08);
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.2);
}

/* ---------- Chat main ---------- */
.chat-head {
  position: relative;
  overflow: hidden;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem;
  /* Keep the header clear of the status bar / notch / in-app browser top
   * chrome. env() is 0 where there is no inset, so desktop is unaffected. */
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.055), transparent 48%),
    rgba(0, 0, 0, 0.34);
}
.chat-head::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-yellow));
  opacity: 0.72;
  pointer-events: none;
}
.chat-head-l { display: flex; flex-direction: column; min-width: 0; }
.chat-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
}
.chat-sub {
  font-size: 0.75rem;
  color: var(--text-dim2);
}
.chat-head-r {
  display: flex; align-items: center; gap: 0.6rem;
}
/* E2E badge: a compact green icon chip (not a wide text pill), so it fits the
   header at every width — this is what lets us drop the old viewport-based hide
   (chat.js syncHeaderForViewport + the mobile display:none). Green border + faint
   fill carry the security read; no glow on this small element. */
.lock-badge {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  width: 36px; height: 36px;
  font-size: 1rem;
  color: var(--neon-green);
  border: 1px solid rgba(0, 255, 149, 0.3);
  background: rgba(0, 255, 149, 0.06);
  border-radius: var(--r-ctl);
}
.online-count {
  font-size: 0.75rem;
  color: var(--text-dim2);
}
/* Unread room-message badge (on the 👥 users control + the userlist heading).
   Pink pill so it reads as "new" — distinct from the dim online-count text. */
.msg-unread {
  background: var(--neon-pink);
  color: #000;
  font-weight: 700;
  font-size: 0.68rem;
  line-height: 1.5;
  border-radius: 9px;
  padding: 0 6px;
  min-width: 1.2em;
  text-align: center;
  box-shadow: 0 0 8px rgba(255, 43, 214, 0.45);
}
.ul-title .msg-unread { margin-left: 0.4rem; }
/* Mobile-only chat controls: ☰ opens the room sidebar, 👥 opens the
 * userlist. Hidden on desktop where both panels are always visible. */
.chat-burger, .chat-users-btn { display: none; }
.drawer-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drawer-scrim { display: none; }
/* shared shell lives with .icon-btn above; .notify-btn adds the bits
 * that the regen ⟳ button doesn't need (centering + tighter timing). */
.notify-btn {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition-duration: 0.15s;
}
.notify-btn:hover { border-color: var(--neon-cyan); color: var(--neon-cyan); }
.notify-btn.on {
  color: var(--neon-pink);
  border-color: var(--neon-pink);
  box-shadow: 0 0 8px rgba(255, 43, 214, 0.4);
}
/* Call actions are rows inside the ⋮ menu (.call-row). .locked = non-Pro
   (dimmed upsell), .call-live = a call is in progress, :disabled = re-entrant
   guard while a call/overlay is already up. */
.call-row.locked { opacity: 0.6; }
.call-row.call-live { color: var(--neon-green); }
.popup-row:disabled { opacity: 0.5; cursor: not-allowed; }
.messages {
  flex: 1;
  /* Flex children default to min-height:auto, so without this the list grows to
   * fit every message and shoves .composer past the 100vh edge (clipped
   * off-screen) instead of scrolling. Block-axis twin of .chat-main{min-width:0}. */
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.empty-state {
  width: min(100%, 680px);
  margin: auto;
  padding: clamp(1.2rem, 4vw, 1.8rem);
  border: 1px solid rgba(0, 240, 255, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0, rgba(0, 240, 255, 0.1), transparent 38%),
    linear-gradient(145deg, rgba(255, 43, 214, 0.045), transparent 70%),
    rgba(7, 7, 13, 0.38);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.28);
  text-align: center;
  color: var(--text-dim);
}
.es-icon {
  font-size: 3rem;
  color: var(--neon-purple);
  text-shadow: 0 0 15px var(--neon-purple);
  margin-bottom: 1rem;
  font-family: var(--font-display);
}
.es-text { font-size: 0.95rem; line-height: 1.7; max-width: 520px; margin-left: auto; margin-right: auto; }
.es-text > div + div { margin-top: 0.3rem; }
.es-title {
  margin-bottom: 0.35rem;
  color: var(--neon-cyan);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}
/* Empty-state action buttons (mobile: open the room/people drawers) + note. */
.es-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.1rem; }
.es-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.es-btn:hover { background: var(--neon-cyan); color: var(--bg); box-shadow: 0 0 14px rgba(0, 240, 255, 0.5); }
.es-btn.es-primary {
  background: rgba(255, 43, 214, 0.12);
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.18);
}
.es-btn.es-primary:hover { background: var(--neon-pink); color: #05050a; }
.es-note { color: var(--text-dim); font-size: 0.8rem; line-height: 1.6; margin-top: 1.1rem; max-width: 520px; margin-left: auto; margin-right: auto; }
/* Live "active rooms" discovery block in the empty state. Reuses the neon
 * palette; chips echo the .es-btn outline-cyan look, the count badge the pink
 * .room-badge. */
.es-discover { margin-top: 1.3rem; }
/* "ตอนนี้กำลังฮิต" hub header sits above the per-section titles. */
.es-discover-head {
  color: var(--neon-cyan); font-family: var(--font-mono); font-size: 0.92rem;
  letter-spacing: 0.1em; margin-bottom: 0.9rem; text-align: center;
}
.es-discover-title {
  color: var(--neon-pink); font-family: var(--font-mono); font-size: 0.8rem;
  letter-spacing: 0.08em; margin-bottom: 0.6rem;
}
/* space between stacked sections (live / rooms / posts) */
.es-discover-title ~ .es-discover-title,
.es-discover-chips + .es-discover-title { margin-top: 0.9rem; }
.es-discover-chips { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.es-discover-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 2.25rem;
  background: rgba(0, 240, 255, 0.06); border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan); font-family: var(--font-mono); font-size: 0.82rem;
  padding: 0.4rem 0.7rem; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.es-discover-chip:hover { background: var(--neon-cyan); color: var(--bg); box-shadow: 0 0 14px rgba(0, 240, 255, 0.5); }
.es-discover-count {
  background: var(--neon-pink); color: var(--bg); border-radius: 999px;
  font-size: 0.72rem; padding: 0.05rem 0.45rem; min-width: 1.2em; text-align: center;
}
.es-discover-chip:hover .es-discover-count { background: var(--bg); color: var(--neon-pink); }
/* "Be the first to chat" hint in a freshly-joined empty room. */
#room-empty-hint {
  margin: auto; align-self: center; text-align: center;
  color: var(--text-dim); font-size: 0.9rem; line-height: 1.6; padding: 1rem;
}

.msg {
  display: flex;
  gap: 0.7rem;
  max-width: 72%;
  animation: slideIn 0.25s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.me { align-self: flex-end; flex-direction: row-reverse; }

/* Consecutive messages from one sender tuck together: drop the repeated avatar
 * and name/time line and pull the bubble up (against the .messages gap) so a
 * burst reads as one block. The avatar keeps its box via visibility so bubbles
 * stay aligned; the time moves to the bubble's hover title. */
.msg.grouped { margin-top: -0.35rem; }
.msg.grouped .msg-avatar { visibility: hidden; }
.msg.grouped .msg-meta { display: none; }

.msg-avatar {
  width: var(--msg-av); height: var(--msg-av);
  border-radius: 6px;
  border: 1px solid var(--neon-purple);
  box-shadow: 0 2px 8px rgba(177, 75, 255, 0.35);
  overflow: hidden;
  background: rgba(177, 75, 255, 0.12);
  flex-shrink: 0;
}
.msg.me .msg-avatar {
  border-color: var(--neon-cyan);
  box-shadow: 0 2px 8px rgba(0, 240, 255, 0.35);
}

.msg-body { display: flex; flex-direction: column; gap: 0.2rem; }
.msg-meta {
  font-size: 0.7rem;
  color: var(--text-dim2);
  display: flex; gap: 0.5rem;
}
.msg-name { color: var(--neon-pink); font-weight: 700; }
.msg.me .msg-name { color: var(--neon-cyan); }

.msg-bubble {
  background: rgba(177, 75, 255, 0.1);
  border: 1px solid rgba(177, 75, 255, 0.4);
  padding: 0.7rem 1rem;
  /* Consistent 14px corners with one 4px "tail" toward the avatar (bottom-left
     for others, bottom-right for me) — keeps the left/right speaker cue without
     the old hard 4px/12px asymmetry. */
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) 4px;
  box-shadow: var(--depth-bubble);
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.msg-bubble.is-empty { display: none; }
.msg.me .msg-bubble {
  background: rgba(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.4);
  border-radius: var(--r-bubble) var(--r-bubble) 4px var(--r-bubble);
}
/* Tap-affordance: the bubble lifts (brighter fill + border + cyan glow) on
   hover/keyboard-focus. Gated to fine-pointer devices so a tap on touch never
   leaves a bubble stuck-lit — touch uses the .palette-open state below instead. */
@media (hover: hover) {
  .msg:hover .msg-bubble,
  .msg:focus-within .msg-bubble,
  .msg-bubble:focus-visible {
    background: rgba(177, 75, 255, 0.14);
    border-color: rgba(177, 75, 255, 0.6);
    box-shadow: var(--depth-bubble), var(--glow-cyan);
  }
  .msg.me:hover .msg-bubble,
  .msg.me:focus-within .msg-bubble,
  .msg.me .msg-bubble:focus-visible {
    background: rgba(0, 240, 255, 0.12);
    border-color: rgba(0, 240, 255, 0.6);
    box-shadow: var(--depth-bubble), var(--glow-cyan);
  }
}
/* Click-open state (toggled by chat.js when the reaction palette opens) — kept
   OUTSIDE the hover gate so it also lights on touch, marking which message the
   palette belongs to. */
.msg.palette-open .msg-bubble { background: rgba(0, 240, 255, 0.12); }
.msg-edited { color: var(--text-dim2); font-size: 0.68rem; font-weight: 400; letter-spacing: 0.02em; }
/* @mentions: any @nickname is cyan; a mention of YOU is pink + chipped, and the
 * whole bubble gets a pink accent so you spot it when scanning. */
.mention { color: var(--neon-cyan); font-weight: 700; }
.mention-me { color: var(--neon-pink); background: rgba(255, 43, 214, 0.12); border-radius: 3px; padding: 0 3px; }
.msg.mentions-me .msg-bubble {
  border-color: rgba(255, 43, 214, 0.55);
  box-shadow: var(--depth-bubble), var(--glow-pink);
}
/* Date divider between days — a centered pill label flanked by faint rules. */
.date-divider {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 0.5rem 0;
  color: var(--text-dim2); font-size: 0.68rem;
  font-family: var(--font-mono); letter-spacing: 0.08em;
}
.date-divider::before, .date-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(0, 240, 255, 0.18);
}
.date-divider span {
  flex-shrink: 0; padding: 0.12rem 0.7rem;
  border: 1px solid rgba(0, 240, 255, 0.25); border-radius: 999px;
  background: rgba(0, 240, 255, 0.05);
}
/* "New messages" divider — pink accent so it stands apart from the date divider. */
.new-divider {
  display: flex; align-items: center; gap: 0.7rem;
  margin: 0.4rem 0;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em;
}
.new-divider::before, .new-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255, 43, 214, 0.4);
}
.new-divider span {
  flex-shrink: 0; padding: 0.12rem 0.7rem;
  border: 1px solid rgba(255, 43, 214, 0.5); border-radius: 999px;
  background: rgba(255, 43, 214, 0.1); color: var(--neon-pink);
}
/* DM read receipt: one dim status line under the latest outgoing message
 * (ส่งแล้ว / ถึงแล้ว / อ่านแล้ว). Sits flush-right beneath the "me" bubble. */
.dm-status {
  align-self: flex-end;
  margin-top: -0.35rem;
  padding: 0 0.3rem 0.1rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--text-dim2);
}
/* Outbox: a DM queued to an offline peer, auto-sent when they come back online.
 * Dimmed bubble + dashed border + a "รอส่ง" tag. Reuses the locked neon pink. */
.msg.dm-pending { opacity: 0.62; }
.msg.dm-pending .msg-bubble,
.msg.dm-pending.me .msg-bubble { border-style: dashed; box-shadow: none; }
.dm-pending-tag { margin-top: 0.15rem; font-size: 0.66rem; letter-spacing: 0.04em; color: var(--neon-pink); }
.msg.dm-pending.me .dm-pending-tag { text-align: right; }
.dm-notice {
  align-self: stretch;
  border: 1px solid rgba(255, 43, 214, 0.38);
  background: rgba(255, 43, 214, 0.08);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.12);
}
/* Anonymous onboarding nudge — appears above the composer after a few sent
 * messages, one-time and dismissible (snoozed 7 days). Reuses the .dm-notice
 * translucent-panel look with a cyan accent + the existing .btn-neon CTA, so it
 * stays inside the locked neon vocabulary. */
.signup-nudge {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin: 0 0.75rem 0.5rem;
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 0.07);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.12);
}
.signup-nudge-text { flex: 1 1 12rem; font-size: 0.84rem; line-height: 1.45; }
.signup-nudge-actions { display: flex; gap: 0.5rem; align-items: center; }
.signup-nudge .btn-neon.btn-primary { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
.signup-nudge-dismiss {
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 4px; padding: 0.4rem 0.7rem; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.8rem;
}
.signup-nudge-dismiss:hover { border-color: var(--neon-pink); color: var(--neon-pink); }
.msg.msg-deleted .msg-bubble {
  font-style: italic; color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03); border-style: dashed;
}
.msg-image {
  display: block; max-width: min(320px, 70%); max-height: 60vh; margin-top: 0.3rem;
  border-radius: 12px; border: 1px solid rgba(177, 75, 255, 0.4); cursor: pointer;
}

.msg-system {
  align-self: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0.3rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-style: italic;
}
.msg-system.success { color: var(--neon-green); border-color: rgba(0, 255, 149, 0.4); }
.msg-system.error { color: var(--neon-red); border-color: rgba(255, 56, 96, 0.4); }

/* ---------- Message reactions (additive) ---------- */
.msg-body { position: relative; }
.msg-react-palette {
  position: absolute;
  /* Anchor the popup just above the message and let it grow UPWARD. With 13-15
   * buttons it wraps to two rows; a fixed `top` sized for one row let the 2nd
   * row overlap the bubble. bottom:100% keeps it clear of the message at any
   * height. */
  bottom: calc(100% + 4px);
  display: flex;
  gap: 2px;
  padding: 3px 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  /* Rounded rect, not a full pill — the palette is a 2-row grid, where a pill
   * radius reads as a lopsided blob. */
  border-radius: var(--r-md);
  box-shadow: var(--glow-cyan);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
  flex-wrap: wrap;
  /* Fixed width (not max-width) so the popup is the SAME box for every message
   * — it no longer grows/shrinks with the bubble's length. Anchored to the
   * message's outer edge (left/right:0) which is constant per alignment, so its
   * position is constant too. */
  width: min(15rem, 86vw);
}
.msg:not(.me) .msg-react-palette { left: 0; justify-content: flex-start; }
.msg.me .msg-react-palette { right: 0; justify-content: flex-end; }
/* Shown on click/tap (toggled via .palette-open), not hover — works on mobile
 * and keeps the box from flickering as the pointer moves. */
.msg.palette-open .msg-react-palette { opacity: 1; pointer-events: auto; }
.rx-btn {
  background: transparent; border: none; color: inherit;
  padding: 2px 5px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 4px;
  transition: transform 0.1s, background 0.12s;
}
.rx-btn:hover { background: rgba(0, 240, 255, 0.12); transform: scale(1.2); }

.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.msg-reactions:empty { display: none; }
.rx-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px 1px 5px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.12s;
}
.rx-tag:hover { background: rgba(0, 240, 255, 0.12); border-color: var(--neon-cyan); }
.rx-tag.mine {
  background: rgba(255, 43, 214, 0.1);
  border-color: rgba(255, 43, 214, 0.4);
}
.rx-tag .rx-count { color: var(--text-dim2); }
.rx-tag.mine .rx-count { color: var(--neon-pink); }

/* reply (quote) — preview bar above input + quoted block inside a message */
.rx-reply { font-size: 0.95rem; color: var(--neon-cyan); }
.rx-save { font-size: 0.9rem; color: var(--text-dim); }
.rx-save.on { color: #ffcc00; text-shadow: 0 0 6px rgba(255, 204, 0, 0.5); }
.rx-save:hover { color: #ffcc00; }
.msg-quote {
  border-left: 2px solid var(--neon-cyan);
  padding: 4px 8px;
  margin: 0 0 4px 0;
  background: rgba(0, 240, 255, 0.05);
  border-radius: 0 6px 6px 0;
  max-width: 100%;
  font-size: 0.82rem;
  opacity: 0.85;
  /* Tappable: clicking jumps to + flashes the quoted message (jumpToMessage). */
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.msg-quote:hover { opacity: 1; background: rgba(0, 240, 255, 0.1); }
.msg-quote-name { color: var(--neon-cyan); font-family: var(--font-mono); font-size: 0.72rem;
  letter-spacing: 0.06em; margin-bottom: 2px; }
.msg-quote-text { color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg.me .msg-quote { border-left-color: var(--neon-pink); background: rgba(255, 43, 214, 0.05); }
.msg.me .msg-quote:hover { background: rgba(255, 43, 214, 0.12); }
.msg.me .msg-quote-name { color: var(--neon-pink); }
.reply-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 1rem;
  border-top: 1px dashed rgba(0, 240, 255, 0.25);
  border-left: 3px solid var(--neon-cyan);
  background: rgba(0, 240, 255, 0.05);
  font-size: 0.8rem;
}
.reply-bar-body { flex: 1; min-width: 0; }
.reply-bar-name { color: var(--neon-cyan); font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.08em; }
.reply-bar-text { color: var(--text-dim); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.reply-bar-x {
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; line-height: 1;
  font-family: var(--font-mono);
}
.reply-bar-x:hover { color: var(--neon-pink); border-color: var(--neon-pink); }
/* Edit bar reuses the reply-bar layout with a pink accent. */
.edit-bar { border-left-color: var(--neon-pink); background: rgba(255, 43, 214, 0.05); }
.edit-bar .reply-bar-name { color: var(--neon-pink); }

.img-chip {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 1rem;
  border-top: 1px dashed rgba(255, 43, 214, 0.25);
  border-left: 3px solid var(--neon-pink);
  background: rgba(255, 43, 214, 0.05);
  font-size: 0.8rem; color: var(--text-dim);
}
.img-chip span { flex: 1; min-width: 0; }
.img-chip-x {
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; line-height: 1;
  font-family: var(--font-mono);
}
.img-chip-x:hover { color: var(--neon-pink); border-color: var(--neon-pink); }
/* Thumbnail preview of the staged image in the attach chip. */
.img-chip-thumb {
  width: 44px; height: 44px; flex-shrink: 0;
  object-fit: cover; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(177, 75, 255, 0.5);
}
.img-chip-thumb:hover { border-color: var(--neon-cyan); }
/* Attach (📎) button: sized to match the composer row (same height as the
 * input + SEND), not the small 32x32 header icon-btn it used to borrow. */
.composer-attach, .composer-emoji {
  flex-shrink: 0;
  height: var(--cmp-h);
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--cmp-h);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--neon-cyan);
  font-size: 1.2rem; line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer-attach:hover, .composer-emoji:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
.composer-emoji[aria-expanded="true"] { border-color: var(--neon-cyan); box-shadow: 0 0 10px rgba(0, 240, 255, 0.4); }

/* Emoji picker popup — anchored above the composer (which is position:relative).
 * Neon-toned grid; built/inserted client-side, no new palette colours. */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0.5rem;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.15rem;
  width: min(18rem, 80vw);
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
  backdrop-filter: blur(6px);
}
.emoji-picker.hidden { display: none; }
.emoji-opt {
  border: none; background: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 0.3rem; border-radius: 5px;
  transition: background 0.12s;
}
.emoji-opt:hover { background: rgba(0, 240, 255, 0.15); }

/* @mention autocomplete dropdown — floats above the composer (same panel recipe
 * as the emoji picker); arrow keys move .on, click/Enter selects. */
.mention-pop {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 0.5rem;
  z-index: 30;
  display: flex; flex-direction: column;
  min-width: 11rem; max-width: min(18rem, 80vw);
  max-height: 13rem; overflow-y: auto;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
  backdrop-filter: blur(6px);
}
.mention-pop.hidden { display: none; }
.mention-opt {
  display: flex; align-items: center; gap: 0.5rem;
  border: none; background: none; cursor: pointer;
  padding: 0.4rem 0.5rem; border-radius: 5px;
  color: var(--text); font-size: 0.85rem; text-align: left;
  transition: background 0.12s;
}
.mention-opt.on, .mention-opt:hover { background: rgba(0, 240, 255, 0.15); }
.mention-opt-av {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 4px;
  overflow: hidden; background: rgba(0, 240, 255, 0.08); border: 1px solid var(--line);
}

/* In-page image popup (lightbox) — same backdrop recipe as .modal-bg. */
.img-lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 3vh 3vw;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(6px);
}
.img-lightbox-img {
  max-width: 92vw; max-height: 88vh; object-fit: contain;
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.35);
  border-radius: 6px;
}
.img-lightbox-close {
  position: fixed; top: 1rem; right: 1.2rem;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line);
  color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer;
  font-family: var(--font-mono);
}
.img-lightbox-close:hover {
  color: var(--neon-cyan); border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

/* Pro WebRTC call surface: one compact overlay for outgoing, incoming, and
   active 1-1 voice/video calls. Media stays browser-to-browser via WebRTC. */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}
.call-overlay.hidden { display: none; }
.call-card {
  width: min(720px, 94vw);
  max-height: min(680px, 92vh);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.9rem;
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.08), rgba(0, 0, 0, 0.88));
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.26), 0 18px 50px rgba(0, 0, 0, 0.6);
}
.call-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.call-title {
  font-family: var(--font-display);
  color: var(--neon-cyan);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}
.call-status {
  margin-top: 0.15rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.call-stage {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 45%, rgba(157, 78, 221, 0.22), transparent 36%),
    rgba(0, 0, 0, 0.55);
}
.call-remote-video,
.call-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #02040a;
}
.call-remote-video {
  position: absolute;
  inset: 0;
}
.call-local-video {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  width: min(170px, 32vw);
  height: min(120px, 22vw);
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
}
.call-audio-avatar {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 4.5rem);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
}
.call-overlay.audio-only .call-remote-video,
.call-overlay.audio-only .call-local-video { display: none; }
.call-overlay.audio-only .call-audio-avatar { display: flex; }
.call-incoming-actions,
.call-controls {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.call-incoming-actions.hidden,
.call-controls.hidden { display: none; }
.call-pill,
.call-icon-btn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s, background 0.15s;
}
.call-pill {
  min-width: 8rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-weight: 700;
}
.call-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1rem;
}
.call-pill.accept,
.call-icon-btn.on {
  border-color: var(--neon-green);
  color: var(--neon-green);
  box-shadow: 0 0 12px rgba(54, 255, 138, 0.3);
}
.call-icon-btn:hover,
.call-pill:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}
.call-pill.hangup,
.call-icon-btn.hangup {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}
.call-pill.hangup:hover,
.call-icon-btn.hangup:hover {
  background: rgba(255, 43, 214, 0.12);
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.35);
}

/* ─── Unified popup base (inbox + chat overflow menu) ─── */
.head-pop { position: relative; display: inline-flex; }
.popup {
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 18px rgba(0, 240, 255, 0.25);
  z-index: 80;
}
.popup.hidden { display: none; }
.inbox-panel,
.chat-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  max-width: 92vw;
  max-height: 60vh;
  overflow: auto;
}
.chat-menu { min-width: 220px; }
/* Section label inside the ⋮ menu — buckets the 8 actions into 4 groups. Crisp
   display type, no glow; a hairline above each non-first group separates them
   without drawing a divider under every single row. */
.popup-section {
  font-family: var(--font-display);
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim2);
  padding: 0.55rem 0.9rem 0.25rem;
}
.popup-row + .popup-section {
  border-top: 1px solid rgba(0, 240, 255, 0.14);
  margin-top: 0.2rem; padding-top: 0.5rem;
}
.popup-row {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.popup-row:hover { background: rgba(0, 240, 255, 0.08); color: var(--neon-cyan); }
/* The 🔔 inbox unread count sits at the end of its menu row — push it right. */
.popup-row .msg-unread { margin-left: auto; }
.inbox-empty {
  padding: 0.85rem 0.9rem 0.2rem;
  color: var(--text);
  font-size: 0.86rem;
}
.inbox-empty-hint {
  padding: 0 0.9rem 0.75rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.45;
}
.inbox-start-btn {
  color: var(--neon-cyan);
  border-top: 1px solid var(--line);
}
.notif-clear-all {
  display: inline-flex;
  min-height: 2.05rem;
  margin: 0.45rem 0.55rem 0.15rem auto;
}
.inbox-panel .notif-row {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 2rem;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 18rem;
  min-height: 3.9rem;
  margin: 0.45rem 0.55rem;
  padding: 0.55rem;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 16px rgba(0, 240, 255, 0.025);
}
.inbox-panel .notif-row::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--neon-cyan), transparent);
  opacity: 0.35;
}
.inbox-panel .notif-row.unread {
  border-color: rgba(255, 43, 214, 0.3);
  background:
    linear-gradient(135deg, rgba(255, 43, 214, 0.11), rgba(0, 240, 255, 0.05)),
    rgba(0, 0, 0, 0.32);
}
.inbox-panel .notif-row.unread::before {
  background: linear-gradient(180deg, var(--neon-pink), var(--neon-cyan));
  opacity: 0.95;
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.45);
}
.inbox-panel .notif-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid rgba(0, 240, 255, 0.18);
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.06);
  font-size: 0.92rem;
  line-height: 1;
}
.inbox-panel .notif-body {
  display: grid;
  gap: 0.38rem;
  min-width: 0;
}
.notif-body.is-link {
  cursor: pointer;
}
.notif-body.is-link:hover .notif-text,
.notif-body.is-link:focus-visible .notif-text {
  color: var(--neon-cyan);
}
.notif-body:focus-visible {
  outline: 1px solid var(--neon-cyan);
  outline-offset: 3px;
  border-radius: 6px;
}
.inbox-panel .notif-text {
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.inbox-panel .notif-row.unread .notif-text { color: #fff; }
.inbox-panel .notif-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.28rem;
}
.inbox-panel .notif-kind,
.inbox-panel .notif-time,
.inbox-panel .notif-unread-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.2rem;
  padding: 0.06rem 0.38rem;
  border-radius: 999px;
  font-size: 0.62rem;
  line-height: 1.2;
}
.inbox-panel .notif-kind {
  border: 1px solid rgba(0, 240, 255, 0.16);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.055);
}
.inbox-panel .notif-time {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.035);
}
.inbox-panel .notif-unread-chip {
  color: var(--bg);
  background: var(--neon-pink);
  font-family: var(--font-display);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.4);
}
.inbox-panel .notif-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  border: 1px solid rgba(255, 43, 214, 0.14);
  border-radius: 999px;
  background: rgba(255, 43, 214, 0.045);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.16s, color 0.16s, background 0.16s, box-shadow 0.16s;
}
.inbox-panel .notif-del-btn:hover,
.inbox-panel .notif-del-btn:focus-visible {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  background: rgba(255, 43, 214, 0.12);
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.28);
  outline: none;
}
.thread-unread-badge,
.thread-offline-badge {
  margin-left: auto;
  white-space: nowrap;
}
.thread-unread-badge {
  padding: 0 7px;
  border-radius: 9px;
  background: var(--neon-pink, #ff2bd6);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
}
.thread-offline-badge {
  color: var(--text-dim, #7a8aa0);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}
/* Mobile keeps the same top-anchored dropdown as desktop (base rule above).
   A previous bottom-sheet (position:fixed; bottom:0) opened at the bottom of
   the screen and covered the composer, far from the top-bar button that
   triggered it. max-width:92vw on the base rule keeps it on-screen. */
/* Bubble width cap — readable line length on wide viewports */
@media (min-width: 1200px) {
  .msg { max-width: min(72%, 640px); }
}

/* typing indicator */
.typing-indicator {
  padding: 0.4rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 0.5rem;
}
.dots { display: inline-flex; gap: 3px; }
.dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--neon-cyan);
  animation: bounce 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* composer */
/* In-chat search bar (below the header) + the per-message filter class. */
.search-bar {
  position: relative;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.045), transparent 60%),
    rgba(0, 0, 0, 0.38);
}
.search-bar.hidden { display: none; }
.search-bar input {
  min-height: 2.35rem;
  flex: 1; min-width: 0;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.5rem 0.8rem; color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; outline: none;
  color-scheme: dark;
}
.search-bar input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 8px rgba(0, 240, 255, 0.35); }
.search-count { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.search-close {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.125rem; min-height: 2.125rem;
  border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text-dim);
  cursor: pointer; font-size: 1rem; padding: 0; line-height: 1;
}
.search-close:hover, .search-close:focus-visible {
  color: var(--neon-pink);
  border-color: rgba(255, 43, 214, 0.3);
  background: rgba(255, 43, 214, 0.08);
  outline: none;
}
.search-hidden { display: none !important; }

/* Pinned-message bar (below the search bar) + the message-palette pin toggle. */
.pin-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-bottom: 1px solid rgba(0, 240, 255, 0.2); background: rgba(0, 240, 255, 0.06); }
.pin-bar.hidden { display: none; }
.pin-emoji { flex-shrink: 0; }
.pin-text { flex: 1; min-width: 0; text-align: left; border: none; background: none; color: var(--text); font-family: var(--font-mono); font-size: 0.85rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-text:hover { color: var(--neon-cyan); }
.pin-clear { flex-shrink: 0; border: none; background: none; color: var(--text-dim); cursor: pointer; font-size: 0.95rem; padding: 0.2rem 0.4rem; line-height: 1; }
.pin-clear:hover { color: var(--neon-pink); }
.rx-pin.on { background: rgba(0, 240, 255, 0.18); border-radius: 4px; }
.msg-flash { animation: msgFlash 1.2s ease; }
@keyframes msgFlash { 0%, 100% { background: transparent; } 30% { background: rgba(0, 240, 255, 0.12); } }

/* One-time onboarding hint bar (how to react/reply + start a DM). */
.chat-hints {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.07), transparent 62%),
    rgba(0, 0, 0, 0.26);
  font-size: 0.8rem; color: var(--text-dim);
}
.chat-hints.hidden { display: none; }
.chat-hints-icon { flex-shrink: 0; font-size: 1rem; }
.chat-hints-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.2rem; }
.chat-hints-body b { color: var(--neon-cyan); font-weight: 700; }
.chat-hints-close {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; min-width: 2.125rem; min-height: 2.125rem;
  border: none; border-radius: 6px; background: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.95rem; padding: 0; line-height: 1;
}
.chat-hints-close:hover,
.chat-hints-close:focus-visible { color: var(--neon-pink); background: rgba(255,43,214,0.08); }

/* Transient toast (e.g. "คัดลอกแล้ว") — floats above the composer, auto-fades. */
.chat-toast {
  position: fixed;
  bottom: 5.5rem; left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 250;
  padding: 0.5rem 1rem;
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 999px;
  color: var(--neon-cyan);
  font-size: 0.82rem;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.chat-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.chat-toast.is-clickable { pointer-events: auto; cursor: pointer; }

.composer {
  --cmp-h: 3rem; /* shared height for all composer controls (1-line state) */
  display: flex; gap: 0.6rem; align-items: flex-end; position: relative;
  padding: 1rem 1.5rem;
  /* Keep the input clear of the home indicator / bottom browser chrome. */
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.055), transparent 52%),
    linear-gradient(270deg, rgba(255, 43, 214, 0.04), transparent 48%),
    rgba(0, 0, 0, 0.34);
}
.composer::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  opacity: 0.62;
  pointer-events: none;
}
/* Floating "new messages" pill — appears when a message lands while the viewer
 * has scrolled up; click jumps to the latest. Anchored above the composer
 * within .chat-main (position: relative). Neon cyan accent, no new palette. */
.scroll-pill {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(5.4rem + env(safe-area-inset-bottom, 0px));
  z-index: 20; padding: 0.4rem 0.9rem;
  border: 1px solid var(--neon-cyan); border-radius: var(--r-pill);
  background: var(--panel); color: var(--neon-cyan);
  font-family: var(--font-mono); font-size: 0.8rem; cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35); backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.15s;
}
.scroll-pill:hover { background: rgba(0, 240, 255, 0.14); transform: translateX(-50%) translateY(-1px); }
.scroll-pill.hidden { display: none; }
.composer input, .composer textarea {
  flex: 1;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(0, 240, 255, 0.04), rgba(0, 0, 0, 0.5)),
    rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  color-scheme: dark;
  transition: border-color 0.2s, box-shadow 0.2s;
}
/* The message composer is a textarea (multi-line): starts one row tall and
 * auto-grows via JS up to ~6 lines, then scrolls internally. Scope the
 * transition above to border/shadow so the auto-grow height isn't animated. */
.composer textarea {
  resize: none;
  line-height: 1.5;
  /* Fixed at the shared control height so the whole composer row stays level
   * with the buttons. Multi-line / long text scrolls inside this fixed box
   * rather than growing it (autoGrowComposer only resets the height now). The
   * 1.8rem term gives a single line generous vertical room so device font
   * metrics (a phone's Thai face renders taller than desktop Chrome) never
   * clip the text. */
  height: var(--cmp-h);
  padding: calc((var(--cmp-h) - 1.8rem) / 2) 0.9rem;
  overflow-y: auto;
}
.composer input:focus, .composer textarea:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
.composer input:disabled, .composer textarea:disabled { opacity: 0.4; cursor: not-allowed; }
/* The SEND button reuses the big .btn-neon CTA; compact it inside the composer
 * (and keep it from shrinking) so the attach + emoji + textarea + send row fits
 * without overflowing the right edge on narrow screens. */
.composer .btn-neon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 6.25rem;
  height: var(--cmp-h);
  padding: 0 1.1rem; font-size: 0.82rem; letter-spacing: 0.06em; flex-shrink: 0;
}

/* Sidebar inputs (private-room code, etc.) — same neon treatment as the
 * composer: dark field, cyan focus glow, mono font. letter-spacing gives
 * a code-entry feel (visual only — doesn't alter the value). */
.sb-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  outline: none;
  transition: all 0.2s;
}
.sb-input::placeholder { color: var(--text-dim); opacity: 0.65; letter-spacing: 0.03em; }
.sb-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
.sb-gap { margin-top: 0.5rem; }

/* Small inline actions used by chat-only overlays (profile popup, relationship
   center, shared Dialog fallback). pages.css defines the same vocabulary for
   app pages; this local base keeps /chat visually complete on its own. */
.tiny-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.125rem;
  min-width: 0;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}
.tiny-btn:hover,
.tiny-btn:focus-visible {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  outline: none;
}
.tiny-btn.primary {
  border-color: var(--neon-cyan);
  color: var(--bg);
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0,240,255,0.28);
}
.tiny-btn.danger:hover,
.tiny-btn.danger:focus-visible {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  background: rgba(255,43,214,0.08);
}
.tiny-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* user list */
.userlist {
  padding: 1.2rem;
  overflow-y: auto;
}
.ul-title {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-dim2);
  margin-bottom: 0.8rem;
  text-align: center;
}
.user-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}
.user-item:hover { background: rgba(255, 255, 255, 0.04); }
/* Click-to-DM affordances (chat online list + /online avatars). */
.user-item.dm-able { cursor: pointer; }
.user-item.dm-able:hover { background: rgba(0, 240, 255, 0.07); }
.user-item.dm-able:focus-visible {
  outline: 1px solid var(--neon-cyan);
  outline-offset: 2px;
}
.user-avatar.dm-avatar { cursor: pointer; }
.user-avatar.dm-avatar:hover { border-color: var(--neon-cyan); box-shadow: 0 0 8px rgba(0, 240, 255, 0.5); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(177, 75, 255, 0.12);
  border: 1px solid var(--neon-purple);
  flex-shrink: 0;
}
.avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}
.user-name { color: var(--text); display: flex; align-items: center; gap: 0.3rem; min-width: 0; flex: 1 1 auto; }
.user-item.is-me .user-name { color: var(--neon-cyan); }
.user-name .pro-star { color: var(--neon-pink); font-size: 0.7rem; text-shadow: 0 0 5px var(--neon-pink); }
.user-name .you-tag { color: var(--text-dim2); font-size: 0.72rem; }
.user-item.is-active-dm {
  background: rgba(0,240,255,0.12);
  box-shadow: inset 3px 0 0 var(--neon-cyan, #00f0ff);
}
.msg-pro-badge {
  color: var(--neon-pink);
  font-size: 0.7rem;
}
.me-tier-badge {
  padding: 1px 5px;
  font-size: 0.55rem;
}
.dm-unread-badge {
  margin-left: auto; flex: 0 0 auto;
  background: var(--neon-pink); color: #000; font-weight: 700;
  font-size: 0.68rem; line-height: 1.5; min-width: 1.4em; text-align: center;
  border-radius: 9px; padding: 0 6px;
  box-shadow: 0 0 8px rgba(255, 43, 214, 0.45);
}
.panel-pulse {
  animation: panelPulse 0.9s ease-out;
}
@keyframes panelPulse {
  0% { box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.2), 0 0 0 rgba(0, 240, 255, 0); }
  45% { box-shadow: inset 0 0 0 1px var(--neon-cyan), 0 0 18px rgba(0, 240, 255, 0.45); }
  100% { box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0), 0 0 0 rgba(0, 240, 255, 0); }
}
.ul-empty { color: var(--text-dim); font-size: 0.8rem; padding: 0.5rem 0.2rem; line-height: 1.5; }
.ul-caption {
  color: var(--text-dim); font-size: 0.72rem; line-height: 1.5;
  margin: -0.3rem 0 0.7rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex; justify-content: center; align-items: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
/* Notched-corner popup. clip-path clips `border` + `box-shadow`, so the neon edge
   is drawn as a layered fill — the box bg is the edge colour and a 1px-inset
   ::before holds the opaque interior — and the glow moves to drop-shadow so it
   traces the notch. Same technique as .auth-card; keeps the top-right + bottom-left
   diagonal cuts with a continuous edge instead of a bare gap. */
.modal {
  position: relative;
  background: var(--neon-cyan);
  filter: drop-shadow(0 0 16px rgba(0, 240, 255, 0.35));
  padding: 2rem 2.5rem;
  border-radius: 6px;
  text-align: center;
  max-width: 400px;
  clip-path: polygon(0 0, 95% 0, 100% 8%, 100% 100%, 5% 100%, 0 92%);
}
.modal::before {
  content: ''; position: absolute; inset: 1px; background: #0e0e1b; z-index: -1;
  clip-path: polygon(0 0, 95% 0, 100% 8%, 100% 100%, 5% 100%, 0 92%);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}
.modal-body { margin-bottom: 1.5rem; }
.modal-body p { color: var(--text-dim); font-size: 0.9rem; }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin-top: 0.5rem;
}
.modal-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 86px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl, 8px);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}
.modal-action-btn:hover,
.modal-action-btn:focus-visible {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  outline: none;
}
.modal-action-btn.primary,
.modal-action-btn.danger {
  padding: 0.55rem 1.1rem;
  font-weight: 700;
}
.modal-action-btn.primary {
  border-color: var(--neon-cyan);
  color: var(--bg);
  background: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.32);
}
.modal-action-btn.danger {
  border-color: var(--neon-pink);
  color: var(--bg);
  background: var(--neon-pink);
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.34);
}
.shared-dialog-input {
  width: 100%;
  margin-top: 0.8rem;
  letter-spacing: 0.02em;
  resize: none;
}
.shared-dialog-input.is-multiline {
  min-height: 8rem;
  line-height: 1.5;
  resize: vertical;
}
@media (max-width: 520px) {
  .modal-actions { align-items: stretch; flex-direction: column-reverse; }
  .modal-action-btn { width: 100%; }
}

/* Profile popup → compact profile card. Click an avatar to see the person's
   profile + context-aware actions. Reuses the .modal-bg overlay + .tiny-btn /
   .stat-chip / .presence-dot tokens; same locked neon vocabulary. */
.profile-pop-able { cursor: pointer; }
.profile-pop-able:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}
.profile-pop-card {
  position: relative;
  width: min(92vw, 348px);
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  border-radius: 6px;
  overflow: hidden;
  text-align: left;
}
.profile-pop-close {
  position: absolute; top: 0.5rem; right: 0.7rem; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); border: none; color: var(--text);
  font-size: 1.2rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.profile-pop-close:hover { color: var(--neon-pink); box-shadow: 0 0 8px var(--neon-pink); }
.profile-pop-banner {
  position: relative;
  height: 92px;
  background: linear-gradient(120deg, rgba(0, 240, 255, 0.18), rgba(255, 43, 214, 0.22));
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.profile-pop-banner-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-pop-body { padding: 0 1.4rem 1.3rem; }
.profile-pop-head { display: flex; flex-direction: column; align-items: center; }
.profile-pop-av {
  width: 112px; height: 112px; margin-top: -56px;
  border: 2px solid var(--neon-cyan); border-radius: 8px;
  overflow: hidden; background-color: var(--bg);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.45);
  /* Tappable — opens the profile picture full-size (see ensureProfilePopup). */
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
}
.profile-pop-av:hover {
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.7);
  transform: scale(1.04);
}
.profile-pop-idwrap { margin-top: 0.6rem; width: 100%; text-align: center; }
.profile-pop-name {
  font-family: var(--font-display); font-size: 1.15rem; color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.3); word-break: break-word;
}
.profile-pop-handle { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.1rem; }
.profile-pop-presence {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.4rem;
  font-size: 0.74rem; color: var(--text-dim); margin-top: 0.35rem;
}
.profile-pop-tier {
  padding: 0.05rem 0.45rem; border-radius: 999px;
  background: var(--neon-pink); color: var(--bg);
  font-size: 0.6rem; letter-spacing: 0.1em; font-weight: 700;
}
.profile-pop-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; margin: 0.8rem 0 0; }
.profile-pop-chips .stat-chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25rem 0.6rem; color: var(--text-dim); font-size: 0.72rem;
}
.profile-pop-status {
  color: var(--text); font-size: 0.85rem; line-height: 1.5; margin-top: 0.7rem;
  text-align: center; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.profile-pop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 0.9rem; }
.profile-pop-actions .tiny-btn { padding: 0.45rem 0.85rem; font-size: 0.8rem; }
.profile-pop-divider { border-top: 1px dashed var(--line); margin: 0.85rem 0 0.7rem; }
.profile-pop-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.profile-pop-foot .tiny-btn { padding: 0.35rem 0.75rem; font-size: 0.72rem; opacity: 0.85; }
.profile-pop-foot .tiny-btn:hover { opacity: 1; }
.profile-pop-hint { color: var(--text-dim); font-size: 0.75rem; line-height: 1.5; margin-top: 0.8rem; text-align: center; }
.profile-pop-report { display: grid; gap: 0.6rem; margin-top: 0.9rem; }
.profile-pop-report-title { color: var(--text); font-size: 0.85rem; }
.profile-pop-reason {
  width: 100%; min-height: 80px; resize: vertical;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); color: var(--text);
  border-radius: 4px; padding: 0.6rem 0.7rem; font-family: var(--font-mono); font-size: 0.85rem;
}
.profile-pop-reason:focus { outline: none; border-color: var(--neon-cyan); box-shadow: 0 0 8px rgba(0, 240, 255, 0.4); }
.profile-pop-report-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.profile-pop-card .tiny-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 400px) {
  .profile-pop-card { width: 94vw; }
  .profile-pop-body { padding: 0 1.1rem 1.1rem; }
  /* Tiny phones: collapse the visual SEND label to a ▶ glyph. The button keeps
     aria-label="ส่ง", so hiding the text span does not remove its accessible name. */
  #btn-send span { display: none; }
  #btn-send::after { content: '\25B6'; font-size: 0.95rem; line-height: 1; }
  .composer .btn-neon { padding: 0 0.7rem; }
}

/* Relationships center (friends / blocks / mute). A tabbed overlay built on the
   same .modal-bg + .user-item + .tiny-btn + .presence-dot vocabulary as the
   profile popup — same locked neon tokens, no new colors/fonts. */
.rel-modal {
  position: relative;
  width: 460px; max-width: 92vw;
  max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  border-radius: 6px;
  padding: 1.4rem 1.5rem 1.1rem;
}
.rel-modal .modal-title { margin-bottom: 0.9rem; }
.rel-tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--line); }
.rel-tab {
  flex: 1; min-height: 40px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); font-family: var(--font-mono); font-size: 0.82rem;
  padding: 0.5rem 0.3rem; border-bottom: 2px solid transparent;
}
.rel-tab:hover { color: var(--neon-cyan); }
.rel-tab.active { color: var(--neon-cyan); border-bottom-color: var(--neon-cyan); text-shadow: 0 0 6px var(--neon-cyan); }
.rel-body { overflow-y: auto; flex: 1; min-height: 140px; padding-top: 0.6rem; }
.rel-section-title {
  color: var(--text-dim); font-size: 0.7rem; letter-spacing: 0.06em;
  text-transform: uppercase; margin: 0.8rem 0 0.35rem;
}
.rel-section-title:first-child { margin-top: 0; }
.rel-empty { color: var(--text-dim); font-size: 0.83rem; padding: 1.1rem 0.3rem; line-height: 1.5; text-align: center; }
.rel-row-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.rel-row-sub { color: var(--text-dim); font-size: 0.72rem; display: flex; align-items: center; }
.rel-row-actions { display: flex; gap: 0.4rem; margin-left: auto; flex-shrink: 0; }
.rel-add { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.rel-add-input {
  flex: 1; min-width: 0;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-mono); font-size: 0.82rem; padding: 0.45rem 0.6rem; border-radius: 3px;
}
.rel-add-input:focus { outline: none; border-color: var(--neon-cyan); }

.loader {
  width: 60px; height: 60px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--neon-cyan); }

/* Accessibility: honor the OS "reduce motion" setting (vestibular sensitivity).
 * Freeze animations + transitions to near-instant so end states show without
 * movement. The neon palette/look is fully preserved — only motion is removed. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* responsive */
@media (max-width: 1000px) {
  body.chat-page { grid-template-columns: 240px 1fr; }
  .userlist { display: none; }
}
@media (max-width: 700px) {
  /* Single-column chat: the room sidebar + userlist become slide-out
   * drawers (left + right) reachable from the header, so mobile users can
   * still pick rooms, find matches, and see who's in the room. */
  /* The body is already fixed to the viewport, so mobile drawers stay inside
     that box and are hidden with clipping instead of off-screen transforms.
     This avoids horizontal scroll areas on browsers that include transformed
     drawers in body.scrollWidth. */
  body.chat-page { grid-template-columns: 1fr; contain: layout; }

  .chat-burger, .chat-users-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
    flex: 0 0 auto; height: 44px; padding: 0 0.8rem;
    border: 1px solid var(--neon-cyan); border-radius: 6px;
    background: rgba(0, 0, 0, 0.4); color: var(--neon-cyan);
    font-size: 1.1rem; line-height: 1; cursor: pointer;
    text-shadow: 0 0 6px var(--neon-cyan); transition: all 0.2s;
  }
  .chat-users-btn { font-size: 0.85rem; }
  .chat-burger:hover, .chat-users-btn:hover { background: var(--neon-cyan); color: var(--bg); text-shadow: none; }
  .chat-head { gap: 0.5rem; padding: 0.7rem 0.7rem; padding-top: calc(0.7rem + env(safe-area-inset-top, 0px)); }
  /* basis:0 → the title column takes only the leftover space. Let Thai room
   * titles wrap naturally instead of clipping a few pixels under the dense
   * mobile action cluster. */
  .chat-head-l { flex: 1 1 0; min-width: 0; overflow: hidden; }
  .chat-title {
    display: block; max-width: 100%; font-size: 0.92rem; line-height: 1.22;
    white-space: normal; overflow: visible; overflow-wrap: anywhere; text-overflow: clip;
  }
  .chat-sub {
    display: block; max-width: 100%; line-height: 1.25;
    white-space: normal; overflow: visible; overflow-wrap: anywhere; text-overflow: clip;
  }
  .chat-head-r { gap: 0.4rem; flex: 0 0 auto; min-width: 0; }
  /* The E2E badge is now a compact 🔒 chip that fits at every width, so it is no
     longer hidden on phones (paired with the chat.js syncHeaderForViewport no-op).
     Transient toast must also clear the taller composer on home-indicator phones —
     the base .chat-toast bottom has no safe-area term. */
  .chat-toast { bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); }
  .search-bar { gap: 0.45rem; padding: 0.55rem 0.7rem; }
  .search-count { font-size: 0.72rem; }
  /* sidebar → left drawer */
  .sidebar {
    display: flex; position: absolute; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(86vw, 300px); border-right: 1px solid var(--neon-cyan);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.65);
    clip-path: inset(0 100% 0 0); opacity: 0; visibility: hidden; pointer-events: none;
    transition: clip-path 0.24s ease, opacity 0.18s ease, visibility 0s linear 0.24s;
    overflow-x: hidden;
  }
  #sb-toggle:checked ~ .sidebar {
    clip-path: inset(0 0 0 0); opacity: 1; visibility: visible; pointer-events: auto;
    transition-delay: 0s;
  }

  /* userlist → right drawer */
  .userlist {
    display: flex; position: absolute; top: 0; right: 0; bottom: 0; z-index: 60;
    width: min(74vw, 260px); padding: 1.2rem;
    border-left: 1px solid var(--neon-pink); border-right: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.65);
    clip-path: inset(0 0 0 100%); opacity: 0; visibility: hidden; pointer-events: none;
    transition: clip-path 0.24s ease, opacity 0.18s ease, visibility 0s linear 0.24s;
    overflow-x: hidden;
  }
  #ul-toggle:checked ~ .userlist {
    clip-path: inset(0 0 0 0); opacity: 1; visibility: visible; pointer-events: auto;
    transition-delay: 0s;
  }

  /* Dimmed backdrop — each scrim only appears for its OWN open drawer, so
   * tapping it closes that drawer (not toggles the other one). A shared
   * .drawer-scrim selector here would match both labels and the later one
   * (ul) would sit on top, opening the userlist when you meant to close
   * the sidebar. */
  #sb-toggle:checked ~ .sb-scrim,
  #ul-toggle:checked ~ .ul-scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(7, 7, 13, 0.62); cursor: pointer;
  }

  .composer { --cmp-h: 3.1rem; padding: 0.7rem 0.9rem; gap: 0.5rem; padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px)); }
  .composer input, .composer textarea { font-size: 0.95rem; }
  /* Phones: compact the SEND label; every control still shares --cmp-h. */
  .composer .btn-neon { min-width: 5rem; padding: 0 0.8rem; font-size: 0.76rem; letter-spacing: 0.02em; }
  .composer-attach, .composer-emoji { font-size: 1.1rem; }
  .call-card { width: 96vw; max-height: 92vh; padding: 0.7rem; }
  .call-stage { min-height: 280px; }
  .call-local-video { width: 112px; height: 84px; right: 0.55rem; bottom: 0.55rem; }
  .call-pill { min-width: 7rem; }
}

/* Tiny phones (<=400px): trim the header control cluster so it never exceeds the
   viewport even with the E2E chip shown + (Pro) call buttons. Controls stay
   tappable; the chip stays visible, just smaller. Placed AFTER the <=700px block
   so these overrides win on source order. */
@media (max-width: 400px) {
  .chat-head-r { gap: 0.3rem; }
  .lock-badge { width: 32px; height: 32px; font-size: 0.9rem; }
  .chat-users-btn { padding: 0 0.5rem; }
  .composer .btn-neon { min-width: var(--cmp-h); padding: 0 0.7rem; }
}
