/* ═══════════════════════════════════════════════════════════
   沉浸对话 · 样式系统
   深色优先；分层靠明度与细边框，不靠重阴影。
   移动端优先：默认就是手机竖屏，宽屏只做居中增强。
   ═══════════════════════════════════════════════════════════ */

/* ---------------- 设计令牌 ---------------- */
:root {
  color-scheme: light;

  /* 纸面：整体不是纯白，留一点点暖 */
  --bg: #fbfbfd;
  --bg-elev: #ffffff;
  --bg-sunken: #f4f4f8;
  --bg-chip: #f2f2f7;

  /* 文本四阶 */
  --ink: #14151a;
  --ink-2: #4a4f5c;
  --ink-3: #7c828f;
  --ink-4: #a8adb8;

  /* 线：三级粗细 */
  --line: rgba(20, 21, 26, 0.085);
  --line-strong: rgba(20, 21, 26, 0.16);
  --line-hair: rgba(20, 21, 26, 0.05);

  --accent: #6355f0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(99, 85, 240, 0.1);
  --accent-line: rgba(99, 85, 240, 0.26);
  --accent-glow: rgba(99, 85, 240, 0.22);

  --ok: #17915f;
  --warn: #b4771a;
  --danger: #d6473a;

  --shadow-s: 0 1px 2px rgba(16, 18, 30, 0.05), 0 1px 1px rgba(16, 18, 30, 0.03);
  --shadow-m: 0 2px 6px rgba(16, 18, 30, 0.06), 0 8px 24px rgba(16, 18, 30, 0.07);
  --shadow-l: 0 -8px 40px rgba(16, 18, 30, 0.12);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tap: 44px;

  /* 键盘弹起时的可用高度，由 JS 写入（visualViewport） */
  --vh: 100dvh;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 0.22s;
}

html[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0a0b0f;
  --bg-elev: #14161d;
  --bg-sunken: #101218;
  --bg-chip: #1b1e27;

  --ink: #f0f1f5;
  --ink-2: #b6bac6;
  --ink-3: #878d9c;
  --ink-4: #626877;

  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.17);
  --line-hair: rgba(255, 255, 255, 0.045);

  --accent: #8b7dff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(139, 125, 255, 0.15);
  --accent-line: rgba(139, 125, 255, 0.34);
  --accent-glow: rgba(139, 125, 255, 0.28);

  --ok: #4ec98d;
  --warn: #e0aa4e;
  --danger: #ff7a6b;

  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-m: 0 2px 8px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-l: 0 -8px 48px rgba(0, 0, 0, 0.6);
}

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

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

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.68 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

/* 深色模式给整页一点极轻的径向光，避免死黑 */
html[data-theme='dark'] body {
  background-image: radial-gradient(120% 70% at 50% -10%, rgba(139, 125, 255, 0.075), transparent 60%);
  background-repeat: no-repeat;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

::selection {
  background: var(--accent-soft);
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--vh);
  overflow: hidden;
}

/* ---------------- 顶栏 ---------------- */
.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(var(--sat) + 6px) calc(var(--sar) + 8px) 8px calc(var(--sal) + 8px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line-hair);
  z-index: 5;
}

.bar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 17px;
  color: var(--ink-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform 0.12s var(--ease);
}

.icon:active {
  background: var(--bg-chip);
  color: var(--ink);
  transform: scale(0.94);
}

.icon.attach {
  font-size: 18px;
}

/* ---------------- 消息流 ---------------- */
.stream {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px calc(var(--sar) + 14px) 10px calc(var(--sal) + 14px);
  scroll-behavior: smooth;
}

.stream::-webkit-scrollbar {
  width: 6px;
}

.stream::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

.msg {
  max-width: 680px;
  margin: 0 auto 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: rise 0.26s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.msg .bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
  word-break: break-word;
  box-shadow: var(--shadow-s);
  font-size: 15.5px;
  line-height: 1.72;
}

.msg.assistant .bubble {
  align-self: flex-start;
  border-bottom-left-radius: 7px;
  background: color-mix(in srgb, var(--bg-elev) 92%, var(--bg));
}

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

.msg.user .bubble {
  align-self: flex-end;
  background: linear-gradient(168deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 82%, #2a1c6e) 100%);
  color: var(--accent-ink);
  border-color: transparent;
  border-bottom-right-radius: 7px;
  box-shadow: 0 1px 2px var(--accent-glow), 0 8px 26px -12px var(--accent-glow);
}

.actions {
  display: flex;
  gap: 2px;
  padding: 0 4px;
  max-width: 86%;
}

.msg.user .actions {
  justify-content: flex-end;
}

.actions button {
  color: var(--ink-4);
  font-size: 12.5px;
  padding: 7px 9px;
  border-radius: 9px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.actions button:active {
  background: var(--bg-chip);
  color: var(--ink);
}

.msg:not(.open) .actions {
  display: none;
}

/* 思考过程 */
.thinking {
  max-width: 86%;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 9px 13px;
  font-size: 13.5px;
  color: var(--ink-3);
  background: var(--bg-sunken);
}

.thinking summary {
  color: var(--ink-4);
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}

.thinking summary::-webkit-details-marker {
  display: none;
}

.thinking summary::before {
  content: '▸ ';
}

.thinking[open] summary::before {
  content: '▾ ';
}

.thinking .body {
  white-space: pre-wrap;
  margin-top: 7px;
  line-height: 1.62;
}

/* 气泡内的 markdown */
.bubble p {
  margin: 0.55em 0;
}

.bubble > :first-child {
  margin-top: 0;
}

.bubble > :last-child {
  margin-bottom: 0;
}

.bubble code {
  background: rgba(125, 125, 145, 0.15);
  padding: 1.5px 5px;
  border-radius: 6px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

.bubble pre {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  padding: 11px 13px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 0.75em 0;
  -webkit-overflow-scrolling: touch;
}

.bubble pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

.bubble blockquote {
  margin: 0.65em 0;
  padding: 2px 0 2px 11px;
  border-left: 2px solid var(--accent-line);
  color: var(--ink-2);
}

.bubble ul,
.bubble ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
}

.bubble li {
  margin: 0.2em 0;
}

.bubble a {
  color: inherit;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
}

.bubble strong {
  font-weight: 650;
}

.cursor::after {
  content: '▍';
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1.1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* 空态 */
.empty {
  max-width: 560px;
  margin: 11vh auto 0;
  text-align: center;
  color: var(--ink-3);
  padding: 0 10px;
}

.empty .mark {
  font-size: 38px;
  filter: saturate(0.9);
}

.empty h2 {
  margin: 10px 0 12px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.empty p {
  font-size: 13.5px;
  line-height: 1.75;
  margin: 0;
}

.empty .starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

/* ---------------- 回到底部 ---------------- */
.jump {
  position: absolute;
  right: calc(var(--sar) + 14px);
  bottom: calc(var(--sab) + 104px);
  z-index: 6;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(12px);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  box-shadow: var(--shadow-m);
  transition: transform 0.15s var(--ease);
}

.jump:active {
  transform: scale(0.95);
}

/* ---------------- 输入区 ---------------- */
.composer {
  flex: 0 0 auto;
  padding: 8px calc(var(--sar) + 10px) calc(var(--sab) + 8px) calc(var(--sal) + 10px);
  background: var(--bg);
  border-top: 1px solid var(--line-hair);
  z-index: 5;
}

.composer-row {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

#input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  max-height: 34vh;
  padding: 12px 15px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  outline: none;
  font-size: 16px;
  line-height: 1.55;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

#input::placeholder {
  color: var(--ink-4);
}

#input:focus {
  border-color: var(--accent-line);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.send {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: linear-gradient(168deg, var(--accent), color-mix(in srgb, var(--accent) 80%, #2a1c6e));
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px -2px var(--accent-glow);
  transition: transform 0.14s var(--ease), opacity 0.16s var(--ease);
}

.send:active {
  transform: scale(0.92);
}

.send:disabled {
  opacity: 0.42;
}

.send.stop {
  background: var(--danger);
  font-size: 13px;
  box-shadow: 0 2px 10px -2px color-mix(in srgb, var(--danger) 60%, transparent);
}

.hint {
  max-width: 680px;
  margin: 7px auto 0;
  font-size: 12px;
  color: var(--ink-4);
  min-height: 15px;
  text-align: center;
  transition: color 0.2s var(--ease);
}

/* 键盘弹起时收紧留白，把高度让给输入框 */
html.typing .empty {
  margin-top: 4vh;
}

.app.kb-open .jump {
  bottom: calc(var(--sab) + 12px);
}

/* ---------------- 附件 ---------------- */
.attach-bar {
  max-width: 680px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(100%, 380px);
  padding: 7px 11px;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--ink);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: rise 0.2s var(--ease) both;
}

.attach-chip b {
  color: var(--ink-3);
  font-weight: 400;
  padding-left: 2px;
}

.attach-chip.mini {
  background: var(--bg-chip);
  border-color: var(--line);
  color: var(--ink-2);
  padding: 4px 9px;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 86%;
}

.msg.user .thumb {
  width: 138px;
  max-height: 138px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
}

.msg.user.anchor {
  align-items: stretch;
}

.anchor-bubble {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-sunken) !important;
  color: var(--ink-2) !important;
  border: 1px dashed var(--line-strong) !important;
  font-size: 13px;
  align-self: flex-start !important;
  max-width: 100% !important;
  border-radius: 13px !important;
  box-shadow: none !important;
}

.anchor-toggle {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 12.5px;
}

.anchor-body {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg-sunken);
  padding: 11px 13px;
  -webkit-overflow-scrolling: touch;
}

.anchor-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.msg .meter {
  font-size: 11.5px;
  color: var(--ink-4);
  padding: 0 4px;
  max-width: 86%;
  font-variant-numeric: tabular-nums;
}

.msg.user .meter {
  align-self: flex-end;
}

/* 拖拽落区 */
.app.dropping::after {
  content: '松手即挂载';
  position: fixed;
  inset: 8px;
  z-index: 8;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent-line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  backdrop-filter: blur(3px);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

/* ---------------- 预算条 ---------------- */
.budget {
  max-width: 680px;
  margin: 0 auto 8px;
  padding: 9px 13px;
  border-radius: 11px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--line);
}

.budget.warn {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}

.budget.over {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

.lnk {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0 2px;
}

/* ---------------- 遮罩 / 抽屉 / 弹层 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 14, 0.42);
  backdrop-filter: blur(2px);
  z-index: 20;
  animation: fade 0.18s var(--ease);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 336px);
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 12px) 12px calc(var(--sab) + 12px);
  gap: 10px;
  animation: slideIn 0.24s var(--ease);
  box-shadow: var(--shadow-m);
}

@keyframes slideIn {
  from {
    transform: translateX(-18px);
    opacity: 0.4;
  }
}

.drawer-head,
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-head strong,
.sheet-head strong {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 4px;
  align-content: start;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 9px 11px;
  border-radius: 13px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14.5px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.conv-item:active {
  background: var(--bg-chip);
}

.conv-item.on {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 550;
}

.conv-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item .del {
  color: var(--ink-4);
  font-size: 14px;
  padding: 8px;
  border-radius: 9px;
}

.drawer-foot {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.sheet,
.meter-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 6px 16px calc(var(--sab) + 20px);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheetUp 0.26s var(--ease);
  box-shadow: var(--shadow-l);
}

@keyframes sheetUp {
  from {
    transform: translateY(28px);
    opacity: 0.4;
  }
}

.sheet-grab {
  width: 40px;
  height: 4px;
  border-radius: 3px;
  background: var(--line-strong);
  margin: 6px auto 12px;
}

.sheet-body {
  display: grid;
  gap: 18px;
  padding-top: 14px;
  max-width: 600px;
  margin: 0 auto;
}

/* ---------------- 表单 ---------------- */
.field {
  display: grid;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.field > span {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 500;
}

.field > span em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-4);
  font-weight: 400;
}

.field-note {
  font-style: normal;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-4);
}

.field-note.good {
  color: var(--ok);
}

.field.row {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 11px;
  font-size: 14.5px;
  color: var(--ink);
}

.field input[type='text'],
.field input[type='password'],
.field textarea {
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  outline: none;
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.field input[type='text']:focus,
.field input[type='password']:focus,
.field textarea:focus {
  border-color: var(--accent-line);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  height: 32px;
}

.field input[type='range']:disabled {
  opacity: 0.4;
}

.field input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13.5px;
  color: var(--ink-2);
  min-height: 38px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.12s var(--ease);
}

.chip:active {
  transform: scale(0.96);
}

.chip.on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 600;
}

.empty .chip {
  background: var(--bg-elev);
  box-shadow: var(--shadow-s);
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 13px;
  padding: 12px 15px;
  min-height: var(--tap);
  font-size: 15px;
  transition: background 0.16s var(--ease), transform 0.12s var(--ease), border-color 0.16s var(--ease);
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  background: linear-gradient(168deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #2a1c6e));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px -3px var(--accent-glow);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn.ghost:active {
  background: var(--bg-chip);
}

.btn.tiny {
  min-height: 36px;
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 11px;
  justify-self: start;
}

.btn.block {
  width: 100%;
}

/* ---------------- 档位预览 ---------------- */
.peek {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-sunken);
  padding: 12px 14px;
  max-height: 260px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.peek pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.72;
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

.peek-warn {
  font-size: 12px;
  color: var(--warn);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-hair);
}

.peek-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-hair);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-4);
}

.peek-foot b {
  color: var(--ink-2);
}

.peek-others {
  margin: 6px 0 0;
  padding-left: 1.1em;
  display: grid;
  gap: 2px;
}

.peek-others li {
  list-style: '· ';
}

.sheet-note {
  font-size: 12.5px;
  color: var(--ink-4);
  line-height: 1.72;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ---------------- 计量面板 ---------------- */
.meter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 9px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  background: var(--bg-sunken);
  display: grid;
  gap: 4px;
  min-width: 0;
}

.stat span {
  font-size: 11.5px;
  color: var(--ink-4);
}

.stat b {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.good {
  color: var(--ok);
}

.warn {
  color: var(--warn);
}

.dim {
  color: var(--ink-4);
}

.meter-note {
  font-size: 12.5px;
  line-height: 1.72;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 14px;
  word-break: break-word;
}

.meter-tip {
  font-size: 12px;
  color: var(--ink-4);
  line-height: 1.68;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 14px;
}

.meter-hist summary {
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  padding: 12px 0 8px;
  list-style: none;
}

.meter-hist summary::-webkit-details-marker {
  display: none;
}

.meter-hist summary::before {
  content: '▸ ';
}

.meter-hist[open] summary::before {
  content: '▾ ';
}

.hist {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.hist-row {
  display: flex;
  gap: 9px;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.hist-row span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 92px);
  transform: translateX(-50%);
  max-width: 88vw;
  background: color-mix(in srgb, var(--ink) 94%, transparent);
  color: var(--bg);
  padding: 11px 17px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.55;
  z-index: 40;
  text-align: center;
  box-shadow: var(--shadow-m);
  animation: toastIn 0.22s var(--ease);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ---------------- 宽屏 ---------------- */
@media (min-width: 720px) {
  .bar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .stream {
    padding-left: 22px;
    padding-right: 22px;
  }

  .msg .bubble,
  .actions,
  .msg .meter,
  .thumbs {
    max-width: 76%;
  }

  .msg .bubble {
    font-size: 16px;
  }

  .sheet,
  .meter-panel {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(680px, 92vw);
    border-radius: 20px 20px 0 0;
  }

  @keyframes sheetUp {
    from {
      opacity: 0;
      transform: translate(-50%, 28px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
