:root {
  --bg: #0b1020;
  --panel: #131a2e;
  --panel-2: #1b2438;
  --line: #263049;
  --text: #e6ecf7;
  --muted: #8b98b4;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 800px at 20% -10%, #16203a, var(--bg));
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
button {
  cursor: pointer; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; padding: 9px 14px;
  font-size: 14px; transition: .15s;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
input, textarea, select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ---------- login ---------- */
#login {
  min-height: 100%; height: 100%; display: flex; align-items: flex-start;
  justify-content: center; overflow-y: auto; padding: 20px 0;
}
.card {
  width: 400px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; }
.msg { min-height: 20px; font-size: 13px; margin-top: 10px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

/* login tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs button {
  flex: 1; background: transparent; color: var(--muted); padding: 7px 0;
  font-size: 13px; border-radius: 7px;
}
.tabs button.on { background: var(--accent); color: #fff; }

/* ---------- app ---------- */
#app { height: 100%; display: flex; }
.sidebar {
  flex: 0 0 280px; width: 280px; min-width: 0;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px;
  overflow: hidden;
  transition: flex-basis .2s ease, width .2s ease, padding .2s ease;
}
.brand { font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.brand span { color: var(--accent-2); }
.userbox {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin-bottom: 12px; font-size: 12px;
}
.userbox .email { color: var(--muted); word-break: break-all; }
.quota { height: 6px; background: #0d1524; border-radius: 4px; margin-top: 8px; overflow: hidden; }
.quota > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.quota.full > i { background: var(--err); }
.conv-list { flex: 1; overflow-y: auto; margin: 4px -6px; min-height: 0; }
.conv {
  padding: 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent; display: flex; justify-content: space-between; gap: 6px;
}
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--panel-2); border-color: var(--accent); }
.conv .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .del { color: var(--muted); opacity: 0; }
.conv:hover .del { opacity: 1; }
.sidebar-foot { display: flex; gap: 8px; margin-top: 10px; }

/* collapsed sidebar */
.sidebar.collapsed {
  flex: 0 0 0 !important; width: 0 !important; min-width: 0 !important;
  padding: 0 !important; border-right: none;
}

.chat { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 10px;
}
.chat-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; line-height: 1.9; }
.bubble { max-width: 860px; padding: 12px 14px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.bubble .who { font-size: 11px; color: var(--muted); margin-bottom: 6px; }

.step {
  align-self: flex-start; font-size: 12.5px; color: var(--muted);
  background: #0e1626; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; font-family: Consolas, "Cascadia Mono", monospace; max-width: 760px;
  white-space: pre-wrap; word-break: break-word;
}
.step.tool { border-left: 3px solid var(--accent-2); }
.step.result-ok { border-left: 3px solid var(--ok); }
.step.result-err { border-left: 3px solid var(--err); }
.step.done { border-left: 3px solid var(--warn); color: var(--text); }

/* ---------- composer (single source of truth) ---------- */
.composer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 20px 16px;
  display: flex; flex-direction: column; gap: 10px;
  align-items: stretch;
}
.composer textarea {
  resize: none; height: 56px; max-height: 200px;
  line-height: 1.55; width: 100%; display: block; padding: 12px 14px;
}
.comp-row {
  display: flex; gap: 10px; align-items: center;
  width: 100%; min-width: 0;
}
.composer-controls {
  display: flex; gap: 8px; align-items: center;
  flex: 1 1 auto; min-width: 0; flex-wrap: wrap;
}
.composer .send {
  height: 36px; padding: 0 24px; flex: 0 0 auto; border-radius: 8px;
  font-size: 13.5px;
}

/* ---------- chat enhancements (notice / search / templates / counter) ---------- */
.notice {
  padding: 9px 20px 9px 46px; font-size: 13px; line-height: 1.5;
  background: rgba(59, 130, 246, .12); color: var(--text);
  border-bottom: 1px solid var(--line); word-break: break-word;
}
/* Sidebar open: the toggle sits on the sidebar edge, so the notice needs
   no left clearance. Collapsed: the fixed toggle floats at left:0 and
   would cover the first characters of the notice — reserve room for it. */
#app:not(.sb-collapsed) .notice { padding-left: 20px; }
.notice.warn { background: rgba(245, 158, 11, .14); color: var(--warn); }
.conv-search {
  width: 100%; margin: 6px 0 2px; padding: 7px 10px; font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; outline: none;
}
.conv-search:focus { border-color: var(--accent); }
.templates { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
  white-space: nowrap; transition: .15s;
}
.tpl:hover { color: var(--text); border-color: var(--accent); }
.char-count { font-size: 12px; color: var(--muted); flex: 0 0 auto; padding-left: 4px; }
.head-btn { padding: 5px 12px !important; font-size: 12.5px !important; flex: 0 0 auto; }
.bubble { position: relative; }
.copy-btn {
  margin-top: 8px; background: transparent; border: 1px solid var(--line);
  color: var(--muted); border-radius: 6px; padding: 2px 10px; font-size: 11.5px; cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- files drawer ---------- */
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 380px; background: var(--panel);
  border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; z-index: 20;
  box-shadow: -20px 0 50px rgba(0,0,0,.4);
}
.drawer h3 { margin: 0 0 12px; font-size: 15px; }
.file {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  font-size: 12.5px;
}
.file a { color: var(--accent-2); text-decoration: none; word-break: break-all; }
.drawer .foot { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- settings ---------- */
.settings { font-size: 12px; color: var(--muted); margin-top: 10px; }
.settings input { font-size: 12px; padding: 7px 9px; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 20px; font-size: 11px;
  white-space: nowrap; flex: 0 0 auto; }
.tag.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.tag.err { background: rgba(239,68,68,.15); color: var(--err); }
.tag.mode { background: rgba(34,211,238,.15); color: var(--accent-2); }

/* ---------- selectors ---------- */
.model-select, .mode-select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 0 10px; height: 36px; font-size: 12.5px;
  cursor: pointer; outline: none; width: auto; flex: 0 1 auto;
}
.model-select { max-width: 240px; }
.mode-select { max-width: 220px; }
.model-select:focus, .mode-select:focus { border-color: var(--accent); }
.model-select optgroup { color: var(--accent-2); font-weight: 600; }
.model-select option { padding: 4px 8px; }

/* ---------- sidebar toggle ---------- */
.sidebar-toggle {
  position: fixed; left: 0; top: 12px; z-index: 40;
  background: var(--panel); border: 1px solid var(--line);
  border-left: none; border-radius: 0 8px 8px 0;
  width: 30px; height: 44px; padding: 0; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: var(--panel-2); }
/* when sidebar is open, keep the button just outside its right edge */
#app:not(.sb-collapsed) .sidebar-toggle { left: 280px; transition: left .2s ease; }

/* ---------- files-in-chat chips ---------- */
.files-chips {
  margin-top: 10px; display: flex; flex-direction: column; gap: 6px;
}
.file-chip {
  display: flex; align-items: center; gap: 10px;
  background: #0e1626; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 12.5px;
}
.file-chip .icon { font-size: 15px; }
.file-chip .fc-name {
  color: var(--accent-2); word-break: break-all;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-chip .fc-name:hover { text-decoration: underline; }
.file-chip .fc-size { color: var(--muted); font-size: 11.5px; flex-shrink: 0; }
.file-chip .fc-del, .file-chip .fc-prev, .file-chip .fc-dl {
  background: transparent; border: none; cursor: pointer;
  padding: 2px 6px; font-size: 14px; border-radius: 4px; color: var(--muted);
  text-decoration: none; flex: 0 0 auto;
}
.file-chip .fc-del:hover { color: var(--err); background: rgba(239,68,68,.1); }
.file-chip .fc-prev:hover, .file-chip .fc-dl:hover { color: var(--accent-2); background: rgba(34,211,238,.1); }

/* ---------- files drawer rows ---------- */
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 6px; background: var(--panel-2);
}
.fr-main { flex: 1; min-width: 0; }
.fr-name {
  font-size: 13px; color: var(--text); word-break: break-all;
  display: flex; align-items: center; gap: 6px;
}
.fr-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.fr-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fr-actions .btn {
  padding: 6px 12px; font-size: 12.5px; border-radius: 6px;
  text-decoration: none; display: inline-block; text-align: center;
}
.fr-actions .btn-dl { background: var(--accent); color: #fff; }
.fr-actions .btn-dl:hover { filter: brightness(1.1); }
.fr-actions .btn-del {
  background: transparent; border: 1px solid var(--err); color: var(--err);
}
.fr-actions .btn-del:hover { background: rgba(239,68,68,.1); }
.btn.btn-prev { background: var(--accent-2); color: #0a1020; }
.btn.btn-prev:hover { filter: brightness(1.1); }

/* ---------- drawer head ---------- */
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-head h3 { margin: 0; }
.wide-drawer { width: 480px; }

/* ---------- tags ---------- */
.tag.tier { background: rgba(245,158,11,.16); color: var(--warn); }
.tag.danger { background: rgba(239,68,68,.15); color: var(--err); }

/* ---------- files: multi-select batch bar ---------- */
.files-usage-bar {
  color: var(--muted); font-size: 12px; margin-bottom: 10px;
  padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px;
}
.batchbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 10px;
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.35);
  border-radius: 8px; font-size: 12.5px;
}
.batch-all { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.batchbar button {
  padding: 5px 12px; font-size: 12px; border-radius: 6px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
}
.batchbar button:disabled { opacity: .45; cursor: not-allowed; }
.batchbar .danger { border-color: var(--err); color: var(--err); }
.fr-pick { display: flex; align-items: center; flex: 0 0 auto; cursor: pointer; }
.fr-pick input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.file-row:has(.fr-check:checked) { border-color: var(--accent); background: rgba(59,130,246,.08); }

/* ---------- mini toast ---------- */
.mini-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px);
  background: rgba(17,24,39,.96); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 80;
  opacity: 0; pointer-events: none; transition: .2s;
}
.mini-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- quota request ---------- */
.qreq-status { display: none; margin-bottom: 10px; }
.qreq-status.show { display: block; }
.me-field.row { display: flex; gap: 8px; align-items: center; }
.me-field.row input { margin-bottom: 0; }
#file-mail-modal .me-field { margin-bottom: 8px; }
#file-mail-modal label { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }

/* ---------- composer polish ---------- */
.composer { border-top: 1px solid var(--line); background: var(--panel); }
.model-select, .mode-select { transition: border-color .15s, box-shadow .15s; }
.model-select:hover, .mode-select:hover { border-color: var(--accent); }

/* ---------- login: forgot password ---------- */
.forgot-row { margin-top: 10px; text-align: center; }
.forgot-row a { color: var(--accent); font-size: 13px; text-decoration: none; }
.forgot-row a:hover { text-decoration: underline; }
.forgot-sep { color: var(--muted); margin: 0 8px; }
.unfreeze-banner {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 8px; padding: 9px 11px; font-size: 12.5px; line-height: 1.6;
  margin-bottom: 10px;
}
.uf-questions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.uf-q label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
  line-height: 1.5; }
.uf-q input, .uf-q select { width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel); color: var(--text); box-sizing: border-box; }
.uf-q select:disabled, .uf-q input:disabled, textarea:disabled,
#uf-email:disabled { opacity: .65; }

/* ---------- feedback routing + history ---------- */
.fb-target { display: flex; flex-direction: column; gap: 6px; }
.fb-target label { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px;
  align-items: flex-start; cursor: pointer; }
.my-fb-head { display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; margin-bottom: 8px; }
.my-fb-list { display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto; padding-right: 4px; }
.myfb-item { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  background: var(--panel-2); }
.myfb-head { display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  font-size: 11.5px; margin-bottom: 5px; }
.myfb-tag { padding: 1px 8px; border-radius: 999px; font-size: 11px; }
.myfb-tag.mail { background: #fef3c7; color: #92400e; }
.myfb-tag.admin { background: #dbeafe; color: #1e40af; }
.myfb-cat { color: var(--text); font-weight: 600; }
.myfb-body { font-size: 12.5px; line-height: 1.7; white-space: pre-wrap;
  word-break: break-word; }
.myfb-reply { margin-top: 6px; padding: 7px 9px; background: #f0fdf4;
  border-radius: 6px; font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; }
.myfb-revoke { margin-top: 6px; font-size: 12px; padding: 3px 10px; }

/* ---------- personal notice scope tag ---------- */
.nt-scope { display: inline-block; margin-right: 6px; padding: 0 7px;
  border-radius: 999px; font-size: 10.5px; font-weight: 600;
  background: #ede9fe; color: #6d28d9; vertical-align: 1px; }

/* ---------- sidebar service notifications ---------- */
.nt-badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  padding: 0 5px; margin-left: 5px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 11px; text-align: center;
}
.nt-list { display: flex; flex-direction: column; gap: 9px;
  max-height: calc(100vh - 220px); overflow-y: auto; padding-right: 4px; }
.nt-card {
  padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; cursor: pointer; transition: border-color .15s, background .15s;
}
.nt-card:hover { border-color: var(--accent); }
.nt-card.unread { border-left: 3px solid var(--accent); }
.nt-card.unread .nt-card-title { color: var(--accent); }
.nt-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.nt-card-title { font-weight: 600; font-size: 13.5px; }
.nt-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.nt-card-preview { color: var(--muted); font-size: 12.5px; margin-top: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-back { margin-bottom: 12px; }
.nt-detail-title { margin: 0 0 10px; font-size: 17px; }
.nt-detail-meta { color: var(--muted); font-size: 12.5px; line-height: 1.9;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.nt-detail-body { font-size: 13.5px; line-height: 1.85; white-space: pre-wrap;
  word-break: break-word; }

/* ---------- preview drawer ---------- */
.preview-iframe {
  width: 100%; height: calc(100vh - 100px); border: none; border-radius: 8px;
  background: #fff;
}
.preview-pre {
  background: #0a1020; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; font-size: 12.5px; line-height: 1.65; max-height: calc(100vh - 100px);
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: Consolas, "Cascadia Mono", monospace; color: #d4e3ff;
}

/* ---------- file content (binary-safe) ---------- */
.binary-note { color: var(--warn); font-size: 12.5px; }

/* ---------- modal (e.g. set login password) ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(5,9,20,.66);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.modal-box {
  width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.6);
}
.modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.modal-box p { margin: 0 0 14px; font-size: 12.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- responsive guards (avoid squeeze/overflow) ---------- */
@media (max-width: 760px) {
  .sidebar { flex: 0 0 180px; width: 180px; padding: 12px; }
  .chat-head { flex-wrap: wrap; }
  .chat-head h2 { flex-basis: 100%; }
  .messages { padding: 14px; }
  .composer { padding: 12px 14px; }
  .notice { padding: 9px 14px; }
  /* collapsed toggle overlaps the notice on small screens too */
  #app.sb-collapsed .notice { padding-left: 40px; }
  .drawer { width: 100%; }
  .comp-row { flex-wrap: wrap; }
  .model-select, .mode-select, .agent-select { flex: 1 1 45%; min-width: 0; max-width: 100%; }
  .composer .send { flex: 1 1 100%; }
}

/* ---------- sidebar account mini-button ---------- */
.me-btn { display: flex; align-items: center; gap: 8px; justify-content: center; }
.me-mini {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; overflow: hidden;
}
.me-mini img { width: 100%; height: 100%; object-fit: cover; }
.me-mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- agent (domain) selector ---------- */
.agent-select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 0 10px; height: 36px; font-size: 12.5px;
  cursor: pointer; outline: none; width: auto; flex: 0 1 auto; max-width: 190px;
}
.agent-select:focus { border-color: var(--accent); }

/* ---------- account panel ---------- */
.me-block {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); padding: 14px; margin-bottom: 14px;
}
.me-title { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; color: var(--text); }
.me-field { margin-bottom: 10px; }
.me-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.me-field textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.me-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.me-inline button { padding: 8px 16px; font-size: 13px; flex: 0 0 auto; }
.me-msg { font-size: 12.5px; color: var(--muted); }
.me-msg.ok { color: var(--ok); }
.me-msg.err { color: var(--err); }
.me-hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.me-kv {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px;
  padding: 5px 0; color: var(--muted);
}
.me-kv b { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }
.me-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.me-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 56px;
  background: var(--bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden;
}
.me-avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-avatar-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.me-avatar-acts button { padding: 6px 12px; font-size: 12.5px; }

/* ---------- login: local entry ---------- */
.local-entry { margin-top: 14px; }
.local-hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin-top: 8px; }

/* ---------- mandatory legal agreement overlay ---------- */
.legal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(5, 8, 18, .82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.legal-overlay.hidden { display: none; }
.legal-box {
  width: 760px; max-width: 100%; max-height: 92vh; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.legal-box h2 { margin: 0; font-size: 19px; }
.legal-meta { font-size: 12.5px; }
.legal-body {
  flex: 1 1 auto; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); padding: 16px 18px; font-size: 13.5px; line-height: 1.85;
  color: var(--text); white-space: pre-wrap;
}
.legal-body h3 { font-size: 15px; margin: 18px 0 6px; color: var(--accent-2); }
.legal-body h3:first-child { margin-top: 0; }
.legal-agree {
  display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px;
  line-height: 1.6; cursor: pointer; user-select: none;
}
.legal-agree input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.legal-box .modal-foot { margin: 0; }
#legal-ok:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- offline local mode ---------- */
#local { height: 100%; display: flex; }

/* ---------- local model setup modal ---------- */
.modal-box.wide { width: 520px; max-width: calc(100vw - 32px); }
.modal-box .muted { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.local-note {
  font-size: 12.5px; padding: 9px 12px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 12px;
  color: var(--muted);
}
.local-models { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.local-model {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  cursor: pointer;
}
.local-model:hover { border-color: var(--accent); }
.local-model input { width: auto; margin-top: 3px; flex: 0 0 auto; }
.local-model.loaded { border-color: var(--ok); }
.lm-info { min-width: 0; }
.lm-name { font-size: 13.5px; font-weight: 600; }
.lm-note { font-size: 12px; color: var(--muted); margin-top: 3px; }
.lm-ok { color: var(--ok); font-weight: 400; font-size: 12px; margin-left: 6px; }
.local-progress { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.lp-text { margin-bottom: 6px; word-break: break-all; }
.lp-bar { height: 6px; border-radius: 4px; background: #0d1524; overflow: hidden; }
.lp-bar > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .15s ease;
}
