:root {
  --accent: #0080E0;
  --accent-2: #0ea5e9;
  --accent-3: #4f46e5;
  --bg: #f4f7fc;
  --card: rgba(255,255,255,.72);
  --fg: #0f172a;
  --muted: #64748b;
  --border: rgba(148,163,184,.22);
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #f43f5e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(0,128,224,.14), transparent 60%),
    radial-gradient(600px 500px at 85% 20%, rgba(79,70,229,.12), transparent 60%),
    radial-gradient(500px 500px at 50% 90%, rgba(14,165,233,.10), transparent 60%);
}
.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-screen { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--card); backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 48px 56px; text-align: center; width: 420px;
  box-shadow: 0 20px 60px rgba(15,23,42,.10), inset 0 1px 0 rgba(255,255,255,.7);
}
.login-logo { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 8px 24px rgba(0,128,224,.25); }
.login-title { font-size: 30px; margin: 18px 0 8px; letter-spacing: -.5px; }
.login-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 28px; line-height: 1.5; }
.login-foot { color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff; border: none; border-radius: 12px; padding: 12px 28px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,128,224,.28);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0,128,224,.34); }
.btn-primary:active { transform: translateY(0); }
.btn-mini { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px; }

/* ---------- 主界面布局 ---------- */
#screen-main { display: flex; }
.sidebar {
  width: 260px; min-width: 260px; background: rgba(255,255,255,.6);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  backdrop-filter: blur(12px);
}
.sidebar-top { padding: 14px; }
.btn-newchat {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--fg); cursor: pointer; font-size: 14px;
}
.btn-newchat:hover { border-color: var(--accent); color: var(--accent); }
.bot-list { flex: 1; overflow-y: auto; padding: 4px 10px; }
.bot-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  cursor: pointer; transition: background .12s;
}
.bot-item:hover { background: rgba(0,128,224,.07); }
.bot-item.active { background: rgba(0,128,224,.13); }
.bot-avatar { width: 36px; height: 36px; border-radius: 10px; }
.bot-meta { flex: 1; min-width: 0; }
.bot-name { font-size: 14px; font-weight: 600; }
.bot-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-bottom { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.side-btn {
  text-align: left; padding: 9px 12px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--fg);
}
.side-btn:hover { background: rgba(0,128,224,.08); }

/* ---------- 聊天区 ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,.5); backdrop-filter: blur(8px);
}
.chat-bot-icon { width: 38px; height: 38px; border-radius: 10px; }
.chat-bot-name { font-size: 16px; font-weight: 700; }
.chat-bot-desc { font-size: 12px; color: var(--muted); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 20px; }
.empty-hint { text-align: center; margin-top: 120px; color: var(--muted); }
.empty-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; }
.empty-hint h2 { color: var(--fg); font-size: 22px; margin-bottom: 6px; }
.empty-hint p { font-size: 14px; }

.msg { display: flex; gap: 12px; margin-bottom: 20px; max-width: 760px; }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; }
.msg-bubble {
  padding: 12px 16px; border-radius: 14px; font-size: 14.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.msg.bot .msg-bubble { background: rgba(255,255,255,.85); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.user .msg-bubble { background: linear-gradient(135deg, var(--accent), var(--accent-3)); color: #fff; border-top-right-radius: 4px; }
.msg.error .msg-bubble { background: rgba(244,63,94,.08); border: 1px solid rgba(244,63,94,.3); color: var(--danger); }
.msg .typing { color: var(--muted); }

/* ---------- 输入栏 ---------- */
.chat-input-bar { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); background: rgba(255,255,255,.5); }
.chat-input-bar textarea {
  flex: 1; resize: none; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 14.5px; font-family: inherit; background: #fff; outline: none; max-height: 160px;
}
.chat-input-bar textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,128,224,.12); }
.btn-send {
  width: 44px; height: 44px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-3)); color: #fff; font-size: 20px;
  align-self: flex-end; box-shadow: 0 6px 16px rgba(0,128,224,.28);
}
.btn-send:disabled { opacity: .4; cursor: default; }

/* ---------- 模态面板 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); }
.modal-card { background: #fff; border-radius: 18px; width: 520px; max-width: 92vw; max-height: 84vh; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-close { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; overflow-y: auto; max-height: calc(84vh - 60px); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--fg); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(0,128,224,.12); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.status { margin-top: 12px; font-size: 13px; min-height: 18px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

/* ---------- 用量 ---------- */
.usage-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.usage-card { background: rgba(0,128,224,.05); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.usage-card .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.usage-card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.usage-list { font-size: 13px; }
.usage-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- 账户 ---------- */
.accounts-list { margin-top: 16px; }
.acct-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.acct-item .name { font-weight: 600; font-size: 14px; }
.acct-item .email { font-size: 12px; color: var(--muted); }
.acct-item button { margin-left: auto; border: none; background: transparent; color: var(--danger); cursor: pointer; }

details { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details p { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ---------- 右侧 Bot 详情面板 ---------- */
.detail-panel {
  width: 300px; min-width: 300px; background: rgba(255,255,255,.72);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  backdrop-filter: blur(12px);
}
.detail-head { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); }
.detail-avatar { width: 44px; height: 44px; border-radius: 12px; }
.detail-head-meta { flex: 1; min-width: 0; }
.detail-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-del { border: none; background: transparent; cursor: pointer; font-size: 16px; opacity: .6; }
.detail-del:hover { opacity: 1; }
.detail-tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 10px 0; border: none; background: transparent; cursor: pointer;
  font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.detail-body { flex: 1; overflow-y: auto; padding: 16px 14px; }
.tab-panel.hidden { display: none; }
.section { margin-bottom: 20px; }
.section-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.section-hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.detail-panel .field { margin-bottom: 12px; }
.detail-panel .field label { font-size: 12px; }
.detail-panel .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* ---------- 资料库 ---------- */
.kb-list { margin-bottom: 12px; }
.kb-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.kb-item .kb-name { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.kb-item .kb-name button { border: none; background: transparent; color: var(--danger); cursor: pointer; font-size: 12px; }
.kb-item .kb-content { color: var(--muted); font-size: 12px; max-height: 60px; overflow: hidden; }
.kb-add { display: flex; flex-direction: column; gap: 8px; }
.kb-add input, .kb-add textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; resize: vertical;
}

/* ---------- 头像选择 ---------- */
.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-picker .ico {
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer; border: 2px solid transparent;
}
.icon-picker .ico.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,128,224,.15); }

/* ---------- 登录/注册 ---------- */
.auth-tabs { display: flex; gap: 6px; margin: 16px 0; background: rgba(148,163,184,.12); border-radius: 10px; padding: 4px; }
.auth-tab { flex: 1; padding: 8px 0; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.auth-tab.active { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.auth-method { display: flex; gap: 6px; margin-bottom: 12px; }
.method-btn { flex: 1; padding: 7px 0; border: 1px solid var(--border); background: transparent; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.method-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(0,128,224,.06); font-weight: 600; }
.remember { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.remember input { width: auto !important; accent-color: var(--accent); }
.account-meta { cursor: pointer; }
.status { font-size: 13px; margin-top: 10px; min-height: 18px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
#auth-login, #auth-register { display: flex; flex-direction: column; gap: 12px; }
#auth-login .field, #auth-register .field { margin-bottom: 0; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }
.login-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(0,128,224,.12); }
.login-foot.status.err { color: var(--danger); }
.login-foot.status.ok { color: var(--ok); }

/* ---------- 账号栏 ---------- */
.account-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.account-avatar { width: 34px; height: 34px; border-radius: 10px; }
.account-meta { flex: 1; min-width: 0; }
.account-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-email { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-logout { border: none; background: transparent; cursor: pointer; font-size: 15px; opacity: .55; }
.account-logout:hover { opacity: 1; color: var(--danger); }

/* ---------- Bot 子菜单 & 分组 ---------- */
.bot-item { position: relative; }
.bot-more {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; font-size: 17px; color: var(--muted);
  cursor: pointer; opacity: 0; padding: 3px 7px; border-radius: 6px; transition: opacity .15s;
}
.bot-item:hover .bot-more { opacity: 1; }
.bot-more:hover { background: rgba(0,0,0,.06); color: var(--accent); }
.bot-menu {
  position: fixed; z-index: 9999; min-width: 190px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 32px rgba(15,23,42,.18); padding: 6px;
}
.menu-item { padding: 9px 12px; border-radius: 8px; font-size: 13.5px; cursor: pointer; color: var(--fg); white-space: nowrap; }
.menu-item:hover { background: rgba(0,128,224,.08); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(225,29,72,.08); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.unread-dot { display: inline-block; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.pin-mark { font-size: 11px; margin-left: 4px; opacity: .85; }
.bot-item.pinned { background: rgba(0,128,224,.05); }
.bot-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 12px 14px 4px; font-weight: 700; }
.bot-group.hidden-head { cursor: pointer; }
.bot-group.hidden-head:hover { color: var(--accent); }

/* ---------- 通用 prompt 模态 & row ---------- */
.modal-card.small { width: 330px; }
#prompt-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
#prompt-input:focus { border-color: var(--accent); outline: none; }
.row { display: flex; align-items: center; }
#auth-register .field input, #auth-login .field input { width: 100%; }
.detail-panel .field select { width: 100%; }

/* ---------- 会话切换器 ---------- */
.chat-head-meta { flex: 1; min-width: 0; }
.chat-header-right { display: flex; align-items: center; gap: 8px; }
.conv-switcher { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; max-width: 240px; background: rgba(255,255,255,.6); }
.conv-switcher:hover { border-color: var(--accent); }
.conv-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.conv-caret { color: var(--muted); font-size: 11px; }
.btn-newconv { border: 1px solid var(--border); background: rgba(255,255,255,.6); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--accent); }
.btn-newconv:hover { border-color: var(--accent); background: rgba(0,128,224,.06); }
.conv-menu { position: fixed; z-index: 9999; min-width: 220px; max-width: 300px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 32px rgba(15,23,42,.18); padding: 6px; }
.conv-menu .menu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-menu .menu-item.active { background: rgba(0,128,224,.08); }
.conv-item-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-del { opacity: 0; font-size: 12px; padding: 2px 4px; border-radius: 4px; }
.conv-menu .menu-item:hover .conv-item-del { opacity: .7; }
.conv-item-del:hover { opacity: 1; color: var(--danger); }
.menu-item.muted { color: var(--muted); cursor: default; }

/* ---------- 输入框增强（附件/朗读）+ 分组折叠 ---------- */
.chat-input-wrap { border-top: 1px solid var(--border); background: rgba(255,255,255,.6); padding: 8px 12px; }
.chat-input-bar { display: flex; align-items: flex-end; gap: 8px; }
.btn-attach, .btn-speak { border: 1px solid var(--border); background: rgba(255,255,255,.7); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 15px; flex: none; display: flex; align-items: center; justify-content: center; }
.btn-attach:hover, .btn-speak:hover { border-color: var(--accent); background: rgba(0,128,224,.06); }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.attach-chips:empty { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 14px; background: rgba(0,128,224,.06); }
.attach-chip button { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.attach-chip button:hover { color: var(--danger); }
.bot-group.collapsible { cursor: pointer; user-select: none; }
.bot-group.collapsible:hover { color: var(--accent); }

/* ---------- 设置多分类 ---------- */
.modal-card.wide { width: 780px; max-width: 94vw; }
.settings-body { display: flex; height: 540px; }
.settings-sidebar { width: 160px; border-right: 1px solid var(--border); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; flex: none; }
.set-nav { text-align: left; padding: 10px 12px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.set-nav:hover { background: rgba(0,0,0,.04); }
.set-nav.active { background: rgba(0,128,224,.08); color: var(--accent); font-weight: 600; }
.settings-content { flex: 1; overflow-y: auto; padding: 16px 20px; }
.set-panel.hidden { display: none; }

/* 用量 */
.usage-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.usage-card { background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.usage-card .num { font-size: 20px; font-weight: 700; }
.usage-card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.usage-list .usage-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; gap: 12px; }
.usage-row-name { font-weight: 600; }
.usage-row-val { color: var(--muted); text-align: right; }

/* 连接应用 */
.conn-search input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; margin-bottom: 12px; box-sizing: border-box; }
.conn-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.conn-cat { padding: 6px 14px; border: 1px solid var(--border); background: transparent; border-radius: 16px; cursor: pointer; font-size: 13px; color: var(--muted); }
.conn-cat.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.conn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.conn-card { background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.conn-icon { font-size: 28px; }
.conn-name { font-size: 13px; font-weight: 600; }
.conn-btn { border: 1px solid var(--accent); background: transparent; color: var(--accent); border-radius: 16px; padding: 5px 16px; cursor: pointer; font-size: 12.5px; }
.conn-btn:hover { background: rgba(0,128,224,.08); }
.conn-btn.connected { border-color: var(--border); color: var(--muted); background: rgba(0,0,0,.04); }

/* 账号栏用量 */
.account-usage { font-size: 11px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* 消息附件展示 */
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; }
.msg-files { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.msg-file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.6); font-size: 13px; }
.msg-file-ico { font-size: 16px; }
.msg-file-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { color: var(--muted); font-size: 12px; }
