/* =========================================================
 * Max Chat · 设计语言对齐 Cloudflare 官方 AI 模板
 *   --primary-color: #f6821f   --light-bg: #f9fafb
 *   --border-color: #e5e7eb    --text-color: #1f2937
 *   --user-msg-bg: #fff2e6     --assistant-msg-bg: #f3f4f6
 * ========================================================= */

:root {
  --primary-color: #f6821f;
  --primary-hover: #e67e22;
  --primary-soft: #fff2e6;
  --light-bg: #f9fafb;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --text-faint: #9ca3af;
  --user-msg-bg: #fff2e6;
  --assistant-msg-bg: #f3f4f6;
  --card-bg: #ffffff;
  --page-bg: #ffffff;
  --sidebar-bg: #f9fafb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --primary-hover: #ff9540;
  --primary-soft: rgba(246, 130, 31, .16);
  --light-bg: #14161a;
  --border-color: #2a2e36;
  --text-color: #e8eaed;
  --text-light: #9aa2ae;
  --text-faint: #6b7280;
  --user-msg-bg: rgba(246, 130, 31, .16);
  --assistant-msg-bg: #1c1f25;
  --card-bg: #1a1d23;
  --page-bg: #0f1115;
  --sidebar-bg: #14161a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 12px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--page-bg);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
code, pre { font-family: var(--mono); }

/* ===================== 密码门禁 ===================== */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--light-bg);
}
.gate[hidden] { display: none; }

.gate-card {
  width: min(380px, 100%);
  text-align: center;
  padding: 34px 26px 30px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.gate-logo {
  width: 46px; height: 46px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--primary-color);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.gate-card h1 { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.gate-sub { margin-top: 6px; font-size: 13px; color: var(--text-light); }

#gateForm { margin-top: 20px; }

.gate-input {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-color);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.gate-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, .13);
}
.gate-input.err { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .1); }

.gate-err {
  min-height: 18px;
  margin-top: 7px;
  font-size: 12.5px;
  color: #dc2626;
  text-align: left;
}

.gate-btn {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--primary-color);
  border-radius: var(--radius);
  transition: background .15s;
}
.gate-btn:hover { background: var(--primary-hover); }
.gate-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===================== 布局 ===================== */
.app { display: flex; height: 100vh; min-height: 0; }
.app[hidden] { display: none; }

/* ===================== 侧边栏 ===================== */
.sidebar {
  width: 260px;
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  transition: margin .2s ease;
}
.app.collapsed .sidebar { margin-left: -260px; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 9px;
  flex: 0 0 auto;
}
.brand { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }

.sidebar-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 8px;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color .15s, background .15s;
}
.new-chat:hover { border-color: var(--primary-color); background: var(--primary-soft); }
.new-chat svg { width: 15px; height: 15px; flex: 0 0 15px; color: var(--primary-color); }

.conv-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding-bottom: 8px; }
.conv-list { display: flex; flex-direction: column; gap: 1px; }

.conv-group {
  padding: 12px 8px 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: .02em;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-color);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .13s;
}
.conv-item:hover { background: rgba(0, 0, 0, .045); }
html[data-theme="dark"] .conv-item:hover { background: rgba(255, 255, 255, .06); }
.conv-item.active { background: var(--primary-soft); font-weight: 600; }
.conv-item .title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .del {
  flex: 0 0 20px; width: 20px; height: 20px; padding: 4px;
  border-radius: 4px; color: var(--text-faint); opacity: 0;
  transition: opacity .13s, color .13s, background .13s;
}
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: #dc2626; background: rgba(220, 38, 38, .12); }

.sidebar-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  border-top: 1px solid var(--border-color);
}
.foot-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-light);
  font-size: 13.5px;
  transition: background .13s, color .13s;
}
.foot-btn:hover { background: rgba(0, 0, 0, .045); color: var(--text-color); }
html[data-theme="dark"] .foot-btn:hover { background: rgba(255, 255, 255, .06); }
.foot-btn svg { width: 16px; height: 16px; flex: 0 0 16px; }

.scrim { display: none; }

/* ===================== 主区 ===================== */
.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--page-bg);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  padding: 7px;
  border-radius: 6px;
  color: var(--text-light);
  transition: background .13s, color .13s;
}
.icon-btn:hover { background: var(--light-bg); color: var(--text-color); }
.only-mobile { display: none; }

/* ===================== 聊天区 ===================== */
.chat { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; min-height: 0; }

.welcome {
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 20px 24px;
  text-align: center;
}
.welcome[hidden] { display: none; }
.welcome h1 { font-size: 25px; font-weight: 650; letter-spacing: -.025em; }
.welcome p { margin-top: 9px; font-size: 13.5px; color: var(--text-light); }

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 520px;
  margin: 26px auto 0;
}
.suggestion {
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 13px;
  text-align: left;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.suggestion:hover { border-color: var(--primary-color); color: var(--text-color); box-shadow: var(--shadow-sm); }

.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }

.msg-role {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 4px;
  padding: 0 2px;
  font-weight: 500;
}

.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}
.msg.user .msg-bubble {
  background: var(--user-msg-bg);
  border: 1px solid rgba(246, 130, 31, .22);
}
.msg.assistant .msg-bubble {
  background: var(--assistant-msg-bg);
  border: 1px solid var(--border-color);
}
.msg.user .msg-bubble { white-space: pre-wrap; }
.msg-bubble > *:first-child { margin-top: 0; }
.msg-bubble > *:last-child { margin-bottom: 0; }

.msg-bubble p { margin: 0 0 9px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 { margin: 16px 0 8px; line-height: 1.35; font-weight: 650; }
.msg-bubble h1 { font-size: 1.28em; }
.msg-bubble h2 { font-size: 1.16em; }
.msg-bubble h3 { font-size: 1.06em; }
.msg-bubble ul, .msg-bubble ol { margin: 0 0 9px; padding-left: 20px; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble a { color: var(--primary-color); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }
.msg-bubble blockquote { margin: 9px 0; padding: 2px 0 2px 11px; border-left: 3px solid var(--border-color); color: var(--text-light); }
.msg-bubble hr { border: none; border-top: 1px solid var(--border-color); margin: 14px 0; }
.msg-bubble table { width: 100%; border-collapse: collapse; margin: 9px 0; font-size: 13px; display: block; overflow-x: auto; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border-color); padding: 6px 9px; text-align: left; }
.msg-bubble th { background: var(--card-bg); font-weight: 600; }

.msg-bubble code.inline {
  font-size: .88em;
  padding: .16em .42em;
  border-radius: 4px;
  background: rgba(0, 0, 0, .055);
  border: 1px solid var(--border-color);
}
html[data-theme="dark"] .msg-bubble code.inline { background: rgba(255, 255, 255, .08); }

.codeblock { margin: 9px 0; border: 1px solid var(--border-color); border-radius: var(--radius); overflow: hidden; background: var(--card-bg); }
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; font-size: 11px; color: var(--text-faint);
  background: var(--light-bg); border-bottom: 1px solid var(--border-color);
}
.codeblock-head .copy { font-size: 11px; padding: 2px 7px; border-radius: 4px; color: var(--text-light); }
.codeblock-head .copy:hover { background: var(--card-bg); color: var(--primary-color); }
.codeblock pre { margin: 0; padding: 11px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }
.codeblock code { white-space: pre; }

.msg-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.msg-images img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  object-fit: cover;
  cursor: zoom-in;
}

.msg-actions { display: flex; gap: 2px; margin-top: 5px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-actions button {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 5px;
  font-size: 11.5px; color: var(--text-faint);
}
.msg-actions button:hover { background: var(--light-bg); color: var(--text-color); }
.msg-actions svg { width: 12px; height: 12px; flex: 0 0 12px; }

.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.cursor::after { content: "▋"; margin-left: 1px; color: var(--primary-color); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.err-box {
  border: 1px solid rgba(220, 38, 38, .3);
  background: rgba(220, 38, 38, .06);
  color: #dc2626;
  padding: 8px 11px;
  border-radius: var(--radius);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 6px;
}
html[data-theme="dark"] .err-box { color: #f87171; background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); }

/* ===================== 输入区 ===================== */
.composer-wrap {
  flex: 0 0 auto;
  padding: 8px 20px 10px;
  background: var(--page-bg);
}

.composer {
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, .1);
}

.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: none;
  color: var(--text-color);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  max-height: 200px;
  padding: 13px 15px 4px;
}
.composer textarea::placeholder { color: var(--text-faint); }

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 11px 15px 0;
}
.attach-preview[hidden] { display: none; }

.attach-item {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-item .rm {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  padding: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}
.attach-item .rm:hover { background: rgba(0, 0, 0, .85); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 9px 9px 9px;
}
.composer-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.composer-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.tool-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  padding: 7px;
  border-radius: 6px;
  color: var(--text-light);
  transition: background .13s, color .13s;
}
.tool-btn:hover { background: var(--light-bg); color: var(--primary-color); }
.tool-btn[hidden] { display: none; }

/* 模型切换（底部） */
.model-picker { position: relative; min-width: 0; }

.model-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 260px;
  padding: 6px 9px;
  border-radius: 6px;
  color: var(--text-light);
  font-size: 12.5px;
  transition: background .13s, color .13s;
}
.model-btn:hover { background: var(--light-bg); color: var(--text-color); }
.model-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.model-btn .chev { width: 13px; height: 13px; flex: 0 0 13px; }

.model-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 30;
  min-width: 250px;
  max-width: 320px;
  max-height: 300px;
  overflow-y: auto;
  padding: 5px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: popUp .13s ease-out;
}
.model-menu[hidden] { display: none; }
@keyframes popUp { from { opacity: 0; transform: translateY(5px); } }

.model-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-color);
  text-align: left;
  transition: background .12s;
}
.model-opt:hover { background: var(--light-bg); }
.model-opt.sel { background: var(--primary-soft); font-weight: 600; }
.model-opt .m-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.model-opt .m-prov { font-size: 10.5px; color: var(--text-faint); flex: 0 0 auto; }
.model-opt .m-eye { flex: 0 0 14px; width: 14px; height: 14px; color: var(--primary-color); }

.model-menu-empty { padding: 12px 10px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

.send-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  padding: 8px;
  border-radius: 6px;
  background: var(--primary-color);
  color: #fff;
  transition: background .15s, opacity .15s, transform .1s;
}
.send-btn:hover { background: var(--primary-hover); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }
.send-btn.stop { background: #dc2626; }
.send-btn.stop:hover { background: #b91c1c; }

.disclaimer {
  max-width: 800px;
  margin: 7px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* ===================== 弹窗 ===================== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, .5);
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }

.modal-card {
  width: min(580px, 100%);
  max-height: min(88vh, 880px);
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .16s ease-out;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}
.modal-head h2 { font-size: 15px; font-weight: 650; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-light); }
.field .val { color: var(--primary-color); font-family: var(--mono); }
.sub { font-size: 11.5px; color: var(--text-faint); }
.sub code { background: var(--light-bg); padding: 1px 4px; border-radius: 3px; }
.sub b { color: var(--primary-color); }

.input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(246, 130, 31, .12); }
textarea.input { resize: vertical; line-height: 1.55; }
input[type="range"] { accent-color: var(--primary-color); width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row .input { flex: 1 1 auto; }
.provider-row { display: flex; gap: 8px; align-items: center; }
.provider-row .input { flex: 1 1 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.model-list { display: flex; flex-wrap: wrap; gap: 6px; }
.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 12px;
  font-family: var(--mono);
  transition: border-color .13s, background .13s, color .13s;
}
.model-chip.on { border-color: var(--primary-color); background: var(--primary-soft); color: var(--text-color); }
.model-chip .eye { width: 12px; height: 12px; flex: 0 0 12px; color: var(--primary-color); }

.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn.ghost { background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-light); }
.btn.ghost:hover { border-color: var(--primary-color); color: var(--text-color); }
.btn.ghost.danger:hover { border-color: #dc2626; color: #dc2626; }
.btn.ghost.small { padding: 5px 10px; font-size: 12px; align-self: flex-start; }
.btn.primary { background: var(--primary-color); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.test-result { font-size: 12.5px; min-height: 17px; }
.test-result.ok { color: #059669; }
.test-result.err { color: #dc2626; }
.test-result.loading { color: var(--text-light); }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--light-bg);
}

/* ===================== Toast ===================== */
.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 9px 16px;
  border-radius: var(--radius);
  background: var(--text-color);
  color: var(--card-bg);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .18s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ===================== 图片放大 ===================== */
.lightbox {
  position: fixed; inset: 0; z-index: 95;
  display: grid; place-items: center;
  padding: 30px;
  background: rgba(0, 0, 0, .82);
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ===================== 滚动条 ===================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ===================== 响应式 ===================== */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.collapsed .sidebar { margin-left: 0; }
  .app:not(.collapsed) .sidebar { transform: translateX(0); }
  .scrim.show {
    display: block; position: fixed; inset: 0; z-index: 39;
    background: rgba(17, 24, 39, .5);
  }
  .only-mobile { display: grid; }
  .topbar { padding: 10px 14px; }
  .messages { padding: 18px 14px 22px; }
  .composer-wrap { padding: 8px 12px 10px; }
  .msg { max-width: 92%; }
  .suggestions { grid-template-columns: 1fr; }
  .model-btn { max-width: 150px; }
  .welcome { padding-top: 44px; }
  .welcome h1 { font-size: 21px; }
}

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