/* WatchTogether — dark RTL theme, Vazirmatn. One accent color. */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1f232c;
  --border: #2a2f3a;
  --text: #eef1f6;
  --text-dim: #9aa3b2;
  --text-faint: #656d7d;
  --accent: #7c5cff;
  --accent-hover: #6a49f2;
  --accent-soft: rgba(124, 92, 255, 0.15);
  --green: #3ddc84;
  --orange: #ffab40;
  --red: #ff5c6c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Buttons & inputs --- */
button, input, select {
  font-family: inherit;
  font-size: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { background: var(--bg-elev-2); }
.btn.subtle {
  background: var(--bg-elev-2);
  color: var(--text-dim);
}
.btn.subtle:hover { background: var(--border); color: var(--text); }
.btn.sm { padding: 8px 14px; font-size: 0.9rem; }

.field {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--text-faint); }

label.lbl {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* --- Home page --- */
.home-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.home-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.brand h1 { font-size: 1.6rem; margin: 0; font-weight: 700; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}
.tagline { color: var(--text-dim); margin: 0 0 28px; font-size: 0.95rem; }

.section { margin-bottom: 22px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > .field { flex: 1; }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-faint); font-size: 0.85rem;
  margin: 24px 0;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Mode picker */
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  background: var(--bg-elev-2);
  transition: border-color 0.15s, background 0.15s;
}
.mode-opt:hover { border-color: var(--text-faint); }
.mode-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt .t { font-weight: 500; margin-bottom: 4px; }
.mode-opt .d { font-size: 0.8rem; color: var(--text-dim); line-height: 1.5; }

/* --- Room page --- */
.room-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}
/* Sheet/FAB are mobile-only; hidden on desktop */
.sheet-header { display: none; }
.mobile-fab { display: none; }
.voice-ptt-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-dim); cursor: pointer; }
.voice-ptt-row input { accent-color: var(--accent); width: 16px; height: 16px; }
#voice-mute-btn.active { color: var(--green); }

@media (max-width: 820px) {
  .room-wrap { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .topbar { padding: 12px 14px; }
  .status { margin: 12px 14px !important; }
  .stage { border-radius: 0; border-left: none; border-right: none; }

  /* Touch-friendly controls */
  .ctrl-row { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ctrl-row::-webkit-scrollbar { display: none; }
  .ctrl-btn { padding: 9px; }
  .progress { height: 22px; }
  .pb-track, .pb-buffer, .pb-played { height: 6px; }
  .vol { display: none; }              /* keep the mute button; drop the slider */
  .reaction { font-size: 1.7rem; }
  .menu { max-width: 72vw; }

  /* Sidebar becomes a slide-up bottom sheet */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--bg-elev); border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,0.55);
    max-height: 80vh; overflow-y: auto; gap: 12px;
    padding: 0 14px calc(14px + env(safe-area-inset-bottom));
    transform: translateY(100%); transition: transform 0.28s ease;
  }
  .sidebar.open { transform: translateY(0); }
  .sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: var(--bg-elev); z-index: 2;
    padding: 12px 0 10px; margin-bottom: 2px; border-bottom: 1px solid var(--border);
  }
  .sheet-tabs { display: flex; gap: 6px; }
  .sheet-tab {
    background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
    padding: 7px 18px; border-radius: 20px; cursor: pointer; font-size: 0.9rem; font-family: inherit;
  }
  .sheet-tab.active { background: var(--accent); color: #fff; border-color: transparent; }
  .sheet-close { background: transparent; border: none; color: var(--text-dim); font-size: 1.25rem; cursor: pointer; padding: 4px 8px; }

  /* Tab visibility inside the sheet */
  .sidebar[data-tab="chat"] .grp-people { display: none; }
  .sidebar[data-tab="people"] .grp-chat { display: none; }
  .chat-messages { height: 46vh; }

  /* Floating action button to open the sheet */
  .mobile-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 55;
    width: 54px; height: 54px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow);
  }
}

@media (max-width: 480px) {
  .home-card { padding: 22px; }
  .mode-picker { grid-template-columns: 1fr; }
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.room-code {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 0.9rem; color: var(--text-dim);
}
.room-code b { color: var(--text); letter-spacing: 2px; font-family: monospace; font-size: 1rem; }

/* Player */
.player-col { min-width: 0; }
.stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
}
.stage video {
  width: 100%; height: 100%; display: block; background: #000;
}
/* YouTube iframe fills the stage like the <video> */
.yt-frame { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.yt-frame iframe { width: 100%; height: 100%; display: block; border: 0; }
/* In YouTube mode our external-subtitle controls don't apply (YT has its own) */
.yt-mode .sub-ctrl,
.yt-mode #subtitle-panel { display: none; }
.stage.controls-hidden { cursor: none; }

/* Empty state overlay */
.empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  background: radial-gradient(circle at 50% 40%, #14181f, #0b0d11);
}
.empty-state h3 { margin: 0; font-weight: 500; }
.empty-state .es-inner { width: 100%; max-width: 420px; }
.hint { color: var(--text-dim); font-size: 0.85rem; }
.hidden { display: none !important; }

/* Catch-up / autoplay overlay */
.overlay-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); z-index: 6;
}

/* Custom control bar */
.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 16px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  display: flex; flex-direction: column; gap: 8px;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 5;
}
.controls.hidden-bar { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* Progress bar: layered track / buffered / played + transparent range on top */
.progress { position: relative; height: 16px; display: flex; align-items: center; direction: ltr; }
.pb-track, .pb-buffer, .pb-played {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 5px; border-radius: 4px; pointer-events: none;
}
.pb-track  { width: 100%; background: rgba(255,255,255,0.22); }
.pb-buffer { width: 0;    background: rgba(255,255,255,0.45); }
.pb-played { width: 0;    background: var(--accent); }
.pb-range {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.pb-range::-webkit-slider-runnable-track { background: transparent; border: none; }
.pb-range::-moz-range-track { background: transparent; border: none; }
.pb-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: 0;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.pb-range::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}

/* LTR control row so media controls read like YouTube even on an RTL page */
.ctrl-row { display: flex; align-items: center; gap: 12px; direction: ltr; }
.ctrl-btn {
  background: transparent; border: none; color: #fff;
  cursor: pointer; font-size: 1.15rem; line-height: 1;
  padding: 4px; border-radius: 6px; display: inline-flex;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.12); }
.ctrl-btn.active { color: var(--accent); }
.ctrl-btn svg { display: block; }
.time { color: #dfe4ee; font-size: 0.85rem; font-variant-numeric: tabular-nums; direction: ltr; }
.spacer { flex: 1; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.panel h4 { margin: 0 0 12px; font-size: 0.95rem; font-weight: 500; color: var(--text-dim); }

.user-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.user-item { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; padding: 3px 6px; border-radius: 8px; }
.u-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--text-faint); }
.u-dot.ready { background: var(--green); }
.u-dot.buffering { background: var(--orange); }
.u-dot.mismatch { background: var(--red); box-shadow: 0 0 8px var(--red); }
.u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.u-mic { display: inline-flex; color: var(--green); flex-shrink: 0; }
.u-mic.muted { color: var(--text-faint); }
/* Speaking highlight — animated ring around the row */
.user-item.speaking { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.user-item.speaking .u-mic { color: var(--accent); }

/* Voice controls */
.voice-group { display: inline-flex; align-items: center; }
.ctrl-btn.caret { font-size: 0.7rem; padding: 4px 2px; margin-inline-start: -4px; }
#mic-btn.active { color: var(--green); }
#mic-btn.talking { color: var(--accent); }
.menu-item.active::before { content: '✓ '; }

/* Status line */
.status {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.9rem;
  min-height: 44px;
}
.status.ok { color: var(--green); }
.status.warn { color: var(--orange); }
.status.error { color: var(--red); }

/* Subtitle cue styling — RTL, Vazirmatn, legible */
video::cue {
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  font-size: 1.05em;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  padding: 0.1em 0.3em;
}

/* Volume control (fill set inline via JS gradient) */
.vol-wrap { display: flex; align-items: center; gap: 6px; }
.vol {
  -webkit-appearance: none; appearance: none;
  width: 78px; height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--accent) 100%, rgba(255,255,255,0.25) 100%);
  cursor: pointer; direction: ltr;
}
.vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
}
.vol::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: none; }

/* Transient "who paused/played" notice */
.player-notice {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.72); color: #fff; padding: 7px 16px;
  border-radius: 20px; font-size: 0.88rem; z-index: 8; white-space: nowrap;
}

/* Popup menus (subtitle selector, emoji picker). Anchored to the button's
   right edge; since the row is LTR these buttons sit on the right, so menus
   open leftward INTO the player and never spill off an edge. */
.menu-wrap { position: relative; }
.menu {
  position: absolute; bottom: calc(100% + 10px); right: 0;
  min-width: 160px; max-width: 240px; max-height: 240px; overflow-y: auto;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 6px; z-index: 20;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.menu::-webkit-scrollbar { width: 8px; }
.menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.menu-item {
  display: block; width: 100%; text-align: right;
  background: transparent; border: none; color: var(--text);
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 0.9rem;
}
.menu-item:hover { background: var(--border); }
.menu-item.active { color: var(--accent); font-weight: 500; }
.menu-item.active::before { content: '✓ '; }
.menu-empty { padding: 10px; color: var(--text-dim); font-size: 0.82rem; line-height: 1.6; }

.emoji-pop {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; min-width: 172px;
}
.emoji-item {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.35rem; padding: 6px; border-radius: 8px; line-height: 1;
}
.emoji-item:hover { background: var(--border); transform: scale(1.15); }

/* Floating emoji reactions */
.reaction-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 7; }
.reaction {
  position: absolute; bottom: 70px; font-size: 2.2rem;
  animation: floatUp 3s ease-out forwards;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  15%  { transform: translateY(-20px) scale(1.1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(-220px) scale(1); opacity: 0; }
}

/* Chat */
.chat-panel { display: flex; flex-direction: column; }
.chat-messages {
  display: flex; flex-direction: column; gap: 8px;
  height: 240px; overflow-y: auto; padding-left: 4px; margin-bottom: 10px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.chat-msg { max-width: 90%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; text-align: left; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: 0.72rem; color: var(--text-faint); margin-bottom: 2px; }
.chat-msg.mine .chat-meta { flex-direction: row-reverse; }
.chat-name { color: var(--text-dim); font-weight: 500; }
.chat-text {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 7px 11px; border-radius: 12px; font-size: 0.9rem; word-break: break-word;
}
.chat-msg.mine .chat-text { background: var(--accent-soft); border-color: transparent; }
.chat-msg.system { align-self: center; color: var(--text-faint); font-size: 0.8rem; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row .field { flex: 1; padding: 9px 12px; font-size: 0.9rem; }

/* Not-found page */
.nf-wrap {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px;
}
.nf-wrap .big { font-size: 3rem; }

/* ===== Discord-style components ===== */
.panel h4 { text-transform: none; letter-spacing: 0.02em; font-size: 0.78rem; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }

/* Voice channel panel + user tray */
.voice-join { width: 100%; }
.user-tray {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px;
}
.tray-status { font-size: 0.82rem; color: var(--green); font-weight: 500; }
.tray-actions { display: flex; gap: 2px; }
.tray-btn {
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--radius-sm); display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.95rem;
}
.tray-btn:hover { background: var(--border); color: var(--text); }
.tray-btn.off { color: var(--red); }
.tray-btn.danger:hover { background: var(--red); color: #fff; }

/* Clickable voice members + connection state */
.user-item .u-mic { cursor: default; }
.user-item[data-id] { cursor: default; }
.user-item.connecting .u-name::after { content: ' • در حال اتصال…'; color: var(--text-faint); font-size: 0.8rem; }

/* Per-user volume popup */
.vol-pop { position: fixed; padding: 10px 12px; min-width: 180px; }
.vol-pop-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 8px; }
.vol-pop-range { width: 100%; height: 5px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-close { background: transparent; border: none; color: var(--text-dim); font-size: 1.2rem; cursor: pointer; }
.modal select.field { cursor: pointer; }

/* Chat: replies, reactions, actions, typing */
.chat-msg { position: relative; padding: 2px 2px 4px; border-radius: 6px; }
.chat-msg:hover { background: rgba(255,255,255,0.03); }
.chat-reply-ref {
  font-size: 0.75rem; color: var(--text-faint); border-inline-start: 2px solid var(--border);
  padding-inline-start: 6px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react-chip {
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 1px 7px; font-size: 0.78rem; color: var(--text-dim);
}
.chat-actions {
  position: absolute; top: -10px; inset-inline-end: 6px; display: none; gap: 2px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px;
}
.chat-msg:hover .chat-actions { display: flex; }
.ca-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; padding: 2px 5px; border-radius: 4px; font-size: 0.85rem; }
.ca-btn:hover { background: var(--border); color: var(--text); }
.react-pick { position: fixed; display: flex; gap: 2px; padding: 4px; }
.typing-line { min-height: 16px; font-size: 0.75rem; color: var(--text-faint); font-style: italic; padding: 2px 2px; }
.reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 6px;
}
.reply-bar-text { font-size: 0.78rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-cancel { background: transparent; border: none; color: var(--text-faint); cursor: pointer; }

/* ===== Members, roles, status, context menu ===== */
.user-item { align-items: center; }
.u-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.u-name { display: flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-status { font-size: 0.72rem; color: var(--text-faint); }
.user-item.speaking .u-status { color: var(--green); }
.u-icons { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--text-dim); }
.mini { display: block; }
.mini.crown { color: var(--orange); }
.mini.deaf, .mini.srvmute { color: var(--red); }
.user-item.actionable { cursor: pointer; }
.user-item.actionable:hover { background: var(--bg-elev-2); }

.member-menu { position: fixed; min-width: 190px; }
.menu-title { font-size: 0.82rem; color: var(--text-dim); padding: 4px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-weight: 500; }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red); color: #fff; }
.mm-vol { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 0.82rem; color: var(--text-dim); }
.mm-range { flex: 1; height: 5px; }
.menu-sub { color: var(--text-faint); font-size: 0.78rem; }
.h4-ico { vertical-align: -2px; margin-inline-end: 3px; }

/* ===== Chat composer + markdown ===== */
.chat-input-row { align-items: center; gap: 6px; }
.composer-input { flex: 1; }
.composer-btn {
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.composer-btn:hover { color: var(--text); border-color: var(--text-faint); }
.composer-btn.send { background: var(--accent); color: #fff; border-color: transparent; }
.composer-btn.send:hover { background: var(--accent-hover); }
.composer-emoji { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.chat-text code { background: var(--bg-elev-2); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 0.85em; }
.chat-text a { color: var(--accent); word-break: break-all; }

/* ===== Layout hierarchy polish ===== */
.room-wrap { max-width: 1240px; }
.topbar {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 16px;
}
.chat-panel { display: flex; flex-direction: column; }
.chat-messages { flex: 1; min-height: 200px; }
@media (min-width: 821px) {
  .sidebar { position: sticky; top: 20px; }
  .chat-messages { height: auto; max-height: 52vh; }
}

/* Screen share overlay (covers the stage while active) */
.screenshare-view {
  position: absolute; inset: 0; z-index: 9; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.screenshare-view video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.ss-bar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; z-index: 2;
  background: rgba(0,0,0,0.6); padding: 6px 12px; border-radius: 20px;
}
.ss-label { color: #fff; font-size: 0.85rem; }
#share-btn.active { color: var(--green); }

/* Voice debug overlay (Discord-style) */
.voice-debug {
  position: fixed; top: 12px; left: 12px; z-index: 120; width: 320px; max-width: 90vw;
  max-height: 70vh; overflow: auto; background: rgba(15,17,21,0.96);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: 0.72rem; color: var(--text-dim);
  font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr;
}
.vd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text);
  position: sticky; top: 0; background: rgba(15,17,21,0.98); font-family: 'Vazirmatn', sans-serif; font-size: 0.8rem;
}
.vd-head button { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; }
.vd-body { padding: 8px 10px; white-space: pre-wrap; line-height: 1.6; }
.vd-peer { border-bottom: 1px dashed var(--border); padding-bottom: 6px; margin-bottom: 6px; }
.vd-k { color: var(--text-faint); }
.vd-ok { color: var(--green); }
.vd-bad { color: var(--red); }
.vd-warn { color: var(--orange); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); z-index: 50; opacity: 0; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

/* ===== v0.6.1 fixes ===== */

/* JS-positioned popups must NOT inherit .menu's control-bar anchoring
   (bottom:calc(100%+10px); right:0) — that put them off-place and clipped. */
.member-menu, .react-pick, .composer-emoji, .vol-pop {
  position: fixed; bottom: auto; right: auto; left: auto;
  max-height: 60vh; overflow-y: auto;
}

/* Composer: equal-height input + buttons; flip the send icon for RTL */
.chat-input-row { align-items: center; gap: 6px; }
.composer-input { flex: 1; height: 40px; padding: 0 12px; }
.composer-btn { width: 40px; height: 40px; padding: 0; }
.composer-btn.send svg { transform: scaleX(-1); }  /* point toward the RTL text flow */

/* Subtitle menu extras (upload + paste-link live inside the player menu) */
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-linkrow { display: flex; gap: 6px; padding: 4px; }
.menu-linkrow .field { flex: 1; direction: ltr; font-size: 0.82rem; padding: 8px 10px; }

/* Members panel head with inline join button */
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h4 { margin: 0; }
.voice-join.sm { flex-shrink: 0; }

/* Name modal input */
#name-modal .field { width: 100%; }

/* ===== No-scroll app shell — the room page never scrolls; chat scrolls inline ===== */
body.room-page { overflow: hidden; height: 100vh; }
.room-page .room-wrap {
  height: 100vh; max-height: 100vh; overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr); align-items: stretch;
}
.player-col { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Fixed 16/9 aspect (width-driven, like the original); max-height only guards
   against page overflow on very short/wide screens. */
.player-col .stage { flex: 0 0 auto; aspect-ratio: 16 / 9; width: 100%; max-height: calc(100vh - 150px); margin: 0 auto; }
.player-col .stage video { object-fit: contain; }
.player-col .status-row { flex: 0 0 auto; }

@media (min-width: 821px) {
  .sidebar {
    position: sticky; top: 0; min-height: 0; max-height: 100%;
    display: flex; flex-direction: column; gap: 16px; overflow: hidden;
  }
  .sidebar #members-panel { flex: 0 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
  .sidebar #members-panel .user-list { overflow-y: auto; min-height: 0; }
  .chat-panel { flex: 1 1 auto; min-height: 0; }
  .chat-messages { flex: 1 1 auto; min-height: 0; max-height: none; height: auto; }
}

/* ===== v0.6.2 ===== */
/* Wider layout; the 2-column grid is DESKTOP-ONLY so it never overrides the
   mobile single-column rule (that bug left an empty 340px column on phones). */
.room-page .room-wrap { max-width: 1760px; }
@media (min-width: 821px) {
  .room-page .room-wrap { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 820px) {
  .room-page .room-wrap { grid-template-columns: 1fr !important; }
}

/* Status row — status / now-playing / change-video all the same height */
.status-row { display: flex; align-items: stretch; gap: 10px; margin-top: 12px; }
.status-row .status { flex: 1; margin: 0; display: flex; align-items: center; }
.status-row #change-video { flex: 0 0 auto; display: inline-flex; align-items: center; }
.now-playing {
  display: inline-flex; align-items: center; gap: 6px; max-width: 40%;
  color: var(--text-dim); font-size: 0.85rem; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 14px;
}
.now-playing #now-playing-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Join-voice button + tray spacing */
.voice-join { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
#members-panel .user-tray { margin-bottom: 12px; padding: 8px 10px; }
#members-panel .user-list { margin-top: 2px; }

/* Bigger subtitle menu action items */
.menu-item.big { padding: 11px 12px; font-size: 0.95rem; }

/* Subtitle appearance modal rows */
.ss-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.ss-row .lbl { margin: 0; }
input[type="color"] { width: 46px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-elev-2); cursor: pointer; padding: 2px; }
#substyle-modal .vol, #substyle-modal input[type="range"] { accent-color: var(--accent); }
