:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --primary: #1a73e8;
  --text: #111;
  --muted: #888;
  --border: #e5e5ea;
  --error: #d93025;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.banner {
  background: var(--error);
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
}
.banner-hidden { display: none; }
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 120px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.bubble-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble-reply, .bubble-system {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble-loading::after {
  content: '正在检索…';
  color: var(--muted);
}
.citation {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin: 6px 0 2px;
}
.passage { margin: 0 0 8px; }
.passage:last-child { margin-bottom: 0; }
.lowmatch-note {
  background: #fff8e1;
  border: 1px solid #f0d57a;
  color: #6b4f00;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}
.composer {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  outline: none;
}
.input:disabled { background: #f0f0f0; }
.submit {
  padding: 0 16px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 14px;
}
.submit:disabled { background: #b0b0b0; }
.disclaimer {
  position: fixed;
  bottom: 64px; left: 0; right: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
@media (min-width: 640px) {
  .thread, .composer { max-width: 640px; margin-left: auto; margin-right: auto; }
  .composer { left: 50%; transform: translateX(-50%); }
}
