/* rovante v2 — dark & light academic minimal */
html[data-theme="dark"] {
  --bg: #0b0b0c;
  --panel: #121214;
  --panel2: #17171a;
  --border: #242428;
  --fg: #f0f0f0;
  --muted: #8d8d94;
  --accent: #ffffff;
  --accent-fg: #0b0b0c;
  --danger: #e5484d;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
html[data-theme="light"] {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel2: #f0f0ee;
  --border: #e2e2de;
  --fg: #141414;
  --muted: #75757c;
  --accent: #141414;
  --accent-fg: #ffffff;
  --danger: #d93036;
  --shadow: 0 8px 30px rgba(0,0,0,.10);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--fg); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- login ---------- */
#login-screen { height: 100%; display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; max-width: 420px; padding: 40px 24px; }
.brand-logo { width: 88px; height: 88px; border-radius: 20px; margin-bottom: 18px; }
.brand-name { font-size: 34px; font-weight: 650; letter-spacing: .5px; }
.brand-sub { color: var(--muted); font-size: 13.5px; margin: 10px 0 28px; line-height: 1.7; }
.btn-primary {
  background: var(--accent); color: var(--accent-fg); border: none;
  border-radius: 9px; padding: 10px 20px; font-weight: 600; display: inline-block; text-decoration: none;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--fg); border-radius: 9px; padding: 10px 16px; }
.btn-danger { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 9px; padding: 10px 16px; }
.login-note { color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ---------- layout ---------- */
#app { height: 100%; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 16px 16px 12px; }
.side-logo { width: 36px; height: 36px; border-radius: 9px; }
.side-title { font-weight: 650; font-size: 17px; }
.side-sub { color: var(--muted); font-size: 11.5px; }
.side-close { display: none; margin-left: auto; background: none; border: none; color: var(--muted); font-size: 16px; }
.btn-new {
  margin: 6px 12px 8px; padding: 10px; border-radius: 9px;
  background: var(--panel2); color: var(--fg); border: 1px solid var(--border); font-weight: 600;
}
.btn-new:hover { border-color: var(--muted); }
.conv-filter { margin: 0 12px 8px; padding: 7px 11px; font-size: 13px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px; min-height: 0; }
.conv-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; position: relative;
  border: 1px solid transparent; display: flex; flex-direction: column; gap: 2px;
}
.conv-item:hover { background: var(--panel2); }
.conv-item.active { background: var(--panel2); border-color: var(--border); }
.conv-item .t { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 22px; }
.conv-item .m { color: var(--muted); font-size: 11px; display: flex; gap: 6px; align-items: center; }
.conv-del {
  position: absolute; right: 6px; top: 8px; background: none; border: none; color: var(--muted);
  font-size: 12.5px; padding: 2px 5px; border-radius: 6px; opacity: 0;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--panel); }
.mode-tag {
  display: inline-block; font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; white-space: nowrap;
}
.side-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.side-link { background: none; border: none; color: var(--muted); text-align: left; padding: 7px 6px; border-radius: 7px; font-size: 13.5px; }
.side-link:hover { background: var(--panel2); color: var(--fg); }
.user-box { display: flex; align-items: center; gap: 8px; padding: 8px 6px 2px; font-size: 13px; color: var(--muted); }
.role-tag { font-size: 10.5px; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; color: var(--fg); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 54px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; flex: none; gap: 8px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conv-title {
  font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 46vw; cursor: text; border-radius: 6px; padding: 3px 6px;
}
.conv-title:hover { background: var(--panel2); }
.topbar-right { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  background: none; border: none; color: var(--muted); font-size: 16px;
  padding: 6px 8px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { color: var(--fg); background: var(--panel2); }
#side-open { display: none; font-size: 19px; }
.engine-dots { display: flex; gap: 5px; align-items: center; margin-right: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dot.on { background: #3ecf8e; }

.messages { flex: 1; overflow-y: auto; padding: 24px 0 8px; min-height: 0; }
.msg-wrap { max-width: 800px; margin: 0 auto; padding: 0 22px 20px; position: relative; }
.msg-user .bubble {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 15px; white-space: pre-wrap; word-break: break-word;
}
.msg-ai .bubble { padding: 2px 0; word-break: break-word; }
.who { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: .4px; }
.bubble pre {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0; font-size: 13px;
}
.bubble code { background: var(--panel2); border-radius: 4px; padding: 1.5px 5px; font-size: 13px; }
.bubble pre code { background: none; padding: 0; }
.bubble h1,.bubble h2,.bubble h3 { margin: 14px 0 8px; line-height: 1.35; }
.bubble ul, .bubble ol { padding-left: 22px; margin: 8px 0; }
.who a, .bubble a { color: #4d8df0; }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--fg); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-images img {
  max-width: min(260px, 60vw); max-height: 260px; border-radius: 10px;
  border: 1px solid var(--border); cursor: zoom-in; display: block;
}
.msg-tools { position: absolute; right: 22px; top: 0; opacity: 0; transition: opacity .12s; }
.msg-wrap:hover .msg-tools { opacity: 1; }
.msg-tools button { background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; border-radius: 7px; padding: 3px 9px; }
.citations { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.citations .cit-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cit-item { font-size: 12.5px; color: var(--muted); padding: 4px 0; display: flex; gap: 8px; }
.cit-item .idx { color: var(--fg); }
.progress-line { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.spinner {
  width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--fg);
  border-radius: 50%; animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-line { color: var(--danger); font-size: 13.5px; padding: 4px 0; }
.empty-state { max-width: 620px; margin: 5vh auto 0; text-align: center; color: var(--muted); padding: 0 16px; }
.empty-state h2 { color: var(--fg); font-size: 23px; margin: 8px 0 10px; }
.empty-logo { font-size: 30px; color: var(--fg); }
.empty-agents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 20px; text-align: left; max-width: 520px; margin-left: auto; margin-right: auto; }
.more-agents-btn { margin-top: 16px; font-size: 13px; padding: 8px 16px; }
.agent-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.agent-card:hover { border-color: var(--muted); }
.agent-card .an { font-size: 13px; font-weight: 600; }
.agent-card .ad { font-size: 11px; color: var(--muted); line-height: 1.45; }
.agent-card.custom { border-style: dashed; }
.attach-item.file-item .file-chip { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; max-width: 180px; }
.file-chip .fn { font-size: 12px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fi { font-size: 15px; flex: none; }
.msg-file {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--fg);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; font-size: 13px;
}
.msg-file:hover { border-color: var(--muted); }
.msg-file .fi { font-size: 16px; }

/* ---------- composer ---------- */
.composer { flex: none; padding: 6px 22px 16px; max-width: 800px; margin: 0 auto; width: 100%; }
.feature-row { display: flex; gap: 7px; align-items: center; margin-bottom: 7px; flex-wrap: wrap; }
.feature-label { font-size: 11.5px; color: var(--muted); }
.feature-toggle {
  font-size: 12px; padding: 4px 12px; border-radius: 8px; border: 1px dashed var(--border);
  background: none; color: var(--muted); white-space: nowrap;
}
.feature-toggle:hover { color: var(--fg); }
html[data-theme="dark"] .feature-toggle.on {
  border-style: solid; border-color: #3ecf8e; color: #3ecf8e; font-weight: 600;
  background: rgba(62, 207, 142, .10);
}
html[data-theme="light"] .feature-toggle.on {
  border-style: solid; border-color: #1f9d63; color: #1f9d63; font-weight: 600;
  background: rgba(31, 157, 99, .10);
}
.feat-tags { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.btn-stop { background: var(--danger) !important; color: #fff !important; }
.edit-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--muted); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; margin-bottom: 8px;
}
.edit-banner button { background: none; border: none; color: var(--fg); font-size: 12.5px; flex: none; }
.attach-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attach-item { position: relative; }
.attach-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border); }
.attach-item > button.rm {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--fg); color: var(--bg); border: none; font-size: 10px; line-height: 1;
}
.attach-item.file-item { display: flex; align-items: center; gap: 6px; }
.attach-item.file-item .file-chip { max-width: 260px; }
.attach-item.file-item > button.rm {
  position: static; top: auto; right: auto; width: 20px; height: 20px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.attach-item.file-item > button.save-note { flex: none; }
.agent-chips { display: flex; gap: 7px; margin-bottom: 9px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.agent-chips::-webkit-scrollbar { display: none; }
.chip {
  font-size: 12.5px; padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: none; color: var(--muted); white-space: nowrap; flex: none;
}
.chip:hover { color: var(--fg); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.attach-btn { flex: none; font-size: 18px; padding: 10px; }
#input { flex: 1; resize: none; max-height: 180px; line-height: 1.5; border-radius: 12px; padding: 12px 14px; }
#send { padding: 12px 22px; border-radius: 11px; flex: none; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 14px; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(540px, 96vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 15px; }
.modal-body { padding: 15px 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
#settings-form, #agent-form { display: flex; flex-direction: column; gap: 12px; }
#settings-form label, #agent-form label, .upload-label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.row-2 { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.modal-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.agent-section-title { font-size: 13px; color: var(--muted); margin-top: 2px; }
.agent-manage-list { display: flex; flex-direction: column; gap: 6px; }
.agent-row {
  display: flex; align-items: center; gap: 10px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 13.5px;
}
.agent-row .ae { font-size: 17px; }
.agent-row .an { font-weight: 600; }
.agent-row .ad { color: var(--muted); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-row button { background: none; border: none; color: var(--danger); font-size: 12.5px; flex: none; }
.lib-list { display: flex; flex-direction: column; gap: 6px; }
.lib-item { display: flex; justify-content: space-between; align-items: center; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; gap: 8px; }
.lib-item .sz { color: var(--muted); font-size: 12px; }
.lib-item button { background: none; border: none; color: var(--danger); font-size: 13px; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--border); color: var(--fg);
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px; z-index: 300; max-width: 76vw; box-shadow: var(--shadow);
}

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 200; cursor: zoom-out; }
.viewer img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* ---------- mobile ---------- */
.sidebar-mask { display: none; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #side-open { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(296px, 84vw); z-index: 120;
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: none; }
  .sidebar-mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 110; }
  .side-close { display: block; }
  .topbar { padding: 0 8px; }
  .conv-title { max-width: 34vw; font-size: 14px; }
  .messages { padding-top: 12px; }
  .msg-wrap { padding: 0 12px 16px; }
  .composer { padding: 6px 10px calc(12px + env(safe-area-inset-bottom)); }
  .agent-chips { margin-bottom: 7px; }
  .chip { font-size: 12px; padding: 6px 12px; }
  #input { font-size: 16px; /* prevent iOS zoom */ padding: 11px 12px; }
  #send { padding: 12px 16px; }
  .msg-images img { max-width: 100%; }
  .msg-tools { position: static; opacity: 1; margin-top: 6px; }
  .conv-del { opacity: .65; }
  .empty-agents { grid-template-columns: repeat(2, 1fr); }
  .viewer img { max-width: 98vw; }
}

/* ---------- companions (角色聊天) ---------- */
.companions-card { width: min(780px, 96vw); }
.comp-intro { margin: 0; line-height: 1.6; }
.comp-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.comp-tab {
  background: none; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); padding: 5px 14px; font-size: 13px;
}
.comp-tab:hover { color: var(--fg); }
.comp-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.comp-card {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 13px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .14s ease, transform .14s ease;
}
.comp-card:hover { border-color: var(--muted); transform: translateY(-1px); }
.comp-card .cc-emoji { font-size: 27px; line-height: 1.2; }
.comp-card .cc-name { font-weight: 650; font-size: 14.5px; }
.comp-card .cc-tag { font-size: 12px; color: var(--fg); opacity: .85; line-height: 1.45; }
.comp-card .cc-who { font-size: 11px; color: var(--muted); line-height: 1.4; }
@media (max-width: 860px) {
  .comp-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---------- mode switch + chat pane ---------- */
.mode-switch { display: flex; gap: 4px; margin: 2px 12px 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.ms-btn { flex: 1; border: 1px solid transparent; background: none; color: var(--muted); padding: 7px 0; border-radius: 7px; font-size: 13px; }
.ms-btn:hover { color: var(--fg); }
.ms-btn.on { background: var(--panel); color: var(--fg); font-weight: 600; border-color: var(--border); }
.side-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-hint { font-size: 11px; color: var(--muted); padding: 0 14px 8px; }
.comp-list { flex: 1; overflow-y: auto; padding: 4px 8px 6px; min-height: 0; }
.comp-cat { position: sticky; top: 0; z-index: 1; background: var(--panel); font-size: 11.5px; color: var(--muted); padding: 12px 8px 4px; letter-spacing: .5px; }
.comp-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.comp-row:hover { background: var(--panel2); }
.comp-row.active { background: var(--panel2); border-color: var(--border); }
.comp-row .ce { font-size: 19px; flex: none; width: 26px; text-align: center; line-height: 1.35; }
.comp-row .cmid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.comp-row .cn { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-row .ct { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-row .cx { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; flex: none; margin-top: 1px; }

/* ---------- terms ---------- */
.terms-card { width: min(660px, 96vw); }
.terms-body h4 { font-size: 14px; margin: 8px 0 2px; }
.terms-body ul { padding-left: 18px; margin: 4px 0; display: flex; flex-direction: column; gap: 7px; }
.terms-body li { font-size: 12.5px; opacity: .92; line-height: 1.65; }
.terms-meta { font-size: 11.5px; color: var(--muted); }
.terms-sec { font-size: 12.5px; font-weight: 600; margin: 12px 0 0; opacity: .95; }

/* ---------- rich markdown in messages ---------- */
.bubble h1 { font-size: 20px; margin: 14px 0 8px; }
.bubble h2 { font-size: 18px; margin: 12px 0 7px; }
.bubble h3 { font-size: 16px; margin: 10px 0 6px; }
.bubble h4 { font-size: 14.5px; margin: 10px 0 5px; }
.bubble h5, .bubble h6 { font-size: 13.5px; margin: 8px 0 4px; }
.bubble p { margin: 5px 0; }
.bubble ul, .bubble ol { margin: 6px 0 6px 22px; }
.bubble pre { overflow-x: auto; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.bubble pre code { background: none; padding: 0; font-size: 12.5px; }
.bubble blockquote { border-left: 3px solid var(--border); margin: 8px 0; padding: 2px 0 2px 12px; color: var(--muted); }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.bubble .md-table-wrap { overflow-x: auto; margin: 10px 0; max-width: 100%; }
.bubble table { border-collapse: collapse; font-size: 13px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.bubble th { background: var(--panel2); font-weight: 600; }
.bubble .katex { font-size: 1.05em; }
.bubble .katex-display { margin: 10px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.bubble .math-fallback { font-size: 12.5px; }
.menu-pop { position: fixed; z-index: 80; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; min-width: 172px; }
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--fg); font-size: 13px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.menu-pop button:hover { background: var(--panel2); }

/* ---------- v3: 矢量图标 ---------- */
.ico { width: 15px; height: 15px; flex: none; display: inline-block; vertical-align: -2.5px; }
.ico.xl { width: 32px; height: 32px; vertical-align: 0; }
.side-link { display: flex; align-items: center; gap: 9px; }
.ms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ms-btn .ico { width: 14px; height: 14px; vertical-align: 0; }
.btn-new { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-new .ico { width: 14px; height: 14px; vertical-align: 0; }
.feature-toggle { display: inline-flex; align-items: center; gap: 5px; }
.feature-toggle .ico { width: 13px; height: 13px; vertical-align: 0; }
.icon-btn .ico { width: 16px; height: 16px; vertical-align: 0; }
.edit-banner .ico { width: 13px; height: 13px; vertical-align: 0; margin-right: 1px; }
.amark { display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; flex: none; }
.amark .ico { width: 14px; height: 14px; vertical-align: 0; }
.acirc { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--border); align-items: center; justify-content: center; font-size: 10px; font-weight: 650; flex: none; color: var(--fg); }
.acirc.big { width: 30px; height: 30px; font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip .amark { width: 15px; height: 15px; }
.chip.on .amark .ico { color: inherit; }
.mode-tag { display: inline-flex; align-items: center; gap: 5px; }
.mode-tag .amark { width: 14px; height: 14px; }
.mode-tag .amark .ico { width: 12px; height: 12px; vertical-align: 0; }
.conv-del { display: inline-flex; align-items: center; }
.conv-del .ico { width: 13px; height: 13px; vertical-align: 0; }
.menu-pop button { display: flex; align-items: center; gap: 8px; }
.menu-pop .ico { width: 14px; height: 14px; vertical-align: 0; color: var(--muted); }
.msg-file .fi, .file-chip .fi { display: inline-flex; align-items: center; }
.msg-file .fi .ico, .file-chip .fi .ico { width: 15px; height: 15px; vertical-align: 0; }
.empty-logo .ico { width: 32px; height: 32px; vertical-align: 0; }
.agent-card .an { display: flex; align-items: center; gap: 7px; }
.agent-card .an .amark .ico { width: 13px; height: 13px; }
.agent-row .ae { display: inline-flex; align-items: center; }
.cc-emoji { display: flex; align-items: center; min-height: 30px; }
.comp-row .ce { display: inline-flex; justify-content: center; }
/* ---------- v3: notes modal（内容库） ---------- */
.notes-card { width: min(900px, 96vw); height: min(640px, 90vh); }
.notes-body { flex-direction: row !important; gap: 0 !important; padding: 0 !important; overflow: hidden !important; flex: 1; min-height: 0; }
.notes-tree { width: 292px; flex: none; border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.notes-view { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 20px; }
.note-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.note-row:hover { background: var(--panel2); }
.note-row.on { background: var(--panel2); }
.note-row .nc { width: 14px; flex: none; display: inline-flex; align-items: center; color: var(--muted); }
.note-row .nc .ico { width: 12px; height: 12px; vertical-align: 0; transition: transform .12s; }
.note-node.closed > .note-kids { display: none; }
.note-node.closed > .note-row .nc .ico { transform: rotate(-90deg); }
.note-node.closed > .note-row { color: var(--muted); }
.note-row .nt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-title { font-size: 18px; font-weight: 650; margin-bottom: 10px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.btn-ghost.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; text-decoration: none; color: var(--fg); }
.btn-ghost.sm:hover { border-color: var(--muted); }
/* ---------- v3: caps modal（技能与工具） ---------- */
.caps-card { width: min(640px, 96vw); }
.caps-tabs { display: flex; gap: 8px; }
.caps-list { display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.cap-row { display: flex; gap: 11px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.cap-ic { color: var(--muted); margin-top: 2px; display: inline-flex; }
.cap-ic .ico { width: 15px; height: 15px; vertical-align: 0; }
.cap-main { min-width: 0; }
.cap-n { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.cap-d { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.55; }
.cap-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; font-weight: 400; }
/* ---------- v3: 成熟化细节 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

.note-row .ni { width: 14px; flex: none; display: inline-flex; color: var(--muted); }
.note-row .ni .ico { width: 13px; height: 13px; vertical-align: 0; }
.note-row.lvl0 { font-weight: 550; }
.note-row.lvl0 .ni { color: var(--fg); }
.modal { background: rgba(0,0,0,.62); }

.who { display: flex; align-items: center; gap: 6px; }
.who .amark { width: 14px; height: 14px; }
.who .amark .ico { width: 12px; height: 12px; }

/* ===== [V4] 侧边栏精简 ===== */
.side-foot { padding: 8px 10px 10px; gap: 0; }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-link { padding: 7px 9px; font-size: 13px; border-radius: 8px; }
.side-link .ico { width: 15px; height: 15px; }
.side-sep { height: 1px; background: var(--border); margin: 7px 9px; }
.user-box { padding: 7px 9px 2px; }
.user-box .acirc { width: 22px; height: 22px; font-size: 11.5px; flex: none; }
.side-legal { background: none; border: none; color: var(--muted); opacity: .72; font-size: 11px; text-align: left; padding: 4px 9px 0; cursor: pointer; }
.side-legal:hover { opacity: 1; text-decoration: underline; }
/* ===== [V4] 聊天栏角色列表 ===== */
.comp-more { margin-top: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--border); border-radius: 9px; text-align: center; cursor: pointer; }
.comp-more:hover { color: var(--fg); border-color: var(--muted); }
/* ===== [V4] 设置页 ===== */
.settings-card { width: min(680px, 94vw); }
.set-body { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; }
.set-sec { font-size: 11.5px; color: var(--muted); letter-spacing: .5px; margin: 14px 2px 4px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); }
.set-lb { font-size: 13.5px; flex: none; }
.set-val { font-size: 12.5px; margin-left: auto; text-align: right; }
.set-note { font-size: 12px; color: var(--muted); line-height: 1.6; padding: 2px 4px; }
.account-row .set-account-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-acc-name { font-weight: 650; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.set-acc-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.seg { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { background: none; border: none; color: var(--muted); font-size: 12.5px; padding: 6px 14px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--fg); font-weight: 600; }
.set-link-row { cursor: pointer; }
.set-link-row:hover { border-color: var(--muted); }
.set-link-hint { margin-left: auto; font-size: 12.5px; color: var(--muted); }
#set-admin-box { margin-top: 4px; }
#set-admin-box summary { font-size: 13px; color: var(--muted); cursor: pointer; padding: 8px 2px; }
#settings-form label { display: block; margin: 10px 0; font-size: 13px; }
#settings-form input, #settings-form select { width: 100%; margin-top: 6px; }
/* ===== [V4] 笔记文件预览 ===== */
.np-pdf { width: 100%; flex: 1; min-height: 480px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); margin-top: 6px; }
.np-meta { font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.np-meta a { color: var(--muted); }
.np-filecard { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-top: 10px; background: var(--panel2); }
.np-filecard .nf-ic { display: inline-flex; color: var(--muted); }
.np-filecard .nf-main { flex: 1; min-width: 0; }
.nf-n { font-weight: 600; font-size: 14px; word-break: break-all; }
.nf-d { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== [V5] 统一界面 / 人格列表 ===== */
.agent-row.clickable { cursor: pointer; }
.agent-row.clickable:hover { background: var(--panel2); }
.empty-comp-grid { margin: 18px auto 0; max-width: 760px; width: 100%; }
.empty-comp-grid .comp-card { text-align: left; }
.empty-state .comp-more { background: transparent; margin: 14px auto 0; display: block; max-width: 280px; width: 100%; }

/* ===== [V7] 设置页 v2（Claude 式） ===== */
.settings-card { padding: 0; width: min(880px, 94vw); height: min(660px, 88vh); display: flex; flex-direction: column; overflow: hidden; }
.settings-card .modal-head { padding: 15px 20px; }
.settings-layout { display: flex; flex: 1; min-height: 0; }
.set-nav { width: 172px; flex: none; border-right: 1px solid var(--border); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.set-nav-btn { background: none; border: none; color: var(--muted); text-align: left; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.set-nav-btn:hover { background: var(--panel2); color: var(--fg); }
.set-nav-btn.on { background: var(--panel2); color: var(--fg); font-weight: 600; }
.set-pane-wrap { flex: 1; min-width: 0; overflow: auto; padding: 6px 20px 26px; }
.set-pane { display: none; }
.set-pane.on { display: block; }
.set-select { margin-left: auto; background: var(--panel2); color: var(--fg); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 13px; max-width: 240px; }
.login-legal { margin-top: 10px; font-size: 12px; }
.login-legal a { color: var(--muted); }

/* [V10] 设置 v3 */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch > span { width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; display: inline-block; }
.switch > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; }
.btn-ghost.sm.danger { color: #e0705c; border-color: rgba(224,112,92,.4); }
.btn-ghost.sm.danger:hover { border-color: #e0705c; }
.plan-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; background: linear-gradient(135deg, rgba(232,163,61,.10), transparent 60%), var(--panel2); margin-bottom: 14px; }
.plan-badge { display: inline-block; font-size: 10.5px; letter-spacing: .12em; font-weight: 700; color: var(--accent-fg); background: var(--accent); border-radius: 6px; padding: 2px 7px; margin-bottom: 8px; }
.plan-name { font-size: 17px; font-weight: 650; }
.plan-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.mem-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; max-height: 240px; overflow: auto; }
.mem-item { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.mem-item .mem-text { flex: 1; min-width: 0; }
.mem-item .mem-del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.mem-item .mem-del:hover { color: #e0705c; }
.temp-banner { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; padding: 7px 12px; margin: 0 0 8px; }
.temp-banner[hidden] { display: none !important; }
.temp-banner svg { width: 15px; height: 15px; flex: none; }
.temp-banner button { margin-left: auto; background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.btn-temp { margin-top: 6px; opacity: .9; }
.btn-temp .ico { opacity: .8; }
/* [V11] 周用量进度条 */
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 6px 0 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
/* [V12] 模型选择器 + 隐私 chip */
.model-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--fg); cursor: pointer; }
.model-chip:hover { border-color: var(--muted); }
.model-chip .ico { width: 13px; height: 13px; }
.model-chip .chev { width: 11px; height: 11px; opacity: .6; }
.model-menu { position: fixed; z-index: 60; min-width: 230px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.35); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.model-menu[hidden] { display: none !important; }
.model-opt { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 9px 10px; border-radius: 8px; border: none; background: none; color: var(--fg); cursor: pointer; }
.model-opt:hover { background: var(--panel2); }
.model-opt.on { background: var(--panel2); box-shadow: inset 0 0 0 1px var(--border); }
.model-opt .mo-name { font-size: 13px; font-weight: 600; }
.model-opt .mo-desc { font-size: 11.5px; color: var(--muted); }
.privacy-chip.on { border-style: solid !important; color: #e8a33d !important; border-color: rgba(232,163,61,.55) !important; background: rgba(232,163,61,.10) !important; }
/* [V13] 输入框内联模型/强度（对标 Codex） */
.composer-box { border: 1px solid var(--border); background: var(--panel); border-radius: 14px; padding: 6px 8px; gap: 6px; align-items: flex-end; box-shadow: var(--shadow); }
.composer-box #input { border: none !important; background: none !important; box-shadow: none !important; padding: 8px 4px; }
.composer-box .attach-btn { align-self: flex-end; margin-bottom: 1px; }
.composer-tools { display: flex; align-items: center; gap: 6px; flex: none; padding-bottom: 1px; }
.composer-tools .btn-primary { padding: 9px 16px; border-radius: 9px; margin-left: 2px; }
.model-chip.in-row { padding: 7px 8px; font-size: 11.5px; background: none; border-color: transparent; color: var(--muted); gap: 4px; }
.model-chip.in-row:hover { background: var(--panel2); color: var(--fg); }
.model-chip.in-row#model-btn { color: var(--fg); }
.model-chip.in-row .chev { opacity: .5; width: 10px; height: 10px; }
.effort-chip { min-width: 42px; justify-content: center; }
.model-menu { z-index: 80; }
@media (max-width: 680px) {
  .model-chip.in-row #model-chip-name { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .effort-chip { display: inline-flex; min-width: 40px; padding-left: 6px; padding-right: 6px; }
  .effort-chip #effort-label { font-size: 10.5px; }
}
@media (max-width: 560px) {
  #engine-dots, #export-btn, #theme-btn, #conv-agent-tag, #top-model { display: none; }
  .conv-title { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .composer-tools { gap: 3px; }
  .composer-box { padding: 5px 6px; }
}

/* [V14] 顶栏模型/用量 · 消息元数据 · 会话菜单 · @/命令弹层 */
.top-chip { flex:none; font-size:11.5px; color:var(--muted); padding:4px 9px; border:1px solid var(--border); border-radius:7px; background:none; white-space:nowrap; }
button.top-chip { cursor:pointer; color:var(--fg); }
button.top-chip:hover { background:var(--panel2); }
.usage-chip { font-variant-numeric: tabular-nums; }
.msg-meta { font-size:11px; color:var(--muted); margin:5px 0 0; padding-left:2px; letter-spacing:.2px; }
.conv-item .conv-menu { margin-left:auto; flex:none; background:none; border:none; color:var(--muted); font-size:16px; line-height:1; padding:0 4px; opacity:0; cursor:pointer; }
.conv-item:hover .conv-menu { opacity:1; }
.conv-menu-pop { position:fixed; z-index:90; min-width:150px; background:var(--panel); border:1px solid var(--border); border-radius:10px; box-shadow:var(--shadow); padding:5px; display:flex; flex-direction:column; }
.conv-menu-pop button { text-align:left; background:none; border:none; color:var(--fg); font-size:13px; padding:8px 10px; border-radius:6px; cursor:pointer; }
.conv-menu-pop button:hover { background:var(--panel2); }
.conv-menu-pop button.danger { color:var(--danger); }
.conv-archived-toggle { background:none; border:none; color:var(--muted); font-size:12px; text-align:left; padding:8px 6px; cursor:pointer; }
.conv-archived-toggle:hover { color:var(--fg); }
.pop-list { position:fixed; z-index:85; width:min(320px,92vw); max-height:300px; overflow-y:auto; background:var(--panel); border:1px solid var(--border); border-radius:11px; box-shadow:var(--shadow); padding:5px; }
.pop-list[hidden] { display:none !important; }
.pop-head { font-size:11px; color:var(--muted); padding:7px 9px 3px; text-transform:none; }
.pop-item { display:flex; flex-direction:column; gap:1px; width:100%; text-align:left; background:none; border:none; color:var(--fg); padding:7px 9px; border-radius:7px; cursor:pointer; }
.pop-item:hover { background:var(--panel2); }
.pop-item .pi-t { font-size:13px; }
.pop-item .pi-s { font-size:11px; color:var(--muted); }
.shortcut-table { width:100%; border-collapse:collapse; font-size:13px; }
.shortcut-table td { padding:7px 6px; border-bottom:1px solid var(--border); }
.shortcut-table td:first-child { color:var(--muted); white-space:nowrap; width:130px; font-family:ui-monospace, Menlo, Consolas, monospace; font-size:12px; }
.side-legal-links { display:flex; gap:12px; padding:6px 8px 2px; font-size:12px; }
.side-legal-links a { color:var(--muted); text-decoration:none; }
.side-legal-links a:hover { color:var(--fg); text-decoration:underline; }
@media (max-width: 860px) {
  .usage-chip { display:none; }
  .top-chip { font-size:11px; padding:3px 7px; }
  .msg-meta { font-size:10.5px; }
}
@media (max-width: 560px) {
  .composer { padding:6px 10px 12px; }
  .topbar { padding:0 10px; }
  .model-menu { max-width:92vw; }
}

/* math */
.katex-display{overflow-x:auto;overflow-y:hidden;margin:.55em 0;padding:2px 0}
.katex{font-size:1.03em}
.md-table-wrap .katex{font-size:1em}

.mem-company { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); padding: 10px 12px; }
.mem-company summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--fg); }
.mem-company summary::-webkit-details-marker { display: none; }
.mem-company summary::before { content: "▸"; color: var(--muted); font-size: 11px; transition: transform .15s; }
.mem-company[open] summary::before { transform: rotate(90deg); }
.mem-company-tag { font-size: 11px; font-weight: 400; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.mem-company .set-note { margin-top: 8px; }
.mem-company .mem-list { margin-bottom: 0; }


.msg-file.msg-image{display:block;max-width:360px;padding:6px;background:var(--panel,#fff);border:1px solid var(--line,#e5e5e5);border-radius:12px}
.msg-file.msg-image .msg-image-preview{display:block;width:100%;max-height:360px;object-fit:contain;border-radius:8px;margin-bottom:6px;background:#f4f4f4}
.msg-file.msg-image .fn{display:block;font-size:12px;opacity:.75;word-break:break-all}


.msg-inline-image{display:block;max-width:min(100%,420px);max-height:420px;object-fit:contain;border-radius:12px;cursor:zoom-in;background:#f4f4f4}
