/* =============================================================
   临时聊天室 — 设计系统：极简暗色（Minimalism & Swiss Style）
   暗色为默认；浅色仅跟随系统偏好（prefers-color-scheme: light）
   ============================================================= */

:root {
  color-scheme: dark;
  /* 表面层级：bg < surface < surface-2 < surface-3 */
  --bg: #090d16;
  --surface: #121824;
  --surface-2: #1a2233;
  --surface-3: #222d42;
  --header-bg: rgba(18, 24, 36, 0.82);
  /* 文本 */
  --text: #f1f5f9;
  --muted: #94a3b8;
  /* 描边 */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  /* 强调色（Messenger 蓝 + 渐变） */
  --accent: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --accent-strong: #2563eb;
  --accent-bright: #60a5fa;
  --on-accent: #ffffff;
  --accent-soft: rgba(59, 130, 246, 0.18);
  /* 气泡色 */
  --mine: #1e3a8a;
  --mine-gradient: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  --mine-text: #ffffff;
  /* 语义状态 */
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --danger-border: rgba(248, 113, 113, 0.45);
  --online: #10b981;
  --online-soft: rgba(16, 185, 129, 0.15);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.15);
  --scrim: rgba(4, 7, 14, 0.68);
  /* 空间与阴影 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.28);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.38);
  --shadow: var(--shadow-lg);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --kb-inset: 0px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --header-bg: rgba(255, 255, 255, 0.88);
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent: #2563eb;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --accent-strong: #1d4ed8;
    --accent-bright: #3b82f6;
    --on-accent: #ffffff;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --mine: #2563eb;
    --mine-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --mine-text: #ffffff;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.45);
    --online: #059669;
    --online-soft: rgba(5, 150, 105, 0.12);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, 0.12);
    --scrim: rgba(15, 23, 42, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.09);
    --shadow-xl: 0 20px 48px rgba(15, 23, 42, 0.12);
    --shadow: var(--shadow-lg);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  /* 整个页面不滚动也不橡皮筋：唯一能滚的是消息列表。
     否则 Android 的下拉刷新、iOS 的整页回弹都会打断聊天。 */
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.req {
  color: var(--danger);
  font-size: 12px;
}

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 13px;
}

.app {
  height: 100%;
  /* 支持时改用动态视口高度：移动端地址栏收起/展开时 100% 不跟随，会露出白边。
     再减去 --kb-inset，让软键盘弹出时输入框仍然贴在键盘上沿。
     两条 dvh 声明在旧浏览器上整体失效，自动退回上面的 100%。 */
  height: 100dvh;
  height: calc(100dvh - var(--kb-inset, 0px));
}

/* ------------------------------------------------------------- 视图容器 */

.view {
  height: 100%;
}

.view-center {
  display: flex;
  /* 竖向居中交给 .card 的 margin:auto。若用 align-items:center，内容一旦高于
     视口（横屏手机上的创建表单），顶部会被裁掉且永远滚不上去。 */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* 刘海 / 灵动岛 / 横屏侧边 / 底部横条都要避开 */
  padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px))
    calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 有富余空间时竖向居中；空间不够时归零，让 overflow-y 能滚到整个表单 */
  margin: auto 0;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}

.card > p {
  margin: 0 0 6px;
  font-size: 13px;
}

label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
}

input[type='text'],
input[type='password'],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input[type='checkbox']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 4px;
  line-height: 1.5;
}

.error {
  font-size: 13px;
  color: var(--danger);
  margin: 4px 0;
}

/* 表单里的勾选项：整行可点，触摸目标够大 */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.45;
}

.check-row input[type='checkbox'] {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 4px;
}

.owner-tools {
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn svg {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: 0 2px 8px var(--accent-soft), var(--shadow-sm);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 16px var(--accent-soft), var(--shadow-md);
}

.btn-primary:active {
  filter: brightness(0.96);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
  box-shadow: none;
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
  gap: 5px;
}

.btn-icon {
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 9px;
  box-shadow: none;
}

.btn-icon:hover {
  color: var(--accent-bright);
  background: var(--surface-2);
}

.btn-icon svg {
  display: block;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* -------------------------------------------------------------- 聊天室 */

.view-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* 顶部安全区：加到主屏幕 / 全屏时状态栏会盖住内容 */
  padding: calc(10px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px))
    10px calc(14px + env(safe-area-inset-left, 0px));
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.chat-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  cursor: pointer;
}

.chat-title strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 品牌圆点：聊天气泡意象，暗色下用亮蓝描一圈柔光 */
.chat-title strong::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  box-shadow: 0 0 0 3px var(--accent-soft);
  vertical-align: 1px;
}

.chat-title .muted {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge.is-online {
  color: var(--online);
  border-color: var(--online-soft);
  background: var(--online-soft);
}

.badge.is-warn {
  color: var(--warn);
  border-color: var(--warn-soft);
  background: var(--warn-soft);
}

/* -------------------------------------------------------------- 消息流 */

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 82%;
  align-self: flex-start;
  animation: msg-in 0.22s var(--ease);
}

.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-bottom: 2px;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.16s ease;
}

.msg-avatar:hover {
  transform: scale(1.08);
}

.msg-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.msg.mine .msg-main {
  align-items: flex-end;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px;
}

.msg-name {
  font-weight: 600;
  color: var(--text);
  font-size: 12.5px;
}

.msg.mine .msg-head {
  flex-direction: row-reverse;
}

.msg-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
  line-height: 1.55;
  font-size: 14.5px;
}

.msg.mine .msg-text {
  background: var(--mine-gradient);
  border-color: transparent;
  color: var(--mine-text);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
  box-shadow: 0 2px 10px var(--accent-soft);
}

.msg-image {
  display: block;
  line-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg-image:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}

.msg-image img {
  display: block;
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 15px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.msg-file:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.msg-file-icon {
  flex-shrink: 0;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.msg-file-name {
  font-weight: 500;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.msg-file-size {
  font-size: 11.5px;
  color: var(--muted);
}

.system {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

/* ------------------------------------------------------------ 发送中占位 */

.pending {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px 0;
  max-height: 200px;
  overflow-y: auto;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.chip-body {
  flex: 1 1 auto;
  min-width: 0;
}

.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 5px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.12s linear;
}

.chip-cancel {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
}

.file-input-hidden {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

/* -------------------------------------------------------------- 输入区 */

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px calc(14px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--border);
}

.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  max-height: min(160px, 32dvh);
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.composer .btn {
  flex-shrink: 0;
}

.composer textarea:focus {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.drop-hint {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--accent-bright);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 30;
  border: 3px dashed var(--accent);
}

/* ------------------------------------------------------------ 面板/浮层 */

.sheet {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  /* 同 .view-center：矮视口下面板可能比屏幕高，必须能滚而不是被裁 */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px))
    calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
  z-index: 40;
  animation: sheet-fade 0.18s ease;
}

@keyframes sheet-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sheet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 26px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: auto 0;
  animation: sheet-in 0.24s var(--ease);
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.sheet-card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sheet-card > p {
  margin: 0;
  font-size: 13px;
}

.share-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.share-row input {
  flex: 1 1 auto;
  font-size: 13px;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.sheet-actions .btn {
  flex: 1 1 auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px))
    calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
  z-index: 50;
}

.overlay .btn {
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-3);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-width: 90vw;
  text-align: center;
  animation: toast-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@media (max-width: 600px) {
  .view-chat {
    border-left: none;
    border-right: none;
  }

  .msg {
    max-width: 86%;
  }
}

/* -------------------------------------------------------------- 公共大厅 */

.view-hall {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.hall-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}

.hall-state {
  margin: 40px auto;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  max-width: 320px;
}

.hall-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hall-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.hall-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--accent-soft);
}

.hall-card.is-loading {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-md);
  pointer-events: none;
  cursor: wait;
}

.hall-list.has-loading .hall-card:not(.is-loading) {
  opacity: 0.55;
  pointer-events: none;
}

.hall-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hall-card-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
  min-width: 0;
}

.hall-card-loading {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 12px;
  font-weight: 600;
  flex: none;
  animation: card-badge-in 0.18s ease;
}

.hall-card.is-loading .hall-card-loading {
  display: inline-flex;
}

.spinner {
  width: 13px;
  height: 13px;
  animation: spin 0.8s linear infinite;
  flex: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes card-badge-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.hall-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.hall-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--online-soft);
  color: var(--online);
  font-size: 11.5px;
  font-weight: 600;
  flex: none;
}

.hall-card-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.hall-pager {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px calc(14px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--border);
}

.hall-pager .muted {
  font-size: 12px;
  text-align: center;
  flex: 1 1 auto;
}

@media (max-width: 600px) {
  .view-hall {
    border-left: none;
    border-right: none;
  }
}

/* ------------------------------------------------------------ 桌面滚动条 */

.messages::-webkit-scrollbar,
.view-center::-webkit-scrollbar,
.hall-body::-webkit-scrollbar,
.sheet::-webkit-scrollbar,
.overlay::-webkit-scrollbar,
.composer textarea::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.messages::-webkit-scrollbar-thumb,
.view-center::-webkit-scrollbar-thumb,
.hall-body::-webkit-scrollbar-thumb,
.sheet::-webkit-scrollbar-thumb,
.overlay::-webkit-scrollbar-thumb,
.composer textarea::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-track,
.view-center::-webkit-scrollbar-track,
.hall-body::-webkit-scrollbar-track,
.sheet::-webkit-scrollbar-track,
.overlay::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------------------------------------- 触摸设备适配 */

@media (pointer: coarse) {
  /* iOS Safari 聚焦 font-size < 16px 的输入框时会自动放大整个页面，而且不会缩回来。
     输入框（含只读的分享链接框）一律提到 16px 规避。 */
  input[type='text'],
  input[type='password'],
  textarea,
  .share-row input {
    font-size: 16px;
  }

  /* 触摸目标不小于 44px（Apple HIG 与 Material 的共同建议值）。
     只撑开点击区域，字号不动，视觉上不会变臃肿。 */
  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  .btn-small {
    padding: 10px 14px;
  }

  /* 顶栏操作区空间敏感，在触摸设备上保持紧凑，避免挤压房间标题 */
  .chat-header .chat-actions .btn-small {
    padding: 6px 10px;
    min-height: 36px;
  }

  .btn-icon {
    min-width: 44px;
  }

  .chip-cancel {
    min-width: 44px;
    min-height: 44px;
  }

  .msg-image,
  .msg-file {
    touch-action: manipulation;
  }

  /* 手指没有悬停，粘住的 :hover 只会让人困惑，改用按下反馈 */
  .btn:hover {
    background: var(--surface);
    border-color: var(--border);
  }

  .btn:active {
    background: var(--surface-2);
  }

  .btn-primary:hover,
  .btn-primary:active {
    background: var(--accent);
    border-color: var(--accent);
  }

  .btn-primary:active {
    filter: brightness(0.88);
  }

  .btn-danger:hover {
    background: transparent;
    border-color: var(--danger-border);
  }

  .msg-file:hover {
    border-color: var(--border);
  }
}

/* 横屏手机竖向空间极紧（iPhone 横屏只有 ~390px），压缩所有非内容元素 */
@media (orientation: landscape) and (max-height: 480px) {
  .chat-header {
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
  }

  /* 房间号与身份信息在横屏下让位给消息区 */
  .chat-title .muted {
    display: none;
  }

  .view-chat {
    max-width: none;
  }

  .msg-image img {
    max-height: 52dvh;
  }

  .toast {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* -------------------------------------------------------- 移动端顶栏适配 */

@media (max-width: 600px) {
  .chat-header {
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px))
      8px calc(10px + env(safe-area-inset-left, 0px));
    gap: 8px;
  }

  .chat-title strong {
    font-size: 14px;
  }

  /* 移动端允许顶部详情换行展示两行，彻底避免房号、昵称、身份和在房人数被截断 */
  .chat-title .muted {
    font-size: 11.5px;
    line-height: 1.35;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .chat-header .chat-actions {
    gap: 4px;
  }

  .chat-header .chat-actions .btn-small {
    padding: 5px 8px;
    min-height: 34px;
    font-size: 12px;
    gap: 4px;
  }

  .chat-header .badge {
    padding: 2px 7px;
    font-size: 11px;
  }
}

@media (max-width: 440px) {
  .chat-header {
    padding: calc(6px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px))
      6px calc(8px + env(safe-area-inset-left, 0px));
    gap: 6px;
  }

  /* 窄屏手机下，"更多" 按钮隐藏文字仅留三点图标，释放宝贵的横向宽度给房间信息 */
  #btn-menu span {
    display: none;
  }

  #btn-menu {
    padding: 5px 7px;
    min-width: 32px;
    justify-content: center;
  }

  .chat-title strong {
    font-size: 13.5px;
  }

  .chat-title .muted {
    font-size: 11px;
  }

  .composer {
    padding: 8px calc(8px + env(safe-area-inset-right, 0px))
      calc(8px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
    gap: 6px;
  }

  .composer .btn-icon {
    padding: 7px 8px;
  }

  #btn-send {
    padding: 8px 12px;
  }
}

/* ------------------------------------------------------ 无障碍：减少动效 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
