/* ==========================================================================
   ChatDock · 界面风格对齐 DeepSeek 网页版
   浅色主题 / 品牌蓝 #4d6bfe / Inter 字体 / 居中内容区 / 大圆角输入框
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-soft-2: #f2f4f7;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --border: #e6e8ee;
  --border-strong: #d9dce4;
  --text: #1b1c1f;
  --text-2: #3c3f45;
  --muted: #7d7f85;
  --muted-2: #979da6;
  --accent: #4d6bfe;
  --accent-hover: #3f5cf0;
  --accent-weak: #eef2ff;
  --accent-weak-2: #e4ebff;
  --danger: #ff5a5a;
  --danger-weak: #fff1f1;
  --user-bubble: #eff2fb;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > button { flex-shrink: 0; white-space: nowrap; }
.row > input[type="file"] { flex: 1; min-width: 0; }
.row > input:not([type="file"]) { flex: 1; min-width: 0; }
.row-end { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: #fff; }
textarea { resize: vertical; font-family: inherit; }
code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ---------------- 按钮 ---------------- */

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary.small { padding: 6px 12px; font-size: 13px; }
.btn-primary.wide { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.btn-ghost.tiny { padding: 3px 9px; font-size: 12px; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* ---------------- 登录 ---------------- */

.auth {
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.auth-card {
  width: 384px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(24, 34, 68, .06);
}
.auth-card h1 { margin: 14px 0 4px; font-size: 22px; letter-spacing: -.01em; }
.logo {
  width: 56px; height: 56px; border-radius: 16px;
  object-fit: contain; background: #fff;
  margin: 0 auto 2px; display: block;
}
.tabs {
  display: flex; gap: 4px; background: var(--panel-2);
  padding: 4px; border-radius: 11px; margin: 22px 0 18px;
}
.tab {
  flex: 1; background: transparent; border: none; padding: 7px; border-radius: 8px;
  color: var(--muted); cursor: pointer; font-size: 14px;
}
.tab.active { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
#auth-form { display: flex; flex-direction: column; gap: 12px; }

/* ---------------- 布局 ---------------- */

.app { display: grid; grid-template-columns: 264px 1fr; height: 100%; }

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-head { padding: 16px 16px 10px; display: flex; align-items: center; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--accent); font-size: 16px; letter-spacing: -.01em;
}
.brand-logo {
  width: 22px; height: 22px; object-fit: contain; flex-shrink: 0;
  border-radius: 6px;
}

.new-chat {
  margin: 0 14px 10px;
  height: 38px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.new-chat:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }

.search-wrap { position: relative; margin: 0 14px 8px; }
.search-ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); display: flex; pointer-events: none;
}
.search {
  margin: 0;
  width: 100%;
  height: 34px;
  padding: 0 38px 0 32px;
  font-size: 13px;
  background: var(--bg-soft-2);
  border: 1px solid transparent;
  border-radius: 10px;
}
.search:focus { background: #fff; border-color: var(--accent); }
.search-action {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.search-action:hover { background: #e9ecf3; color: var(--accent); }
.search-action.active { background: var(--accent-weak); color: var(--accent); }
.search-action.active:hover { background: var(--accent-weak-2); }

.conv-toolbar { display: flex; align-items: center; gap: 8px; padding: 0 16px 8px; }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; min-height: 0; }
.conv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-size: 14px;
  transition: background .12s;
}
.conv-item:hover { background: #eceef4; }
.conv-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 500; }
.conv-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.selected { background: var(--accent-weak-2); }

.conv-check { width: 14px; height: 14px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.pin-mark { font-size: 11px; flex-shrink: 0; opacity: .9; }
.conv-actions { display: none; align-items: center; gap: 2px; flex-shrink: 0; }
.conv-item:hover .conv-actions { display: flex; }
.conv-act {
  background: transparent; border: none; color: var(--muted-2);
  cursor: pointer; padding: 2px; line-height: 1;
  display: inline-flex; align-items: center; border-radius: 6px;
}
.conv-act:hover { color: var(--accent); background: var(--accent-weak); }
.conv-act.on { color: var(--accent); }
.conv-act.danger:hover { color: var(--danger); background: var(--danger-weak); }
.rename-input {
  flex: 1; min-width: 0; padding: 3px 6px; font-size: 13px;
  background: #fff; border: 1px solid var(--accent); border-radius: 6px;
}
.conv-empty { color: var(--muted-2); font-size: 13px; padding: 18px 10px; text-align: center; }

.select-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-top: 1px solid var(--border);
  background: #fff;
}
.select-bar .small {
  margin-right: auto; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.select-bar button { white-space: nowrap; flex-shrink: 0; }

.sidebar-foot { padding: 10px 14px 12px; border-top: 1px solid var(--border); position: relative; }
.balance-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.balance { font-size: 13px; color: var(--accent); font-weight: 600; margin-right: auto; }
.user-badge { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-buttons { display: flex; gap: 6px; margin-top: 8px; }
.foot-buttons .btn-ghost { flex: 1; padding: 5px 6px; }

/* 底部用户菜单 */
.user-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px; border: none; background: transparent;
  border-radius: 10px; cursor: pointer; text-align: left;
}
.user-row:hover { background: #eceef4; }
.avatar-initial {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #4d6bfe, #8b9bff);
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-email { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-points { font-size: 11px; color: var(--accent); font-weight: 600; }
.user-more { color: var(--muted-2); display: flex; flex-shrink: 0; }

.menu {
  position: absolute; left: 14px; right: 14px; bottom: calc(100% + 4px);
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 14px 40px rgba(20, 28, 50, .16);
  z-index: 30;
}
.menu-label { font-size: 11px; color: var(--muted-2); padding: 6px 10px 3px; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-2);
  text-align: left;
}
.menu-item:hover { background: var(--bg-soft-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-weak); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }

/* ---------------- 主区 ---------------- */

.main { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.topbar {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  gap: 16px;
}
.conv-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.messages { flex: 1; overflow-y: auto; padding: 8px 0 4px; min-height: 0; }
.empty-state { text-align: center; margin-top: 14vh; }
.empty-logo {
  width: 64px; height: 64px; border-radius: 18px;
  object-fit: contain; background: #fff;
  margin: 0 auto 16px; display: block;
}
.empty-state h2 { margin: 8px 0 6px; font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.empty-actions { margin-top: 20px; display: flex; justify-content: center; gap: 10px; }

/* ---------------- 消息 ---------------- */

.msg {
  display: flex; gap: 10px;
  max-width: 780px; margin: 0 auto;
  padding: 10px 24px;
}
.msg .avatar, .msg .role-name { display: none; }
.msg .body { min-width: 0; }
.msg.user { justify-content: flex-end; }
.msg.user .body {
  max-width: 78%;
  display: flex; flex-direction: column; align-items: flex-end;
}
.msg.user .bubble {
  background: var(--user-bubble);
  border-radius: 18px;
  padding: 10px 16px;
  max-width: 100%;
}
.msg.user .msg-actions { justify-content: flex-end; }
.msg.assistant .body { width: 100%; }
.msg .content { word-wrap: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.75; color: var(--text); }
.msg.user .content { line-height: 1.6; }

.msg .content p { margin: 0 0 10px; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content h1, .msg .content h2, .msg .content h3, .msg .content h4 {
  margin: 20px 0 10px; line-height: 1.4; font-weight: 600; letter-spacing: -.01em;
}
.msg .content h1 { font-size: 21px; }
.msg .content h2 { font-size: 18px; }
.msg .content h3 { font-size: 16px; }
.msg .content ul, .msg .content ol { padding-left: 22px; margin: 10px 0; }
.msg .content li { margin: 4px 0; }
.msg .content a { color: var(--accent); text-decoration: none; }
.msg .content a:hover { text-decoration: underline; }
.msg .content pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px;
  overflow-x: auto; margin: 12px 0;
}
.msg .content pre code { background: none; padding: 0; font-size: 13px; }
.msg .content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.msg .content th, .msg .content td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.msg .content th { background: var(--bg-soft); font-weight: 600; }
.msg .content blockquote {
  margin: 12px 0; padding: 2px 14px; border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.msg .content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

details.reasoning {
  margin-bottom: 10px; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; color: var(--muted); font-size: 13px;
  background: var(--bg-soft);
}
details.reasoning summary { cursor: pointer; user-select: none; color: var(--muted); }
/* 思考链保留换行 */
details.reasoning > div {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  margin-top: 6px;
  max-height: 50vh;
  overflow-y: auto;
}

.msg-actions {
  margin-top: 8px; display: flex; gap: 2px; flex-wrap: wrap;
  opacity: 0; transition: opacity .15s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-act {
  width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: none; color: var(--muted-2);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.msg-act:hover { color: var(--accent); background: var(--accent-weak); }

/* 联网搜索过程 */
.search-block {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 12px; background: var(--bg-soft);
}
.search-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.search-items { display: flex; flex-direction: column; gap: 6px; }
.search-step { font-size: 13px; color: var(--muted); }
.search-step.error { color: var(--danger); }
.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.search-result {
  display: block; text-decoration: none;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; background: #fff;
}
.search-result:hover { border-color: var(--accent); }
.sr-title { color: var(--text); font-size: 13px; font-weight: 500; }
.sr-meta { color: var(--muted-2); font-size: 11px; margin-top: 2px; }
.sr-snippet {
  color: var(--muted); font-size: 12px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 引用来源 */
.sources { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.sources-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.source-item { font-size: 12px; display: flex; gap: 6px; align-items: baseline; margin: 3px 0; }
.source-index { color: var(--accent); flex-shrink: 0; }
.source-item a { color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item a:hover { color: var(--accent); text-decoration: underline; }

/* 分支切换器 */
.branch-bar { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.branch-btn {
  background: #fff; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; width: 22px; height: 22px; cursor: pointer; line-height: 1; font-size: 13px; padding: 0;
}
.branch-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.branch-btn:disabled { opacity: .35; cursor: default; }
.branch-label { color: var(--muted); }

/* 编辑消息 */
.edit-box { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.edit-box textarea { width: 100%; background: #fff; }

/* 附件 */
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 9px; padding: 4px 8px; font-size: 12px; max-width: 280px;
}
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .kind { color: var(--muted-2); font-size: 11px; flex-shrink: 0; }
.attach-chip button { background: none; border: none; color: var(--muted-2); cursor: pointer; padding: 0 2px; font-size: 12px; }
.attach-chip button:hover { color: var(--danger); }
.attach-chip.uploading { opacity: .55; }
.attach-thumb { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; flex-shrink: 0; background: #eee; }
.attach-image {
  width: 108px; height: 108px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border);
  cursor: zoom-in; background: var(--bg-soft-2);
  transition: transform .15s;
}
.attach-image:hover { transform: scale(1.02); }

/* ---------------- 输入区 ---------------- */

.composer-wrap {
  flex-shrink: 0;
  max-width: 780px; width: 100%; margin: 0 auto;
  padding: 8px 24px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.composer-box {
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: #fff;
  padding: 12px 14px 8px;
  box-shadow: 0 2px 12px rgba(24, 34, 68, .05);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 2px 16px rgba(77, 107, 254, .12);
}
.composer-box textarea {
  border: none; background: transparent; padding: 2px 4px;
  min-height: 26px; max-height: 200px; width: 100%;
  font-size: 15px; line-height: 1.6; resize: none; outline: none;
}
.composer-box textarea:focus { border: none; background: transparent; }

.composer-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 6px;
}
.tools-left, .tools-right { display: flex; align-items: center; gap: 6px; }
.tools-hint { font-size: 12px; }

.tool-pill {
  height: 30px; padding: 0 12px;
  background: #fff; border: 1px solid var(--border);
  color: var(--muted); border-radius: 999px;
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.tool-pill:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.tool-pill.active {
  background: var(--accent-weak); border-color: var(--accent); color: var(--accent); font-weight: 500;
}
.tool-pill.recording { border-color: var(--danger); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.tool-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1;
}
.tool-icon:hover { background: var(--bg-soft-2); color: var(--text); }

.send-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: background .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: #d9ddec; cursor: not-allowed; }

.composer-hint {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted-2); padding: 0 4px;
}

.cursor-blink::after {
  content: '▍'; color: var(--accent); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- 弹窗 ---------------- */

.modal {
  position: fixed; inset: 0; background: rgba(17, 22, 35, .35);
  display: grid; place-items: center; z-index: 50; padding: 24px;
}
.modal-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 16px; width: 640px; max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(20, 28, 50, .18);
}
.modal-card.wide-card { width: 760px; }
.modal-card.narrow-card { width: 460px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-body h3 { font-size: 14px; margin: 0 0 6px; }
.modal-body section { display: flex; flex-direction: column; gap: 8px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.stack-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.add-provider { border-top: 1px solid var(--border); padding-top: 16px; }

.notice {
  background: var(--accent-weak); border: 1px solid var(--accent-weak-2);
  border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--text-2);
  line-height: 1.75;
}
.import-result { font-size: 13px; color: var(--muted); }
.advanced { border-top: 1px solid var(--border); padding-top: 12px; }
.advanced > summary {
  cursor: pointer; color: var(--muted); font-size: 13px;
  list-style: none; user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: '▸ '; }
.advanced[open] > summary::before { content: '▾ '; }
.advanced > section { margin-top: 14px; }

/* 充值：去小店买兑换码 */
.purchase-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.purchase-box .purchase-text { flex: 1; min-width: 0; }
.purchase-box .purchase-title { font-size: 14px; font-weight: 600; }
.purchase-box .purchase-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.purchase-box a.btn-primary { text-decoration: none; white-space: nowrap; }
.test-result { font-size: 13px; white-space: pre-wrap; line-height: 1.6; }
.test-result.ok { color: #19a15f; }
.test-result.bad { color: var(--danger); }

/* 用量 */
.usage-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.usage-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.usage-card .label { font-size: 12px; color: var(--muted); }
.usage-card .value { font-size: 17px; font-weight: 600; margin-top: 2px; }
.usage-list { display: flex; flex-direction: column; }
.usage-row {
  display: grid; grid-template-columns: 1.4fr auto auto; gap: 10px;
  font-size: 12px; padding: 8px 2px; border-bottom: 1px solid var(--border); color: var(--muted);
}
.usage-row .cost { color: var(--accent); }
.usage-empty { color: var(--muted-2); font-size: 13px; padding: 12px 0; }

/* 分支树 */
.tree-body {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 52vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 8px; background: var(--bg-soft);
}
.tree-node {
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--muted);
}
.tree-node:hover { background: var(--accent-weak); color: var(--text); }
.tree-node.on-path { background: var(--accent-weak); color: var(--text); }
.tree-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tree-dot.user { background: var(--accent); }
.tree-dot.assistant { background: #34b47a; }
.tree-role { font-size: 11px; color: var(--muted-2); flex-shrink: 0; }
.tree-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 服务商卡片（历史组件，保留样式） */
.provider-list { display: flex; flex-direction: column; gap: 8px; }
.provider-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 12px;
}
.provider-card .info { flex: 1; min-width: 0; }
.provider-card .name { font-weight: 600; font-size: 14px; }
.provider-card .meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* ---------------- 管理后台 ---------------- */

.admin-page { display: block; background: var(--bg); }
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.admin-head h1 { font-size: 20px; margin: 4px 0 0; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.admin-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.admin-card .label { font-size: 12px; color: var(--muted); }
.admin-card .value { font-size: 21px; font-weight: 700; margin-top: 4px; }
.admin-section { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 18px; }
.admin-section h2 { font-size: 15px; margin: 0 0 12px; }
.admin-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.admin-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.admin-form input { width: 150px; }
.admin-form select { width: 170px; }
#site-effort { width: 210px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--bg-soft); }
.data-table td.mono { font-family: ui-monospace, Consolas, monospace; }
.code-box {
  margin-top: 12px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  max-height: 260px; overflow: auto; white-space: pre;
}
.copy-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; }
.badge.used { background: var(--danger-weak); color: var(--danger); }
.badge.free { background: #eafaf1; color: #19a15f; }
.badge.admin { background: var(--accent-weak); color: var(--accent); }
.price-rates {
  margin-top: 14px; border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; background: var(--bg-soft);
}
.rate-line {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 14px;
  font-size: 12px; padding: 4px 0; color: var(--muted);
}
.rate-head { color: var(--text); font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 4px; }
.rate-label { color: var(--text); }

/* ---------------- 分享页 ---------------- */

.share-page { display: block; background: var(--bg); }
.share-shell { max-width: 820px; margin: 0 auto; padding: 32px 24px 60px; }
.share-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.share-head h1 { font-size: 20px; margin: 10px 0 0; }
.share-messages { max-width: none; padding: 0; }
.share-messages .msg { padding: 12px 0; }
.share-foot { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; }

/* ---------------- 图标统一 ---------------- */

.ico-svg { display: block; flex-shrink: 0; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
.icon-action {
  display: inline-flex; align-items: center; gap: 6px;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  font-size: 16px; padding: 0;
}
.icon-btn:hover { color: var(--accent); background: var(--accent-weak); }
.tool-icon[data-icon], .tool-icon {
  display: inline-flex; align-items: center; justify-content: center;
}
.send-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.branch-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.pin-mark { display: inline-flex; color: var(--accent); }
.menu-item [data-icon] { color: var(--muted); display: inline-flex; }

/* ---------------- 管理后台布局 ---------------- */

.admin-topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.admin-topbar .left { display: flex; align-items: center; gap: 12px; }
.admin-topbar .sep { width: 1px; height: 18px; background: var(--border); }
.admin-topbar .title { font-size: 16px; font-weight: 600; }
.admin-topbar .right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

.admin-layout {
  display: grid; grid-template-columns: 196px minmax(0, 1fr);
  gap: 28px; max-width: 1180px; margin: 0 auto;
  padding: 24px 24px 72px;
}
.admin-nav { position: sticky; top: 84px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.admin-nav a:hover { background: var(--accent-weak); color: var(--accent); }
.admin-nav .nav-label { font-size: 11px; color: var(--muted-2); padding: 10px 10px 4px; }

.admin-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.admin-section { scroll-margin-top: 76px; }
.admin-section .sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.admin-section .sec-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.admin-section .sec-head .sec-desc { font-size: 12px; color: var(--muted-2); }
.admin-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.stat .k { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; }
.admin-section .body { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .admin-nav { display: none; }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 286px; z-index: 60;
    display: flex;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 16px 50px rgba(20, 28, 50, .2);
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex !important; }
  .topbar { gap: 8px; }
  .conv-title { flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
  .modal-card, .modal-card.wide-card, .modal-card.narrow-card { width: 100%; }
  .msg { padding: 10px 16px; }
  .msg-actions { opacity: 1; }
  .composer-wrap { padding: 8px 16px 12px; }
}

.sidebar-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(17, 22, 35, .35);
}
.mobile-only { display: none; }
