* {
  box-sizing: border-box;
}

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

body {
  background: #0f172a;
  color: #e5e7eb;
  font-family: system-ui, -apple-system, BlinkMacSystemFont;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== 主容器 ===== */

.chat-container {
  width: 100%;
  height: 100dvh;               /* iOS / iPad 关键 */
  max-width: 920px;             /* iPad / 桌面 */
  display: flex;
  flex-direction: column;
  background: #020617;
}

/* ===== Header ===== */

.chat-header {
  padding: 14px;
  text-align: center;
  font-weight: 600;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

/* ===== 消息区 ===== */

.chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== 单条消息 ===== */

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.bot {
  align-self: flex-start;
  background: #1f2937;
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}

/* ===== 输入区 ===== */

.chat-input {
  display: flex;
  padding: 10px;
  border-top: 1px solid #1e293b;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  padding: 10px;
  border-radius: 8px;
  border: none;
  outline: none;
  background: #020617;
  color: #e5e7eb;
  font-size: 16px;          /* 防 iOS 放大 */
  min-height: 44px;         /* 触控友好 */
}

.chat-input button {
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== 手机优化 ===== */

@media (max-width: 600px) {
  .chat-container {
    max-width: 100%;
  }

  .message {
    max-width: 92%;
    font-size: 15px;
  }
}

/* ===== iPad 优化 ===== */

@media (min-width: 768px) and (max-width: 1024px) {
  .chat-container {
    max-width: 860px;
  }

  .message {
    font-size: 16px;
    line-height: 1.7;
  }
}

/* ===== 桌面优化 ===== */

@media (min-width: 1024px) {
  .chat-container {
    max-width: 960px;
    height: calc(100dvh - 32px);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  }
}

/* ===== 横屏（手机 / iPad） ===== */

@media (orientation: landscape) and (max-height: 500px) {
  .chat-header {
    padding: 8px;
  }

  .chat-input textarea {
    rows: 1;
  }
}
