/* ─────────────────────────────────────────────
   lingdong/chat — 深夜电台风格 v2
   ───────────────────────────────────────────── */

:root {
  --bg: #15110d;
  --bg-2: #1d1813;
  --surface: #251f19;
  --surface-2: #2e2620;
  --line: #3a302787;
  --text: #f4ecdf;
  --text-dim: #b9ad99;
  --muted: #8a7d6b;
  --amber: #e8a547;
  --amber-soft: #ffd089;
  --sage: #95c187;
  --coral: #d97757;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);

  --font-display: "Fraunces", "Songti SC", "Noto Serif SC", Georgia, serif;
  --font-ui: "Geist", -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, #2a1f15 0%, transparent 60%),
    radial-gradient(800px 400px at 100% 100%, #1f1812 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.85  0 0 0 0 0.6  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  z-index: 0;
}

.screen {
  position: relative; z-index: 1;
  width: 100vw; height: 100vh;
  height: 100dvh;
}

.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }

/* ─────────── 登录页（不变） ─────────── */
.login { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(440px, 100%);
  padding: 36px 36px 28px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber-soft) 50%, transparent);
  opacity: 0.4;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px; letter-spacing: 0.02em;
  color: var(--text-dim); margin-bottom: 28px;
}
.brand-mark { color: var(--amber); font-size: 18px; animation: spin 8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-card h1 {
  font-family: var(--font-display);
  font-weight: 400; font-size: 38px; line-height: 1.1;
  margin: 0 0 10px;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  letter-spacing: -0.02em;
}
.login-card .sub { margin: 0 0 28px; color: var(--text-dim); font-size: 14.5px; line-height: 1.5; }
#login-form { display: grid; gap: 14px; }
#login-form label { display: grid; gap: 6px; }
#login-form label > span {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-family: var(--font-mono);
}
#login-form input {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--text); padding: 12px 14px;
  border-radius: 10px; font-size: 15px;
  font-family: var(--font-mono);
  transition: border-color 0.2s, background 0.2s;
}
#login-form input:focus { outline: none; border-color: var(--amber); background: var(--surface); }
.btn-primary {
  margin-top: 8px;
  background: var(--amber); color: #15110d;
  border: none; padding: 13px 16px;
  border-radius: 10px; font-weight: 600; font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px -8px rgba(232, 165, 71, 0.5);
}
.btn-primary:hover { background: var(--amber-soft); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.recent { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.recent-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-family: var(--font-mono);
  display: block; margin-bottom: 10px;
}
#recent-list { display: flex; flex-wrap: wrap; gap: 6px; }
.recent-pill {
  background: var(--bg); border: 1px solid var(--line);
  color: var(--text-dim); padding: 6px 12px;
  border-radius: 999px; font-family: var(--font-mono);
  font-size: 12.5px; cursor: pointer; transition: all 0.15s;
}
.recent-pill:hover { border-color: var(--amber); color: var(--text); }
.footnote { margin: 24px 0 0; font-size: 12px; color: var(--muted); text-align: center; font-family: var(--font-mono); }

/* ─────────── 房间页（新布局） ─────────── */
/* 默认（无共享）：左用户列表 + 右聊天大版面 */
.room {
  display: grid;
  grid-template-areas:
    "topbar topbar"
    "users  chat"
    "ctrl   ctrl";
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 260px 1fr;
  gap: 0;
}

/* 共享时：左用户 + 中舞台 + 右聊天 */
body.sharing-active .room {
  grid-template-areas:
    "topbar topbar topbar"
    "users  stage  chat"
    "ctrl   ctrl   ctrl";
  grid-template-columns: 260px 1fr 340px;
}

/* stage 默认隐藏，只在共享时出现 */
.stage {
  grid-area: stage;
  display: none;
  padding: 20px;
  overflow: hidden;
}
body.sharing-active .stage { display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .room {
    grid-template-areas:
      "topbar"
      "users"
      "chat"
      "ctrl";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  body.sharing-active .room {
    grid-template-areas:
      "topbar"
      "stage"
      "chat"
      "ctrl";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  body.sharing-active .users-panel { display: none; }
  .users-panel { max-height: 35vh; }
}

.topbar {
  grid-area: topbar;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 17, 13, 0.7);
  backdrop-filter: blur(12px);
}
.room-meta { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live {
  background: var(--sage);
  box-shadow: 0 0 0 0 rgba(149, 193, 135, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(149, 193, 135, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(149, 193, 135, 0); }
  100% { box-shadow: 0 0 0 0 rgba(149, 193, 135, 0); }
}
.room-name { font-family: var(--font-display); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
#room-count { font-family: var(--font-mono); font-size: 12.5px; }
.me { display: flex; align-items: center; gap: 14px; }
.me .userid {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 4px 10px; border-radius: 6px;
  font-size: 13px; color: var(--amber-soft);
  border: 1px solid var(--line);
}
.btn-ghost {
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); padding: 7px 14px;
  border-radius: 8px; font-size: 13px; transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-ghost.danger:hover { background: rgba(217, 119, 87, 0.15); color: var(--coral); border-color: var(--coral); }

/* ─────────── 用户列表面板 ─────────── */
.users-panel {
  grid-area: users;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.users-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.user-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s, box-shadow 0.2s;
}
.user-item:hover { background: rgba(255, 255, 255, 0.03); }
.user-item.speaking {
  background: rgba(149, 193, 135, 0.08);
  box-shadow: inset 2px 0 0 var(--sage);
}

.user-avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 15px; font-weight: 500;
  color: #15110d;
  letter-spacing: -0.02em;
}

.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-item.self .user-name { color: var(--amber-soft); }
.user-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.tag.admin { background: var(--amber); color: #15110d; font-weight: 600; }
.tag.silenced { background: rgba(217, 119, 87, 0.2); color: var(--coral); border: 1px solid var(--coral); }

.badges {
  display: flex; gap: 4px;
  flex: 0 0 auto;
}
.badge {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.4);
  display: grid; place-items: center;
  color: var(--coral);
}
.badge svg { width: 11px; height: 11px; }
.badge.share { color: var(--amber); }

.user-menu-btn {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  transition: all 0.15s;
}
.user-item:hover .user-menu-btn { border-color: var(--line); color: var(--text-dim); }
.user-menu-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--amber) !important; }

.user-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow);
  min-width: 150px;
  display: flex;
  flex-direction: column;
}
.user-menu button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.12s;
}
.user-menu button:hover { background: var(--surface-2); }
.user-menu button.danger { color: var(--coral); }
.user-menu button.danger:hover { background: rgba(217, 119, 87, 0.15); }

/* 管理员面板 */
.admin-panel {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(232, 165, 71, 0.04);
}
.admin-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--amber-soft);
}
.admin-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-family: var(--font-ui);
  text-align: left;
  transition: all 0.15s;
}
.admin-btn:hover {
  border-color: var(--amber);
  color: var(--text);
  background: rgba(232, 165, 71, 0.06);
}

/* ─────────── 共享舞台 ─────────── */
.spotlight {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.spotlight video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.spotlight-label {
  position: absolute;
  bottom: 14px; left: 14px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--amber-soft);
}
.spotlight-label span { color: var(--text); margin-right: 4px; }
.spotlight-btn {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  display: grid; place-items: center;
  transition: all 0.15s;
}
.spotlight-btn:hover { background: rgba(0,0,0,0.85); border-color: var(--amber); }
#spotlight-video:fullscreen { width: 100vw; height: 100vh; object-fit: contain; background: #000; }

/* ─────────── 聊天面板 ─────────── */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}
.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.chat-msg .who {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber-soft);
  font-weight: 500;
}
.chat-msg .when {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.chat-msg .chat-body {
  color: var(--text);
}
.chat-msg.system {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.chat-msg.mine .who { color: var(--sage); }

.chat-img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  display: block;
  background: var(--surface);
}
.chat-img:hover { border-color: var(--amber); }

.chat-input {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-input input[type="text"] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  min-width: 0;
}
.chat-input input[type="text"]:focus {
  outline: none;
  border-color: var(--amber);
}
.chat-icon-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 8px;
  display: grid; place-items: center;
  transition: all 0.15s;
}
.chat-icon-btn svg { width: 18px; height: 18px; }
.chat-icon-btn:hover { color: var(--amber); border-color: var(--amber); background: var(--surface-2); }

/* 图片放大查看 */
.img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 500;
  display: grid;
  place-items: center;
  cursor: zoom-out;
  animation: viewer-in 0.2s ease-out;
}
@keyframes viewer-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.img-viewer img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.img-viewer-close {
  position: absolute;
  top: 22px; right: 28px;
  width: 38px; height: 38px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
}

/* ─────────── 底部控制 ─────────── */
.controls {
  grid-area: ctrl;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: rgba(21, 17, 13, 0.85);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.ctrl {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 12px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.ctrl svg { width: 18px; height: 18px; }
.ctrl:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.ctrl.active { background: var(--amber); color: #15110d; border-color: var(--amber); }
.ctrl.active:hover { background: var(--amber-soft); }
.ctrl.danger-active {
  background: rgba(217, 119, 87, 0.15);
  color: var(--coral);
  border-color: var(--coral);
}

/* ─────────── 提示 ─────────── */
.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--amber);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90vw;
  animation: toast-in 0.25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

audio { display: none; }
[hidden] { display: none !important; }

/* 语言切换 */
.lang-switch {
  margin-top: 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.lang-switch button {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}
.lang-switch button:hover { color: var(--text-dim); }
.lang-switch button.active { color: var(--amber-soft); }