/* ============================================
   雪櫃靈感餐單 Planner - Styles
   Design: Sage 綠 + 米白 + 黑色 Pill CTA
   Reference: Nutrilens (layout) + Farm2Table (color)
   ============================================ */

/* === 設計變量 === */
:root {
  /* Sage 綠色系 */
  --sage-900: #2A4A35;
  --sage-700: #3A6B4C;
  --sage-500: #5B8C6F;
  --sage-300: #A8D5BA;
  --sage-100: #D4E8DC;
  --sage-50:  #ECF4EF;

  /* Cream 米色系 */
  --cream:    #F5F1E8;
  --cream-2:  #FAF7EE;

  /* 中性色 */
  --white:    #FFFFFF;
  --ink:      #1A1A1A;
  --ink-mid:  #4A4A4A;
  --ink-light:#7A7A7A;
  --border:   #E8E4DA;
  --border-2: #D8D4CA;

  /* 強調色（小心使用） */
  --orange:   #E26A2C;
  --orange-bg:#FDEFE3;
  --red:      #C73E3E;
  --red-bg:   #FDE7E7;
  --yellow:   #D4A418;
  --yellow-bg:#FFF4D6;

  /* 陰影 */
  --shadow-sm: 0 2px 6px rgba(58, 110, 76, 0.06);
  --shadow:    0 4px 16px rgba(58, 110, 76, 0.08);
  --shadow-lg: 0 8px 24px rgba(58, 110, 76, 0.12);

  /* 圓角 */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* 字體 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang HK", "Microsoft JhengHei", "Helvetica Neue", sans-serif;
  --font-display: "Times New Roman", "PingFang HK", "Microsoft JhengHei", serif;

  --t-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --t:      0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 15px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }

/* 確保 [hidden] 屬性有效 */
[hidden] { display: none !important; }

/* ============================================
   通用組件
   ============================================ */

/* 黑色 Pill CTA（主要按鈕） */
.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 14px 24px;
  border-radius: var(--r-pill);
  transition: all var(--t-fast);
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.btn-pill:hover:not(:disabled) {
  background: #000;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-pill:active:not(:disabled) { transform: translateY(1px); }
.btn-pill:disabled {
  background: var(--border-2);
  color: var(--ink-light);
  cursor: not-allowed;
}
.btn-pill.full { width: 100%; }
.btn-pill.lg { padding: 16px 28px; font-size: 1rem; }

/* 黑色 Pill + 圓形箭頭 + 剔號（參考 Nutrilens） */
.btn-pill-cta {
  background: var(--ink);
  color: var(--white);
  font-weight: 700;
  font-size: 1rem;
  padding: 8px 8px 8px 24px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: all var(--t-fast);
  position: relative;
}
.btn-pill-cta::after {
  content: "";
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3Cpolyline points='12 5 19 12 12 19'/%3E%3C/svg%3E");
  background-size: 18px;
  background-repeat: no-repeat;
  background-position: center;
}
.btn-pill-cta:hover {
  background: #000;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-pill-cta:active { transform: translateY(1px); }

/* 綠色圓形按鈕（如 stepper +、-） */
.btn-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.btn-circle:hover { border-color: var(--sage-700); color: var(--sage-700); }
.btn-circle:active { transform: scale(0.92); }

/* Sage 綠實心 chip（用於偏好/選擇） */
.chip {
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--sage-700); }
.chip.selected {
  background: var(--sage-700);
  border-color: var(--sage-700);
  color: var(--white);
}

/* 大型 stepper - 2人份/600 kcal 等 */
.big-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
  border-radius: var(--r);
  padding: 12px 16px;
}
.big-stepper .value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
  flex: 1;
  text-align: center;
}
.big-stepper .value small {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-light);
  margin-left: 4px;
}

/* Tag pill (綠色，已選食材) */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--sage-700);
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 600;
}
.tag-pill button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: var(--white);
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  transition: background var(--t-fast);
}
.tag-pill button:hover { background: rgba(255,255,255,0.5); }

/* Stat badge（熱量/時間等） */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--cream-2);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 600;
}
.badge.sage   { background: var(--sage-100); color: var(--sage-900); }
.badge.warn   { background: var(--orange-bg); color: var(--orange); }

/* 卡片 */
.card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Back button (黑) */
.btn-back-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--t-fast);
}
.btn-back-circle:hover { border-color: var(--ink); }

/* 雪花背景 */
.snowflakes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.snowflakes span {
  position: absolute;
  top: -20px;
  color: var(--sage-300);
  opacity: 0.35;
  font-size: 1.2rem;
  animation: fall linear infinite;
  user-select: none;
}
.snowflakes span:nth-child(1) { left: 5%;  animation-duration: 14s; animation-delay: 0s; }
.snowflakes span:nth-child(2) { left: 15%; animation-duration: 18s; animation-delay: 2s;   font-size: 1.5rem; }
.snowflakes span:nth-child(3) { left: 25%; animation-duration: 12s; animation-delay: 4s;   font-size: 1rem; }
.snowflakes span:nth-child(4) { left: 40%; animation-duration: 16s; animation-delay: 1s;   font-size: 1.8rem; }
.snowflakes span:nth-child(5) { left: 55%; animation-duration: 20s; animation-delay: 3s;   font-size: 1.3rem; }
.snowflakes span:nth-child(6) { left: 70%; animation-duration: 15s; animation-delay: 5s;   font-size: 1.6rem; }
.snowflakes span:nth-child(7) { left: 85%; animation-duration: 17s; animation-delay: 6s;   font-size: 1.1rem; }
.snowflakes span:nth-child(8) { left: 92%; animation-duration: 13s; animation-delay: 2.5s; font-size: 1.4rem; }
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(360deg); }
}

/* ============================================
   App Container & 屏幕
   ============================================ */
.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 20px 40px;
}

.screen {
  animation: fadeUp 0.4s ease;
}
.screen[hidden] { display: none; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Onboarding 屏幕
   ============================================ */
.onboarding-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 32px;
  position: relative;
}

.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.onboarding-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
}
.onboarding-brand .snowflake {
  display: inline-block;
  animation: wobble 3s ease-in-out infinite;
  font-size: 1.4rem;
}
.onboarding-brand .ai-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--sage-700);
  background: var(--sage-100);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 2px;
  vertical-align: super;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}

.btn-skip {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-light);
  padding: 6px 4px;
}
.btn-skip:hover { color: var(--ink); }

/* 步驟指示 */
.onboarding-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 20px 0 32px;
}
.onboarding-dots .dot {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-2);
  transition: all var(--t);
}
.onboarding-dots .dot.active { background: var(--ink); width: 48px; }

.onboarding-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.onboarding-headline {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}
.onboarding-headline .accent {
  color: var(--sage-700);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.onboarding-headline .accent::after {
  content: "💧";
  display: inline-block;
  font-size: 0.7em;
}

.onboarding-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0 32px;
  position: relative;
  min-height: 280px;
}
.onboarding-hero .hero-image {
  width: 100%;
  max-width: 380px;
  height: auto;
  border-radius: var(--r-lg);
  object-fit: cover;
  box-shadow: var(--shadow-lg);
}
.onboarding-hero .hero-emoji-large {
  font-size: 8rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
}
.onboarding-hero .welcome-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--sage-700);
  color: var(--white);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transform: rotate(-8deg);
  animation: popIn 0.4s ease;
}
@keyframes popIn {
  from { transform: rotate(-8deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(-8deg) scale(1); opacity: 1; }
}

.onboarding-progress-card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.onboarding-progress-card .progress-ring {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 12px;
}
.onboarding-progress-card .progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.onboarding-progress-card .progress-ring .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--sage-900);
}
.onboarding-progress-card .ring-label {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-weight: 600;
}

.onboarding-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}
.onboarding-stats .stat {
  background: var(--white);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.onboarding-stats .stat .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.onboarding-stats .stat.protein .dot { background: var(--yellow); }
.onboarding-stats .stat.carbs   .dot { background: var(--sage-500); }
.onboarding-stats .stat.fat     .dot { background: var(--red); }

.onboarding-steppers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  margin: 16px 0;
}
.onboarding-stepper {
  background: var(--white);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.onboarding-stepper .label {
  font-weight: 700;
  font-size: 0.9rem;
}
.onboarding-stepper .controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.onboarding-stepper .controls .val {
  min-width: 60px;
  text-align: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.onboarding-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
}
.onboarding-footer .login-hint {
  font-size: 0.85rem;
  color: var(--ink-light);
}
.onboarding-footer .login-hint a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

/* ============================================
   Header (主流程)
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0 4px;
  font-size: 1.1rem;
  font-weight: 800;
}
.app-header .snowflake {
  font-size: 1.5rem;
  display: inline-block;
  animation: wobble 3s ease-in-out infinite;
}

/* ============================================
   Stepper 進度
   ============================================ */
.stepper-bar {
  display: flex;
  gap: 6px;
  margin: 8px 0 20px;
}
.stepper-bar .bar {
  flex: 1;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  transition: background var(--t);
}
.stepper-bar .bar.done { background: var(--sage-700); }
.stepper-bar .bar.active { background: var(--ink); }

/* 屏幕標題 */
.screen-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.screen-sub {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: 20px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   Screen 1: 食材輸入
   ============================================ */
.input-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.mode-card {
  background: var(--white);
  border: 2px dashed var(--border-2);
  border-radius: var(--r-lg);
  padding: 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all var(--t);
}
.mode-card:hover, .mode-card.active {
  border-style: solid;
  border-color: var(--sage-700);
  background: var(--white);
  transform: translateY(-2px);
}
.mode-card .mode-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--sage-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--white);
}
.mode-card .mode-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.mode-card .mode-desc {
  font-size: 0.7rem;
  color: var(--ink-light);
  text-align: center;
}

.photo-preview {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.photo-preview img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.photo-preview .photo-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
}
.photo-preview .btn-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: var(--white);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.manual-input {
  margin-bottom: 20px;
}
.input-row {
  display: flex;
  gap: 8px;
  background: var(--white);
  border-radius: var(--r);
  padding: 6px 6px 6px 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.input-row input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  padding: 10px 0;
  background: transparent;
  min-width: 0;
}
.input-row .btn-add {
  background: var(--sage-700);
  color: var(--white);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 700;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--ink);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--t-fast);
}
.tag:hover { border-color: var(--sage-700); color: var(--sage-700); }
.tag.selected {
  background: var(--sage-100);
  border-color: var(--sage-300);
  color: var(--sage-900);
  font-weight: 700;
}

.selected-section {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 16px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
}
.empty-hint {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-style: italic;
}
.btn-clear {
  font-size: 0.8rem;
  color: var(--ink-light);
  text-decoration: underline;
  padding: 4px;
}

/* ============================================
   Screen 2: 偏好設定
   ============================================ */
.form-group {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.value-tag {
  background: var(--sage-100);
  color: var(--sage-900);
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  font-weight: 700;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Range slider */
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--sage-700);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(58, 110, 76, 0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--sage-700);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-top: 6px;
}

/* ============================================
   Screen 3: 餐單結果
   ============================================ */
.plan-summary {
  font-size: 0.95rem;
  color: var(--ink-mid);
  margin-bottom: 16px;
  font-weight: 500;
}
.plan-summary strong {
  color: var(--ink);
  font-weight: 800;
}
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.plan-card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 14px;
  cursor: pointer;
  transition: all var(--t);
  align-items: center;
  animation: popIn 0.4s ease;
}
.plan-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
@keyframes popIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.plan-card .plan-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--r);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--cream-2);
}
.plan-card .plan-emoji {
  width: 72px;
  height: 72px;
  border-radius: var(--r);
  background: var(--cream-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  flex-shrink: 0;
}

.plan-card .plan-info {
  flex: 1;
  min-width: 0;
}
.plan-card .plan-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}
.plan-card .plan-desc {
  font-size: 0.8rem;
  color: var(--ink-light);
  margin-bottom: 6px;
}
.plan-card .plan-stats {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ============================================
   Screen 4: 食譜詳情
   ============================================ */
.recipe-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.recipe-title-wrap {
  flex: 1;
}
.recipe-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--ink);
}
.recipe-actions {
  display: flex;
  gap: 8px;
}
.icon-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--t-fast);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn.active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}
.icon-btn .icon { font-size: 1rem; }

.recipe-hero {
  width: 100%;
  height: 220px;
  border-radius: var(--r-lg);
  object-fit: cover;
  margin-bottom: 16px;
  background: var(--cream-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  box-shadow: var(--shadow);
}

.recipe-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.recipe-section {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.ingredient-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ingredient-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--r);
  font-size: 0.9rem;
}
.ingredient-list li.have { background: var(--sage-50); }
.ingredient-list li.miss { background: var(--orange-bg); }
.ingredient-list .ing-name { font-weight: 700; }
.ingredient-list .ing-qty {
  background: var(--white);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--border);
}
.ingredient-list .portion-note {
  font-size: 0.7rem;
  color: var(--ink-light);
  font-style: italic;
  width: 100%;
  margin-left: 24px;
}

.step-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step-list li {
  counter-increment: step;
  padding: 14px 14px 14px 56px;
  position: relative;
  background: var(--cream-2);
  border-radius: var(--r);
  font-size: 0.9rem;
  line-height: 1.6;
}
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 32px;
  height: 32px;
  background: var(--sage-700);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

/* 營養 grid */
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.nutrition-item {
  text-align: center;
  background: var(--cream-2);
  border-radius: var(--r);
  padding: 12px 6px;
}
.nutrition-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--sage-900);
}
.nutrition-value small {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-light);
}
.nutrition-label {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-light);
  margin-top: 2px;
}

/* 食安 */
.recipe-safety {
  background: linear-gradient(135deg, #FFF4E8 0%, #FFE4CC 100%);
  border-left: 3px solid var(--orange);
}
.safety-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.safety-list li {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(226, 106, 44, 0.2);
}
.safety-list li:last-child { border: none; }

/* 小朋友 */
.recipe-kids {
  background: linear-gradient(135deg, #FFF8E0 0%, #FFEBB3 100%);
  border-left: 3px solid var(--yellow);
}
.kids-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kids-list li {
  font-size: 0.9rem;
  padding: 8px 12px;
  background: rgba(255,255,255,0.6);
  border-radius: var(--r);
  border: 1px dashed var(--yellow);
}

/* 剩食 */
.recipe-leftover {
  background: linear-gradient(135deg, #ECF4EF 0%, #D4E8DC 100%);
  border-left: 3px solid var(--sage-700);
}
.leftover-idea {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* 健康 flag badges */
.health-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.health-badge {
  font-size: 0.7rem;
  background: var(--sage-100);
  color: var(--sage-900);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-weight: 700;
}

/* Tip */
.recipe-tip {
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--cream-2);
  padding: 12px;
  border-radius: var(--r);
  border-left: 3px solid var(--sage-700);
}

/* ============================================
   買餸清單
   ============================================ */
.shopping-section {
  background: linear-gradient(135deg, #FFF8E7 0%, #FFEFD5 100%);
  border-left: 3px solid var(--orange);
  animation: fadeUp 0.3s ease;
}
.shopping-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.shopping-header .section-title { margin-bottom: 0; }
.shopping-actions { display: flex; gap: 6px; }

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shopping-category {
  background: rgba(255,255,255,0.6);
  border-radius: var(--r);
  padding: 8px 10px;
}
.shopping-cat-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.shopping-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.shopping-item:hover { background: rgba(255,255,255,0.8); }
.shopping-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--sage-700);
}
.shopping-item-name {
  flex: 1;
  color: var(--ink);
}
.shopping-item.checked .shopping-item-name {
  text-decoration: line-through;
  color: var(--ink-light);
}
.shopping-item-qty {
  font-size: 0.8rem;
  color: var(--ink-light);
  background: var(--white);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
}

/* 收藏 */
.favorites-list { display: flex; flex-direction: column; gap: 8px; }
.favorite-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--cream-2);
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1.5px solid transparent;
}
.favorite-item:hover {
  background: var(--white);
  border-color: var(--sage-700);
}
.favorite-emoji { font-size: 1.5rem; }
.favorite-info { flex: 1; }
.favorite-name { font-size: 0.95rem; font-weight: 700; }
.favorite-meta { font-size: 0.75rem; color: var(--ink-light); margin-top: 2px; }
.favorite-remove {
  color: var(--ink-light);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: var(--r-sm);
}
.favorite-remove:hover { background: var(--red-bg); color: var(--red); }

/* ============================================
   Actions (底部按鈕)
   ============================================ */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.actions .btn-pill,
.actions .btn-pill-cta { flex: 1; }
.actions .btn-secondary {
  flex: 1;
  background: var(--white);
  color: var(--ink);
  border: 1.5px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 0.95rem;
  transition: all var(--t-fast);
}
.actions .btn-secondary:hover { border-color: var(--ink); }

/* ============================================
   Loader
   ============================================ */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(245, 241, 232, 0.9);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.loader-content { text-align: center; }
.loader-snow {
  font-size: 3rem;
  animation: spin 1.5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  margin-top: 12px;
  font-size: 1rem;
  color: var(--sage-700);
  font-weight: 700;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

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

/* ============================================
   PWA Install Prompt
   ============================================ */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 16px;
  right: 16px;
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  z-index: 150;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  max-width: 480px;
  margin: 0 auto;
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-install-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}
.pwa-install-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.pwa-install-sub {
  font-size: 0.8rem;
  opacity: 0.7;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pwa-install-btn {
  background: var(--white);
  color: var(--ink);
  border: none;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t-fast);
}
.pwa-install-btn:hover { transform: scale(1.05); }
.pwa-install-close {
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
  transition: all var(--t-fast);
}
.pwa-install-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* 離線指示 */
.offline-indicator {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}
.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 360px) {
  .onboarding-headline { font-size: 2rem; }
  .screen-title { font-size: 1.6rem; }
  .recipe-title { font-size: 1.4rem; }
  .nutrition-grid { grid-template-columns: repeat(2, 1fr); }
  .input-modes { gap: 6px; }
  .mode-card { padding: 14px 4px; }
}

@media (min-width: 481px) {
  .app { padding: 24px 24px 40px; }
  .onboarding-screen { padding: 32px 32px 40px; }
}

/* Smooth scroll */
html { scroll-behavior: smooth; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--sage-700);
  outline-offset: 2px;
}
