:root {
  --bg0: 245 245 247;
  --bg1: 242 242 247;
  --card: 255 255 255;
  --text: 29 29 31;
  --muted: 110 110 115;
  --line: 210 210 215;
  --brand: 0 113 227;
  --brand-hover: 0 102 204;
  --brand2: 41 151 255;
  --ok: 52 199 89;
  --warn: 255 159 10;
  --bad: 255 69 58;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.04), 0 12px 40px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.1), 0 24px 80px rgba(0,0,0,.12);
  --glass-bg: rgba(255,255,255,.78);
  --glass-border: rgba(255,255,255,.65);
  --surface-inset: rgba(0, 0, 0, .035);
  --toast-bg: rgba(29,29,31,.92);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --scrollbar-thumb: #e2e2e7;
  --scrollbar-thumb-hover: #cfcfd4;
  --scrollbar-track: transparent;
}

html.theme-dark {
  color-scheme: dark;
  --bg0: 22 22 24;
  --bg1: 28 28 30;
  --card: 44 44 46;
  --text: 255 255 255;
  --muted: 174 174 178;
  --line: 58 58 60;
  --brand: 10 132 255;
  --brand-hover: 64 156 255;
  --brand2: 100 210 255;
  --glass-bg: rgba(44,44,46,.78);
  --glass-border: rgba(255,255,255,.06);
  --surface-inset: rgba(255,255,255,.06);
  --toast-bg: rgba(44,44,46,.95);
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
  --scrollbar-track: transparent;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
html, body { height: 100%; }
body {
  margin: 0;
  color: rgb(var(--text));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 420px at 8% -8%, rgb(var(--brand) / .09), transparent 55%),
    radial-gradient(700px 380px at 96% 0%, rgb(var(--brand2) / .07), transparent 50%),
    linear-gradient(180deg, rgb(var(--bg0)), rgb(var(--bg1)));
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
.chat-stream,
.chat-list,
.mod-page,
.diag-out,
.case-list,
.push-list {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.chat-stream::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb,
.mod-page::-webkit-scrollbar-thumb {
  background-color: #e8e8ed;
}
/* 主应用：整页高度内分配，避免对话区按 100vh 算高导致底部输入框被裁切 */
body:has(.app) {
  overflow: hidden;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  appearance: none;
  border: 1px solid rgb(var(--line) / .9);
  background: rgb(var(--card) / .92);
  color: rgb(var(--text));
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform .18s var(--ease), background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: rgb(var(--brand));
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: rgb(var(--brand-hover)); }
.btn-primary:active { filter: brightness(0.96); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; margin-top: 8px; }

.field {
  width: 100%;
  border: 1px solid rgb(var(--line) / .9);
  background: var(--surface-inset);
  color: rgb(var(--text));
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
.field:focus {
  border-color: rgb(var(--brand) / .55);
  box-shadow: 0 0 0 4px rgb(var(--brand) / .12);
}
textarea.field { resize: vertical; min-height: 44px; }
.field.compact { width: auto; min-width: 120px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid rgb(var(--line) / 0.85);
  background: rgb(var(--card) / 0.85);
  color: rgb(var(--muted));
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(var(--muted) / 0.55);
}
.chip.ok {
  background: rgb(var(--ok) / 0.12);
  border-color: rgb(var(--ok) / 0.28);
  color: rgb(var(--ok));
}
.chip.ok::before {
  background: rgb(var(--ok));
  box-shadow: 0 0 0 3px rgb(var(--ok) / 0.18);
}
.chip.bad {
  background: rgb(var(--bad) / 0.12);
  border-color: rgb(var(--bad) / 0.28);
  color: rgb(var(--bad));
}
.chip.bad::before { background: rgb(var(--bad)); }
.muted-chip {
  color: rgb(var(--muted));
  background: var(--surface-inset);
  border-color: transparent;
}
.muted-chip::before { display: none; }
.muted { color: rgb(var(--muted)); }
.hidden { display: none !important; }
.form-error {
  color: rgb(var(--bad));
  font-size: 13px;
  background: rgb(var(--bad) / .08);
  border-radius: 10px;
  padding: 8px 10px;
}
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgb(var(--brand) / .12);
  color: rgb(var(--brand));
}
.badge.confirmed { background: rgb(var(--ok) / .15); color: rgb(var(--ok)); }

/* layout — 顶栏对齐信息底座 */
.app {
  height: 100%;
  max-height: 100dvh;
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 20px calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.glass {
  background: var(--glass-bg);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.top-bar-dashboard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.top-bar-dashboard::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgb(var(--brand2)), rgb(var(--brand)));
  opacity: 0.9;
}
.top-bar-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: rgb(var(--muted));
}
.top-bar-title {
  margin: 2px 0 0;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: rgb(var(--text));
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.mod-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  flex-shrink: 0;
}
.mod-nav-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: rgb(var(--text));
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
  cursor: pointer;
  font: inherit;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s var(--ease);
}
.mod-nav-item:hover {
  background: var(--surface-inset);
}
.mod-nav-item:hover .mod-nav-icon {
  transform: translateY(-1px);
  background: rgb(var(--brand) / .14);
  color: rgb(var(--brand));
}
.mod-nav-item.active {
  background: rgb(var(--card));
  border-color: rgb(var(--brand) / .35);
  box-shadow: var(--shadow-sm);
}
.mod-nav-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgb(var(--brand) / .08);
  color: rgb(var(--brand));
  transition: background .15s ease, color .15s ease, transform .15s var(--ease), box-shadow .15s ease;
}
.mod-nav-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}
.mod-nav-item.active .mod-nav-icon {
  background: linear-gradient(145deg, rgb(var(--brand2)), rgb(var(--brand)));
  color: #fff;
  box-shadow: 0 4px 12px rgb(var(--brand) / .28);
}
.mod-nav-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mod-nav-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mod-nav-desc {
  font-size: 11.5px;
  color: rgb(var(--muted));
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mod-view {
  display: none;
  min-height: 0;
}
.mod-view.active {
  display: grid;
  gap: 12px;
  flex: 1;
  min-height: 0;
  height: 100%;
  align-content: stretch;
}
#viewAsk.active {
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
#viewTools.active,
#viewDiagnose.active,
#viewPush.active {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.mod-page {
  padding: 18px 20px 20px;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
}
.mod-page-head h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.mod-page-head .muted,
.mod-page-head .tip {
  margin: 0;
  font-size: 13px;
}
.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.tool-block.cardish {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-inset);
  border: 1px solid rgb(var(--line) / .35);
}
.tools-grid > .tool-block.cardish {
  margin-top: 0;
  border-top: none;
}
.diagnose-page {
  gap: 14px;
  overflow: auto;
}
.diagnose-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
  flex-shrink: 0;
}
.diagnose-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}
.diag-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.diag-field-label {
  display: block;
  height: 14px;
  line-height: 14px;
  font-size: 12px;
  color: rgb(var(--muted));
}
.diag-actions-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 40px;
}
.diag-control {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  margin: 0;
  border: 1px solid rgb(var(--line) / .9);
  border-radius: 12px;
  background-color: var(--surface-inset);
  color: rgb(var(--text));
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 38px;
  outline: none;
}
.diag-control.compact { min-width: 132px; }
#binSelect.diag-control { min-width: 220px; }
select.diag-control {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 36px 0 12px;
  background-color: var(--surface-inset);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236e6e73' d='M1.2 1.2 6 6l4.8-4.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  cursor: pointer;
}
select.diag-control:focus,
.diag-btn:focus-visible {
  border-color: rgb(var(--brand) / .55);
  box-shadow: 0 0 0 4px rgb(var(--brand) / .12);
}
.diag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  line-height: 1;
  cursor: pointer;
  background: rgb(var(--card) / .92);
  transition: transform .18s var(--ease), background .18s ease, border-color .18s ease;
}
.diag-btn:hover { transform: translateY(-1px); }
.diag-btn.primary {
  background: rgb(var(--brand));
  border-color: transparent;
  color: #fff;
}
.diag-btn.primary:hover { background: rgb(var(--brand-hover)); }
.diagnose-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
.diagnose-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface-inset);
  border: 1px solid rgb(var(--line) / .35);
}
.pane-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.diag-out {
  flex: 1;
  min-height: 240px;
  max-height: none;
  font-size: 14px;
  line-height: 1.55;
  padding: 14px 16px;
}
.plan-pane { position: relative; }
.plan-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px dashed rgb(var(--line) / .7);
  border-radius: 12px;
  background: rgb(var(--card) / .45);
}
.plan-placeholder.hidden { display: none; }
.plan-box {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0;
}
.plan-edit {
  flex: 1;
  min-height: 280px;
  font-size: 14px;
  line-height: 1.55;
  resize: none;
}
.eval-out {
  max-height: 140px;
  flex-shrink: 0;
}
.track-box {
  margin-top: 4px;
  padding: 12px;
  border-radius: 12px;
  background: rgb(var(--card) / .7);
  border: 1px solid rgb(var(--line) / .45);
  flex-shrink: 0;
}
.track-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.track-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.track-steps li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 13px;
}
.track-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: rgb(var(--line));
}
.track-steps li.done .track-dot { background: rgb(var(--ok)); }
.track-steps li.running .track-dot {
  background: rgb(var(--brand));
  box-shadow: 0 0 0 3px rgb(var(--brand) / .2);
}
.track-steps li.pending { opacity: .65; }
.track-note { color: rgb(var(--muted)); font-size: 12px; }
.case-section {
  flex-shrink: 0;
  padding-top: 4px;
}
.case-section-head h3 {
  margin: 0 0 2px;
  font-size: 14px;
}
.case-section-head .muted {
  margin: 0 0 10px;
  font-size: 12px;
}
.case-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 180px;
  overflow: auto;
}
.case-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgb(var(--line) / .4);
  background: var(--surface-inset);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.case-card strong {
  font-size: 13px;
  line-height: 1.35;
}
.case-card .meta {
  font-size: 12px;
  color: rgb(var(--muted));
}
.case-card .row-actions { margin: 0; }
.push-page { overflow: auto; }
.push-list {
  display: grid;
  gap: 12px;
}
.push-card {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgb(var(--line) / .4);
  background: var(--surface-inset);
  display: grid;
  gap: 8px;
}
.push-card.high {
  border-color: rgb(var(--brand) / .35);
  background: rgb(var(--brand) / .06);
}
.push-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.push-cat {
  font-size: 12px;
  font-weight: 650;
  color: rgb(var(--brand));
}
.push-card h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.push-card p {
  margin: 0;
  font-size: 13px;
  color: rgb(var(--muted));
  line-height: 1.5;
}
.push-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.push-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(var(--card) / .85);
  border: 1px solid rgb(var(--line) / .45);
  color: rgb(var(--muted));
}
.history-toggle { display: none; }
.toolbar-actions .icon-btn.tiny { color: rgb(var(--muted)); }
.toolbar-actions .icon-btn.tiny:hover { color: rgb(var(--brand)); }
#btnDeleteChat:hover { color: rgb(var(--bad)); border-color: rgb(var(--bad) / .35); background: rgb(var(--bad) / .08); }
.history-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 40;
}

.history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: none;
  padding: 10px;
  overflow: hidden;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.history-head h2 { margin: 0; font-size: 15px; }
.chat-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-item {
  text-align: left;
  border: 1px solid transparent;
  background: var(--surface-inset);
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  color: rgb(var(--text));
  font: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.chat-item:hover { border-color: rgb(var(--brand) / .35); }
.chat-item.active {
  border-color: rgb(var(--brand) / .55);
  background: rgb(var(--brand) / .1);
}
.chat-item .t {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item {
  position: relative;
  padding-right: 36px;
}
.chat-item .m {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: rgb(var(--muted));
}
.chat-item .rename-mini {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgb(var(--muted));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
}
.chat-item:hover .rename-mini,
.chat-item.active .rename-mini { opacity: 1; }
.chat-item .rename-mini:hover {
  background: rgb(var(--brand) / .12);
  color: rgb(var(--brand));
}
.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-title-wrap { min-width: 0; flex: 1; }
.title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-title-text {
  max-width: min(420px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}
.title-input {
  max-width: min(420px, 55vw);
  height: 32px;
  padding: 4px 10px;
  font-weight: 600;
}
.icon-btn.tiny {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
}

/* 对话窗口放大 */
.app.chat-expanded .mod-nav,
.app.chat-expanded .history-panel {
  display: none !important;
}
.app.chat-expanded #viewAsk.active {
  grid-template-columns: 1fr;
}
.app.chat-expanded .chat-panel {
  min-height: 0;
  height: 100%;
}
body.chat-expanded-lock {
  overflow: hidden;
}
.panel {
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}
.panel h2 { margin: 0 0 8px; font-size: 15px; }
.panel h3 { margin: 0 0 6px; font-size: 13px; }
.tip { margin: 0 0 8px; font-size: 12px; }

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow: hidden;
}
.chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.chat-toolbar .muted { display: block; font-size: 12px; margin-top: 2px; }
.chat-stream {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 8px;
  min-height: 0;
}
.chat-stream:has(.bubble:only-child.system) {
  justify-content: center;
}
.chat-stream:has(.bubble:only-child.system) .bubble.system {
  align-self: center;
  max-width: min(420px, 92%);
  text-align: center;
  background: transparent;
  color: rgb(var(--muted));
  font-size: 13.5px;
  line-height: 1.55;
}
.bubble {
  max-width: min(920px, 100%);
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 16px;
  word-break: break-word;
  animation: rise .35s var(--ease);
}
.bubble.user {
  align-self: flex-end;
  background: rgb(var(--brand) / 0.08);
  color: rgb(var(--text));
  border: 1px solid rgb(var(--brand) / 0.28);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
}
.bubble.user .chat-thumb {
  border-color: rgb(var(--line) / 0.55);
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface-inset);
  border: 1px solid rgb(var(--line) / .45);
  border-bottom-left-radius: 6px;
  white-space: normal;
}
.image-note { margin-bottom: 8px; font-size: 12px; }
.md-body {
  font-size: 16px;
  line-height: 1.7;
  color: rgb(var(--text));
}
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body p { margin: 0 0 0.7em; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 0.9em 0 0.45em;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.md-body h1 { font-size: 1.25em; }
.md-body h2 { font-size: 1.12em; }
.md-body h3, .md-body h4 { font-size: 1.02em; }
.md-body ul, .md-body ol {
  margin: 0.35em 0 0.75em;
  padding-left: 1.35em;
}
.md-body li { margin: 0.2em 0; }
.md-body li > p { margin: 0.2em 0; }
.md-body blockquote {
  margin: 0.6em 0;
  padding: 0.35em 0.85em;
  border-left: 3px solid rgb(var(--brand) / 0.45);
  color: rgb(var(--muted));
  background: rgb(var(--brand) / 0.04);
  border-radius: 0 8px 8px 0;
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.06);
}
html.theme-dark .md-body code { background: rgb(255 255 255 / 0.08); }
.md-body pre {
  margin: 0.55em 0 0.85em;
  padding: 10px 12px;
  border-radius: 10px;
  overflow: auto;
  background: rgb(0 0 0 / 0.06);
  border: 1px solid rgb(var(--line) / 0.55);
}
html.theme-dark .md-body pre { background: rgb(255 255 255 / 0.06); }
.md-body pre code {
  padding: 0;
  background: transparent;
  font-size: 12.5px;
  line-height: 1.5;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0 0.9em;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.md-body th, .md-body td {
  border: 1px solid rgb(var(--line) / 0.75);
  padding: 6px 10px;
  text-align: left;
}
.md-body th {
  background: rgb(var(--brand) / 0.08);
  font-weight: 600;
}
.md-body a { color: rgb(var(--brand)); }
.md-body hr {
  border: 0;
  border-top: 1px solid rgb(var(--line) / 0.7);
  margin: 0.9em 0;
}
.md-fallback {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}
.bubble.system {
  align-self: center;
  background: transparent;
  color: rgb(var(--muted));
  font-size: 12px;
  padding: 4px 8px;
}
.md-body .md-cite {
  display: inline;
  color: rgb(var(--brand));
  font-weight: 650;
  font-size: 0.92em;
  text-decoration: none;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 4px;
}
.md-body .md-cite:hover {
  background: rgb(var(--brand) / .12);
  text-decoration: underline;
}
.ask-answer-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: -2px 0 8px;
}
.speak-btn,
.speak-style-btn {
  border: 1px solid rgb(var(--line) / .75);
  background: var(--surface-inset);
  color: rgb(var(--brand));
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.3;
}
.speak-style-btn {
  color: rgb(var(--muted));
  font-weight: 550;
}
.speak-btn:hover,
.speak-style-btn:hover {
  border-color: rgb(var(--brand) / .45);
  background: rgb(var(--brand) / .08);
  color: rgb(var(--brand));
}
.speak-btn.speaking {
  border-color: rgb(var(--brand) / .55);
  background: rgb(var(--brand) / .12);
  color: rgb(var(--brand));
}
.cite-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgb(var(--line) / .65);
  font-size: 12px;
  line-height: 1.45;
  color: rgb(var(--muted));
}
.cite-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.cite-head strong {
  font-size: 12px;
  color: rgb(var(--brand));
}
.cite-list { display: grid; gap: 6px; }
.cite-row {
  display: block;
  border: 1px solid rgb(var(--line) / .55);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgb(var(--card) / .9);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.cite-row.flash {
  border-color: rgb(var(--brand));
  box-shadow: 0 0 0 3px rgb(var(--brand) / .22);
  animation: cite-flash 1.6s ease;
}
@keyframes cite-flash {
  0% { background: rgb(var(--brand) / .14); }
  100% { background: rgb(var(--card) / .9); }
}
.cite-main { min-width: 0; }
.cite-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cite-card-head h4 {
  margin: 0;
  font-size: 12px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.35;
  min-width: 0;
  color: rgb(var(--text));
}
.cite-fname {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cite-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgb(var(--brand));
  color: #fff;
  font-size: 10px;
  flex-shrink: 0;
}
.cite-score {
  font-size: 11px;
  color: rgb(var(--muted));
  white-space: nowrap;
}
.cite-row .src {
  font-size: 11px;
  color: rgb(var(--muted));
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.cite-act {
  border: 1px solid rgb(var(--line) / .75);
  background: var(--surface-inset);
  color: rgb(var(--brand));
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.cite-act:hover {
  border-color: rgb(var(--brand) / .45);
  background: rgb(var(--brand) / .08);
}
.cite-hits {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.cite-hit {
  border: 1px solid rgb(var(--line) / .5);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-inset);
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
.cite-hit.flash {
  border-color: rgb(var(--brand));
  box-shadow: 0 0 0 3px rgb(var(--brand) / .2);
  background: rgb(var(--brand) / .1);
  animation: cite-flash 1.6s ease;
}
.cite-hit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: rgb(var(--muted));
}
.cite-hit-no {
  color: rgb(var(--brand));
  font-weight: 700;
}
.cite-hit-body {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: rgb(var(--muted));
}
.cite-hit-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}
.cite-open {
  border: 0;
  background: transparent;
  color: rgb(var(--brand));
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.cite-open:hover { text-decoration: underline; }
.cite-empty {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-inset);
  font-size: 12px;
}

.composer {
  border-top: 1px solid rgb(var(--line) / .45);
  padding-top: 12px;
  margin-top: auto;
  flex-shrink: 0;
}
.composer-box {
  border: 1px solid rgb(var(--line) / .75);
  background: var(--surface-inset);
  border-radius: 16px;
  padding: 10px 12px 10px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.composer-box:focus-within {
  border-color: rgb(var(--brand) / .55);
  box-shadow: 0 0 0 4px rgb(var(--brand) / .1);
  background: rgb(var(--card) / .55);
}
.composer-input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 2px 8px !important;
  min-height: 52px;
  max-height: 140px;
  resize: none;
  line-height: 1.45;
  overflow-y: hidden;
  width: 100%;
  display: block;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}
.composer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer-tool-wrap {
  position: relative;
}
.chat-tool-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-30%);
  width: min(292px, calc(100vw - 48px));
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgb(var(--line) / .55);
  background:
    linear-gradient(180deg, rgb(var(--card) / .98), rgb(var(--card) / .94));
  box-shadow:
    0 0 0 1px rgb(255 255 255 / .55) inset,
    0 12px 40px rgb(15 23 42 / .14),
    0 2px 8px rgb(15 23 42 / .06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
  display: grid;
  gap: 6px;
  animation: tool-menu-in .18s var(--ease);
  transform-origin: 30% 100%;
}
.chat-tool-menu.hidden {
  display: none;
}
.chat-tool-menu::after {
  content: "";
  position: absolute;
  left: 28%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: rgb(var(--card));
  border-right: 1px solid rgb(var(--line) / .55);
  border-bottom: 1px solid rgb(var(--line) / .55);
  transform: rotate(45deg);
}
@keyframes tool-menu-in {
  from { opacity: 0; transform: translateX(-30%) translateY(6px) scale(.96); }
  to { opacity: 1; transform: translateX(-30%) translateY(0) scale(1); }
}
.chat-tool-menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid rgb(var(--line) / .35);
  margin-bottom: 2px;
}
.chat-tool-menu-title {
  font-size: 13px;
  font-weight: 720;
  letter-spacing: -0.02em;
  color: rgb(var(--text));
}
.chat-tool-menu-sub {
  font-size: 11px;
  color: rgb(var(--muted));
}
.chat-tool-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 10px 10px;
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  transition: background .15s ease, border-color .15s ease, transform .15s var(--ease);
}
.chat-tool-item:hover {
  background: rgb(var(--brand) / .07);
  border-color: rgb(var(--brand) / .18);
  transform: translateY(-1px);
}
.chat-tool-item:active {
  transform: translateY(0);
}
.chat-tool-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--brand));
  background:
    linear-gradient(145deg, rgb(var(--brand) / .14), rgb(var(--brand2) / .08));
  border: 1px solid rgb(var(--brand) / .16);
  flex-shrink: 0;
}
.chat-tool-ico-grad {
  color: #0a7a4a;
  background: linear-gradient(145deg, rgb(52 199 89 / .16), rgb(10 132 255 / .08));
  border-color: rgb(52 199 89 / .22);
}
.chat-tool-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.chat-tool-copy strong {
  font-size: 13px;
  font-weight: 700;
  color: rgb(var(--text));
  letter-spacing: -0.01em;
}
.chat-tool-copy em {
  font-style: normal;
  font-size: 11px;
  color: rgb(var(--muted));
}
.chat-tool-arrow {
  font-size: 18px;
  color: rgb(var(--muted));
  opacity: .55;
  transition: transform .15s ease, color .15s ease, opacity .15s ease;
}
.chat-tool-item:hover .chat-tool-arrow {
  color: rgb(var(--brand));
  opacity: 1;
  transform: translateX(2px);
}
.icon-btn.open-tools {
  color: rgb(var(--brand));
  border-color: rgb(var(--brand) / .45);
  background: rgb(var(--brand) / .1);
}
.chat-tool-panel {
  display: none;
}
.chat-tool-panel:not(.hidden) {
  display: block;
}
.composer-box.tool-mode {
  border-color: rgb(var(--brand) / .4);
  box-shadow:
    0 0 0 4px rgb(var(--brand) / .1),
    0 10px 28px rgb(15 23 42 / .06);
  background:
    linear-gradient(180deg, rgb(var(--card) / .95), rgb(245 248 255 / .9));
}
.composer-box.tool-mode .composer-chat-slot {
  display: none;
}
.composer-box.tool-mode .chat-tool-panel {
  display: block;
  margin: 0;
  padding: 4px 4px 2px;
  border: 0;
  background: transparent;
  border-radius: 0;
  animation: tool-panel-in .2s var(--ease);
}
@keyframes tool-panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: rgb(255 255 255 / .75);
  border: 1px solid rgb(var(--line) / .5);
  gap: 2px;
  box-shadow: 0 1px 2px rgb(15 23 42 / .04);
}
.panel-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 650;
  color: rgb(var(--muted));
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.panel-tab.active {
  background: rgb(var(--brand));
  color: #fff;
  box-shadow: 0 4px 12px rgb(var(--brand) / .28);
}
.panel-close {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid rgb(var(--line) / .55);
  background: rgb(255 255 255 / .85);
  color: rgb(var(--muted));
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.panel-close:hover {
  color: rgb(var(--text));
  border-color: rgb(var(--brand) / .35);
  background: #fff;
}
.chat-tool-panel h4 {
  margin: 0 0 4px;
  font-size: 16px;
  letter-spacing: -0.02em;
  font-weight: 720;
}
.chat-tool-panel .panel-desc {
  margin: 0 0 14px;
  font-size: 12px;
  color: rgb(var(--muted));
  line-height: 1.5;
}
.chat-tool-panel .panel-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.chat-tool-panel .panel-actions .btn-primary {
  min-width: 152px;
  height: 42px;
  border-radius: 12px;
  font-weight: 650;
  box-shadow: 0 6px 16px rgb(var(--brand) / .22);
}
.chat-tool-panel .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.chat-tool-panel label {
  display: block;
  font-size: 12px;
  color: rgb(var(--muted));
  font-weight: 550;
}
.chat-tool-panel .field {
  margin-top: 5px;
  width: 100%;
  border-radius: 12px;
  background: rgb(255 255 255 / .9);
}
.chat-tool-panel .panel-grad-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.chat-tool-panel .panel-grad-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
}
.icon-btn.listening {
  color: #fff;
  background: rgb(var(--bad));
  border-color: transparent;
  box-shadow: 0 0 0 4px rgb(var(--bad) / .18);
  animation: voice-pulse 1.2s ease infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgb(var(--bad) / .16); }
  50% { box-shadow: 0 0 0 7px rgb(var(--bad) / .08); }
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgb(var(--line) / .7);
  background: rgb(var(--card) / .85);
  color: rgb(var(--muted));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s var(--ease);
}
.icon-btn:hover {
  color: rgb(var(--brand));
  border-color: rgb(var(--brand) / .45);
  background: rgb(var(--brand) / .08);
  transform: translateY(-1px);
}
.send-btn {
  min-width: 88px;
  height: 40px;
  padding: 0 18px;
  border-radius: 12px;
}
.composer-hint { margin-top: 8px; font-size: 12px; }
.image-preview {
  position: relative;
  width: fit-content;
  margin: 0 0 10px;
}
.thumb-btn {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: 12px;
}
.image-preview img,
.chat-thumb {
  max-height: 88px;
  max-width: min(220px, 60vw);
  border-radius: 12px;
  display: block;
  border: 1px solid rgb(var(--line) / .5);
  object-fit: cover;
  background: #fff;
}
.chat-thumb-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: 12px;
}
.icon-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgb(var(--bad));
  color: #fff;
  cursor: pointer;
  line-height: 22px;
  font-size: 14px;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 24, 28, .78);
  display: grid;
  place-items: center;
  padding: 56px 24px 28px;
  backdrop-filter: blur(6px);
}
.lightbox-stage {
  display: grid;
  gap: 10px;
  justify-items: center;
  max-width: min(960px, 100%);
  width: 100%;
}
.lightbox img {
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 100%);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  background: #fff;
}
.lightbox-caption {
  width: 100%;
  max-width: 720px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.92);
  color: rgb(var(--text));
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.lightbox-caption strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}
.lightbox-caption span {
  color: rgb(var(--muted));
  font-size: 12px;
}
.lightbox-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 81;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: rgb(36, 40, 44);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.lightbox-close:hover { background: #fff; }

.doc-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(16, 20, 24, .72);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}
.doc-viewer-panel {
  width: min(1080px, 100%);
  height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: rgb(var(--card) / .98);
  border: 1px solid rgb(var(--line) / .55);
  box-shadow: var(--shadow-lg);
}
.doc-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--line) / .55);
  background: var(--surface-soft);
}
.doc-viewer-eyebrow {
  font-size: 11px;
  color: rgb(var(--muted));
  margin-bottom: 2px;
}
.doc-viewer-head strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-all;
}
.doc-viewer-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-inset);
  color: rgb(var(--text));
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.doc-viewer-close:hover { background: rgb(var(--brand) / .12); color: rgb(var(--brand)); }
.doc-viewer-body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #f4f5f7;
}
html.theme-dark .doc-viewer-body { background: #1a1b1e; }
.doc-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.doc-viewer-text {
  margin: 0;
  padding: 18px 20px;
  height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SimSun", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: 15px;
  line-height: 1.75;
  color: rgb(var(--text));
}
.doc-viewer-loading,
.doc-viewer-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: rgb(var(--muted));
}
.doc-viewer-error { color: rgb(var(--bad)); }

.tools-grid .tool-block + .tool-block { margin-top: 0; padding-top: 16px; border-top: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-2 label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: rgb(var(--muted));
  margin-bottom: 8px;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.result-box {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-inset);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}
.grad-points { display: grid; gap: 8px; }
.grad-row {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: 6px;
  align-items: center;
}
.tool-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
}
.tool-full-label {
  display: block;
  margin: 10px 0;
  font-size: 13px;
}
.tool-full-label .field { margin-top: 6px; width: 100%; }
.tool-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgb(var(--bg0));
  border: 1px solid rgb(var(--line) / .4);
  font-size: 13px;
  line-height: 1.5;
}
.tool-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 10px;
}
.tool-metrics .k {
  display: block;
  font-size: 11px;
  color: rgb(var(--muted));
}
.tool-metrics .v {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.tool-metrics .badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.risk-high { background: rgb(var(--bad) / .12); color: rgb(var(--bad)); }
.badge.risk-mid { background: rgb(var(--warn) / .14); color: rgb(var(--warn)); }
.badge.risk-low { background: rgb(var(--ok) / .12); color: rgb(var(--ok)); }
.tool-advice { margin: 0 0 6px; }
.tool-note { margin: 0; font-size: 11px; }
.grad-bars { display: grid; gap: 8px; margin: 8px 0 10px; }
.grad-bar-row {
  display: grid;
  grid-template-columns: 52px 1fr minmax(88px, auto) auto;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgb(var(--line) / .35);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: rgb(var(--brand));
  min-width: 4px;
}
.bar-flag {
  font-size: 11px;
  color: rgb(var(--bad));
  white-space: nowrap;
}
.bar-temp { font-variant-numeric: tabular-nums; text-align: right; }
.tool-call-card {
  margin: 0 0 4px;
  padding: 14px 16px 12px;
  border-radius: 16px;
  border: 1px solid rgb(var(--line) / .55);
  background:
    linear-gradient(165deg, rgb(var(--card) / .96), rgb(var(--bg0) / .9)),
    rgb(var(--card) / .92);
  box-shadow: 0 8px 24px rgb(15 23 42 / .06);
}
.tool-call-card.tc-dew,
.tool-call-card.tc-grad {
  border-color: rgb(var(--brand) / .22);
}
.tc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.tc-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--brand));
  background: rgb(var(--brand) / .1);
  border: 1px solid rgb(var(--brand) / .18);
  flex-shrink: 0;
}
.tc-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.tc-titles strong {
  font-size: 14px;
  letter-spacing: -0.01em;
}
.tc-algo {
  font-size: 11px;
  color: rgb(var(--muted));
}
.tc-status,
.tc-badge {
  font-size: 11px;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgb(var(--brand) / .1);
  color: rgb(var(--brand));
  white-space: nowrap;
}
.tc-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tc-hero-label {
  display: block;
  font-size: 11px;
  color: rgb(var(--muted));
  margin-bottom: 2px;
}
.tc-hero-value {
  font-size: 34px;
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--ink));
}
.tc-hero-value small {
  font-size: 14px;
  font-weight: 600;
  margin-left: 2px;
  color: rgb(var(--muted));
}
.tc-hero-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.tc-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.tc-pill.tc-risk-high { background: rgb(var(--bad) / .12); color: rgb(var(--bad)); }
.tc-pill.tc-risk-mid { background: rgb(var(--warn) / .16); color: rgb(var(--warn)); }
.tc-pill.tc-risk-low { background: rgb(var(--ok) / .14); color: rgb(var(--ok)); }
.tc-margin {
  font-size: 12px;
  color: rgb(var(--muted));
  font-variant-numeric: tabular-nums;
}
.tc-gauge { margin-bottom: 12px; }
.tc-gauge-track {
  height: 7px;
  border-radius: 999px;
  background: rgb(var(--line) / .35);
  overflow: hidden;
}
.tc-gauge-fill {
  height: 100%;
  border-radius: inherit;
  min-width: 4px;
  transition: width .25s ease;
}
.tc-gauge-fill.tc-risk-high { background: rgb(var(--bad)); }
.tc-gauge-fill.tc-risk-mid { background: rgb(var(--warn)); }
.tc-gauge-fill.tc-risk-low { background: rgb(var(--ok)); }
.tc-gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: rgb(var(--muted));
}
.tc-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tc-tile {
  padding: 10px 10px 9px;
  border-radius: 12px;
  background: rgb(var(--bg0) / .85);
  border: 1px solid rgb(var(--line) / .4);
}
.tc-tile .k {
  display: block;
  font-size: 11px;
  color: rgb(var(--muted));
  margin-bottom: 4px;
}
.tc-tile .v {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tc-bars {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgb(var(--bg0) / .75);
  border: 1px solid rgb(var(--line) / .35);
}
.tc-bar-row {
  display: grid;
  grid-template-columns: 48px 1fr 52px 40px auto;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.tc-bar-track {
  height: 7px;
  border-radius: 999px;
  background: rgb(var(--line) / .3);
  overflow: hidden;
}
.tc-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: rgb(var(--brand));
}
.tc-bar-row.is-hot .tc-bar-fill { background: rgb(var(--bad)); }
.tc-bar-row.is-cold .tc-bar-fill { background: rgb(59 130 246); }
.tc-bar-temp { font-variant-numeric: tabular-nums; text-align: right; font-weight: 650; }
.tc-bar-dev { font-variant-numeric: tabular-nums; text-align: right; font-size: 11px; }
.tc-flag {
  font-size: 10px;
  font-weight: 700;
  color: rgb(var(--bad));
  white-space: nowrap;
}
.tc-hotline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
}
.tc-hotline .k { color: rgb(var(--muted)); flex-shrink: 0; }
.tc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tc-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(var(--bad) / .1);
  color: rgb(var(--bad));
  font-weight: 650;
  font-size: 11px;
}
.tc-advice {
  font-size: 13px;
  line-height: 1.55;
  color: rgb(var(--ink) / .88);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgb(var(--brand) / .05);
  border: 1px solid rgb(var(--brand) / .12);
  margin-bottom: 10px;
}
.tc-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.tc-note {
  font-size: 11px;
  line-height: 1.4;
  color: rgb(var(--muted));
  flex: 1;
  min-width: 0;
}
.tool-call-pending .tc-hint { margin: 0; font-size: 12px; }
@media (max-width: 640px) {
  .tc-tiles { grid-template-columns: 1fr; }
  .tc-hero { flex-direction: column; align-items: flex-start; }
  .tc-hero-side { align-items: flex-start; }
  .tc-bar-row { grid-template-columns: 44px 1fr 48px; }
  .tc-bar-dev, .tc-flag { display: none; }
  .tc-foot { flex-direction: column; align-items: stretch; }
}

.status-safe { color: rgb(var(--ok)); font-weight: 700; }
.status-watch { color: rgb(var(--warn)); font-weight: 700; }
.status-danger { color: rgb(var(--bad)); font-weight: 700; }

.plan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

/* login 样式见 assets/login.css */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1200px) {
  .mod-nav-desc { display: none; }
  .mod-nav-item { gap: 10px; padding: 10px; }
  .mod-nav-icon { width: 36px; height: 36px; }
}

@media (max-width: 1100px) {
  .tools-grid { grid-template-columns: 1fr; }
  .diagnose-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .diagnose-pane { min-height: 320px; }
  .diag-out, .plan-edit { min-height: 220px; }
}

/* 平板：菜单仍保持一行四项，仅收起对话侧栏 */
@media (max-width: 960px) {
  .mod-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .mod-nav-item {
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    padding: 10px 6px;
    text-align: center;
  }
  .mod-nav-text { align-items: center; }
  .mod-nav-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .mod-nav-icon svg { width: 18px; height: 18px; }
  .mod-nav-title { font-size: 12px; white-space: normal; line-height: 1.25; }
  .diagnose-page { overflow: auto; }
  .case-list { max-height: none; }
  #viewAsk.active { grid-template-columns: 1fr; }
  .history-toggle { display: inline-flex; }
  .history-panel {
    display: none;
    position: fixed;
    z-index: 50;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: min(300px, calc(100vw - 48px));
    max-height: none;
    min-height: 0;
    height: auto;
  }
  .history-panel.open {
    display: flex;
  }
  .send-btn { min-width: 76px; }
  .top-actions .btn, .top-actions .chip { font-size: 12px; }
  .chat-toolbar { flex-wrap: wrap; }
}

/* 手机：横向一排紧凑菜单，避免 2×2 占掉对话高度 */
@media (max-width: 640px) {
  .mod-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 5px;
  }
  .mod-nav::-webkit-scrollbar { display: none; }
  .mod-nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    padding: 8px 10px;
    gap: 8px;
    min-width: max-content;
  }
  .mod-nav-text { align-items: flex-start; }
  .mod-nav-title { font-size: 12.5px; white-space: nowrap; }
  .mod-nav-icon {
    width: 30px;
    height: 30px;
  }
  .mod-nav-icon svg { width: 16px; height: 16px; }
}

@media (max-width: 480px) {
  .app { padding: 12px 12px calc(16px + var(--safe-bottom)); gap: 12px; }
  .top-bar-dashboard { padding: 16px; }
  .top-bar-dashboard::before { display: none; }
  .grad-row { grid-template-columns: 1fr 1fr; }
  .grad-row .btn { grid-column: 1 / -1; }
  .composer-hint { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .btn { animation: none !important; transition: none !important; }
}
