:root {
  --bg: #08111f;
  --bg2: #101a2d;
  --card: #111c30;
  --card2: #17253c;
  --text: #f7f9fc;
  --muted: #a8b6ca;
  --line: #293b57;
  --accent: #7ce2ac;
  --accent-dark: #052e1a;
  --blue: #72c7ff;
  --danger: #fb7185;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
}

body.light {
  --bg: #f5f8fc;
  --bg2: #edf3fa;
  --card: #ffffff;
  --card2: #f1f5fa;
  --text: #102036;
  --muted: #58697e;
  --line: #d5e0ec;
  --accent: #0b9f69;
  --accent-dark: #ffffff;
  --blue: #0c83c9;
  --danger: #be123c;
  --shadow: 0 14px 38px rgba(27, 48, 76, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(124, 226, 172, .16), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(114, 199, 255, .11), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg2));
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 14px;
  background: var(--card2);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
button:hover { transform: translateY(-1px); border-color: var(--accent); }
button.primary, .tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-dark);
}
button.ghost { background: transparent; }
button.wide { width: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 2px 0 4px; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.045em; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 950; letter-spacing: .14em; }
.sync-state { margin: 0; color: var(--muted); }
.sync-state.ok { color: var(--muted); }
.sync-state.err { color: var(--danger); }
.top-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.tabs {
  position: sticky;
  top: 111px;
  z-index: 19;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg2) 90%, transparent);
  backdrop-filter: blur(14px);
}
.tabs button { min-width: 150px; background: transparent; }

main { width: min(1400px, 100%); margin: 0 auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; }
.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.card h2, .card h3, .card p { margin-top: 0; }
.card p { color: var(--muted); line-height: 1.55; }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 15%, var(--card)), color-mix(in srgb, var(--blue) 8%, var(--card)));
}
.hero h2 { margin: 7px 0; font-size: clamp(24px, 4vw, 36px); }
.hero-total { min-width: 180px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card2); text-align: center; }
.hero-total b { display: block; font-size: 36px; color: var(--accent); }
.hero-total span { color: var(--muted); font-size: 13px; }

.dayplan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.dayitem, .recipe-card, .week-day {
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.dayitem { padding: 15px; }
.meal-heading, .week-day-heading, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.meal-heading { margin-bottom: 13px; color: var(--accent); font-weight: 900; }
.meal-heading b { color: var(--muted); font-size: 12px; }
.compact-recipe h4 { min-height: 43px; margin: 0 0 10px; font-size: 17px; }
.statline { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.statline span, .category-label, .badge, .result-count {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.category-label { color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 9px 0; }
.badge { color: var(--accent); }
.muted-badge { color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.recipe-actions button { flex: 1 1 110px; }

.advisor-block { margin-top: 18px; }
.section-heading { margin-bottom: 16px; }
.section-heading h2 { margin: 5px 0 0; }
.recommend-buttons { display: flex; gap: 9px; flex-wrap: wrap; }
.recommend-buttons button { flex: 1 1 150px; }
.single-suggestion { margin-top: 16px; }
.featured-card { max-width: 720px; }

.macro {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.macro div {
  padding: 11px 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card2);
  text-align: center;
}
.macro b { display: block; color: var(--accent); font-size: 19px; }
.macro span { color: var(--muted); font-size: 11px; }

.weekplan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 13px;
}
.week-day { padding: 15px; }
.week-day-heading { margin-bottom: 10px; }
.week-day-heading h3 { margin: 0; }
.week-day-heading span { color: var(--accent); font-weight: 900; }
.week-meal {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  padding: 10px;
  text-align: left;
  font-weight: 500;
}
.week-meal span { display: grid; gap: 3px; min-width: 0; }
.week-meal b { color: var(--accent); font-size: 12px; }
.week-meal strong { flex: 0 0 auto; color: var(--muted); font-size: 12px; }

.browser-tools { margin-bottom: 16px; }
.searchbar { display: grid; gap: 7px; margin: 14px 0; color: var(--muted); font-size: 13px; font-weight: 800; }
.searchbar input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--card2);
  color: var(--text);
}
.searchbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters button.active { background: var(--accent); color: var(--accent-dark); border-color: var(--accent); }
.recipe-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); gap: 14px; }
.recipe-card { display: flex; flex-direction: column; justify-content: space-between; gap: 13px; min-height: 270px; padding: 17px; }
.recipe-card h3 { margin: 9px 0; font-size: 20px; line-height: 1.25; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 18, .78);
  backdrop-filter: blur(8px);
}
.hidden { display: none !important; }
.modal-card {
  position: relative;
  width: min(780px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
}
.close { position: sticky; float: right; top: 0; width: 42px; height: 42px; padding: 0; border-radius: 999px; font-size: 26px; z-index: 2; }
.modal-card li { margin-bottom: 8px; line-height: 1.48; color: var(--muted); }
.recipe-note { padding: 12px; border-left: 3px solid var(--accent); background: var(--card2); }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
.loading-card, .error-card { display: grid; place-items: center; min-height: 220px; text-align: center; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { position: static; display: block; padding: 18px; }
  .top-actions { margin-top: 14px; }
  .tabs { top: 0; justify-content: stretch; }
  .tabs button { min-width: 0; flex: 1; }
  main { padding: 14px; }
  .hero { display: block; }
  .hero-total { margin-top: 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > button { width: 100%; }
  .macro { grid-template-columns: repeat(2, 1fr); }
  .recipe-list, .dayplan, .weekplan { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
  .modal-card { padding: 18px; border-radius: 18px; }
}
