/* ============================================================
   AI宝宝辅食助手 — Premium Minimalist Design
   设计方向：温柔、高级、宝妈友好
   ============================================================ */

/* ---------- Variables ---------- */
:root {
  --rose: #D4A5A5;
  --rose-light: #F0E0E0;
  --cream: #FBF7F4;
  --white: #FFFFFF;
  --text: #4A3F3F;
  --text-soft: #8C7F7F;
  --text-muted: #B8ADAD;
  --border: #EDE6E6;
  --green-soft: #C5D5C0;
  --green-bg: #F2F7F0;
  --warn-bg: #FFF9F0;
  --warn-text: #C08A3A;
  --danger: #D4756B;
  --shadow-xs: 0 1px 3px rgba(74, 63, 63, 0.04);
  --shadow-sm: 0 2px 8px rgba(74, 63, 63, 0.06);
  --shadow-md: 0 4px 16px rgba(74, 63, 63, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 24px);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: 32px 16px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.header-emoji { font-size: 2.4rem; display: block; margin-bottom: 4px; }
.header-title { font-size: 1.35rem; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.header-sub { font-size: 0.8rem; color: var(--text-soft); margin-top: 2px; }

/* ---------- Quota ---------- */
.quota-bar {
  text-align: center;
  padding: 8px 16px;
  font-size: 0.72rem;
  color: var(--text-soft);
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.quota-bar strong { color: var(--rose); font-weight: 700; }
.quota-bar.exhausted { color: var(--danger); }
.quota-bar.exhausted strong { color: var(--danger); }

/* ---------- Main ---------- */
.main-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Form Card ---------- */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group:last-of-type {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.required { color: var(--danger); }
.optional-tag {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
  background: #F5F3F3;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ---------- Age Controls ---------- */
.age-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.age-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 1.3rem;
  color: var(--rose);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.age-btn:active { background: var(--rose-light); transform: scale(0.95); }
.age-value {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  min-width: 60px;
  text-align: center;
  line-height: 1;
}
.age-unit {
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 500;
}

/* Slider */
.slider-wrap { padding: 0 4px; margin-bottom: 6px; }
#ageSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #E8D5D5, var(--rose));
  outline: none;
}
#ageSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--rose);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
#ageSlider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--rose);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}

/* Ticks — positioned via JS */
.tick-row {
  position: relative;
  height: 20px;
  margin-bottom: 6px;
}
.tick {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.2s;
}
.tick.active { color: var(--rose); font-weight: 700; }

.texture-tip {
  font-size: 0.75rem;
  color: var(--rose);
  text-align: center;
  background: var(--rose-light);
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-block;
  width: 100%;
}

/* ---------- Input ---------- */
.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  background: #FAF8F7;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus,
.form-textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(212,165,165,0.12);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-textarea--sm { min-height: 44px; }

.input-with-actions { position: relative; }
.input-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(212,165,165,0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:active { background: var(--rose-light); }
.icon-btn-emoji { font-size: 1rem; }
.icon-btn.listening {
  background: var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,117,107,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(212,117,107,0); }
}

.form-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-top: 6px;
}

/* ---------- Submit ---------- */
.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  background: var(--rose);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(212,165,165,0.3);
}
.submit-btn:active { transform: scale(0.97); opacity: 0.9; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.submit-btn.loading .submit-text { display: none; }
.submit-btn .submit-loading { display: none; }
.submit-btn.loading .submit-loading { display: block; }

/* ---------- Empty Guide ---------- */
.empty-guide {
  text-align: center;
  padding: 40px 24px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.guide-header { font-size: 3rem; margin-bottom: 8px; }
.empty-guide h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; }
.guide-list { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.guide-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
}
.guide-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Recipe List ---------- */
.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Recipe Card ---------- */
.recipe-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: cardIn 0.4s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cover */
.recipe-card__cover {
  height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.recipe-card__cover-emoji {
  font-size: 3.8rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.08));
}
.recipe-card__cover-label {
  font-size: 0.7rem;
  color: rgba(74,63,63,0.45);
  background: rgba(255,255,255,0.65);
  padding: 3px 12px;
  border-radius: 12px;
}

/* Header */
.recipe-card__header {
  padding: 14px 16px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.recipe-card__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.recipe-card__time {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.recipe-card__badge {
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--rose);
  background: var(--rose-light);
  border-radius: 14px;
  flex-shrink: 0;
}

/* Ingredients tags */
.recipe-card__ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
}
.ingredient-tag {
  font-size: 0.72rem;
  color: var(--text-soft);
  background: #FAF8F7;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Expand toggle */
.recipe-card__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--rose);
  cursor: pointer;
}
.expand-arrow {
  font-size: 0.65rem;
  transition: transform 0.3s;
}
.recipe-card.expanded .expand-arrow { transform: rotate(180deg); }

/* Detail */
.recipe-card__detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.recipe-card.expanded .recipe-card__detail { max-height: 900px; }
.recipe-card__detail-inner { padding: 0 16px 16px; }

.detail-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 8px;
}

/* Steps */
.steps-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #FAF8F7;
  border-radius: var(--radius-sm);
}
.step-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.step-content { flex: 1; }
.step-label { font-size: 0.62rem; font-weight: 700; color: var(--rose); display: block; }
.step-text { font-size: 0.8rem; color: var(--text-soft); line-height: 1.5; }

/* Texture */
.texture-box {
  background: var(--green-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.8rem;
  color: #5A7A50;
  line-height: 1.5;
}

/* Suggestion card */
.recipe-card--suggestion { border: 2px dashed #D4B896; }
.recipe-card--suggestion .recipe-card__name { color: #B8860B; }

/* ---------- Actions ---------- */
.results-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.action-btn {
  flex: 1;
  height: 44px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 22px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.action-btn--ghost {
  background: var(--white);
  color: var(--text-soft);
  border: 1.5px solid var(--border);
}
.action-btn--ghost:active { background: #FAF8F7; }

/* ---------- Loading Overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(251,247,244,0.9);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.loading-overlay.visible { opacity: 1; pointer-events: auto; }
.loading-content { text-align: center; }
.loading-bowl {
  font-size: 3rem;
  display: inline-block;
  animation: stir 1.2s ease-in-out infinite;
}
@keyframes stir {
  0%, 100% { transform: rotate(0deg) translateX(0); }
  25% { transform: rotate(12deg) translateX(3px); }
  50% { transform: rotate(0deg) translateX(6px); }
  75% { transform: rotate(-12deg) translateX(3px); }
}
.loading-content p {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 0.8rem;
  z-index: 200;
  opacity: 0;
  transition: all 0.35s ease;
  max-width: 88vw;
  text-align: center;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: #6B9E6B; }
.toast.warning { background: #D4A86A; }

/* ---------- Modal (Voice & Camera) ---------- */
.voice-modal,
.camera-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.voice-modal.visible,
.camera-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.voice-content,
.camera-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  width: 90vw;
  max-width: 360px;
}
.voice-wave {
  font-size: 3rem;
  margin-bottom: 12px;
}
.voice-content p,
.camera-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.voice-hint,
.camera-hint {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-bottom: 16px;
}
.voice-stop-btn {
  padding: 10px 32px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.camera-preview {
  width: 100%;
  height: 220px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
.camera-preview video,
.camera-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.camera-capture-btn,
.camera-retake-btn,
.camera-use-btn {
  padding: 10px 20px;
  border-radius: 22px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.camera-capture-btn { background: var(--rose); color: #fff; }
.camera-retake-btn { background: #F0E0E0; color: var(--text); }
.camera-use-btn { background: var(--green-soft); color: #4A6A3A; }
.camera-close-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px;
}
.camera-result {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-bottom: 8px;
  min-height: 20px;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
  .main-content { padding: 24px; }
  .recipe-list { gap: 18px; }
}
