/* =========================================================
   Комната — видеовстречи по ссылке
   Файл стилей. Внешних ресурсов нет: только системные шрифты.
   ========================================================= */

:root {
  --bg: #0a0b0e;
  --bg-soft: #0e1015;
  --panel: #14161d;
  --panel-2: #191c24;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef4;
  --text-dim: #b9becd;
  --muted: #8b90a0;
  --accent: #7bf1c4;
  --accent-ink: #062018;
  --accent-soft: rgba(123, 241, 196, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.14);
  --radius: 16px;
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.55);
  --topbar: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

body[data-view="room"] { overflow: hidden; }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-inline { width: 15px; height: 15px; vertical-align: -2px; }
.icon-xl { width: 34px; height: 34px; stroke-width: 1.4; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------------- topbar ---------------- */

.topbar {
  height: var(--topbar);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 30;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.wordmark-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(123, 241, 196, 0.12);
}

.topbar-nav { display: flex; align-items: center; gap: 6px; }

.ghost-link,
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.ghost-link:hover, .icon-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}
.icon-link .icon { width: 16px; height: 16px; }

/* ---------------- views ---------------- */

.main { position: relative; }

.view { width: 100%; }

.view-home { min-height: calc(100dvh - var(--topbar)); display: flex; flex-direction: column; position: relative; }

.home-glow {
  position: absolute;
  inset: -200px 20% auto -10%;
  height: 560px;
  background:
    radial-gradient(58% 60% at 30% 40%, rgba(123, 241, 196, 0.13), transparent 70%),
    radial-gradient(45% 50% at 70% 20%, rgba(111, 140, 255, 0.10), transparent 72%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.home-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 32px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.82fr);
  gap: 64px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
}

.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(123, 241, 196, 0.5);
  animation: pulse 2.6s infinite;
  flex: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(123, 241, 196, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(123, 241, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 241, 196, 0); }
}

h1 {
  margin: 22px 0 0;
  font-size: clamp(38px, 5.4vw, 66px);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 680;
}

.lede {
  margin: 22px 0 0;
  max-width: 47ch;
  color: var(--text-dim);
  font-size: 16.5px;
  line-height: 1.62;
}

.feature-list {
  list-style: none;
  margin: 34px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.feature-list li { display: flex; align-items: flex-start; gap: 12px; }

.feature-ico {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(123, 241, 196, 0.18);
  flex: none;
}
.feature-ico .icon { width: 18px; height: 18px; }

.feature-body { display: flex; flex-direction: column; padding-top: 1px; }
.feature-body b { font-weight: 600; font-size: 14.5px; }
.feature-body span { color: var(--muted); font-size: 13.5px; }

/* ---------------- card / form ---------------- */

.card {
  background: linear-gradient(180deg, #161922 0%, #111319 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 26px 22px;
  box-shadow: var(--shadow-lg);
}

.card h2 { margin: 0; font-size: 21px; letter-spacing: -0.02em; font-weight: 620; }
.card-sub { margin: 7px 0 20px; color: var(--muted); font-size: 13.8px; line-height: 1.5; }

.card-note {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12.5px;
  padding-left: 4px;
}

.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 46px;
  padding: 0 18px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(123, 241, 196, 0.16);
}
.btn-primary:hover { background: #8ef7cf; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); }

.btn-block { width: 100%; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 11px; }

.divider {
  position: relative;
  text-align: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
}
.divider::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--line);
}
.divider span { position: relative; background: #14161e; padding: 0 10px; }

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 7px;
  letter-spacing: 0.01em;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(9, 10, 14, 0.65);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: #63697a; }
.input:focus {
  border-color: rgba(123, 241, 196, 0.55);
  box-shadow: 0 0 0 3px rgba(123, 241, 196, 0.10);
}

.join-row { display: flex; gap: 8px; }
.join-row .input { flex: 1; min-width: 0; }
.join-row .btn { height: 46px; }

.form-error {
  margin: 8px 0 0;
  min-height: 18px;
  color: var(--danger);
  font-size: 12.5px;
}

.fine {
  margin: 18px 0 0;
  color: #6f7484;
  font-size: 11.8px;
  line-height: 1.5;
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.fine .icon { margin-top: 2px; color: #7d8496; }

.home-foot {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px 26px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #62687a;
  font-size: 12px;
}
.home-foot a { color: #8b90a0; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.home-foot a:hover { color: var(--text); }

/* ---------------- lobby ---------------- */

.view-lobby { min-height: calc(100dvh - var(--topbar)); display: flex; align-items: center; justify-content: center; padding: 24px; }

.lobby {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: stretch;
}

.lobby-preview {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #07080b;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  min-height: 320px;
}

.lobby-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #6d7282;
  background: radial-gradient(60% 60% at 50% 40%, #14171f, #07080b 78%);
  font-size: 13px;
}

.lobby-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(10, 11, 14, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12.5px;
  backdrop-filter: blur(8px);
}
.chip-soft { background: rgba(255, 255, 255, 0.04); border-color: var(--line); color: var(--text-dim); font-size: 12px; }
.chip-hide-sm { }

.lobby-controls { display: flex; gap: 8px; }

.round-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(16, 18, 24, 0.75);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  backdrop-filter: blur(8px);
}
.round-btn:hover { background: rgba(30, 34, 44, 0.9); }
.round-btn[aria-pressed="false"] { background: var(--danger); border-color: transparent; color: #fff; }

.lobby-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.lobby-panel h2 { margin: 10px 0 18px; font-size: 22px; letter-spacing: -0.02em; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
}
.back-link:hover { color: var(--text); }
.back-link .icon { width: 16px; height: 16px; }

.code-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.room-code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 26px;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text);
}

#name-input { margin-bottom: 16px; }

.lobby-status { min-height: 18px; margin: 10px 0 0; color: var(--accent); font-size: 12.5px; }
.lobby-status[data-error="true"] { color: var(--danger); }

/* ---------------- room ---------------- */

.view-room {
  height: calc(100dvh - var(--topbar));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 20px 10px;
  flex: none;
}

.room-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.room-name {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.room-meta { display: flex; align-items: center; gap: 8px; }

.mini-btn {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); border-color: var(--line); }
.mini-btn .icon { width: 15px; height: 15px; }

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #e2b93b;
  flex: none;
}
#conn-chip[data-state="online"] .status-dot { background: var(--accent); }
#conn-chip[data-state="offline"] .status-dot { background: var(--danger); }

.conn-banner {
  margin: 0 20px 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(255, 107, 107, 0.28);
  color: #ffc9c9;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.room-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  transition: grid-template-columns 0.22s ease;
}

.room-body[data-chat="true"] { grid-template-columns: minmax(0, 1fr) 372px; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 4px 20px 10px;
}

.grid {
  height: 100%;
  display: grid;
  gap: 10px;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
}

.tile {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  background: #0b0d12;
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 0;
  isolation: isolate;
}

.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b0d12;
}
.tile[data-mirror="true"] .tile-video { transform: scaleX(-1); }
.tile[data-screen="true"] .tile-video { object-fit: contain; background: #000; }
.tile[data-video="off"] .tile-video { opacity: 0; }

.tile-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(65% 65% at 50% 35%, #1a1e27, #0b0d12 80%);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.tile[data-video="off"] .tile-fallback { opacity: 1; }

.tile-initial {
  width: 68px; height: 68px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tile-top { position: absolute; inset: 10px 10px auto 10px; display: flex; gap: 6px; justify-content: flex-start; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.02em;
  background: rgba(9, 10, 14, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  backdrop-filter: blur(6px);
}
.badge-screen { color: var(--accent); border-color: rgba(123, 241, 196, 0.32); background: rgba(8, 30, 24, 0.7); }

.tile-bottom {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 12px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-size: 12.5px;
}

.tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.tile-flags { display: inline-flex; gap: 5px; color: #d6d9e2; }
.tile-flags .icon { width: 15px; height: 15px; }
.tile-flag-muted { color: #ff9a9a; }

.tile-status {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(9, 10, 14, 0.78);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.stage-empty-card {
  pointer-events: auto;
  width: min(430px, 100%);
  text-align: center;
  background: rgba(14, 16, 21, 0.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.stage-empty-card .feature-ico { margin-bottom: 12px; }
.stage-empty-card h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.01em; }
.stage-empty-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.stage-link {
  display: block;
  margin-top: 12px;
  font-size: 11.5px;
  color: #6f7484;
  word-break: break-all;
}

/* ---------------- dock ---------------- */

.dock {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px 18px;
}

.dock-btn {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.dock-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--line-strong); }
.dock-btn:active { transform: translateY(1px); }
.dock-btn .icon { width: 21px; height: 21px; }
.dock-label { font-size: 9.5px; letter-spacing: 0.02em; color: var(--muted); }
.dock-btn:hover .dock-label { color: var(--text-dim); }

#btn-mic[data-on="false"],
#btn-cam[data-on="false"] {
  background: var(--danger-soft);
  border-color: rgba(255, 107, 107, 0.3);
  color: #ff9d9d;
}
#btn-mic[data-on="false"] .dock-label,
#btn-cam[data-on="false"] .dock-label { color: #ff9d9d; }

.dock-btn[data-on="true"]#btn-screen {
  background: var(--accent-soft);
  border-color: rgba(123, 241, 196, 0.35);
  color: var(--accent);
}
.dock-btn[data-on="true"]#btn-screen .dock-label { color: var(--accent); }

.dock-btn[data-on="true"]#btn-chat { background: var(--accent-soft); border-color: rgba(123, 241, 196, 0.3); color: var(--accent); }
.dock-btn[data-on="true"]#btn-chat .dock-label { color: var(--accent); }

.dock-btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.dock-btn-danger:hover { background: #ff7d7d; }
.dock-btn-danger .dock-label { color: rgba(255, 255, 255, 0.85); }
.dock-btn-danger .icon { transform: rotate(135deg); }

.dock-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 19px; height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dock-sep { width: 1px; height: 30px; background: var(--line); margin: 0 6px; }

.audio-sink { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------- chat ---------------- */

.chat {
  display: none;
  min-height: 0;
  flex-direction: column;
  background: #0d0f14;
  border-left: 1px solid var(--line);
  position: relative;
}

.room-body[data-chat="true"] .chat { display: flex; }

.chat-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-head b { font-size: 14px; font-weight: 600; display: block; }
.chat-sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }

.chat-empty {
  margin: auto;
  text-align: center;
  color: #5f6474;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-empty span:first-child { color: var(--text-dim); font-size: 13.5px; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg-head { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; }
.msg-name { color: var(--accent); font-weight: 600; }
.msg[data-self="true"] .msg-name { color: #a9b4ff; }
.msg-time { color: #5f6474; font-size: 10.5px; }
.msg[data-self="true"] .msg-head { justify-content: flex-end; }

.msg-bubble {
  align-self: flex-start;
  max-width: 92%;
  padding: 8px 11px;
  border-radius: 12px 12px 12px 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg[data-self="true"] .msg-bubble {
  align-self: flex-end;
  background: rgba(123, 241, 196, 0.10);
  border-color: rgba(123, 241, 196, 0.18);
  border-radius: 12px 12px 4px 12px;
}

.msg-image {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: #07080b;
}

.msg-system {
  text-align: center;
  font-size: 11.5px;
  color: #6a6f7f;
  padding: 2px 0;
}

.chat-compose {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: #0d0f14;
}

.compose-btn, .compose-send {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.compose-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.compose-send { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.compose-send:hover { background: #8ef7cf; }
.compose-send .icon { width: 18px; height: 18px; }

.chat-input {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  resize: none;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(9, 10, 14, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
}
.chat-input:focus { border-color: rgba(123, 241, 196, 0.45); }

.chat-drop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 12, 0.82);
  border: 2px dashed rgba(123, 241, 196, 0.5);
  border-radius: 14px;
  margin: 8px;
  color: var(--accent);
  font-size: 13.5px;
  z-index: 5;
}
.chat[data-drop="true"] .chat-drop { display: flex; }

/* ---------------- toasts ---------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 70;
  pointer-events: none;
  align-items: center;
}

.toast-out { opacity: 0; transform: translateY(4px); transition: opacity 0.2s ease, transform 0.2s ease; }

.toast {
  padding: 9px 14px;
  border-radius: 11px;
  background: rgba(20, 23, 30, 0.94);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.8px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease;
  max-width: min(460px, 90vw);
  text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- modal ---------------- */

.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 8, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  z-index: 1;
}
.modal-x {
  position: absolute;
  top: 10px; right: 10px;
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-x:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.modal-x .icon { width: 16px; height: 16px; }

.modal-title { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-body-text { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; line-height: 1.6; }

.modal-img { display: block; width: 100%; height: auto; border-radius: 12px; background: #07080b; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.settings-grid .full { grid-column: 1 / -1; }
.settings-hint { color: #6f7484; font-size: 11.5px; line-height: 1.5; margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .home-inner { grid-template-columns: minmax(0, 1fr); gap: 36px; padding: 24px 22px 28px; }
  .home-copy h1 { font-size: clamp(34px, 8vw, 52px); }
  .home-foot { padding: 0 22px 22px; }
  .lobby { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
  .lobby-preview { aspect-ratio: 16 / 10; min-height: 240px; }
  .lobby-panel { padding: 20px; }
  .room-head { padding: 2px 14px 8px; }
  .stage { padding: 2px 12px 8px; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .stage { overflow-y: auto; }
  .topbar { padding: 0 16px; }
  .topbar-nav .ghost-link { display: none; }
  .dock { gap: 4px; padding: 8px 10px 14px; }
  .dock-btn { width: 54px; height: 54px; border-radius: 15px; }
  .dock-label { display: none; }
  .dock-sep { margin: 0 2px; }
  .toasts { bottom: 86px; }

  .chat {
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 45;
    border-left: 0;
    width: 100%;
  }
  .room-body[data-chat="true"] .chat { display: flex; }

  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-auto-rows: minmax(0, 1fr); }
  .tile-initial { width: 56px; height: 56px; font-size: 21px; }
}

@media (max-width: 420px) {
  .join-row { flex-direction: column; }
  .join-row .btn { width: 100%; }
  .room-code { font-size: 22px; }
  .chip-hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------- guide page ---------------- */

.doc-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 24px 80px;
}

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 30px;
}
.doc-back:hover { color: var(--text); }
.doc-back .icon { width: 16px; height: 16px; }

.doc h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.doc .doc-lede {
  margin: 0 0 34px;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1.65;
}

.doc h2 {
  margin: 44px 0 14px;
  font-size: 23px;
  letter-spacing: -0.02em;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.doc h3 {
  margin: 26px 0 10px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.doc p, .doc li {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.68;
}

.doc p { margin: 0 0 12px; }

.doc ol, .doc ul { margin: 0 0 16px; padding-left: 22px; }
.doc li { margin-bottom: 7px; }
.doc li::marker { color: var(--accent); }

.doc b, .doc strong { color: var(--text); font-weight: 600; }

.doc a { color: var(--accent); border-bottom: 1px solid rgba(123, 241, 196, 0.28); }
.doc a:hover { border-bottom-color: var(--accent); }

.doc code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.9em;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  color: #d8f7ea;
  overflow-wrap: anywhere;
}

.doc pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #0b0d12;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.doc pre code { background: none; border: 0; padding: 0; color: #cfe9df; font-size: 12.5px; line-height: 1.6; }

.doc-note {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(123, 241, 196, 0.22);
  background: rgba(123, 241, 196, 0.06);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.6;
}
.doc-note b { color: var(--accent); }

.doc-warn {
  border-color: rgba(255, 200, 100, 0.25);
  background: rgba(255, 200, 100, 0.06);
}
.doc-warn b { color: #ffcf7a; }

.doc-table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 13.5px; }
.doc-table th, .doc-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.02em; text-transform: uppercase; }
.doc-table td { color: var(--text-dim); }
.doc-table td:first-child { color: var(--text); white-space: nowrap; }

.doc-steps { display: grid; gap: 12px; margin: 0 0 18px; padding: 0; list-style: none; }
.doc-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}
.doc-step-num {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(123, 241, 196, 0.22);
}
.doc-step-body b { display: block; color: var(--text); font-size: 14px; margin-bottom: 3px; }
.doc-step-body span { color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 640px) {
  .doc-wrap { padding: 10px 18px 60px; }
  .doc-table { font-size: 12.5px; }
  .doc-table th, .doc-table td { padding: 8px; }
}

.doc-foot-link { margin-top: 38px; }
.doc-table td:first-child { white-space: normal; }

/* ---------------- invite button, rank prefix, preview note ---------------- */

.dock-btn-invite {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.dock-btn-invite:hover { background: #8ef7cf; border-color: transparent; }
.dock-btn-invite .dock-label { color: rgba(6, 32, 24, 0.78); }
.dock-btn-invite:hover .dock-label { color: rgba(6, 32, 24, 0.92); }

.preview-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 200, 100, 0.28);
  background: rgba(255, 200, 100, 0.07);
  color: #ffd693;
  font-size: 12px;
  line-height: 1.5;
}

.invite-link { margin-bottom: 14px; font-size: 13px; }

.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-actions .btn { flex: 1; min-width: 140px; }

@media (max-width: 760px) {
  .dock { gap: 3px; padding: 8px 8px 14px; }
  .dock-btn { width: 50px; height: 52px; border-radius: 14px; }
  .dock-sep { display: none; }
  .dock-btn-invite { width: 54px; }
}

/* ---------------- diagnostics ---------------- */

button.chip { font-family: inherit; cursor: pointer; }
button.chip:hover { border-color: var(--line-strong); color: var(--text); }

.diag-pre {
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 10px;
  background: #0b0d12;
  border: 1px solid var(--line);
  color: #cfe9df;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 11.8px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
}
