/* ===================== 设计变量 ===================== */
:root {
  --bg: #f5f6f9;
  --bg-soft: #eceef3;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --text: #12151c;
  --text-dim: #6b7280;
  --text-faint: #98a1af;
  --line: #e4e7ee;
  --line-soft: #eef0f5;
  --brand: #3a63f3;
  --brand-2: #7b4df2;
  --brand-soft: #eaefff;
  --danger: #e0453e;
  --code-bg: #14171f;
  --code-text: #e6e9f0;
  --shadow-sm: 0 1px 2px rgba(18, 21, 28, .06), 0 2px 8px rgba(18, 21, 28, .04);
  --shadow-md: 0 8px 30px rgba(18, 21, 28, .10);
  --shadow-lg: 0 24px 60px rgba(18, 21, 28, .18);
  --radius: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --top-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --bg-soft: #14181f;
    --surface: #161a22;
    --surface-2: #1b202a;
    --text: #e8ebf2;
    --text-dim: #97a1b2;
    --text-faint: #6b7688;
    --line: #232936;
    --line-soft: #1c2230;
    --brand: #6f8dff;
    --brand-2: #9a7bff;
    --brand-soft: #1b2340;
    --danger: #ff6b63;
    --code-bg: #0a0c11;
    --code-text: #dfe4ee;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ===================== 登录门禁 ===================== */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px calc(20px + env(safe-area-inset-left)) calc(24px + var(--sab));
  background:
    radial-gradient(90% 60% at 15% 0%, rgba(58, 99, 243, .16), transparent 60%),
    radial-gradient(80% 55% at 90% 10%, rgba(123, 77, 242, .14), transparent 62%),
    var(--bg);
  z-index: 60;
}

.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 30px 24px 22px;
  box-shadow: var(--shadow-lg);
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.gate-logo {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  margin: 0 auto 16px;
}

.gate-title {
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  text-align: center;
  letter-spacing: -.01em;
}

.gate-sub {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
}

.gate-form { display: flex; flex-direction: column; gap: 10px; }

.gate-input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color .18s, background .18s;
}

.gate-input:focus { border-color: var(--brand); background: var(--surface); }
.gate-input::placeholder { color: var(--text-faint); }

.gate-btn {
  height: 48px;
  border-radius: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 15.5px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(58, 99, 243, .28);
  transition: transform .12s, opacity .18s;
}

.gate-btn:active { transform: scale(.98); }
.gate-btn:disabled { opacity: .6; }

.gate-err {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

.gate-note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-faint);
  text-align: center;
}

/* ===================== 主框架 ===================== */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}

.top {
  flex: 0 0 auto;
  height: calc(var(--top-h) + var(--sat));
  padding: var(--sat) 6px 0;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(245, 246, 249, .86);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line-soft);
  z-index: 20;
}

@media (prefers-color-scheme: dark) {
  .top { background: rgba(13, 15, 20, .82); }
}

.top-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.top-title {
  max-width: 100%;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-model {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .01em;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, .14);
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--text-dim);
  transition: background .16s, color .16s;
}

.icon-btn:active { background: var(--bg-soft); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }

/* ===================== 消息区 ===================== */
.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 14px 14px 0;
}

.scroll::-webkit-scrollbar { width: 0; height: 0; }

.msgs { display: flex; flex-direction: column; gap: 16px; }

/* 欢迎页 */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--top-h) - 190px);
  padding: 16px 6px 24px;
  text-align: center;
  animation: fade .5s ease both;
}

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

.welcome-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.welcome-h {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.welcome-p {
  margin: 0 auto;
  max-width: 300px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.welcome-p b { color: var(--text); font-weight: 600; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 24px;
}

.chip {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: transform .14s, border-color .16s, background .16s;
}

.chip:active { transform: scale(.96); background: var(--brand-soft); border-color: transparent; }

/* 消息行 */
.msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 100%;
  animation: msgIn .28s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

.bubble {
  position: relative;
  max-width: 86%;
  padding: 11px 14px;
  border-radius: var(--radius);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px rgba(58, 99, 243, .22);
  white-space: pre-wrap;
}

.msg.ai .bubble {
  max-width: 94%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.meta {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity .2s;
}

.msg.ai .meta { opacity: 1; }

.mini {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .16s, color .16s;
}

.mini:active { background: var(--bg-soft); color: var(--text); }

/* 打字光标 */
.streaming .md > :last-child::after,
.streaming .think + .md > :last-child::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--brand);
  border-radius: 1px;
  animation: blink 1s steps(1) infinite;
}

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

/* 思考过程 */
.think {
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-left: 2px solid var(--line);
  padding-left: 9px;
}

.think summary {
  cursor: pointer;
  color: var(--text-faint);
  list-style: none;
  font-size: 12px;
  user-select: none;
}

.think summary::-webkit-details-marker { display: none; }
.think .think-body { margin-top: 6px; white-space: pre-wrap; opacity: .85; }

/* 加载点 */
.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 8px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.scroll-pad { height: 14px; }

/* 回到底部 */
.to-bottom {
  position: absolute;
  right: 14px;
  bottom: calc(84px + var(--sab));
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  z-index: 15;
  animation: fade .2s both;
}

/* ===================== Markdown ===================== */
.md { font-size: 15px; line-height: 1.72; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .72em; }
.md h1, .md h2, .md h3, .md h4 {
  margin: 1.1em 0 .5em;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.01em;
}
.md h1 { font-size: 19px; }
.md h2 { font-size: 17.5px; }
.md h3 { font-size: 16px; }
.md h4 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 .75em; padding-left: 1.35em; }
.md li { margin: .22em 0; }
.md li > p { margin: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.1em 0; }
.md blockquote {
  margin: .6em 0;
  padding: .1em 0 .1em .9em;
  border-left: 3px solid var(--line);
  color: var(--text-dim);
}
.md a { color: var(--brand); text-decoration: none; border-bottom: 1px solid rgba(58, 99, 243, .32); }
.md strong { font-weight: 650; }
.md del { color: var(--text-faint); }

.md code {
  padding: .15em .38em;
  font-size: .88em;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.md pre {
  position: relative;
  margin: .7em 0 .85em;
  padding: 12px 13px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--code-bg);
  -webkit-overflow-scrolling: touch;
}

.md pre code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--code-text);
  font-size: 12.8px;
  line-height: 1.6;
  white-space: pre;
}

.code-wrap { position: relative; }
.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: .8em 0 -.2em;
  padding: 0 2px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: ui-monospace, Menlo, monospace;
}
.code-bar .cp { color: var(--text-dim); }

/* ===================== 输入区 ===================== */
.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + var(--sab));
  background: linear-gradient(to top, var(--bg) 65%, rgba(245, 246, 249, 0));
  z-index: 18;
}

@media (prefers-color-scheme: dark) {
  .composer { background: linear-gradient(to top, var(--bg) 65%, rgba(13, 15, 20, 0)); }
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
}

.composer-inner:focus-within {
  border-color: rgba(58, 99, 243, .55);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.input {
  flex: 1 1 auto;
  min-height: 34px;
  max-height: 132px;
  padding: 6px 0;
  font-size: 16px; /* iOS 防缩放 */
  line-height: 1.5;
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
  resize: none;
  overflow-y: auto;
  scrollbar-width: none;
}

.input::-webkit-scrollbar { width: 0; }
.input::placeholder { color: var(--text-faint); }

.send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 16px rgba(58, 99, 243, .30);
  transition: transform .14s, opacity .18s, background .2s;
}

.send:active { transform: scale(.93); }
.send:disabled { opacity: .38; box-shadow: none; }
.send .i-stop { display: none; }

.send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.send.stop {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.composer-hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: .02em;
  transition: opacity .3s;
}

/* ===================== 抽屉 ===================== */
.drawer-mask, .sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, .42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 30;
  animation: fade .2s both;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(84vw, 330px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 31;
  transform: translateX(-102%);
  transition: transform .3s cubic-bezier(.22, .8, .24, 1);
  padding-top: var(--sat);
  box-shadow: var(--shadow-lg);
}

.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .04em;
}

.drawer-new {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 13px;
  transition: transform .14s;
}

.drawer-new:active { transform: scale(.98); }

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 8px;
  scrollbar-width: none;
}

.conv-list::-webkit-scrollbar { width: 0; }

.conv {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 8px 10px 12px;
  border-radius: 12px;
  text-align: left;
  transition: background .16s;
}

.conv:active { background: var(--bg-soft); }
.conv.active { background: var(--brand-soft); }

.conv-body { flex: 1 1 auto; min-width: 0; }

.conv-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }

.conv-del {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-faint);
  opacity: .7;
}

.conv-del:active { background: rgba(224, 69, 62, .12); color: var(--danger); }

.empty-tip {
  padding: 28px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}

.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px calc(12px + var(--sab));
  border-top: 1px solid var(--line-soft);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
  border-radius: 10px;
}

.text-btn:active { background: var(--bg-soft); }
.text-btn.danger { color: var(--danger); }

/* ===================== 设置面板 ===================== */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 32;
  padding: 8px 18px calc(16px + var(--sab));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateY(101%);
  transition: transform .32s cubic-bezier(.22, .8, .24, 1);
  max-height: 88dvh;
  overflow-y: auto;
}

.sheet.open { transform: none; }

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 99px;
  background: var(--line);
}

.sheet-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 620;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.field-label b { color: var(--brand); font-weight: 650; }
.field-label i {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.field-label i { display: inline; margin-left: 6px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: none;
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: var(--bg-soft);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--line);
  box-shadow: 0 2px 8px rgba(18, 21, 28, .18);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: var(--bg-soft);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--line);
}

.field-area {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  resize: vertical;
}

.field-area:focus { border-color: var(--brand); background: var(--surface); }

/* 登录审计 */
.audit {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: none;
}

.audit::-webkit-scrollbar { width: 0; }

.audit-row {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.audit-row:last-child { border-bottom: 0; }

.audit-l1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.audit-badge {
  flex: 0 0 auto;
  padding: 1px 7px;
  font-size: 10.5px;
  border-radius: 99px;
  background: rgba(28, 168, 84, .13);
  color: #15803d;
}

.audit-badge.bad {
  background: rgba(224, 69, 62, .13);
  color: var(--danger);
}

.audit-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.audit-time {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
  flex: 0 0 auto;
}

.audit-geo {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-dim);
  word-break: break-word;
}

.audit-empty {
  margin: 0;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

.sheet-note {
  margin: 0 0 14px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-faint);
}

@media (prefers-color-scheme: dark) {
  .audit-badge { background: rgba(52, 199, 89, .16); color: #5fd97f; }
  .audit-badge.bad { background: rgba(255, 107, 99, .16); color: #ff8f88; }
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  flex: 1 1 0;
  height: 46px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 600;
  transition: transform .13s, opacity .16s;
}

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

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(58, 99, 243, .26);
}

.btn.ghost {
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.btn.ghost.danger, .btn.ghost:active { color: var(--danger); }

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--sab));
  transform: translate(-50%, 8px);
  max-width: 86vw;
  padding: 10px 16px;
  font-size: 13px;
  color: #fff;
  background: rgba(20, 23, 31, .92);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  opacity: 0;
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== 大屏微调 ===================== */
@media (max-width: 719px) {
  /* 手机屏上长代码行软换行，避免横向拖动 */
  .md pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
}

@media (min-width: 720px) {
  .bubble { max-width: 72%; }
  .msg.ai .bubble { max-width: 78%; }
  .scroll { padding-inline: max(14px, calc((100vw - 760px) / 2)); }
  .composer, .top { padding-inline: max(12px, calc((100vw - 760px) / 2)); }
}
