/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --brand:           #34C759;
  --brand-dim:       rgba(52,199,89,0.14);
  --accent:          #FF9500;
  --destructive:     #FF3B30;
  --kcal-ok:         #34C759;
  --kcal-warn:       #FF9500;
  --kcal-over:       #FF3B30;
  --macro-carb:      #007AFF;
  --macro-fat:       #FF9500;
  --macro-protein:   #34C759;

  --bg:              #F2F2F7;
  --canvas:          #E5E5EA;
  --card:            #FFFFFF;
  --card2:           #F2F2F7;
  --card3:           #E5E5EA;
  --overlay:         rgba(242,242,247,0.88);

  --text:            #000000;
  --text2:           #6C6C70;
  --text3:           #AEAEB2;
  --sep:             rgba(60,60,67,0.29);

  --font:            -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --shadow:          0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-sm:       0 1px 6px rgba(0,0,0,0.06), 0 0.5px 2px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg:      #000000;
    --canvas:  #121212;
    --card:    #1C1C1E;
    --card2:   #2C2C2E;
    --card3:   #3A3A3C;
    --overlay: rgba(18,18,18,0.90);
    --text:    #FFFFFF;
    --text2:   #8E8E93;
    --text3:   #48484A;
    --sep:     rgba(84,84,88,0.65);
    --shadow:  0 2px 14px rgba(0,0,0,0.5), 0 1px 4px rgba(0,0,0,0.4);
    --shadow-sm: 0 1px 8px rgba(0,0,0,0.35), 0 0.5px 2px rgba(0,0,0,0.3);
  }
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button {
  cursor: pointer; border: none; background: none;
  font-family: inherit; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea { font-family: inherit; color: inherit; }
* { -webkit-tap-highlight-color: transparent; }

/* ─── App Shell ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

#content { flex: 1; overflow: hidden; position: relative; }

/* ─── Screen ─────────────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  height: calc(56px + env(safe-area-inset-top, 0));
  background: var(--card);
  border-bottom: 0.5px solid var(--sep);
  flex-shrink: 0;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.screen-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.screen-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.screen-large-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--brand);
  font-size: 17px;
  font-weight: 400;
  padding: 8px 0;
  flex-shrink: 0;
}

.header-action-btn {
  color: var(--brand);
  font-size: 15px;
  font-weight: 500;
  padding: 8px 0;
  flex-shrink: 0;
  white-space: nowrap;
}
.header-action-btn.destructive { color: var(--destructive); }

.scroll-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 24px;
}

/* ─── Tab Bar ────────────────────────────────────────────────────────────────── */
#tab-bar {
  display: flex;
  background: var(--overlay);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  padding-bottom: env(safe-area-inset-bottom, 0);
  flex-shrink: 0;
  z-index: 20;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px 10px;
  color: var(--text3);
  transition: color 0.2s;
  min-height: 49px;
}

.tab-btn.active { color: var(--brand); }

.tab-icon {
  width: 26px;
  height: 26px;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  stroke-width: 1.7;
}

.tab-btn.active .tab-icon {
  transform: scale(1.08);
  stroke-width: 2.2;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  line-height: 1;
}

/* ─── Form Sections ──────────────────────────────────────────────────────────── */
.form-section { margin-top: 32px; }
.form-section:first-child { margin-top: 20px; }

.section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 20px 8px;
}

.section-footer {
  font-size: 13px;
  color: var(--text2);
  padding: 8px 20px 0;
  line-height: 1.5;
}

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 0 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ─── Dividers ───────────────────────────────────────────────────────────────── */
.divider      { height: 0.5px; background: var(--sep); margin-left: 16px; }
.divider-full { height: 0.5px; background: var(--sep); }

/* ─── Form Rows ──────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 52px;
  gap: 12px;
}

.form-row-label { display: flex; flex-direction: column; gap: 2px; }

.form-label-secondary {
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  letter-spacing: 0.1px;
}

.form-value-large {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.form-row-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-slider-row {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-slider-label {
  font-size: 15px;
  font-weight: 500;
}

.form-footer-text { font-size: 13px; color: var(--text2); }

.form-input-row { padding: 14px 16px; }

/* ─── Stepper ────────────────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  background: var(--card2);
  border-radius: 10px;
  overflow: hidden;
  border: 0.5px solid var(--sep);
}

.stepper-btn {
  width: 42px;
  height: 36px;
  font-size: 24px;
  font-weight: 300;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  line-height: 1;
}
.stepper-btn:active { background: var(--card3); }
.stepper-btn:disabled { color: var(--text3); }

.stepper-sep {
  width: 0.5px;
  height: 22px;
  background: var(--sep);
  flex-shrink: 0;
}

/* ─── Slider ─────────────────────────────────────────────────────────────────── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  /* Visible track background in all modes */
  background: var(--card3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(0,0,0,0.08);
  cursor: grab;
  transition: transform 0.12s;
}
.slider:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.1);
}

.slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  border: none;
}

/* Accent fill per track */
.slider         { accent-color: var(--brand); }
.slider-carb    { accent-color: var(--macro-carb); }
.slider-fat     { accent-color: var(--macro-fat); }

/* ─── Select ─────────────────────────────────────────────────────────────────── */
.select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--brand);
  text-align: right;
  max-width: 160px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2334C759' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

/* ─── Number input ───────────────────────────────────────────────────────────── */
.num-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 52px;
  gap: 12px;
}
.num-input-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.num-input-footnote {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.num-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.num-input-unit {
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  flex-shrink: 0;
}

.num-input {
  border: 0.5px solid var(--sep);
  border-radius: 8px;
  background: var(--card2);
  padding: 6px 10px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 110px;
  outline: none;
  color: var(--text);
}
.num-input-sm { width: 64px; padding: 4px 8px; font-size: 15px; }
.num-input:focus { border-color: var(--brand); }
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input[type=number] { -moz-appearance: textfield; }

/* ─── Kcal Stepper (editable stepper for calorie input) ──────────────────────── */
.kcal-stepper {
  display: flex;
  align-items: center;
  background: var(--card2);
  border-radius: 10px;
  overflow: hidden;
  border: 0.5px solid var(--sep);
  flex-shrink: 0;
}
.kcal-input {
  width: 80px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 0 4px;
  height: 36px;
  outline: none;
  -moz-appearance: textfield;
}
.kcal-input::-webkit-outer-spin-button,
.kcal-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ─── Toggle / iOS Switch ────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 50px;
  cursor: pointer;
  gap: 12px;
}

.toggle-label { font-size: 17px; font-weight: 400; }

.toggle-wrap { position: relative; flex-shrink: 0; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  display: block;
  width: 51px;
  height: 31px;
  background: #E5E5EA;
  border-radius: 16px;
  transition: background 0.25s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}
@media (prefers-color-scheme: dark) { .toggle-track { background: #39393D; } }
.toggle-input:checked ~ .toggle-track { background: var(--brand); }

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 0.5px rgba(0,0,0,0.05);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.toggle-input:checked ~ .toggle-track::after { transform: translateX(20px); }

/* ─── Text Input ─────────────────────────────────────────────────────────────── */
.text-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 17px;
  color: var(--text);
  padding: 4px 0;
  line-height: 1.4;
}
.text-input::placeholder { color: var(--text3); }

/* ─── Chips ──────────────────────────────────────────────────────────────────── */
.exclusion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  background: var(--card2);
  color: var(--text2);
  border: 0.5px solid var(--sep);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  cursor: pointer;
}

.chip-selected {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  font-weight: 600;
}

.chip-check { font-size: 11px; }

/* ─── Macro Donut Chart ──────────────────────────────────────────────────────── */
.macro-chart-container {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 20px 22px;
}

.macro-donut {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.macro-donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.macro-donut-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--macro-protein);
  line-height: 1;
}
.macro-donut-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.macro-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.macro-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-carb    { background: var(--macro-carb); }
.dot-fat     { background: var(--macro-fat); }
.dot-protein { background: var(--macro-protein); }

.value-accent  { font-size: 15px; font-weight: 700; color: var(--brand);        font-variant-numeric: tabular-nums; }
.value-carb    { font-size: 15px; font-weight: 700; color: var(--macro-carb);   font-variant-numeric: tabular-nums; }
.value-fat     { font-size: 15px; font-weight: 700; color: var(--macro-fat);    font-variant-numeric: tabular-nums; }
.value-protein { font-size: 15px; font-weight: 700; color: var(--macro-protein);font-variant-numeric: tabular-nums; }

/* ─── Step Card (Generate) ───────────────────────────────────────────────────── */
.step-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 0 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 0;
}

.step-divider {
  height: 0.5px;
  background: var(--sep);
  margin: 14px 16px 0;
}

.step-indicator {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--card2);
  color: var(--text2);
  border: 1.5px solid var(--sep);
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.step-indicator.complete {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.step-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
}

.prompt-ready-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--brand-dim);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 0.5px solid rgba(52,199,89,0.3);
}
.prompt-ready-icon { font-size: 24px; flex-shrink: 0; }
.prompt-ready-info { flex: 1; min-width: 0; }
.prompt-ready-title { font-size: 15px; font-weight: 600; }
.prompt-ready-sub   { font-size: 12px; color: var(--text2); margin-top: 2px; }

.response-ready-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--brand-dim);
  border-radius: var(--radius-md);
  border: 0.5px solid rgba(52,199,89,0.3);
}
.response-ready-icon { color: var(--brand); font-size: 18px; flex-shrink: 0; }
.response-ready-text { font-size: 14px; color: var(--text2); flex: 1; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.1px;
  transition: opacity 0.15s, transform 0.1s;
  user-select: none;
}
.btn:active { opacity: 0.75; transform: scale(0.98); }

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 8px rgba(52,199,89,0.4);
}
.btn-secondary {
  background: var(--card2);
  color: var(--brand);
  font-size: 16px;
  border: 0.5px solid var(--sep);
}
.btn-sm {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  width: auto;
}
.btn-text {
  color: var(--brand);
  font-size: 16px;
  font-weight: 600;
  padding: 8px 0;
}
.btn-text.btn-destructive { color: var(--destructive); }

/* ─── Summary Card (Generate) ────────────────────────────────────────────────── */
.summary-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 0 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  min-height: 46px;
  gap: 12px;
}
.summary-label { font-size: 15px; color: var(--text2); font-weight: 400; flex-shrink: 0; }
.summary-value { font-size: 15px; font-weight: 500; text-align: right; color: var(--text); }

/* ─── Day Cards ──────────────────────────────────────────────────────────────── */
.day-card {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 6px 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.day-card:active { opacity: 0.7; transform: scale(0.99); }

.day-card-bar { width: 5px; flex-shrink: 0; }

.day-card-body {
  flex: 1;
  min-width: 0; /* prevents flex child from overflowing the card */
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.day-card-text { flex: 1; min-width: 0; overflow: hidden; }

.day-card-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1;
}
.day-card-sub {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.kcal-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.chevron {
  color: var(--text3);
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

/* ─── Segmented Control ──────────────────────────────────────────────────────── */
.segmented {
  display: flex;
  background: var(--card2);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  border: 0.5px solid var(--sep);
}
.seg-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}
.seg-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 5px rgba(0,0,0,0.15), 0 0.5px 1px rgba(0,0,0,0.1);
}

.header-segmented { flex: 1; max-width: 220px; }

/* ─── Meal Cards ─────────────────────────────────────────────────────────────── */
.meal-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 6px 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.meal-card:active { opacity: 0.7; transform: scale(0.99); }
.meal-card.no-recipe { cursor: default; }
.meal-card.no-recipe:active { opacity: 1; transform: none; }

.meal-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.meal-info { flex: 1; min-width: 0; }
.meal-type {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}
.meal-name { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
.meal-kcal {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text2);
  flex-shrink: 0;
}

/* ─── Day / Recipe Footers ───────────────────────────────────────────────────── */
.day-footer {
  background: var(--overlay);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 0.5px solid var(--sep);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0));
  text-align: center;
  flex-shrink: 0;
}
.day-footer-kcal {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.6px;
  line-height: 1;
}
.day-footer-sub { font-size: 13px; color: var(--text2); margin-top: 5px; }

/* ─── Recipe View ────────────────────────────────────────────────────────────── */
.recipe-section { margin-top: 22px; padding: 0 16px; }

.recipe-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.ingredient-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 5px 0;
}
.ingredient-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
  margin-top: 9px;
}
.ingredient-text { font-size: 16px; line-height: 1.5; }

.numbered-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
}
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-text { font-size: 16px; line-height: 1.5; flex: 1; }

.duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
  font-size: 15px;
  padding: 8px 0;
  font-weight: 500;
}

.kcal-footer-bar {
  background: var(--overlay);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 0.5px solid var(--sep);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ─── Shopping List ──────────────────────────────────────────────────────────── */
.progress-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 0 16px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-title { font-size: 16px; font-weight: 600; }
.progress-label { font-size: 14px; color: var(--text2); font-variant-numeric: tabular-nums; }

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--card2);
  border-radius: 4px;
  overflow: hidden;
  border: 0.5px solid var(--sep);
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.22,1,0.36,1);
}

.shopping-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
.shopping-cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}
.cat-icon { font-size: 17px; }
.shopping-cat-badge {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text2);
  background: var(--card2);
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
  border: 0.5px solid var(--sep);
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  cursor: pointer;
  background: var(--card);
}
.shopping-item + .shopping-item { border-top: 0.5px solid var(--sep); }

.shopping-check-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 24px;
  line-height: 1;
  transition: color 0.15s;
}
.shopping-item-name {
  font-size: 17px;
  line-height: 1.3;
  transition: color 0.2s;
}
.shopping-item.checked .shopping-item-name {
  color: var(--text3);
  text-decoration: line-through;
  text-decoration-color: var(--text3);
}

.shopping-cat-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 0 16px 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 32px;
  text-align: center;
  gap: 10px;
}
.empty-icon { font-size: 64px; line-height: 1; }
.empty-title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin-top: 8px; }
.empty-sub   { font-size: 16px; color: var(--text2); line-height: 1.5; max-width: 280px; }

.empty-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  color: white;
  padding: 14px 28px;
  border-radius: 28px;
  font-size: 17px;
  font-weight: 600;
  margin-top: 12px;
  box-shadow: 0 2px 10px rgba(52,199,89,0.4);
  transition: opacity 0.15s, transform 0.1s;
}
.empty-action:active { opacity: 0.75; transform: scale(0.97); }

/* ─── AI response textarea ───────────────────────────────────────────────────── */
.ai-textarea {
  width: 100%;
  min-height: 140px;
  max-height: 220px;
  background: var(--card2);
  border: 0.5px solid var(--sep);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 15px;
  color: var(--text);
  resize: none;
  line-height: 1.5;
  font-family: var(--font);
  outline: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: border-color 0.2s;
}
.ai-textarea:focus { border-color: var(--brand); }
.ai-textarea::placeholder { color: var(--text3); }

.error-text {
  font-size: 13px;
  color: var(--destructive);
  line-height: 1.4;
}

/* ─── Desktop / Wide Screen Layout ──────────────────────────────────────────── */
@media (min-width: 640px) {
  body {
    background: var(--canvas);
  }

  #app {
    max-width: 680px;
    margin: 0 auto;
    background: var(--bg);
    box-shadow: 0 0 0 0.5px var(--sep), 0 12px 40px rgba(0,0,0,0.25);
  }

  /* Floating dock tab-bar */
  #tab-bar {
    margin: 0 12px 12px;
    margin-bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    border-radius: 20px;
    border: 0.5px solid var(--sep);
    box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 6px rgba(0,0,0,0.1);
    padding-bottom: 0;
  }

  .tab-btn { padding: 10px 4px 14px; }

  /* Give cards slightly more horizontal breathing room */
  .card          { margin: 0 20px; }
  .step-card     { margin: 0 20px; }
  .summary-card  { margin: 0 20px; }
  .day-card      { margin: 6px 20px; }
  .meal-card     { margin: 6px 20px; }
  .progress-card { margin: 0 20px; }
  .shopping-cat-card { margin: 0 20px 12px; }

  /* Custom scrollbar */
  .scroll-content::-webkit-scrollbar       { width: 8px; }
  .scroll-content::-webkit-scrollbar-track { background: transparent; }
  .scroll-content::-webkit-scrollbar-thumb {
    background: var(--card3);
    border-radius: 4px;
    border: 2px solid var(--bg);
  }
  .scroll-content::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* Wider textarea */
  .ai-textarea { min-height: 180px; max-height: 320px; }
}
