/* ============================================================
   WDFS-Fusion 内测版 · 液态玻璃风格
   网动繁生 · 无 emoji，全程动效
   ============================================================ */

:root {
  /* 粉白 + 浅紫 明亮玻璃配色 */
  --bg-0: #faf7fc;
  --bg-1: #fdf8ff;
  --bg-2: #f5edfb;
  --ink: #4b3a5f;
  --ink-2: #6f6490;
  --ink-3: #9d91bd;
  --ink-4: #b2a6cf;
  --accent: #b18cff;
  --accent-2: #c9a8ff;
  --accent-3: #e6b3ff;
  --danger: #fb7185;
  --glass-bg: linear-gradient(150deg, rgba(255,255,255,.66), rgba(255,255,255,.34));
  --glass-bg-strong: linear-gradient(150deg, rgba(255,255,255,.88), rgba(255,255,255,.68));
  --glass-bd: rgba(178,140,255,.22);
  --glass-hi: rgba(255,255,255,.85);
  --shadow-lg: 0 24px 60px -18px rgba(168,120,255,.35), 0 0 0 1px rgba(255,255,255,.55) inset;
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22,.9,.28,1);
  --ease-spring: cubic-bezier(.34,1.4,.5,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(135deg, #fff6ff 0%, #f7efff 48%, #f0e6ff 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(198,160,255,.4); }

/* ---------- 背景场景 ---------- */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .5;
  will-change: transform;
  animation: drift 26s var(--ease) infinite alternate;
}
.blob-a { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax;
  background: radial-gradient(circle at 30% 30%, #e0c6ff, transparent 70%); }
.blob-b { width: 40vmax; height: 40vmax; right: -10vmax; top: 6vmax;
  background: radial-gradient(circle at 60% 40%, #ffd3f0, transparent 72%);
  animation-duration: 32s; animation-delay: -8s; }
.blob-c { width: 38vmax; height: 38vmax; left: 22vmax; bottom: -16vmax;
  background: radial-gradient(circle at 50% 50%, #d9c6ff, transparent 70%);
  animation-duration: 40s; animation-delay: -16s; }
.blob-d { width: 26vmax; height: 26vmax; right: 20vmax; bottom: -8vmax;
  background: radial-gradient(circle at 50% 50%, #ffc9ea, transparent 70%);
  animation-duration: 36s; animation-delay: -4s; opacity: .38; }
@keyframes drift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(4vmax, -3vmax, 0) scale(1.08); }
  100% { transform: translate3d(-3vmax, 3vmax, 0) scale(.96); }
}
.noise {
  position: absolute; inset: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
  mix-blend-mode: overlay; pointer-events: none;
}
.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(216,190,255,.38) 100%);
  pointer-events: none;
}

/* ---------- 玻璃基元 ---------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 12px 34px -18px rgba(178,140,255,.4), var(--glass-hi) 0 1px 0 inset;
}
.glass-strong {
  background: var(--glass-bg-strong);
  border: 1px solid rgba(255,255,255,.7);
  backdrop-filter: blur(34px) saturate(160%);
  -webkit-backdrop-filter: blur(34px) saturate(160%);
  box-shadow: var(--shadow-lg), var(--glass-hi) 0 1px 0 inset;
}
/* 顶部高光扫过 */
.glass::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 32%);
  opacity: 0; pointer-events: none;
  transition: opacity .5s var(--ease);
}
.glass:hover::before { opacity: 1; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 应用布局 ---------- */
.app {
  position: relative; z-index: 1;
  display: flex; height: 100vh; height: 100dvh;
  gap: 14px; padding: 14px;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 280px; flex: 0 0 280px;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .45s var(--ease-spring), width .45s var(--ease-spring);
}
.sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-radius: var(--radius);
}
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, #e6d2ff, #f7d7ff);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 6px 18px -6px rgba(189,140,255,.5), 0 0 0 6px rgba(201,168,255,.14);
}
.brand-svg { width: 26px; height: 26px; overflow: visible; }
.brand-svg .s-node { fill: #8a5cff; stroke: none; }
.brand-svg .s-edge { stroke: rgba(138,92,255,.55); stroke-width: 1.2; }
.brand-title { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); letter-spacing: .4px; }

.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: #fff; cursor: pointer;
  border: 1px solid rgba(255,255,255,.5);
  background: linear-gradient(135deg, #c39bff, #a56bff 55%, #e08cff);
  box-shadow: 0 10px 26px -10px rgba(178,120,255,.8), 0 0 0 6px rgba(201,168,255,.18);
  transition: transform .28s var(--ease-spring), box-shadow .28s var(--ease), filter .28s var(--ease);
}
.btn-new:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 16px 34px -12px rgba(190,120,255,.9), 0 0 0 6px rgba(201,168,255,.24); }
.btn-new:active { transform: translateY(0) scale(.98); }

.session-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 2px; margin-right: -4px; padding-right: 6px;
}
.empty-side {
  color: var(--ink-3); font-size: 12.5px; text-align: center;
  padding: 30px 12px; line-height: 1.8;
}
.session-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer; position: relative;
  border: 1px solid transparent;
  transition: background .3s var(--ease), color .3s var(--ease), transform .25s var(--ease), border-color .3s var(--ease);
  animation: itemIn .4s var(--ease) both;
}
@keyframes itemIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.session-item:hover { background: rgba(201,168,255,.16); color: var(--ink); }
.session-item.active {
  background: linear-gradient(135deg, rgba(201,168,255,.35), rgba(230,179,255,.28));
  border-color: rgba(178,140,255,.4);
  color: var(--ink);
}
.session-item.active::after {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.session-meta { flex: 1; min-width: 0; }
.session-name {
  font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-time { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.session-del {
  opacity: 0; flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-3); cursor: pointer;
  border: none; background: transparent;
  transition: opacity .25s var(--ease), background .25s var(--ease), color .25s var(--ease), transform .2s var(--ease);
}
.session-item:hover .session-del { opacity: 1; }
.session-del:hover { background: rgba(251,113,133,.14); color: var(--danger); transform: scale(1.08); }
.session-del .ic { width: 15px; height: 15px; }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; }
.side-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: transform .28s var(--ease), color .3s var(--ease), background .3s var(--ease);
}
.side-btn:hover { color: var(--ink); transform: translateX(3px); background: rgba(201,168,255,.16); }
.side-btn .ic { width: 18px; height: 18px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(178,140,255,.35); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(178,140,255,.5); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 主区域 ---------- */
.main { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: var(--radius);
}
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-2); background: transparent; border: 1px solid transparent; border-radius: 11px;
  transition: background .3s var(--ease), color .3s var(--ease), transform .25s var(--ease-spring);
}
.icon-btn:hover { background: rgba(201,168,255,.18); color: var(--ink); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 {
  font-size: 15.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 11.5px; color: var(--ink-3); }

.model-picker { display: flex; align-items: center; gap: 8px; }
.pick-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); font-weight: 550;
  background: rgba(255,255,255,.5); border: 1px solid var(--glass-bd);
  transition: border-color .3s var(--ease), color .3s var(--ease), transform .25s var(--ease-spring), box-shadow .3s var(--ease);
}
.pick-chip:hover { color: var(--ink); border-color: rgba(178,140,255,.55); transform: translateY(-1px); }
.pick-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 10px var(--accent-3); }
.pick-chip.free .dot { background: linear-gradient(135deg, var(--accent-3), var(--accent)); box-shadow: 0 0 12px rgba(230,179,255,.9); }

/* ---------- 消息区 ---------- */
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 8px 8px; scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.msg { display: flex; gap: 12px; animation: msgIn .5s var(--ease) both; max-width: 860px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 11px;
  display: grid; place-items: center; margin-top: 2px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, #3d6ef7, #7c5cf0);
  border: 1px solid rgba(255,255,255,.25); color: #fff;
  box-shadow: 0 6px 16px -6px rgba(99,102,241,.6);
}
.msg.ai .msg-avatar {
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.22); color: var(--ink);
}
.msg-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; max-width: 640px; }
.msg-bubble {
  padding: 13px 16px; border-radius: 16px; font-size: 14px; line-height: 1.72;
  overflow-wrap: break-word; word-break: break-word;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, rgba(61,110,247,.85), rgba(124,92,240,.82));
  border: 1px solid rgba(255,255,255,.2); color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 12px 26px -14px rgba(99,102,241,.75);
}
.msg.ai .msg-bubble {
  background: rgba(20,26,50,.62);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom-left-radius: 6px;
}
.msg-role { font-size: 11px; color: var(--ink-3); padding: 0 4px; }
.msg.user .msg-role { text-align: right; }
.msg-time { font-size: 10.5px; color: var(--ink-4, #5f6b8c); padding: 0 4px; opacity: .7; }

/* 消息头像图片 / 用户上传图片 */
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.msg-avatar .avatar-initial { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.msg-img {
  max-width: 280px; max-height: 320px; width: auto; display: block;
  border-radius: 10px; margin-bottom: 8px; object-fit: contain;
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.18);
}

/* 消息内排版 */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px;
  background: rgba(255,255,255,.09); padding: 1.5px 6px; border-radius: 6px;
}
.msg-bubble pre {
  background: rgba(4,8,20,.6); border: 1px solid rgba(255,255,255,.1);
  padding: 12px 14px; border-radius: 12px; overflow-x: auto; margin: 8px 0;
}
.msg-bubble pre code { background: none; padding: 0; font-size: 12.5px; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble a { color: var(--accent); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { font-size: 15px; margin: 10px 0 6px; }
.msg-bubble blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--ink-2); margin: 8px 0; }
.msg-bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.msg-bubble td, .msg-bubble th { border: 1px solid rgba(255,255,255,.16); padding: 6px 10px; font-size: 13px; }
.msg-bubble hr { border: none; border-top: 1px solid rgba(255,255,255,.14); margin: 10px 0; }

/* 打字指示 */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* 空状态 */
.empty {
  margin: auto; text-align: center; max-width: 440px;
  animation: msgIn .7s var(--ease) both;
}
.empty-mark {
  width: 74px; height: 74px; margin: 0 auto 22px; border-radius: 24px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(110,168,255,.16), rgba(167,139,250,.12));
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 18px 40px -18px rgba(110,168,255,.5);
  animation: floatY 5s var(--ease) infinite alternate;
}
@keyframes floatY { from { transform: translateY(-4px); } to { transform: translateY(6px); } }
.empty-mark .ic { width: 34px; height: 34px; color: var(--accent); }
.empty h3 { font-size: 18px; font-weight: 650; margin-bottom: 10px; }
.empty p { font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }
.empty .prompts { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-top: 22px; }
.prompt-chip {
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 12.5px; color: var(--ink-2);
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd);
  transition: all .3s var(--ease-spring);
}
.prompt-chip:hover { color: var(--ink); border-color: rgba(178,140,255,.55); background: rgba(201,168,255,.22); transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(178,140,255,.5); }

/* ---------- 输入区 ---------- */
.composer-wrap { padding: 2px 6px 4px; }
.composer {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 8px 10px 10px; border-radius: 22px;
  transition: box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.composer:focus-within {
  border-color: rgba(110,168,255,.5);
  box-shadow: 0 14px 40px -16px rgba(110,168,255,.4), var(--glass-hi) 0 1px 0 inset;
}
.composer-line { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  color: var(--ink); font-family: inherit; font-size: 14.5px; line-height: 1.6;
  max-height: 180px; padding: 8px 0;
}
.composer textarea::placeholder { color: var(--ink-3); }
.btn-send {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  border: 1px solid rgba(255,255,255,.24);
  background: linear-gradient(135deg, #3d6ef7, #7c5cf0);
  box-shadow: 0 8px 22px -8px rgba(99,102,241,.7);
  transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease), filter .25s var(--ease);
}
.btn-send:hover { transform: translateY(-2px) scale(1.05); filter: brightness(1.08); box-shadow: 0 12px 28px -8px rgba(99,102,241,.9); }
.btn-send:active { transform: scale(.92); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.composer-hint { text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 8px; }

/* 上传图片按钮 */
.btn-img {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd);
  transition: all .28s var(--ease-spring);
}
.btn-img:hover { color: var(--accent); border-color: rgba(178,140,255,.55); background: rgba(201,168,255,.18); transform: translateY(-1px); }

/* 图片附件（发送前预览） */
.attach-row { padding: 2px 2px 0; }
.attach-chip {
  display: flex; align-items: center; gap: 8px; width: fit-content;
  padding: 6px; border-radius: 12px;
  background: rgba(255,255,255,.55); border: 1px solid var(--glass-bd);
  box-shadow: 0 6px 16px -10px rgba(168,120,255,.5);
}
.attach-chip img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; display: block; }
.attach-remove {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-3); cursor: pointer;
  border: none; background: transparent; transition: all .22s var(--ease);
}
.attach-remove:hover { background: rgba(251,113,133,.16); color: var(--danger); transform: scale(1.08); }
.attach-remove .ic { width: 15px; height: 15px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(5,8,20,.5);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--ease);
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%; max-width: 520px; border-radius: 26px; padding: 30px;
  position: relative; overflow: hidden;
  transform: translateY(20px) scale(.96); opacity: 0;
  transition: transform .5s var(--ease-spring), opacity .35s var(--ease);
}
.modal.open .modal-card { transform: none; opacity: 1; }
.modal-wide { max-width: 640px; }
.modal-glow {
  position: absolute; inset: -40% -30% auto; height: 70%;
  background: radial-gradient(closest-side, rgba(110,168,255,.28), transparent);
  pointer-events: none;
}
.modal-card h3 { font-size: 20px; font-weight: 680; margin-bottom: 8px; position: relative; }
.modal-lead { font-size: 13px; color: var(--ink-2); position: relative; margin-bottom: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; }
.modal-body { position: relative; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; position: relative; }

.consent-box {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px; padding: 18px; position: relative;
  font-size: 13.5px; line-height: 1.8; color: var(--ink-2);
}
.consent-box strong { color: var(--ink); }
.consent-core {
  background: rgba(110,168,255,.1); border: 1px solid rgba(110,168,255,.28);
  border-radius: 12px; padding: 12px 14px; margin: 12px 0;
  color: var(--ink); font-size: 13.5px; line-height: 1.75;
}
.consent-note { font-size: 12px; color: var(--ink-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; position: relative; }

/* 按钮 */
.btn-primary, .btn-ghost {
  padding: 11px 22px; border-radius: 13px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease);
}
.btn-primary {
  color: #fff; border: 1px solid rgba(255,255,255,.22);
  background: linear-gradient(135deg, #3d6ef7, #7c5cf0);
  box-shadow: 0 10px 26px -10px rgba(99,102,241,.7);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -10px rgba(99,102,241,.85); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { color: var(--ink-2); background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd); }
.btn-ghost:hover { color: var(--ink); background: rgba(255,255,255,.1); }
.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 10px; }

/* ---------- 设置 ---------- */
.set-group { margin-bottom: 22px; }
.set-label { display: block; font-size: 13px; font-weight: 650; color: var(--ink); margin-bottom: 10px; }
.set-desc { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.preset {
  padding: 11px 13px; border-radius: 12px; cursor: pointer; text-align: left;
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-bd); color: var(--ink-2);
  font-size: 12.5px; font-weight: 550;
  transition: all .28s var(--ease-spring);
}
.preset:hover { background: rgba(255,255,255,.09); color: var(--ink); transform: translateY(-1px); }
.preset.active {
  background: linear-gradient(135deg, rgba(110,168,255,.2), rgba(167,139,250,.16));
  border-color: rgba(110,168,255,.55); color: var(--ink);
  box-shadow: 0 8px 22px -10px rgba(110,168,255,.55);
}
.preset .free-tag { display: block; font-size: 10.5px; color: var(--accent-3); margin-top: 3px; font-weight: 600; }

.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; font-weight: 550; }
.field input, .field textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; resize: vertical;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd); color: var(--ink);
  font-family: inherit; font-size: 13.5px; outline: none;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.field input:focus, .field textarea:focus {
  border-color: rgba(110,168,255,.55); background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px rgba(110,168,255,.14);
}
.field select {
  width: 100%; padding: 11px 38px 11px 14px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd); color: var(--ink);
  font-family: inherit; font-size: 13.5px; outline: none; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.field select:focus {
  border-color: rgba(110,168,255,.55); background-color: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px rgba(110,168,255,.14);
}
.field select option { background: #1c2240; color: var(--ink); }
.field-note { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; }

/* ---------- 角色创建/编辑 ---------- */
.reco-note {
  font-size: 12px; color: var(--ink-2); line-height: 1.7;
  background: rgba(255,255,255,.05); border: 1px dashed var(--glass-bd);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px;
}
.reco-note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.reco-note a:hover { text-decoration: underline; }

.role-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar-preview {
  width: 72px; height: 72px; flex: 0 0 72px; border-radius: 20px;
  display: grid; place-items: center; overflow: hidden; position: relative;
  background: linear-gradient(150deg, rgba(177,140,255,.18), rgba(230,179,255,.14));
  border: 1px solid var(--glass-bd);
  box-shadow: 0 10px 24px -14px rgba(168,120,255,.6);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initial { font-size: 26px; font-weight: 700; color: var(--accent); }
.role-avatar-actions { display: flex; flex-direction: column; gap: 8px; }

/* 邀请码输入框 */
.invite-input {
  width: 100%; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px;
  background: rgba(255,255,255,.07); border: 1px solid var(--glass-bd); color: var(--ink);
  font-family: inherit; font-size: 13px; outline: none; font-weight: 550; letter-spacing: .3px;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.invite-input:focus { border-color: rgba(110,168,255,.55); background: rgba(255,255,255,.1); box-shadow: 0 0 0 3px rgba(110,168,255,.14); }
.invite-input::placeholder { color: var(--ink-3); font-weight: 400; letter-spacing: normal; }
.consent-note.err { color: var(--danger); }

/* ---------- 免费模型卡片（白底圆角） ---------- */
.free-model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
@media (max-width: 640px) { .free-model-grid { grid-template-columns: 1fr; } }
.free-model-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer;
  padding: 12px 13px; border-radius: var(--radius-sm); background: #ffffff;
  border: 1px solid rgba(255,255,255,.9); box-shadow: 0 4px 14px -8px rgba(168,120,255,.4);
  color: var(--ink); transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease), border-color .2s;
  font-family: inherit;
}
.free-model-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -10px rgba(168,120,255,.5); }
.free-model-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(177,140,255,.28), 0 8px 20px -10px rgba(168,120,255,.5); }
.free-model-card .fm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.free-model-card .fm-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.free-model-card .fm-pool {
  font-size: 10px; color: var(--accent); background: rgba(177,140,255,.16);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap; flex: 0 0 auto;
}
.free-model-card .fm-note { font-size: 11px; color: var(--ink-3); line-height: 1.5; }
.free-model-card .fm-quota { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.free-model-card .fm-quota-text { font-size: 10.5px; color: var(--ink-2); }
.free-model-card .fm-bar { height: 5px; border-radius: 999px; background: rgba(177,140,255,.16); overflow: hidden; }
.free-model-card .fm-bar i {
  display: block; height: 100%; border-radius: 999px; min-width: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .4s var(--ease);
}

/* ---------- 消息用量行（Tokens / 缓存命中） ---------- */
.msg-usage {
  font-size: 10.5px; color: var(--ink-3); padding: 4px 4px 0; opacity: .8; line-height: 1.5;
}

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--glass-bd); }
.switch {
  width: 50px; height: 28px; border-radius: 999px; flex: 0 0 auto; cursor: pointer;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); position: relative;
  transition: background .3s var(--ease);
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
  transition: transform .32s var(--ease-spring);
}
.switch.on { background: linear-gradient(135deg, #3d6ef7, #7c5cf0); }
.switch.on .knob { transform: translateX(22px); }

/* ---------- 记忆图谱 ---------- */
.memory-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; position: relative; }
.memory-stats { font-size: 12px; color: var(--ink-3); }
.memory-canvas {
  height: 360px; border-radius: 16px; position: relative; overflow: hidden;
  background: rgba(255,255,255,.03); border: 1px solid var(--glass-bd);
}
.memory-canvas svg { width: 100%; height: 100%; display: block; }
.mem-node { cursor: pointer; }
.mem-orb {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .32s var(--ease), filter .32s var(--ease);
}
.mem-node:hover .mem-orb {
  transform: scale(1.16);
  filter: drop-shadow(0 4px 12px rgba(177,140,255,.55));
}
.mem-label { font-size: 10px; fill: var(--ink-2); text-anchor: middle; pointer-events: none; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  padding: 11px 20px; border-radius: 14px; font-size: 13px; color: var(--ink);
  background: var(--glass-bg-strong); border: 1px solid var(--glass-bd);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  animation: toastIn .5s var(--ease-spring) both;
}
.toast.out { animation: toastOut .4s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px) scale(.95); } }

/* ---------- 移动端 ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(4,6,16,.5);
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease);
}
.scrim.show { opacity: 1; pointer-events: auto; }

@media (max-width: 820px) {
  .app { padding: 6px; gap: 8px; }
  /* 侧栏改为轻量玻璃抽屉，不遮住主体 */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 45;
    width: 86vw; max-width: 320px; padding: 12px;
    transform: translateX(-104%);
    background: rgba(255,253,255,.72);
    backdrop-filter: blur(28px) saturate(150%);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    border-right: 1px solid var(--glass-bd);
    box-shadow: 18px 0 48px -20px rgba(168,120,255,.5);
    transition: transform .45s var(--ease-spring);
  }
  .sidebar.open { transform: none; }

  /* 顶栏：模型选择器靠右，标题区收缩不溢出 */
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-title { flex: 1 1 auto; }
  .model-picker { max-width: 46%; }
  .pick-chip { padding: 7px 10px; font-size: 11.5px; }
  .pick-chip .chip-label { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .msg { gap: 10px; }
  .msg-body { max-width: 100%; }
  .msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; }

  /* 弹窗靠底、全宽，方便单手操作 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    max-width: 100%; width: 100%;
    border-radius: 26px 26px 0 0; padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
  }
  .memory-canvas { height: 52vh; }
}

@media (max-width: 420px) {
  .topbar-title h2 { font-size: 14px; }
  .topbar-sub { display: none; }
  .model-picker { max-width: 40%; }
  .pick-chip .dot { display: none; }
}

/* 减少动态偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ================= 消息内表情包 & 语音气泡 ================= */
.msg-emoji {
  display: inline-block; max-width: 140px; max-height: 140px;
  vertical-align: middle; border-radius: 12px; margin: 2px 4px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04);
}
.msg-bubble.voice-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; min-width: 150px; max-width: 240px;
  border-radius: 18px;
}
.msg-bubble.voice-msg .v-play {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; border: none;
  background: linear-gradient(135deg, #b48cff, #e08cff);
  box-shadow: 0 4px 12px rgba(178,140,255,.4);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.msg-bubble.voice-msg .v-play:hover { transform: scale(1.08); box-shadow: 0 6px 16px rgba(178,140,255,.55); }
.msg-bubble.voice-msg .v-play .v-play-ic { width: 16px; height: 16px; }
.msg-bubble.voice-msg .v-play .v-pause-ic { width: 14px; height: 14px; display: none; }
.msg-bubble.voice-msg .v-play.playing .v-play-ic { display: none; }
.msg-bubble.voice-msg .v-play.playing .v-pause-ic { display: block; }
.msg-bubble.voice-msg .v-wave { display: inline-flex; align-items: center; gap: 3px; height: 20px; }
.msg-bubble.voice-msg .v-wave .vb {
  width: 3px; height: var(--h); border-radius: 2px;
  background: linear-gradient(180deg, #b48cff, #e08cff);
  opacity: .7; transition: height .3s var(--ease);
}
.msg-bubble.voice-msg .v-play.playing ~ .v-wave .vb { animation: vbounce .9s infinite var(--ease); }
.msg-bubble.voice-msg .v-play.playing ~ .v-wave .vb:nth-child(2n) { animation-delay: .18s; }
.msg-bubble.voice-msg .v-play.playing ~ .v-wave .vb:nth-child(3n) { animation-delay: .36s; }
@keyframes vbounce { 0%,100% { height: 20%; } 50% { height: var(--h); } }
.msg-bubble.voice-msg .v-dur { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ================= 表情包库弹窗 ================= */
.emoji-tip { font-size: 12.5px; color: var(--ink-2); margin: 0 0 14px; line-height: 1.6; }
.emoji-upload .field { margin-bottom: 12px; }
#emojiUploadBtn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px;
  margin-top: 4px; max-height: 40vh; overflow-y: auto; padding: 4px 2px;
}
.emoji-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px 10px; border-radius: 14px;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-bd);
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.emoji-cell:hover { border-color: rgba(178,140,255,.5); background: rgba(201,168,255,.12); }
.emoji-cell img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; }
.emoji-cell .emoji-name { font-size: 12px; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-cell .emoji-del {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: none; align-items: center; justify-content: center; cursor: pointer;
  color: var(--ink-3); background: rgba(20,26,50,.5); border: 1px solid var(--glass-bd);
}
.emoji-cell:hover .emoji-del { display: flex; }
.emoji-cell .emoji-del .ic { width: 11px; height: 11px; }
.emoji-cell .emoji-del:hover { color: #fff; background: rgba(232,86,120,.8); border-color: transparent; }
