/* ══════════════════════════════════════════════════════════════
   BARE RADIO — Video Chat UI
   Aesthetic: Sports broadcast · Bold American radio · Signal tower
   Palette: #0C0D14 · #CC1C2E · #1A3AA0 · #FFFFFF
   ══════════════════════════════════════════════════════════════ */

/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #000000;
  --bg2:         #0a0a0a;
  --bg3:         #111113;
  --red:         #CC1C2E;
  --red-bright:  #E8223B;
  --red-dim:     #8f1220;
  --blue:        #1A3AA0;
  --blue-bright: #2148C8;
  --blue-dim:    #102370;
  --white:       #FFFFFF;
  --cream:       #EEF0F8;
  --grey:        #5a5c70;
  --grey-lt:     #8a8da8;
  --font-disp:   'Bebas Neue', 'Impact', sans-serif;
  --font-mono:   'IBM Plex Mono', 'Courier New', monospace;
  --font-ui:     'Space Grotesk', sans-serif;
  --tile-radius: 4px;
  --glow-red:    0 0 16px rgba(204,28,46,0.65), 0 0 40px rgba(204,28,46,0.25);
  --glow-blue:   0 0 14px rgba(26,58,160,0.7),  0 0 32px rgba(26,58,160,0.3);
  --topbar-h:    52px;
}

html, body {
  height: 100%;
  height: -webkit-fill-available;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-ui);
  overflow: hidden;
}

/* ── NOISE & SCANLINES ────────────────────────────────────── */
.join-noise {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}
.join-scanlines {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, transparent 0px, transparent 2px,
    rgba(0,0,0,0.18) 2px, rgba(0,0,0,0.18) 4px
  );
}

/* ── SIGNAL DOT ───────────────────────────────────────────── */
.signal-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red); box-shadow: var(--glow-red);
  animation: pulse-dot 1.2s ease-in-out infinite; flex-shrink: 0;
}
.signal-dot.small { width: 7px; height: 7px; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ── FREQUENCY BARS ───────────────────────────────────────── */
.freq-bars { display: flex; align-items: flex-end; gap: 3px; height: 40px; margin: 20px 0; }
.freq-bars.small { height: 24px; margin: 6px 0; }
.freq-bars span {
  flex: 1; background: var(--red); border-radius: 1px; min-height: 4px;
  animation: freq-anim 0.8s ease-in-out infinite alternate;
}
.freq-bars span:nth-child(even) { background: var(--blue-bright); }
.freq-bars span:nth-child(1)  { animation-delay: 0.00s; }
.freq-bars span:nth-child(2)  { animation-delay: 0.07s; }
.freq-bars span:nth-child(3)  { animation-delay: 0.14s; }
.freq-bars span:nth-child(4)  { animation-delay: 0.21s; }
.freq-bars span:nth-child(5)  { animation-delay: 0.28s; }
.freq-bars span:nth-child(6)  { animation-delay: 0.35s; }
.freq-bars span:nth-child(7)  { animation-delay: 0.42s; }
.freq-bars span:nth-child(8)  { animation-delay: 0.49s; }
.freq-bars span:nth-child(9)  { animation-delay: 0.10s; }
.freq-bars span:nth-child(10) { animation-delay: 0.17s; }
.freq-bars span:nth-child(11) { animation-delay: 0.24s; }
.freq-bars span:nth-child(12) { animation-delay: 0.31s; }
.freq-bars span:nth-child(13) { animation-delay: 0.38s; }
.freq-bars span:nth-child(14) { animation-delay: 0.45s; }
.freq-bars span:nth-child(15) { animation-delay: 0.52s; }
.freq-bars span:nth-child(16) { animation-delay: 0.59s; }
@keyframes freq-anim {
  from { height: 4px; }
  to   { height: 100%; }
}

/* ════════════════════════════════════════════════════════════
   JOIN SCREEN
   ════════════════════════════════════════════════════════════ */
.join-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(26,58,160,0.18) 0%, transparent 65%),
    radial-gradient(ellipse 55% 45% at 20% 20%, rgba(204,28,46,0.10) 0%, transparent 60%);
}

.join-inner {
  position: relative; z-index: 2;
  width: min(420px, 92vw);
  display: flex; flex-direction: column; align-items: center;
  animation: fade-up 0.6s ease both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.on-air-tag {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.25em;
  color: var(--red-bright); border: 1px solid var(--red); padding: 2px 8px;
  border-radius: 2px; box-shadow: var(--glow-red);
}
.brand-logo {
  width: min(280px, 70vw); height: auto;
  filter: drop-shadow(0 4px 24px rgba(204,28,46,0.45)) drop-shadow(0 0 60px rgba(26,58,160,0.3));
  animation: logo-breathe 4s ease-in-out infinite;
}
@keyframes logo-breathe {
  0%, 100% { filter: drop-shadow(0 4px 24px rgba(204,28,46,0.45)) drop-shadow(0 0 60px rgba(26,58,160,0.3)); }
  50%       { filter: drop-shadow(0 4px 32px rgba(204,28,46,0.7)) drop-shadow(0 0 80px rgba(26,58,160,0.5)); }
}
.brand-sub {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.35em;
  color: var(--blue-bright); text-transform: uppercase; margin-top: 4px; opacity: 0.9;
}

/* ── JOIN FORM ────────────────────────────────────────────── */
.join-form { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.join-welcome {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--grey-lt); text-align: center; margin-bottom: 4px;
}
.join-uname { color: var(--cream); font-weight: 700; }

.logout-link {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--grey); text-align: center; text-decoration: none;
  transition: color 0.18s;
}
.logout-link:hover { color: var(--red-bright); }
.form-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.2em;
  color: var(--grey-lt); margin-bottom: -4px; margin-top: 6px;
}
.form-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--grey);
  border-radius: var(--tile-radius); color: var(--cream);
  font-family: var(--font-mono); font-size: 14px; font-weight: 500;
  padding: 10px 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input::placeholder { color: var(--grey); }
.form-input:focus { border-color: var(--blue-bright); box-shadow: 0 0 0 2px rgba(26,58,160,0.25); }

.camera-preview-wrap {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #000; border: 1px solid var(--grey); border-radius: var(--tile-radius); overflow: hidden;
}
.preview-label {
  position: absolute; top: 8px; left: 10px; z-index: 2;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.2em;
  color: var(--blue-bright);
}
.camera-preview-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  border: none; border-radius: var(--tile-radius); cursor: pointer;
  padding: 12px 20px; transition: all 0.18s ease; text-transform: uppercase;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--glow-red); }
.btn-primary:hover:not(:disabled) {
  background: var(--red-bright);
  box-shadow: 0 0 28px rgba(255,59,0,0.8), 0 0 60px rgba(255,59,0,0.3);
  transform: translateY(-1px);
}
.btn-primary:disabled { background: var(--bg3); color: var(--grey); box-shadow: none; cursor: not-allowed; }
.btn-secondary {
  background: transparent; color: var(--blue-bright);
  border: 1px solid var(--blue-bright); box-shadow: var(--glow-blue);
}
.btn-secondary:hover { background: rgba(26,58,160,0.12); transform: translateY(-1px); }
.btn-leave {
  background: transparent; color: var(--red); border: 1px solid var(--red);
  font-size: 11px; padding: 6px 14px;
}
.btn-leave:hover { background: rgba(255,59,0,0.1); }
.join-error {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--red);
  text-align: center; padding: 6px; border: 1px solid rgba(255,59,0,0.3);
  border-radius: var(--tile-radius); background: rgba(255,59,0,0.05); animation: fade-up 0.3s ease;
}

/* ════════════════════════════════════════════════════════════
   CHAT ROOM SHELL
   ════════════════════════════════════════════════════════════ */
.chat-room {
  display: flex; flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  background: var(--bg);
  animation: fade-up 0.4s ease both;
}

/* ── TOP BAR ──────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: var(--topbar-h); flex-shrink: 0;
  background: var(--bg2); border-bottom: 1px solid rgba(204,28,46,0.25);
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo { height: 34px; width: auto; filter: drop-shadow(0 2px 8px rgba(204,28,46,0.5)); }
.topbar-room {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.2em;
  color: var(--blue-bright); background: rgba(26,58,160,0.15); border: 1px solid rgba(26,58,160,0.4);
  padding: 2px 8px; border-radius: 2px; text-transform: uppercase;
}
.topbar-info { display: flex; align-items: center; gap: 16px; position: relative; }
.lang-toggle {
  display: flex;
  gap: 4px;
  align-items: center;
}
.lang-btn {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 0;
  display: flex;
  align-items: center;
}
.lang-btn img { display: block; border-radius: 2px; }
.lang-btn:hover { opacity: 1; border-color: rgba(255,255,255,0.4); transform: scale(1.08); }
.lang-btn.active { opacity: 1; border-color: var(--red); box-shadow: 0 0 6px rgba(204,28,46,0.4); }
.viewer-count {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
}
.vc-icon { color: var(--red); animation: pulse-dot 1.2s ease-in-out infinite; font-size: 10px; }

/* Topbar icon button (bg picker) */
.topbar-icon-btn {
  width: 32px; height: 32px; background: transparent;
  border: 1px solid var(--grey); border-radius: var(--tile-radius);
  font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.18s, border-color 0.18s;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.07); border-color: var(--grey-lt); }
.topbar-icon-btn.active { border-color: var(--blue-bright); }

/* Background picker panel */
.bg-btn-wrap { position: relative; display: inline-flex; }
.bg-picker {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 200;
  width: 260px;
  animation: fade-up 0.18s ease both;
}
.bg-picker-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.22em;
  color: var(--grey); margin-bottom: 10px; display: block;
}
/* Category tabs */
.bg-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: rgba(0,0,0,0.3); border-radius: 6px; padding: 3px;
}
.bg-tab {
  flex: 1; padding: 6px 8px; cursor: pointer;
  background: transparent; border: none; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--grey-lt);
  transition: background 0.15s, color 0.15s;
}
.bg-tab:hover { color: #fff; }
.bg-tab.active { background: var(--red); color: #fff; }
.bg-swatches {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.bg-swatch {
  width: 100%; aspect-ratio: 1;
  border-radius: 5px; border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer; transition: border-color 0.15s, transform 0.12s;
}
.bg-swatch:hover { transform: scale(1.12); }
.bg-swatch.active { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
/* Image background grid */
.bg-image-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-height: 240px; overflow-y: auto;
}
.bg-image-thumb {
  width: 100%; aspect-ratio: 16/10;
  border-radius: 5px; border: 2px solid rgba(255,255,255,0.15);
  cursor: pointer; transition: border-color 0.15s, transform 0.12s;
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
.bg-image-thumb:hover { transform: scale(1.06); }
.bg-image-thumb.active { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.bg-image-hint {
  font-family: var(--font-mono); font-size: 11px; color: var(--grey-lt);
  text-align: center; padding: 18px 4px;
}

/* ── WORKSPACE ────────────────────────────────────────────── */
.workspace {
  flex: 1; overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 360px;
}

/* ════════════════════════════════════════════════════════════
   CHAT — MAIN AREA
   ════════════════════════════════════════════════════════════ */
.chat-main {
  display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}

.chat-messages {
  flex: 1; list-style: none;
  overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--grey); border-radius: 2px; }

/* Message bubbles — ALL left-aligned */
.chat-msg { display: flex; flex-direction: column; gap: 4px; animation: fade-up 0.25s ease both; }

.msg-header { display: flex; align-items: center; gap: 6px; }

.msg-name {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--blue-bright); text-transform: uppercase;
}
/* Own messages: name in red, bubble has red accent — still left side */
.chat-msg.mine .msg-name { color: var(--red-bright); }

.msg-cam-icon {
  font-size: 11px; opacity: 0.7; line-height: 1;
  cursor: pointer; transition: opacity 0.15s;
}
.msg-cam-icon:hover { opacity: 1; }

.msg-time {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--grey); margin-left: auto;
}
.msg-text {
  font-family: var(--font-ui); font-size: var(--chat-font-size, 17px); line-height: 1.5;
  color: var(--cream); word-break: break-word;
  background: var(--bg3); padding: 8px 12px;
  border-radius: 2px 8px 8px 8px; border-left: 2px solid var(--blue-bright);
  max-width: 680px;
}
.chat-msg.mine .msg-text { border-left-color: var(--red-bright); }

/* @mention styling */
.mention {
  font-weight: 700;
  color: var(--blue-bright);
  background: rgba(96,165,250,0.12);
  border-radius: 3px;
  padding: 0 3px;
}
.mention-me {
  color: var(--red-bright);
  background: rgba(204,28,46,0.15);
  animation: mention-flash 0.6s ease;
}
@keyframes mention-flash {
  0%,100% { background: rgba(204,28,46,0.15); }
  40%      { background: rgba(204,28,46,0.45); }
}

/* @mention autocomplete dropdown */
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 999;
  list-style: none;
  margin: 0; padding: 4px 0;
  background: var(--bg3);
  border: 1px solid var(--blue-bright);
  border-radius: 8px;
  min-width: 160px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.mention-dropdown li {
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--cream);
  font-weight: 600;
  transition: background 0.1s;
}
.mention-dropdown li:hover,
.mention-dropdown li.active {
  background: rgba(96,165,250,0.18);
  color: var(--blue-bright);
}

/* System messages */
.chat-msg.system .msg-text {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em;
  color: var(--grey-lt); font-style: italic; background: transparent;
  border: none; padding: 0; border-radius: 0; text-align: center; align-self: center;
}

/* Welcome system message */
.chat-msg.system.welcome .msg-text {
  font-size: 16px; letter-spacing: 0.06em;
  color: #ffffff; font-style: normal; font-weight: 600;
  padding: 4px 0;
}

/* ── FORMATTING TOOLBAR ──────────────────────────────────── */
.format-toolbar {
  display: flex; align-items: center; gap: 3px;
  padding: 5px 12px 4px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: var(--bg2);
  flex-shrink: 0;
  position: relative;
}
.fmt-btn {
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; color: var(--grey-lt);
  font-family: var(--font-ui); font-size: 15px; font-weight: 700;
  padding: 4px 10px; cursor: pointer; transition: all .15s;
  line-height: 1.4;
}
.fmt-btn:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); color: var(--cream); }
.fmt-btn.active { background: rgba(26,58,160,.25); border-color: var(--blue-b); color: var(--cream); }
.fmt-color-wrap { position: relative; }
.fmt-color-swatch {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #ffffff; margin-right: 3px; vertical-align: middle;
  border: 1px solid rgba(255,255,255,.25);
}
.fmt-gif-btn { font-family: var(--font-mono); font-size: 13px; letter-spacing: .1em; }
.fmt-sep { width: 1px; height: 16px; background: rgba(255,255,255,.1); margin: 0 4px; }

/* ── GIF PICKER ───────────────────────────────────────────── */
.gif-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.7);
  z-index: 500;
  overflow: hidden;
}
.gif-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.gif-picker-title {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .18em; color: var(--grey-lt); text-transform: uppercase;
}
.gif-close-btn {
  background: none; border: none; color: var(--grey); font-size: 13px;
  cursor: pointer; padding: 0 2px; line-height: 1; transition: color .15s;
}
.gif-close-btn:hover { color: var(--cream); }
.gif-search-row { display: flex; gap: 6px; margin-bottom: 8px; }
.gif-search-input {
  flex: 1; background: var(--bg2); border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px; color: var(--cream); font-family: var(--font-ui);
  font-size: 12px; padding: 6px 10px; outline: none; transition: border-color .18s;
}
.gif-search-input:focus { border-color: var(--blue-bright); }
.gif-search-submit {
  background: var(--blue); border: none; border-radius: 4px; color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .12em; padding: 6px 12px; cursor: pointer; transition: background .15s;
}
.gif-search-submit:hover { background: var(--blue-bright); }
.gif-results {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px;
  max-height: 180px; overflow-y: auto;
}
.gif-results img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px;
  cursor: pointer; transition: transform .15s, opacity .15s; opacity: .85;
}
.gif-results img:hover { transform: scale(1.06); opacity: 1; }
.gif-hint { color: var(--grey); font-family: var(--font-mono); font-size: 10px;
  text-align: center; padding: 16px 0; grid-column: 1/-1; letter-spacing: .1em; }

/* ── CHAT GIF MESSAGE ─────────────────────────────────────── */
.msg-gif {
  max-width: 220px; border-radius: 6px; display: block;
  margin-top: 4px; cursor: pointer;
}

/* Chat input */
.clear-chat-bar {
  padding: 6px 16px;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: flex-end;
}
.clear-chat-btn {
  background: transparent;
  border: 1px solid rgba(204,28,46,0.35);
  color: var(--grey-lt);
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: .05em;
}
.clear-chat-btn:hover {
  background: rgba(204,28,46,0.12);
  border-color: var(--red-bright);
  color: var(--red-bright);
}

.chat-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0; background: var(--bg2);
  position: relative;
}
.chat-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--grey);
  border-radius: var(--tile-radius); color: var(--cream);
  font-family: var(--font-ui); font-size: 16px; padding: 11px 16px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input::placeholder { color: var(--grey); }
.chat-input:focus { border-color: var(--blue-bright); box-shadow: 0 0 0 2px rgba(26,58,160,0.2); }

/* Icon buttons in input row */
.input-icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--grey);
  border-radius: var(--tile-radius); cursor: pointer;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
  position: relative;
}
.input-icon-btn:hover { background: rgba(255,255,255,0.07); transform: scale(1.08); }
.input-icon-btn.active { border-color: var(--blue-bright); background: rgba(26,58,160,0.15); }
.input-icon-btn.cam-on  { border-color: var(--blue-bright); box-shadow: 0 0 8px rgba(26,58,160,0.35); }
.input-icon-btn.cam-off { border-color: var(--red); opacity: 0.6; }

/* Send button */
.chat-send-btn {
  background: var(--red); color: #fff; border: none;
  border-radius: var(--tile-radius); width: 44px; height: 44px; font-size: 18px;
  cursor: pointer; transition: background 0.18s, transform 0.12s;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--red-bright); transform: scale(1.06); }
.chat-send-btn:active { transform: scale(0.96); }

/* ── EMOJI PICKER ─────────────────────────────────────────── */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 16px;
  width: 300px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 200;
  animation: fade-up 0.18s ease both;
}
.emoji-picker-tabs {
  display: flex; gap: 4px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 6px;
}
.emoji-tab {
  background: none; border: none; cursor: pointer;
  font-size: 16px; padding: 3px 6px; border-radius: 4px;
  opacity: 0.5; transition: opacity 0.15s, background 0.15s;
}
.emoji-tab:hover, .emoji-tab.active { opacity: 1; background: rgba(255,255,255,0.08); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
}
.emoji-grid::-webkit-scrollbar { width: 3px; }
.emoji-grid::-webkit-scrollbar-thumb { background: var(--grey); border-radius: 2px; }
.emoji-btn-item {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 4px; border-radius: 4px; line-height: 1;
  transition: background 0.12s, transform 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.emoji-btn-item:hover { background: rgba(255,255,255,0.1); transform: scale(1.2); }

/* ── LOCAL CAM SIDEBAR ────────────────────────────────────── */
.local-cam-sidebar {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg3);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  flex-shrink: 0;
}
.local-cam-sidebar video {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  transform: scaleX(-1); /* mirror own camera */
}
/* scanline overlay */
.local-cam-sidebar::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, transparent 0px, transparent 2px,
    rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px
  );
}
/* name label bottom-left */
.local-cam-label {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 4;
  padding: 4px 8px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--blue-bright);
  background: linear-gradient(to top, rgba(10,11,20,0.85) 0%, transparent 100%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* profile button — top-right corner of cam preview */
.local-cam-profile-btn {
  position: absolute; top: 6px; right: 6px; z-index: 5;
  width: 24px; height: 24px;
  background: rgba(10,11,20,0.65); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%; color: var(--grey-lt); font-size: 13px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}
.local-cam-profile-btn:hover {
  background: var(--blue); border-color: var(--blue-bright); color: #fff;
}
/* cam-off state */
.local-cam-sidebar .local-cam-off {
  display: none;
  position: absolute; inset: 0; z-index: 3;
  align-items: center; justify-content: center; flex-direction: column; gap: 6px;
  background: var(--bg2);
}
.local-cam-sidebar.cam-off video { visibility: hidden; }
.local-cam-sidebar.cam-off .local-cam-off { display: flex; }
.local-cam-off .cam-off-icon { font-size: 22px; opacity: 0.25; }
.local-cam-off .cam-off-text {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.15em; color: var(--grey);
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg2); border-left: 1px solid rgba(26,58,160,0.2);
  overflow-y: auto; min-height: 0;
}
.sidebar-section { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.05); }
/* The user-list section is the flexible, internally-scrolling region so the
   sidebar itself never grows a scrollbar when the cam picker appears. */
.sidebar > .sidebar-section {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.sidebar-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.25em;
  color: var(--grey); margin-bottom: 10px;
}

/* User list */
.user-list {
  list-style: none; display: flex; flex-direction: column; gap: 7px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
}
.user-list::-webkit-scrollbar { width: 2px; }
.user-list::-webkit-scrollbar-thumb { background: var(--grey); }
.user-list li {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--cream);
  animation: fade-up 0.3s ease both;
}
.user-list li .ul-dot { display: none; } /* replaced by avatar */
.user-list li.you .ul-dot { display: none; }
.user-list li .ul-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.user-list li .ul-cam { font-size: 11px; opacity: 0.6; flex-shrink: 0; }

/* Webcam view button */
.cam-view-btn {
  background: none;
  border: none;
  padding: 3px 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
  border-radius: 6px;
}
.cam-view-btn:hover {
  opacity: 1;
  transform: scale(1.15);
  background: rgba(255,255,255,0.08);
}
.cam-view-btn svg { display: block; }

/* Viewer count badge on webcam button */
.viewer-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  background: var(--red-bright);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.cam-view-btn { position: relative; }

/* Camera control row — directly under the cam preview */
.cam-ctrl-row {
  flex-shrink: 0; padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cam-ctrl-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--bg3); border: 1px solid var(--grey); border-radius: var(--tile-radius);
  color: var(--grey-lt); font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; padding: 7px 12px; cursor: pointer; transition: all 0.18s;
}
.cam-ctrl-btn.active {
  border-color: var(--blue-bright); color: var(--blue-bright);
  box-shadow: 0 0 8px rgba(26,58,160,0.3);
}
.cam-ctrl-btn:hover { background: rgba(255,255,255,0.04); }
.ctrl-text { font-size: 10px; }

/* Camera source picker (webcam / ManyCam / OBS Virtual Camera) */
.cam-select {
  flex-shrink: 0; width: calc(100% - 20px); margin: 0 10px 8px;
  background: var(--bg3); color: var(--grey-lt);
  border: 1px solid var(--grey); border-radius: var(--tile-radius);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  padding: 6px 8px; cursor: pointer; transition: border-color 0.18s;
}
.cam-select:hover, .cam-select:focus { border-color: var(--blue-bright); outline: none; }

/* Cam-view button pending (awaiting owner approval) */
.cam-view-btn.cam-view-pending {
  animation: vr-pulse 1s ease-in-out infinite;
  opacity: 0.7;
}
@keyframes vr-pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ── CAMERA VIEW REQUEST MODAL ─────────────────────────────── */
.view-request-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(4px);
  animation: vr-fade 0.18s ease;
}
@keyframes vr-fade { from { opacity: 0; } to { opacity: 1; } }
.view-request-inner {
  width: min(92vw, 380px); background: var(--bg2);
  border: 1px solid var(--red); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(204,28,46,0.15);
  padding: 28px 24px 24px; text-align: center;
  animation: vr-pop 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes vr-pop { from { transform: scale(0.9) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.vr-icon {
  font-size: 34px; line-height: 1; margin-bottom: 10px;
  filter: drop-shadow(0 0 10px rgba(204,28,46,0.5));
}
.vr-title {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: #fff; margin: 0 0 10px;
}
.vr-text { color: var(--grey-lt); font-size: 14px; line-height: 1.5; margin: 0 0 22px; }
.vr-text strong { color: var(--red-bright); font-weight: 700; }
.vr-actions { display: flex; gap: 10px; }
.vr-btn {
  flex: 1; padding: 11px 12px; border-radius: 8px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; transition: all 0.16s;
}
.vr-allow { background: var(--red); color: #fff; border: 1px solid var(--red); box-shadow: var(--glow-red); }
.vr-allow:hover { background: var(--red-bright); transform: translateY(-1px); }
.vr-deny { background: transparent; color: var(--grey-lt); border: 1px solid var(--grey); }
.vr-deny:hover { border-color: #fff; color: #fff; }

/* ── ADMIN USER-INFO MODAL ─────────────────────────────────── */
.userinfo-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(4px);
  animation: vr-fade 0.18s ease;
}
.userinfo-inner {
  position: relative; width: min(94vw, 440px); max-height: 86vh; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--blue-bright); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(33,72,200,0.15);
  padding: 24px; animation: vr-pop 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.userinfo-close-btn {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: var(--grey-lt); font-size: 26px; line-height: 1; cursor: pointer; transition: color 0.15s;
}
.userinfo-close-btn:hover { color: #fff; }
.userinfo-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.userinfo-avatar, .userinfo-avatar-ph {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  border: 2px solid var(--blue-bright);
}
.userinfo-avatar-ph {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--cream); font-weight: 700; font-size: 22px;
}
.userinfo-name { margin: 0; font-size: 19px; color: #fff; font-weight: 700; word-break: break-word; }
.userinfo-role {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--blue-bright); font-weight: 700;
}
.userinfo-rows { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.userinfo-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.userinfo-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--grey-lt); flex-shrink: 0;
}
.userinfo-val { color: var(--cream); font-size: 13px; text-align: right; word-break: break-all; }
.userinfo-iptitle {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--grey-lt); margin: 4px 0 8px;
}
.userinfo-iplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.userinfo-iplist li {
  display: flex; justify-content: space-between; gap: 12px;
  font-family: var(--font-mono); font-size: 12px; color: var(--cream);
  background: var(--bg); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px; padding: 7px 10px;
}
.userinfo-iplist li .ui-ip { font-weight: 700; }
.userinfo-iplist li .ui-at { color: var(--grey-lt); }
.userinfo-iplist li.empty { justify-content: center; color: var(--grey-lt); font-style: italic; }

/* Admin info button in user list + clickable chat name */
.mod-btn.info-btn { /* inherits mod-btn styling */ }
.msg-name.admin-clickable { cursor: pointer; text-decoration: underline dotted transparent; transition: text-decoration-color 0.15s; }
.msg-name.admin-clickable:hover { text-decoration-color: currentColor; }

/* ── TOAST ─────────────────────────────────────────────────── */
.app-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  z-index: 10000; max-width: 86vw;
  background: var(--bg2); color: #fff; border: 1px solid var(--blue-bright);
  border-radius: 8px; padding: 11px 18px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.03em;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.toast-red { border-color: var(--red); }

.sidebar-freq { flex-shrink: 0; }
.sidebar-tag { display: none; } /* replaced by sidebar-credit */

/* ── AVATARS ──────────────────────────────────────────────── */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg3);
}
.avatar-placeholder {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid rgba(255,255,255,0.1);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: var(--grey-lt); text-transform: uppercase;
}
.avatar.sm, .avatar-placeholder.sm { width: 22px; height: 22px; font-size: 8px; }

/* ── PROFILE MODAL ────────────────────────────────────────── */
.profile-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5, 6, 14, 0.82);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
.profile-modal-inner {
  position: relative;
  width: min(380px, 94vw);
  background: var(--bg2);
  border: 1px solid rgba(26,58,160,0.35);
  border-radius: 6px;
  padding: 28px 28px 24px;
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  animation: modal-in 0.22s cubic-bezier(0.34,1.4,0.64,1);
}
@keyframes modal-in { from { transform: scale(0.93); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.profile-close-btn {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 4px;
  background: transparent; border: 1px solid rgba(255,255,255,0.1);
  color: var(--grey-lt); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.profile-close-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }
.profile-title {
  font-family: var(--font-disp); font-size: 22px; letter-spacing: 0.05em;
  color: var(--cream); margin: 0;
}
/* Avatar section */
.profile-avatar-section {
  display: flex; align-items: center; gap: 18px;
}
.profile-avatar-wrap {
  position: relative; width: 72px; height: 72px; flex-shrink: 0;
}
.profile-avatar-img {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--blue-bright);
}
.profile-avatar-placeholder {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg3); border: 2px solid var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-disp); font-size: 26px; color: var(--blue-bright);
  letter-spacing: 0.05em;
}
.profile-avatar-actions {
  display: flex; flex-direction: column; gap: 8px;
}
/* Divider */
.profile-divider {
  height: 1px; background: rgba(255,255,255,0.07); margin: 0 -28px;
}
/* Password section */
.profile-pw-section {
  display: flex; flex-direction: column; gap: 8px;
}
.profile-section-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.22em; color: var(--grey); margin-bottom: 2px;
}
.profile-input {
  background: var(--bg3); border: 1px solid var(--grey); border-radius: 4px;
  color: var(--cream); font-family: var(--font-mono); font-size: 13px;
  padding: 9px 12px; outline: none; width: 100%;
  transition: border-color 0.2s;
}
.profile-input:focus { border-color: var(--blue-bright); }
.profile-status {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  min-height: 16px;
}
.profile-status.ok { color: #3ddc84; }
.profile-status.err { color: var(--red-bright); }

.avatar-upload-hint {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em;
  color: var(--grey-lt); text-align: center; margin-top: 4px;
  text-transform: uppercase;
}

/* ── RADIO PLAYER ─────────────────────────────────────────── */
.sidebar-player {
  display: flex; flex-direction: column; gap: 10px;
  padding: 0;
  border-bottom: none;
}
/* Now playing row */
.player-nowplaying {
  display: flex; align-items: center; gap: 10px;
}
.player-art-wrap { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.player-art {
  width: 64px; height: 64px; border-radius: 6px; object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
}
.player-art-ph {
  width: 64px; height: 64px; border-radius: 6px;
  background: var(--bg3); border: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
}
.player-art-icon { font-size: 26px; }
.player-track-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px;
}
.player-title {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.04em;
}
.player-artist {
  font-family: var(--font-mono); font-size: 11px; color: var(--grey-lt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.08em;
}
/* Freq bars pause state */
.player-freq-bars.paused span { animation-play-state: paused !important; height: 3px !important; }
/* Controls row */
.player-controls {
  display: flex; align-items: center; gap: 8px;
}
.player-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg3); color: var(--cream);
  font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.player-btn:hover { background: var(--blue); border-color: var(--blue-bright); }
.play-btn.playing {
  background: var(--red); border-color: var(--red-bright);
  box-shadow: 0 0 10px rgba(204,28,46,0.5);
}
.stop-btn:hover { background: var(--bg3); border-color: var(--grey-lt); color: var(--grey-lt); }
/* Volume */
.player-vol-wrap {
  display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0;
}
.player-vol-icon { font-size: 11px; flex-shrink: 0; opacity: 0.7; }
.player-vol {
  flex: 1; height: 3px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.15); border-radius: 2px; outline: none; cursor: pointer;
}
.player-vol::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue-bright); cursor: pointer;
  box-shadow: 0 0 4px rgba(33,72,200,0.6);
}
.player-vol::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; border: none;
  background: var(--blue-bright); cursor: pointer;
}

/* ── SIDEBAR BOTTOM CREDIT ────────────────────────────────── */
.sidebar-bottom {
  flex-shrink: 0;
  margin-top: auto;
  padding: 10px 16px;
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.sidebar-credit {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--red) 0%, var(--blue-b) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: white;
  background-clip: text;
  opacity: 1;
  text-shadow: none;
  display: block;
  text-align: center;
  padding: 2px 0 2px;
}

/* ════════════════════════════════════════════════════════════
   FLOATING VIDEO TILES
   ════════════════════════════════════════════════════════════ */
.video-container {
  position: fixed; inset: 0;
  pointer-events: none;   /* clicks pass through to chat */
  z-index: 50;
}

.video-tile {
  position: absolute;
  pointer-events: all;    /* tiles themselves are interactive */
  width: 240px; height: 180px;
  min-width: 140px; min-height: 36px;
  background: #000;
  border: 1px solid var(--grey);
  border-radius: 6px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
  transition: box-shadow 0.2s;
  animation: tile-enter 0.3s ease both;
}
@keyframes tile-enter {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
.video-tile:hover { box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(26,58,160,0.4); }
.video-tile.local { border-color: var(--blue-bright); box-shadow: 0 8px 32px rgba(0,0,0,0.6), var(--glow-blue); }

/* Drag bar (title bar) */
.tile-dragbar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px; height: 28px; flex-shrink: 0;
  background: var(--bg3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: move; user-select: none;
}
.tile-drag-icon {
  font-size: 10px; opacity: 0.4; letter-spacing: -1px; flex-shrink: 0;
}
.tile-dragbar-name {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--grey-lt); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1;
}
.video-tile.local .tile-dragbar-name { color: var(--blue-bright); }

/* Drag bar action buttons */
.tile-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.tile-btn {
  width: 18px; height: 18px;
  background: rgba(255,255,255,0.08);
  border: none; border-radius: 3px; cursor: pointer;
  color: var(--grey-lt); font-size: 10px; font-family: var(--font-mono); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.tile-btn:hover { background: rgba(255,255,255,0.18); color: var(--white); }
.tile-btn.close-btn:hover { background: var(--red); color: #fff; }

/* Video body */
.tile-body {
  flex: 1; position: relative; overflow: hidden; min-height: 0;
}
.tile-body video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.video-tile.local .tile-body video { transform: scaleX(-1); }

/* CRT scanline on video */
.tile-body::before {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom, transparent 0px, transparent 2px,
    rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px
  );
}

/* Cam-off state */
.tile-cam-off {
  position: absolute; inset: 0; z-index: 5; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 6px;
  background: var(--bg2);
}
.tile-cam-off .cam-off-icon { font-size: 24px; opacity: 0.3; }
.tile-cam-off .cam-off-text {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.15em; color: var(--grey);
}
.video-tile.cam-off .tile-cam-off { display: flex; }
.video-tile.cam-off .tile-body video { visibility: hidden; }

/* Resize handle (bottom-right corner) */
.tile-resize {
  position: absolute; bottom: 0; right: 0; z-index: 10;
  width: 16px; height: 16px; cursor: se-resize;
  pointer-events: all;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.15) 50%);
}

/* Minimised state — body hidden, tile collapses to drag bar height */
.video-tile.minimised .tile-body { display: none; }
.video-tile.minimised .tile-resize { display: none; }
.video-tile.minimised { height: 28px !important; }

/* ── ROLE BADGES ──────────────────────────────────────────── */
.role-badge {
  display: inline-flex; align-items: center;
  padding: 1px 5px;
  font-family: var(--font-mono); font-size: 8px; font-weight: 700;
  letter-spacing: 0.12em; border-radius: 2px;
  color: var(--badge-color, #fff);
  border: 1px solid var(--badge-color, #fff);
  opacity: 0.9; flex-shrink: 0; vertical-align: middle;
  text-transform: uppercase;
}
.role-badge.small { font-size: 7px; padding: 0 4px; }

/* ── KICK / BAN BUTTONS ───────────────────────────────────── */
.mod-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; padding: 0 2px; line-height: 1;
  opacity: 0.5; transition: opacity 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.mod-btn:hover { opacity: 1; transform: scale(1.25); }
.kick-btn:hover { filter: sepia(1) saturate(4) hue-rotate(0deg); }
.ban-btn:hover  { filter: sepia(1) saturate(5) hue-rotate(315deg); }

/* ── ROOM ALERT (kick/ban notification) ───────────────────── */
.room-alert {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 9999;
  background: #10111C; border: 2px solid var(--red);
  color: var(--cream); padding: 18px 32px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  letter-spacing: 0.1em; text-align: center;
  border-radius: 4px; box-shadow: 0 0 40px rgba(204,28,46,0.45);
  opacity: 1; transition: opacity 0.4s;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════
   MOBIL / RESPONSIV
   ══════════════════════════════════════════════════════════ */

.mobile-only { display: none !important; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 89;
  background: rgba(0,0,0,0.65);
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {

  .mobile-only { display: flex !important; }
  .viewer-count { display: none; }

  /* Korrekt høyde på mobil — ekskluderer nettleserens verktøylinje */
  html, body { height: 100dvh; height: -webkit-fill-available; }
  .chat-room  { height: 100dvh; height: -webkit-fill-available; }

  .workspace {
    grid-template-columns: 1fr;
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Chat-main fyller hele bredden */
  .chat-main {
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* Sidebar som drawer fra høyre */
  .sidebar {
    position: fixed;
    top: var(--topbar-h); right: -320px; bottom: 0;
    width: 300px; z-index: 90;
    transition: right 0.25s ease;
    border-left: 1px solid rgba(255,255,255,0.08);
    overflow-y: auto;
  }
  .sidebar.mobile-open { right: 0; }

  /* ☰-knapp — stor og tydelig */
  #sidebar-toggle {
    width: 44px; height: 44px;
    font-size: 22px;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #fff !important;
    background: rgba(255,255,255,0.08) !important;
  }

  .chat-messages { padding: 12px; gap: 12px; }
  .msg-text { max-width: 100%; padding: 10px 14px; }

  /* Format-toolbar — scroll horisontalt */
  .format-toolbar {
    overflow-x: auto; flex-wrap: nowrap;
    gap: 2px; padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .format-toolbar::-webkit-scrollbar { display: none; }

  /* Input alltid synlig nederst */
  .chat-input-row {
    padding: 8px 10px;
    gap: 6px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
  }
  .chat-input {
    font-size: 16px; /* hindrer iOS auto-zoom */
    padding: 10px 12px;
  }
  .input-icon-btn { width: 44px; height: 44px; font-size: 20px; }
  .chat-send-btn  { width: 44px; height: 44px; font-size: 16px; }

  .topbar { padding: 0 12px; }
  .topbar-logo { height: 28px; }
  .btn-leave { font-size: 10px; padding: 5px 10px; }

  .gif-picker { left: 0; right: 0; width: auto; }
  .local-cam-sidebar { height: 140px; }
}

@media (max-width: 480px) {
  .topbar-room { display: none; }
  .msg-name { font-size: 11px; }
}
