/* ==========================================================
   小欣 · AI 陪伴秘书
   温暖、克制、移动优先
   ========================================================== */

/* ---------- 变量 ---------- */
:root,
html[data-theme="light"] {
  --bg: #faf6f1;
  --bg-grad-1: #fdf7f0;
  --bg-grad-2: #f4ece3;
  --bg-grad-3: #f9efe9;
  --surface: #ffffff;
  --surface-2: #fdfaf7;
  --surface-3: #f8f2ec;
  --text: #322b27;
  --text-2: #6e625d;
  --text-3: #a2958e;
  --line: rgba(74, 52, 40, 0.08);
  --line-strong: rgba(74, 52, 40, 0.14);
  --brand: #d4826c;
  --brand-2: #bf6a56;
  --brand-soft: #f8e7e0;
  --brand-softer: #fdf3ef;
  --accent: #7f9c8e;
  --accent-soft: #e8f0eb;
  --warn: #c9756b;
  --user-bubble-1: #e2a184;
  --user-bubble-2: #cf7d67;
  --user-text: #ffffff;
  --ai-bubble: #ffffff;
  --ai-border: rgba(74, 52, 40, 0.06);
  --shadow-xs: 0 1px 2px rgba(120, 88, 68, 0.05);
  --shadow-sm: 0 2px 10px rgba(120, 88, 68, 0.06);
  --shadow: 0 10px 30px rgba(120, 88, 68, 0.10);
  --shadow-lg: 0 24px 60px rgba(120, 88, 68, 0.16);
  --ring: rgba(212, 130, 108, 0.28);
  --scroll: rgba(120, 95, 80, 0.18);
  --overlay: rgba(44, 32, 26, 0.32);
  --code-bg: #f4eee8;
  --skeleton: #efe7e0;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #141110;
  --bg-grad-1: #1a1614;
  --bg-grad-2: #121010;
  --bg-grad-3: #1c1513;
  --surface: #211c19;
  --surface-2: #262019;
  --surface-3: #2b241f;
  --text: #f0e8e2;
  --text-2: #b0a29a;
  --text-3: #857972;
  --line: rgba(255, 240, 230, 0.08);
  --line-strong: rgba(255, 240, 230, 0.14);
  --brand: #e09a82;
  --brand-2: #eaa98f;
  --brand-soft: #3a2823;
  --brand-softer: #2c211d;
  --accent: #9dbfae;
  --accent-soft: #26332d;
  --warn: #e08c81;
  --user-bubble-1: #c9826c;
  --user-bubble-2: #b56f5b;
  --user-text: #fff8f4;
  --ai-bubble: #241f1b;
  --ai-border: rgba(255, 240, 230, 0.06);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.46);
  --ring: rgba(224, 154, 130, 0.3);
  --scroll: rgba(255, 240, 230, 0.16);
  --overlay: rgba(0, 0, 0, 0.5);
  --code-bg: #2e2722;
  --skeleton: #2e2723;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #141110;
    --bg-grad-1: #1a1614;
    --bg-grad-2: #121010;
    --bg-grad-3: #1c1513;
    --surface: #211c19;
    --surface-2: #262019;
    --surface-3: #2b241f;
    --text: #f0e8e2;
    --text-2: #b0a29a;
    --text-3: #857972;
    --line: rgba(255, 240, 230, 0.08);
    --line-strong: rgba(255, 240, 230, 0.14);
    --brand: #e09a82;
    --brand-2: #eaa98f;
    --brand-soft: #3a2823;
    --brand-softer: #2c211d;
    --accent: #9dbfae;
    --accent-soft: #26332d;
    --warn: #e08c81;
    --user-bubble-1: #c9826c;
    --user-bubble-2: #b56f5b;
    --user-text: #fff8f4;
    --ai-bubble: #241f1b;
    --ai-border: rgba(255, 240, 230, 0.06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.46);
    --ring: rgba(224, 154, 130, 0.3);
    --scroll: rgba(255, 240, 230, 0.16);
    --overlay: rgba(0, 0, 0, 0.5);
    --code-bg: #2e2722;
    --skeleton: #2e2723;
    color-scheme: dark;
  }
}

/* ---------- 重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 8% -5%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 700px at 100% 0%, var(--bg-grad-3), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-2), var(--bg) 45%, var(--bg-grad-1));
  pointer-events: none;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

::selection {
  background: var(--brand-soft);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.hidden {
  display: none !important;
}

.serif {
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

/* ---------- 启动屏 ---------- */
.boot-screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-3);
}

.boot-orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff6ee, var(--brand) 62%, var(--brand-2));
  box-shadow: 0 0 0 0 var(--ring);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 var(--ring); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 18px transparent; }
}

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  user-select: none;
}

.btn:hover {
  background: var(--surface-3);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--user-bubble-1), var(--user-bubble-2));
  color: var(--user-text);
  border: none;
  box-shadow: 0 8px 20px -8px rgba(190, 110, 85, 0.6);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--user-bubble-1), var(--user-bubble-2));
  filter: brightness(1.04);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-3);
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  color: var(--warn);
  border-color: rgba(201, 117, 107, 0.3);
  background: transparent;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background 0.18s, color 0.18s, transform 0.12s;
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.3px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 13px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--surface);
}

.textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.hint {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
}

.error-text {
  font-size: 13px;
  color: var(--warn);
  min-height: 18px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 460px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(44, 36, 32, 0.92);
  color: #fdf6f1;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
  max-width: 100%;
}

html[data-theme="dark"] .toast {
  background: rgba(240, 232, 226, 0.95);
  color: #241f1b;
}

.toast.out {
  animation: toast-out 0.28s ease forwards;
}

.toast .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* ---------- Modal ---------- */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  animation: fade-in 0.2s ease;
}

.modal-host[hidden] {
  display: none !important;
}

.modal {
  width: min(560px, 100%);
  max-height: min(86dvh, 820px);
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-up 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
  border: 1px solid var(--line);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 12px;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.modal-body {
  padding: 4px 22px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

@keyframes modal-up {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ==========================================================
   登录页
   ========================================================== */
.auth {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  overflow: hidden;
}

.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
}

.auth-glow.g1 {
  width: 420px;
  height: 420px;
  background: #f3c9b6;
  top: -120px;
  left: -100px;
  animation: drift 18s ease-in-out infinite;
}

.auth-glow.g2 {
  width: 380px;
  height: 380px;
  background: #e9d3c4;
  bottom: -140px;
  right: -80px;
  animation: drift 22s ease-in-out infinite reverse;
}

.auth-glow.g3 {
  width: 260px;
  height: 260px;
  background: #dfe9e1;
  top: 45%;
  right: 12%;
  opacity: 0.4;
  animation: drift 26s ease-in-out infinite;
}

html[data-theme="dark"] .auth-glow {
  opacity: 0.22;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -24px) scale(1.06); }
  66% { transform: translate(-20px, 20px) scale(0.96); }
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  padding: 38px 34px 30px;
  border-radius: 30px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--surface) 60%, var(--line-strong));
  box-shadow: 0 30px 80px -30px rgba(120, 80, 60, 0.35), 0 2px 0 rgba(255,255,255,0.6) inset;
  animation: auth-in 0.6s cubic-bezier(0.2, 0.9, 0.25, 1);
}

html[data-theme="dark"] .auth-card {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(24px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  margin-bottom: 26px;
}

.auth-orb {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: linear-gradient(145deg, #fdf1e9, #f2cdbb 55%, #e6a98f);
  box-shadow: 0 12px 30px -10px rgba(200, 130, 100, 0.55), inset 0 1px 0 rgba(255,255,255,0.7);
  position: relative;
}

.auth-orb::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  animation: pulse-ring 3.6s ease-out infinite;
}

@keyframes pulse-ring {
  0% { opacity: 0.7; transform: scale(1); }
  70% { opacity: 0; transform: scale(1.14); }
  100% { opacity: 0; transform: scale(1.14); }
}

.auth-brand h1 {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 6px;
  text-indent: 6px;
}

.auth-brand p {
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: 1.6px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-input {
  position: relative;
}

.auth-input .input {
  height: 50px;
  padding: 0 46px 0 16px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  font-size: 15px;
}

.auth-input .lead-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  display: flex;
}

.auth-input .input.has-icon {
  padding-left: 44px;
}

.auth-input .lead-icon svg {
  width: 18px;
  height: 18px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.pw-toggle:hover {
  color: var(--text-2);
}

.auth-submit {
  height: 50px;
  border-radius: 15px;
  font-size: 15px;
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}

.auth-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.28) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform 0.6s;
}

.auth-submit:hover::after {
  transform: translateX(120%);
}

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3);
}

.auth-switch button {
  color: var(--brand-2);
  font-weight: 600;
  margin-left: 4px;
}

.auth-note {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.3px;
}

.auth-note svg {
  width: 13px;
  height: 13px;
}

.auth-foot {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

/* ==========================================================
   应用骨架
   ========================================================== */
.app-root {
  height: 100dvh;
}

.shell {
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 286px;
  flex: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-right: 1px solid var(--line);
  z-index: 30;
}

.side-head {
  padding: 20px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: linear-gradient(145deg, #fdf1e9, #efc9b6);
  box-shadow: var(--shadow-xs);
  flex: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 2px;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.6px;
  margin-top: -2px;
}

.side-actions {
  padding: 0 14px 12px;
}

.new-chat {
  width: 100%;
  height: 42px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.2s;
}

.new-chat:hover {
  border-color: var(--brand);
  color: var(--brand-2);
  background: var(--brand-softer);
}

.side-label {
  padding: 10px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-3);
  text-transform: uppercase;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.16s;
  position: relative;
}

.conv-item:hover {
  background: var(--surface-3);
}

.conv-item.active {
  background: var(--brand-softer);
}

.conv-item.active .conv-title {
  color: var(--brand-2);
  font-weight: 600;
}

.conv-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: var(--surface-3);
  flex: none;
}

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

.conv-title {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.4;
}

.conv-sub {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.conv-del {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: none;
  place-items: center;
  color: var(--text-3);
  flex: none;
}

.conv-item:hover .conv-del {
  display: grid;
}

.conv-del:hover {
  background: var(--surface);
  color: var(--warn);
}

.side-foot {
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.16s;
  width: 100%;
  text-align: left;
}

.user-chip:hover {
  background: var(--surface-3);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(145deg, #c99b83, #a97e68);
  flex: none;
  font-family: inherit;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-tag {
  font-size: 11px;
  color: var(--text-3);
}

/* ---------- 主区 ---------- */
.main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-head {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  z-index: 20;
}

.chat-head .head-persona {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.persona-avatar {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--brand-soft);
  flex: none;
  position: relative;
}

.persona-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7fbb92;
  border: 2px solid var(--surface);
}

.persona-title {
  min-width: 0;
}

.persona-title h2 {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}

.persona-title p {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

/* ---------- 消息区 ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px clamp(14px, 4vw, 40px) 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.messages-inner {
  max-width: 780px;
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: 1px;
  margin: 8px 0 2px;
}

.day-divider::before,
.day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msg-in 0.34s cubic-bezier(0.2, 0.9, 0.25, 1);
  max-width: 100%;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 14%, transparent);
  flex: none;
  margin-top: 2px;
  user-select: none;
}

.msg.user .msg-avatar {
  background: linear-gradient(145deg, #d8a288, #b87f66);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.msg-time .icon-btn {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .msg-time .icon-btn {
    display: inline-flex;
    opacity: 0;
    transition: opacity 0.15s;
  }

  .msg:hover .msg-time .icon-btn {
    opacity: 0.55;
  }
}

.msg-body {
  max-width: min(78%, 620px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.bubble {
  padding: 11px 15px;
  border-radius: 6px 18px 18px 18px;
  background: var(--ai-bubble);
  border: 1px solid var(--ai-border);
  box-shadow: var(--shadow-xs);
  font-size: 14.8px;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bubble > *:first-child { margin-top: 0; }
.bubble > *:last-child { margin-bottom: 0; }

/* 长回复折叠 */
.bubble.folded {
  max-height: 280px;
  overflow: hidden;
  position: relative;
}

.bubble.folded::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--ai-bubble));
  pointer-events: none;
}

.bubble.folded.open {
  max-height: none;
}

.bubble.folded.open::after {
  display: none;
}

.msg.user .bubble.folded::after {
  background: linear-gradient(to bottom, rgba(226, 161, 132, 0), var(--user-bubble-2));
}

.fold-toggle {
  align-self: flex-start;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.fold-toggle:hover {
  text-decoration: underline;
}

.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child { margin-bottom: 0; }

.bubble strong {
  font-weight: 650;
  color: var(--text);
}

.bubble em {
  font-style: italic;
  color: var(--text-2);
}

.bubble code {
  background: var(--code-bg);
  padding: 1.5px 5px;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}

.bubble pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.55;
}

.bubble pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.bubble ul,
.bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.bubble li { margin: 2px 0; }

.bubble blockquote {
  margin: 8px 0;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--brand-soft);
  color: var(--text-2);
}

.bubble a {
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
  color: var(--brand-2);
}

.msg.user {
  flex-direction: row-reverse;
}

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

.msg.user .bubble {
  background: linear-gradient(135deg, var(--user-bubble-1), var(--user-bubble-2));
  color: var(--user-text);
  border: none;
  border-radius: 18px 6px 18px 18px;
  box-shadow: 0 6px 16px -8px rgba(180, 105, 82, 0.6);
}

.msg.user .bubble a {
  color: #fff;
  border-bottom-color: rgba(255,255,255,0.5);
}

.msg.user .bubble code {
  background: rgba(255,255,255,0.18);
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  padding: 0 4px;
}

.msg-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
}

/* 附件 */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
  justify-content: flex-end;
}

.msg:not(.user) .msg-attachments {
  justify-content: flex-start;
}

.img-thumb {
  max-width: 210px;
  max-height: 230px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-3);
  cursor: zoom-in;
  border: 1px solid var(--line);
  position: relative;
  display: flex;
}

.img-thumb img {
  display: block;
  max-width: 100%;
  max-height: 230px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.35s;
}

.img-thumb:hover img {
  transform: scale(1.04);
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px 8px 9px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  max-width: 260px;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.file-chip .fi {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-2);
  flex: none;
}

/* 文件名和大小上下叠，别并排挤成一坨 */
.file-chip .ft {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.file-chip .fn {
  display: block;
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-chip .fs {
  display: block;
  font-size: 10.5px;
  color: var(--text-3);
}

/* 打字指示 */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

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

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

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

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--brand);
  margin-left: 2px;
  vertical-align: -0.15em;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* 滚动到底 */
.scroll-bottom {
  position: absolute;
  right: 24px;
  bottom: 132px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  color: var(--text-2);
  z-index: 15;
  border: 1px solid var(--line);
  transition: opacity 0.2s, transform 0.2s;
}

.scroll-bottom:hover {
  transform: translateY(-2px);
}

/* ---------- 欢迎态 ---------- */
.welcome {
  flex: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 16px 12vh;
  gap: 18px;
}

.welcome-orb {
  width: 84px;
  height: 84px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  font-size: 40px;
  background: linear-gradient(145deg, var(--brand-soft), var(--surface));
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  animation: float 5s ease-in-out infinite;
  position: relative;
}

.welcome-orb::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 38px;
  background: radial-gradient(circle, var(--ring), transparent 70%);
  z-index: -1;
  opacity: 0.6;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.welcome h2 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 2px;
}

.welcome .greet-text {
  font-size: 14.5px;
  color: var(--text-2);
  line-height: 1.9;
  max-width: 420px;
  white-space: pre-wrap;
}

.starters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
  margin-top: 4px;
  max-width: 460px;
}

.starter {
  padding: 9px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.18s;
}

.starter:hover {
  border-color: var(--brand);
  color: var(--brand-2);
  background: var(--brand-softer);
  transform: translateY(-1px);
}

.welcome-note {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* ---------- 输入区 ---------- */
.composer-wrap {
  flex: none;
  padding: 8px clamp(12px, 4vw, 40px) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  z-index: 18;
}

.composer {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 8px 8px 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--brand) 55%, transparent);
  box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--ring) 55%, transparent);
}

.composer.dragover {
  border-color: var(--brand);
  background: var(--brand-softer);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 3px;
  flex: none;
}

.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  max-height: 160px;
  min-height: 28px;
  padding: 7px 4px;
  color: var(--text);
}

.composer textarea::placeholder {
  color: var(--text-3);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--user-bubble-1), var(--user-bubble-2));
  color: #fff;
  flex: none;
  transition: transform 0.14s, opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 16px -8px rgba(190, 110, 85, 0.7);
}

.send-btn:disabled {
  opacity: 0.55;
  box-shadow: none;
  filter: saturate(0.7);
}

.send-btn:not(:disabled):hover {
  transform: translateY(-1px) scale(1.03);
}

.send-btn:not(:disabled):active {
  transform: scale(0.94);
}

.send-btn svg {
  width: 19px;
  height: 19px;
}

.composer-meta {
  max-width: 780px;
  margin: 7px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-3);
  padding: 0 6px;
  letter-spacing: 0.2px;
}

.composer-meta .mem-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.composer-meta .mem-dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.attach-tray {
  max-width: 780px;
  margin: 0 auto 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attach-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 26px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
  font-size: 12px;
  max-width: 220px;
  animation: msg-in 0.25s ease;
}

.attach-item img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
}

.attach-item .an {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-item .rm {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  background: var(--surface-3);
}

.attach-item .rm:hover {
  color: var(--warn);
}

/* ---------- 人设面板 ---------- */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 11px;
}

.persona-card {
  position: relative;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}

.persona-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 80px at 100% 0%, var(--p-accent, var(--brand-soft)), transparent 70%);
  opacity: 0.35;
  pointer-events: none;
}

.persona-card:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, transparent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.persona-card.active {
  border-color: var(--brand);
  background: var(--brand-softer);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 60%, transparent);
}

.persona-card .pc-emoji {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.persona-card .pc-name {
  font-size: 14.5px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 6px;
}

.persona-card .pc-sub {
  font-size: 11px;
  color: var(--brand-2);
  letter-spacing: 0.4px;
}

.persona-card .pc-desc {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.persona-card .pc-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.persona-card .pc-tag {
  font-size: 9.5px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-3);
}

.persona-card .btn {
  white-space: nowrap;
  padding: 0 9px;
  font-size: 11.5px;
  height: 30px;
  border-radius: 9px;
  flex: none;
}

/* ---------- 记忆页 ---------- */
.page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-head {
  flex: none;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.page-head h2 {
  font-size: 16px;
  font-weight: 650;
  flex: 1;
  letter-spacing: 0.5px;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px clamp(14px, 4vw, 32px) calc(30px + env(safe-area-inset-bottom));
}

.page-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.stat-card .num {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--brand-2);
}

.stat-card .lbl {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.section-title h3 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-title h3::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--brand);
  opacity: 0.7;
}

.section-title .count {
  font-size: 11px;
  color: var(--text-3);
}

.mem-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.mem-more {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: var(--surface-2);
  color: var(--brand-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.mem-more:hover {
  background: var(--surface-3);
}

.mem-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}

.mem-row:last-child {
  border-bottom: none;
}

.mem-row:hover {
  background: var(--surface-2);
}

.mem-key {
  flex: none;
  min-width: 76px;
  max-width: 110px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-2);
  background: var(--brand-softer);
  padding: 2px 8px;
  border-radius: 6px;
  text-align: center;
  line-height: 1.6;
  word-break: break-word;
}

.mem-content {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  min-width: 0;
}

.mem-meta {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.mem-del {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.mem-row:hover .mem-del {
  opacity: 1;
}

.mem-del:hover {
  background: var(--surface-3);
  color: var(--warn);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.8;
}

.empty-state .ico {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: 0.6;
}

/* 心情曲线 */
.mood-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-xs);
}

.mood-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mood-title {
  font-size: 13px;
  font-weight: 650;
}

.mood-latest {
  font-size: 11px;
  color: var(--text-3);
}

.mood-latest b {
  font-weight: 650;
}

.mood-plot {
  position: relative;
  height: 92px;
  margin: 2px 0 12px;
}

.mood-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mood-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mood-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--surface);
  box-shadow: 0 1px 4px rgba(120, 88, 68, 0.18);
}

.mood-dot.latest {
  width: 11px;
  height: 11px;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--mc) 18%, transparent),
    0 2px 8px rgba(120, 88, 68, 0.28);
}

.mood-dist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  line-height: 1.4;
  padding: 3px 9px;
  border-radius: 99px;
  font-weight: 550;
}

.mood-chip i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  opacity: 0.9;
}

.mood-chip b {
  font-weight: 700;
  opacity: 0.85;
}

/* ---------- 设置页 ---------- */
.setting-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-card h3 {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: 0.4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-row .sr-main {
  min-width: 0;
}

.setting-row .sr-title {
  font-size: 13.5px;
  font-weight: 550;
}

.setting-row .sr-desc {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 1px;
}

.theme-switch {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.theme-switch button {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  transition: all 0.18s;
}

.theme-switch button.on {
  background: var(--surface);
  color: var(--brand-2);
  box-shadow: var(--shadow-xs);
  font-weight: 700;
}

/* ---------- 后台 ---------- */
.admin-layout {
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

.admin-nav {
  width: 210px;
  flex: none;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav .an-brand {
  padding: 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-nav .an-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.16s;
  text-align: left;
}

.admin-nav .an-item:hover {
  background: var(--surface-3);
}

.admin-nav .an-item.on {
  background: var(--brand-softer);
  color: var(--brand-2);
  font-weight: 600;
}

.admin-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px clamp(16px, 3vw, 34px) 60px;
}

.admin-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-title h1 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 0.5px;
}

.admin-title p {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-xs);
}

.metric .m-num {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
}

.metric .m-lbl {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.metric .m-trend {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 650;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--surface-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}

.tag.green {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.red {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--warn);
}

.tag.sand {
  background: var(--brand-softer);
  color: var(--brand-2);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 110px;
  padding-top: 10px;
}

.bar-chart .bar {
  flex: 1 1 0;
  max-width: 46px;
  min-width: 4px;
  background: linear-gradient(to top, var(--brand), color-mix(in srgb, var(--brand) 45%, transparent));
  border-radius: 4px 4px 2px 2px;
  position: relative;
  transition: opacity 0.2s;
  min-height: 3px;
}

.bar-chart .bar:hover {
  opacity: 0.75;
}

.bar-labels {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 9.5px;
  color: var(--text-3);
  text-align: center;
}

.bar-labels span {
  flex: 1 1 0;
  max-width: 46px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* ---------- 图片预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(10, 8, 7, 0.92);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.2s;
}

.lightbox img {
  max-width: 96vw;
  max-height: 88dvh;
  border-radius: 10px;
  object-fit: contain;
}

.lightbox .close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: grid;
  place-items: center;
}

/* ---------- 抽屉遮罩 ---------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 29;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.drawer-mask.on {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(84vw, 310px);
    transform: translateX(-102%);
    transition: transform 0.32s cubic-bezier(0.25, 0.9, 0.3, 1);
    box-shadow: var(--shadow-lg);
    background: var(--surface);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .conv-del {
    display: grid;
    opacity: 0.55;
  }

  .admin-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    width: min(72vw, 240px);
    transform: translateX(-102%);
    transition: transform 0.3s ease;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
  }

  .admin-nav.open {
    transform: translateX(0);
  }

  .admin-main {
    padding-top: 14px;
  }

  .admin-mobile-bar {
    display: flex !important;
  }
}

@media (min-width: 861px) {
  .mobile-only {
    display: none !important;
  }
}

@media (max-width: 520px) {
  .chat-head {
    height: 58px;
    padding: 0 10px;
  }

  .messages {
    padding: 16px 12px 8px;
  }

  .msg-body {
    max-width: 82%;
  }

  .bubble {
    font-size: 14.5px;
    padding: 10px 13px;
  }

  .msg-avatar {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 10px;
  }

  .composer-meta .kbd-hint {
    display: none;
  }

  .composer-wrap {
    padding: 6px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .composer {
    border-radius: 20px;
  }

  .img-thumb {
    max-width: 168px;
    max-height: 190px;
  }

  .img-thumb img {
    max-height: 190px;
  }

  .auth-card {
    padding: 30px 22px 24px;
    border-radius: 24px;
  }

  .auth-brand h1 {
    font-size: 26px;
  }

  .stat-card .num {
    font-size: 20px;
  }

  .modal {
    border-radius: 20px;
    max-height: 90dvh;
  }

  .persona-grid {
    grid-template-columns: repeat(auto-fill, minmax(163px, 1fr));
    gap: 9px;
  }

  .scroll-bottom {
    right: 14px;
    bottom: 120px;
  }
}

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

/* ---------- 打印无关 ---------- */
@media print {
  .sidebar, .composer-wrap, .chat-head { display: none; }
}

/* ==========================================================
   文字动效
   ========================================================== */

/* 流式输出：每个小片段淡入 */
.stream-chunk {
  animation: chunk-in 0.26s ease both;
}

@keyframes chunk-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 通用上浮 */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes orb-in {
  from { opacity: 0; transform: scale(0.82); filter: blur(6px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* 欢迎页：依次浮现 */
.welcome .welcome-orb {
  animation: orb-in 0.75s cubic-bezier(0.2, 0.8, 0.25, 1) both,
             float 5s 1.4s ease-in-out infinite;
}

.welcome h2 {
  animation: fade-up 0.7s 0.12s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.welcome .greet-text {
  animation: fade-up 0.7s 0.2s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.welcome .starters {
  animation: fade-up 0.7s 0.3s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.welcome .welcome-note {
  animation: fade-up 0.7s 0.4s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

/* 登录页 */
.auth-orb {
  animation: orb-in 0.8s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.auth-brand h1 {
  animation: title-in 0.9s 0.08s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

@keyframes title-in {
  from { opacity: 0; letter-spacing: 18px; filter: blur(3px); }
  to { opacity: 1; letter-spacing: 6px; filter: blur(0); }
}

.auth-brand p {
  animation: fade-up 0.65s 0.24s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.auth-form > * {
  animation: fade-up 0.55s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.auth-form > *:nth-child(1) { animation-delay: 0.3s; }
.auth-form > *:nth-child(2) { animation-delay: 0.36s; }
.auth-form > *:nth-child(3) { animation-delay: 0.42s; }
.auth-form > *:nth-child(4) { animation-delay: 0.48s; }
.auth-form > *:nth-child(5) { animation-delay: 0.52s; }

.auth-switch,
.auth-note,
.auth-foot {
  animation: fade-up 0.6s 0.56s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

/* 新消息：更轻的入场 */
.msg {
  animation: msg-in 0.4s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

/* 骨架屏 */
.skeleton-bubble {
  width: min(62%, 380px);
  height: 46px;
  border-radius: 6px 18px 18px 18px;
  background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 45%, var(--surface-3) 60%);
  background-size: 240% 100%;
  animation: shimmer 1.5s linear infinite;
  border: 1px solid var(--ai-border);
}

.skeleton-bubble.short { width: min(44%, 280px); height: 40px; }

.skeleton-avatar {
  background: var(--surface-3) !important;
  border-color: transparent !important;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

/* 打字机光标更柔和 */
.caret {
  width: 2px;
  border-radius: 2px;
  background: var(--brand);
  opacity: 0.85;
}

/* ---------------- 邀请码（后台） ---------------- */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.22s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(40, 26, 18, 0.22);
  transition: transform 0.22s ease;
}

.switch.on {
  background: var(--brand);
}

.switch.on::after {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.55;
  cursor: default;
}

.invite-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.invite-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 0 2px 14px;
  font-size: 13px;
  color: var(--text-2);
}

.invite-stats b {
  font-weight: 650;
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .stream-chunk,
  .welcome .welcome-orb,
  .welcome h2,
  .welcome .greet-text,
  .welcome .starters,
  .welcome .welcome-note,
  .auth-orb,
  .auth-brand h1,
  .auth-brand p,
  .auth-form > *,
  .auth-switch,
  .auth-note,
  .auth-foot,
  .msg,
  .skeleton-bubble {
    animation: none !important;
  }
}
