:root {
  --bg: #08111f;
  --bg-soft: #101a2f;
  --panel: rgba(16, 26, 48, 0.85);
  --panel-2: rgba(18, 30, 55, 0.92);
  --text: #edf4ff;
  --muted: #9eb2d2;
  --line: rgba(255, 255, 255, 0.09);
  --primary: #82b1ff;
  --primary-2: #5fd3ff;
  --danger: #ff7d93;
  --success: #6dd9a6;
  --warning: #ffd27d;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(95,211,255,.18), transparent 28%),
    radial-gradient(circle at top right, rgba(130,177,255,.15), transparent 26%),
    linear-gradient(180deg, #0b1426 0%, #08111f 50%, #08111f 100%);
}
.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}
a { color: inherit; text-decoration: none; }
input, select, button { font: inherit; }
input, select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 2px),
    calc(100% - 16px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus, select:focus {
  border-color: rgba(130,177,255,.45);
  box-shadow: 0 0 0 3px rgba(130,177,255,.12);
}
label {
  display: block;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.account-profile-form select {
  display: block;
  width: 100% !important;
  min-height: 48px;
  padding: 14px 42px 14px 16px !important;
  border-radius: 14px;
  border: 1px solid var(--line);
  background-color: rgba(255,255,255,0.05);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 2px),
    calc(100% - 16px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.account-profile-form select:focus {
  border-color: rgba(130,177,255,.45);
  box-shadow: 0 0 0 3px rgba(130,177,255,.12);
}
button, .anchor-btn {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}
button:hover, .anchor-btn:hover, .chip:hover { transform: translateY(-1px); }
.shell {
  position: relative;
  z-index: 1;
  max-width: 1460px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.auth-shell { max-width: 1100px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}
.topbar.compact { margin-bottom: 18px; }
.brand { font-size: 28px; font-weight: 800; letter-spacing: .02em; }
.muted { color: var(--muted); }
.top-actions, .lang-switch, .row-compact, .chip-row, .feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.chip, .user-pill, .feature-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.chip.active { background: rgba(130,177,255,.18); border-color: rgba(130,177,255,.34); }
.chip.danger { color: white; background: rgba(255,123,147,.16); }
.feature-chip { font-size: 13px; color: var(--muted); }
.action-chip { color: var(--text); }
.hero-card, .panel, .form-card, .status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.glass-highlight {
  position: relative;
  overflow: hidden;
}
.glass-highlight::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(95,211,255,.18), transparent 65%);
}
.hero-card {
  padding: 28px;
  margin-bottom: 22px;
}
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
  gap: 18px;
  align-items: stretch;
}
.hero-copy { position: relative; z-index: 1; }
.hero-copy h1 { margin: 6px 0 10px; font-size: 40px; line-height: 1.1; }
.hero-copy p { margin: 0 0 8px; line-height: 1.65; max-width: 68ch; }
.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--primary-2);
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.grid.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.panel {
  padding: 22px;
}
.panel-glow {
  box-shadow: 0 16px 48px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.03);
}
.panel h2, .panel h3 { margin-top: 0; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.section-tag {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(130,177,255,.12);
  color: var(--primary);
  border: 1px solid rgba(130,177,255,.2);
}
.primary-btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #07111d;
  font-weight: 800;
  margin-top: 16px;
  box-shadow: 0 12px 24px rgba(95,211,255,.16);
}
.ghost-btn {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--line);
}
.ghost-btn.active {
  background: rgba(130,177,255,.18);
  border-color: rgba(130,177,255,.36);
  box-shadow: 0 0 0 1px rgba(130,177,255,.08) inset;
}
.ghost-btn.danger { color: var(--danger); }
.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.notice.error { border-color: rgba(255,123,147,.42); color: #ffd4dd; }
.notice.warning { border-color: rgba(255,210,125,.35); color: #ffeabc; }
.hidden { display: none; }
.result-box { margin-top: 16px; }
.text-link { display: inline-block; margin-top: 14px; color: var(--primary-2); }
.auth-card {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  align-items: stretch;
}
.form-card { padding: 22px; }
.elevated-card {
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,.08);
}
.status-card {
  padding: 22px;
  align-self: stretch;
}
.status-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.status-grid div {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.status-grid strong { font-size: 16px; }
.compact-panel { min-height: 150px; }
.list-panel { display: grid; gap: 14px; }
.list-item {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.list-item.stacked { align-items: flex-start; }
.item-title { font-weight: 700; margin-bottom: 4px; }
.centered { text-align: center; }
.narrow-panel {
  max-width: 560px;
  margin: 80px auto 0;
}
.room-grid-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
}
.side-panel { position: sticky; top: 20px; height: fit-content; }
.stack-controls { display: grid; gap: 10px; }
.button-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.button-grid-2 .full-span { grid-column: 1 / -1; }
.video-panel { min-height: 72vh; }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.video-card {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #050913;
  border: 1px solid var(--line);
  min-height: 220px;
}
.self-card { outline: 2px solid rgba(95,211,255,.15); }
video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-height: 220px;
}
.video-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  font-size: 13px;
}
.mini-panel { margin-top: 18px; }
.slim-btn { width: auto; min-width: 140px; }
.mt-12 { margin-top: 12px; }

@media (max-width: 1080px) {
  .dashboard-hero, .grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .grid.two, .auth-card, .room-grid-layout { grid-template-columns: 1fr; }
  .hero-copy h1 { font-size: 32px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .side-panel { position: static; }
}
@media (max-width: 620px) {
  .button-grid-2 { grid-template-columns: 1fr; }
}


.video-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  min-height: 72vh;
}
.video-main {
  min-height: 72vh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-content: stretch;
  align-items: stretch;
}
.video-stage.grid-1 .video-main { grid-template-columns: minmax(0, 1fr); }
.video-stage.grid-2 .video-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.video-stage.grid-3 .video-main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.video-stage.paged-grid .video-main { align-content: start; }
.video-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 72vh;
  overflow: auto;
}
.video-stage.sidebar-hidden {
  grid-template-columns: minmax(0, 1fr) 0;
}
.video-stage.sidebar-hidden .video-sidebar {
  display: none;
}
.video-stage.focus-layout .video-main {
  grid-template-columns: 1fr;
}
.video-stage.focus-layout .video-main .video-card {
  min-height: 72vh;
}
.video-stage.screen-share-mode .video-main .video-card {
  min-height: 76vh;
}
.video-stage.grid-layout .video-main .video-card {
  min-height: 0;
  aspect-ratio: 16 / 9;
}
.video-stage.grid-layout .video-main .video-el,
.video-stage.grid-layout .video-main video {
  min-height: 0;
  height: 100%;
}
.video-sidebar .video-card {
  min-height: 118px;
}
.video-sidebar .video-el,
.video-sidebar video {
  min-height: 118px;
  height: 118px;
}
.video-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.video-pager.hidden { display: none; }
.video-pager-info {
  min-width: 72px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.pager-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
}
.video-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
}
.card-btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(6, 12, 24, .58);
  color: var(--text);
  font-size: 12px;
  backdrop-filter: blur(8px);
}
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: radial-gradient(circle at center, rgba(130,177,255,.08), transparent 55%), #050913;
  z-index: 1;
}
.video-card.has-video .video-placeholder {
  display: none;
}
.video-card .video-el,
.video-card video {
  position: relative;
  z-index: 2;
}
.video-card.is-focused {
  box-shadow: 0 0 0 2px rgba(130,177,255,.35), 0 18px 48px rgba(0,0,0,.35);
}
.video-stage.focus-layout .video-sidebar {
  padding-left: 4px;
}
@media (max-width: 960px) {
  .video-stage,
  .video-stage.sidebar-hidden {
    grid-template-columns: 1fr;
  }
  .video-main,
  .video-stage.grid-2 .video-main,
  .video-stage.grid-3 .video-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .video-sidebar {
    flex-direction: row;
    overflow: auto;
    max-height: none;
  }
  .video-sidebar .video-card {
    min-width: 180px;
  }
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card {
    min-height: 50vh;
  }
}
@media (max-width: 640px) {
  .video-main,
  .video-stage.grid-2 .video-main,
  .video-stage.grid-3 .video-main {
    grid-template-columns: 1fr;
  }
}


.video-card:fullscreen,
.video-card:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-card:fullscreen .video-toolbar,
.video-card:-webkit-full-screen .video-toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
}
.video-card:fullscreen .video-label,
.video-card:-webkit-full-screen .video-label {
  position: fixed;
  left: 20px;
  bottom: 20px;
}
.video-card:fullscreen .video-el,
.video-card:fullscreen video,
.video-card:-webkit-full-screen .video-el,
.video-card:-webkit-full-screen video {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  background: #000;
}
.video-card:fullscreen .video-placeholder,
.video-card:-webkit-full-screen .video-placeholder {
  width: 100vw;
  height: 100vh;
}


body.has-simulated-fullscreen {
  overflow: hidden;
}
.video-card.fullscreen-simulated {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  background: #000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.video-card.fullscreen-simulated .video-toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2;
}
.video-card.fullscreen-simulated .video-label {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 2;
}
.video-card.fullscreen-simulated .video-el,
.video-card.fullscreen-simulated video,
.video-card.fullscreen-simulated .video-placeholder {
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain;
  background: #000;
}

.quick-grid .compact-panel { min-height: 200px; }
.link-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.wide-link {
  width: 100%;
  justify-content: flex-start;
}
.compact-list { margin-top: 12px; }
.history-item {
  align-items: center;
}
.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.section-tag.active {
  background: rgba(109,217,166,.12);
  border-color: rgba(109,217,166,.25);
  color: var(--success);
}
.section-tag.ended {
  background: rgba(255,125,147,.12);
  border-color: rgba(255,125,147,.25);
  color: var(--danger);
}
.wrap-actions {
  flex-wrap: wrap;
}
@media (max-width: 760px) {
  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .history-actions {
    width: 100%;
    align-items: stretch;
  }
}

.grid.one {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
.guide-layout {
  display: grid;
  gap: 18px;
}
.support-wrap {
  display: grid;
  gap: 14px;
}
.guide-card {
  padding: 18px;
  border-radius: 18px;
}
.directory-row {
  font-size: 13px;
  margin-bottom: 10px;
}
.guide-item {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 0 14px;
  margin-top: 10px;
}
.guide-item summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0;
  font-weight: 700;
}
.guide-item summary::-webkit-details-marker { display: none; }
.guide-item p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.7;
}
.support-grid {
  display: grid;
  gap: 12px;
}
.support-grid div {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.support-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.support-grid strong {
  font-size: 15px;
  word-break: break-word;
}


.auth-landing-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 420px);
  gap: 28px;
  align-items: center;
  min-height: 620px;
  padding: 34px;
}
.landing-copy {
  position: relative;
  z-index: 1;
  padding: 12px 6px 12px 4px;
  max-width: 620px;
}
.landing-copy h1 {
  margin: 10px 0 12px;
  font-size: 54px;
  line-height: 1.04;
  letter-spacing: -.03em;
}
.landing-copy p {
  max-width: 58ch;
}
.landing-tagline {
  font-size: 22px;
  font-weight: 700;
  color: #dceaff;
  margin-bottom: 8px;
}
.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 26px 0 16px;
}
.landing-actions .ghost-btn {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
}
.small-note {
  font-size: 14px;
}
.auth-form-card {
  width: 100%;
  max-width: 420px;
  justify-self: end;
  padding: 28px;
}
.narrow-shell {
  max-width: 980px;
}
.help-page-panel,
.support-page-panel {
  padding: 26px;
}
.guide-page-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}
.guide-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  padding: 0;
}
.guide-item summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 20px;
  font-weight: 700;
}
.guide-item summary::-webkit-details-marker {
  display: none;
}
.guide-item p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
  line-height: 1.7;
}
.support-grid-large {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.support-grid-large div {
  min-height: 118px;
}
@media (max-width: 900px) {
  .auth-landing-card {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 22px;
  }
  .auth-form-card {
    justify-self: stretch;
    max-width: none;
  }
  .landing-copy h1 {
    font-size: 38px;
  }
  .support-grid-large {
    grid-template-columns: 1fr;
  }
}
textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 88px;
}
.auth-links-row { display:flex; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.single-column-card { max-width: 980px; margin: 0 auto; }
.room-grid-layout { grid-template-columns: 320px minmax(0, 1fr); align-items: stretch; }
.video-panel { position: relative; min-height: 780px; overflow: hidden; display:grid; grid-template-columns: minmax(0, 1.45fr) minmax(380px, 430px); gap: 20px; align-items: stretch; }
.video-panel.chat-collapsed-layout { grid-template-columns: minmax(0, 1fr) 0; }
.video-stage { min-width: 0; align-self: stretch; }
.danmaku-layer { position:absolute; top: 12px; left: 12px; right: 390px; height: 150px; pointer-events:none; overflow:hidden; z-index:3; }
.video-panel.chat-collapsed-layout .danmaku-layer { right: 12px; }
.danmaku-item { position:absolute; left:100%; white-space:nowrap; padding:8px 14px; border-radius:999px; background:rgba(8,17,31,.74); border:1px solid rgba(255,255,255,.12); backdrop-filter:blur(12px); animation: danmaku-move linear forwards; }
@keyframes danmaku-move { from { transform: translateX(0); } to { transform: translateX(-160vw); } }
.chat-window {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-self: stretch;
  background: rgba(8,16,32,.92);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  backdrop-filter: blur(18px);
  z-index: 5;
  overflow: hidden;
  display:flex;
  flex-direction:column;
  min-height: 0;
}
.chat-window.chat-collapsed { display:none; }
.chat-side-toggle { position:absolute; right: 18px; top: 50%; transform: translateY(-50%); z-index: 6; padding: 12px 14px; border-radius: 16px; background: rgba(8,16,32,.94); border: 1px solid rgba(255,255,255,.12); color: var(--text); box-shadow: 0 12px 36px rgba(0,0,0,.3); }
.chat-show-btn.hidden { display:none; }
.chat-header, .chat-toolbar, .chat-actions { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 14px; }
.chat-header { cursor: default; border-bottom:1px solid var(--line); }
.chat-toolbar { justify-content:flex-start; padding-top:10px; padding-bottom:8px; }
.chat-mode-btn, .mention-option, .attachment-btn { border:1px solid var(--line); background:rgba(255,255,255,.05); color:var(--text); border-radius:12px; padding:8px 12px; cursor:pointer; }
.chat-mode-btn.active { background: rgba(130,177,255,.18); border-color: rgba(130,177,255,.34); }
.picker-panel { padding:10px 14px; margin:0 14px 10px; border:1px solid var(--line); border-radius:14px; background:rgba(255,255,255,.04); display:flex; flex-wrap:wrap; gap:8px; }
.chat-messages { flex:1; min-height: 220px; overflow:auto; padding: 0 14px 14px; display:flex; flex-direction:column; gap:10px; align-items:stretch; }
.chat-message { align-self: stretch; display:flex; flex-direction:column; gap:8px; padding:10px 12px; border-radius:16px; background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08); min-height:0; height:auto; }
.chat-message.host-only { border-color: rgba(255,210,125,.28); }
.chat-message-head { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin:0; font-size:12px; color:var(--muted); }
.chat-message-body { line-height:1.65; word-break:break-word; white-space:normal; min-height:0; }
.chat-message-body.withdrawn { color: var(--muted); font-style: italic; }
.chat-message-body:empty { display:none; }
.mention-badge { display:inline-flex; margin-right:6px; margin-bottom:6px; padding:3px 8px; border-radius:999px; background:rgba(130,177,255,.18); color:var(--primary); font-size:12px; }
.chat-attachment-block { margin-top: 2px; }
.chat-media { display:block; width:auto; max-width:100%; max-height:260px; object-fit:contain; border-radius:14px; border:1px solid rgba(255,255,255,.08); background:#050913; }
.chat-input-row { padding: 0 14px; }
.chat-composer { position:relative; padding-bottom: 14px; border-top:1px solid rgba(255,255,255,.06); }
.chat-actions { padding-top: 10px; }
.chat-actions-left { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.chat-attachment-preview { padding: 0 14px 12px; }
.small-note { font-size:12px; }
.mention-option { font-size:13px; }
.emoji-popover { position:absolute; left:14px; right:14px; bottom:76px; padding:12px; border:1px solid var(--line); border-radius:18px; background:rgba(8,16,32,.98); box-shadow:0 18px 48px rgba(0,0,0,.35); z-index:8; }
.emoji-popover.hidden { display:none; }
.emoji-popover-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.emoji-picker { display:grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap:8px; }
.emoji-option { border:1px solid var(--line); background:rgba(255,255,255,.05); color:var(--text); border-radius:12px; min-height:42px; font-size:20px; cursor:pointer; }
.chat-context-menu { position:fixed; min-width:168px; padding:8px; border-radius:14px; border:1px solid rgba(255,255,255,.12); background:rgba(8,16,32,.98); box-shadow:0 16px 40px rgba(0,0,0,.35); z-index:30; display:grid; gap:6px; }
.chat-context-menu.hidden { display:none; }
.chat-context-menu .context-item { text-align:left; border:1px solid transparent; background:rgba(255,255,255,.04); color:var(--text); border-radius:10px; padding:9px 12px; cursor:pointer; }
.chat-context-menu .context-item:hover { border-color: var(--line); background:rgba(255,255,255,.08); }
.chat-context-menu .context-item.danger { color:#ff8f8f; }
@media (max-width: 1100px) {
  .room-grid-layout { grid-template-columns: 1fr; }
  .video-panel { grid-template-columns: 1fr; min-height: 920px; }
  .danmaku-layer { right: 12px; }
  .chat-side-toggle { top: auto; bottom: 18px; transform: none; }
}
@media (max-width: 768px) {
  .video-panel { min-height: auto; }
  .chat-window { min-height: 420px; }
}


/* v4 room layout polish */
.room-grid-layout > .side-panel { min-width: 0; }
.video-stage.focus-layout { grid-template-columns: minmax(0, 1fr); }
.video-main { min-width: 0; }
.video-main .video-card { width: 100%; }
.video-stage.focus-layout .video-main { display: block; min-width: 0; }
.video-stage.focus-layout .video-main .video-card { width: 100%; min-height: 700px; }
.video-stage.screen-share-mode .video-main .video-card { min-height: 760px; }
.video-sidebar:empty { display: none; }
.chat-window { min-height: 720px; }
.chat-messages { min-height: 340px; }
.chat-input-row textarea { min-height: 108px; }
.chat-header { align-items: flex-start; }
.chat-header > div:first-child { flex: 1; min-width: 0; }

/* forgot password polish */
.auth-request-shell { max-width: 1120px; }
.password-reset-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 28px;
  align-items: stretch;
  min-height: 560px;
  padding: 30px;
}
.password-reset-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 6px;
}
.password-reset-copy h2 {
  margin: 6px 0 14px;
  font-size: 42px;
  line-height: 1.08;
}
.password-reset-copy p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 56ch;
}
.password-reset-points {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.password-reset-points div {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.password-reset-points strong { display:block; margin-bottom: 4px; }
.password-reset-form {
  width: 100%;
  max-width: 430px;
  justify-self: end;
  padding: 28px;
}
.password-reset-form textarea { min-height: 128px; resize: vertical; }
@media (max-width: 1200px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 390px; }
}
@media (max-width: 960px) {
  .password-reset-card { grid-template-columns: 1fr; min-height: auto; padding: 22px; }
  .password-reset-form { max-width: none; justify-self: stretch; }
}
@media (max-width: 768px) {
  .room-grid-layout { grid-template-columns: 1fr; }
  .video-panel { grid-template-columns: 1fr; min-height: auto; }
  .chat-window { min-height: 460px; }
  .video-stage.focus-layout .video-main .video-card { min-height: 56vh; }
}

@media (max-width: 560px) {
  .emoji-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chat-actions { flex-direction: column; align-items: stretch; }
  .chat-actions-left { width: 100%; }
  .chat-actions .primary-btn { width: 100%; }
}


/* v6.1 stable room/chat sizing */
.room-grid-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 18px; }
.video-panel {
  min-height: 680px;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 390px);
  gap: 18px;
}
.video-stage {
  min-height: 0;
  align-self: stretch;
}
.video-main {
  min-height: 0;
}
.video-stage.focus-layout .video-main .video-card {
  min-height: clamp(420px, 58vh, 620px);
  aspect-ratio: 16 / 9;
}
.video-stage.screen-share-mode .video-main .video-card {
  min-height: clamp(440px, 62vh, 680px);
  aspect-ratio: 16 / 9;
}
.video-card .video-el,
.video-card video {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}
.chat-window {
  min-height: 0;
  max-height: min(78vh, 820px);
}
.chat-header, .chat-toolbar { flex-shrink: 0; }
.chat-messages {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-composer {
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(8,16,32,.05), rgba(8,16,32,.28));
}
.chat-input-row textarea {
  min-height: 92px;
  max-height: 180px;
}
.chat-attachment-preview {
  max-height: 200px;
  overflow-y: auto;
}
.emoji-popover {
  left: auto;
  right: 14px;
  width: min(320px, calc(100% - 28px));
  bottom: 68px;
}
.emoji-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 1200px) {
  .room-grid-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .video-panel { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 960px) {
  .video-panel { grid-template-columns: 1fr; min-height: auto; }
  .chat-window { max-height: none; }
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card {
    min-height: 50vh;
  }
}


/* v6.1.2 hotfix */
.video-panel { min-height: 640px; grid-template-columns: minmax(0, 1fr) 360px; }
.video-stage { min-height: 0; align-self: start; }
.video-main { min-height: 0; align-content: start; }
.video-stage.focus-layout .video-main .video-card { min-height: clamp(340px, 50vh, 520px); max-height: 62vh; }
.video-stage.screen-share-mode .video-main .video-card { min-height: clamp(360px, 54vh, 560px); max-height: 68vh; }
.video-sidebar { max-height: min(62vh, 520px); }
.video-label { background: transparent; padding: 0; border-radius: 0; text-shadow: 0 2px 10px rgba(0,0,0,.9); font-size: 12px; letter-spacing: .2px; }
.chat-window { height: min(74vh, 760px); max-height: min(74vh, 760px); overflow: visible; }
.chat-header, .chat-toolbar, .chat-composer { background: rgba(8,16,32,.92); }
.chat-messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 10px; }
.chat-message { gap: 6px; }
.chat-translation { margin-top: 6px; padding: 8px 10px; border-radius: 12px; background: rgba(130,177,255,.08); border: 1px solid rgba(130,177,255,.18); color: var(--muted); font-size: 12px; line-height: 1.5; }
.chat-translation-label { margin-bottom: 4px; color: var(--primary-2); font-size: 11px; }
.chat-context-menu { z-index: 9999; }
.chat-attachment-preview { max-height: 180px; overflow-y: auto; }
.chat-media { max-height: 220px; }
@media (max-width: 1200px) { .video-panel { grid-template-columns: minmax(0, 1fr) 340px; } }


/* v6.1.4 chat sizing and media spacing */
.video-panel { grid-template-columns: minmax(0, 1fr) 500px; gap: 18px; }
.chat-window {
  height: min(86vh, 980px);
  max-height: min(86vh, 980px);
  min-height: 800px;
}
.chat-header, .chat-toolbar, .chat-composer { padding-left: 18px; padding-right: 18px; }
.chat-toolbar { padding-top: 12px; padding-bottom: 12px; }
.chat-messages {
  padding: 8px 18px 18px;
  gap: 16px;
  scrollbar-gutter: stable;
}
.chat-message {
  padding: 14px 16px 16px;
  gap: 10px;
  border-radius: 18px;
}
.chat-message-head { margin-bottom: 2px; }
.chat-message-body {
  font-size: 14px;
  line-height: 1.75;
}
.chat-attachment-block {
  margin-top: 10px;
  margin-bottom: 10px;
}
.chat-media {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 14px;
}
.chat-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.msg-action-btn {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  font-size: 12px;
}
.msg-action-btn:hover {
  color: var(--text);
  border-color: rgba(130,177,255,.34);
  background: rgba(130,177,255,.12);
}
.msg-action-btn.danger {
  color: #ff9aa9;
}
.chat-input-row textarea {
  min-height: 112px;
}
.emoji-popover {
  right: 18px;
  bottom: 92px;
  width: min(320px, calc(100% - 36px));
  max-height: 360px;
  overflow-y: auto;
}
.chat-actions {
  padding-top: 12px;
}
.chat-actions .primary-btn {
  width: 132px;
  margin-top: 0;
}
.chat-context-menu { display: none !important; }
@media (max-width: 1280px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 450px; }
}
@media (max-width: 960px) {
  .video-panel { grid-template-columns: 1fr; }
  .chat-window { min-height: 620px; height: auto; max-height: none; }
}


/* v6.1.4b hard fix for chat sizing and media spacing */
.video-panel {
  grid-template-columns: minmax(0, 1fr) 560px !important;
  gap: 20px !important;
}
.chat-window {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 760px !important;
  height: min(84vh, 900px) !important;
  max-height: min(84vh, 900px) !important;
  display: flex !important;
  flex-direction: column !important;
}
.chat-header,
.chat-toolbar,
.chat-composer {
  flex: 0 0 auto !important;
}
.chat-messages {
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 12px 18px 18px !important;
  scrollbar-gutter: stable !important;
}
.chat-message {
  display: block !important;
  flex: none !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 0 16px 0 !important;
  padding: 14px 16px !important;
  border-radius: 18px !important;
  overflow: hidden !important;
}
.chat-message:last-child {
  margin-bottom: 0 !important;
}
.chat-message-head {
  margin: 0 0 8px 0 !important;
  line-height: 1.4 !important;
}
.chat-message-body {
  display: block !important;
  margin: 0 !important;
  line-height: 1.75 !important;
}
.chat-attachment-block {
  display: block !important;
  margin: 12px 0 10px 0 !important;
}
.chat-media {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  max-height: 320px !important;
  margin: 0 !important;
}
.chat-message-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 10px !important;
}
.emoji-popover {
  right: 18px !important;
  left: auto !important;
  bottom: 90px !important;
  width: 320px !important;
  max-width: calc(100% - 36px) !important;
  z-index: 20 !important;
}
@media (max-width: 1400px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 500px !important; }
}
@media (max-width: 1200px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 420px !important; }
}
@media (max-width: 960px) {
  .video-panel { grid-template-columns: 1fr !important; }
  .chat-window {
    min-height: 620px !important;
    height: auto !important;
    max-height: none !important;
  }
}


/* v6.1.4c height-focused fix */
.video-panel {
  grid-template-columns: minmax(0, 1fr) 360px !important;
  gap: 18px !important;
  align-items: stretch !important;
}
.chat-window {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 900px !important;
  height: min(92vh, 1180px) !important;
  max-height: min(92vh, 1180px) !important;
  align-self: stretch !important;
}
.chat-messages {
  padding: 14px 16px 18px !important;
  gap: 18px !important;
}
.chat-message {
  margin: 0 0 18px 0 !important;
}
.chat-attachment-block {
  margin: 14px 0 14px 0 !important;
}
.chat-media {
  max-height: 360px !important;
}
.chat-composer {
  margin-top: auto !important;
}
.emoji-popover {
  bottom: 88px !important;
}
@media (max-width: 1400px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 340px !important; }
}
@media (max-width: 1200px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 320px !important; }
}
@media (max-width: 960px) {
  .video-panel { grid-template-columns: 1fr !important; }
  .chat-window {
    min-height: 720px !important;
    height: auto !important;
    max-height: none !important;
  }
}

/* mobile-only adaptation fix */
@media (max-width: 768px) {
  .shell {
    width: min(100% - 20px, 100%) !important;
    margin: 14px auto 28px !important;
  }
  .topbar,
  .topbar.compact {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  .top-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
  }
  .top-actions > * {
    max-width: 100% !important;
  }
  .room-grid-layout {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .side-panel {
    order: 2 !important;
    position: static !important;
    top: auto !important;
  }
  .video-panel {
    order: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    min-height: auto !important;
    padding: 14px !important;
    gap: 14px !important;
    overflow: visible !important;
  }
  .video-stage,
  .video-main {
    min-height: 0 !important;
  }
  .video-stage {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    order: 1 !important;
  }
  .video-main {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .video-main .video-card,
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card,
  .video-card,
  .video-card video,
  .video-card .video-el {
    min-height: 220px !important;
    height: 48vh !important;
    max-height: 56vh !important;
  }
  .video-sidebar {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    padding-bottom: 4px !important;
  }
  .video-sidebar .video-card,
  .video-sidebar .video-card video,
  .video-sidebar .video-card .video-el {
    min-width: 140px !important;
    width: 140px !important;
    min-height: 96px !important;
    height: 96px !important;
  }
  .danmaku-layer {
    left: 12px !important;
    right: 12px !important;
    height: 96px !important;
  }
  .chat-window {
    order: 2 !important;
    width: 100% !important;
    min-height: 520px !important;
    height: 64vh !important;
    max-height: none !important;
    border-radius: 18px !important;
  }
  .chat-window.chat-collapsed {
    display: none !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-composer {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .chat-header {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .chat-header .row-compact {
    width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
  }
  .chat-toolbar {
    flex-wrap: wrap !important;
  }
  .picker-panel {
    margin-left: 12px !important;
    margin-right: 12px !important;
  }
  .chat-messages {
    min-height: 0 !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 14px 12px 16px !important;
    gap: 14px !important;
  }
  .chat-message {
    margin: 0 0 14px 0 !important;
    padding: 12px 12px 14px !important;
  }
  .chat-message:last-child {
    margin-bottom: 0 !important;
  }
  .chat-attachment-block {
    margin: 10px 0 10px 0 !important;
  }
  .chat-media {
    max-height: 220px !important;
  }
  .chat-input-row {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .chat-input-row textarea {
    min-height: 88px !important;
  }
  .chat-actions {
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .chat-actions-left {
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .chat-actions .primary-btn,
  #sendChatBtn {
    width: auto !important;
    min-width: 84px !important;
    flex: 0 0 auto !important;
    margin-top: 0 !important;
  }
  .emoji-popover {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    bottom: 84px !important;
  }
  .chat-side-toggle {
    right: 12px !important;
    bottom: 12px !important;
    top: auto !important;
    transform: none !important;
  }
  .button-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .row-compact {
    flex-wrap: wrap !important;
  }
  .status-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 14px, 100%) !important;
    margin-top: 10px !important;
  }
  .brand {
    font-size: 28px !important;
  }
  .panel {
    padding: 14px !important;
  }
  .button-grid-2 {
    grid-template-columns: 1fr !important;
  }
  .video-main .video-card,
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card,
  .video-card,
  .video-card video,
  .video-card .video-el {
    height: 42vh !important;
    min-height: 200px !important;
  }
  .chat-window {
    min-height: 380px !important;
    height: 50vh !important;
    max-height: 58vh !important;
  }
  .status-grid {
    grid-template-columns: 1fr !important;
  }
}


/* v6.1.5 mobile chat bottom-sheet and meeting watermark */
.video-label-stack {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
.video-meeting-watermark {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.34);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.88);
  font-size: 11px;
  letter-spacing: .2px;
  text-shadow: 0 2px 10px rgba(0,0,0,.9);
  backdrop-filter: blur(8px);
}
.chat-mobile-handle {
  display: none;
  border: 0;
  background: transparent;
  padding: 10px 0 2px;
  cursor: ns-resize;
}
.chat-mobile-handle span {
  display: block;
  width: 56px;
  height: 6px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255,255,255,.28);
}
body.chat-dragging {
  user-select: none;
  overscroll-behavior: none;
}
@media (max-width: 768px) {
  .video-panel {
    position: relative !important;
    padding-bottom: 12px !important;
  }
  .chat-side-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    right: 14px !important;
    bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 12px)) !important;
    z-index: 70 !important;
  }
  .chat-show-btn.hidden {
    display: none !important;
  }
  .chat-window {
    --mobile-chat-height: 62vh;
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 10px)) !important;
    width: auto !important;
    min-height: 0 !important;
    height: var(--mobile-chat-height) !important;
    max-height: 84vh !important;
    z-index: 60 !important;
    box-shadow: 0 20px 60px rgba(0,0,0,.45) !important;
    border-radius: 20px !important;
  }
  .chat-window.chat-collapsed {
    display: none !important;
  }
  .chat-mobile-handle {
    display: block !important;
    flex: 0 0 auto !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-composer {
    background: rgba(8,16,32,.97) !important;
  }
  .chat-header {
    padding-top: 6px !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding-bottom: 12px !important;
  }
  .chat-composer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 2 !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -10px 24px rgba(0,0,0,.18) !important;
  }
  .chat-input-row textarea {
    min-height: 92px !important;
    max-height: 22vh !important;
  }
  .chat-actions {
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  .chat-actions-left {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  .chat-actions .primary-btn,
  #sendChatBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 92px !important;
    width: 92px !important;
    flex: 0 0 92px !important;
  }
  .emoji-popover {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 90px) !important;
  }
}
@media (max-width: 560px) {
  .chat-window {
    left: 8px !important;
    right: 8px !important;
    height: var(--mobile-chat-height) !important;
    max-height: 82vh !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-composer,
  .chat-input-row,
  .chat-messages,
  .picker-panel {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .chat-actions {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}


/* v6.1.7 mobile chat reflow: place chat below video on phones, remove overlay crowding */
.video-label-stack {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
.video-meeting-watermark { display: none !important; }

@media (max-width: 768px) {
  .video-panel {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 14px !important;
  }

  .video-stage,
  .video-stage.sidebar-hidden {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    min-height: 0 !important;
  }

  .video-main {
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .video-sidebar {
    order: 2 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    padding-bottom: 2px !important;
  }

  .video-sidebar .video-card {
    flex: 0 0 132px !important;
    min-width: 132px !important;
    min-height: 92px !important;
  }

  .video-sidebar .video-el,
  .video-sidebar video {
    height: 92px !important;
    min-height: 92px !important;
  }

  .video-main .video-card,
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card,
  .video-card,
  .video-card video,
  .video-card .video-el {
    width: 100% !important;
    min-height: clamp(220px, 34vh, 360px) !important;
    height: clamp(220px, 34vh, 360px) !important;
    max-height: 42vh !important;
  }

  .danmaku-layer {
    left: 12px !important;
    right: 12px !important;
    top: 12px !important;
    height: 88px !important;
  }

  .chat-side-toggle {
    position: fixed !important;
    right: 12px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
    top: auto !important;
    transform: none !important;
    z-index: 80 !important;
  }

  .chat-window {
    --mobile-chat-height: 52vh;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    min-height: 420px !important;
    height: var(--mobile-chat-height) !important;
    max-height: 72vh !important;
    border-radius: 18px !important;
    z-index: 5 !important;
    overflow: hidden !important;
    box-shadow: 0 18px 48px rgba(0,0,0,.28) !important;
  }

  .chat-window.chat-collapsed {
    display: none !important;
  }

  .chat-mobile-handle {
    display: block !important;
    flex: 0 0 auto !important;
  }

  .chat-header,
  .chat-toolbar,
  .chat-composer {
    background: rgba(8,16,32,.97) !important;
  }

  .chat-header {
    padding-top: 6px !important;
  }

  .chat-toolbar {
    flex-wrap: wrap !important;
  }

  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 180px !important;
    overflow-y: auto !important;
    padding-bottom: 10px !important;
  }

  .chat-composer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 2 !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 -10px 22px rgba(0,0,0,.18) !important;
  }

  .chat-input-row textarea {
    min-height: 88px !important;
    max-height: 18vh !important;
  }

  .chat-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .chat-actions-left {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }

  #sendChatBtn,
  .chat-actions .primary-btn {
    display: inline-flex !important;
    width: 88px !important;
    min-width: 88px !important;
    flex: 0 0 88px !important;
    margin-top: 0 !important;
  }

  .emoji-popover {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 84px) !important;
  }
}

@media (max-width: 560px) {
  .shell {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .topbar.compact {
    margin-bottom: 12px !important;
  }

  .panel,
  .video-panel {
    padding: 12px !important;
  }

  .video-main .video-card,
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card,
  .video-card,
  .video-card video,
  .video-card .video-el {
    min-height: clamp(208px, 31vh, 300px) !important;
    height: clamp(208px, 31vh, 300px) !important;
    max-height: 38vh !important;
  }

  .chat-window {
    min-height: 400px !important;
    height: var(--mobile-chat-height) !important;
    max-height: 68vh !important;
  }

  .chat-header,
  .chat-toolbar,
  .chat-composer,
  .chat-input-row,
  .chat-messages,
  .picker-panel,
  .chat-actions {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .chat-header {
    gap: 8px !important;
  }

  .chat-header .row-compact {
    width: 100% !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
  }

  .chat-mode-btn {
    flex: 1 1 calc(50% - 6px) !important;
    justify-content: center !important;
  }

  .attachment-btn,
  #emojiBtn {
    min-height: 42px !important;
  }
}


/* v6.1.8 final chat stabilization: desktop hide/show restored, mobile messages independently scrollable */
#chatShowBtn.chat-side-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#chatShowBtn.chat-show-btn.hidden {
  display: none !important;
}
.video-panel.chat-collapsed-layout {
  grid-template-columns: minmax(0, 1fr) !important;
}
.video-panel.chat-collapsed-layout #chatWindow {
  display: none !important;
}
@media (min-width: 769px) {
  .video-panel {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px) !important;
    align-items: stretch !important;
  }
  .chat-window {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 640px !important;
    height: min(78vh, 860px) !important;
    max-height: min(78vh, 860px) !important;
    overflow: hidden !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }
}
@media (max-width: 768px) {
  .video-panel {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    overflow: visible !important;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .chat-side-toggle {
    position: fixed !important;
    right: 12px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
    top: auto !important;
    transform: none !important;
    z-index: 90 !important;
  }
  .chat-window {
    --mobile-chat-height: 260px;
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    margin-top: 6px !important;
  }
  .chat-window.chat-collapsed {
    display: none !important;
  }
  .chat-mobile-handle {
    display: block !important;
    flex: 0 0 auto !important;
    padding-top: 10px !important;
    padding-bottom: 4px !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-composer,
  .chat-attachment-preview,
  .chat-input-row,
  .chat-messages,
  .picker-panel,
  .chat-actions {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .chat-header,
  .chat-toolbar {
    flex: 0 0 auto !important;
  }
  .chat-toolbar {
    flex-wrap: wrap !important;
    gap: 10px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }
  .chat-mode-btn {
    flex: 1 1 calc(50% - 6px) !important;
    justify-content: center !important;
    text-align: center !important;
  }
  #mentionPicker.picker-panel {
    max-height: 120px !important;
    overflow-y: auto !important;
  }
  .chat-messages {
    order: 5 !important;
    flex: 0 0 auto !important;
    height: clamp(220px, var(--mobile-chat-height), 360px) !important;
    min-height: 220px !important;
    max-height: 360px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    padding-top: 8px !important;
    padding-bottom: 12px !important;
    background: rgba(255,255,255,.02) !important;
    border-top: 1px solid rgba(255,255,255,.05) !important;
    border-bottom: 1px solid rgba(255,255,255,.05) !important;
  }
  .chat-message {
    min-height: auto !important;
  }
  .chat-attachment-preview {
    order: 6 !important;
    max-height: 140px !important;
    overflow-y: auto !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }
  .chat-composer {
    order: 7 !important;
    position: relative !important;
    bottom: auto !important;
    z-index: 1 !important;
    flex: 0 0 auto !important;
    box-shadow: none !important;
    padding-top: 10px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .chat-input-row {
    padding-top: 0 !important;
    padding-bottom: 10px !important;
  }
  .chat-input-row textarea {
    display: block !important;
    width: 100% !important;
    min-height: 88px !important;
    max-height: 132px !important;
    resize: vertical !important;
  }
  .chat-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    gap: 10px !important;
    padding-top: 4px !important;
  }
  .chat-actions-left {
    display: flex !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
  }
  .chat-actions-left > * {
    flex: 1 1 calc(50% - 5px) !important;
    min-width: 0 !important;
  }
  #sendChatBtn,
  .chat-actions .primary-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
    min-height: 48px !important;
    margin: 0 !important;
  }
  .emoji-popover {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    margin: 10px 14px 0 !important;
  }
}
@media (max-width: 560px) {
  .chat-header {
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .chat-header .row-compact {
    width: 100% !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .chat-header .row-compact > * {
    flex: 0 0 auto !important;
  }
  .chat-window {
    --mobile-chat-height: 240px;
  }
}


/* v6.1.9 mobile screen-share fullscreen + chat translation/clear polish */
.video-el:fullscreen,
.video-el:-webkit-full-screen,
video:fullscreen,
video:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  background: #000 !important;
  object-fit: contain !important;
}

@media (max-width: 768px) {
  .video-el:fullscreen,
  .video-el:-webkit-full-screen,
  video:fullscreen,
  video:-webkit-full-screen {
    object-fit: contain !important;
    background: #000 !important;
  }
}

/* v6.2.0 chat file delivery + account prefs */
.chat-file-permission-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:0 14px 10px;
  color:var(--muted);
}
.chat-file-permission-row select {
  min-width:140px;
  border-radius:10px;
  background:rgba(255,255,255,.06);
  color:var(--text);
  border:1px solid var(--line);
  padding:8px 10px;
}
.chat-file-meta {
  display:flex;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  font-size:12px;
  color:var(--muted);
  margin-top:8px;
}
.chat-file-links {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
.chat-file-card {
  padding:12px;
  border-radius:14px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
}
@media (max-width: 768px) {
  .chat-file-permission-row {
    flex-direction:column;
    align-items:stretch;
  }
  .chat-file-permission-row select {
    width:100%;
    min-width:0;
  }
}


.chat-file-card.standardized{display:flex;align-items:center;gap:12px}.chat-file-badge{min-width:56px;height:56px;border-radius:14px;display:flex;align-items:center;justify-content:center;font-weight:800;letter-spacing:.5px;background:rgba(122,168,255,.18);border:1px solid rgba(122,168,255,.28);color:#dbe8ff}.chat-file-card.standardized .chat-file-meta{flex:1;min-width:0}.chat-file-card.standardized .chat-file-links{display:flex;flex-wrap:wrap;gap:8px}

/* admin stats + account preference polish */
.admin-metric-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}
.metric-card {
  padding:14px;
  border-radius:16px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  display:flex;
  flex-direction:column;
  gap:8px;
}
.metric-card span,
.metric-card small {
  color:var(--muted);
}
.metric-card strong {
  font-size:28px;
  line-height:1;
}
.metric-bar {
  width:100%;
  height:8px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  overflow:hidden;
}
.metric-bar i {
  display:block;
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg, rgba(122,168,255,.95), rgba(103,212,255,.95));
}
.compact-grid div strong {
  font-size:14px;
}
.speaker-pref-desc {
  margin: -2px 0 8px;
}
@media (max-width: 768px) {
  .admin-metric-grid {
    grid-template-columns:1fr;
  }
}

/* v6.3.4 desktop chat panel and admin action polish */
@media (min-width: 1024px) {
  .video-panel {
    grid-template-columns: minmax(0, 1fr) minmax(460px, 520px) !important;
    gap: 22px !important;
    align-items: stretch !important;
  }
  #chatWindow.chat-window,
  .chat-window {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 780px !important;
    height: min(88vh, 980px) !important;
    max-height: min(88vh, 980px) !important;
    overflow: hidden !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-composer,
  .chat-file-permission-row {
    flex: 0 0 auto !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 460px !important;
    padding: 14px 18px 18px !important;
    overflow-y: auto !important;
  }
  .chat-composer {
    padding-top: 14px !important;
    padding-bottom: 16px !important;
  }
  .chat-input-row textarea,
  #chatInput {
    min-height: 148px !important;
    height: 148px !important;
    max-height: 220px !important;
    resize: vertical !important;
  }
}

.admin-top-grid,
.admin-mid-grid {
  align-items: stretch;
}
.admin-alert-panel .notice {
  margin-top: 0;
}
.admin-actions-grid .row-compact {
  flex-wrap: wrap;
}
.admin-reset-form input {
  flex: 1 1 180px;
}

/* v6.3.5 desktop chat panel final fix */
@media (min-width: 769px) {
  .room-grid-layout {
    grid-template-columns: 300px minmax(0, 1fr) !important;
    align-items: start !important;
  }
  .video-panel {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(440px, 520px) !important;
    gap: 18px !important;
    align-items: stretch !important;
    min-height: 980px !important;
    overflow: visible !important;
  }
  .video-stage {
    min-height: 980px !important;
  }
  .chat-window {
    display: flex !important;
    flex-direction: column !important;
    align-self: stretch !important;
    min-height: 980px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .chat-header,
  .chat-toolbar,
  .chat-file-permission-row,
  .chat-input-row,
  .chat-actions,
  .chat-attachment-preview,
  #mentionPicker {
    flex: 0 0 auto !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 420px !important;
    overflow-y: auto !important;
    padding-bottom: 16px !important;
  }
  .chat-composer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 3 !important;
    background: rgba(8,16,32,.96) !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
    padding-top: 14px !important;
    padding-bottom: 18px !important;
    box-shadow: 0 -12px 28px rgba(0,0,0,.18) !important;
  }
  .chat-input-row {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .chat-input-row textarea {
    min-height: 132px !important;
    max-height: 280px !important;
    resize: vertical !important;
  }
  .chat-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-bottom: 2px !important;
  }
  .chat-actions-left {
    display: flex !important;
    flex: 1 1 260px !important;
    min-width: 0 !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .chat-actions .primary-btn,
  #sendChatBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 140px !important;
    min-width: 140px !important;
    flex: 0 0 140px !important;
    margin-top: 0 !important;
  }
  .attachment-btn,
  .chat-actions-left .ghost-btn {
    max-width: 100% !important;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .video-panel {
    grid-template-columns: minmax(0, 1fr) minmax(400px, 460px) !important;
  }
}

@media (max-width: 768px) {
  .chat-window {
    min-height: 560px !important;
  }
  .chat-composer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }
}


/* v6.3.6 chat scroll and attachment preview fix */
@media (min-width: 769px) {
  .video-panel {
    overflow: hidden !important;
    align-items: stretch !important;
  }
  .chat-window {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: min(88vh, 980px) !important;
    max-height: min(88vh, 980px) !important;
    overflow: hidden !important;
  }
  .chat-header,
  .chat-toolbar,
  #mentionPicker,
  .chat-composer {
    flex: 0 0 auto !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }
  .chat-composer {
    position: relative !important;
    bottom: auto !important;
    margin-top: 0 !important;
    z-index: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    background: rgba(8,16,32,.96) !important;
    box-shadow: none !important;
  }
  .chat-file-permission-row,
  .chat-attachment-preview,
  .chat-input-row,
  .chat-actions {
    flex: 0 0 auto !important;
  }
  .chat-attachment-preview {
    order: 1 !important;
    padding: 0 16px 0 !important;
    max-height: 168px !important;
    overflow-y: auto !important;
  }
  .chat-file-permission-row {
    order: 2 !important;
    padding: 0 16px !important;
  }
  .chat-input-row {
    order: 3 !important;
    padding: 0 16px !important;
  }
  .chat-actions {
    order: 4 !important;
  }
  .chat-attachment-preview .chat-media {
    max-height: 120px !important;
    width: auto !important;
  }
  .chat-attachment-preview .chat-file-card,
  .chat-attachment-preview > img,
  .chat-attachment-preview > video {
    margin-bottom: 8px !important;
  }
}

@media (max-width: 768px) {
  .chat-window {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .chat-composer {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .chat-attachment-preview {
    max-height: 132px !important;
    overflow-y: auto !important;
    padding: 0 12px !important;
  }
  .chat-attachment-preview .chat-media {
    max-height: 96px !important;
  }
}

/* v6.3.8 mobile chat composer visibility + attachment preview order fix */
@media (max-width: 768px) {
  .video-panel {
    overflow: visible !important;
  }

  .chat-window {
    --mobile-chat-height: min(68vh, 620px);
    display: flex !important;
    flex-direction: column !important;
    min-height: 420px !important;
    height: clamp(420px, var(--mobile-chat-height), 78vh) !important;
    max-height: 78vh !important;
    overflow: hidden !important;
  }

  .chat-header,
  .chat-toolbar,
  #mentionPicker,
  .chat-composer {
    flex: 0 0 auto !important;
  }

  .chat-messages {
    order: 4 !important;
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 140px !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    padding-top: 8px !important;
    padding-bottom: 12px !important;
  }

  .chat-composer {
    order: 5 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding-top: 10px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(8,16,32,.96) !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
  }

  .chat-file-permission-row {
    order: 1 !important;
    padding: 0 12px 8px !important;
  }

  .chat-attachment-preview {
    order: 2 !important;
    max-height: 108px !important;
    overflow-y: auto !important;
    padding: 0 12px !important;
  }

  .chat-attachment-preview .chat-media {
    max-height: 72px !important;
    width: auto !important;
  }

  .chat-input-row {
    order: 3 !important;
    padding: 0 12px !important;
  }

  .chat-input-row textarea,
  #chatInput {
    display: block !important;
    width: 100% !important;
    min-height: 72px !important;
    max-height: 120px !important;
    resize: vertical !important;
  }

  .emoji-popover {
    order: 4 !important;
    margin: 0 12px !important;
  }

  .chat-actions {
    order: 5 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 0 12px !important;
  }

  .chat-actions-left {
    display: flex !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  .chat-actions-left > * {
    flex: 1 1 calc(50% - 5px) !important;
    min-width: 0 !important;
  }

  #sendChatBtn,
  .chat-actions .primary-btn {
    display: inline-flex !important;
    width: 100% !important;
    min-height: 46px !important;
    flex: 1 1 100% !important;
    margin: 0 !important;
  }
}

@media (max-width: 560px) {
  .chat-window {
    min-height: 400px !important;
    height: clamp(400px, var(--mobile-chat-height), 76vh) !important;
  }

  .chat-input-row textarea,
  #chatInput {
    min-height: 68px !important;
    max-height: 108px !important;
  }

  .chat-attachment-preview {
    max-height: 96px !important;
  }

  .chat-attachment-preview .chat-media {
    max-height: 64px !important;
  }
}


/* v6.3.9 mobile chat controls hard-fix + stable participant sync */
@media (max-width: 768px) {
  .video-panel {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 12px !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .chat-window {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    border-radius: 18px !important;
  }

  .chat-header,
  .chat-toolbar,
  #mentionPicker,
  .chat-composer,
  .chat-file-permission-row,
  .chat-attachment-preview,
  .chat-input-row,
  .chat-actions,
  .chat-actions-left {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .chat-messages {
    flex: 0 1 auto !important;
    min-height: 180px !important;
    max-height: 34vh !important;
    overflow-y: auto !important;
  }

  .chat-composer {
    position: relative !important;
    bottom: auto !important;
    padding: 10px 0 calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 10px !important;
    overflow: visible !important;
  }

  .chat-file-permission-row {
    order: 1 !important;
    padding: 0 12px !important;
  }

  .chat-attachment-preview {
    order: 2 !important;
    display: block !important;
    padding: 0 12px !important;
    max-height: 120px !important;
    overflow-y: auto !important;
  }

  .chat-input-row {
    order: 3 !important;
    padding: 0 12px !important;
  }

  #chatInput {
    width: 100% !important;
    min-height: 76px !important;
    max-height: 132px !important;
  }

  .chat-actions {
    order: 4 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 0 12px !important;
    overflow: visible !important;
  }

  .chat-actions-left {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    flex: none !important;
  }

  .chat-actions-left > *,
  .attachment-btn,
  .chat-actions-left .ghost-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 10px 8px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #sendChatBtn,
  .chat-actions .primary-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 46px !important;
    margin: 0 !important;
    flex: none !important;
  }
}

@media (max-width: 480px) {
  .chat-actions-left {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .chat-actions-left > :last-child {
    grid-column: 1 / -1 !important;
  }
}

/* ===== Desktop room UI balance v6.4.6 safe patch ===== */
@media (min-width: 1180px) {
  .shell {
    max-width: 1560px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .topbar.compact {
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 16px;
  }

  .topbar.compact > div:first-child {
    min-width: 240px;
  }

  .topbar.compact .top-actions {
    justify-content: flex-end;
  }

  .room-grid-layout {
    grid-template-columns: 296px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .side-panel {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 132px);
    overflow: auto;
    padding: 18px;
    scrollbar-width: thin;
  }

  .side-panel .mini-panel {
    margin-top: 14px;
  }

  .button-grid-2 {
    gap: 9px;
  }

  .button-grid-2 .ghost-btn,
  .button-grid-2 .primary-btn {
    min-height: 42px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .video-panel {
    grid-template-columns: minmax(0, 1fr) 440px !important;
    gap: 18px;
    align-items: stretch;
  }

  .chat-window {
    border-radius: 20px;
  }

  .chat-header,
  .chat-toolbar,
  .chat-file-permission-row,
  .chat-composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-messages {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (min-width: 1180px) and (max-width: 1360px) {
  .room-grid-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .video-panel {
    grid-template-columns: minmax(0, 1fr) 400px !important;
  }
}


/* v6.4.7 safe meeting grid + delayed media fix */
.video-stage.grid-layout {
  grid-template-columns: minmax(0, 1fr);
}
.video-stage.grid-layout .video-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-content: stretch;
}
.video-stage.grid-layout .video-sidebar {
  display: none !important;
}
.video-stage.grid-layout .video-card {
  min-height: clamp(240px, 34vh, 360px);
  max-height: clamp(240px, 34vh, 360px);
  aspect-ratio: 16 / 9;
}
.video-stage.grid-layout .video-main:has(.video-card:nth-child(1):last-child) {
  grid-template-columns: 1fr;
}
@media (min-width: 961px) {
  .room-grid-layout { grid-template-columns: 280px minmax(0, 1fr); gap: 18px; }
  .video-panel { grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; }
  .side-panel { max-height: calc(100vh - 130px); overflow: auto; }
  .video-stage { min-height: clamp(420px, 58vh, 640px); }
  .video-main .video-card,
  .video-stage.focus-layout .video-main .video-card,
  .video-stage.screen-share-mode .video-main .video-card {
    border-radius: 22px;
    overflow: hidden;
  }
}
@media (max-width: 1200px) and (min-width: 961px) {
  .video-panel { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 960px) {
  .video-stage.grid-layout .video-main {
    grid-template-columns: 1fr;
  }
  .video-stage.grid-layout .video-card {
    min-height: clamp(220px, 34vh, 340px);
    max-height: clamp(220px, 34vh, 340px);
  }
}

/* v6.4.10 strict desktop meeting grid fix */
@media (min-width: 961px) {
  .video-panel {
    align-items: start;
  }

  .video-stage.grid-layout {
    min-height: clamp(520px, 70vh, 820px);
  }

  .video-stage.grid-layout .video-main {
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: 1fr;
    align-content: start;
    gap: 16px;
    min-height: 0;
    height: auto;
  }

  .video-stage.grid-layout.grid-1 .video-main {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .video-stage.grid-layout.grid-2 .video-main {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .video-stage.grid-layout.grid-3 .video-main {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .video-stage.grid-layout .video-card {
    width: 100%;
    min-width: 0;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .video-stage.grid-layout .video-card,
  .video-stage.grid-layout .video-card video,
  .video-stage.grid-layout .video-card .video-el {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .video-stage.grid-layout .video-main:has(.video-card:nth-child(1):last-child) {
    grid-template-columns: minmax(0, 1fr) !important;
    max-width: min(980px, 100%);
    margin: 0 auto;
  }

  .video-pager {
    justify-content: center;
    margin-top: 14px;
  }
}


/* v6.4.11 desktop paged grid polish */
@media (min-width: 961px) {
  .video-panel {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 20px;
    align-items: start;
  }

  .video-stage.grid-layout,
  .video-stage.paged-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: 0 !important;
  }

  .video-stage.grid-layout .video-main,
  .video-stage.paged-grid .video-main {
    width: 100%;
    margin: 0;
    gap: 14px;
    align-content: start;
    justify-items: stretch;
  }

  .video-stage.grid-1 .video-main {
    max-width: min(960px, 100%);
    margin-inline: auto;
  }

  .video-stage.grid-2 .video-main {
    max-width: min(1120px, 100%);
    margin-inline: auto;
  }

  .video-stage.grid-3 .video-main {
    max-width: min(1280px, 100%);
    margin-inline: auto;
  }

  .video-stage.grid-layout .video-main .video-card,
  .video-stage.paged-grid .video-main .video-card {
    width: 100%;
    min-height: 0 !important;
    height: auto !important;
    aspect-ratio: 16 / 10;
    border-radius: 18px;
  }

  .video-pager {
    justify-content: center;
    margin: 10px 0 6px;
    padding-inline: 8px;
  }

  .video-pager-info {
    min-width: 54px;
    font-size: 12px;
  }

  .pager-btn {
    min-width: 88px;
  }

  .chat-window {
    align-self: stretch;
    margin-top: 4px;
  }
}


/* v6.4.12 desktop pager + chat column alignment */
@media (min-width: 961px) {
  .video-panel {
    grid-auto-flow: row;
    align-items: start;
  }

  .video-panel > #videoStage {
    grid-column: 1;
    grid-row: 1;
  }

  .video-panel > #videoPager {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    width: 100%;
    margin-top: 12px;
    margin-bottom: 0;
  }

  .video-panel > #chatWindow {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
  }

  .video-panel > #chatShowBtn,
  .video-panel > #chatContextMenu {
    grid-column: 2;
  }

  .video-stage.grid-layout.grid-3 .video-main,
  .video-stage.paged-grid.grid-3 .video-main {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .video-stage.grid-layout .video-main .video-card,
  .video-stage.paged-grid .video-main .video-card {
    aspect-ratio: 16 / 9;
  }
}


/* v6.4.12 mention dropdown with search for desktop + mobile */
.picker-panel {
  padding: 0;
  margin: 0 14px 10px;
  background: transparent;
  border: 0;
}
#mentionPicker.hidden { display: none !important; }
.mention-dropdown {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  background: rgba(10,18,34,.98);
  box-shadow: 0 18px 42px rgba(0,0,0,.24);
  overflow: hidden;
}
.mention-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.mention-dropdown-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}
.mention-search-wrap {
  padding: 10px 12px 8px;
}
.mention-search-input {
  width: 100%;
  padding: 10px 12px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
  color: var(--text);
  ime-mode: auto;
  font-family: inherit;
}
.mention-search-input:focus {
  outline: 0;
  border-color: rgba(130,177,255,.55);
  box-shadow: 0 0 0 3px rgba(130,177,255,.14);
}
.mention-options-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.mention-option-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  text-align: left;
  border-radius: 12px;
}
.mention-option-at {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(130,177,255,.14);
  color: var(--primary);
  font-weight: 700;
  flex: 0 0 22px;
}
.mention-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mention-empty {
  padding: 10px 4px 2px;
  color: var(--muted);
  font-size: 13px;
}
@media (min-width: 769px) {
  #mentionPicker {
    margin: 0 16px 10px !important;
  }
  .mention-options-list {
    max-height: 220px;
  }
}
@media (max-width: 768px) {
  #mentionPicker {
    margin: 0 12px 10px !important;
  }
  .mention-dropdown-head {
    padding: 10px 10px;
  }
  .mention-search-wrap {
    padding: 10px 10px 8px;
  }
  .mention-options-list {
    max-height: 160px;
    padding: 0 10px 10px;
  }
  .mention-option-row {
    padding: 10px 10px;
  }
}


/* v6.4.16 participant pager search + first-page button */
.video-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.video-pager-left,
.video-pager-center,
.video-pager-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.video-pager-center {
  flex-wrap: wrap;
  justify-content: center;
}
.video-search-input {
  width: min(320px, 62vw);
  min-width: 220px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-family: inherit;
}
.video-search-input:focus {
  outline: 0;
  border-color: rgba(130,177,255,.55);
  box-shadow: 0 0 0 3px rgba(130,177,255,.14);
}
.pager-home-btn {
  min-width: 54px;
  font-size: 20px;
  line-height: 1;
}
.video-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(52vh, 420px);
  margin: 0 auto;
  width: min(520px, 92%);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  padding: 18px 20px;
  text-align: center;
}
@media (max-width: 768px) {
  .video-pager {
    gap: 10px;
  }
  .video-pager-left,
  .video-pager-center,
  .video-pager-right {
    width: 100%;
    justify-content: center;
  }
  .video-search-input {
    width: min(100%, 340px);
    min-width: 0;
  }
}


.mobile-scan-trigger { display: none; }
.scan-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(4, 10, 24, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.scan-modal.hidden { display: none !important; }
.scan-modal-card {
  width: min(100%, 420px);
  border-radius: 20px;
  background: rgba(12, 22, 44, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 14px;
}
.scan-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.scan-modal-body { position: relative; }
.scan-video {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 16px;
  background: #050a14;
}
.scan-frame {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(62vw, 220px);
  height: min(62vw, 220px);
  max-width: calc(100% - 44px);
  max-height: calc(100% - 88px);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(130, 177, 255, 0.92);
  border-radius: 20px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}
.scan-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
@media (max-width: 768px) {
  .mobile-scan-trigger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
}
@media (min-width: 769px) {
  .scan-modal { display: none !important; }
}

/* room layout cleanup: canonical desktop/mobile sizing */
.room-grid-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.room-grid-layout > .side-panel,
.video-panel,
#videoStage,
#videoMain,
#videoSidebar,
.chat-window {
  min-width: 0;
}

.video-panel {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

.video-panel.chat-collapsed-layout {
  grid-template-columns: minmax(0, 1fr) 0 !important;
}

.chat-window,
#chatWindow.chat-window {
  width: 100%;
  min-height: 620px;
  max-height: calc(100vh - 150px);
  height: auto;
  overflow: hidden;
}

@media (max-width: 1360px) {
  .video-panel {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1100px) {
  .room-grid-layout {
    grid-template-columns: 1fr;
  }

  .video-panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .chat-window,
  #chatWindow.chat-window {
    min-height: 460px;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .room-grid-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .video-panel {
    grid-template-columns: 1fr !important;
    gap: 14px;
    min-height: auto;
  }

  .chat-window,
  #chatWindow.chat-window {
    min-height: 380px;
    height: auto;
    max-height: none;
  }
}
