:root {
  --fg: #111;
  --muted: #8a8a8a;
  --line: #e8e8e8;
  --bg: #fff;
  --soft: #f5f5f5;
  --danger: #c0392b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
body { overscroll-behavior: none; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }

/* ---------- auth ---------- */
.auth-box { margin: auto; width: 100%; max-width: 380px; padding: 28px 24px; }
.auth-box h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: 3px; font-weight: 500; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 16px; min-height: 1em; word-break: break-all; }
.qrs { display: flex; gap: 18px; margin: 0 0 18px; }
.qrs:empty { display: none; }
.qrs figure { margin: 0; }
.qrs img { width: 128px; height: 128px; display: block; border: 1px solid var(--line); }
.qrs figcaption { font-size: 11px; color: var(--muted); margin-top: 5px; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  outline: none;
}
input:focus, textarea:focus { border-color: #bbb; }
button {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}
button:active { background: var(--soft); }
button.primary { background: var(--fg); color: #fff; border-color: var(--fg); }
button.primary:active { opacity: .85; }
button.link { border: none; background: none; color: var(--muted); padding: 8px 0; text-decoration: underline; font-size: 14px; }
button.link.danger { color: var(--danger); }
button.icon { border: none; background: none; font-size: 20px; padding: 6px 8px; line-height: 1; }
.msg { color: var(--danger); font-size: 14px; min-height: 20px; margin: 10px 0 0; }

/* ---------- chat ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg);
}
.who { display: flex; align-items: center; gap: 8px; }
.bar-right { display: flex; align-items: center; gap: 4px; }
.rate-tag {
  font-size: 11px; line-height: 1; padding: 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
  background: var(--bg); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.rate-tag.peak { color: #fff; background: #e5484d; border-color: #e5484d; }
.rate-tag.offpeak { color: #1f7a4d; border-color: #bfe3cf; background: #eefaf3; }
.rate-tag.nobill { color: var(--muted); }
.rate-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rate-strong { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.rate-strong.peak { color: #e5484d; }
.avatar {
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
}
.avatar-img { object-fit: cover; display: block; border: 1px solid var(--line); }
.name { font-size: 15px; }
.list { flex: 1; overflow-y: auto; padding: 14px 12px 8px; -webkit-overflow-scrolling: touch; }
.msg-row { display: flex; margin: 6px 0; }
.msg-row.me { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.me .bubble { background: var(--fg); color: #fff; }
.bubble.sticker { background: none; font-size: 56px; padding: 0 4px; }
.msg-row.me .bubble.sticker { background: none; }
.bubble audio { max-width: 200px; height: 34px; display: block; }
.voice-tag { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.voice-cap { flex-basis: 100%; font-size: 13px; line-height: 1.45; margin-top: 4px; opacity: .9; }
.img-tag { display: block; max-width: 220px; }
.img-tag img { display: block; max-width: 100%; border-radius: 10px; cursor: zoom-in; }
.meta { font-size: 11px; color: var(--muted); margin: 2px 4px 0; text-align: right; }
.meta .speak { border: none; background: none; color: var(--muted); font-size: 13px; line-height: 1; padding: 2px 4px; margin-left: 4px; cursor: pointer; }
.meta .speak:hover { color: #111; }
.meta .speak.loading { opacity: .45; }
.row.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.row.toggle input { width: auto; }
.typing { color: var(--muted); font-size: 13px; padding: 4px 12px; }
.day { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }

.composer {
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.row { display: flex; align-items: flex-end; gap: 8px; }
.row textarea { resize: none; max-height: 120px; border-radius: 18px; padding: 9px 12px; }
button.send { border-radius: 18px; padding: 9px 16px; }
.emoji-panel {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  max-height: 180px; overflow-y: auto; padding: 6px 2px 10px;
}
.emoji-panel button { border: none; background: none; font-size: 24px; padding: 4px 0; }
.rec { display: flex; align-items: center; gap: 12px; padding: 6px 2px 0; }
.rec span { color: var(--danger); font-variant-numeric: tabular-nums; }

/* ---------- sheet ---------- */
.sheet {
  position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 20;
}
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.card h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.pre { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--soft); border-radius: 8px; padding: 10px; margin: 0; }
.facts { margin: 0; padding-left: 18px; font-size: 14px; }
.facts li { margin: 4px 0; }
.facts li button { border: none; background: none; color: var(--muted); font-size: 12px; padding: 0 0 0 6px; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 9px 14px; border-radius: 20px; font-size: 13px; z-index: 50;
  max-width: 86vw; text-align: center;
}

/* 工具调用小条：手机上能看见我在动手 */
.tool-chip .bubble {
  font-size: 12px;
  color: #8a8a8a;
  background: rgba(0, 0, 0, 0.03);
  border: 1px dashed rgba(0, 0, 0, 0.08);
  padding: 6px 10px;
  border-radius: 10px;
  max-width: 82%;
  word-break: break-all;
  line-height: 1.5;
}
.tool-chip.done .bubble {
  opacity: 0.45;
}
