:root {
  --ink: #1c1c1c;
  --muted: #5a5f67;
  --paper: #f6f2ec;
  --panel: #ffffff;
  --accent: #1d6d6f;
  --accent-soft: #cfe4e1;
  --gold: #b08d57;
  --shadow: 0 20px 60px rgba(27, 34, 41, 0.12);
  --radius: 18px;
  --border: rgba(29, 109, 111, 0.14);
  --gradient: linear-gradient(140deg, rgba(29, 109, 111, 0.12), rgba(176, 141, 87, 0.14));
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top left, #f1e8dc 0%, #f6f2ec 48%, #f3f5f7 100%);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
  overflow-x: hidden; /* 防止任何子元素横向溢出 */
  max-width: 100vw;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  touch-action: manipulation; /* 防止双击缩放 */
  -webkit-text-size-adjust: 100%; /* 防止 iOS 自动调整字体大小 */
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    radial-gradient(circle, rgba(0, 0, 0, 0.1) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(0, 0, 0, 0.06) 0.5px, transparent 0.5px);
  background-size: 14px 14px, 22px 22px;
  background-position: 0 0, 5px 5px;
  mix-blend-mode: multiply;
  z-index: -1;
}

.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(246, 242, 236, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--gradient);
  color: var(--accent);
  box-shadow: 0 12px 30px rgba(29, 109, 111, 0.15);
  flex-shrink: 0;
}

.logo-mark i {
  font-size: 1.2rem;
}

/* Logo 图片样式 */
.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  display: block;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px; /* 最小触控区域 */
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(29, 109, 111, 0.2);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(29, 109, 111, 0.26);
}

.btn.is-pressed {
  transform: scale(0.97);
  box-shadow: none;
}

.hamburger {
  border: none;
  background: transparent;
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  cursor: pointer;
}

.bar {
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 4px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(25, 30, 33, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 998;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.mobile-sidebar {
  position: fixed;
  top: var(--navbar-h, 72px);
  left: -320px;
  width: min(300px, 85vw);
  max-width: 300px;
  /* 高度兼容：vh 作为兜底，dvh 解决移动端地址栏伸缩导致底部被遮挡的问题 */
  height: calc(100vh - var(--navbar-h, 72px));
  height: calc(100dvh - var(--navbar-h, 72px));
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 999;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* 更流畅的缓动曲线 */
  overflow-y: auto;
  overscroll-behavior: contain; /* 防止滚动穿透 */
  -webkit-overflow-scrolling: touch;
  /* 底部留出安全区 + 额外空间，避免最后一项被底部手势栏遮住 */
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
}

.mobile-sidebar .sidebar-menu,
.mobile-sidebar .sidebar-section {
  padding: 0 16px 16px;
}

.mobile-sidebar .sidebar-section {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* ============ 移动端侧边栏紧凑化优化 ============ */

/* 分组标题：统一使用左侧色块 + 渐变背景 + 加粗字体（覆盖所有三个分组） */
.mobile-sidebar .sidebar-header {
  padding: 10px 12px 10px 14px;
  margin: 14px 16px 8px;
  background: linear-gradient(90deg, rgba(29, 109, 111, 0.18), rgba(29, 109, 111, 0.06));
  border-left: 3px solid var(--accent);
  border-bottom: none;
  border-radius: 8px;
}

/* .sidebar-section 内部 header 不要重复外边距 */
.mobile-sidebar .sidebar-section .sidebar-header {
  margin: 0 0 8px;
}

.mobile-sidebar .sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* 菜单项紧凑化：从 12/14px 内边距 → 10/12px；gap 从 10px → 6px */
.mobile-sidebar .sidebar-menu,
.mobile-sidebar .hot-topics {
  gap: 6px;
  padding-top: 4px;
}

.mobile-sidebar .menu-item,
.mobile-sidebar .topic-item {
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 0.92rem;
  gap: 10px;
}

.mobile-sidebar .menu-item i,
.mobile-sidebar .topic-item i {
  font-size: 0.95rem;
  width: 16px;
}

/* 中小学生专区：从卡片风格改为与菜单项一致的列表项风格 */
.mobile-sidebar .special-topics {
  gap: 6px;
}

.mobile-sidebar .topic-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 44px;
  background: rgba(29, 109, 111, 0.06);
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: none;
  font-size: 0.92rem;
}

.mobile-sidebar .topic-card:hover {
  background: rgba(29, 109, 111, 0.12);
  border-color: rgba(29, 109, 111, 0.4);
  transform: none;
  box-shadow: none;
}

.mobile-sidebar .topic-card i {
  font-size: 0.95rem;
  width: 16px;
  color: var(--accent);
}

.mobile-sidebar .topic-card h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
}

/* 卡片里的描述文字在紧凑列表中隐藏，避免占用空间 */
.mobile-sidebar .topic-card p {
  display: none;
}

.mobile-sidebar.active {
  left: 0;
}

.main-container {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 18px;
  padding: 18px;
  margin-top: 78px;
  height: calc(100vh - 78px - 60px);
  overflow: hidden;
}

.left-sidebar,
.right-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.sidebar-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 1.05rem;
}

.sidebar-menu,
.hot-topics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.menu-item,
.topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: 44px; /* 最小触控区域 */
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(29, 109, 111, 0.06);
  color: var(--ink);
}

.menu-item:hover,
.topic-item:hover,
.menu-item.active {
  border-color: rgba(29, 109, 111, 0.4);
  background: rgba(29, 109, 111, 0.12);
  transform: translateY(-1px);
}

.menu-item i,
.topic-item i {
  color: var(--accent);
  width: 18px;
  text-align: center;
}

.sidebar-section {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.special-topics {
  display: grid;
  gap: 12px;
}

.topic-card {
  background: var(--gradient);
  color: var(--ink);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(176, 141, 87, 0.2);
  box-shadow: 0 18px 36px rgba(27, 34, 41, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topic-card h4 {
  margin: 10px 0 6px;
  font-size: 1rem;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.topic-card i {
  font-size: 1.4rem;
  color: var(--accent);
}

.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 40px rgba(27, 34, 41, 0.16);
}

.teacher-topic {
  background: rgba(29, 109, 111, 0.08);
}

.main-content {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  overflow: hidden;
}

.intro-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  padding: 18px;
  border-radius: 16px;
  background: var(--gradient);
  border: 1px solid rgba(29, 109, 111, 0.18);
}

.intro-card h1 {
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: clamp(1.6rem, 1.2rem + 1vw, 2.2rem);
  margin-bottom: 8px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 2.4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  font-size: 0.98rem;
}

.intro-meta {
  display: grid;
  gap: 12px;
}

.metric {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(29, 109, 111, 0.18);
}

.metric__label {
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.metric__value {
  font-size: 1rem;
  font-weight: 600;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  border-radius: 16px;
  background: #f9f7f3;
  border: 1px solid rgba(29, 109, 111, 0.12);
  overscroll-behavior: contain; /* 防止滚动穿透到页面 */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(29, 109, 111, 0.4);
  border-radius: 6px;
}

/* 统一全站滚动条样式：侧边栏、容器等 */
.mobile-sidebar::-webkit-scrollbar,
.left-sidebar::-webkit-scrollbar,
.right-sidebar::-webkit-scrollbar {
  width: 6px;
}

.mobile-sidebar::-webkit-scrollbar-track,
.left-sidebar::-webkit-scrollbar-track,
.right-sidebar::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.mobile-sidebar::-webkit-scrollbar-thumb,
.left-sidebar::-webkit-scrollbar-thumb,
.right-sidebar::-webkit-scrollbar-thumb {
  background: rgba(29, 109, 111, 0.4);
  border-radius: 6px;
}

/* Firefox 滚动条样式 */
.mobile-sidebar,
.left-sidebar,
.right-sidebar,
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 109, 111, 0.4) transparent;
}

.welcome-message,
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  animation: fadeInUp 0.4s ease;
}

/* AI 消息从左侧滑入 */
.message:not(.user-message) {
  animation: fadeInLeft 0.4s ease;
}

/* 用户消息从右侧滑入 */
.user-message {
  flex-direction: row-reverse;
  animation: fadeInRight 0.4s ease;
}

.bot-avatar,
.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.bot-avatar {
  background: rgba(29, 109, 111, 0.12);
  color: var(--accent);
  border: 1px solid rgba(29, 109, 111, 0.4);
}

.user-avatar {
  background: var(--accent);
  color: #ffffff;
}

.message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(29, 109, 111, 0.16);
  box-shadow: 0 12px 30px rgba(27, 34, 41, 0.08);
  word-break: break-word;
}

.user-message .message-content {
  background: rgba(29, 109, 111, 0.12);
  border-color: rgba(29, 109, 111, 0.3);
}

.default-questions {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(29, 109, 111, 0.18);
  background: rgba(29, 109, 111, 0.06);
}

.default-questions h3 {
  color: var(--accent);
  margin-bottom: 12px;
  font-size: 1rem;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.question-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  min-height: 44px; /* 触控最小区域 */
  border: 1px solid rgba(29, 109, 111, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: fadeInScale 0.4s ease backwards;
}

/* 错开问题卡片动画 */
.question-card:nth-child(1) { animation-delay: 0.05s; }
.question-card:nth-child(2) { animation-delay: 0.1s; }
.question-card:nth-child(3) { animation-delay: 0.15s; }
.question-card:nth-child(4) { animation-delay: 0.2s; }

.question-card i {
  color: var(--accent);
}

.question-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(27, 34, 41, 0.12);
}

.default-questions.hidden {
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.4s ease;
  pointer-events: none;
}

.chat-input-container {
  margin-top: 12px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(29, 109, 111, 0.18);
  padding: 12px;
  box-shadow: 0 12px 30px rgba(27, 34, 41, 0.1);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 109, 111, 0.06);
  border-radius: 999px;
  padding: 6px 8px;
  border: 1px solid transparent;
  transition: border 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: rgba(29, 109, 111, 0.4);
}

#messageInput {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 16px; /* 16px 防止 iOS Safari 自动缩放 */
  outline: none;
  color: var(--ink);
}

#messageInput::placeholder {
  color: var(--muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0; /* 防止被输入框挤压 */
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(29, 109, 111, 0.2);
}

/* 麦克风按钮 */
.mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mic-btn:hover {
  color: var(--accent);
  background: rgba(29, 109, 111, 0.08);
}

/* 录音中：红色脉冲动画 */
.mic-btn.recording {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.1);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4); transform: scale(1); }
  50%       { box-shadow: 0 0 0 8px rgba(229, 62, 62, 0);  transform: scale(1.08); }
}

/* 小屏下同步缩小 */
@media (max-width: 480px) {
  .mic-btn {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
  }
}
@media (max-width: 360px) {
  .mic-btn {
    width: 38px;
    height: 38px;
  }
}

/* 发送按钮点击波纹效果 */
.send-btn:active {
  transform: scale(0.9);
  box-shadow: 0 4px 12px rgba(29, 109, 111, 0.3);
}

/* 发送中旋转动画 */
.send-btn.sending {
  pointer-events: none;
  animation: sendPulse 0.6s ease;
}

.send-btn.sending i {
  animation: sendFly 0.6s ease forwards;
}

@keyframes sendPulse {
  0% { transform: scale(1); }
  30% { transform: scale(0.85); background: var(--gold); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); background: var(--accent); }
}

@keyframes sendFly {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  50% { transform: translate(6px, -6px) rotate(15deg); opacity: 0.4; }
  100% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
}

.input-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  padding: 18px 0;
  background: rgba(29, 109, 111, 0.92);
  color: #ffffff;
  text-align: center;
  z-index: 100;
}

.footer-content p {
  font-size: 0.85rem;
  opacity: 0.92;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 10px 0;
  color: var(--accent);
  font-weight: 600;
}

.message-content p {
  margin: 8px 0;
}

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 18px;
}

.message-content code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  background: rgba(29, 109, 111, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

.message-content pre {
  background: #111a1f;
  color: #e6edf3;
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
}

.message-content a {
  color: var(--accent);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* AI 消息从左侧滑入 */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 用户消息从右侧滑入 */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 问题卡片渐入 */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 1200px) {
  .main-container {
    grid-template-columns: 200px 1fr 240px;
  }
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    height: calc(100vh - 78px - 60px);
    padding: 12px;
    overflow: hidden; /* é˜²æ­¢å®¹å™¨æ•´ä½“æ»šåŠ¨ */
  }

  .main-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* å…³é”®ï¼šè®©ä¸»å†…å®¹åŒºåŸŸä¹Ÿä¸æ»šåŠ¨ */
  }

  .intro-card {
    flex-shrink: 0; /* é˜²æ­¢ä»‹ç»å¡ç‰‡è¢«åŽ‹ç¼© */
  }

  .chat-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-messages {
    flex: 1;
    overflow-y: auto; /* åªæœ‰è¿™é‡Œå¯ä»¥æ»šåŠ¨ */
    -webkit-overflow-scrolling: touch;
  }

  .chat-input-container {
    flex-shrink: 0; /* å›ºå®šè¾“å…¥æ¡† */
    margin-bottom: env(safe-area-inset-bottom, 0);
  }

  .left-sidebar,
  .right-sidebar {
    display: none;
  }

  .hamburger {
    display: flex;
  }
}

@media (max-width: 768px) {
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  .main-container {
    height: calc(100vh - 72px - 50px);
    margin-top: 72px;
  }

  .nav-container {
    padding: 12px 16px;
  }

  .logo-subtitle {
    display: none;
  }

  .main-content {
    padding: 14px;
    border-radius: 12px;
  }

  .intro-card {
    padding: 14px;
  }

  .question-grid {
    grid-template-columns: 1fr;
  }

  .footer {
    display: none;
  }

  .chat-input-container {
    padding: 10px;
  }

  .mobile-sidebar {
    top: var(--navbar-h, 72px);
    height: calc(100vh - var(--navbar-h, 72px));
    height: calc(100dvh - var(--navbar-h, 72px));
  }

  /* 移动端消息气泡加宽、字体优化 */
  .message-content {
    max-width: 82%;
    font-size: 15px;
    line-height: 1.65;
  }
}

/* 键盘弹起时的样式调整 */
body.keyboard-open .main-container {
  height: calc(var(--vh, 100vh) - 72px);
  transition: height 0.15s ease;
}

body.keyboard-open .intro-card {
  display: none;
}

body.keyboard-open .chat-container {
  flex: 1;
}

@media (max-width: 480px) {
  .nav-container {
    padding: 10px 12px;
    gap: 10px;
  }

  .logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .logo-title {
    font-size: 1rem;
  }

  .btn--primary span {
    display: none;
  }

  .btn--primary {
    padding: 8px 12px;
  }

  .main-container {
    padding: 10px;
  }

  .main-content {
    padding: 12px;
    border-radius: 12px;
  }

  .chat-messages {
    padding: 12px;
  }

  .welcome-message,
  .message {
    gap: 8px;
    margin-bottom: 12px;
  }

  .bot-avatar,
  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .message-content {
    max-width: calc(100% - 48px);
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.6;
    border-radius: 14px;
  }

  .intro-card h1 {
    font-size: 1.4rem;
  }

  .default-questions {
    padding: 12px;
  }

  .default-questions h3 {
    font-size: 0.95rem;
  }

  .question-card {
    padding: 10px;
    font-size: 0.88rem;
  }

  .chat-input-container {
    padding: 8px;
    border-radius: 14px;
  }

  .input-wrapper {
    padding: 4px 6px;
  }

  #messageInput {
    padding: 8px 10px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
  }

  .input-hint {
    font-size: 0.76rem;
    margin-top: 6px;
  }
}

/* 极小屏幕（iPhone SE 一代 / 折叠屏外屏 等 ≤360px）*/
@media (max-width: 360px) {
  .nav-container {
    padding: 8px 10px;
    gap: 8px;
  }

  .logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .logo-title {
    font-size: 0.95rem;
  }

  .main-container {
    padding: 8px;
  }

  .main-content {
    padding: 10px;
  }

  .chat-messages {
    padding: 10px;
  }

  .bot-avatar,
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .message-content {
    max-width: calc(100% - 44px);
    padding: 8px 10px;
    font-size: 13.5px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }
}
