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

:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --border: #e5e2dc;
  --text: #1a1a1a;
  --muted: #888;
  --accent: #c0392b;
  --accent-light: #fdf0ee;
  --green: #27ae60;
  --green-light: #edf7f1;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: max(20px, env(safe-area-inset-top)) 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
header .subtitle { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* NAV */
.nav-wrap {
  position: relative;
  margin-top: 14px;
}
.nav-wrap::after {
  content: '›';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 36px;
  background: linear-gradient(to right, transparent, var(--surface) 60%);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  font-size: 1.2rem;
  color: var(--muted);
}
nav#main-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
nav#main-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.nav-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* VIEWS */
.view { display: none; padding: 20px 16px; }
.view.active { display: block; }

/* PROGRESS */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  margin-bottom: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}
.progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 20px;
}

/* CHECKLIST */
.checklist-group { margin-bottom: 28px; }
.checklist-group h2 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.check-item:active { background: var(--bg); }
.check-item.done { background: var(--green-light); border-color: #c3e6d4; }
.check-item.done .check-text { color: var(--muted); text-decoration: line-through; }

.checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background 0.15s, border-color 0.15s;
}
.check-item.done .checkbox {
  background: var(--green);
  border-color: var(--green);
}
.checkbox svg { display: none; }
.check-item.done .checkbox svg { display: block; }

.check-text { font-size: 0.95rem; line-height: 1.45; }
.check-meta { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

.timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #f0c8c3;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.timer-btn:active { opacity: 0.7; }

/* RECIPES */
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.recipe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.recipe-header h2 { font-size: 0.95rem; font-weight: 700; }
.recipe-tag {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 600;
}
.tag-starter { background: #fef9e7; color: #b7950b; }
.tag-main { background: var(--accent-light); color: var(--accent); }
.tag-veg { background: var(--green-light); color: var(--green); }
.tag-side { background: #eaf4fb; color: #2471a3; }
.tag-dessert { background: #f5eef8; color: #7d3c98; }

.chevron { transition: transform 0.2s; font-size: 0.75rem; color: var(--muted); }
.recipe-card.open .chevron { transform: rotate(180deg); }

.recipe-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.recipe-card.open .recipe-body { display: block; }

.recipe-body h3 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 8px;
}
.ingredient-list { list-style: none; }
.ingredient-list li {
  font-size: 0.9rem;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.ingredient-list li:last-child { border-bottom: none; }

.step-list { list-style: none; counter-reset: steps; }
.step-list li {
  counter-increment: steps;
  display: flex;
  gap: 10px;
  font-size: 0.9rem;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(steps);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border-radius: 99px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* SHOPPING */
.shopping-actions { margin-bottom: 16px; }
.secondary-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
.secondary-btn:active { background: var(--bg); }

.shop-group { margin-bottom: 24px; }
.shop-group h2 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shop-item.got { background: var(--green-light); border-color: #c3e6d4; }
.shop-item.got .shop-name { color: var(--muted); text-decoration: line-through; }
.shop-item .checkbox { flex-shrink: 0; }
.shop-item.got .checkbox { background: var(--green); border-color: var(--green); }
.shop-name { font-size: 0.9rem; font-weight: 500; }
.shop-qty { font-size: 0.8rem; color: var(--muted); margin-left: auto; text-align: right; }

/* TIMER MODAL */
.modal {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 32px 24px max(48px, calc(32px + env(safe-area-inset-bottom)));
  z-index: 300;
  transition: transform 0.3s ease;
  text-align: center;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}
.modal.hidden { display: none; }
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}
#modal-backdrop.hidden { display: none; }

.timer-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.timer-display { font-size: 3.5rem; font-weight: 700; letter-spacing: -1px; margin-bottom: 24px; font-variant-numeric: tabular-nums; }
.timer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.timer-controls button {
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
#timer-start { background: var(--green); color: white; }
#timer-pause { background: var(--accent); color: white; }
#timer-reset { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
#timer-close { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.timer-done .timer-display { color: var(--green); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* MENU */
.menu-card {
  max-width: 340px;
  margin: 20px auto;
  text-align: center;
  padding: 0 8px;
}
.menu-occasion {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.menu-divider {
  width: 40px;
  height: 1px;
  background: var(--border);
  margin: 0 auto 24px;
}
.menu-course {
  margin-bottom: 22px;
}
.menu-course-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.menu-dish {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 5px;
  color: var(--text);
}
.menu-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}
.menu-desc-shared {
  margin-top: 10px;
  font-style: italic;
}
.menu-rule {
  color: var(--border);
  font-size: 1rem;
  margin: 4px 0 22px;
  letter-spacing: 0.3em;
}
.menu-or-block { margin-top: 0; }
.menu-or {
  font-size: 0.7rem;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 8px;
}
.menu-footer {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 20px;
}

/* TIMER TRAY */
#timer-tray {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
}
.rtb-item {
  background: #1a1a1a;
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.25);
}
.rtb-item:last-child {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.rtb-label { flex: 1; font-size: 0.8rem; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rtb-display { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.rtb-controls { display: flex; gap: 6px; }
.rtb-controls button { background: rgba(255,255,255,0.12); border: none; color: white; border-radius: 6px; padding: 6px 10px; font-size: 0.85rem; cursor: pointer; }
.rtb-controls button:active { background: rgba(255,255,255,0.22); }
.rtb-item.done { animation: timer-flash 0.6s infinite; }
.rtb-item.done .rtb-display { color: white; }
@keyframes timer-flash {
  0%, 100% { background: #c0392b; }
  50% { background: #1a1a1a; }
}

/* RECIPE STEP TIMER BUTTON */
.recipe-timer-btn {
  flex-shrink: 0;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #f0c8c3;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  margin-top: 2px;
  white-space: nowrap;
}
.recipe-timer-btn:active { opacity: 0.7; }
.step-list li span { flex: 1; }
.step-list li.has-check { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.step-list li.has-check:active { background: var(--bg); }
.step-list li.done > span { color: var(--muted); text-decoration: line-through; }
.step-check-box {
  width: 20px; height: 20px;
  border-radius: 5px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s;
}
.step-list li.done .step-check-box { background: var(--green); border-color: var(--green); }
.step-check-box svg { display: none; }
.step-list li.done .step-check-box svg { display: block; }

/* ASK CLAUDE */
.ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  background: #f0f4ff;
  color: #2c5fcc;
  border: 1px solid #c8d8f8;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ask-btn:active { opacity: 0.7; }

.shopping-ask-fab {
  position: fixed;
  bottom: max(24px, calc(16px + env(safe-area-inset-bottom)));
  right: 16px;
  background: var(--text) !important;
  color: white !important;
  border: none !important;
  border-radius: 99px !important;
  padding: 12px 20px !important;
  font-size: 0.9rem !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 100;
}
.shopping-ask-fab:active { opacity: 0.8; }

.plating-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  background: #f5f0ff;
  color: #6c3fc5;
  border: 1px solid #ddd0f8;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.plating-toggle-btn:active { opacity: 0.7; }
.plating-images-wrap { margin-top: 10px; }
.plating-images-wrap.hidden { display: none; }
.plating-images-wrap img {
  width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}

.ask-msg { margin-bottom: 8px; }
.ask-msg-user { text-align: right; }
.ask-msg-user span {
  display: inline-block;
  background: #e8eeff;
  border-radius: 12px 12px 2px 12px;
  padding: 8px 12px;
  font-size: 0.875rem;
  max-width: 88%;
  text-align: left;
}
.ask-msg-assistant span {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  font-size: 0.875rem;
  max-width: 95%;
  white-space: pre-wrap;
  line-height: 1.55;
  text-align: left;
}
.ask-msg-assistant.streaming span { opacity: 0.8; }

#ask-input:focus, #api-key-input:focus {
  outline: none;
  border-color: #2c5fcc;
}

.ask-thinking {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
