/* Essensplaner – Gestaltung
   Farben: Salbei-Papier als Grund, tiefes Mangold-Grün als Aktion,
   je Mahlzeit eine eigene Farbe (Hafer · Kräuter · Rote Bete). */

:root {
  --bg: #EEF1EA;
  --surface: #FBFCF9;
  --surface-2: #E3E8DF;
  --ink: #16211B;
  --muted: #58655D;
  --line: #D2D9CD;
  --accent: #1D5C45;
  --accent-ink: #F3FAF6;
  --accent-soft: #D5E6DB;
  --meal-f: #9A6412;
  --meal-m: #3A7A4A;
  --meal-a: #A2365A;
  --kids-bg: #FBEFC4;
  --kids-ink: #664A00;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(22, 33, 27, .06), 0 8px 24px rgba(22, 33, 27, .08);

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;
  --t-xs: .8125rem;
  --t-sm: .9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.25rem;
  --t-xl: 1.625rem;
  --t-2xl: 2.125rem;
  --r: 12px;
  --r-sm: 8px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1512;
    --surface: #18201B;
    --surface-2: #222C26;
    --ink: #E3ECE5;
    --muted: #97A59C;
    --line: #2C3831;
    --accent: #86D0A8;
    --accent-ink: #0C1E15;
    --accent-soft: #1E392C;
    --meal-f: #E6B24E;
    --meal-m: #8BC898;
    --meal-a: #E583A4;
    --kids-bg: #3A3114;
    --kids-ink: #F4D77A;
    --danger: #F2837B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #0F1512;
  --surface: #18201B;
  --surface-2: #222C26;
  --ink: #E3ECE5;
  --muted: #97A59C;
  --line: #2C3831;
  --accent: #86D0A8;
  --accent-ink: #0C1E15;
  --accent-soft: #1E392C;
  --meal-f: #E6B24E;
  --meal-m: #8BC898;
  --meal-a: #E583A4;
  --kids-bg: #3A3114;
  --kids-ink: #F4D77A;
  --danger: #F2837B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-md)/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: var(--t-xl); font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: var(--t-lg); font-weight: 650; }
p { margin: 0; }
.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.label {
  font-size: var(--t-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App-Rahmen ---------- */

.app { min-height: 100vh; }
.main {
  max-width: 1120px; margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: var(--t-xs); font-weight: 700;
}
.nav a .ic { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav .brand, .nav .nav-extra { display: none; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; padding: 24px 12px;
    display: flex; flex-direction: column; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav .brand {
    display: block; font-family: var(--f-display); font-weight: 800; font-size: var(--t-lg);
    letter-spacing: -.02em; padding: 0 12px 20px; color: var(--ink);
  }
  .nav .brand small { display: block; font: 400 var(--t-xs)/1.3 var(--f-body); color: var(--muted); letter-spacing: 0; }
  .nav a {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--t-sm);
  }
  .nav a:hover { background: var(--surface-2); color: var(--ink); }
  .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
  .nav .nav-extra { display: flex; margin-top: auto; }
  .main { padding: 32px 32px 64px; width: 100%; }
  .no-desktop { display: none !important; }
}

.topbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px;
  margin-bottom: 20px;
}
.topbar .sub { color: var(--muted); font-size: var(--t-sm); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--muted);
  padding: 4px 10px; border-radius: 99px; background: var(--surface-2);
}
.status-pill.warn { color: var(--kids-ink); background: var(--kids-bg); }

/* ---------- Buttons & Chips ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: var(--t-sm); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 56px; font-size: var(--t-md); padding: 12px 22px; border-radius: var(--r); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn[aria-pressed="true"] { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 14px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  font-size: var(--t-sm); font-weight: 700; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-xs); font-weight: 700;
  padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag.kids { background: var(--kids-bg); color: var(--kids-ink); }
.tag.exotic { background: var(--accent-soft); color: var(--ink); }
.tag .ic { width: 14px; height: 14px; }

/* ---------- Wochenplan ---------- */

.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav h1 { min-width: 0; }

.hint {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 16px;
  border-radius: var(--r); background: var(--accent-soft); font-size: var(--t-sm);
}
.hint .ic { color: var(--accent); margin-top: 2px; }

.week { display: grid; gap: 10px; }
.dayrow {
  display: grid; gap: 8px; padding: 12px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
}
.dayrow.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dayrow.past { opacity: .62; }
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dayname { font-family: var(--f-display); font-weight: 700; font-size: var(--t-lg); letter-spacing: -.01em; }
.dayname small { font: 400 var(--t-sm) var(--f-body); color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.today-mark { font-size: var(--t-xs); font-weight: 700; color: var(--accent); margin-left: 6px; }

.people {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  font-size: var(--t-sm); font-weight: 700; color: var(--muted);
}
.people[aria-pressed="true"] { background: var(--kids-bg); border-color: transparent; color: var(--kids-ink); }

.slots { display: grid; gap: 6px; }
.slot {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px;
  width: 100%; min-height: 56px; padding: 8px 12px; text-align: left;
  border-radius: var(--r-sm); border: 1px solid transparent; background: var(--surface-2);
}
.slot:hover { border-color: var(--line); }
.slot .meal { font-size: var(--t-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.slot[data-meal="f"] .meal { color: var(--meal-f); }
.slot[data-meal="m"] .meal { color: var(--meal-m); }
.slot[data-meal="a"] .meal { color: var(--meal-a); }
.slot .title { grid-column: 1; font-weight: 700; line-height: 1.25; }
.slot .meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--t-xs); color: var(--muted); }
.slot .side { grid-column: 2; grid-row: 1 / span 3; display: flex; gap: 2px; color: var(--muted); }
.slot.empty { background: transparent; border: 1.5px dashed var(--line); }
.slot.empty .title { color: var(--muted); font-weight: 400; }
.slot.off { background: transparent; min-height: 40px; }
.slot.off .title { color: var(--muted); font-weight: 400; font-size: var(--t-sm); }

@media (min-width: 760px) {
  .dayrow { grid-template-columns: 150px 1fr; align-items: start; }
  .dayhead { flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 4px; }
  .dayname small { display: block; margin: 2px 0 0; }
  .dayname .today-mark { margin-left: 0; }
  .slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot { align-self: stretch; }
}

/* ---------- Heute ---------- */

.today-grid { display: grid; gap: 12px; }
.meal-card {
  display: grid; gap: 10px; padding: 18px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
}
.meal-card h2 { font-size: var(--t-xl); }
.meal-card .meal { font-size: var(--t-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.meal-card[data-meal="f"] .meal { color: var(--meal-f); }
.meal-card[data-meal="m"] .meal { color: var(--meal-m); }
.meal-card[data-meal="a"] .meal { color: var(--meal-a); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--kids-bg); color: var(--kids-ink); font-size: var(--t-sm); font-weight: 700;
}
.tomorrow { margin-top: 28px; display: grid; gap: 10px; }
.tomorrow ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.tomorrow li { display: flex; gap: 10px; align-items: baseline; }
.sos { margin-top: 28px; }
@media (min-width: 760px) { .today-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Kochbuch ---------- */

.searchbar { position: relative; margin-bottom: 12px; }
.searchbar .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbar input { padding-left: 44px; }
.rlist { display: grid; gap: 8px; margin-top: 16px; }
@media (min-width: 760px) { .rlist { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rrow {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit; text-align: left; width: 100%;
}
.rrow:hover { border-color: var(--muted); }
.rrow .title { font-weight: 700; line-height: 1.3; }
.rrow .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--t-xs); color: var(--muted); }
.rrow .fav { color: var(--meal-a); }
.mealdots { display: inline-flex; gap: 3px; }
.mealdots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.mealdots i.on-f { background: var(--meal-f); }
.mealdots i.on-m { background: var(--meal-m); }
.mealdots i.on-a { background: var(--meal-a); }

.recipe-head { display: grid; gap: 12px; margin-bottom: 24px; }
.recipe-head .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.recipe-body { display: grid; gap: 28px; }
@media (min-width: 900px) { .recipe-body { grid-template-columns: minmax(260px, 1fr) 1.6fr; align-items: start; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.ing-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 0; }
.ing-list li { display: grid; grid-template-columns: 6.5em 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ing-list li:last-child { border-bottom: 0; }
.ing-list .amt { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 16px; counter-reset: step; max-width: 62ch; }
.steps li { display: grid; grid-template-columns: 2.25rem 1fr; gap: 12px; counter-increment: step; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--ink); font-family: var(--f-display); font-weight: 700;
}
.stepper { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 2px; background: var(--surface); }
.stepper output { min-width: 7.5em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip { margin-top: 16px; font-size: var(--t-sm); color: var(--muted); }

/* ---------- Kochmodus ---------- */

.cook { max-width: 720px; margin: 0 auto; display: grid; gap: 20px; }
.cook-progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.cook-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }
.cook-step {
  min-height: 42vh; display: grid; align-content: center; gap: 16px; padding: 28px 24px;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
}
.cook-step .count { font-family: var(--f-display); font-weight: 700; color: var(--accent); }
.cook-step p { font-size: clamp(1.35rem, 3.6vw, 1.9rem); line-height: 1.4; }
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checklist label {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 4px; border-bottom: 1px solid var(--line);
  font-size: var(--t-lg);
}
.checklist input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }

/* ---------- Einkaufsliste ---------- */

.shop-days { margin-bottom: 16px; }
.shop-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 20px; }
.shop-group { margin-bottom: 20px; }
.shop-group h3 { font: 700 var(--t-xs)/1.2 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.shop-items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.shop-items li + li { border-top: 1px solid var(--line); }
.shop-items label { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; cursor: pointer; }
.shop-items input { width: 22px; height: 22px; accent-color: var(--accent); }
.shop-items .amt { font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--t-sm); text-align: right; }
.shop-items .uses { display: block; font-size: var(--t-xs); color: var(--muted); }
.shop-items input:checked ~ span { color: var(--muted); text-decoration: line-through; }
.pantry { font-size: var(--t-sm); color: var(--muted); }

/* ---------- Formulare ---------- */

.field { display: grid; gap: 6px; }
.field > span { font-size: var(--t-sm); font-weight: 700; }
.field small { color: var(--muted); font-size: var(--t-xs); }
input[type="text"], input[type="number"], input[type="search"], input[type="url"], input[type="password"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea { min-height: 140px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: var(--t-sm); }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.settings { display: grid; gap: 20px; max-width: 640px; }
.settings section { display: grid; gap: 14px; }

/* ---------- Sheet (Auswahl-Fenster) ---------- */

.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 16, 13, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 90vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-head .sub { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }
.sheet-section { display: grid; gap: 8px; margin-bottom: 20px; }
.option-list { display: grid; gap: 8px; }
.option-list .rrow { background: var(--surface); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 760px) {
  .backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 18px; padding-bottom: 24px; }
  .sheet-grip { display: none; }
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 99px; background: var(--surface-2); margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 99px; background: transparent; font-weight: 700; font-size: var(--t-sm); color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.thinking { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r); background: var(--surface); color: var(--muted); }
.thinking::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--danger); font-size: var(--t-sm); font-weight: 700; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); padding: 10px 10px 10px 16px; border-radius: var(--r);
  background: var(--ink); color: var(--bg); font-size: var(--t-sm); font-weight: 700; box-shadow: var(--shadow);
}
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 700; text-decoration: underline; min-height: 36px; padding: 0 8px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------- Anmeldung ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 16px; }
.login-card h1 { font-size: var(--t-2xl); }

.empty-state { padding: 28px; border-radius: var(--r); border: 1.5px dashed var(--line); text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .nav, .topbar .actions, .shop-days, .shop-summary .actions, .toast, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .main { padding: 0; }
  .shop-items { border: 0; }
  .shop-items label { min-height: 0; padding: 3px 0; }
}
