/* ─────────────────────────────────────────────
   AI 助手页（侧边栏「智能」组 · data-page="assistant"）

   极简克制双栏布局：
     · 左侧 234px 可收起历史栏（窄屏自动变为抽屉），按时间分段、按需搜索；
     · 右侧平铺无外框：极简顶栏 + 居中输入空态 / 740px 阅读列 + 底部输入区；
     · 已完成工具收成极静单行折叠条，待确认 / 失败使用干净细框卡片。
   ───────────────────────────────────────────── */

.page.active[data-page="assistant"] {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--pad);
}

.asst-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ─── 左栏：历史会话（234px、平铺无边框、单行轻头） ─── */
.asst-side {
  flex: none;
  width: 234px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-right: 14px;
  margin-right: 18px;
  border-right: 1px solid var(--hairline);
  transition: width 180ms cubic-bezier(.2, .8, .2, 1), padding-right 180ms cubic-bezier(.2, .8, .2, 1), margin-right 180ms cubic-bezier(.2, .8, .2, 1), opacity 150ms ease, border-color 150ms ease, visibility 180ms ease;
}
.asst-side.is-collapsed {
  width: 0;
  padding-right: 0;
  margin-right: 0;
  opacity: 0;
  visibility: hidden;
  border-right-width: 0;
  border-right-color: transparent;
  pointer-events: none;
}

.asst-side-head {
  flex: none;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 6px;
}
.asst-side-head .spacer { flex: 1 1 auto; }
.asst-new {
  justify-content: flex-start;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
[data-slot="sheet-content"] .asst-side-collapse { display: none; }
[data-slot="sheet-content"] .asst-side-head { height: 42px; padding: 0 10px; }
[data-slot="sheet-content"] .asst-side-search { padding: 0 10px 6px; }
[data-slot="sheet-content"] .asst-side-list { padding: 2px 8px 10px; }
[data-slot="sheet-content"] .asst-side-foot { padding: 8px 10px; }

.asst-side-search {
  flex: none;
  padding: 2px 0 8px;
}

.asst-side-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 10px;
}
.asst-side-empty {
  padding: 24px 8px;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}
.asst-side-group {
  padding: 10px 8px 4px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  user-select: none;
}
.asst-side-group:first-child { padding-top: 2px; }

.asst-side-row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 30px;
  border-radius: var(--r-sm);
  transition: background-color 110ms ease;
  content-visibility: auto;
  contain-intrinsic-size: auto 30px;
}
.asst-side-row.active { background: var(--surface-2); }
.asst-side-row:hover:not(.active) { background: var(--nav-hover); }

.asst-side-btn {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 400;
  text-align: left;
  transition: color 110ms ease;
}
.asst-side-row:hover .asst-side-btn,
.asst-side-row.active .asst-side-btn {
  color: var(--text);
  padding-right: 26px;
}
.asst-side-row.active .asst-side-btn { font-weight: 500; }
.asst-side-btn .title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asst-side-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--text-3);
  transition: opacity 110ms ease, color 110ms ease;
}
.asst-side-row:hover .asst-side-del,
.asst-side-row:focus-within .asst-side-del,
.asst-side-row.active .asst-side-del { opacity: 1; }
.asst-side-del:hover {
  background: transparent;
  color: var(--danger);
}

.asst-side-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 0;
  border-top: 1px solid var(--hairline);
}
.asst-side-foot-btn {
  height: 24px;
  padding: 0 8px;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 400;
}
.asst-side-foot-btn:hover { color: var(--text); }
.asst-side-foot-btn.is-danger:hover {
  background: transparent;
  color: var(--danger);
}

/* ─── 右栏：对话本体（极简顶栏 / 消息区 / 输入区）─── */
.asst-main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.asst-top {
  flex: none;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 6px;
}
.asst-top.has-border { border-bottom: 1px solid var(--hairline); }
.asst-top .spacer { flex: 1 1 auto; }

.asst-menu {
  flex: none;
  display: none;
  color: var(--text-2);
}
.asst-top-collapsed-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.asst-title {
  min-width: 0;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.asst-ghost-ctl {
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
  gap: 5px;
}
.asst-ghost-ctl:hover:not(:disabled) {
  background: var(--nav-hover);
  color: var(--text);
}
.asst-key-label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asst-key-pop-row {
  width: 100%;
  height: auto;
  justify-content: flex-start;
  padding: 7px 8px;
  text-align: left;
  border-radius: var(--r-sm);
}
.asst-key-pop-row.is-active {
  background: var(--surface-2);
  color: var(--text);
}

/* ─── 空态：居中聚焦 ─── */
.asst-empty-center {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 12px 6vh;
  overflow-y: auto;
}
.asst-empty-inner {
  width: min(740px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.asst-empty-heading {
  margin: 0;
  font-size: 20px;
  font-weight: 550;
  letter-spacing: -0.015em;
  color: var(--text);
  text-align: center;
}
.asst-empty-inner .asst-composer-wrap {
  padding: 0;
  max-width: 100%;
}
.asst-quick-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.asst-quick-chip {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
}
.asst-quick-chip:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.asst-empty-warn {
  width: min(560px, 100%);
}

/* ─── 消息区（740px 阅读列）─── */
.asst-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 18px 12px 16px;
}
.asst-flow {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.asst-flow > *,
.asst-scroll > * { flex: 0 0 auto; }

.asst-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.asst-msg:not(:last-child) {
  content-visibility: auto;
  contain-intrinsic-size: auto 96px;
}
.asst-msg.user { align-items: flex-end; }
.asst-user-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: min(82%, 580px);
}
.asst-user-bubble {
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}
.asst-user-bubble p { margin: 0; }

.asst-msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.asst-msg-shot {
  display: block;
  max-width: 220px;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  object-fit: cover;
}
.asst-msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.asst-msg-file {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
}
.asst-msg-file svg { flex: none; color: var(--text-3); }
.asst-msg-file-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.asst-msg-file-size { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.asst-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.asst-msg-time {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.asst-msg-actions {
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity 120ms ease;
}
.asst-msg-actions > [role="group"] { padding-top: 0; }
.asst-msg:hover .asst-msg-actions,
.asst-msg:focus-within .asst-msg-actions { opacity: 1; }

/* 助手回复：无圆头像、直接左对齐 */
.asst-bot-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  word-break: break-word;
}
.asst-bot-who {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.asst-bot-model {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* 助手 Markdown 正文与独立代码块 */
.asst-md-flow { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.asst-msg.bot .md p { margin: 0 0 7px; }
.asst-msg.bot .md p:last-child { margin-bottom: 0; }
.asst-msg.bot .md ul, .asst-msg.bot .md ol { margin: 4px 0 7px; padding-left: 20px; }
.asst-msg.bot .md li { margin: 2px 0; }
.asst-msg.bot .md .md-h { margin: 10px 0 4px; font-weight: 600; color: var(--text); }
.asst-msg.bot .md .md-hr { border: 0; border-top: 1px solid var(--hairline); margin: 10px 0; }
.asst-msg.bot .md .md-quote {
  margin: 6px 0;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-2);
}
.asst-msg.bot .md a { color: var(--primary-fg); text-decoration: underline; text-underline-offset: 2px; }
.asst-msg.bot .md code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.asst-msg.bot .md pre {
  margin: 7px 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow-x: auto;
}
.asst-msg.bot .md pre code { padding: 0; border: 0; background: transparent; }
.asst-msg.bot .md b, .asst-msg.bot .md strong { font-weight: 650; }
.asst-msg.bot .md .md-table {
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}
.asst-msg.bot .md .md-table th,
.asst-msg.bot .md .md-table td { padding: 5px 9px; border: 1px solid var(--border); text-align: left; }
.asst-msg.bot .md .md-table th { background: var(--surface-2); color: var(--text); font-weight: 600; }

.asst-code-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.asst-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}
.asst-code-copy {
  height: 20px;
  gap: 4px;
  padding: 0 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-3);
}
.asst-code-pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-2);
}

.asst-caret {
  display: inline-block;
  width: 6px;
  height: 13px;
  vertical-align: -2px;
  background: var(--text-2);
  animation: asst-caret 1s steps(2) infinite;
}
@keyframes asst-caret { 50% { opacity: 0; } }

.asst-notice { font-size: 12.5px; }

/* ─── 已完成 / 运行中 / 已取消工具：极静单行折叠条 ─── */
.asst-tool-quiet {
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: auto 34px;
}
.asst-tool-quiet-trigger {
  width: fit-content;
  max-width: 100%;
  height: auto;
  padding: 3px 7px;
  margin-left: -7px;
  gap: 6px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
  justify-content: flex-start;
  text-align: left;
}
.asst-tool-quiet-trigger:not(:disabled):hover {
  background: var(--nav-hover);
  color: var(--text-2);
}
.asst-tool-quiet-trigger:disabled { opacity: 1; cursor: default; }
.asst-tool-quiet-name { font-weight: 500; color: var(--text-2); white-space: nowrap; }
.asst-tool-quiet-auto { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.asst-tool-quiet-sum {
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asst-tool-chev { flex: none; color: var(--text-3); transition: transform .15s ease; }
.asst-tool-chev.open { transform: rotate(180deg); }

.asst-tool-quiet-detail {
  margin-top: 6px;
  padding: 8px 12px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.asst-tool-pre {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─── 待确认 / 失败工具卡：干净细框 ─── */
.asst-confirm-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  box-shadow: none;
}
.asst-confirm-card.is-danger,
.asst-confirm-card.is-failed {
  border-color: var(--danger-bd);
}
.asst-confirm-head,
.asst-confirm-head-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  text-align: left;
}
.asst-confirm-head-trigger:disabled { opacity: 1; cursor: default; }
.asst-confirm-title {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.asst-confirm-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-3);
}
.asst-tool-ico-bad {
  display: inline-flex;
  align-items: center;
  color: var(--danger);
}
.asst-confirm-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.asst-confirm-lead { font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.asst-confirm-hint { color: var(--text-3); font-size: 11.5px; line-height: 1.5; }
.asst-confirm-hint.danger { color: var(--danger); }
.asst-confirm-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-inset);
}
.asst-confirm-actions { display: inline-flex; align-items: center; gap: 8px; }

.asst-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: auto;
  background: var(--surface);
}
.asst-mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.asst-mini-table th {
  padding: 6px 9px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}
.asst-mini-table td { padding: 6px 9px; border-bottom: 1px solid var(--hairline); color: var(--text-2); }
.asst-mini-table tr:last-child td { border-bottom: 0; }
.asst-mini-table .mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }
.asst-mini-table .hl { color: var(--primary-fg); font-weight: 600; }

/* ─── 回到底部轻量浮钮 ─── */
.asst-scroll-bottom-wrap {
  position: relative;
  height: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.asst-scroll-bottom-btn {
  position: absolute;
  bottom: 10px;
  pointer-events: auto;
  height: 26px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text-2);
  font-size: 11.5px;
}
.asst-scroll-bottom-btn:hover { color: var(--text); }
