/* ============ 创意小黄鸭 · 通用样式 ============ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --duck-yellow: #FFD93D;
  --duck-yellow-deep: #F4B400;
  --duck-orange: #FF9F1C;
  --duck-cream: #FFF8E1;
  --duck-cream-deep: #FFEBA1;
  --text-primary: #2D2A26;
  --text-secondary: #6B6357;
  --text-muted: #9C9285;
  --bg-gradient: linear-gradient(135deg, #FFF8E1 0%, #FFEBA1 50%, #FFD93D 100%);
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-shadow: 0 8px 32px rgba(244, 180, 0, 0.18);
  --bubble-user: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  --bubble-duck: #FFFFFF;
  --border-soft: rgba(244, 180, 0, 0.25);
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #E53935;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ============ 欢迎页样式 ============ */
.page-welcome {
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-decoration span {
  position: absolute;
  font-size: 32px;
  opacity: 0.35;
  animation: float 6s ease-in-out infinite;
}

.bg-decoration .float-1 { top: 8%;  left: 10%; animation-delay: 0s; }
.bg-decoration .float-2 { top: 18%; right: 12%; animation-delay: 1.2s; }
.bg-decoration .float-3 { top: 60%; left: 5%; animation-delay: 2.4s; }
.bg-decoration .float-4 { top: 75%; right: 8%; animation-delay: 0.8s; }
.bg-decoration .float-5 { top: 40%; right: 18%; animation-delay: 3.6s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(8deg); }
}

.welcome-card {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 28px;
  padding: 32px 24px 28px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-soft);
  text-align: center;
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ 小黄鸭 SVG/CSS 角色 ============ */
.duck-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.duck {
  width: 110px;
  height: 110px;
  position: relative;
  animation: duckBounce 3s ease-in-out infinite;
}

@keyframes duckBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.duck-body {
  width: 100%;
  height: 100%;
  background: var(--duck-yellow);
  border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%;
  position: relative;
  box-shadow: inset -10px -10px 20px rgba(244, 180, 0, 0.4),
              0 6px 16px rgba(244, 180, 0, 0.3);
}

.duck-eye {
  position: absolute;
  width: 12px;
  height: 14px;
  background: #2D2A26;
  border-radius: 50%;
  top: 32%;
}

.duck-eye.left  { left: 30%; }
.duck-eye.right { right: 30%; }

.duck-eye::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  top: 2px;
  right: 2px;
}

.duck-beak {
  position: absolute;
  width: 32px;
  height: 18px;
  background: var(--duck-orange);
  border-radius: 50% 50% 60% 60% / 30% 30% 100% 100%;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.15);
}

.duck-cheek {
  position: absolute;
  width: 14px;
  height: 8px;
  background: #FFB3B3;
  border-radius: 50%;
  top: 48%;
  opacity: 0.7;
}

.duck-cheek.left  { left: 18%; }
.duck-cheek.right { right: 18%; }

.duck-wing {
  position: absolute;
  width: 24px;
  height: 32px;
  background: var(--duck-yellow-deep);
  border-radius: 60% 40% 60% 40%;
  top: 50%;
}

.duck-wing.left  { left: -6%; transform: rotate(-15deg); }
.duck-wing.right { right: -6%; transform: rotate(15deg); }

.welcome-title {
  margin: 8px 0 4px;
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #F4B400 0%, #FF9F1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.welcome-intro {
  text-align: left;
  background: var(--duck-cream);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 20px;
  border-left: 4px solid var(--duck-yellow-deep);
  line-height: 1.7;
  font-size: 15px;
}

.welcome-intro p { margin: 0 0 6px; }
.welcome-intro p:last-child { margin-bottom: 0; }

.welcome-intro .highlight {
  color: var(--duck-orange);
  font-weight: 700;
  font-size: 16px;
  margin-top: 4px;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  text-align: left;
}

.feature-list li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.feature-list .emoji {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.cta-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-primary, .btn-ghost {
  display: inline-block;
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.2s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  color: #2D2A26;
  box-shadow: 0 4px 12px rgba(255, 159, 28, 0.4);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 159, 28, 0.5);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-soft);
}

.btn-ghost:hover {
  background: var(--duck-cream);
}

.footer-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ============ 对话页样式 ============ */
.page-chat {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 248, 225, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 8px;
}

.back-btn:hover {
  background: var(--duck-cream);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.chat-header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.header-duck {
  width: 38px;
  height: 38px;
  background: var(--duck-yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(244, 180, 0, 0.4);
}

.progress-bar {
  height: 3px;
  background: var(--duck-cream);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD93D, #FF9F1C);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 0 3px 3px 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 12px 0;
}

.chat-messages {
  flex: 1;
  display: block;
  padding: 12px 4px 16px;
}

.msg {
  position: relative;
  padding-left: 44px;
  margin: 0 0 14px 0;
  min-height: 36px;
  min-width: 0;
  animation: msgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  width: calc(100vw - 16px);
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  display: block;
}

.msg:last-child {
  margin-bottom: 0;
}

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

.msg-avatar {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--duck-yellow);
  box-shadow: 0 2px 6px rgba(244, 180, 0, 0.3);
}

.msg-avatar.user-avatar {
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.msg-content {
  display: block;
  min-width: 0;
  max-width: 100%;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.msg-bubble p {
  margin: 0 0 6px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg.duck .msg-bubble {
  background: var(--bubble-duck);
  color: var(--text-primary);
  border-top-left-radius: 4px;
  border: 1px solid var(--border-soft);
}

.msg.user {
  padding-left: 0;
  padding-right: 44px;
}

.msg.user .msg-avatar {
  left: auto;
  right: 0;
}

.msg.user .msg-content {
  display: block;
  text-align: right;
}

.msg.user .msg-meta {
  text-align: right;
}

.msg.user .msg-bubble {
  background: var(--bubble-user);
  color: #2D2A26;
  font-weight: 500;
  border-top-right-radius: 4px;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.msg.system {
  justify-content: center;
}

.msg.system .msg-bubble {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 12px;
  border: 1px dashed var(--border-soft);
}

/* ============ 输入区 ============ */
.chat-input-area {
  position: sticky;
  bottom: 0;
  background: rgba(255, 248, 225, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  z-index: 10;
}

.chat-input-wrap {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border: 1.5px solid var(--border-soft);
  border-radius: 16px;
  background: white;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.chat-textarea:focus {
  border-color: var(--duck-orange);
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  border: none;
  color: #2D2A26;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255, 159, 28, 0.4);
  transition: transform 0.1s, box-shadow 0.2s;
}

.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============ 选项按钮 ============ */
.options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  max-width: calc(100% - 50px);
}

.option-chip {
  padding: 8px 14px;
  background: white;
  border: 1.5px solid var(--border-soft);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.option-chip:hover {
  background: var(--duck-cream);
  border-color: var(--duck-yellow-deep);
  transform: translateY(-1px);
}

.option-chip.selected {
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  border-color: transparent;
  color: #2D2A26;
  font-weight: 600;
}

/* ============ 报告页样式 ============ */
.page-report {
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.report-header {
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  color: #2D2A26;
  padding: 32px 20px 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.report-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, rgba(255,255,255,0.4), transparent 60%);
}

.report-header-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.report-emoji {
  font-size: 56px;
  display: block;
  margin-bottom: 8px;
  animation: duckBounce 3s ease-in-out infinite;
}

.report-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 800;
}

.report-subtitle {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

.score-circle {
  width: 130px;
  height: 130px;
  margin: 20px auto 0;
  position: relative;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-track {
  fill: none;
  stroke: rgba(255,255,255,0.3);
  stroke-width: 10;
}

.score-progress {
  fill: none;
  stroke: white;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
}

.score-number {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 11px;
  margin-top: 2px;
  opacity: 0.9;
}

.report-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.report-section {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(244, 180, 0, 0.08);
  border: 1px solid var(--border-soft);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-title .icon {
  font-size: 22px;
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qa-item {
  border-left: 3px solid var(--duck-yellow);
  padding: 4px 0 4px 12px;
}

.qa-question {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}

.qa-answer {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.qa-answer.empty {
  color: var(--text-muted);
  font-style: italic;
}

.diagnosis-card {
  background: linear-gradient(135deg, #FFF8E1 0%, #FFEBA1 100%);
  border-radius: 20px;
  padding: 20px 18px;
  margin-bottom: 16px;
  border: 1px solid var(--duck-cream-deep);
}

.diagnosis-card h3 {
  margin: 0 0 12px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagnosis-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diagnosis-list li {
  background: white;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.diagnosis-list .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.badge.good { background: #C8E6C9; color: #2E7D32; }
.badge.warn { background: #FFE0B2; color: #E65100; }
.badge.bad  { background: #FFCDD2; color: #C62828; }
.badge.info { background: #BBDEFB; color: #1565C0; }

.action-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-item {
  background: white;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border-soft);
  transition: transform 0.15s;
}

.action-item:hover {
  transform: translateX(2px);
}

.action-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD93D 0%, #FF9F1C 100%);
  color: #2D2A26;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.action-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.action-text strong {
  color: var(--duck-orange);
  display: block;
  margin-bottom: 2px;
  font-size: 15px;
}

.report-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding: 0 4px;
}

.report-actions .btn-primary,
.report-actions .btn-ghost {
  width: 100%;
}

.empty-report {
  text-align: center;
  padding: 60px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.empty-report .big-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
}

.empty-report h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text-primary);
}

.empty-report p {
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.6;
}

/* ============ 响应式 / 移动端优化 ============ */
@media (max-width: 480px) {
  .welcome-card { padding: 24px 18px; }
  .welcome-title { font-size: 24px; }
  .duck { width: 90px; height: 90px; }
  .chat-header-title { font-size: 15px; }
  .msg-bubble { font-size: 14.5px; padding: 10px 14px; }
  .report-title { font-size: 22px; }
  .score-circle { width: 110px; height: 110px; }
  .score-number { font-size: 32px; }
  .options-list { max-width: 100%; }
}

@media (min-width: 768px) {
  .welcome-card { padding: 40px 36px; }
  .chat-main { padding: 20px 24px 0; }
  .chat-messages { gap: 16px; }
  .msg-bubble { font-size: 15.5px; }
  .report-header { padding: 48px 24px 56px; }
}

@media (min-width: 1024px) {
  .chat-messages { padding: 24px 8px; }
}

/* ============ 工具类 ============ */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============ 移动端键盘适配 ============ */
@supports (height: 100dvh) {
  body { min-height: 100dvh; }
}
