:root {
  --bg: #0B0B0C;
  --panel: #131315;
  --panel-2: #17171A;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .2);
  --fg: #E9E9EA;
  --fg-2: #9EA0A6;
  --fg-3: #74757C;
  --ok: #5DCAA5;
  --warn: #EF9F27;
  --bad: #F09595;
  --r: 6px;
  --r-lg: 10px;      /* 只给 880 外壳这类大容器用，控件一律 --r */

  /* 字号阶梯：全站只允许这 5 档正文级 + hero/数字两个展示档 */
  --fs-xs: 11px;     /* 标签、徽标、大写字距小标题 */
  --fs-sm: 12px;     /* 辅助信息、次要说明 */
  --fs-md: 13px;     /* 次要正文、次级按钮 */
  --fs-base: 14px;   /* 正文、消息、主按钮 */
  --fs-lg: 20px;     /* 页面/弹窗标题 */

  /* 控件高度：主 40 / 次 32 / 小 28，别再发明新高度 */
  --h-ctl: 40px;
  --h-ctl-sm: 32px;
  --h-ctl-xs: 28px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
a { color: inherit; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */

.bar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .04em;
}

.dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ok);
  margin-left: 7px;
  vertical-align: 2px;
}

.meta { font-size: 12px; color: var(--fg-3); }
.meta b { color: var(--fg-2); font-weight: 400; }

/* ---------- 视图切换 ---------- */

.stage { flex: 1; min-height: 0; display: flex; }
.view { display: none; flex: 1; min-height: 0; flex-direction: column; position: relative; }
.view.on { display: flex; }

/* ---------- 首页 ---------- */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-bottom: 40px;
}

.hero h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.3;
}

/* 规则说明：去卡片壳，纯文字居中，靠字号和颜色分层，不再做一个灰盒子 */
.rules {
  margin: 36px 0 0;
  padding: 0;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.rules-h {
  margin-bottom: 10px;
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  color: var(--fg-3);
}

.rules ul {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg-3);
  font-size: var(--fs-md);
  line-height: 1.9;
}

.rules li { margin: 0; }

.agree {
  margin: 22px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
}

.agree input { accent-color: var(--fg); margin: 0; }

.start {
  margin: 14px 0 0;
  width: 100%;
  max-width: 400px;
  height: 44px;
  font-size: 15px;
}

/* ---------- 资料页 ---------- */

.form {
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  margin: auto;
  padding: 40px 0;
  overflow-y: auto;
}

.form h2 { margin: 0 0 8px; font-size: 20px; font-weight: 500; }
.form .lead { margin: 0 0 28px; font-size: 13px; color: var(--fg-2); }

.field { margin-bottom: 24px; }
.field label { display: block; font-size: 12px; color: var(--fg-3); margin-bottom: 8px; }

.field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--fg);
  outline: none;
}

.field input:focus { border-color: var(--line-2); }
.field input::placeholder { color: var(--fg-3); }

.hint { min-height: 16px; margin-top: 6px; font-size: 12px; color: var(--bad); }
.hint-soft { color: var(--fg-3); }

/* ---------- 年龄滑块 ---------- */

.agerow { display: flex; align-items: center; gap: 16px; }

.ageval {
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-width: 52px;
}
.ageval b {
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}
.ageval i { font-style: normal; font-size: 12px; color: var(--fg-3); }

.ageslider { flex: 1; min-width: 0; }

.field input.age-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: linear-gradient(to right,
    var(--fg) 0 calc(8px + (100% - 16px) * var(--r, 0)),
    var(--line-2) calc(8px + (100% - 16px) * var(--r, 0)) 100%);
  background-size: 100% 2px;
  background-position: 0 50%;
  background-repeat: no-repeat;
  outline: none;
  cursor: pointer;
  touch-action: pan-y;
}

.field input.age-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 4px;
  background: var(--fg);
  box-shadow: 0 0 0 4px rgba(11, 11, 12, .9);
  transition: transform .12s ease;
}
.field input.age-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 4px;
  background: var(--fg);
  box-shadow: 0 0 0 4px rgba(11, 11, 12, .9);
}
.field input.age-range::-moz-range-track { background: transparent; }

.field input.age-range:hover::-webkit-slider-thumb,
.field input.age-range:active::-webkit-slider-thumb { transform: scale(1.12); }
.field input.age-range:active::-webkit-slider-thumb { border-radius: 3px; }

.field input.age-range:focus-visible { outline: none; }
.field input.age-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(11, 11, 12, .9), 0 0 0 5px var(--line-2);
}

.agescale {
  display: flex;
  justify-content: space-between;
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.namerow { display: flex; align-items: center; gap: 8px; }
.namerow input { flex: 1; min-width: 0; letter-spacing: .02em; }
.namerow .ghost { flex: none; height: 40px; padding: 0 14px; }

/* 随机换一个昵称：输入框右侧的骰子按钮 */
.namerow .rand {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.namerow .rand:hover { color: var(--fg); border-color: var(--line-2); background: var(--panel-2); }
.namerow .rand:active { background: var(--panel); }
.namerow .rand:focus-visible { outline: none; border-color: var(--line-2); color: var(--fg); }
.namerow .rand svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.namerow .rand[hidden] { display: none; }

/* 昵称可用性提示：可用给绿、占用露红，检查中压低对比，别抢标题的注意力 */
.hint.namehint { color: var(--fg-3); }
.hint.namehint.is-ok { color: var(--ok); }
.hint.namehint.is-bad { color: var(--bad); }
.hint.namehint.is-dim { color: var(--fg-3); opacity: .75; }

.seg { display: flex; gap: 8px; }
.seg .ghost.sel { background: var(--fg); border-color: var(--fg); color: #0B0B0C; }

.form-acts { display: flex; gap: 8px; margin-top: 28px; }
.form-acts .solid { flex: 1; height: 40px; }
.form-acts .ghost { height: 40px; padding: 0 18px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.link {
  margin: 14px 0 0;
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  color: var(--fg-3);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover { color: var(--fg-2); }

.form-foot { margin-top: 20px; text-align: center; }

/* 顶栏账号入口 */

.acct-btn {
  max-width: 180px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: var(--fg-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s, border-color .15s;
}

.acct-btn:hover { color: var(--fg); border-color: var(--line-2); }
.acct-btn.on { color: var(--fg-2); }

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

.solid {
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--fg);
  border-radius: var(--r);
  background: var(--fg);
  color: #0B0B0C;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}

.solid:disabled { opacity: .3; cursor: not-allowed; }

.ghost {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
  transition: color .15s, border-color .15s;
}

.ghost:hover { color: var(--fg); border-color: var(--fg-2); }
.ghost.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.ghost:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 匹配中 ---------- */

.waiting {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

.pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  position: relative;
}

.pulse::before,
.pulse::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  animation: ripple 2s ease-out infinite;
}

.pulse::after { animation-delay: 1s; }

@keyframes ripple {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(2.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse::before, .pulse::after { animation: none; }
}

.waiting .txt { font-size: 13px; color: var(--fg-2); }

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

.chat-head {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.who .name { font-size: 14px; font-weight: 500; }
.who .sub { font-size: 12px; color: var(--fg-3); }
.acts { display: flex; gap: 6px; flex: none; }

.msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msgs::-webkit-scrollbar { width: 6px; }
.msgs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }

.empty {
  margin: auto;
  font-size: var(--fs-md);
  color: var(--fg-3);
  text-align: center;
}

.sys {
  align-self: center;
  font-size: 12px;
  color: var(--fg-3);
  padding: 2px 0;
}

.bubble {
  max-width: 78%;
  padding: 9px 14px;
  border-radius: var(--r);
  font-size: var(--fs-base);
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble.them {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
}

.bubble.me {
  align-self: flex-end;
  background: var(--fg);
  color: #0B0B0C;
  border: 1px solid var(--fg);
}

.typing {
  flex: none;
  height: 18px;
  font-size: 12px;
  color: var(--fg-3);
  opacity: 0;
  transition: opacity .15s;
}

.typing.on { opacity: 1; }

/* 对方暂时离线：一行细提示，不弹窗、不结束对话 */
.pnote {
  flex: none;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
  color: var(--fg-3);
}

.pnote[hidden] { display: none; }

.compose {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 14px 0 18px;
  border-top: 1px solid var(--line);
}

.compose input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--fg);
  outline: none;
}

.compose input:focus { border-color: var(--line-2); }
.compose input::placeholder { color: var(--fg-3); }
.compose[hidden] { display: none; }

/* 游客只读：占位高度与输入区一致，进来时布局不跳 */
.guestbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line);
}

.guestbar[hidden] { display: none; }

.guestbar .gtxt {
  font-size: 12px;
  color: var(--fg-3);
}

.guestline { padding: 0 0 10px; }

.report-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* display:flex 会吃掉 hidden 的默认表现，必须显式压住 */
.report-bar[hidden] { display: none; }

.report-bar .lbl { font-size: 12px; color: var(--fg-3); margin-right: 2px; }

.toast {
  position: absolute;   /* 相对 .app 卡片定位，桌面上不会掉到卡片外面 */
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel-2);
  font-size: 12px;
  color: var(--fg-2);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.toast.on { opacity: 1; }

/* ---------- 结束 / 封禁 ---------- */

.over {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.over h2 { margin: 0; font-size: 18px; font-weight: 500; }
.over p { margin: 0; font-size: 13px; color: var(--fg-2); }
.over .ghost { margin-top: 8px; height: 40px; padding: 0 18px; }

/* ---------- 管理后台 ---------- */

.admin { max-width: 1080px; }
.admin .bar .meta a { margin-left: 12px; color: var(--fg-2); text-decoration: none; }
.admin .bar .meta a:hover { color: var(--fg); }

.tokenbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--fg-3);
}

.tokenbar input {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--fg);
  outline: none;
  width: 220px;
}

.body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 0 32px; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  padding: 14px 16px;
}

.card .k { font-size: 12px; color: var(--fg-3); }
.card .v { font-size: 22px; font-weight: 500; margin-top: 4px; line-height: 1.2; }

.sec { margin-top: 28px; }

.sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.sec-h h3 { margin: 0; font-size: 14px; font-weight: 500; }
.sec-h .n { font-size: 12px; color: var(--fg-3); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 400;
  font-size: 12px;
  color: var(--fg-3);
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--fg-2); }
td.muted { color: var(--fg-2); }

.snap { color: var(--fg-3); font-size: 12px; line-height: 1.5; }
.snap div { margin: 2px 0; }

.row-empty { padding: 28px 8px; text-align: center; color: var(--fg-3); font-size: 12px; }

.tools { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.tools input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--fg);
  outline: none;
  width: 260px;
}

.tools input::placeholder { color: var(--fg-3); }

@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .tools input { width: 100%; }
}

/* ---------- 注册 / 登录弹窗 ---------- */

.modal {
  position: absolute;   /* 跟着 .app 卡片走 */
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 6, .74);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade .16s ease;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100% - 48px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .65);
  animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}

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

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-mask, .modal-card { animation: none; }
}

.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  transition: border-color .15s;
}

.modal-x::before,
.modal-x::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 1px;
  background: var(--fg-3);
  transition: background .15s;
}

.modal-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.modal-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.modal-x:hover { border-color: var(--line); }
.modal-x:hover::before, .modal-x:hover::after { background: var(--fg); }

.auth-head { padding-right: 26px; }
.auth-head h2 { margin: 0 0 7px; font-size: var(--fs-lg); font-weight: 500; letter-spacing: .01em; }
.auth-head p { margin: 0 0 20px; font-size: 12px; line-height: 1.7; color: var(--fg-3); }

.switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
}

.switch .sw {
  flex: 1;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-3);
  font-size: 12px;
  transition: background .15s, color .15s;
}

.switch .sw:hover { color: var(--fg-2); }
.switch .sw.on { background: var(--fg); color: #0B0B0C; font-weight: 500; }

.modal-card .field { margin-bottom: 16px; }
.modal-card .field label { margin-bottom: 6px; }
.modal-card .field input { height: 38px; }
.modal-card .hint { min-height: 14px; margin-top: 4px; }
.modal-card .agerow { gap: 14px; }
.modal-card .ageval b { font-size: 24px; }

.auth-submit { width: 100%; height: 40px; margin-top: 4px; }

.only-register[hidden] { display: none; }

/* ---------- 首页：匹配偏好 ---------- */

.prefblock {
  width: 100%;
  max-width: 400px;
  margin-top: 26px;
}

.seg.wide { gap: 8px; }
.seg.wide .ghost { flex: 1; height: 44px; font-size: var(--fs-base); }

/* ---------- 公共聊天室 ---------- */

/* 大厅消息：昵称在上，气泡在下；复用 1v1 的 .bubble 左右样式 */
.lmsg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 78%;
}

/* ⛔ .bubble 自带 max-width:78%，但 .lmsg 的宽度又由内容（bubble）决定，
   形成「宽度看内容、max-width 又按父级算」的循环 —— 短消息会被随机挤成两行
   （复现：「诊断消息A」5 个字只给了 72px）。外层 .lmsg 已限 78%，这里放开内层。 */
.lmsg .bubble { max-width: 100%; }

.lmsg.them { align-self: flex-start; }
.lmsg.mine { align-self: flex-end; }
.lmsg .lwho { font-size: 11px; color: var(--fg-3); padding: 0 2px; }
.lmsg.mine .lwho { align-self: flex-end; }

/* ---------- 手机端底部导航 ---------- */

.tabbar { display: none; }

@media (max-width: 900px) {
  .tabbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    flex: none;
    min-height: 54px;
    padding-bottom: env(safe-area-inset-bottom);
    margin: 0 -20px;
    border-top: 1px solid var(--line);
    background: var(--bg);
  }

  .tabbar[hidden] { display: none; }

  .tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--fg-3);
    font-size: 11px;
    transition: color .15s;
  }

  .tabbar button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .tabbar button.on { color: var(--fg); }

  /* 资料页在 tab 结构里不需要「返回」，靠底栏切换 */
  [data-view="profile"] .form-acts .ghost { display: none; }
}

/* ---------- 聊天室：分栏外壳（宽屏左右两栏，窄屏两级切换） ---------- */

.roomsplit {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.roomside {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.roompane {
  flex: 1;
  min-height: 0;
  display: none;
}

.pane-blank {
  margin: auto;
  font-size: 12px;
  color: var(--fg-3);
  text-align: center;
}

.roomlive {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.roomlive[hidden] { display: none; }

/* 窄屏进房：左列表让位，右栏整屏（底栏由 syncTabs 收起） */
.roomsplit.in-room .roomside { display: none; }
.roomsplit.in-room .roompane { display: flex; }

/* ---------- 应用外壳：手机全屏，桌面居中卡片 + 左侧竖排导航 ---------- */

.app {
  position: relative;          /* toast / modal 的定位基准 */
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

/* 卡片里这份 wrap 交给 flex 撑满，不再自己声明整屏高度 */
.app > .wrap {
  height: auto;
  flex: 1;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
}

.rail { display: none; }

@media (min-width: 901px) {
  body.shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    background: #060607;
  }

  body.shell .app {
    width: 100%;
    max-width: 880px;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    max-height: 820px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--bg);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  }

  .rail {
    flex: none;
    width: 74px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 0 16px;
    border-right: 1px solid var(--line);
    background: var(--panel);
  }

  .rail button {
    width: 58px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--r);
    background: transparent;
    color: var(--fg-3);
    font-size: 11px;
    transition: color .15s, background .15s, border-color .15s, opacity .15s;
  }

  .rail button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  .rail button:hover { color: var(--fg-2); }
  .rail button.on { color: var(--fg); background: var(--panel-2); border-color: var(--line); }

  /* 导航常驻：排队 / 1v1 / 房间内都保持可见可点，匹配在服务端继续跑 */

  /* 聊天室：列表 | 聊天 左右两栏（窄屏那套「进房让位」在这里要失效）
     负 margin 抵消 .wrap 的 20px 内边距，让分栏贴满卡片两侧，
     否则中缝分割线悬空、左右各挂一条空白，像卡中卡 */
  .roomsplit {
    margin: 0 -20px;
    flex-direction: row;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .roomside {
    min-width: 0;
    padding-left: 14px;
    border-right: 1px solid var(--line);
  }

  .roomside .chat-head { padding-right: 14px; }
  .roomside .guestline { margin-right: 14px; }

  /* 列表改成会话行：去掉卡片边框，靠 hover / 当前房高亮区分，
     248px 窄列里放卡片会挤到换行 */
  .roomside .roomlist { padding: 8px 10px 12px 6px; }

  .roomside .roomitem {
    margin: 0 0 2px;
    padding: 9px 10px;
    border-color: transparent;
    background: transparent;
  }

  .roomside .roomitem:hover { background: var(--panel-2); border-color: transparent; }
  .roomside .roomitem.on { background: var(--panel-2); border-color: var(--line); }
  .roomside .pinsticky .roomitem { border-color: transparent; }

  .roompane { display: flex; min-width: 0; }
  .roompane .chat-head { padding: 0 18px; }
  .roompane .msgs { padding-left: 18px; padding-right: 18px; }
  .roompane .compose { padding-left: 18px; padding-right: 18px; }
  .roompane .guestbar { padding-left: 18px; padding-right: 18px; }
  .roomsplit.in-room .roomside { display: flex; }

  /* 两栏时左列表随时可点，不需要「返回」 */
  #btn-room-back { display: none; }
}

/* ---------- 聊天室：房间列表 ---------- */

.roomlist {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.roomlist::-webkit-scrollbar { width: 6px; }
.roomlist::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }

.roomitem {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  text-align: left;
  color: inherit;
  transition: background .15s, border-color .15s;
}

.roomitem:hover { background: var(--panel-2); border-color: var(--line-2); }

/* 当前在聊的那间：列表里亮一下，切房时能看出自己在哪 */
.roomitem.on { background: var(--panel-2); border-color: var(--line-2); }

/* 公共聊天室：整张卡钉在列表顶部，别人开的房间从它下面滚过去 */
.pinsticky {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 8px;
  background: var(--bg);
}
.pinsticky .roomitem { margin-bottom: 0; }
.pinsticky .roomitem { border-color: var(--line-2); }

.roomlist .rsep {
  padding: 0 2px 8px;
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: .04em;
}

.roomitem .rmain { flex: 1; min-width: 0; }

.roomitem .rname {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--fg);
}

/* 名字本体可截断，后面的标签（置顶/公开/密码）不许被挤换行 */
.roomitem .rname-t {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.roomitem .rdesc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roomitem .rmeta {
  flex: none;
  font-size: 11px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.roomitem .rtag {
  flex: none;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-size: 10px;
  color: var(--fg-3);
  line-height: 1.4;
}

.roomlist .rmsg {
  margin: auto;
  padding: 40px 0;
  font-size: 12px;
  color: var(--fg-3);
  text-align: center;
}

/* ---------- 条款 / 隐私页 ---------- */

.doc {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0 48px;
}

.doc h1 {
  margin: 20px 0 6px;
  font-size: var(--fs-lg);
  font-weight: 500;
}

.doc .doc-sub {
  margin: 0 0 26px;
  font-size: 12px;
  color: var(--fg-3);
}

.doc h2 {
  margin: 26px 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

.doc p,
.doc li {
  font-size: 13px;
  line-height: 1.75;
  color: var(--fg-2);
}

.doc p { margin: 8px 0; }
.doc ul { margin: 8px 0; padding-left: 18px; }
.doc li { margin: 4px 0; }
.doc b { color: var(--fg); font-weight: 500; }

.doc .doc-back {
  display: inline-block;
  margin-top: 32px;
  font-size: 13px;
  color: var(--fg-2);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
}

/* ---------- 首页页脚（协议入口 + 备案号） ---------- */

.foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  padding: 14px 0 18px;
  font-size: 11px;
  color: var(--fg-3);
  border-top: 1px solid var(--line);
}

.foot a {
  color: var(--fg-3);
  text-decoration: none;
}

.foot a:hover { color: var(--fg-2); }
.foot .sep { color: var(--line-2); }
.foot [hidden] { display: none; }

@media (max-width: 720px) {
  /* 管理后台表格在窄屏改为横向滚动，不挤爆卡片布局 */
  .sec { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sec table { min-width: 560px; }
  .tokenbar { flex-wrap: wrap; }
  .tokenbar input { flex: 1; min-width: 0; width: auto; }
}

/* ---------- 手机端表单适配 ---------- */

@media (max-width: 900px) {
  /* ⛔ iOS Safari：输入框字号 < 16px 时聚焦会强制放大页面。手机端输入类一律 16px */
  input:not([type="range"]):not([type="checkbox"]),
  textarea,
  select {
    font-size: 16px;
  }

  /* 注册弹窗收紧节奏，844 高内放下全部字段，不出滚动条 */
  .modal { padding: 12px; }
  .modal-card {
    max-height: calc(100% - 24px);
    padding: 18px 16px 16px;
  }
  .auth-head p { margin-bottom: 14px; }
  .switch { margin-bottom: 16px; }
  #auth-form .field { margin-bottom: 16px; }
  #auth-form .hint { margin-top: 4px; }
  .agescale { display: none; }   /* 滑块两端的 18/99 刻度在手机上省掉 */
}
