:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e6e8eb;
  --border-strong: #d8dbe0;
  --text: #1f2329;
  --text-sub: #8b909a;
  --text-mute: #b0b4bc;
  --brand: #3b6df6;
  --brand-dark: #2d58d8;
  --brand-soft: #eaf0ff;
  --danger: #e05252;
  --bubble-me: #3b6df6;
  --bubble-me-text: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 300px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  z-index: 20;
}
.sidebar-head {
  height: 68px; padding: 0 18px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.btn-new {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  padding: 7px 11px; font-size: 13px; font-weight: 500; transition: background .15s;
}
.btn-new:hover { background: var(--brand-dark); }
.btn-new svg { width: 15px; height: 15px; }
.search-wrap {
  margin: 12px 14px 6px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 0 11px; height: 36px;
}
.search-wrap svg { width: 15px; height: 15px; color: var(--text-mute); flex-shrink: 0; }
.search-wrap input {
  border: none; background: transparent; outline: none; width: 100%;
  font-size: 13px; color: var(--text);
}
.search-wrap input::placeholder { color: var(--text-mute); }
.win-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px; }
.win-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px;
  border-radius: 10px; cursor: pointer; position: relative;
  transition: background .12s;
}
.win-item:hover { background: var(--panel-2); }
.win-item.active { background: var(--brand-soft); }
.win-item.active .win-title { color: var(--brand-dark); }
.win-avatar {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: #fff; background: #9aa7bd;
}
.win-item.active .win-avatar { background: var(--brand); }
.win-body { flex: 1; min-width: 0; }
.win-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.win-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-time { font-size: 11px; color: var(--text-mute); flex-shrink: 0; }
.win-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.win-preview { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--brand); color: #fff; font-size: 10px; border-radius: 10px;
  padding: 1px 6px; flex-shrink: 0; min-width: 18px; text-align: center;
}
.win-del {
  position: absolute; right: 8px; top: 8px; width: 22px; height: 22px;
  border: none; background: #fff; border-radius: 6px; cursor: pointer;
  display: none; align-items: center; justify-content: center; color: var(--text-sub);
  box-shadow: var(--shadow);
}
.win-item:hover .win-del { display: flex; }
.win-del:hover { color: var(--danger); }
.win-del svg { width: 14px; height: 14px; }
.sidebar-foot {
  height: 42px; border-top: 1px solid var(--border); padding: 0 16px;
  display: flex; align-items: center; font-size: 11px; color: var(--text-mute);
}

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel-2); }
.chat-head {
  height: 68px; flex-shrink: 0; background: var(--panel);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
}
.head-title { flex: 1; min-width: 0; }
.head-title h1 { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-title span { display: block; font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.head-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border: none; background: transparent; cursor: pointer;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--text-sub); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: #fdecec; color: var(--danger); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 20px; }
.date-sep { display: flex; align-items: center; gap: 12px; margin: 4px 0 22px; }
.date-sep::before, .date-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.date-sep span { font-size: 11px; color: var(--text-mute); }
.msg { display: flex; margin-bottom: 18px; }
.msg.me { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; margin: 0 10px;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  font-weight: 600; color: #fff; background: var(--brand);
}
.msg-col { max-width: min(70%, 560px); display: flex; flex-direction: column; align-items: flex-end; }
.msg-name { font-size: 11px; color: var(--text-mute); margin: 0 2px 5px; }
.bubble {
  background: var(--bubble-me); color: var(--bubble-me-text);
  padding: 10px 14px; border-radius: 14px 4px 14px 14px;
  font-size: 14px; line-height: 1.6; word-break: break-word;
  white-space: pre-wrap; box-shadow: var(--shadow);
}
.img-bubble { padding: 5px; background: var(--bubble-me); border-radius: 14px 4px 14px 14px; position: relative; }
.img-bubble img {
  display: block; width: auto; max-width: 200px; max-height: 200px;
  border-radius: 9px; cursor: zoom-in; object-fit: contain;
}
.img-bubble::after {
  content: "点击放大"; position: absolute; right: 8px; bottom: 8px;
  font-size: 10px; color: #fff; background: rgba(0,0,0,.42);
  padding: 2px 6px; border-radius: 6px; pointer-events: none; opacity: 0;
  transition: opacity .15s;
}
.img-bubble:hover::after { opacity: 1; }
.media-bubble {
  background: var(--bubble-me); border-radius: 14px 4px 14px 14px;
  padding: 5px; box-shadow: var(--shadow); overflow: hidden; max-width: 100%;
}
.media-bubble video {
  display: block; max-width: 100%; max-height: 300px; border-radius: 10px; background: #000;
}
.media-dl {
  display: block; color: #fff; font-size: 12px; padding: 7px 6px 4px;
  text-decoration: none; opacity: .9;
}
.media-dl:hover { opacity: 1; text-decoration: underline; }
.file-bubble {
  display: flex; align-items: center; gap: 11px; min-width: 210px; max-width: 100%;
  background: var(--bubble-me); color: var(--bubble-me-text); text-decoration: none;
  padding: 11px 13px; border-radius: 14px 4px 14px 14px; box-shadow: var(--shadow);
}
.file-bubble:hover { background: var(--brand-dark); }
.file-ico { width: 30px; height: 30px; flex-shrink: 0; }
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; opacity: .82; margin-top: 3px; }
.ico-md { color: var(--brand); }
.file-bubble .file-ico { color: rgba(255,255,255,.92); }
.msg-time { font-size: 10.5px; color: var(--text-mute); margin: 5px 2px 0; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: var(--text-mute); }
.empty-icon { width: 72px; height: 72px; border-radius: 20px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty-icon svg { width: 36px; height: 36px; color: var(--brand); }
.empty p { font-size: 15px; color: var(--text-sub); margin-bottom: 6px; }
.empty span { font-size: 12px; }

.composer {
  flex-shrink: 0; background: var(--panel); border-top: 1px solid var(--border);
  padding: 12px 18px 14px;
}
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer .attach { flex-shrink: 0; }
.pending {
  display: none; flex-direction: column; gap: 8px; padding: 0 0 10px;
}
.pending.show { display: flex; }
.pending-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.pending-count { font-size: 12px; color: var(--text-sub); font-weight: 500; }
.pending-clear {
  border: none; background: transparent; color: var(--danger); cursor: pointer;
  font-size: 12px; font-family: inherit; padding: 2px 4px;
}
.pending-clear:hover { text-decoration: underline; }
.pending-list {
  display: flex; flex-wrap: wrap; gap: 7px; max-height: 118px; overflow-y: auto;
  padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2);
}
.pending-item {
  display: inline-flex; align-items: center; gap: 6px; max-width: 230px; height: 32px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 0 7px; font-size: 12px;
}
.pending-list::-webkit-scrollbar { height: 6px; width: 6px; }
.pending-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.pending-ico { width: 16px; height: 16px; color: var(--brand); flex-shrink: 0; }
.pending-ico svg, .file-ico svg { width: 100%; height: 100%; display: block; }
.pending-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-size { color: var(--text-mute); flex-shrink: 0; font-size: 11px; }
.pending-rm {
  border: none; background: transparent; color: var(--text-mute); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.pending-rm:hover { color: var(--danger); }
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 12px; font-size: 14px; font-family: inherit; line-height: 20px;
  min-height: 40px; max-height: 140px; outline: none; background: var(--panel); color: var(--text);
  overflow-y: auto; scrollbar-width: none;
}
.composer textarea::-webkit-scrollbar { display: none; }
.composer textarea:focus { border-color: var(--brand); }
.composer textarea::placeholder { color: var(--text-mute); }
.btn-send {
  flex-shrink: 0; background: var(--brand); color: #fff; border: none;
  border-radius: 10px; padding: 0 18px; height: 40px; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: background .15s;
}
.btn-send:hover { background: var(--brand-dark); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 浮层 ---------- */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
.drop-overlay {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(59,109,246,.15); align-items: center; justify-content: center;
  pointer-events: none;
}
.drop-overlay.show { display: flex; }
.drop-box {
  border: 2px dashed var(--brand); background: var(--panel); border-radius: 18px;
  padding: 40px 56px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.drop-box svg { width: 48px; height: 48px; color: var(--brand); margin-bottom: 14px; }
.drop-box p { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.drop-box span { font-size: 12px; color: var(--text-sub); }
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 40; background: rgba(15,18,24,.88);
  align-items: center; justify-content: center; padding: 40px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lb-close {
  position: absolute; top: 22px; right: 28px; background: transparent; border: none;
  color: #fff; font-size: 34px; cursor: pointer; line-height: 1;
}
.modal-mask {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(15,18,24,.4); align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 360px; background: var(--panel); border-radius: 14px;
  padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
  animation: modalIn .16s ease-out;
}
@keyframes modalIn { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.modal-msg { font-size: 13px; color: var(--text-sub); line-height: 1.6; margin-bottom: 16px; }
.modal-input {
  display: none; width: 100%; border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; margin-bottom: 18px;
}
.modal-input:focus { border-color: var(--brand); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-btn {
  border: none; border-radius: 9px; padding: 9px 18px; font-size: 13px;
  font-weight: 500; cursor: pointer; font-family: inherit;
}
.modal-btn.ghost { background: var(--bg); color: var(--text-sub); }
.modal-btn.ghost:hover { background: var(--border); }
.modal-btn.primary { background: var(--brand); color: #fff; }
.modal-btn.primary:hover { background: var(--brand-dark); }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.win-list, .messages { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.win-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 8px; }
.win-list::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track { background: transparent; }
.win-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px; border: 2px solid var(--panel);
}
.win-list::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ---------- 侧栏底部：管理器入口 ---------- */
.sidebar-foot { justify-content: space-between; gap: 8px; }
.mgr-entry {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text-sub);
  border-radius: 8px; padding: 5px 9px; font-size: 11px; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mgr-entry svg { width: 14px; height: 14px; }
.mgr-entry:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }

/* ---------- 文件管理器（全屏） ---------- */
.mgr {
  display: none; position: fixed; inset: 0; z-index: 30; flex-direction: column;
  background: var(--bg);
}
.mgr.show { display: flex; }
.mgr-head {
  height: 62px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px; gap: 12px;
}
.mgr-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mgr-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; white-space: nowrap; }
.mgr-subtitle { font-size: 12px; font-weight: 400; color: var(--text-mute); margin-left: 4px; }
.mgr-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.mgr-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel); color: var(--text-sub); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-family: inherit; font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.mgr-btn svg { width: 15px; height: 15px; }
.mgr-btn:hover { background: var(--bg); color: var(--text); }
.mgr-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.mgr-btn.primary:hover { background: var(--brand-dark); }

.mgr-body { flex: 1; display: flex; min-height: 0; }
.mgr-tree {
  width: 250px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px 10px; scrollbar-width: thin;
}
.mgr-tree-title { font-size: 11px; color: var(--text-mute); padding: 0 10px 10px; font-weight: 600; letter-spacing: .5px; }
.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 8px;
  font-size: 13px; cursor: pointer; color: var(--text-sub); transition: background .12s;
  white-space: nowrap; overflow: hidden;
}
.tree-row:hover { background: var(--panel-2); }
.tree-row.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; }
.tree-arrow { width: 12px; flex-shrink: 0; transition: transform .15s; font-size: 10px; color: var(--text-mute); }
.tree-node.collapsed > .tree-row .tree-arrow { transform: rotate(-90deg); }
.tree-ico { width: 15px; height: 15px; flex-shrink: 0; color: #e0a92e; }
.tree-ico svg { width: 100%; height: 100%; display: block; }
.tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-children { padding-left: 16px; }
.tree-node.collapsed > .tree-children { display: none; }

.mgr-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mgr-toolbar {
  height: 52px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
}
.mgr-crumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; font-size: 13px; overflow-x: auto; scrollbar-width: none; }
.mgr-crumb::-webkit-scrollbar { display: none; }
.crumb-item { color: var(--brand); cursor: pointer; white-space: nowrap; padding: 3px 5px; border-radius: 6px; }
.crumb-item:hover { background: var(--brand-soft); }
.crumb-item.current { color: var(--text); cursor: default; font-weight: 500; }
.crumb-sep { color: var(--text-mute); }

.mgr-files {
  flex: 1; min-height: 0; overflow-y: auto; padding: 22px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-content: start; gap: 14px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.mgr-files.list-view { grid-template-columns: 1fr; gap: 4px; align-content: start; }
.mgr-files::-webkit-scrollbar { width: 8px; }
.mgr-files::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.file-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 14px; cursor: pointer; user-select: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.file-card:hover { border-color: var(--brand); box-shadow: 0 4px 16px rgba(59,109,246,.1); transform: translateY(-1px); }
.file-card.selected { border-color: var(--brand); background: var(--brand-soft); }
.file-card-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; }
.file-card-icon svg { width: 38px; height: 38px; }
.k-dir { color: #e0a92e; } .k-doc { color: #3b82f6; } .k-code { color: #8b5cf6; }
.k-image { color: #10b981; } .k-video { color: #ec4899; } .k-file { color: #94a3b8; }
.file-card-name {
  font-size: 13px; font-weight: 500; max-width: 100%; word-break: break-all; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.file-card-meta { font-size: 11px; color: var(--text-mute); }

/* list view rows */
.mgr-files.list-view .file-card {
  flex-direction: row; justify-content: flex-start; gap: 12px; text-align: left;
  padding: 9px 14px; border-radius: 9px; transform: none;
}
.mgr-files.list-view .file-card-icon { width: 24px; height: 24px; }
.mgr-files.list-view .file-card-icon svg { width: 22px; height: 22px; }
.mgr-files.list-view .file-card-name { -webkit-line-clamp: 1; white-space: nowrap; flex: 1; }
.mgr-files.list-view .file-card-meta { flex-shrink: 0; }
.mgr-tip { flex-shrink: 0; padding: 10px 22px; font-size: 11px; color: var(--text-mute); background: var(--panel); border-top: 1px solid var(--border); }
.mgr-empty { grid-column: 1 / -1; text-align: center; color: var(--text-mute); padding: 80px 20px; font-size: 14px; }

/* ---------- 文本编辑器 ---------- */
.editor { display: none; position: fixed; inset: 0; z-index: 45; flex-direction: column; background: var(--panel-2); }
.editor.show { display: flex; }
.editor-head {
  height: 58px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
}
.editor-filename { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-head-actions { display: flex; align-items: center; gap: 12px; }
.editor-status { font-size: 12px; color: var(--text-mute); }
.editor-status.dirty { color: #e0862c; }
.editor-status.saved { color: #10b981; }
.editor-tools {
  flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 2px; padding: 7px 14px; flex-wrap: wrap;
}
.editor-tools button {
  min-width: 32px; height: 30px; padding: 0 9px; border: 1px solid transparent; background: transparent;
  color: var(--text-sub); border-radius: 6px; cursor: pointer; font-size: 13px; font-family: inherit;
  transition: background .12s;
}
.editor-tools button:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.editor-tools button.editor-preview-toggle.active { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }
.ed-sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }
.editor-body { flex: 1; display: flex; min-height: 0; }
#edArea {
  flex: 1; width: 100%; resize: none; border: none; outline: none;
  padding: 26px 32px; font-size: 15px; line-height: 1.75;
  font-family: "SF Mono", "Consolas", "Courier New", "Microsoft YaHei", monospace;
  background: var(--panel); color: var(--text); tab-size: 2;
}
.editor-preview {
  flex: 1; overflow-y: auto; padding: 26px 40px; background: var(--panel);
  border-left: 1px solid var(--border); font-size: 15px; line-height: 1.8; color: var(--text);
  scrollbar-width: thin;
}
.editor-preview h1 { font-size: 26px; margin: 16px 0 10px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.editor-preview h2 { font-size: 21px; margin: 14px 0 8px; }
.editor-preview h3 { font-size: 18px; margin: 12px 0 6px; }
.editor-preview p { margin: 8px 0; }
.editor-preview ul, .editor-preview ol { margin: 8px 0; padding-left: 26px; }
.editor-preview blockquote { border-left: 3px solid var(--brand); background: var(--brand-soft); padding: 8px 14px; margin: 10px 0; color: var(--text-sub); }
.editor-preview code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: monospace; color: #d6336c; }
.editor-preview pre { background: #1f2329; color: #e6e8eb; padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.editor-preview pre code { background: transparent; color: inherit; padding: 0; }
.editor-preview a { color: var(--brand); }
.editor-preview table { border-collapse: collapse; margin: 10px 0; }
.editor-preview th, .editor-preview td { border: 1px solid var(--border-strong); padding: 6px 12px; }
.editor-preview th { background: var(--panel-2); }
.editor-preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- 用户入口 ---------- */
.user-entry { margin-left: auto; }

/* ---------- 登录页 ---------- */
.login-screen { display: none; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.login-screen.show { display: flex; }
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(1000px 500px at 15% 10%, rgba(59,109,246,.16), transparent 60%),
    radial-gradient(900px 500px at 85% 90%, rgba(120,90,246,.13), transparent 60%),
    linear-gradient(160deg, #f7f9fd, #eef2fb);
}
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 18px; padding: 36px 34px 28px;
  box-shadow: 0 20px 60px rgba(30,50,100,.14);
  animation: modalIn .25s ease-out;
}
.login-logo { width: 52px; height: 52px; border-radius: 15px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-logo .brand-dot { width: 16px; height: 16px; box-shadow: 0 0 0 6px rgba(59,109,246,.13); }
.login-title { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text-sub); margin: 7px 0 26px; }
.login-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-sub); margin: 0 0 7px 2px; }
.login-input-wrap {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 13px; margin-bottom: 16px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--panel-2);
  transition: border-color .15s, box-shadow .15s;
}
.login-input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-input-wrap svg { width: 18px; height: 18px; color: var(--text-mute); flex-shrink: 0; }
.login-input-wrap input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: var(--text); font-family: inherit; }
.login-error { min-height: 18px; font-size: 12px; color: var(--danger); margin: -4px 0 8px 2px; }
.login-btn {
  width: 100%; height: 44px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; font-family: inherit;
  transition: background .15s; margin-top: 2px;
}
.login-btn:hover { background: var(--brand-dark); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-foot { text-align: center; font-size: 11px; color: var(--text-mute); margin-top: 20px; }

/* ---------- 账号管理面板 ---------- */
.acct-mask {
  display: none; position: fixed; inset: 0; z-index: 70;
  background: rgba(15,18,24,.4); align-items: center; justify-content: center; padding: 20px;
}
.acct-mask.show { display: flex; }
.acct-panel {
  width: 100%; max-width: 440px; max-height: 86vh; background: var(--panel);
  border-radius: 16px; box-shadow: 0 16px 50px rgba(0,0,0,.2);
  display: flex; flex-direction: column; animation: modalIn .18s ease-out; overflow: hidden;
}
.acct-head {
  flex-shrink: 0; height: 56px; padding: 0 18px 0 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.acct-head h2 { font-size: 16px; font-weight: 600; }
.acct-body { padding: 18px 22px 22px; overflow-y: auto; scrollbar-width: thin; }
.acct-current { font-size: 13px; color: var(--text-sub); background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 13px; margin-bottom: 18px; }
.acct-current b { color: var(--text); }
.acct-current .role-tag { font-size: 10px; background: var(--brand-soft); color: var(--brand-dark); padding: 2px 7px; border-radius: 6px; margin-left: 6px; }
.acct-section-title { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-sub); margin: 0 0 10px; }
.acct-mini-btn { border: none; background: transparent; color: var(--brand); font-size: 12px; cursor: pointer; font-family: inherit; }
.acct-mini-btn:hover { text-decoration: underline; }
.acct-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; }
.acct-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.acct-avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.acct-row.admin .acct-avatar { background: #7c5cf0; }
.acct-info { flex: 1; min-width: 0; }
.acct-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-meta { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.acct-del { border: none; background: transparent; color: var(--text-mute); cursor: pointer; font-size: 12px; padding: 4px 7px; border-radius: 6px; font-family: inherit; }
.acct-del:hover { background: #fdecec; color: var(--danger); }
.acct-del:disabled { opacity: .35; cursor: not-allowed; }
.acct-add { border-top: 1px solid var(--border); padding-top: 18px; }
.acct-form-row { display: flex; gap: 8px; margin-bottom: 9px; }
.acct-form-row input, .acct-form-row select {
  flex: 1; min-width: 0; height: 40px; border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 0 12px; font-size: 13px; font-family: inherit; background: var(--panel-2); color: var(--text); outline: none;
}
.acct-form-row input:focus, .acct-form-row select:focus { border-color: var(--brand); }
.acct-form-row select { flex: 0 0 120px; }
.acct-primary { height: 40px; padding: 0 20px; border: none; border-radius: 9px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; }
.acct-primary:hover { background: var(--brand-dark); }
.acct-actions { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.acct-link { border: none; background: transparent; color: var(--brand); font-size: 13px; cursor: pointer; font-family: inherit; padding: 4px; }
.acct-link:hover { text-decoration: underline; }
.acct-link.danger { color: var(--danger); }

@media (max-width: 720px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 24px rgba(0,0,0,.1); }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; }
  .menu-btn { display: flex; }
  .msg-col { max-width: 82%; }
  .composer { padding: 10px 12px; }
  .btn-send { padding: 0 14px; }
  .mgr-subtitle, .mgr-btn span { display: none; }
  .mgr-btn { padding: 8px; }
  .mgr-tree { width: 44%; max-width: 200px; }
  .mgr-head { padding: 0 10px; }
  .mgr-files { padding: 14px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .editor-tools { padding: 6px 8px; }
  #edArea { padding: 18px 16px; }
  .editor-preview { padding: 18px; }
  .login-card { padding: 30px 24px 24px; }
  .acct-panel { max-height: 92vh; }
}
