/* 掌上 DSH · 移动优先深色主题（390×844 设计基准） */

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-soft: #0e141c;
  --panel: #121924;
  --panel-2: #172231;
  --border: #26303d;
  --border-soft: #1d2734;
  --text: #e6edf5;
  --text-dim: #a8b6c7;
  --muted: #7c8b9e;
  --accent: #4d9cff;
  --accent-strong: #2f7ff0;
  --accent-soft: rgba(77, 156, 255, 0.14);
  --ok: #38d39f;
  --danger: #ff6b6b;
  --warn: #f5b942;
  --radius: 14px;
  --radius-lg: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --app-h: 100vh;
  --vv-top: 0px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Segoe UI",
    "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

img { -webkit-user-drag: none; user-select: none; }

:where(button, a, [tabindex], input, textarea, label.q-option):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: fixed;
  top: var(--vv-top, 0px);
  left: 0;
  right: 0;
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ============ 登录 ============ */
@supports (height: 100dvh) {
  :root { --app-h: 100dvh; }
}

.login-view {
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(77, 156, 255, 0.16), transparent 62%),
    radial-gradient(90% 60% at 90% 100%, rgba(56, 211, 159, 0.08), transparent 60%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: fade-up 0.32s ease-out both;
}

.login-logo {
  align-self: center;
  margin: 0 0 14px;
  filter: drop-shadow(0 12px 30px rgba(77, 156, 255, 0.32));
}

.login-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-sub {
  margin: 6px 0 28px;
  color: var(--muted);
  font-size: 13px;
}

.field { text-align: left; }

.field-label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 12px;
  color: var(--text-dim);
}

.input,
.q-custom textarea {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder { color: #5c6b7e; }

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  margin: 10px 2px 0;
  color: var(--danger);
  font-size: 12.5px;
  text-align: left;
}

.login-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.login-hint.mock { color: var(--warn); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.16s ease, opacity 0.16s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 8px 22px -10px rgba(77, 156, 255, 0.85);
}

.btn-ghost {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.35);
  color: #ffb4b4;
}

.btn-block { width: 100%; height: 50px; margin-top: 18px; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 8px; }

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active { background: var(--panel-2); }
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ 主界面骨架 ============ */
.main-view {
  position: relative;
  min-height: 0;
  background: var(--bg);
}

.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(var(--safe-top) + 6px) calc(var(--safe-right) + 6px) 6px calc(var(--safe-left) + 6px);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 15, 20, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 5;
}

.header-center {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0 2px;
}

.header-title {
  margin: 0;
  max-width: 100%;
  font-size: 15.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 10.5px;
  color: var(--muted);
}

.mode-badge {
  flex: none;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid rgba(77, 156, 255, 0.3);
  background: var(--accent-soft);
  color: #8fc2ff;
  font-size: 10px;
  line-height: 16px;
}

.dsh-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(56, 211, 159, 0.14); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.14); }
.dot.unknown { background: var(--warn); }

.mock-chip {
  flex: none;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(245, 185, 66, 0.35);
  background: rgba(245, 185, 66, 0.12);
  color: var(--warn);
  font-size: 10px;
  line-height: 16px;
}

.conn-banner {
  flex: none;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(245, 185, 66, 0.22);
  background: rgba(245, 185, 66, 0.12);
  color: #ffd98a;
  font-size: 11.5px;
  text-align: center;
  cursor: pointer;
}

.conn-banner.info {
  border-bottom-color: var(--border-soft);
  background: var(--panel);
  color: var(--text-dim);
}

.conn-banner.error {
  border-bottom-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 107, 107, 0.12);
  color: #ffb4b4;
}

/* ============ 消息区 ============ */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 14px calc(var(--safe-right) + 12px) 6px calc(var(--safe-left) + 12px);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages-tail { height: 4px; }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: msg-in 0.18s ease-out both;
}

.msg-user { align-items: flex-end; }

.msg-user .bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(180deg, #2f7ff0, #2568d8);
  color: #fff;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 20px -12px rgba(47, 127, 240, 0.9);
}

.msg-assistant { align-items: flex-start; }

.msg-assistant .bubble.raw-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-assistant .bubble {
  max-width: 92%;
  padding: 10px 13px;
  border: 1px solid var(--border-soft);
  border-radius: 18px 18px 18px 6px;
  background: var(--panel);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.msg.streaming .bubble::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 0.9s steps(2, start) infinite;
}

.msg-system { align-items: center; }

.sys-note {
  max-width: 94%;
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.sys-note.error {
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  color: #ffb4b4;
  text-align: left;
}

.sys-note .retry-btn {
  margin-top: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.16);
  color: #ffd0d0;
  font-size: 12px;
}

.msg-meta {
  padding: 4px 3px 0;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

/* Markdown-lite */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 9px; }
.md h1, .md h2, .md h3, .md h4 {
  margin: 14px 0 7px;
  line-height: 1.35;
  font-weight: 650;
}
.md h1 { font-size: 19px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15.5px; }
.md h4 { font-size: 14.5px; color: var(--text-dim); }
.md ul, .md ol { margin: 0 0 9px; padding-left: 1.3em; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 700; color: #f4f8ff; }
.md em { color: var(--text-dim); }
.md blockquote {
  margin: 0 0 9px;
  padding: 2px 0 2px 11px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}
.md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md .table-wrap { margin: 0 0 9px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; line-height: 1.5; }
.md th, .md td { padding: 6px 8px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); color: var(--text); font-weight: 650; white-space: nowrap; }
.md tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
.md a { color: #7db9ff; text-decoration: underline; text-underline-offset: 2px; }
.md .inline-code,
.md code.inline {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--mono);
  font-size: 12.5px;
  color: #cfe3ff;
  white-space: break-spaces;
}

.code-block {
  margin: 9px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #080d13;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 5px 4px 10px;
  border-bottom: 1px solid rgba(38, 48, 61, 0.65);
  background: #0c121a;
}

.code-lang {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.code-copy {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
}

.code-copy:active { background: var(--panel-2); }

.code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: #cfe3ff;
  white-space: pre;
}

/* ============ 工具卡 ============ */
.msg-tool { width: 100%; }

.tool-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}

.tool-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.tool-head:active { background: rgba(255, 255, 255, 0.03); }

.tool-icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #8fc2ff;
}

.tool-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
}

.tool-status {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 17px;
  border: 1px solid transparent;
}

.tool-status.start {
  color: #ffd98a;
  background: rgba(245, 185, 66, 0.12);
  border-color: rgba(245, 185, 66, 0.3);
  animation: soft-pulse 1.6s ease-in-out infinite;
}

.tool-status.ok {
  color: #93efc8;
  background: rgba(56, 211, 159, 0.12);
  border-color: rgba(56, 211, 159, 0.28);
}

.tool-status.error {
  color: #ffb4b4;
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.3);
}

.tool-chevron {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.tool-chevron svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.tool-card.open .tool-chevron { transform: rotate(180deg); }

.tool-body {
  display: none;
  padding: 0 11px 11px;
}

.tool-card.open .tool-body { display: block; }

.tool-section-label {
  margin: 6px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.tool-body pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: #080d13;
  color: #b9cde2;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ============ 状态 / 打字 ============ */
.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.typing-dots { display: inline-flex; gap: 4px; }

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.typing-dots i:nth-child(3) { animation-delay: 0.32s; }

.run-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px 4px;
  padding: 7px 8px 7px 11px;
  border: 1px solid rgba(77, 156, 255, 0.24);
  border-radius: 12px;
  background: var(--accent-soft);
  color: #b7d6ff;
  font-size: 12px;
}

.run-bar span:nth-child(2) { flex: 1 1 auto; }

.run-spinner {
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(77, 156, 255, 0.28);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16vh 24px 24px;
  color: var(--muted);
}

.empty-state img { opacity: 0.9; margin-bottom: 12px; }

.empty-state h2 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p { margin: 0 0 22px; font-size: 13px; line-height: 1.65; }

.empty-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.empty-actions .btn { height: 46px; }

/* ============ 回到底部 ============ */
.scroll-bottom {
  position: absolute;
  right: calc(var(--safe-right) + 14px);
  bottom: calc(var(--safe-bottom) + 92px);
  z-index: 6;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(23, 34, 49, 0.94);
  color: var(--text-dim);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
}

.scroll-bottom svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.unread-badge {
  position: absolute;
  top: -5px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  font-weight: 700;
}

/* ============ 输入区 ============ */
.attach-row {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px calc(var(--safe-right) + 12px) 0 calc(var(--safe-left) + 12px);
  background: rgba(11, 15, 20, 0.92);
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 6px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 11.5px;
  color: var(--text-dim);
}

.attach-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-remove {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.attach-remove:active { background: var(--panel-2); }

.composer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 8px) calc(var(--safe-left) + 10px);
  border-top: 1px solid var(--border-soft);
  background: rgba(11, 15, 20, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.composer-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 132px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer-input::placeholder { color: #5c6b7e; }

.composer-input:focus {
  border-color: rgba(77, 156, 255, 0.7);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.send-btn {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  transition: opacity 0.16s ease, transform 0.12s ease;
}

.send-btn:active { transform: scale(0.94); }
.send-btn:disabled {
  background: var(--panel-2);
  color: var(--muted);
  transform: none;
}

.send-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 14px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 10px;
}

.usage-text {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.composer-hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 抽屉 ============ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 6, 10, 0.62);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.backdrop.show { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(84vw, 340px);
  display: flex;
  flex-direction: column;
  background: #0d131b;
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px -24px rgba(0, 0, 0, 0.9);
  transform: translateX(102%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 8px 16px;
}

.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 650; }

.drawer-actions { display: flex; gap: 0; }

.drawer .icon-btn { width: 36px; height: 36px; }
.drawer .icon-btn svg { width: 19px; height: 19px; }

.pull-hint {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  transition: height 0.12s ease;
}

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conv-item:active { background: var(--panel); }
.conv-item.current { background: var(--panel); border-color: var(--border); }

.conv-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conv-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.conv-time {
  flex: none;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.conv-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 1px;
}

.conv-last {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11.5px;
}

.conv-badges {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.conv-mode {
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 9.5px;
  line-height: 15px;
}

.conv-mode.agent {
  border-color: rgba(56, 211, 159, 0.32);
  background: rgba(56, 211, 159, 0.1);
  color: #93efc8;
}

.conv-running {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  animation: soft-pulse 1.4s ease-in-out infinite;
}

.conv-unread {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.conv-empty {
  padding: 28px 16px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.7;
}

.drawer-foot {
  flex: none;
  padding: 8px calc(var(--safe-right) + 14px) calc(var(--safe-bottom) + 12px) 14px;
  border-top: 1px solid var(--border-soft);
}

.drawer-foot .btn { height: 42px; margin: 0; }

/* ============ 底部抽屉 ============ */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: #101822;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, 0.95);
  transform: translateY(102%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: calc(var(--safe-bottom) + 10px);
  overflow: hidden;
}

.sheet.open { transform: translateY(0); }

.sheet-grab {
  flex: none;
  width: 38px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--border);
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px 6px 16px;
}

.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 650; }

.sheet-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.sheet-item:active { background: var(--panel-2); }

.sheet-item svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sheet-item-main { flex: 1 1 auto; min-width: 0; }
.sheet-item-title { display: block; font-size: 14px; font-weight: 600; }

.sheet-item-desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.sheet-item.danger svg { stroke: var(--danger); }
.sheet-item.danger .sheet-item-title { color: #ffb4b4; }

.sheet-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  text-align: left;
}

.mode-option:active { border-color: var(--accent); background: var(--panel-2); }

.mode-option-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #8fc2ff;
}

.mode-option-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-option-main { flex: 1 1 auto; min-width: 0; }
.mode-option-name { display: block; font-size: 14.5px; font-weight: 650; }

.mode-option-hint {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.mode-option-model {
  display: inline-block;
  margin-top: 6px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 16px;
}

/* 审批 / 提问 */
.approval-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: #cfe3ff;
  font-family: var(--mono);
  font-size: 11.5px;
}

.approval-reason {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.65;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.sheet-actions .btn { height: 46px; width: 100%; }

.sheet-actions .btn[data-act="allow"] {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: #fff;
}

.q-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--panel);
}

.q-head { display: flex; flex-direction: column; gap: 2px; }

.q-header {
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.q-title { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.5; }

.q-options { display: flex; flex-direction: column; gap: 7px; }

.q-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.q-option input {
  flex: none;
  margin-top: 2px;
  accent-color: var(--accent);
}

.q-option.selected { border-color: rgba(77, 156, 255, 0.6); background: var(--accent-soft); }

.q-option-desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.q-custom textarea {
  height: auto;
  min-height: 42px;
  padding: 9px 11px;
  font-size: 14px;
  resize: vertical;
}

.q-error {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

/* 截图 */
.shot-wrap {
  margin: 0;
  padding: 0;
}

.shot-img {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
}

.shot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 44px 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.sheet-error { margin: 0; color: #ffb4b4; font-size: 12.5px; line-height: 1.6; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  z-index: 60;
  max-width: min(88vw, 380px);
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(27, 39, 54, 0.97);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 14px 34px -16px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ 动画 ============ */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes soft-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ============ 桌面 / 大屏 ============ */
@media (min-width: 720px) {
  body {
    background:
      radial-gradient(80% 60% at 50% 0%, rgba(77, 156, 255, 0.08), transparent 70%),
      #06090d;
  }

  .app {
    max-width: 460px;
    margin: 0 auto;
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }

  .drawer {
    right: max(0px, calc(50vw - 230px));
    width: min(340px, 46vw);
  }

  .sheet { max-width: 460px; }

  .scroll-bottom { right: max(calc(var(--safe-right) + 14px), calc(50vw - 216px)); }

  .toast { bottom: calc(var(--safe-bottom) + 104px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* ============ API 设置 ============ */
.api-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.api-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.api-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.api-main { flex: 1 1 auto; min-width: 0; }
.api-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.api-badge {
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 99px;
  padding: 0 6px;
  line-height: 16px;
}
.api-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex: 0 0 auto;
  max-width: 46%;
}
.api-actions .btn-sm { height: 28px; padding: 0 9px; }
.api-actions .btn-sm.danger { color: #ffb4b4; }
.api-form { display: flex; flex-direction: column; gap: 8px; }
.api-form .field { display: flex; flex-direction: column; gap: 4px; }
.api-form .field-label { font-size: 12px; color: var(--text-dim); }
.api-form .input {
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
}
.api-form .input:focus { outline: none; border-color: var(--accent); }
.watch .api-item { flex-direction: column; align-items: stretch; }
.watch .api-actions { max-width: 100%; justify-content: flex-start; }
.watch .api-actions .btn-sm { height: 34px; }
