/*
 * Gestaltung der Rezepte-App.
 *
 * Inhalt (von oben nach unten):
 *   Design-Variablen (hell und dunkel), Kopfleiste, Grundelemente, Filterleiste,
 *   Anmeldung, Rezept-Ansicht und -Formular, Essensplan (Kalender, Dialoge), Kochmodus,
 *   Tag-Menü, Wochenplan, Monatsansicht, Administration, Einkauf und Wiederholungen.
 *
 * Farben stehen als CSS-Variablen am Anfang. Die Akzentfarbe lässt sich in den Einstellungen ändern.
 */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f0eee7;
  --text: #1c1f1a;
  --muted: #62675f;
  --border: #dcd9cf;
  --accent: #2f7d5b;
  --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 12px rgba(0, 0, 0, .04);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121411;
  --surface: #1c1f1b;
  --surface-2: #171a16;
  --text: #e9ece6;
  --muted: #a0a79c;
  --border: #33372f;
  --danger: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: .2rem 0; }

main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }

/* Kopfleiste */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { margin-right: auto; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; max-width: 100%; overflow-x: auto; }
.topbar nav a {
  padding: .4rem .8rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Grundelemente */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .8rem 1rem;
  margin-bottom: 1rem;
}
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.stack { display: flex; flex-direction: column; gap: .8rem; }
.meta { color: var(--muted); font-size: .9rem; margin: .2rem 0; }
.hint { color: var(--muted); font-size: .88rem; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-state p { color: var(--muted); margin: 0 0 1rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: .6rem; color: var(--text); }
label.inline { flex-direction: row; align-items: center; gap: .4rem; }

input, select, textarea, button, .button {
  font: inherit;
  font-size: 1rem;
  min-height: 2.5rem;
  padding: .5rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
input, select, textarea { width: 100%; min-width: 0; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: var(--accent); }
input[type="color"] { width: 3.5rem; padding: .2rem; }
input.narrow { width: 6rem; }
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; }
button, .button {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { border-color: var(--border); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.icon-button { width: 2.5rem; padding: 0; font-size: 1.15rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.span-2 { grid-column: 1 / -1; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.chip, .tag {
  min-height: 0;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .85rem;
  border: 1px solid var(--border);
  background: var(--surface);
}
.tag { color: var(--muted); }
.chip small { opacity: .75; margin-left: .15rem; }
.chip.active, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: .8rem; }
.recipe-card { display: block; overflow: hidden; padding: 0; color: inherit; text-decoration: none; }
.recipe-card:hover { border-color: var(--accent); }
.recipe-card img, .placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}
.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.2rem; }
.card-body { padding: .6rem .75rem .75rem; }
.card-body h3 { overflow-wrap: anywhere; font-size: .98rem; }
.card-body .meta { font-size: .85rem; }
.card-body .chips { margin: .3rem 0 0; gap: .3rem; }
.card-body .tag { font-size: .78rem; padding: .05rem .5rem; }
.plan-card { display: block; color: inherit; text-decoration: none; }
.plan-card:hover { border-color: var(--accent); }
.result-line { margin: 0 0 .6rem; }

/* Filterleiste oben: auf dem PC über die volle Breite, auf dem Handy kompakt */
.filterbar { display: flex; flex-direction: column; gap: .7rem; margin-bottom: .6rem; padding: .8rem; }
.fb-main { display: flex; gap: .5rem; align-items: stretch; }
.fb-main input { flex: 1 1 auto; }
.fb-tags-toggle { flex: 0 0 auto; }
.fb-options { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.fb-scope { grid-column: 1 / -1; }
.fb-options select { min-width: 0; }
.fb-options .ghost { grid-column: 1 / -1; }
.fb-tags { display: none; flex-direction: column; gap: .7rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.fb-tags.open { display: flex; }
.fb-group { display: flex; flex-direction: column; gap: .35rem; }
.fb-group-title { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fb-group .chips { margin: 0; }
.fb-tags .chip { font-size: .88rem; }

/* Anmeldung */
.auth { max-width: 380px; margin: 2.5rem auto; }
.auth h1 { text-align: center; margin-bottom: 1.2rem; }
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.segmented button { flex: 1; border: 0; border-radius: 0; background: transparent; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }

/* Rezept-Ansicht */
.recipe-layout { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 1.2rem; align-items: start; }
.hero { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); margin: .5rem 0 1rem; }
.lead { font-size: 1.05rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { padding: .4rem 0; border-bottom: 1px dashed var(--border); }
.ingredients li.heading { font-weight: 700; color: var(--accent); border: 0; margin-top: .6rem; }
.amount { font-weight: 600; }
.steps { padding-left: 1.4rem; }
.steps li { margin: .6rem 0; }
.fields { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; }
.recipe-view section + section { margin-top: 1.2rem; }

/* Rezept-Formular */
.recipe-form section + section { margin-top: 1rem; }
.image-field { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 1rem; align-items: start; }
.image-preview {
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview span { font-size: 2rem; }
.import-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.import-row input { flex: 1 1 260px; }
.paste { margin-top: .8rem; }
.paste summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: .3rem 0; }
.paste[open] textarea { margin: .5rem 0; }
.tag-field { display: flex; flex-direction: column; gap: .6rem; }
.field-label { margin: 0 0 .3rem; font-size: .9rem; color: var(--muted); }

.rows { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.row { display: flex; gap: .4rem; align-items: center; }
.row textarea { flex: 1; }
.row-actions { display: flex; gap: .2rem; flex-shrink: 0; }
.row-actions button { min-height: 2.2rem; padding: .25rem .55rem; color: var(--muted); }
.ingredient-row {
  display: grid;
  grid-template-columns: 5rem 6.5rem minmax(0, 1fr) auto;
  grid-template-areas: "amount unit name actions";
  gap: .4rem;
  align-items: center;
}
.ingredient-row [data-f="amount"] { grid-area: amount; }
.ingredient-row [data-f="unit"] { grid-area: unit; }
.ingredient-row [data-f="name"] { grid-area: name; }
.ingredient-row .row-actions { grid-area: actions; }
.heading-row input { font-weight: 700; }
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: .4rem;
  align-items: center;
}
.step-no { min-width: 1.6rem; color: var(--muted); align-self: flex-start; padding-top: .55rem; }

/* Essensplan */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.plan-grid { width: 100%; min-width: 780px; border-collapse: separate; border-spacing: 0; }
.plan-grid th, .plan-grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .45rem; vertical-align: top; }
.plan-grid thead th { background: var(--surface-2); font-size: .9rem; text-align: center; font-weight: 600; }
.plan-grid tbody th { background: var(--surface-2); width: 8.5rem; text-align: left; font-weight: 600; }
.plan-grid thead th:first-child, .plan-grid tbody th { position: sticky; left: 0; z-index: 1; }
.plan-grid td { min-width: 120px; }
.entry {
  position: relative;
  margin-bottom: .4rem;
  padding: .35rem 1.8rem .35rem .5rem;
  border-radius: 8px;
  font-size: .9rem;
  overflow-wrap: anywhere;
  background: var(--accent-soft);
}
.entry a { font-weight: 600; text-decoration: none; }
.entry a:hover { text-decoration: underline; }
.entry small { display: block; color: var(--muted); }
.entry.missing { background: var(--surface-2); color: var(--muted); font-style: italic; }
.entry .icon-button { position: absolute; top: .15rem; right: .15rem; width: 1.8rem; min-height: 1.8rem; border: 0; background: transparent; font-size: .9rem; }
.add-entry { width: 100%; min-height: 2rem; border: 1px dashed var(--border); background: transparent; color: var(--muted); }
.add-entry:hover { color: var(--accent); }

details.card summary { cursor: pointer; font-weight: 600; }
details.card form { margin-top: .8rem; }


.swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.swatch { width: 2.2rem; height: 2.2rem; min-height: 0; padding: 0; border-radius: 50%; border: 2px solid var(--border); }
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
.color-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { flex: 1 1 200px; }

/* Dialog & Hinweis */
dialog {
  width: min(480px, calc(100vw - 2rem));
  max-height: 88vh;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; gap: .8rem; }
dialog h2 { margin: 0; }

.toast {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: .65rem 1.1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  z-index: 20;
  text-align: center;
}

.status-error { color: var(--danger); }
.invite-box { display: flex; flex-direction: column; gap: .6rem; margin: .4rem 0; }
.invite-box .inline-form input { flex: 1 1 260px; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .05em; }

.chip.empty { opacity: .45; }
.tag-summary { margin: 0; font-weight: 600; color: var(--accent); }

/* Kochmodus */
.cook { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.cook-head { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; padding: .6rem .9rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.cook-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook-timer-live { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.cook-body { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: 1fr; }
.cook-ingredients { display: none; padding: 1rem; background: var(--surface); border-bottom: 1px solid var(--border); max-height: 55vh; overflow: auto; }
.cook-ingredients.open { display: block; }
.cook-main { padding: 1.5rem 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.cook-count { margin: 0; color: var(--muted); font-weight: 600; }
.cook-progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.cook-progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.cook-text { font-size: clamp(1.35rem, 3.6vw, 2.1rem); line-height: 1.5; margin: .5rem 0; white-space: pre-wrap; }
.cook-timer { display: flex; gap: .6rem; flex-wrap: wrap; }
.cook-nav { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .7rem .9rem; padding-bottom: max(.7rem, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.cook-nav button { min-height: 3.2rem; font-size: 1.1rem; }
.cook-finished { text-align: center; padding: 2rem 0; }
.cook-toggle { display: inline-flex; }
.check-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.check-list li { padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.check-list li.done { opacity: .5; text-decoration: line-through; }
.check-list label { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check-list input { width: 1.3rem; height: 1.3rem; margin-top: .15rem; flex: none; }
.check-list .check-heading { font-weight: 700; color: var(--accent); border: 0; margin-top: .6rem; }

/* PC */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
}
@media (min-width: 900px) {
  .recipe-layout { grid-template-columns: minmax(220px, 1fr) 2fr; }
  .filterbar { position: sticky; top: 4.2rem; z-index: 4; }
  .fb-options { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .fb-scope { width: auto; }
  .fb-options select { width: auto; min-width: 11rem; }
  .fb-options .ghost { grid-column: auto; width: auto; }
  .fb-tags-toggle { display: none; }
  .fb-tags { display: flex; flex-direction: row; flex-wrap: wrap; gap: .6rem 1.6rem; padding-top: .7rem; }
  .fb-group { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; }
  .fb-group-title { min-width: 7rem; }
  .cook-body { grid-template-columns: 340px 1fr; }
  .cook-ingredients { display: block; max-height: none; border-bottom: 0; border-right: 1px solid var(--border); }
  .cook-toggle { display: none; }
  .cook-main { padding: 2.5rem 3rem; justify-content: center; }
  .cook-nav { padding-left: 3rem; padding-right: 3rem; }
}

/* Tag-Menü in der Filterleiste */
.fb-main { display: flex; gap: .5rem; align-items: center; }
.fb-main input { flex: 1 1 auto; }
.tag-menu { position: relative; flex: 0 0 auto; }
.tag-menu-btn { list-style: none; cursor: pointer; gap: .45rem; }
.tag-menu-btn::-webkit-details-marker { display: none; }
.tag-menu-btn::after { content: "▾"; font-size: .8rem; color: var(--muted); }
.tag-menu[open] .tag-menu-btn { border-color: var(--accent); }
.tag-menu-count:not(:empty) {
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: .8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tag-panel {
  margin-top: .5rem;
  padding: .9rem;
  display: grid;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.tag-group-title { margin: 0 0 .45rem; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tag-options { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-option {
  min-height: 2rem;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .9rem;
  background: var(--bg);
}
.tag-option small { color: var(--muted); font-size: .75rem; margin-left: .15rem; }
.tag-option[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tag-option[aria-pressed="true"] small { color: var(--accent-text); opacity: .85; }
.fb-selected { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.fb-selected:empty { display: none; }
.fb-selected .hint { margin-right: .2rem; }
.link-button { min-height: 0; padding: .2rem .4rem; border: 0; background: transparent; color: var(--accent); }
.result-line { margin: .2rem 0 .6rem; }

/* Zurück-Link auf der Rezeptseite */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-bottom: .6rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

/* Wochenplan: Kalender-Stil */
.slot-0 { --slot: #2f7d5b; }
.slot-1 { --slot: #2563eb; }
.slot-2 { --slot: #d97706; }
.slot-3 { --slot: #7c3aed; }
.slot-4 { --slot: #db2777; }

.cal-week { display: none; }
@media (min-width: 760px) {
  .cal-week {
    display: grid;
    grid-template-columns: 8rem repeat(7, minmax(7.5rem, 1fr));
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .cal-weeklist { display: none; }
}
.cal-corner, .cal-dayhead { background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-dayhead { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .6rem .3rem; }
.cal-dow { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cal-date { min-width: 2.1rem; padding: .05rem .4rem; border-radius: 999px; text-align: center; font-size: 1.05rem; font-weight: 700; }
.cal-dayhead.today .cal-date { background: var(--accent); color: var(--accent-text); }
.cal-slot {
  padding: .6rem .6rem;
  font-weight: 600;
  font-size: .9rem;
  background: var(--surface-2);
  border-left: 4px solid var(--slot);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-cell {
  position: relative;
  min-height: 6rem;
  padding: .35rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-cell.today { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-add {
  min-height: 1.6rem;
  width: 100%;
  padding: 0;
  font-size: .8rem;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  opacity: 0;
}
.cal-cell:hover .cal-add, .cal-add:focus { opacity: 1; }
.cal-add:hover { color: var(--accent); border-color: var(--accent); }

.event {
  display: block;
  width: 100%;
  min-height: 0;
  padding: .4rem .55rem;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--slot);
  border-radius: 8px;
  background: color-mix(in srgb, var(--slot) 16%, var(--surface));
  color: var(--text);
  font-size: .85rem;
  line-height: 1.3;
  cursor: pointer;
}
.event:hover { filter: brightness(.97); }
.event-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.event-sub { display: block; font-size: .78rem; color: var(--muted); }
.event.missing { font-style: italic; color: var(--muted); }

/* Tagesansicht */
.agenda-title { margin: 0 0 .7rem; font-size: 1.1rem; }
.agenda-slot { padding: .1rem 0 .1rem .85rem; margin-bottom: 1.1rem; border-left: 4px solid var(--slot); }
.agenda-slot h3 { margin: 0 0 .45rem; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.agenda-slot .event { margin-bottom: .45rem; }
.cal-add-wide {
  width: 100%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
}
.cal-add-wide:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 899px) {
  .fb-main { flex-wrap: wrap; }
  .fb-main input { flex-basis: 100%; }
  .tag-menu { flex: 1 1 100%; }
  .tag-menu-btn { width: 100%; justify-content: space-between; }
  .tag-panel { grid-template-columns: 1fr; }
}
@media (min-width: 900px) {
  .tag-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    width: min(760px, 85vw);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tag-menu { position: static; }
  .fb-main { position: relative; }
}

/* Handy */
@media (max-width: 900px) {
  .hero { max-height: 300px; }
}

@media (max-width: 640px) {
  main { padding: 1rem .7rem 4rem; }
  h1 { font-size: 1.35rem; }
  .page-head { margin-bottom: .7rem; }
  .topbar { padding: .55rem .75rem; }
  .topbar nav { order: 3; width: 100%; padding-bottom: .15rem; }
  .card { padding: .85rem; }
  .filterbar { padding: .7rem; gap: .6rem; }
  .fb-main input { font-size: 1rem; }
  .auth { margin: 1.2rem auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .recipe-layout { grid-template-columns: 1fr; }
  .image-field { grid-template-columns: 1fr; }
  .image-preview { max-width: 240px; }
  .ingredient-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas: "amount unit actions" "name name name";
  }
  .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .page-head .actions { width: 100%; }
  .page-head .actions .button, .page-head .actions button { flex: 1 1 auto; }
  .plan-grid { min-width: 720px; }
  dialog { width: calc(100vw - 1.5rem); padding: 1rem; }
  .recipe-view .page-head .actions .button,
  .recipe-view .page-head .actions button { flex: 1 1 calc(50% - .5rem); }
}

/* Ansicht-Umschalter und Zeitraum-Navigation */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; }
.cal-nav { display: flex; gap: .4rem; }
.view-switch { flex: 0 1 auto; min-width: 16rem; }
.segmented a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: .4rem .8rem;
  color: var(--text);
  text-decoration: none;
}
.segmented a.active { background: var(--accent); color: var(--accent-text); }

/* Wochenliste auf dem Handy */
.cal-weeklist { display: block; }
@media (min-width: 760px) {
  .cal-weeklist { display: none; }
}
.wl-day {
  margin-bottom: .9rem;
  padding: .7rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.wl-day.today { border-color: var(--accent); }
.wl-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.wl-head a { font-size: .9rem; }
.wl-day .event { margin-bottom: .4rem; }

/* Monatsansicht */
.cal-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mo-head {
  padding: .45rem 0;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.mo-day {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
  min-height: 5.5rem;
  padding: .35rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.mo-day:nth-child(7n) { border-right: 0; }
.mo-day:hover { background: var(--surface-2); }
.mo-day.outside { color: var(--muted); opacity: .55; }
.mo-day.today { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.mo-num { align-self: flex-start; min-width: 1.7rem; padding: 0 .3rem; border-radius: 999px; text-align: center; font-size: .9rem; font-weight: 600; }
.mo-day.today .mo-num { background: var(--accent); color: var(--accent-text); }
.mo-titles { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.mo-title {
  display: block;
  padding: .1rem .35rem;
  border-left: 3px solid var(--slot);
  border-radius: 4px;
  background: color-mix(in srgb, var(--slot) 16%, var(--surface));
  font-size: .78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mo-more { font-size: .72rem; color: var(--muted); }
.mo-dots { display: none; flex-wrap: wrap; gap: .2rem; }
.mo-dot { width: .45rem; height: .45rem; border-radius: 50%; background: var(--slot); }
@media (max-width: 759px) {
  .mo-day { align-items: center; min-height: 3.4rem; }
  .mo-num { align-self: center; }
  .mo-titles { display: none; }
  .mo-dots { display: flex; justify-content: center; }
}

/* Scrollbare Listen in der Administration */
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.list-head h3 { margin-bottom: .4rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.filter-row input { flex: 1 1 12rem; }
.filter-row select { flex: 0 0 auto; width: auto; }
.scroll-box { max-height: min(22rem, 55vh); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.scroll-box .admin-table { margin: 0; }
.scroll-box .admin-table th, .scroll-box .admin-table td { padding-left: .6rem; padding-right: .6rem; }
.scroll-box thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }

/* Einkaufsliste mit Auswahl */
.shop-pick { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .25rem; max-height: min(24rem, 50vh); overflow: auto; }
.check-row { display: flex; flex-direction: row; align-items: flex-start; gap: .6rem; padding: .35rem .5rem; border-radius: 8px; cursor: pointer; }
.check-row:hover { background: var(--surface-2); }
.check-row input { margin-top: .25rem; }

/* Mitglieder im Plan */
.member-list { list-style: none; margin: 0 0 .6rem; padding: 0; }
.member-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.link-button.danger { color: var(--danger); }

/* Termine dürfen umbrechen, sonst laufen lange Titel über den Zellenrand */
.event { white-space: normal; }

/* Wiederholungen im Termin-Dialog */
.repeat-box { padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.weekday-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.weekday-row .check-row { padding: .3rem .6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; }
.weekday-row .check-row input { margin: 0; }
