/* ── Familienküche — Stylesheet ─────────────────────────── */
/* Typografie: Playfair Display + Source Serif 4             */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Source+Serif+4:ital,wght@0,300;0,400;1,300&display=swap');

/* ── Design-Token ─────────────────────────────────────────── */
:root {
  --braun-dunkel:  #2C1A0E;
  --braun-mittel:  #5C3317;
  --braun-hell:    #8C6A4A;
  --gold:          #C8954A;
  --gold-hell:     #F0C070;
  --creme:         #FDF6EE;
  --creme-dunkel:  #F5EBD8;
  --creme-rand:    #E8D5C0;
  --weiss:         #FFFDF8;
  --gruen:         #4CAF50;
  --rot:           #E57373;
  --text:          #2C1A0E;
  --text-weich:    #8C6A4A;
  --bg-warm:       #FDF6EE;

  --radius-s:  6px;
  --radius-m:  12px;
  --radius-l:  20px;
  --schatten:  0 2px 12px rgba(44,26,14,.10);
  --schatten-l: 0 8px 32px rgba(44,26,14,.15);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--creme);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--braun-mittel); }

img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────── */
.wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--braun-dunkel) 0%, var(--braun-mittel) 100%);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(44,26,14,.3);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: 960px;
  margin: 0 auto;
}

.site-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--creme);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-logo span { color: var(--gold); }

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: 32px;
}

.site-nav a {
  color: rgba(253,246,238,.7);
  padding: 7px 14px;
  border-radius: var(--radius-m);
  font-size: .9rem;
  transition: background .2s, color .2s;
}
.site-nav a:hover,
.site-nav a.aktiv {
  background: rgba(200,149,74,.25);
  color: var(--gold-hell);
}

/* ── KW-Navigation ────────────────────────────────────────── */
.kw-nav {
  background: var(--braun-dunkel);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: .9rem;
}
.kw-nav a {
  color: var(--gold);
  padding: 4px 12px;
  border: 1px solid rgba(200,149,74,.4);
  border-radius: 20px;
  transition: background .2s;
}
.kw-nav a:hover { background: rgba(200,149,74,.2); }
.kw-nav strong { color: var(--creme); }

/* ── Flash-Nachrichten ────────────────────────────────────── */
.flash {
  padding: 12px 20px;
  border-radius: var(--radius-m);
  margin: 20px 0;
  font-size: .95rem;
}
.flash.ok  { background: #E8F5E9; border-left: 4px solid var(--gruen); color: #2E7D32; }
.flash.err { background: #FFEBEE; border-left: 4px solid var(--rot);   color: #C62828; }

/* ── Wochenplan-Grid ──────────────────────────────────────── */
.wochenplan-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin: 24px 0;
}

@media (max-width: 700px) {
  .wochenplan-grid { grid-template-columns: 1fr; }
}

.tag-karte {
  background: var(--weiss);
  border: 2px solid var(--creme-rand);
  border-radius: var(--radius-m);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--schatten);
  transition: border-color .2s, box-shadow .2s;
  min-height: 160px;
}
.tag-karte:hover { border-color: var(--gold); box-shadow: var(--schatten-l); }
.tag-karte.heute { border-color: var(--gold); background: #FFF9F2; }

.tag-label {
  font-family: 'Playfair Display', serif;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-weich);
}
.tag-label.heute-label { color: var(--gold); font-weight: 600; }

.mahlzeit-emoji { font-size: 2rem; line-height: 1; }

.mahlzeit-name {
  font-size: .85rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
}

.tag-karte .badge-reihe { display: flex; flex-wrap: wrap; gap: 3px; }

.tag-aktionen {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tag-leer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 6px;
  color: var(--creme-rand);
}
.tag-leer-icon { font-size: 1.8rem; }
.tag-leer p { font-size: .8rem; color: var(--text-weich); opacity: .7; }

/* ── Mahlzeit-Slots (Mittag / Abend) ─────────────────────── */
.mahlzeit-slot {
  border: 1px solid var(--creme-rand);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mahlzeit-slot-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-weich);
  font-weight: 600;
}

/* ── Personen-Anzeige ─────────────────────────────────────── */
.personen-info {
  font-size: .78rem;
  color: var(--text-weich);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius-s);
  border: none;
  cursor: pointer;
  font-family: 'Source Serif 4', serif;
  font-size: .85rem;
  font-weight: 400;
  transition: background .2s, transform .1s, box-shadow .2s;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(.97); }

.btn-gold {
  background: var(--gold);
  color: var(--braun-dunkel);
  font-weight: 600;
}
.btn-gold:hover { background: var(--gold-hell); color: var(--braun-dunkel); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--creme-rand);
  color: var(--text-weich);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); background: none; }

.btn-ghost {
  background: rgba(200,149,74,.12);
  color: var(--gold);
  border: 1px solid rgba(200,149,74,.3);
  padding: 5px 10px;
  font-size: .78rem;
}
.btn-ghost:hover { background: rgba(200,149,74,.25); color: var(--gold); }

.btn-danger {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #FFCDD2;
  padding: 5px 10px;
  font-size: .78rem;
}
.btn-danger:hover { background: #FFCDD2; }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── Cards / Panels ───────────────────────────────────────── */
.card {
  background: var(--weiss);
  border: 1.5px solid var(--creme-rand);
  border-radius: var(--radius-l);
  padding: 24px;
  box-shadow: var(--schatten);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--creme-rand);
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--text);
}

/* ── Badges / Tags ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  color: #fff;
  white-space: nowrap;
}

/* ── Tabellen ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-weich); background: var(--creme-dunkel); }
tr:not(:last-child) td { border-bottom: 1px solid var(--creme-rand); }
tr:hover td { background: #FFF9F2; }

/* ── Formulare ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .85rem; color: var(--text-weich); margin-bottom: 5px; }

input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--creme-rand);
  border-radius: var(--radius-s);
  background: var(--creme);
  color: var(--text);
  font-family: 'Source Serif 4', serif;
  font-size: .95rem;
  transition: border-color .2s;
  appearance: none;
}
input[type=text]:focus, input[type=number]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--weiss);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238C6A4A'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Einkaufsliste ────────────────────────────────────────── */
.einkauf-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--creme-rand);
}
.einkauf-item:last-child { border-bottom: none; }

.einkauf-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: none;
  transition: background .2s, border-color .2s;
}
.einkauf-check.erledigt {
  background: var(--gruen);
  border-color: var(--gruen);
}

.einkauf-artikel {
  flex: 1;
  font-size: .95rem;
}
.einkauf-artikel.erledigt {
  text-decoration: line-through;
  color: var(--text-weich);
  opacity: .6;
}

.einkauf-menge {
  font-size: .85rem;
  color: var(--text-weich);
  white-space: nowrap;
}

/* ── Familienmitglieder ───────────────────────────────────── */
.familie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.mitglied-karte {
  background: var(--creme);
  border: 1.5px solid var(--creme-rand);
  border-radius: var(--radius-m);
  padding: 16px;
  text-align: center;
}

.mitglied-emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 8px;
}

.mitglied-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  margin-bottom: 10px;
}

.praef-gruppe { margin-top: 8px; }
.praef-label { font-size: .72rem; color: var(--text-weich); margin-bottom: 4px; }

/* ── KI-Vorschlag Panel ───────────────────────────────────── */
.ki-panel {
  background: linear-gradient(135deg, #FFF3E0, #FFF8F0);
  border: 2px solid #FFB74D;
  border-radius: var(--radius-l);
  padding: 20px;
  margin: 20px 0;
}

.ki-titel {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--braun-mittel);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.ki-label {
  font-size: .72rem;
  background: #FFE0B2;
  color: #E65100;
  padding: 2px 8px;
  border-radius: 10px;
}

.vorschlag-liste {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vorschlag-item {
  background: var(--weiss);
  border: 1.5px solid #FFD0A0;
  border-radius: var(--radius-m);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.vorschlag-emoji { font-size: 1.6rem; }
.vorschlag-info { flex: 1; }
.vorschlag-name { font-size: .95rem; color: var(--text); }
.vorschlag-grund { font-size: .78rem; color: var(--text-weich); font-style: italic; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(44,26,14,.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.offen { display: flex; }

.modal {
  background: var(--weiss);
  border-radius: var(--radius-l);
  padding: 28px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--schatten-l);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-titel {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  margin-bottom: 20px;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  margin-top: 60px;
  padding: 24px 20px;
  border-top: 1px solid var(--creme-rand);
  text-align: center;
  font-size: .8rem;
  color: var(--text-weich);
}

/* ── Utilities ────────────────────────────────────────────── */
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.flex  { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-weich { color: var(--text-weich); }
.text-sm { font-size: .85rem; }
.playfair { font-family: 'Playfair Display', serif; }
.text-center { text-align: center; }

/* ── iPhone / Safe-Area Support ───────────────────────────── */
@supports (padding: env(safe-area-inset-top)) {
  .site-header { padding-top: env(safe-area-inset-top); }
  body         { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Mobile (≤ 700px) — Wochenplan already handled ────────── */

/* ── Mobile (≤ 480px) — General iPhone optimisations ──────── */
@media (max-width: 480px) {

  /* Header */
  .header-inner {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .site-logo {
    font-size: 1.1rem;
    gap: 6px;
  }
  .site-nav {
    order: 3;
    width: 100%;
    justify-content: space-around;
    border-top: 1px solid rgba(200,149,74,.15);
    padding-top: 4px;
    padding-bottom: 2px;
  }
  .site-nav a {
    padding: 5px 6px;
    font-size: .72rem;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    border-radius: var(--radius-s);
    min-height: 44px;
    justify-content: center;
  }

  /* Layout */
  .wrapper { padding: 0 10px; }

  /* KW navigation */
  .kw-nav {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    font-size: .82rem;
  }

  /* Cards */
  .card {
    padding: 14px;
    border-radius: var(--radius-m);
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  /* Wochenplan day cards (already 1-col at 700px, improve layout) */
  .tag-karte {
    min-height: 90px;
    padding: 10px 12px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
  }
  .tag-label  { width: 100%; }
  .tag-aktionen { flex-direction: row; gap: 6px; }

  /* Familie grid: 2-up on mobile */
  .familie-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  /* Buttons: minimum 44px touch target */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Modal: slide up from bottom on iPhone */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    padding: 20px 16px 28px;
    max-height: 88vh;
  }

  /* Tables: make scrollable */
  .card > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Einkauf items: easier touch */
  .einkauf-item { padding: 12px 0; gap: 14px; }
  .einkauf-check { width: 26px; height: 26px; }

  /* Vorschlag items */
  .vorschlag-item { flex-wrap: wrap; }
  .vorschlag-item .btn { margin-left: auto; }

  /* KI Panel */
  .ki-panel { padding: 14px; }
  .ki-titel { font-size: .9rem; flex-wrap: wrap; gap: 6px; }

  /* Footer */
  .site-footer { padding: 16px 12px; margin-top: 40px; }
}

/* ── Narrow iPhones (≤ 390px — iPhone 12/13/14) ────────────── */
@media (max-width: 390px) {
  .site-logo { font-size: 1rem; }
  .site-nav a { font-size: .68rem; padding: 4px 4px; }
  .card { padding: 12px; }
  .modal { padding: 16px 12px 24px; }
  .wrapper { padding: 0 8px; }
}
