/* ============================================================
   Space Local — quiet chat room
   ============================================================ */

:root {
  --bg: #0a0a0c;
  --bg-elev: #101014;
  --panel: #0d0d10;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.22);
  --line-soft: rgba(255, 255, 255, 0.05);
  --ink: #ecebe6;
  --ink-2: #a5a29c;
  --ink-3: #6d6a65;
  --accent: #d8b78c;
  --accent-2: #efd9b9;
  --accent-dim: rgba(216, 183, 140, 0.13);
  --ok: #86b892;
  --danger: #e07a6c;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f5f3ee;
  --bg-elev: #fffdf9;
  --panel: #fbf9f4;
  --line: rgba(28, 25, 20, 0.14);
  --line-strong: rgba(28, 25, 20, 0.3);
  --line-soft: rgba(28, 25, 20, 0.07);
  --ink: #1b1916;
  --ink-2: #57534b;
  --ink-3: #8a857a;
  --accent: #966f3c;
  --accent-2: #7a5730;
  --accent-dim: rgba(150, 111, 60, 0.1);
  --ok: #4d7c5b;
  --danger: #b3483a;
  --shadow: 0 24px 60px -34px rgba(60, 50, 35, 0.45);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* hidden 属性要能压过下面那些 display:flex 的浮层 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.88em; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ---------------------------- 通用小件 ---------------------------- */
.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tiny { font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; }
.tiny-btn { border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; color: var(--ink-2); }
.tiny-btn:hover { border-color: var(--accent); color: var(--accent); }

.icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
  color: var(--ink-2);
  transition: 0.18s;
  flex: none;
}
.icon:hover { background: var(--line-soft); color: var(--ink); }

.ghost { background: none; border: none; }

.primary {
  width: 100%;
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 11px;
  background: var(--accent);
  color: #12100c;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: space-between;
  transition: 0.2s;
}
.primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.primary:disabled { opacity: 0.5; transform: none; cursor: default; }
.primary span { font-size: 16px; }

.link {
  background: none; border: none; padding: 0;
  font-size: 12.5px; color: var(--ink-3);
  text-align: left;
}
.link:hover { color: var(--ink); }
.link.danger:hover { color: var(--danger); }

.mini {
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; color: var(--ink-2);
}
.mini:hover { border-color: var(--accent); color: var(--accent); }

/* ============================ 落地页 ============================ */
.landing {
  position: relative;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0 40px;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.glow-a {
  width: 620px; height: 620px;
  top: -240px; left: -160px;
  background: radial-gradient(circle, rgba(216, 183, 140, 0.17), transparent 68%);
  animation: drift 26s ease-in-out infinite alternate;
}
.glow-b {
  width: 520px; height: 520px;
  bottom: -220px; right: -120px;
  background: radial-gradient(circle, rgba(120, 140, 170, 0.13), transparent 70%);
  animation: drift 32s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(50px, 40px, 0) scale(1.12); }
}

.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 0 0;
  max-width: 1080px; width: 100%; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.3em;
  color: var(--ink-2);
}
.brand b { color: var(--accent); font-weight: 500; }
.ring {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.landing-main {
  position: relative; z-index: 2;
  max-width: 1080px; width: 100%; margin: 0 auto;
  padding: 58px 0 40px;
  flex: 1;
}

.landing-main h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 5.4vw, 66px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 20px 0 0;
}
.landing-main h1 em {
  font-style: italic;
  color: var(--accent);
  font-size: 0.82em;
}

.lede {
  margin: 22px 0 0;
  max-width: 540px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.85;
}

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 46px;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--bg-elev), transparent 130%);
  padding: 26px 26px 22px;
  transition: 0.28s;
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(400px 160px at 20% 0%, var(--accent-dim), transparent 70%);
  opacity: 0;
  transition: 0.3s;
  pointer-events: none;
}
.card:hover { border-color: rgba(216, 183, 140, 0.3); transform: translateY(-2px); }
.card:hover::after { opacity: 1; }

.card-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
}
.card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 27px;
  margin: 8px 0 20px;
  letter-spacing: 0.01em;
}
.card label {
  display: block;
  margin-bottom: 14px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
  font-family: var(--mono);
}
.card input, .card textarea {
  width: 100%;
  margin-top: 7px;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}
.card input::placeholder, .card textarea::placeholder { color: var(--ink-3); opacity: 0.75; }
.card input:focus, .card textarea:focus { border-color: var(--accent); }

.card-note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

/* 可选字段（身份码）：标签下面挂一行小字说明，别把表单撑得太吓人 */
.card label.field-opt span {
  display: block;
  margin-top: 5px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  opacity: 0.85;
}

#last-room-note {
  margin: 0 0 16px;
  padding: 9px 11px;
  border: 1px solid rgba(216, 183, 140, 0.28);
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.6;
  text-transform: none;
  letter-spacing: 0;
}

.facts {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 46px 0 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
}
.facts li {
  padding: 18px 20px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
}
.facts b {
  display: block;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 12.5px;
  margin-bottom: 3px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.landing-foot {
  position: relative; z-index: 2;
  max-width: 1080px; width: 100%; margin: 0 auto;
  padding: 24px 0 30px;
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 12px; align-items: center;
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.landing-foot code { text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.landing-foot .sep { opacity: 0.4; }

/* ============================= 房间 ============================= */
.room {
  /* 钉死在视口上：哪怕文档被滚动了、或者 dvh 在某些环境里算得比窗口高，
     房间本身也不会被顶出去（之前用 height:100dvh 就是这个隐患）。 */
  position: fixed;
  inset: 0;
  display: grid;
  /* minmax(0,1fr)：1fr 的默认最小尺寸是 min-content，遇到长串英文/路径/代码块
     会把整列撑出窗口，表现为"左栏被挤窄 + 中间一大片空白"，右侧还看不全。 */
  grid-template-columns: 286px minmax(0, 1fr);
  grid-template-rows: 100%;
  min-height: 0;
  overflow: hidden;
}

.rail {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* 左栏整体固定：整栏永不滚动。
     以前这里是 overflow-y:auto —— 滚轮一旦落在左栏（或滚动链从消息区传过来），
     标题 / 邀请按钮 / 底部按钮会被滚出视口，看起来就是"左栏跟着右边一起滚"。
     现在只有成员列表和 agent 列表在自己内部滚，骨架永远不动。 */
  overflow: hidden;
  overscroll-behavior: contain;
  min-height: 0;
  height: 100%;
  position: relative;
  z-index: 2;
}

/* 头部、按钮、底部永远不被压缩、不被滚走 */
.rail-head,
.rail-actions,
.rail-foot { flex: 0 0 auto; }

/* 两个列表区块：占剩余空间，内部自己滚 */
.rail-section { flex: 0 1 auto; min-height: 0; }
.rail-section > ul {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rail-section > ul::-webkit-scrollbar { width: 6px; }
.rail-section > ul::-webkit-scrollbar-thumb { border-width: 2px; }

/* 矮窗口（笔记本 / 分屏）压紧间距，保证一屏放得下 */
@media (max-height: 860px) {
  .rail { padding: 18px 16px 12px; gap: 14px; }
  .rail-head h2 { font-size: 21px; margin: 6px 0 3px; }
  .rail-foot { padding-top: 12px; gap: 6px; }
  .member, .bot-row { padding: 5px 8px; }
}

.rail-head h2 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  line-height: 1.25;
  margin: 8px 0 4px;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.rail-meta { margin: 0; font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }

.rail-actions { display: flex; gap: 8px; }
.rail-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--ink-2);
  background: transparent;
  transition: 0.18s;
  display: inline-flex; align-items: center; gap: 8px;
  justify-content: center;
}
.rail-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.rail-btn.accent { flex: 1; border-color: rgba(216, 183, 140, 0.4); color: var(--accent); }
.rail-btn.accent:hover { background: var(--accent-dim); }
.rail-actions .rail-btn:not(.accent) { width: 38px; padding: 9px 0; }

.rail-section { display: flex; flex-direction: column; gap: 10px; }
.rail-label {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.2em;
  color: var(--ink-3);
}
.rail-label span { color: var(--ink-2); letter-spacing: 0; }
.rail-label.agents { justify-content: space-between; }

.member-list, .bot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.member, .bot-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  transition: 0.15s;
}
.member:hover, .bot-row:hover { background: var(--line-soft); color: var(--ink); }
.member .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3); opacity: 0.5; flex: none;
}
.member .dot.on { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px rgba(134, 184, 146, 0.13); }
.member .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .role { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; color: var(--ink-3); }

.bot-row { cursor: pointer; }
.bot-row .emoji { font-size: 15px; line-height: 1; }
.bot-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-row .prov {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em;
  color: var(--ink-3); border: 1px solid var(--line-soft);
  padding: 1px 5px; border-radius: 4px; text-transform: uppercase;
}
.bot-row .warn { color: var(--danger); font-size: 11px; }
.rail-empty { margin: 0; font-size: 11.5px; line-height: 1.7; color: var(--ink-3); padding: 2px 8px; }

.rail-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 9px;
}

/* ---------------------------- 对话区 ---------------------------- */
.convo {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.convo-head {
  height: 60px;
  flex: none;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.convo-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.convo-title span {
  font-size: 14px; color: var(--ink); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo-title small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ink-3); }

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 26px 22px 8px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.messages > * { max-width: min(780px, 100%); margin-left: auto; margin-right: auto; }

/* 大屏（窗口拉宽/最大化）时把正文列和输入框一起放宽，否则整块会变成中间一条细带 */
@media (min-width: 1500px) {
  .messages > *, .composer-row, .composer-hint, .attach-strip { max-width: 940px; }
}

.empty-state {
  text-align: center;
  padding: 70px 20px 40px;
  color: var(--ink-3);
}
.empty-mark { font-size: 30px; color: var(--accent); opacity: 0.7; }
.empty-state h3 {
  font-family: var(--serif); font-weight: 400; font-size: 22px;
  color: var(--ink-2); margin: 12px 0 8px;
}
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; line-height: 1.8; }
.empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.empty-actions .rail-btn.accent { flex: none; }

/* ---------------------------- 消息 ---------------------------- */
.msg {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 10px;
  animation: rise 0.28s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg:hover { background: var(--line-soft); }
.msg.grouped { padding-top: 1px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  flex: none;
  user-select: none;
}
.msg.bot .avatar {
  border-color: rgba(216, 183, 140, 0.42);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(216, 183, 140, 0.05);
}
.msg.grouped .avatar { opacity: 0; }
.msg.grouped .msg-head { display: none; }

.msg-body { min-width: 0; }
.msg-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.msg-name { font-size: 13px; font-weight: 600; color: var(--ink); letter-spacing: 0.01em; }
.msg.bot .msg-name { color: var(--accent); }
.msg-time { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.04em; }
.chip {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em;
  padding: 1px 5px; border-radius: 4px;
  border: 1px solid currentColor; color: var(--accent);
  text-transform: uppercase; opacity: 0.8;
}
.chip.demo { color: var(--ink-3); }

.msg-text {
  font-size: var(--chat-size, 14.5px);
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-text strong { font-weight: 600; }
.msg-text em { font-style: italic; color: var(--ink-2); }
.msg-text code {
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  padding: 1px 5px; border-radius: 5px;
  font-size: 0.86em;
}
.msg-text pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
  line-height: 1.6;
}
.msg-text pre code { background: none; border: none; padding: 0; }
.msg-text .mention { color: var(--accent); background: var(--accent-dim); border-radius: 4px; padding: 0 3px; }
.msg-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.msg.streaming .msg-text::after {
  content: "▍";
  color: var(--accent);
  margin-left: 2px;
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.msg.system {
  display: flex; justify-content: center;
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 10px 0;
}
.msg.system .msg-text { font-size: 10.5px; color: var(--ink-3); text-align: center; }
.msg.system .avatar { display: none; }

.att-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att-grid img, .att-grid video {
  max-width: min(360px, 100%);
  max-height: 340px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  background: var(--panel);
}
.att-grid img { cursor: zoom-in; }

/* ===== 图片页内查看器 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}
.lightbox:active { cursor: grabbing; }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 6px;
  box-shadow: 0 8px 60px rgba(0, 0, 0, 0.5);
  transform-origin: center center;
  will-change: transform;
  cursor: grab;
}
.lightbox-cap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.att-grid video { max-width: min(420px, 100%); }
.att-file {
  display: inline-flex; align-items: center; gap: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  background: var(--panel);
  max-width: 320px;
}
.att-file:hover { border-color: var(--accent); color: var(--ink); }
.att-file .size { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

/* ---------------------------- 输入区 ---------------------------- */
.typing {
  padding: 0 22px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--accent);
  opacity: 0.85;
}

.composer {
  position: relative;
  flex: none;
  border-top: 1px solid var(--line-soft);
  padding: 12px 22px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

/* @ 自动填充弹层 */
.at-pop {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: calc(100% + 4px);
  max-height: 236px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 4px;
  z-index: 60;
}
.at-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.at-item.on { background: color-mix(in srgb, var(--panel) 40%, var(--line-soft)); }
.at-item .emoji { width: 20px; text-align: center; }
.at-item .nm { font-weight: 600; }
.at-item .sub { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 6px;
  background: var(--bg-elev);
  transition: border-color 0.2s, box-shadow 0.2s;
  max-width: 780px; margin: 0 auto;
}
.composer-row:focus-within {
  border-color: rgba(216, 183, 140, 0.42);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
#input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  resize: none;
  padding: 7px 4px;
  max-height: 180px;
  line-height: 1.65;
  font-size: 14.5px;
}
#input::placeholder { color: var(--ink-3); }
.send {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #12100c;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: 0.18s;
  flex: none;
}
.send:hover { background: var(--accent-2); }
.send:disabled { opacity: 0.35; }

.composer-hint {
  display: flex; justify-content: space-between; gap: 12px;
  max-width: 780px; margin: 8px auto 0;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--ink-3);
}
.hint-right { display: flex; gap: 6px; flex-wrap: wrap; }
.bot-chip {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px;
  color: var(--ink-2);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: 0.15s;
}
.bot-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.attach-strip { display: flex; gap: 8px; flex-wrap: wrap; max-width: 780px; margin: 0 auto 8px; }
.attach-strip:empty { display: none; }
.attach-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  height: 54px;
  min-width: 54px;
  display: flex; align-items: center; gap: 8px;
  padding-right: 26px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--panel);
  max-width: 240px;
}
.attach-item img { width: 54px; height: 52px; object-fit: cover; display: block; }
.attach-item .ph { width: 54px; height: 52px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.attach-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item button {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 10px; display: flex; align-items: center; justify-content: center;
}

/* ---------------------------- 浮层 ---------------------------- */
.modal-root { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); animation: fade 0.2s both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(82vh, 760px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  overflow: hidden;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.modal.wide { width: min(720px, 100%); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px; font-weight: 400;
  letter-spacing: 0.01em;
}
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-foot:empty { display: none; }

.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.16em;
  color: var(--ink-3); text-transform: uppercase;
  margin-bottom: 7px;
}
.field input[type="text"], .field input[type="number"], .field textarea, .field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.7; font-size: 13px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field .hint { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }
.field textarea.mono { font-family: var(--mono); font-size: 12px; }

/* 身份码：一行等宽文字 + 复制 */
.ident-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.ident-box code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}
.ident-box .tiny-btn { flex: none; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.invite-link {
  display: flex; gap: 8px;
  border: 1px dashed rgba(216, 183, 140, 0.35);
  background: var(--accent-dim);
  border-radius: 10px;
  padding: 10px 12px;
  align-items: center;
}
.invite-link code {
  flex: 1;
  font-size: 11.5px;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono);
}
.copy-btn {
  border: 1px solid rgba(216, 183, 140, 0.45);
  color: var(--accent);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 11.5px;
  flex: none;
}
.copy-btn:hover { background: var(--accent-dim); }

.invite-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.invite-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  font-size: 12px;
  color: var(--ink-2);
}
.invite-item .meta { flex: 1; min-width: 0; }
.invite-item .meta b { color: var(--ink); font-weight: 500; font-size: 12px; display: block; }
.invite-item .meta small { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.pill {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  padding: 2px 7px; border-radius: 20px; border: 1px solid var(--line);
  text-transform: uppercase; color: var(--ink-3);
}
.pill.active { color: var(--ok); border-color: rgba(134, 184, 146, 0.4); }
.pill.used, .pill.expired, .pill.revoked { color: var(--ink-3); opacity: 0.7; }

.bot-pick {
  display: flex; gap: 12px; align-items: flex-start;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 13px 14px;
  margin-bottom: 8px;
  transition: 0.18s;
  color: var(--ink-2);
}
.bot-pick:hover { border-color: var(--accent); background: var(--accent-dim); }
.bot-pick:disabled { opacity: 0.45; cursor: not-allowed; }
.bot-pick .emoji { font-size: 22px; line-height: 1.2; }
.bot-pick .info { flex: 1; min-width: 0; }
.bot-pick .info b { display: block; color: var(--ink); font-size: 13.5px; font-weight: 600; }
.bot-pick .info p { margin: 3px 0 5px; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }
.bot-pick .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em;
  border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; color: var(--ink-3); text-transform: uppercase;
}
.tag.ok { color: var(--ok); border-color: rgba(134, 184, 146, 0.35); }
.tag.warn { color: var(--danger); border-color: rgba(224, 122, 108, 0.35); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.seg button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-2);
}
.switch-row small { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.toggle {
  width: 38px; height: 21px; border-radius: 20px;
  background: var(--line); position: relative; flex: none;
  transition: 0.2s;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ink-2); transition: 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 20px; background: #12100c; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 14px; }
.tabs button {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink-3);
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
}
.tabs button.on { color: var(--ink); border-color: var(--accent); }

.veil {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  animation: fade 0.25s both;
}
.veil-inner { text-align: center; color: var(--ink-2); max-width: 360px; padding: 24px; }
.veil-mark { font-size: 38px; color: var(--accent); opacity: 0.8; }
.veil-inner h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 10px 0 8px; }
.veil-inner p { font-size: 12.5px; color: var(--ink-3); margin: 0 0 22px; }

.toast {
  position: fixed;
  left: 50%; bottom: 32px;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 12.5px;
  z-index: 400;
  opacity: 0;
  transition: 0.25s;
  pointer-events: none;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.only-mobile { display: none; }

/* ---------------------------- 响应式 ---------------------------- */
@media (max-width: 900px) {
  .landing { padding: 0 22px; }
  .landing-main { padding: 46px 0 30px; }
  .cards { grid-template-columns: 1fr; gap: 14px; margin-top: 32px; }
  .facts { grid-template-columns: 1fr 1fr; margin-top: 32px; }
  .landing-foot { flex-wrap: wrap; font-size: 9.5px; }

  .room { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0;
    width: 286px; z-index: 150;
    transform: translateX(-102%);
    transition: transform 0.26s cubic-bezier(0.3, 0.8, 0.3, 1);
    box-shadow: var(--shadow);
  }
  .rail.open { transform: none; }
  .rail::after { content: ""; }
  .only-mobile { display: inline-flex; }
  .convo-head { padding: 0 12px; }
  .messages { padding: 18px 12px 6px; }
  .composer { padding: 10px 12px 12px; }
  .msg { grid-template-columns: 28px 1fr; gap: 9px; }
  .avatar { width: 28px; height: 28px; font-size: 13px; }
  .msg-text { font-size: 14px; }
  .composer-hint .hint-left { display: none; }
  .modal-root { padding: 12px; align-items: flex-end; }
  .modal { max-height: 88vh; border-radius: 16px; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------------------- 新消息提示 / 可达性提示 ---------------------- */

.icon.muted { opacity: 0.4; }
.icon.muted:hover { opacity: 0.75; }

.reach {
  font-size: 12px;
  line-height: 1.55;
  padding: 9px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink-2);
}
.reach.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }
.reach.bad { border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }

.tiny.warn { color: var(--danger); }

/* ---------------------------- 引用回复 ---------------------------- */

.msg-quote {
  display: flex;
  align-items: baseline;
  gap: 7px;
  max-width: 100%;
  margin: 2px 0 7px;
  padding: 6px 10px;
  border-left: 2px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s ease;
}
.msg-quote:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.msg-quote .q-who { flex: 0 0 auto; color: var(--accent); font-weight: 600; }
.msg-quote .q-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 点引用跳回原消息时闪一下，不然不知道跳哪去了 */
.msg.flash { animation: quoteFlash 1.5s ease-out; border-radius: 10px; }
@keyframes quoteFlash {
  0%, 35% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 75%, transparent); }
  100% { box-shadow: 0 0 0 2px transparent; }
}

/* 右键 / 长按菜单 */
.ctx-menu {
  position: fixed;
  z-index: 95;
  min-width: 150px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  box-shadow: var(--shadow);
  animation: ctxIn 0.12s ease-out;
}
@keyframes ctxIn {
  from { opacity: 0; transform: translateY(-3px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.ctx-menu button {
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: none;
  border-radius: 7px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--accent-dim); color: var(--accent-2); }

/* 输入框上方的「正在回复」条 */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  padding: 7px 10px;
  background: var(--accent-dim);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.reply-bar[hidden] { display: none; }
.reply-bar .rb-line { flex: 0 0 auto; align-self: stretch; width: 2px; border-radius: 2px; background: var(--accent); }
.reply-bar .rb-body { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.reply-bar .rb-body b { flex: 0 0 auto; color: var(--accent); font-weight: 600; }
.reply-bar .rb-body span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .rb-x {
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  border-radius: 5px;
}
.reply-bar .rb-x:hover { color: var(--ink); background: var(--line-soft); }

/* 触屏：长按只弹引用菜单，不要同时弹系统的文字选择菜单 */
@media (hover: none) and (pointer: coarse) {
  .msg .msg-text,
  .msg .msg-quote { -webkit-touch-callout: none; user-select: none; }
}

/* ---------------------------- 动态表情 ---------------------------- */

.de {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  vertical-align: -0.36em;
  margin: 0 1px;
  line-height: 0;
}
.de svg { display: block; width: 100%; height: 100%; }
.de.fail { font-size: 1.1em; line-height: 1.45; }

.emoji-pop {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: calc(100% + 4px);
  z-index: 70;
  padding: 10px 10px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.emoji-pop[hidden] { display: none; }
.emoji-pop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 8px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.emoji-credit { font-size: 10.5px; opacity: 0.7; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 2px;
  max-height: 214px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.emoji-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.emoji-cell:hover { background: var(--accent-dim); }
.emoji-cell.de { width: 100%; height: auto; margin: 0; vertical-align: baseline; }

/* 整条消息只有表情时放大到 3.5 倍（约 1.6em → 5.6em）；
   和文字混排的仍然是 1.6em，跟着字号走，不会把行高撑坏 */
.msg-text.emoji-only {
  line-height: 1.15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
}
.msg-text.emoji-only .de {
  width: 5.6em;
  height: 5.6em;
  margin: 0;
  vertical-align: middle;
}
