/* DeepSeek 手机端 PWA 样式。深色为主，浅色全套覆盖。 */

:root {
  --chat-font-size: 16px;

  --bg: #0e1116;
  --bg-2: #131720;
  --surface: #171c26;
  --surface-2: #1e242f;
  --elevated: #222a38;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #e9edf5;
  --text-2: #b6bdcb;
  --text-3: #7d8698;

  --accent: #4d6bfe;
  --accent-soft: rgba(77, 107, 254, 0.16);
  --accent-text: #8ea2ff;

  --ok: #34c759;
  --warn: #ffb020;
  --danger: #ff5a5f;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --topbar-h: 52px;
  --tabbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.5);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f7f8fa;
  --surface: #f2f4f7;
  --surface-2: #e9edf3;
  --elevated: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --text: #16181d;
  --text-2: #4a5261;
  --text-3: #858d9c;

  --accent: #3d5afe;
  --accent-soft: rgba(61, 90, 254, 0.1);
  --accent-text: #2a44d6;
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, input, select, textarea { font-family: inherit; color: inherit; }
button { background: none; border: none; padding: 0; cursor: pointer; }

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

#offline-banner {
  background: var(--warn);
  color: #221a00;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 5px 10px;
}
#offline-banner[hidden] { display: none; }

/* ------------------------------ 顶栏 ------------------------------ */

#topbar {
  flex: 0 0 auto;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.top-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex: 0 0 auto;
}
.top-btn:active { background: var(--surface); }

#title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

.top-right { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }

.model-chip {
  font-size: 11px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 9px;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.model-chip[hidden] { display: none; }

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

#view {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ------------------------------ 标签栏 ------------------------------ */

#tabbar {
  flex: 0 0 auto;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  z-index: 20;
}

#tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.15s;
}
#tabbar button.active { color: var(--accent-text); }
#tabbar button:active { opacity: 0.6; }

/* ------------------------------ 对话 ------------------------------ */

.chat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 0 8px;
}

.messages {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 空状态 */

.empty {
  padding: 42px 6px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-logo { color: var(--accent); opacity: 0.9; margin-bottom: 14px; }
.empty-title { font-size: 21px; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.01em; }
.empty-sub { font-size: 13px; color: var(--text-3); margin: 0 0 26px; line-height: 1.6; }

.sugg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  width: 100%;
  max-width: 520px;
}
.sugg {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sugg:active { background: var(--surface-2); }
.sugg-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sugg-text { font-size: 11.5px; color: var(--text-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 消息 */

.msg { display: flex; flex-direction: column; }

.msg-user { align-items: flex-end; }
.msg-user .bubble {
  max-width: 86%;
  background: var(--accent);
  color: #fff;
  border-radius: 18px 18px 5px 18px;
  padding: 10px 14px;
  font-size: var(--chat-font-size);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user .user-image {
  max-width: 100%;
  border-radius: 12px;
  display: block;
  margin: 6px 0;
}
.msg-user .user-doc {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 4px 8px;
  margin-top: 6px;
  font-size: 12px;
}
.msg-user .user-text:empty { display: none; }

.msg-assistant { align-items: stretch; }
.assistant-body {
  font-size: var(--chat-font-size);
  line-height: 1.68;
  display: flex;
  flex-direction: column;
  gap: 10px;
  word-break: break-word;
}

.blk { animation: blk-in 0.18s ease-out; }
@keyframes blk-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* 思考块 */

.blk-thinking {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.think-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: left;
}
.think-label { flex: 1 1 auto; }
.think-chev {
  width: 7px; height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s;
  margin-right: 3px;
}
.blk-thinking.is-open .think-chev { transform: rotate(45deg); }
.think-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.think-body { border-top: 1px solid var(--border); }
.think-text {
  padding: 10px 13px 12px;
  font-size: 12.5px;
  line-height: 1.62;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* 工具调用行 */

.tool-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-3);
  padding: 4px 2px;
  min-width: 0;
}
.tool-icon { flex: 0 0 auto; font-size: 12px; }
.tool-label { flex: 0 0 auto; }
.tool-detail {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tool-link { text-decoration: underline; text-decoration-color: var(--border-strong); }

/* 搜索卡片 */

.blk-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 9px 10px 6px;
}
.search-head { padding: 0 2px 6px; }
.search-title { font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: 0.02em; }
.search-list { display: flex; flex-direction: column; gap: 2px; }
.search-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 7px 6px;
  border-radius: 9px;
}
.search-item:active { background: var(--surface-2); }
.search-item-top { display: flex; gap: 8px; align-items: flex-start; }
.search-thumb {
  width: 42px; height: 42px;
  object-fit: cover;
  border-radius: 7px;
  flex: 0 0 auto;
  background: var(--surface-2);
}
.search-item-meta { min-width: 0; flex: 1 1 auto; }
.search-item-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-item-sub { display: flex; gap: 8px; margin-top: 2px; font-size: 11px; color: var(--text-3); }
.search-snippet {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-error, .search-empty { font-size: 12px; color: var(--text-3); padding: 6px; }

/* 引用 */

.citations { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.citation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px 3px 4px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 11.5px;
}
.citation-index {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 9.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.citation-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

/* 正文排版 */

.md-body { color: var(--text); }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body p { margin: 0.55em 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1.05em 0 0.45em;
  line-height: 1.35;
  font-weight: 650;
}
.md-body h1 { font-size: 1.34em; }
.md-body h2 { font-size: 1.2em; }
.md-body h3 { font-size: 1.08em; }
.md-body ul, .md-body ol { margin: 0.55em 0; padding-left: 1.35em; }
.md-body li { margin: 0.24em 0; }
.md-body a { color: var(--accent-text); text-decoration: underline; text-decoration-color: var(--border-strong); word-break: break-all; }
.md-body strong { font-weight: 650; }
.md-body blockquote {
  margin: 0.6em 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.md-body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 1.5px 5px;
  border-radius: 5px;
}
.md-body pre { margin: 0; }
.md-body .md-code { margin: 0.7em 0; background: #12151c; border: 1px solid rgba(255,255,255,0.07); border-radius: 11px; overflow: hidden; }
html[data-theme="light"] .md-body .md-code { background: #1b1f27; }
.md-body .md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 11px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.md-body .md-code-lang { font-size: 11px; color: #8b93a7; font-family: var(--mono); }
.md-body .md-copy {
  font-size: 11px;
  color: #a9b2c6;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
}
.md-body .md-code pre { padding: 11px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md-body .md-code code {
  background: none;
  padding: 0;
  color: #dfe6f5;
  font-size: 12.5px;
  line-height: 1.62;
  white-space: pre;
}
.md-body .md-table { width: 100%; border-collapse: collapse; margin: 0.7em 0; font-size: 0.92em; display: block; overflow-x: auto; }
.md-body .md-table th, .md-body .md-table td { border: 1px solid var(--border-strong); padding: 6px 9px; text-align: left; }
.md-body .md-table th { background: var(--surface); font-weight: 600; }
.md-body img { max-width: 100%; border-radius: 10px; }

/* 消息操作 */

.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 7px;
  opacity: 0.9;
}
.msg-actions .act {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--surface);
}
.msg-actions .act:active { background: var(--surface-2); }

.msg.is-error .msg-error {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: 10px;
  padding: 8px 11px;
  line-height: 1.5;
}

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

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.attach-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.attach-strip[hidden] { display: none; }
.attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  flex: 0 0 auto;
  max-width: 190px;
}
.attach-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.attach-name { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove { color: var(--text-3); font-size: 15px; padding: 0 2px; }

.input-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.15s;
}
.input-row:focus-within { border-color: var(--border-strong); }

.input-row textarea {
  width: 100%;
  border: none;
  outline: none;
  background: none;
  resize: none;
  font-size: max(16px, var(--chat-font-size));
  line-height: 1.5;
  max-height: 168px;
  color: var(--text);
  padding: 2px 0;
  display: block;
}
.input-row textarea::placeholder { color: var(--text-3); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-weight: 500;
  transition: all 0.15s;
}
.chip .chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background 0.15s;
}
.chip.on {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}
.chip.on .chip-dot { background: var(--accent); }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 18px;
  background: var(--surface);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.recording {
  color: #fff;
  background: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.55; } }

.send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  transition: opacity 0.15s, transform 0.1s;
}
.send-btn:active { transform: scale(0.93); }
.send-btn.is-stop { background: var(--surface-2); color: var(--text); }

/* ------------------------------ 抽屉 ------------------------------ */

#drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 40;
}
#drawer-mask.show { opacity: 1; pointer-events: auto; }

#drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(80vw, 320px);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
#drawer.open { transform: none; }

.drawer-head {
  padding: 16px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.drawer-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 16px; }

.drawer-new {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.drawer-item {
  display: flex;
  align-items: center;
  border-radius: 11px;
  margin-bottom: 2px;
}
.drawer-item.is-active { background: var(--surface); }
.drawer-item-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.drawer-item-title {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-item-sub { font-size: 11px; color: var(--text-3); }
.drawer-item-del { color: var(--text-3); font-size: 13px; padding: 8px 10px; }
.drawer-empty { font-size: 12.5px; color: var(--text-3); padding: 12px; text-align: center; }

/* ------------------------------ 设置 ------------------------------ */

.settings {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 40px;
}

.set-section {
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 0 14px;
}
.set-title {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 2px 6px;
}
.set-desc { font-size: 12px; color: var(--text-3); margin: 0 2px 8px; line-height: 1.5; }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
}
.set-row-left { flex: 1 1 auto; min-width: 0; }
.set-label { font-size: 14px; color: var(--text); }
.set-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }
.set-row-right { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; max-width: 58%; }
.set-value { font-size: 12px; color: var(--text-3); }

.switch {
  width: 46px; height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  position: relative;
  transition: background 0.2s;
  flex: 0 0 auto;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

.select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  max-width: 190px;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}

.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  width: 100%;
  min-width: 0;
}
.input:focus { border-color: var(--accent); }

.key-wrap { display: flex; align-items: center; gap: 6px; width: 100%; }
.key-wrap .input { font-size: 13px; font-family: var(--mono); }

.row-inline { display: flex; align-items: center; gap: 6px; }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.5; }
.btn-mini { padding: 6px 11px; font-size: 12.5px; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; width: 100%; margin-top: 10px; padding: 11px; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

.test-status {
  font-size: 12px;
  line-height: 1.5;
  padding: 0 4px 8px;
  color: var(--text-3);
  min-height: 4px;
}
.test-status.is-ok { color: var(--ok); }
.test-status.is-bad { color: var(--danger); }
.test-status.is-pending { color: var(--warn); }

.balance-value { font-size: 15px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.balance-value.is-low { color: var(--danger); }

.range { width: 120px; accent-color: var(--accent); }
.range-value { font-size: 12px; color: var(--text-3); min-width: 34px; }

.set-note {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.65;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin-top: 6px;
}

/* ------------------------------ 底部弹层 ------------------------------ */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  animation: fade-in 0.18s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  background: var(--bg-2);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: slide-up 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet-tall { max-height: 90vh; }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sheet-title { font-size: 16px; font-weight: 650; }
.sheet-close { font-size: 17px; color: var(--text-3); padding: 2px 6px; }
.sheet-body { overflow-y: auto; padding: 14px 16px 24px; -webkit-overflow-scrolling: touch; }

.saving-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  z-index: 70;
}
.sheet-overlay { position: fixed; }
.sheet { position: relative; }

.icon-hint {
  margin: 0 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 14px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.7;
}
.icon-editor-host { padding: 12px 16px 4px; overflow-y: auto; }

/* ------------------------------ 用量面板 ------------------------------ */

.usage-loading { text-align: center; color: var(--text-3); font-size: 13px; padding: 30px; }

.usage-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 15px 16px;
  margin-bottom: 14px;
}
.usage-card-label { font-size: 11.5px; color: var(--text-3); }
.usage-card-value { font-size: 27px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.usage-card-sub { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

.usage-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.usage-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.usage-stat-label { font-size: 10.5px; color: var(--text-3); }
.usage-stat-value { font-size: 14.5px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.usage-stat-sub { font-size: 10px; color: var(--text-3); margin-top: 2px; }

.usage-subtitle { font-size: 11.5px; font-weight: 650; color: var(--text-3); margin: 18px 0 8px; letter-spacing: 0.04em; }

.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 104px;
  padding: 6px 2px 0;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart-caption { font-size: 9.5px; color: var(--text-3); order: 3; }
.chart-value { font-size: 8.5px; color: var(--text-3); order: 1; height: 11px; white-space: nowrap; transform: scale(0.95); }
.chart-bar {
  width: 100%;
  max-width: 30px;
  background: var(--accent);
  border-radius: 4px 4px 2px 2px;
  order: 2;
  transition: height 0.3s;
  min-height: 2px;
}
.chart-bar.is-zero { background: var(--surface-2); }

.usage-models, .usage-list { display: flex; flex-direction: column; gap: 5px; }
.usage-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12.5px;
}
.usage-model-name { font-family: var(--mono); color: var(--text-2); flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-model-sub { color: var(--text-3); font-size: 11px; flex: 0 0 auto; }
.usage-model-cost { font-weight: 650; font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.usage-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; }
.usage-item-top { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.usage-item-time { color: var(--text-3); flex: 0 0 auto; }
.usage-item-model { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-item-cost { font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-item-detail { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.usage-empty { font-size: 12.5px; color: var(--text-3); padding: 14px; text-align: center; }
.usage-note { font-size: 11px; color: var(--text-3); line-height: 1.6; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ------------------------------ Toast ------------------------------ */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  transform: translate(-50%, 12px);
  background: rgba(30, 36, 47, 0.96);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 16px;
  border-radius: 12px;
  max-width: 84vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 90;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

html[data-theme="light"] #toast { background: rgba(22, 24, 29, 0.94); }

/* 滚动条 */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
