* {
  box-sizing: border-box;
}

:root {
  --bg-color: #f7f8fa;
  --text-color: #1a1a1a;
  --header-bg: rgba(255, 255, 255, 0.05); /* 更透明 */
  --glass-border: rgba(255, 255, 255, 0.8); /* 白天改为80%的白色边框 */
  --shadow-color: rgba(0, 0, 0, 0.05);
  --sidebar-bg: rgba(248, 249, 250, 0.65);
  --session-item-bg: rgba(255, 255, 255, 0.5);
  --session-item-hover: rgba(255, 255, 255, 0.8);
  --session-active-border: rgba(102, 187, 106, 0.5);
  --session-active-bg: rgba(232, 245, 233, 0.7);
  --session-active-text: #1b5e20;
  --msg-user-bg: rgba(232, 245, 233, 0.75);
  --msg-user-text: #1b5e20;
  --msg-assistant-bg: rgba(243, 244, 246, 0.65);
  --msg-assistant-text: #333;
  --hint-bg: #fff8e6;
  --hint-border: #ffeaa7;
  --hint-text: #7d5a00;
  --error-bg: #ffebee;
  --error-border: #ffcdd2;
  --error-text: #b71c1c;
  --input-bg: rgba(255, 255, 255, 0.3);
  --input-focus: rgba(255, 255, 255, 0.6);
  --icon-btn-hover: rgba(0, 0, 0, 0.05);
  --tag-bg: rgba(0, 0, 0, 0.05);
  --tag-active-bg: #e8f5e9;
  --tag-active-text: #2e7d32;
  --send-btn-bg: rgba(76, 175, 80, 0.95);
  --send-btn-hover: rgba(67, 160, 71, 1);
  --send-btn-shadow: rgba(76, 175, 80, 0.4);
  --send-btn-hover-shadow: rgba(67, 160, 71, 0.5);
}

body.dark {
  --bg-color: #0d1b2a; /* 夜间模式改为午夜蓝背景 */
  --text-color: #e0e0e0;
  --header-bg: rgba(13, 27, 42, 0.2); /* 适应午夜蓝的毛玻璃 */
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --sidebar-bg: rgba(13, 27, 42, 0.75);
  --session-item-bg: rgba(255, 255, 255, 0.05);
  --session-item-hover: rgba(255, 255, 255, 0.1);
  --session-active-border: rgba(102, 187, 106, 0.3);
  --session-active-bg: rgba(27, 94, 32, 0.4);
  --session-active-text: #81c784;
  --msg-user-bg: rgba(27, 94, 32, 0.6);
  --msg-user-text: #e8f5e9;
  --msg-assistant-bg: rgba(18, 30, 50, 0.55);
  --msg-assistant-text: #e0e0e0;
  --hint-bg: rgba(255, 248, 230, 0.1);
  --hint-border: rgba(255, 234, 167, 0.2);
  --hint-text: #ffeaa7;
  --error-bg: rgba(255, 235, 238, 0.1);
  --error-border: rgba(255, 205, 210, 0.2);
  --error-text: #ffcdd2;
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-focus: rgba(255, 255, 255, 0.1);
  --icon-btn-hover: rgba(255, 255, 255, 0.1);
  --tag-bg: rgba(255, 255, 255, 0.1);
  --tag-active-bg: rgba(27, 94, 32, 0.6);
  --tag-active-text: #81c784;
  --send-btn-bg: rgba(67, 160, 71, 0.95);
  --send-btn-hover: rgba(56, 142, 60, 1);
  --send-btn-shadow: rgba(67, 160, 71, 0.4);
  --send-btn-hover-shadow: rgba(56, 142, 60, 0.5);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-color); /* 主背景 */
  color: var(--text-color);
  height: 100vh;
  /* 适配移动端 100vh 问题，使用支持的动态视口高度 */
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 禁止移动端点击高亮 */
  -webkit-tap-highlight-color: transparent;
  /* 彻底禁止 iOS 上的双指缩放和双击缩放 */
  touch-action: pan-x pan-y;
}

.appContainer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  z-index: 2;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: -5px 0 20px rgba(0,0,0,0.1);
}

.appContainer.drawer-open {
  transform: translateX(250px);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100%;
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border);
  z-index: 1;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  display: flex;
  flex-direction: column;
}
.sidebarHeader {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
}
.sidebarTags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sidebarTag {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 12px;
  background: var(--tag-bg);
  cursor: pointer;
  color: var(--text-color);
}
.sidebarTag.active {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
}
.sessionList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sessionItem {
  padding: 0.75rem;
  background: var(--session-item-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  font-size: 0.9rem;
  color: var(--text-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s, box-shadow 0.2s;
}
.sessionText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.sessionDelBtn {
  margin-left: 0.5rem;
  color: #999;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 4px;
}
.sessionDelBtn:hover {
  color: #d32f2f;
}
.sessionItem:hover {
  background: var(--session-item-hover);
  box-shadow: 0 2px 10px var(--shadow-color);
}
.sidebarSettings {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sidebarSettingRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-color);
}
.iosSwitch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.iosSwitch input { opacity: 0; width: 0; height: 0; }
.iosSwitchSlider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.3s;
}
.iosSwitchSlider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.iosSwitch input:checked + .iosSwitchSlider {
  background: #2e7d32;
}
.iosSwitch input:checked + .iosSwitchSlider::before {
  transform: translateX(20px);
}
.sidebarThemeBtn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--session-item-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.sidebarThemeBtn:hover {
  background: var(--session-item-hover);
}
.sidebarThemeBtn .sidebarSunIcon { display: block; }
.sidebarThemeBtn .sidebarMoonIcon { display: none; }
body.dark .sidebarThemeBtn .sidebarSunIcon { display: none; }
body.dark .sidebarThemeBtn .sidebarMoonIcon { display: block; }

.sessionItem.active {
  border-color: var(--session-active-border);
  background: var(--session-active-bg);
  color: var(--session-active-text);
}

.header {
  /* 悬浮固定在顶部 */
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 56rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* 适配刘海屏顶部安全区，稍窄一点 */
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem 0.5rem;
  background: var(--header-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 30px var(--shadow-color);
  z-index: 100;
  height: calc(3.5rem + env(safe-area-inset-top));
}

.header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
}

.iconBtn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.8;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, opacity 0.2s;
}
.iconBtn:hover {
  background: var(--icon-btn-hover);
  opacity: 1;
}

.main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 56rem;
  margin: 0 auto;
  width: 100%;
  padding: calc(3.5rem + env(safe-area-inset-top)) 0 0 0; /* 移除左右 padding，让滚动条贴边 */
}

.hint {
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.5;
  background: var(--hint-bg);
  border: 1px solid var(--hint-border);
  color: var(--hint-text);
}

.hint.hidden {
  display: none;
}

.hint.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* 增加底部 padding，防止被巨大的透明表单（尤其是大麦克风）遮挡最新消息 */
  padding: 1rem 1rem 14rem 1rem; /* 把左右 padding 加到滚动容器内部 */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 自定义滚动条，使其变细且不突兀，避免遮挡内容 */
.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  align-self: flex-start;
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant {
  max-width: 100%;
  align-self: stretch;
}

.msg.assistant .msgBubble {
  text-align: left;
}

.msgBubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 1.0625rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 15px var(--shadow-color);
}

.msg.user .msgBubble {
  background: var(--msg-user-bg);
  color: var(--msg-user-text);
  border-bottom-right-radius: 4px;
  border: 1px solid var(--glass-border);
}

.msg.assistant .msgBubble {
  background: var(--msg-assistant-bg);
  color: var(--msg-assistant-text);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  white-space: normal;
}

.msg.assistant .msgBubble p { margin: 0 0 0.5em; }
.msg.assistant .msgBubble p:last-child { margin-bottom: 0; }
.msg.assistant .msgBubble h1, .msg.assistant .msgBubble h2, .msg.assistant .msgBubble h3,
.msg.assistant .msgBubble h4, .msg.assistant .msgBubble h5, .msg.assistant .msgBubble h6 {
  margin: 0.75em 0 0.35em;
  font-weight: 600;
  line-height: 1.3;
}
.msg.assistant .msgBubble h1:first-child, .msg.assistant .msgBubble h2:first-child,
.msg.assistant .msgBubble h3:first-child, .msg.assistant .msgBubble h4:first-child,
.msg.assistant .msgBubble h5:first-child, .msg.assistant .msgBubble h6:first-child { margin-top: 0; }
.msg.assistant .msgBubble h1 { font-size: 1.25em; }
.msg.assistant .msgBubble h2 { font-size: 1.15em; }
.msg.assistant .msgBubble h3 { font-size: 1.05em; }
.msg.assistant .msgBubble pre {
  margin: 0.5em 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: #f5f5f5;
  border: 1px solid #e8eaed;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875em;
}
.msg.assistant .msgBubble code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: #f0f0f0;
  font-size: 0.9em;
}
.msg.assistant .msgBubble pre code { padding: 0; background: none; }
.msg.assistant .msgBubble ul, .msg.assistant .msgBubble ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}
.msg.assistant .msgBubble li { margin: 0.2em 0; }
.msg.assistant .msgBubble blockquote {
  margin: 0.5em 0;
  padding-left: 1em;
  border-left: 3px solid #c8e6c9;
  color: #555;
}
.msg.assistant .msgBubble hr { margin: 0.75em 0; border: none; border-top: 1px solid #e8eaed; }
.msg.assistant .msgBubble a { color: #2e7d32; text-decoration: none; }
.msg.assistant .msgBubble a:hover { text-decoration: underline; }
.msg.assistant .msgBubble img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5em 0;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.msg.assistant .msgBubble video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5em 0;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background: #000;
}
.msg.assistant .msgBubble audio {
  max-width: 100%;
  margin: 0.5em 0;
  display: block;
}

.msgActions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}
.msgActionBtn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s;
  padding: 0;
}
.msgActionBtn:hover {
  opacity: 1;
  background: var(--session-item-hover);
}
.msgActionBtn.copied {
  color: #2e7d32;
  opacity: 1;
}

.tts-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s;
  padding: 0;
}
.tts-icon:hover {
  opacity: 1;
  background: var(--session-item-hover);
}

.tts-icon.playing {
  opacity: 1;
  color: #2e7d32;
  animation: pulse 1.5s infinite;
}
body.dark .tts-icon.playing {
  color: #81c784;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

.code-block-wrap {
  position: relative;
}
.codeCopyBtn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s;
  z-index: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.codeCopyBtn:hover {
  opacity: 1;
}
.codeCopyBtn.copied {
  color: #2e7d32;
  border-color: #81c784;
}

.scrollToBottomBtn {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px var(--shadow-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.scrollToBottomBtn:hover {
  opacity: 1;
  transform: translateX(-50%) scale(1.1);
}
.scrollToBottomBtn.hidden {
  display: none;
}

.msg.placeholder .msgBubble {
  opacity: 0.6;
  font-style: italic;
}
.phRobot {
  font-style: normal;
  margin-right: 0.3em;
}

.msg.error .msgBubble {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.msg.loading {
  align-self: flex-start;
  max-width: none;
}

.msg.loading .msgBubble.loadingDots {
  padding: 0.85rem 0.5rem;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.msg.loading .msgBubble.loadingDots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  animation: breathDot 1.4s ease-in-out infinite;
}

@keyframes breathDot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.form {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  z-index: 100;
  background: transparent;
  pointer-events: none; /* 让外层透明区域不阻挡点击事件 */
  border-top: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.asrRemaining {
  text-align: center;
  font-size: 0.85rem;
  color: #e65100;
  background: rgba(255, 243, 224, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 0.35rem 0.8rem;
  margin-bottom: 0.3rem;
  pointer-events: none;
  align-self: center;
  animation: asrWarn 0.6s ease-in-out infinite alternate;
}
body.dark .asrRemaining {
  background: rgba(230, 81, 0, 0.2);
  color: #ffb74d;
}
@keyframes asrWarn {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

.expandBtn {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--input-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
  padding: 0;
  z-index: 3;
}
.expandBtn:hover { opacity: 1; }
.expandBtn.hidden { display: none; }

.form.inputExpanded .inputWrapper {
  border-radius: 16px;
}
.form.inputExpanded .input {
  min-height: 60vh;
  max-height: 75vh;
  border-radius: 16px;
  overflow-y: auto;
}

.imgPreviewArea {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: var(--header-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 -2px 20px var(--shadow-color);
  pointer-events: auto;
}
.imgPreviewArea.hidden {
  display: none;
}

.imgPreviewList {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  pointer-events: auto;
}
.imgPreviewItem {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e8eaed;
}
.imgPreviewItem img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.imgPreviewItem .removeImg {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border: none;
  padding: 0;
  line-height: 1;
}
.uploadBtn {
  padding: 0.6rem;
  background: rgba(232, 245, 233, 0.75); /* 半透明浅绿 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #2e7d32;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 10px rgba(46, 125, 50, 0.1);
}
.uploadBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.formInputRow {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0;
  pointer-events: none; /* 让点击穿透，给子元素响应 */
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* 兼容iOS 26: 让内部可点击元素恢复事件 */
.formInputRow > * {
  pointer-events: auto;
}

.formIconBtn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 24px; /* Change from 50% to 24px to match capsule shape if desired, or keep 50% */
  background: var(--input-bg);
  color: var(--text-color);
  opacity: 0.8;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px var(--shadow-color);
  pointer-events: auto;
}
.formIconBtn:hover {
  background: rgba(0,0,0,0.05);
  opacity: 1;
}
body.dark .formIconBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.inputWrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  background: var(--input-bg);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: border-color 0.2s;
  box-shadow: 0 4px 15px var(--shadow-color);
  pointer-events: auto;
}
.inputWrapper:focus-within {
  background: var(--input-focus);
  border-color: #81c784;
}

.input {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  padding: 10px 88px 11px 1.2rem;
  border: none;
  border-radius: 24px;
  font-size: 18px;
  font-family: inherit;
  resize: none;
  background: transparent;
  color: var(--text-color);
  overflow-y: hidden;
  line-height: 1.5;
}
.input:focus {
  outline: none;
}

.voiceBtnInner {
  position: absolute;
  right: 44px;
  bottom: 5px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-color);
  opacity: 0.5;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 2;
}
.voiceBtnInner:hover {
  opacity: 1;
  background: var(--icon-btn-hover);
}
.voiceBtnInner.listening {
  background: #ffebee;
  color: #c62828;
  opacity: 1;
  animation: voicePulseSmall 1.2s infinite;
}

.formIconBtn.listening {
  background: #ffebee;
  color: #c62828;
  animation: voicePulseSmall 1.2s infinite;
}

@keyframes voicePulseSmall {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(198, 40, 40, 0); }
}

.sendBtn {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  z-index: 3;
  font-size: 0;
  background: var(--send-btn-bg);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sendBtn:hover:not(:disabled) {
  background: var(--send-btn-hover);
}

.sendBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.sendBtn[data-state="sending"] {
  background: #c62828;
}
.sendBtn[data-state="sending"]:hover {
  background: #b71c1c;
}

/* 移动端媒体查询优化 */
@media (max-width: 768px) {
  .header {
    padding: max(0.6rem, env(safe-area-inset-top)) 1rem 0.6rem;
  }
  
  .header h1 {
    font-size: 1.05rem;
  }
  
  .form {
    padding: 0 1rem calc(0.5rem + env(safe-area-inset-bottom)) 1rem;
    background: transparent;
    border-top: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }
  
  .msg {
    max-width: 92%; /* 移动端让气泡更宽，利用屏幕空间 */
  }
  
  .formInputRow {
    gap: 0.4rem;
    align-items: flex-end;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0.5rem 0;
    pointer-events: none;
  }
  
  .formInputRow > * {
    pointer-events: auto;
  }
  
  .inputWrapper {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 24px;
    box-shadow: 0 4px 15px var(--shadow-color);
    pointer-events: auto;
  }
  
  .input {
    min-height: 44px;
    padding: 10px 80px 10px 1rem;
    font-size: 16px;
  }
  .voiceBtnInner {
    width: 32px;
    height: 32px;
    right: 38px;
    bottom: 6px;
  }
  
  .formIconBtn {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 4px 15px var(--shadow-color);
    pointer-events: auto;
  }
  .formIconBtn svg {
    width: 24px;
    height: 24px;
  }
  
  .sendBtn {
    width: 32px;
    height: 32px;
    right: 5px;
    bottom: 6px;
  }
  
  .messages {
    padding-bottom: 8rem;
  }

  .msg.assistant {
    max-width: 100%;
  }
}

/* 麦克风按钮隐藏 */
.voiceBtnInner.voiceHidden {
  display: none;
}

/* ---- 全屏弹层输入 ---- */
.overlayInput {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 25%;
  z-index: 300;
  background: var(--bg-color);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  animation: overlaySlideUp 0.3s ease-out;
}

@keyframes overlaySlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.overlayInputHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.overlayInputHeader span {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-color);
}

.overlayCloseBtn {
  background: none;
  border: none;
  color: var(--text-color);
  opacity: 0.6;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlayCloseBtn:hover { opacity: 1; }

.overlayInputBody {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  min-height: 0;
  position: relative;
}

.overlayTextarea {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  resize: none;
  outline: none;
  padding: 0;
}

.overlayVoiceBtn {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--input-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.overlayVoiceBtn:hover { opacity: 1; }
.overlayVoiceBtn.listening {
  background: #ffebee;
  color: #c62828;
  opacity: 1;
  animation: voicePulseSmall 1.2s infinite;
}

.overlaySendBtn {
  position: absolute;
  right: 4.5rem;
  bottom: 1rem;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--send-btn-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.overlaySendBtn:hover { background: var(--send-btn-hover); }

.overlayBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 299;
  animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
