/* 重置样式 */
*, ::before, ::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e5e7eb;
}

::before, ::after {
  --tw-content: '';
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  font-family: Inter, system-ui, sans-serif;
  font-feature-settings: normal;
  font-variation-settings: normal;
}

body {
  margin: 0;
  line-height: inherit;
}

hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

abbr:where([title]) {
  -webkit-text-decoration: underline dotted;
  text-decoration: underline dotted;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

a {
  color: inherit;
  text-decoration: inherit;
}

b, strong {
  font-weight: bolder;
}

code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1em;
}

small {
  font-size: 80%;
}

sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}

button, input, optgroup, select, textarea {
  font-family: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

button, select {
  text-transform: none;
}

[type='button'], [type='reset'], [type='submit'], button {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}

:-moz-focusring {
  outline: auto;
}

:-moz-ui-invalid {
  box-shadow: none;
}

progress {
  vertical-align: baseline;
}

::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
  height: auto;
}

[type='search'] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

::-webkit-search-decoration {
  -webkit-appearance: none;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

summary {
  display: list-item;
}

blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

ol, ul, menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

dialog {
  padding: 0;
}

textarea {
  resize: vertical;
  /* 核心修复1：textarea 基础样式，防止变短 */
  width: 100% !important;
  min-width: 200px !important; /* 最小宽度，防止挤压 */
  min-height: 80px !important; /* 最小高度，兜底 */
  box-sizing: border-box !important; /* 盒模型，padding不占额外宽度 */
}

input::placeholder, textarea::placeholder {
  opacity: 1;
  color: #9ca3af;
}

button, [role="button"] {
  cursor: pointer;
}

:disabled {
  cursor: default;
}

audio, canvas, embed, iframe, img, object, svg, video {
  display: block;
  vertical-align: middle;
}

img, video {
  max-width: 100%;
  height: auto;
}

[hidden] {
  display: none;
}

/* 核心工具类（适配你的自定义主题） */
.bg-secondary {
  background-color: #F5F7FA;
}

.bg-primary {
  background-color: #165DFF;
}

.bg-white {
  background-color: #FFFFFF;
}

.bg-user {
  background-color: #FFFFFF;
}

.bg-assistant {
  background-color: #E8F3FF;
}

.border-border {
  border-color: #E5E7EB;
}

.text-text {
  color: #333333;
}

.text-lightText {
  color: #666666;
}

.text-red-500 {
  color: #ef4444;
}

.text-white {
  color: #FFFFFF;
}

.min-h-screen {
  min-height: 100vh;
}

.font-sans {
  font-family: Inter, system-ui, sans-serif;
}

.antialiased {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.sticky {
  position: sticky;
}

.top-0 {
  top: 0px;
}

.z-50 {
  z-index: 50;
}

.border-b {
  border-bottom-width: 1px;
}

.shadow-sm {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: 1rem;
  padding-left: 1rem;
}

@media (min-width: 640px) {
  .container {
    max-width: 640px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-6 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-1 {
  gap: 0.25rem;
}

.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.text-xl {
  font-size: 1.25rem;
  line-height: 1.75rem;
}

.text-sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.text-xs {
  font-size: 0.75rem;
  line-height: 1rem;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.font-semibold {
  font-weight: 600;
}

.hover\:text-primary:hover {
  color: #165DFF;
}

.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

.px-2 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.rounded-md {
  border-radius: 0.375rem;
}

.hover\:bg-secondary:hover {
  background-color: #F5F7FA;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-6 {
  gap: 1.5rem;
}

.mb-24 {
  margin-bottom: 6rem;
}

.pb-4 {
  padding-bottom: 1rem;
}

.overflow-y-auto {
  overflow-y: auto;
}

/* 核心修复2：修复响应式高度 calc 表达式（原被转义） */
.h-\[calc<span data-type="inline-math" data-value="MTAwdmgtMjIwcHg="></span>\] {
  height: calc(100vh - 220px);
}

@media (min-width: 360px) {
  .xs\:h-\[calc<span data-type="inline-math" data-value="MTAwdmgtMjAwcHg="></span>\] {
    height: calc(100vh - 200px);
  }
}

@media (min-width: 768px) {
  .md\:h-\[calc<span data-type="inline-math" data-value="MTAwdmgtMTgwcHg="></span>\] {
    height: calc(100vh - 180px);
  }
}

.fixed {
  position: fixed;
}

.bottom-0 {
  bottom: 0px;
}

.left-0 {
  left: 0px;
}

.right-0 {
  right: 0px;
}

.border-t {
  border-top-width: 1px;
}

.max-w-4xl {
  max-width: 56rem;
}

.flex-1 {
  flex: 1 1 0%;
  /* 核心修复3：flex子元素防止溢出 */
  min-width: 0;
}

.relative {
  position: relative;
}

.border {
  border-width: 1px;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.focus\:outline-none:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.focus\:ring-2:focus {
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.focus\:ring-primary\/30:focus {
  --tw-ring-color: rgba(22, 93, 255, 0.3);
}

.focus\:border-primary:focus {
  border-color: #165DFF;
}

.resize-none {
  resize: none;
}

.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

.h-14 {
  height: 3.5rem;
}

@media (min-width: 640px) {
  .sm\:h-16 {
    height: 4rem;
  }
}

@media (min-width: 768px) {
  .md\:h-18 {
    height: 4.5rem;
  }
}

.overflow-hidden {
  overflow: hidden;
}

.absolute {
  position: absolute;
}

.bottom-2 {
  bottom: 0.5rem;
}

.right-4 {
  right: 1rem;
}

.w-11 {
  width: 2.75rem;
}

.h-11 {
  height: 2.75rem;
}

@media (min-width: 640px) {
  .sm\:w-12 {
    width: 3rem;
  }
  .sm\:h-12 {
    height: 3rem;
  }
}

.hover\:bg-primary\/90:hover {
  background-color: rgba(22, 93, 255, 0.9);
}

.active\:scale-95:active {
  --tw-scale-x: 0.95;
  --tw-scale-y: 0.95;
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.hidden {
  display: none;
}

@media (min-width: 640px) {
  .sm\:block {
    display: block;
  }
}

.mt-2 {
  margin-top: 0.5rem;
}

.max-w-\[85\%\] {
  max-width: 85%;
}

@media (min-width: 640px) {
  .sm\:max-w-\[80\%\] {
    max-width: 80%;
  }
}

@media (min-width: 1024px) {
  .lg\:max-w-\[75\%\] {
    max-width: 75%;
  }
}

.leading-relaxed {
  line-height: 1.625;
}

.w-9 {
  width: 2.25rem;
}

.h-9 {
  height: 2.25rem;
}

.rounded-full {
  border-radius: 9999px;
}

.bg-gray-200 {
  background-color: #e5e7eb;
}

.text-gray-600 {
  color: #4b5563;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.bg-loading {
  background-color: #83B7FF;
}

.w-2 {
  width: 0.5rem;
}

.h-2 {
  height: 0.5rem;
}

/* 核心修复4：输入框父容器样式兜底 */
#userInput {
  padding: 12px 16px !important; /* 内边距，保证输入区域 */
  line-height: 1.5 !important;
  border: 1px solid #E5E7EB !important;
  border-radius: 8px !important;
  resize: none !important;
  overflow: hidden !important;
}