:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --bg-subtle: #f4f2eb;
  --sidebar-bg: #f4f1e9;
  --surface: #fffefa;
  --surface-hover: #eeece4;
  --surface-active: #e7e4da;
  --border: #e8e4da;
  --border-strong: #d8d2c5;
  --text: #282b27;
  --text-secondary: #696d64;
  --text-tertiary: #92958b;
  --accent: #356b60;
  --accent-hover: #28564d;
  --accent-soft: #e7efeb;
  --accent-text: #28584e;
  --danger: #b94d3b;
  --shadow-sm: 0 2px 8px rgba(54, 49, 37, 0.05);
  --shadow-md: 0 12px 32px rgba(54, 49, 37, 0.09);
  --shadow-lg: 0 20px 52px rgba(36, 34, 28, 0.18);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d211e;
  --bg-subtle: #232824;
  --sidebar-bg: #191d1a;
  --surface: #252a26;
  --surface-hover: #2c322d;
  --surface-active: #343b35;
  --border: #343b35;
  --border-strong: #485149;
  --text: #edf0e9;
  --text-secondary: #b0b8ad;
  --text-tertiary: #858e83;
  --accent: #8db9a8;
  --accent-hover: #a6cbbd;
  --accent-soft: #2b3a33;
  --accent-text: #c4dfd2;
  --danger: #ef8b79;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, textarea { font: inherit; }

button { -webkit-appearance: none; appearance: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell { display: flex; height: 100dvh; overflow: hidden; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 22px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .brand-logo { color: #14161a; }
.brand-logo svg { width: 19px; height: 19px; }

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close { display: none !important; }

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 28px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--accent);
  color: #fffefa;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(53, 107, 96, 0.16);
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
}
.new-chat:hover { background: var(--accent-hover); box-shadow: 0 6px 14px rgba(53, 107, 96, 0.2); }
.new-chat:active { transform: scale(0.985); }
.new-chat svg { width: 16px; height: 16px; }

.sidebar-label {
  padding: 0 10px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.conversation-list { flex: 1; overflow-y: auto; padding-right: 2px; }

.empty-hint { padding: 6px 10px; font-size: 12px; color: var(--text-tertiary); }

.conversation-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 10px 12px 10px 15px;
  margin-bottom: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 12px;
  text-align: left;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.16s, color 0.16s, transform 0.12s, box-shadow 0.16s;
}
/* 左侧指示条：让"当前在哪一条"一眼可见，而不是只靠背景色 */
.conversation-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  border-radius: 3px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: height 0.2s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.conversation-item:hover { background: var(--surface-hover); color: var(--text); }
.conversation-item:active { transform: scale(0.985); }
.conversation-item.active {
  background: var(--surface);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.conversation-item.active::before { height: 16px; }
.conversation-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.conversation-item.nudge { animation: nudge 0.28s ease-in-out; }

.sidebar-foot { border-top: 1px solid var(--border-strong); padding-top: 16px; margin-top: 10px; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 0 8px; min-width: 0; }
.user-avatar-sm {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 11px; font-weight: 650;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.user-label { font-size: 11px; color: var(--text-tertiary); }
.user-meta code {
  font-size: 10px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 190px;
}

.sidebar-overlay { display: none; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  height: 74px;
  flex: 0 0 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 36px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-group { min-width: 0; }
.app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-subtitle {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 550;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: #12b76a; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- 消息流 ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 46px 28px 28px;
  scroll-behavior: smooth;
}

.messages > * { max-width: 760px; margin-left: auto; margin-right: auto; }

.msg { display: flex; gap: 13px; margin-bottom: 30px; animation: rise 0.24s ease-out both; }
.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
  margin-top: 1px;
}
.avatar.bot {
  background: var(--accent);
  color: #fffefa;
}
.avatar.bot svg { width: 18px; height: 18px; }
.avatar.me { background: var(--surface-active); color: var(--text-secondary); }

.msg-body { min-width: 0; flex: 1; }
.msg.user .msg-body { display: flex; justify-content: flex-end; }

.bubble {
  line-height: 1.8;
  word-break: break-word;
  color: var(--text);
}

/* 仅用户消息是纯文本，需要保留手打回车；助手消息是 Markdown，
   pre-wrap 会把 HTML 源码里的格式化换行渲染成多余空行 */
.msg.user .bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px 18px 5px 18px;
  background: var(--accent-soft);
  color: var(--accent-text);
  white-space: pre-wrap;
}

.msg.assistant .bubble { max-width: 100%; padding: 3px 0; }

/* ---------- Markdown 正文排版 ----------
   节奏参考 ChatGPT：正文 15px / 行高 1.7，段间 12px，
   列表项间 3px，嵌套列表紧贴父项，避免大块留白 */
.md { font-size: 15px; line-height: 1.7; color: var(--text); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }

.md p { margin: 0 0 12px; }
.md strong { font-weight: 650; color: var(--text); }
.md em { font-style: italic; }
.md del { color: var(--text-tertiary); }

.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 20px 0 8px;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -0.015em;
}
.md h1 { font-size: 1.4em; }
.md h2 { font-size: 1.25em; }
.md h3 { font-size: 1.12em; }
.md h4, .md h5, .md h6 { font-size: 1em; }

.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 3px 0; padding-left: 2px; }
.md li::marker { color: var(--accent); font-weight: 600; }
.md li > p { margin: 0 0 4px; }
.md li > ul, .md li > ol { margin: 4px 0 3px; }
.md input[type="checkbox"] { margin-right: 6px; accent-color: var(--accent); }

.md blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text-secondary);
}
.md blockquote p:last-child { margin-bottom: 0; }

.md a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: color 0.16s, text-decoration-color 0.16s;
}
.md a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.md :not(pre) > code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--accent-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
}

.md pre {
  position: relative;
  margin: 16px 0;
  padding: 42px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow-x: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .md pre { box-shadow: none; }
.md pre code {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre;
}
.code-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}
.code-lang {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.code-copy {
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.code-copy:hover { background: var(--surface); color: var(--accent); border-color: var(--border); }

.md hr { margin: 24px 0; border: 0; border-top: 1px solid var(--border-strong); }
.md table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.md th, .md td { padding: 9px 13px; border: 1px solid var(--border); text-align: left; }
.md th { background: var(--bg-subtle); font-weight: 650; }
.md tr:hover td { background: color-mix(in srgb, var(--surface-hover) 45%, transparent); }
.md img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* ---------- 文件附件 ---------- */
.msg-files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.msg-files:empty { display: none; }
.file-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, transform 0.16s;
}
a.file-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.file-icon {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.file-icon svg { width: 19px; height: 19px; }
.file-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.file-name {
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-size { font-size: 11px; color: var(--text-tertiary); }
.file-card.image { display: block; padding: 6px; max-width: 320px; }
.file-card.image img { display: block; width: 100%; border-radius: 8px; }
.file-card.image figcaption {
  padding: 6px 4px 2px;
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.welcome-block { padding: 66px 12px 52px; text-align: center; animation: rise 0.3s ease-out both; }
.welcome-icon {
  width: 60px; height: 60px;
  margin: 0 auto 22px;
  border-radius: 20px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fffefa;
  box-shadow: 0 8px 20px rgba(53, 107, 96, 0.18);
}
.welcome-icon svg { width: 28px; height: 28px; }
.welcome-title { margin: 0 0 10px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 30px; font-weight: 600; letter-spacing: -0.035em; }
.welcome-desc {
  margin: 0 auto;
  max-width: 500px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
}

.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  border-radius: 1px;
  animation: blink 1s steps(2, start) infinite;
}

.thinking { display: inline-flex; align-items: center; gap: 5px; height: 1.6em; }
.thinking i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.2s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.16s; }
.thinking i:nth-child(3) { animation-delay: 0.32s; }

/* ---------- 建议与输入 ---------- */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  padding: 0 28px 16px;
}
.suggestions:empty { display: none; }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.16s, color 0.16s, background 0.16s, transform 0.16s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip:active { transform: translateY(1px); }

.composer-area {
  flex: 0 0 auto;
  padding: 4px 28px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}
.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 9px 10px 9px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
}

textarea {
  flex: 1;
  min-width: 0;
  max-height: 168px;
  align-self: center;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  line-height: 24px;
}
textarea::placeholder { color: var(--text-tertiary); }
.composer textarea:focus-visible { outline: none; }

.composer-actions { display: flex; align-items: center; gap: 4px; padding-bottom: 1px; }

.send-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s, opacity 0.18s;
}
[data-theme="dark"] .send-btn { color: #14161a; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.send-btn svg { width: 20px; height: 20px; }

.stop-btn { width: 36px; height: 36px; border: 1px solid var(--border); }
.stop-btn svg { width: 14px; height: 14px; }

.composer-foot {
  max-width: 760px;
  margin: 10px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  min-height: 16px;
}
.status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.error { color: var(--danger); }

.hidden { display: none !important; }

/* ---------- 访问门禁 ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: rise 0.3s ease-out both;
}

.gate-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.gate-icon svg { width: 26px; height: 26px; }

.gate-title { margin: 0 0 6px; font-size: 18px; font-weight: 650; }
.gate-desc { margin: 0 0 20px; font-size: 13px; color: var(--text-secondary); }

.gate-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.gate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.gate-error { margin: 8px 0 0; min-height: 18px; font-size: 12px; color: var(--danger); }

.gate-submit {
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.18s;
}
[data-theme="dark"] .gate-submit { color: #14161a; }
.gate-submit:hover { background: var(--accent-hover); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  /* 主区退后让出层级，抽屉滑入时露出同色底，不会割裂 */
  .app-shell { background: var(--bg); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(288px, 86vw);
    transform: translateX(-102%);
    /* 关闭略快、打开从容：两种节奏贴合"退出"与"进入"的心智 */
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .sidebar-close { display: grid !important; }
  .menu-btn { display: grid; }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.42);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s;
    z-index: 20;
  }
  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.34s ease, visibility 0.34s;
  }

  /* 背景页面轻微后退 + 圆角，形成"抽屉在上层"的纵深感（iOS 设置页的惯例） */
  .main {
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
      border-radius 0.24s ease;
    will-change: transform;
  }
  body.sidebar-open .main {
    transform: translateX(26px) scale(0.975);
    border-radius: 20px 0 0 20px;
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1),
      border-radius 0.34s ease;
  }

  /* 列表项依次滑入：用 backwards 而非 both，动画结束后自动交还默认样式 */
  body.sidebar-open .conversation-item {
    animation: itemIn 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
    animation-delay: calc(var(--stagger, 0) * 20ms + 60ms);
  }
  @keyframes itemIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
  }

  .topbar { padding: 0 20px; }
  .messages { padding: 32px 20px 20px; }
  .suggestions { padding: 0 20px 12px; }
  .composer-area { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 600px) {
  .topbar { height: 58px; flex-basis: 58px; }
  .app-title { font-size: 14px; }
  .app-subtitle { font-size: 11px; }
  .mode-pill { display: none; }
  .messages { padding: 24px 14px 14px; }
  .msg { gap: 9px; margin-bottom: 24px; }
  .avatar { width: 28px; height: 28px; flex-basis: 28px; border-radius: 9px; }
  .avatar svg { width: 16px; height: 16px; }
  .msg.user .bubble { max-width: 88%; }
  .suggestions { padding: 0 14px 8px; gap: 6px; }
  .chip { padding: 7px 11px; font-size: 11px; }
  .composer-area { padding: 4px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 17px; padding: 8px 8px 8px 13px; }
  .composer-foot { padding: 0 4px; }
  .shortcut-hint { display: none; }
  .welcome-block { padding: 42px 4px 32px; }
  .welcome-icon { width: 54px; height: 54px; margin-bottom: 18px; border-radius: 17px; }
  .welcome-title { font-size: 24px; }
  .welcome-desc { font-size: 13px; }
  .md { font-size: 14.5px; line-height: 1.65; }
  .md ul, .md ol { padding-left: 20px; }
  .md pre { margin: 12px -4px; padding: 40px 12px 12px; border-radius: 10px; }
  .md pre code { font-size: 11.5px; }
  .msg-files { gap: 8px; }
  .file-card { max-width: 100%; }
}

@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;
  }
}
