:root {
  --chat-bg: #f3f5f9;
  --chat-card: #fff;
  --chat-primary: #3b5bdb;
  --chat-text: #1e293b;
  --chat-muted: #64748b;
  --chat-border: #e2e8f0;
}
* { box-sizing: border-box; }
body.chat-body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  background: var(--chat-bg);
  color: var(--chat-text);
}
body.chat-body .chat-app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--chat-card);
  padding-bottom: calc(var(--tab-h, 58px) + env(safe-area-inset-bottom, 0px));
}
body.chat-body .tabbar { z-index: 40; }
@media (min-width: 900px) {
  body.chat-body .chat-app { padding-bottom: 0; }
}
.chat-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--chat-border);
  position: sticky; top: 0; background: #fff; z-index: 20;
}
.chat-top h1 { margin: 0; font-size: 17px; }
.chat-top .back { text-decoration: none; color: var(--chat-primary); font-size: 14px; margin-right: 10px; }
.lang-btn {
  border: 1px solid var(--chat-border); background: #fff; border-radius: 999px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.lang-panel {
  display: none; position: absolute; right: 12px; top: 48px; background: #fff;
  border: 1px solid var(--chat-border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.08);
  min-width: 180px; overflow: hidden; z-index: 30;
}
.lang-panel.show { display: block; }
.lang-panel button {
  display: flex; width: 100%; gap: 8px; align-items: center; border: 0; background: #fff;
  padding: 10px 12px; cursor: pointer; font-size: 14px; text-align: left;
}
.lang-panel button:hover, .lang-panel button.on { background: #eef2ff; }
.chat-tabs { display: flex; border-bottom: 1px solid var(--chat-border); }
.chat-tabs button {
  flex: 1; border: 0; background: #fff; padding: 12px; font-weight: 700; color: var(--chat-muted); cursor: pointer;
}
.chat-tabs button.on { color: var(--chat-primary); box-shadow: inset 0 -2px 0 var(--chat-primary); }
.chat-list { flex: 1; overflow: auto; }
.chat-item {
  display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--chat-border);
  text-decoration: none; color: inherit; align-items: center;
}
.chat-item:active { background: #f8fafc; }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; background: #dbe4ff; color: #364fc7;
  display: flex; align-items: center; justify-content: center; font-weight: 800; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.meta { flex: 1; min-width: 0; }
.meta .t { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .s { font-size: 12px; color: var(--chat-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #e03131; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-tabs button { position: relative; }
.tab-unread {
  position: absolute; top: 6px; right: 18%; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #e03131; color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px; display: none;
}
.tab-unread.show { display: inline-block; }
.letter { padding: 4px 14px; font-size: 12px; color: var(--chat-muted); background: #f8fafc; }
.room-msgs { flex: 1; overflow: auto; padding: 12px; background: #f8fafc; }
.bubble-row { display: flex; margin-bottom: 10px; }
.bubble-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 78%; padding: 8px 12px; border-radius: 14px; background: #fff;
  border: 1px solid var(--chat-border); font-size: 14px; line-height: 1.45; word-break: break-word;
}
.bubble-row.mine .bubble { background: #dbe4ff; border-color: #bac8ff; }
.bubble img { max-width: 100%; border-radius: 8px; display: block; }
.bubble .time { display: block; margin-top: 4px; font-size: 11px; color: var(--chat-muted); }
.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--chat-border); background: #fff;
}
.composer textarea {
  flex: 1; min-height: 40px; max-height: 100px; border: 1px solid var(--chat-border);
  border-radius: 12px; padding: 10px; resize: none; font: inherit;
}
.composer .tools { display: flex; gap: 6px; }
.composer button, .tool-btn {
  border: 0; background: var(--chat-primary); color: #fff; border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-weight: 700;
}
.tool-btn { background: #e2e8f0; color: #334155; }
.muted-bar { padding: 10px; text-align: center; color: var(--chat-muted); background: #fff7ed; font-size: 13px; }
.empty { padding: 40px 16px; text-align: center; color: var(--chat-muted); }
.emoji-panel {
  display: none; flex-wrap: wrap; gap: 4px; padding: 8px; border-top: 1px solid var(--chat-border); background: #fff; max-height: 140px; overflow: auto;
}
.emoji-panel.show { display: flex; }
.emoji-panel span { font-size: 22px; cursor: pointer; padding: 4px; }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h, 58px) + 18px); width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: var(--chat-primary); color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(59,91,219,.35); z-index: 35;
}
.admin-bar {
  display: flex; gap: 8px; padding: 8px 12px; background: #eef2ff; border-bottom: 1px solid var(--chat-border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
/* HTML hidden 属性会被上面的 display:flex 覆盖，必须显式压住 */
.admin-bar[hidden] {
  display: none !important;
}
.admin-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 12px; cursor: pointer;
  background: #fff; color: #1e3a8a; font-size: 12px; font-weight: 700;
  box-shadow: 0 1px 4px rgba(30,58,138,.08);
}
.admin-chip-ico { font-size: 13px; opacity: .85; }
.folder-bar {
  display: flex; gap: 6px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--chat-border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.folder-bar[hidden] { display: none !important; }
.folder-chip {
  flex: 0 0 auto; border: 1px solid var(--chat-border); background: #f8fafc; color: #475569;
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.folder-chip.on { background: var(--chat-primary); color: #fff; border-color: var(--chat-primary); }
.chat-item.pinned { background: linear-gradient(90deg, #eef2ff 0%, #fff 48%); }
.chat-item .pin-tag {
  font-size: 10px; font-weight: 700; color: #4338ca; background: #e0e7ff;
  border-radius: 999px; padding: 2px 6px; margin-left: 6px; vertical-align: middle;
}
.chat-item.pressing { background: #eef2ff; }
.bubble .read-tick {
  display: inline-block; margin-left: 4px; color: #94a3b8; font-size: 12px; font-weight: 700;
}
.bubble .read-tick.on { color: #12b886; }
.bubble a.chat-link {
  color: #3b5bdb; text-decoration: underline; word-break: break-all;
}
.msg-revoke {
  color: var(--chat-primary); text-decoration: none; margin-left: 4px; font-size: 11px;
}
.admin-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px;
}
.admin-modal-head h3 { margin: 0; }
.admin-hint { margin: 0 0 12px; font-size: 12px; color: var(--chat-muted); line-height: 1.45; }
.admin-label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin: 8px 0 4px; }
.admin-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.admin-row input, .admin-row select { flex: 1; margin-bottom: 0 !important; }
.tool-btn.primary { background: var(--chat-primary); color: #fff; }
.tool-btn.block { width: 100%; margin-top: 8px; }
.invite-box {
  margin-top: 14px; padding: 12px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--chat-border);
}
.invite-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 720px; background: #fff; border-radius: 16px 16px 0 0; padding: 16px; max-height: 78vh; overflow: auto;
}
.modal h3 { margin: 0 0 10px; }
.modal input, .modal textarea, .modal select {
  width: 100%; border: 1px solid var(--chat-border); border-radius: 10px; padding: 10px; margin-bottom: 8px; font: inherit;
  box-sizing: border-box;
}
.modal hr { border: 0; border-top: 1px solid var(--chat-border); margin: 14px 0; }
