/* ============================================================
   DeepSeek 鲸鱼娘 · 蓝色大肥鱼主题
   ============================================================ */
:root {
  --bg: #070e22;
  --bg-2: #0b1738;
  --panel: #101f42;
  --panel-2: #162a52;
  --glass: rgba(16, 31, 66, 0.62);
  --glass-2: rgba(20, 38, 78, 0.84);
  --line: rgba(126, 166, 255, 0.20);
  --line-strong: rgba(126, 166, 255, 0.36);
  --text: #f3f7ff;
  --dim: #9fb3d9;
  --dim2: #7086b0;
  --brand: #3f6bff;
  --brand-2: #5e9bff;
  --aqua: #8fd8ff;
  --gold: #e6c36a;
  --pink: #ffa8c8;
  --ok: #4ade80;
  --warn: #ffc35c;
  --err: #ff6b8a;
  --shadow: 0 24px 70px rgba(0, 8, 30, 0.55);
  --radius: 22px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fbf7ef;
  --bg-2: #f3ede2;
  --panel: #fffdf8;
  --panel-2: #f7f2e8;
  --glass: rgba(255, 253, 248, 0.78);
  --glass-2: rgba(255, 253, 248, 0.92);
  --line: #e7dfd0;
  --line-strong: #d6c9b4;
  --text: #1b2a5b;
  --dim: #63739a;
  --dim2: #8b98b4;
  --brand: #2f55e8;
  --brand-2: #4f8dff;
  --aqua: #1f9fd0;
  --gold: #b8892e;
  --pink: #f06aa8;
  --ok: #0e9f6e;
  --warn: #b7791f;
  --err: #e04561;
  --shadow: 0 18px 50px rgba(60, 80, 140, 0.14);
  color-scheme: light;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(900px 620px at 88% -12%, rgba(63, 107, 255, 0.32), transparent 62%),
    radial-gradient(720px 520px at -12% 18%, rgba(143, 216, 255, 0.15), transparent 62%),
    radial-gradient(700px 460px at 55% 112%, rgba(230, 195, 106, 0.10), transparent 64%),
    var(--bg);
  background-attachment: fixed;
}
:root[data-theme="light"] body {
  background:
    radial-gradient(900px 620px at 88% -12%, rgba(47, 85, 232, 0.14), transparent 62%),
    radial-gradient(720px 520px at -12% 18%, rgba(31, 159, 208, 0.10), transparent 62%),
    radial-gradient(700px 460px at 55% 112%, rgba(184, 137, 46, 0.09), transparent 64%),
    var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { color: var(--brand); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.hidden { display: none !important; }

/* 背景气泡 */
.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bub {
  position: absolute;
  bottom: -14vh;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(170, 235, 255, 0.30), rgba(105, 229, 255, 0.05) 55%, transparent 72%);
  border: 1px solid rgba(105, 229, 255, 0.16);
  animation: bubbleRise linear infinite;
  opacity: 0.34;
}
:root[data-theme="light"] .bub {
  opacity: 0.22;
  border-color: rgba(61, 91, 255, 0.12);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.8), rgba(61, 91, 255, 0.05) 55%, transparent 72%);
}
.bub.b1 { left: 8%;  width: 26px; height: 26px; animation-duration: 21s; animation-delay: -6s; }
.bub.b2 { left: 22%; width: 12px; height: 12px; animation-duration: 26s; animation-delay: -14s; opacity: .4; }
.bub.b3 { left: 68%; width: 34px; height: 34px; animation-duration: 24s; animation-delay: -2s; opacity: .35; }
.bub.b4 { left: 84%; width: 16px; height: 16px; animation-duration: 19s; animation-delay: -11s; opacity: .5; }
.bub.b5 { left: 48%; width: 9px;  height: 9px;  animation-duration: 30s; animation-delay: -18s; opacity: .35; }
.bub.b6 { left: 36%; width: 20px; height: 20px; animation-duration: 27s; animation-delay: -22s; opacity: .3; }
@keyframes bubbleRise {
  0% { transform: translateY(0) translateX(0) scale(0.9); opacity: 0; }
  12% { opacity: .55; }
  50% { transform: translateY(-55vh) translateX(14px) scale(1); }
  88% { opacity: .35; }
  100% { transform: translateY(-118vh) translateX(-8px) scale(1.06); opacity: 0; }
}

/* ============ 布局 ============ */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);
  max-width: 100%;
  overflow: hidden;
}

#topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(max(8px, env(safe-area-inset-top))) 10px 8px;
  border-bottom: 1px solid transparent;
  background: linear-gradient(to bottom, rgba(7, 14, 34, 0.94), rgba(7, 14, 34, 0.55));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 20;
  transition: border-color .25s;
}
:root[data-theme="light"] #topbar { background: linear-gradient(to bottom, rgba(251, 247, 239, 0.95), rgba(251, 247, 239, 0.66)); }
#topbar.scrolled { border-bottom-color: var(--line); }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 13px;
  color: var(--dim);
  transition: background .15s, color .15s, transform .15s;
}
.icon-btn:active { background: var(--glass-2); color: var(--text); transform: scale(.93); }

#titleWrap { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
#convTitle {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#modelBadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(91, 124, 255, 0.36);
  background: rgba(91, 124, 255, 0.14);
  color: #b9caff;
  font-size: 10.5px;
  letter-spacing: .2px;
  cursor: pointer;
}
:root[data-theme="light"] #modelBadge { color: #2f49c9; background: rgba(61, 91, 255, 0.09); }
#modelBadge:active { transform: scale(.96); }
.live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(230, 195, 106, 0.55);
  animation: live 2.6s infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(230, 195, 106, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(230, 195, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(230, 195, 106, 0); }
}

#scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

#thread {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 14px 12px;
}

/* ============ 空状态 ============ */
.empty {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 8px 24px;
  text-align: center;
  animation: fade .5s ease;
}

.hero-frame {
  position: relative;
  width: min(76vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 158px 158px 34px 34px;
  background: radial-gradient(120% 78% at 50% 4%, #ffffff 0%, #ecf3ff 38%, #d3e4ff 100%);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: inset 0 1px 0 #fff, 0 30px 60px rgba(40, 60, 140, .16);
  margin: 4px 0 18px;
  overflow: hidden;
  flex: none;
}
.hero-frame::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 150px 150px 27px 27px;
  border: 1px solid rgba(201, 162, 74, .32);
  z-index: 3;
  pointer-events: none;
}
:root[data-theme="dark"] .hero-frame {
  background: radial-gradient(120% 78% at 50% 4%, #263861 0%, #16244a 45%, #0c1630 100%);
  border-color: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 30px 60px rgba(0, 0, 0, .45);
}
.hero-tag {
  position: absolute;
  top: 16px; left: 0; right: 0;
  z-index: 3;
  font-size: 8px;
  letter-spacing: 2.6px;
  font-weight: 600;
  color: rgba(28, 42, 85, .42);
}
:root[data-theme="dark"] .hero-tag { color: rgba(255, 255, 255, .36); }
.hero-art {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  height: 89%;
  width: auto;
  filter: drop-shadow(0 16px 22px rgba(30, 50, 120, .22));
  z-index: 2;
  user-select: none;
  animation: floaty 6.5s ease-in-out infinite;
}
.hero-star {
  position: absolute;
  color: var(--gold);
  z-index: 4;
  font-size: 11px;
  opacity: .9;
  animation: twinkle 4.2s ease-in-out infinite;
}
.hero-star.st1 { top: 18%; left: 12%; font-size: 9px; animation-delay: -.8s; }
.hero-star.st2 { top: 32%; right: 10%; font-size: 13px; animation-delay: -2s; }
.hero-star.st3 { top: 55%; left: 8%; font-size: 7px; animation-delay: -3s; }

@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.94); }
  50% { opacity: .95; transform: scale(1.08); }
}
@keyframes floaty {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: -.6px;
  font-weight: 760;
  color: var(--text);
}
.empty p {
  margin: 0 0 18px;
  max-width: 320px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
}
.sugs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 440px;
}
.sug {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(40, 50, 90, .05);
  text-align: left;
  color: var(--text);
  overflow: hidden;
  transition: transform .15s, box-shadow .18s, border-color .18s;
}
.sug:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(40, 50, 90, .09); }
.sug:active { transform: scale(.98); }
.sug > svg {
  width: 32px; height: 32px;
  padding: 8px;
  box-sizing: border-box;
  flex: none;
  border-radius: 11px;
  background: #edf3ff;
  color: var(--brand);
  stroke-width: 1.7;
}
:root[data-theme="dark"] .sug > svg { background: rgba(124, 147, 255, .12); color: #a9c0ff; }
.sug-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sug-txt b { font-size: 12.5px; font-weight: 650; line-height: 1.3; color: var(--text); }
.sug-txt span { font-size: 10.8px; color: var(--dim2); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-arrow { flex: none; color: var(--dim2); font-size: 12px; opacity: .6; transition: transform .15s, opacity .15s; }
.sug:hover .sug-arrow { transform: translateX(2px); opacity: 1; color: var(--brand); }

/* ============ 消息 ============ */
.msg { animation: fade .28s ease; }
.msg + .msg { margin-top: 22px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.msg.user .bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 20px 20px 7px 20px;
  background: linear-gradient(135deg, #2b4fd8 0%, #3f6bff 55%, #5e9bff 100%);
  border: 1px solid rgba(160, 190, 255, 0.28);
  color: #fff;
  font-size: 15.5px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 10px 28px rgba(50, 80, 220, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.msg.user .bubble:empty { display: none; }
.msg.user .pics { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.msg.user .pics img {
  width: 108px; height: 108px;
  object-fit: cover;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.msg.assistant { position: relative; }
.a-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; height: 28px; }
.a-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #fffdf8;
  border: 1.5px solid rgba(230, 195, 106, 0.65);
  box-shadow: 0 4px 14px rgba(20, 50, 160, 0.35);
  flex: none;
  overflow: hidden;
  object-fit: cover;
}
.a-name { font-size: 12.5px; color: var(--text); font-weight: 600; letter-spacing: .1px; }
.a-model { font-size: 10px; color: var(--gold); padding: 1px 6px; border-radius: 5px; background: rgba(230, 195, 106, 0.10); }
.a-state { font-size: 11px; color: var(--dim2); margin-left: auto; font-variant-numeric: tabular-nums; }

/* 思考 */
.think {
  margin: 6px 0 12px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--aqua);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(105, 229, 255, 0.07), rgba(91, 124, 255, 0.03));
  overflow: hidden;
}
.think > summary {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}
.think > summary::-webkit-details-marker { display: none; }
.think > summary .spark {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 12px rgba(105, 229, 255, 0.9);
  flex: none;
}
.think[open] > summary { color: var(--text); }
.think > summary .chev { margin-left: auto; transition: transform .2s; opacity: .55; }
.think[open] > summary .chev { transform: rotate(180deg); }
.think-body {
  padding: 9px 12px 11px;
  font-size: 13px;
  line-height: 1.72;
  color: #a9c3e8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  border-top: 1px dashed var(--line);
}
:root[data-theme="light"] .think-body { color: #44577a; }
.think.streaming > summary .label::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--aqua);
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .15; } }

/* 工具 */
.tool {
  margin: 9px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}
.tool-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; color: var(--dim); }
.tool-row .label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-row .count { margin-left: auto; font-size: 11px; color: var(--dim2); flex: none; }
.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid rgba(105, 229, 255, 0.25);
  border-top-color: var(--aqua);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tool.ok .tool-row svg { color: var(--ok); width: 15px; height: 15px; }
.tool.fail .tool-row svg { color: var(--err); width: 15px; height: 15px; }
.src-list { display: flex; gap: 6px; overflow-x: auto; padding: 0 10px 10px; scrollbar-width: none; }
.src-list::-webkit-scrollbar { display: none; }
.src {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  max-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(112, 152, 255, 0.08);
  font-size: 11.5px;
  color: var(--dim);
  text-decoration: none;
}
.src:hover { color: var(--text); border-color: var(--line-strong); }
.src .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--aqua); flex: none; }
.src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 正文 */
.md { font-size: 15.5px; line-height: 1.75; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 11px; }
.md h1, .md h2, .md h3, .md h4 { margin: 19px 0 8px; line-height: 1.35; font-weight: 700; letter-spacing: -.2px; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 16.5px; }
.md h4 { font-size: 15.5px; }
.md ul, .md ol { margin: 0 0 11px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0; }
.md blockquote {
  margin: 0 0 11px;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--dim);
}
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md a { color: #8fc4ff; text-decoration: none; border-bottom: 1px solid rgba(143, 196, 255, 0.35); }
:root[data-theme="light"] .md a { color: #2456d8; }
.md strong { font-weight: 700; }
.md code.inline {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .88em;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(112, 152, 255, 0.12);
  border: 1px solid var(--line);
}
.md .table-wrap { overflow-x: auto; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.md th { background: rgba(112, 152, 255, 0.08); font-weight: 650; }
.md tr:last-child td { border-bottom: 0; }

.code {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #060d1d;
}
:root[data-theme="light"] .code { background: #f3f7ff; }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--dim2);
  background: rgba(112, 152, 255, 0.06);
}
.code-head button { font-size: 11px; color: var(--dim); padding: 2px 7px; border-radius: 6px; }
.code-head button:active { background: var(--panel-2); }
.code pre { margin: 0; padding: 13px; overflow-x: auto; }
.code code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.8px;
  line-height: 1.64;
  color: #cfe0ff;
  white-space: pre;
}
:root[data-theme="light"] .code code { color: #1f2c4a; }

.notice {
  margin: 9px 0;
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(255, 195, 92, 0.08);
  border: 1px solid rgba(255, 195, 92, 0.22);
  color: var(--warn);
  font-size: 12.5px;
}
.error-box {
  margin: 10px 0;
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(255, 107, 138, 0.08);
  border: 1px solid rgba(255, 107, 138, 0.25);
  color: var(--err);
  font-size: 13px;
  line-height: 1.55;
}
.error-box button {
  margin-top: 8px;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 107, 138, 0.4);
  color: var(--err);
}

.a-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px;
  min-height: 24px;
  color: var(--dim2);
  font-size: 11px;
}
.a-foot .meta { margin-right: auto; letter-spacing: .1px; }
.a-foot .act {
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--dim2);
}
.a-foot .act:hover { background: var(--glass); color: var(--text); }
.a-foot svg { width: 15px; height: 15px; }

#toBottom {
  position: absolute;
  right: 14px;
  bottom: 142px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--glass-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 15;
  animation: fade .2s;
}

/* ============ 输入区 ============ */
#composerWrap {
  flex: none;
  padding: 8px 10px calc(9px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 56%, rgba(7, 14, 34, 0));
  z-index: 18;
}
:root[data-theme="light"] #composerWrap { background: linear-gradient(to top, var(--bg) 56%, rgba(251, 247, 239, 0)); }

#thumbs { display: flex; gap: 7px; padding: 0 4px 8px; overflow-x: auto; }
#thumbs:empty { display: none; }
.thumb { position: relative; flex: none; width: 58px; height: 58px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .68);
  color: #fff;
  display: grid; place-items: center;
}
.thumb button svg { width: 11px; height: 11px; }

#composer {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 5px 5px 5px 7px;
  border-radius: 25px;
  border: 1px solid var(--line);
  background: var(--glass-2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px rgba(0, 6, 25, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color .18s, box-shadow .18s;
}
:root[data-theme="light"] #composer { box-shadow: 0 12px 34px rgba(40, 70, 140, 0.12); }
#composer:focus-within {
  border-color: rgba(105, 229, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(91, 124, 255, 0.16), 0 14px 40px rgba(0, 6, 25, 0.42);
}

.composer-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--dim);
}
.composer-btn:active { background: rgba(112, 152, 255, 0.14); }
.composer-btn svg { width: 21px; height: 21px; }

#input {
  flex: 1;
  min-height: 38px;
  max-height: 132px;
  padding: 9px 2px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}
#input::placeholder { color: var(--dim2); }

.send-btn {
  width: 37px; height: 37px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #2f55e8, #3f6bff 55%, #8fd8ff 130%);
  color: #fff;
  transition: opacity .15s, transform .12s;
  box-shadow: 0 6px 18px rgba(70, 110, 255, 0.42);
}
.send-btn:disabled { opacity: .35; box-shadow: none; }
.send-btn:active { transform: scale(.93); }
.send-btn.stop { background: var(--panel-2); color: var(--err); box-shadow: none; border: 1px solid var(--line); }
.send-btn svg { width: 19px; height: 19px; }

#toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 3px 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--dim2);
  font-size: 12px;
  white-space: nowrap;
  transition: all .16s;
}
.chip svg { width: 14px; height: 14px; }
.chip.on {
  color: var(--aqua);
  border-color: rgba(105, 229, 255, 0.42);
  background: rgba(105, 229, 255, 0.10);
}
:root[data-theme="light"] .chip.on { color: #007a99; background: rgba(0, 159, 196, 0.08); border-color: rgba(0, 159, 196, 0.35); }
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
}
.seg button {
  padding: 3px 8px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--dim2);
  transition: all .16s;
}
.seg button.on {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 3px 10px rgba(91, 124, 255, 0.35);
}
#effortHint { margin-left: auto; font-size: 10.5px; color: var(--dim2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 374px) {
  #effortHint { display: none; }
  .seg button { padding: 3px 6px; }
}

/* ============ 抽屉 ============ */
#scrim {
  position: fixed; inset: 0;
  background: rgba(2, 6, 16, .58);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade .18s;
}
#drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(84vw, 330px);
  background: linear-gradient(160deg, rgba(14, 26, 51, .98), rgba(8, 16, 34, .99));
  border-right: 1px solid var(--line);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  animation: slideIn .24s cubic-bezier(.2, .8, .2, 1);
  box-shadow: var(--shadow);
}
:root[data-theme="light"] #drawer { background: linear-gradient(160deg, #fffdf8, #f3ede2); }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 18px; }
.drawer-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 10px;
  border-radius: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s, border-color .14s;
}
.conv-item:hover { background: rgba(112, 152, 255, 0.08); }
.conv-item.active {
  background: linear-gradient(100deg, rgba(91, 124, 255, 0.20), rgba(105, 229, 255, 0.06));
  border-color: rgba(91, 124, 255, 0.30);
}
.conv-main { flex: 1; min-width: 0; }
.conv-name { font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { margin-top: 3px; font-size: 11px; color: var(--dim2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-tools { display: flex; gap: 2px; opacity: .5; }
.conv-item:hover .conv-tools { opacity: 1; }
.conv-tools button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--dim); }
.conv-tools button:hover { background: var(--panel-2); color: var(--text); }
.conv-tools svg { width: 14px; height: 14px; }
.drawer-foot { display: flex; gap: 6px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.drawer-action {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(112, 152, 255, 0.08);
  color: var(--dim);
  font-size: 12.5px;
}
.drawer-action svg { width: 16px; height: 16px; }

/* ============ 设置 ============ */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  background: linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
  border-top: 1px solid var(--line-strong);
  border-radius: 24px 24px 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  animation: sheetUp .28s cubic-bezier(.2, .8, .2, 1);
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
}
:root[data-theme="light"] .sheet { background: #fffdf8; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-title { font-size: 16px; font-weight: 700; }
.sheet-body { overflow-y: auto; padding: 6px 16px 28px; }
.set-group { margin-top: 18px; }
.set-group h3 { margin: 0 0 8px; font-size: 11.5px; font-weight: 650; letter-spacing: .7px; text-transform: uppercase; color: var(--dim2); }
.set-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 7px;
  font-size: 13.5px;
}
.set-row .grow { flex: 1; min-width: 0; }
.set-row .hint { color: var(--dim2); font-size: 11.5px; margin-top: 2px; line-height: 1.45; }
.set-row .val { color: var(--dim); font-size: 12.5px; }
.set-row select, .set-row input[type="text"], .set-row input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  max-width: 140px;
}
.btn-sm {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(112, 152, 255, 0.08);
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.btn-sm.primary { background: linear-gradient(140deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; }
.model-pick { display: flex; flex-direction: column; gap: 7px; }
.model-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 13px;
  cursor: pointer;
}
.model-opt.on { border-color: rgba(105, 229, 255, 0.5); background: rgba(91, 124, 255, 0.12); }
.model-opt .radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.model-opt.on .radio { border-color: var(--aqua); background: radial-gradient(circle, var(--aqua) 45%, transparent 47%); }
.model-opt .t { font-size: 13.5px; }
.model-opt .d { font-size: 11.5px; color: var(--dim2); margin-top: 2px; }
.qr-box { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 13px; }
.qr-box img { width: 108px; height: 108px; border-radius: 8px; background: #fff; padding: 5px; }
.qr-box .url { font-size: 11.5px; color: var(--dim); word-break: break-all; line-height: 1.5; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 6px; background: rgba(112, 152, 255, 0.10); color: var(--dim2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: rgba(74, 222, 128, 0.3); background: rgba(74, 222, 128, 0.08); }
.danger { color: var(--err); }

/* ============ 登录 ============ */
.overlay {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 500px at 50% 24%, rgba(91, 124, 255, 0.30), transparent 65%),
    radial-gradient(500px 400px at 80% 80%, rgba(105, 229, 255, 0.14), transparent 70%),
    rgba(4, 8, 18, .92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  animation: fade .3s;
  color: #eef1f8;
}
.login-card .logo { width: 90px; height: 90px; border-radius: 50%; background: #fffdf8; border: 3px solid rgba(255, 255, 255, .92); box-shadow: 0 0 0 2px rgba(230, 195, 106, .7), 0 18px 40px rgba(20, 50, 160, .45); object-fit: cover; }
.setup-icon { width: 56px; height: 56px; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); display: grid; place-items: center; color: var(--aqua); }
.setup-icon svg { width: 26px; height: 26px; }
.login-card h1 { font-size: 22px; margin: 2px 0 0; letter-spacing: .2px; color: #f4f6fd; }
.login-card .muted { color: rgba(232, 238, 250, .64); font-size: 13px; line-height: 1.55; margin: 0; }
.field {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: #fff;
  font-size: 16px;
  outline: none;
  text-align: center;
  letter-spacing: 1.5px;
}
.field::placeholder { color: rgba(255, 255, 255, .32); letter-spacing: 1.5px; }
.field:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(105, 229, 255, .16); }
.primary {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border-radius: 13px;
  background: linear-gradient(140deg, #2f55e8, #3f6bff 60%, #8fd8ff 130%);
  color: #fff;
  font-size: 14.5px;
  font-weight: 650;
  box-shadow: 0 10px 26px rgba(70, 110, 255, .35);
}
.primary:disabled { opacity: .55; }
.link { font-size: 12.5px; color: rgba(232, 238, 250, .6); text-decoration: none; }
.err { min-height: 16px; font-size: 12px; color: #ff8a9a; margin: 2px 0 0; line-height: 1.45; }
.voice-tips {
  width: 100%;
  margin: 6px 0 2px;
  padding-left: 18px;
  text-align: left;
  color: rgba(232, 238, 250, .66);
  font-size: 12.5px;
  line-height: 1.6;
}
.voice-tips li { margin-bottom: 7px; }
.voice-card { max-width: 352px; }
.voice-card .primary { margin-top: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(16, 30, 56, .96);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 11px;
  font-size: 12.5px;
  z-index: 120;
  box-shadow: var(--shadow);
  animation: fade .18s;
  max-width: 80vw;
  text-align: center;
  backdrop-filter: blur(12px);
}
:root[data-theme="light"] .toast { background: rgba(255, 255, 255, .96); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

@media (min-width: 640px) {
  #thread { padding: 26px 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
