/* ==========================================================
   WOAIL Chat App — Liquid Glass Style
   类 Gemini 三栏聊天布局
   ========================================================== */

/* ---------- Tokens (Light by default) ---------- */
:root {
  /* Surfaces */
  --bg: #fbfbfd;
  --bg-soft: #ffffff;
  --text: #1d1d1f;
  --text-dim: #6e6e73;
  --text-muted: #86868b;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-bg-strong: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-hover: rgba(0, 0, 0, 0.15);

  /* Brand */
  --primary: #0071e3;
  --primary-dark: #0058b0;
  --primary-glow: rgba(0, 113, 227, 0.25);
  --primary-soft: rgba(0, 113, 227, 0.1);

  --accent-purple: #bf5af2;
  --accent-cyan: #64d2ff;
  --accent-pink: #ff375f;
  --accent-orange: #ff9f0a;
  --accent-green: #30d158;

  /* Gradient (蓝→青→紫) */
  --gradient-bg: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 50%, var(--accent-purple) 100%);
  --gradient-glow: rgba(191, 90, 242, 0.28);

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark Mode ---------- */
body.dark-mode {
  --bg: #000000;
  --bg-soft: #0a0a0c;
  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-muted: #6e6e73;

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-strong: rgba(255, 255, 255, 0.10);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.22);

  --primary: #2997ff;
  --primary-dark: #0684c7;
  --primary-glow: rgba(41, 151, 255, 0.35);
  --primary-soft: rgba(41, 151, 255, 0.15);

  --gradient-bg: linear-gradient(135deg, #2997ff 0%, #64d2ff 50%, #bf5af2 100%);
  --gradient-glow: rgba(191, 90, 242, 0.35);
}

/* ---------- Reset / Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s var(--ease-soft), color 0.4s var(--ease-soft);
}
button { font-family: inherit; cursor: pointer; border: none; background: transparent; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Aurora Background ---------- */
.aurora-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  overflow: hidden;
}
.aurora-bg::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at top, var(--primary-soft), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(191, 90, 242, 0.08), transparent 50%);
  opacity: 0.9;
}
.aurora-glow {
  position: absolute; border-radius: 50%;
  filter: blur(120px); opacity: 0.5;
  animation: floatGlow 18s ease-in-out infinite;
}
.aurora-glow-1 { width: 500px; height: 500px;
  background: radial-gradient(circle, var(--primary-glow), transparent 70%);
  top: -150px; left: -100px;
}
.aurora-glow-2 { width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(191, 90, 242, 0.22), transparent 70%);
  top: 20%; right: -150px;
  animation-delay: -6s;
}
.aurora-glow-3 { width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(6, 132, 199, 0.2), transparent 70%);
  bottom: -200px; left: 15%;
  animation-delay: -12s;
}
body:not(.dark-mode) .aurora-glow { opacity: 0.3; }
body:not(.dark-mode) .aurora-glow-1 { background: radial-gradient(circle, rgba(0, 113, 227, 0.15), transparent 70%); }
body:not(.dark-mode) .aurora-glow-2 { background: radial-gradient(circle, rgba(191, 90, 242, 0.12), transparent 70%); }

@keyframes floatGlow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 40px) scale(0.95); }
}

/* ---------- Glass Toolkit ---------- */
.glass-card, .glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  transition: all 0.3s var(--ease);
}
.glass-card:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}
body:not(.dark-mode) .glass-card,
body:not(.dark-mode) .glass-panel {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* ---------- App Shell (双栏布局) ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  height: 100vh;
  box-sizing: border-box;
}

/* ---------- Sidebar (左侧栏，默认隐藏为 overlay，点击汉堡按钮滑出) ---------- */
.sidebar {
  position: fixed;
  top: 12px; left: 12px; bottom: 12px;
  width: 280px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  min-height: 0;
  box-sizing: border-box;
  z-index: 70;
  transform: translateX(calc(-100% - 20px));
  transition: transform 0.4s var(--ease);
}
@media (min-width: 769px) {
  .sidebar {
    transform: translateX(0);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  }
}
.sidebar.open { transform: translateX(0); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.sidebar-header {
  padding: 4px 8px 16px;
}
.new-chat-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  box-shadow: 0 6px 20px var(--gradient-glow);
  animation: gradientShift 8s ease infinite, glowPulse 4s ease-in-out infinite;
}
.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(100, 210, 255, 0.55), 0 0 0 1px rgba(255,255,255,0.08) inset;
}
.new-chat-btn:active { transform: translateY(0); }
.new-chat-btn .icon { width: 18px; height: 18px; }
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: var(--glass-border-hover); border-radius: 999px; }

.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-dim);
  text-align: left;
  transition: all 0.2s var(--ease-soft);
  border: 1px solid transparent;
}
.history-item:hover {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  color: var(--text);
}
.history-item.active {
  background: var(--primary-soft);
  color: var(--text);
  border-color: var(--primary-glow);
}
.history-item .h-title {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .h-edit {
  opacity: 0; color: var(--text-muted);
  transition: opacity 0.2s;
  display: inline-flex; align-items: center; justify-content: center;
}
.history-item .h-edit svg { width: 15px; height: 15px; }
.history-item .h-del {
  opacity: 0; font-size: 16px; color: var(--text-muted);
  transition: opacity 0.2s;
}
.history-item:hover .h-edit { opacity: 1; }
.history-item:hover .h-del { opacity: 1; }
.history-item .h-edit:hover { color: var(--primary); }
.history-item .h-del:hover { color: var(--accent-pink); }

.h-rename {
  flex: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.h-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 13px; color: var(--text-muted);
}

.sidebar-footer {
  display: flex; gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}
.footer-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dim);
  transition: all 0.25s var(--ease-soft);
}
.footer-btn:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hover);
  color: var(--text);
}
.footer-btn .icon { width: 18px; height: 18px; }

/* 主题切换图标动画 */
.theme-icon-moon, .theme-icon-sun {
  width: 18px; height: 18px;
}
.theme-icon-moon { display: inline-block; }
.theme-icon-sun { display: none; }
body:not(.dark-mode) .theme-icon-moon { display: none; }
body:not(.dark-mode) .theme-icon-sun { display: inline-block; }

/* ---------- Chat Main ---------- */
.chat-main {
  display: flex; flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 0;
}
@media (min-width: 769px) {
  .chat-main {
    margin-left: 300px;
  }
}
.chat-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
.menu-btn {
  display: none; align-items: center; justify-content: center;
  padding: 10px; border-radius: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: all 0.2s var(--ease-soft);
}
.menu-btn:hover { background: var(--glass-bg-strong); border-color: var(--glass-border-hover); }
.menu-btn .icon { width: 20px; height: 20px; }
@media (max-width: 768px) {
  .menu-btn {
    display: inline-flex;
  }
}

.topbar-avatar {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--gradient-bg); background-size: 200% 200%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0; margin-right: 10px;
  animation: gradientShift 8s ease infinite, glowPulse 4s ease-in-out infinite;
}
.topbar-avatar svg { width: 18px; height: 18px; }
.chat-title-wrap { flex: 1; min-width: 0; }
.chat-title { font-size: 16px; font-weight: 600; margin: 0; }
.chat-model-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  margin-top: 2px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.topbar-actions { display: flex; gap: 8px; }
.mode-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-size: 13px; color: var(--text-dim);
}
.mode-toggle:hover { color: var(--text); background: var(--glass-bg-strong); }
.mode-toggle .icon { width: 16px; height: 16px; }

/* ---------- Chat Area ---------- */
.chat-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--glass-border-hover); border-radius: 999px; }

/* Welcome */
.welcome-screen {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 16px;
  text-align: center;
  min-height: 0;
}
.welcome-avatar {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; margin-bottom: 24px;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: gradientShift 8s ease infinite, glowPulseMedium 4s ease-in-out infinite;
}
.welcome-avatar:hover { transform: translateY(-3px) scale(1.04); }
.welcome-avatar svg { width: 32px; height: 32px; }

.welcome-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  margin: 0 0 12px;
}
.gradient-text {
  font-weight: 700;
  background: var(--gradient-bg);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(41, 151, 255, 0.35); }
  33%      { box-shadow: 0 6px 24px rgba(100, 210, 255, 0.55); }
  66%      { box-shadow: 0 6px 24px rgba(191, 90, 242, 0.55); }
}
@keyframes glowPulseMedium {
  0%, 100% { box-shadow: 0 10px 32px rgba(41, 151, 255, 0.45); }
  33%      { box-shadow: 0 10px 36px rgba(100, 210, 255, 0.6); }
  66%      { box-shadow: 0 10px 36px rgba(191, 90, 242, 0.6); }
}
@keyframes glowPulseSmall {
  0%, 100% { box-shadow: 0 4px 12px rgba(41, 151, 255, 0.35); }
  33%      { box-shadow: 0 4px 16px rgba(100, 210, 255, 0.55); }
  66%      { box-shadow: 0 4px 16px rgba(191, 90, 242, 0.55); }
}
@keyframes glowPulseTiny {
  0%, 100% { box-shadow: 0 2px 8px rgba(41, 151, 255, 0.4); }
  33%      { box-shadow: 0 2px 10px rgba(100, 210, 255, 0.55); }
  66%      { box-shadow: 0 2px 10px rgba(191, 90, 242, 0.55); }
}
.welcome-sub {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 500px;
  margin: 0 0 40px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  max-width: 900px; width: 100%;
}
.suggestion-card {
  padding: 18px;
  text-align: left;
  display: flex; flex-direction: column; gap: 8px;
}
.sug-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.sug-icon svg { width: 18px; height: 18px; }
.sug-title { font-size: 15px; font-weight: 600; }
.sug-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

/* Messages */
.messages {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 0 24px;
  display: flex; flex-direction: column; gap: 12px;
  align-items: flex-start;
}
.msg {
  display: flex;
  max-width: 100%;
  animation: msgIn 0.3s var(--ease);
}
.msg-ai {
  align-self: flex-start;
  flex-direction: column;
  align-items: flex-start;
}
.msg-user {
  align-self: flex-end;
  flex-direction: column;
  align-items: flex-end;
}

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

.msg-bubble {
  padding: 14px 20px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.msg-ai .msg-bubble {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.msg-user .msg-bubble {
  background: #e8e8ec;
  color: var(--text);
  border-bottom-right-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.dark-mode .msg-user .msg-bubble {
  background: #3a3a3c;
  color: #f5f5f7;
}
.msg-user .msg-bubble .msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.msg-user .msg-bubble .msg-attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.msg-user .msg-bubble .msg-attach-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  cursor: zoom-in;
}
.msg-user .msg-bubble .msg-attach-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg-user .msg-bubble .msg-attach-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.msg-error .msg-bubble {
  background: rgba(255, 55, 95, 0.1);
  border: 1px solid rgba(255, 55, 95, 0.3);
  color: var(--accent-pink);
}

.msg-typing .msg-bubble { color: var(--text-dim); }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---------- Input Area ---------- */
.input-area {
  flex-shrink: 0;
  padding: 10px 12px 14px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}
.input-wrap {
  padding: 12px;
  display: flex; align-items: flex-end; gap: 10px;
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
body:not(.dark-mode) .input-wrap {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}
.plus-btn {
  width: 38px; height: 38px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.25s var(--ease-soft), background 0.25s var(--ease-soft), border-color 0.25s var(--ease-soft);
}
.plus-btn svg { width: 18px; height: 18px; }
.plus-btn:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px) rotate(90deg);
}
.plus-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  transform: rotate(90deg);
}

.input-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#chat-input {
  width: 100%;
  border: none; outline: none; background: transparent;
  color: var(--text);
  font-size: 15px; font-family: inherit;
  resize: none;
  min-height: 24px; max-height: 200px;
  padding: 6px 0;
  line-height: 1.5;
}
#chat-input::placeholder { color: var(--text-muted); }

.input-actions { display: flex; align-items: center; gap: 8px; }
.attach-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.25s var(--ease-soft), background 0.25s var(--ease-soft), border-color 0.25s var(--ease-soft);
  flex-shrink: 0;
}
.attach-btn svg { width: 18px; height: 18px; }
.attach-btn:hover {
  transform: translateY(-2px);
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hover);
}
.attach-btn:active { transform: translateY(0); }

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 10px;
}
.attach-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text);
  max-width: 220px;
  position: relative;
}
.attach-item.is-image {
  padding: 4px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.attach-item img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.attach-item .attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  font-size: 11px;
  color: var(--text-dim);
}
.attach-item .attach-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.attach-item .attach-remove:hover {
  background: rgba(255,55,95,0.15);
  color: var(--accent-pink);
}

.send-btn, .stop-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.25s var(--ease-soft), box-shadow 0.25s var(--ease-soft);
  animation: gradientShift 8s ease infinite, glowPulseSmall 4s ease-in-out infinite;
}
.send-btn svg { width: 18px; height: 18px; }
.stop-btn svg { width: 14px; height: 14px; }
.send-btn:hover, .stop-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(100, 210, 255, 0.55); }
.send-btn:active, .stop-btn:active { transform: translateY(0); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; animation: none; }
.input-hint {
  text-align: center;
  font-size: 11px; color: var(--text-muted);
  margin-top: 8px;
}

/* ---------- Drawer (右侧设置面板) ---------- */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease-soft);
  z-index: 50;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 12px; right: 12px; bottom: 12px;
  width: 340px; max-width: calc(100vw - 24px);
  padding: 20px;
  transform: translateX(calc(100% + 20px));
  transition: transform 0.4s var(--ease);
  z-index: 60;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer::-webkit-scrollbar { width: 6px; }
.drawer::-webkit-scrollbar-thumb { background: var(--glass-border-hover); border-radius: 999px; }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.drawer-header h3 { margin: 0; font-size: 17px; font-weight: 600; }
.drawer-close {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease-soft);
}
.drawer-close:hover { background: var(--glass-bg-strong); border-color: var(--glass-border-hover); }
.drawer-close .icon { width: 18px; height: 18px; }

.drawer-section { margin-bottom: 24px; }
.drawer-label {
  display: block;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 10px;
  font-weight: 500;
}
.drawer-value {
  float: right;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.mode-switcher {
  display: flex; gap: 8px;
  padding: 4px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
.mode-chip {
  flex: 1;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 10px;
  color: var(--text-dim);
  transition: all 0.25s var(--ease-soft);
}
.mode-chip.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary-glow);
}

.mode-hint {
  font-size: 12px; color: var(--text-muted);
  margin-top: 10px; line-height: 1.5;
}

.drawer-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px; font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.drawer-select:focus { border-color: var(--primary); }
.drawer-select option { background: var(--bg-soft); color: var(--text); }

.drawer-range {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--glass-bg);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.drawer-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  cursor: pointer;
  border: 2px solid var(--bg);
  animation: gradientShift 8s ease infinite, glowPulseTiny 4s ease-in-out infinite;
}
.drawer-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  cursor: pointer;
  border: 2px solid var(--bg);
  animation: gradientShift 8s ease infinite, glowPulseTiny 4s ease-in-out infinite;
}

.api-status {
  padding: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
.status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.status-indicator {
  width: 8px; height: 8px; border-radius: 50%;
}
.status-ok { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-warn { background: var(--accent-orange); box-shadow: 0 0 8px var(--accent-orange); }
.status-error { background: var(--accent-pink); box-shadow: 0 0 8px var(--accent-pink); }

.status-sub {
  font-size: 12px; color: var(--text-muted);
  margin-top: 6px; line-height: 1.4;
}

.drawer-action {
  width: 100%;
  padding: 14px;
  background: var(--gradient-bg);
  background-size: 200% 200%;
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: gradientShift 8s ease infinite, glowPulse 4s ease-in-out infinite;
}
.drawer-action:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(100, 210, 255, 0.55); }
.drawer-action:active { transform: translateY(0); }

.drawer-action-secondary {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-soft);
}
.drawer-action-secondary:hover {
  color: var(--text);
  border-color: var(--glass-border-hover);
  background: var(--glass-bg);
}

/* ---------- 默认模型展示 ---------- */
.default-model-status {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(41, 151, 255, 0.12), rgba(191, 90, 242, 0.08));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
.default-model-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.default-model-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.default-model-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- 角标 Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge-flagship {
  background: linear-gradient(135deg, rgba(41, 151, 255, 0.2), rgba(191, 90, 242, 0.18));
  color: var(--primary);
  border-color: var(--primary-glow);
}
.badge-inline {
  margin-left: 6px;
  font-size: 10px;
  padding: 2px 7px;
  vertical-align: middle;
}

/* ---------- 顶部状态角标 ---------- */
.status-mini-badge {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(41, 151, 255, 0.18), rgba(191, 90, 242, 0.16));
  color: var(--primary);
  border: 1px solid var(--primary-glow);
}

.drawer-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 12px 0;
}

.drawer-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px; font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 6px;
}
.drawer-input:focus {
  border-color: var(--primary);
}

.drawer-label-collapsible {
  cursor: pointer;
  user-select: none;
  display: flex; align-items: center; gap: 6px;
}
.caret {
  display: inline-block;
  transition: transform 0.2s var(--ease-soft);
  font-size: 10px;
  color: var(--text-dim);
}
.drawer-label-collapsible.open .caret {
  transform: rotate(90deg);
}
.custom-panel {
  margin-top: 10px;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Quick Panel (快捷模式浮层) ---------- */
.quick-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 20px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 30;
}
.quick-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.quick-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.quick-panel-title {
  font-size: 15px;
  font-weight: 600;
}
.quick-panel-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.quick-panel-close svg { width: 14px; height: 14px; }
.quick-panel-close:hover {
  background: var(--glass-bg-strong);
  color: var(--text);
  border-color: var(--glass-border-hover);
}
.quick-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.quick-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.25s var(--ease-soft);
  font-family: inherit;
}
.quick-card:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}
.quick-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-bg-strong);
  border-radius: 10px;
}
.quick-icon svg { width: 16px; height: 16px; }
.quick-info { min-width: 0; }
.quick-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.quick-desc {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .quick-panel-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .quick-title { font-size: 12px; }
  .quick-desc { font-size: 10px; }
}

/* ---------- 画板面板（AI 画图） ---------- */
.canvas-panel { max-height: calc(100vh - 120px); overflow-y: auto; }
.canvas-field { margin-top: 12px; }
.canvas-field-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 12px 0 6px;
  font-weight: 500;
}
.canvas-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.canvas-input:focus { border-color: var(--primary); }
.canvas-input::placeholder { color: var(--text-dim); opacity: 0.7; }

.canvas-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.canvas-chip {
  padding: 6px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.canvas-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}
.canvas-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.canvas-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 16px;
  padding: 12px 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s var(--ease-soft);
}
.canvas-generate:hover {
  background: var(--glass-bg-strong);
  border-color: var(--primary);
  transform: translateY(-2px);
}
.canvas-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.canvas-result {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.canvas-result img {
  width: 100%;
  border-radius: 14px;
  display: block;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
.canvas-result .canvas-result-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.canvas-result-actions button {
  padding: 6px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.canvas-result-actions button:hover {
  background: var(--glass-bg-strong);
  border-color: var(--primary);
}
.canvas-loading {
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.canvas-loading .typing-dots { margin-right: 6px; }
.canvas-error {
  padding: 12px 14px;
  background: rgba(255, 55, 95, 0.12);
  border: 1px solid rgba(255, 55, 95, 0.35);
  color: #ff7a93;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-all;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .drawer { width: 320px; }
  .suggestion-grid { display: none; }
  .welcome-title .gradient-text { display: block; }
}

@media (max-width: 480px) {
  .app-shell { padding: 8px; gap: 8px; }
  .input-area { padding: 0 8px 12px; }
  .welcome-screen { padding: 24px 12px; }
  .chat-title { display: none; }
  .welcome-title { font-size: 28px; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .aurora-glow { animation: none; }
}

/* ---------- Mobile Performance ---------- */
@media (max-width: 768px) {
  .aurora-glow {
    filter: none !important;
    animation: none !important;
    opacity: 0.25 !important;
  }
  .glass-card:hover, .glass-panel:hover {
    transform: none !important;
  }
  .topbar-avatar, .welcome-avatar {
    animation: none !important;
  }
  .suggestion-card {
    animation: none !important;
  }
}

/* ============================================================
   Markdown 渲染（WOAIL 官方风格，与首页完全一致）
   ============================================================ */
.msg-bubble .md-p {
  margin: 0 0 0.6em;
  line-height: 1.7;
}
.msg-bubble .md-p:last-child { margin-bottom: 0; }

.msg-bubble .md-h1,
.msg-bubble .md-h2,
.msg-bubble .md-h3,
.msg-bubble .md-h4,
.msg-bubble .md-h5,
.msg-bubble .md-h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 0.4em 0 0.5em;
}
.msg-bubble .md-h1 { font-size: 1.45rem; }
.msg-bubble .md-h2 { font-size: 1.25rem; }
.msg-bubble .md-h3 { font-size: 1.1rem; }
.msg-bubble .md-h4 { font-size: 1.02rem; }
.msg-bubble .md-h5,
.msg-bubble .md-h6 { font-size: 0.98rem; opacity: 0.95; }

.msg-bubble .md-hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1em 0;
}

.msg-bubble .md-list {
  margin: 0.4em 0 0.8em 1.3em;
  padding: 0;
  line-height: 1.7;
}
.msg-bubble .md-list li {
  margin: 0.18em 0;
}
.msg-bubble .md-ol { list-style-type: decimal; }
.msg-bubble ul.md-list { list-style-type: disc; }

.msg-bubble .md-quote {
  margin: 0.6em 0;
  padding: 0.35em 0.8em;
  border-left: 3px solid var(--primary);
  background: rgba(41, 151, 255, 0.06);
  color: var(--text-dim);
  font-style: normal;
  border-radius: 0 10px 10px 0;
}

.msg-bubble strong { font-weight: 700; color: var(--text); }
.msg-bubble em { font-style: italic; }
.msg-bubble del { opacity: 0.55; text-decoration: line-through; }

.msg-bubble a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(41, 151, 255, 0.4);
  transition: color 0.2s;
}
.msg-bubble a:hover {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

/* 行内代码 */
.msg-bubble .inline-code {
  display: inline-block;
  padding: 0.1em 0.45em;
  margin: 0 0.15em;
  background: rgba(127, 127, 127, 0.15);
  border: 1px solid rgba(127, 127, 127, 0.25);
  border-radius: 6px;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  color: var(--text);
  line-height: 1.4;
}

/* 代码块 */
.msg-bubble .md-code-block {
  position: relative;
  margin: 0.8em 0;
  padding: 14px 16px 14px 16px;
  background: #111216;
  color: #e7e9ee;
  border-radius: 12px;
  border: 1px solid rgba(127, 127, 127, 0.2);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  white-space: pre;
}
.msg-bubble .md-code-block code {
  display: block;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  border: none;
}
.msg-bubble .md-code-block::before {
  content: "";
  display: block;
  height: 8px;
  margin-bottom: 8px;
  background:
    radial-gradient(circle at 4px 4px, #ff5f56 3px, transparent 3.5px),
    radial-gradient(circle at 20px 4px, #ffbd2e 3px, transparent 3.5px),
    radial-gradient(circle at 36px 4px, #27c93f 3px, transparent 3.5px);
  background-repeat: no-repeat;
}

/* 表格 */
.msg-bubble .md-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
  font-size: 0.92em;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}
.msg-bubble .md-table th,
.msg-bubble .md-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.msg-bubble .md-table th {
  background: rgba(127, 127, 127, 0.1);
  font-weight: 600;
}
.msg-bubble .md-table tr:last-child td { border-bottom: none; }

/* 浅色模式下代码块也保持深色风格（更易读） */
body:not(.dark-mode) .msg-bubble .md-code-block {
  background: #0f1115;
  color: #e7e9ee;
  border-color: rgba(0, 0, 0, 0.15);
}

/* ---------- 消息操作栏（底部徽章 + 按钮） ---------- */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 4px 0;
  align-self: stretch;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.msg-ai:hover .msg-actions,
.msg-user:hover .msg-actions {
  opacity: 1;
  transform: translateY(0);
}
.msg-ai.msg-typing .msg-actions { display: none; }

.msg-powered {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.powered-gradient {
  background: var(--gradient-bg);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
  font-weight: 700;
}

.msg-action-btns {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  margin-left: auto;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
}
.msg-action-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}
.msg-action-btn svg {
  width: 15px;
  height: 15px;
}
.msg-action-btn:hover {
  background: var(--glass-bg-strong);
  color: var(--text);
}
.msg-action-btn.active[data-action="like"] {
  color: var(--primary);
}
.msg-action-btn.active[data-action="like"] svg {
  fill: var(--primary);
  stroke: var(--primary);
}
.msg-action-btn.active[data-action="dislike"] {
  color: var(--accent-pink);
}

@media (max-width: 768px) {
  .msg-actions {
    opacity: 1;
    transform: none;
  }
}
