:root {
  --bg: #0f1420;
  --bg-panel: #171e2e;
  --bg-raised: #1f2941;
  --line: #2a3450;
  --text: #eaf0ff;
  --text-dim: #93a0bd;
  --accent: #4f8cff;
  --danger: #ff6b6b;
  --ok: #38c172;
  --radius: 18px;
  --gap: 18px;
}

/* `hidden` heisst versteckt — auch bei Elementen, deren Klasse display:flex
   setzt (.panel, .check-row …). Sonst standen Picnic- und Gmail-Bereich in den
   Einstellungen da, obwohl nichts eingerichtet ist. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  padding: var(--gap);
  gap: var(--gap);
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--gap);
}

.clock .time {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock .date {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-top: 4px;
}

.status-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
}

.status-chip[hidden] { display: none; }
.status-chip.stale { color: var(--text-dim); border-style: dashed; }
.status-chip.full { border-color: var(--ok); }
.status-chip.low { border-color: var(--danger); }
button.status-chip { font: inherit; font-size: 0.95rem; cursor: pointer; }
.geraete-chip.an { border-color: #f6c445; }

/* ---------------------------------------------------------------- geraete */

.modal.modal-geraete { width: min(720px, 100%); } /* .modal steht weiter unten und würde sonst gewinnen */
.geraete {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(180px, 40vw), 1fr));
  gap: 10px;
}
.geraet {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.geraet.an { border-color: #f6c445; background: #2e2a1f; }
.geraet.offline { opacity: 0.6; border-style: dashed; }
.geraet-kopf {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}
.geraet-kopf:disabled { cursor: default; }
/* Symbol über dem Namen — daneben bricht „Kaffeemaschine“ mitten im Wort. */
.geraet-symbol { font-size: 1.6rem; line-height: 1; flex: none; }
.geraet-name { font-weight: 600; font-size: 1.05rem; overflow-wrap: break-word; hyphens: auto; }
@media (max-width: 620px) {
  .geraet-name { font-size: 1rem; }
}
.geraet-zustand { color: var(--text-dim); font-size: 0.9rem; }
.geraet.an .geraet-zustand { color: #f6c445; }
.geraet input[type="range"] { width: 100%; accent-color: #f6c445; height: 32px; margin: 0; }
.geraet-rollo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.geraet-rollo .ghost-btn { padding: 10px 0; font-size: 1.1rem; }
.geraet.busy { opacity: 0.7; pointer-events: none; }

.app-title {
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.topbar-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Die Infozeile: schmal, aber auf dem Tablet aus zwei Metern lesbar. */
.noteline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1.05rem;
  font-family: inherit;
  cursor: pointer;
}

.noteline[hidden] { display: none; }

/* Ohne Notizen bleibt sie als dezente Einladung stehen. */
.noteline.empty {
  color: var(--text-dim);
  border-style: dashed;
  background: transparent;
}
.noteline-icon { flex: none; }

.noteline-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.noteline-count {
  flex: none;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.notes-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }

.note-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-raised);
  border-radius: 12px;
  padding: 12px 14px;
}

.note-item .note-body { flex: 1; min-width: 0; }
.note-item .note-text { overflow-wrap: anywhere; }
.note-item .note-meta { color: var(--text-dim); font-size: 0.82rem; margin-top: 3px; }

.check-row { display: flex; align-items: center; gap: 10px; color: var(--text-dim); }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync {
  color: var(--text-dim);
  font-size: 0.85rem;
  min-width: 5.5rem;
  text-align: right;
}

.sync.error { color: var(--danger); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1.5rem;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn:active { background: var(--bg-raised); }

/* ------------------------------------------------------------------ layout */

/* Die Terminspalte braucht weniger Breite als die Listen: Termine sind kurze
   Zeilen, Einkaufszettel wollen Platz zum Antippen. */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: var(--gap);
}

/* Heute-Zeile: Abendessen und nächster Termin, aus zwei Metern lesbar. */
.today-bar {
  display: flex;
  gap: 10px;
  flex: none;
}

.today-bar[hidden] { display: none; }

.today-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 1.1rem;
  text-align: left;
}

button.today-item { cursor: pointer; }
button.today-item:active { filter: brightness(1.15); }

.today-label { flex: none; color: var(--text-dim); font-size: 0.9rem; }

.today-value {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-value.leer { font-weight: 400; color: var(--text-dim); }

.mail-item { cursor: pointer; border-left-color: #f6c445; align-items: center; }
.mail-item[hidden] { display: none; }
.mail-weg {
  flex: none;
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 0 4px;
  cursor: pointer;
}

/* Ohne min-width: 0 wachsen Rasterspalten mit ihrem Inhalt — die Chips der
   Familienmitglieder haben die ToDo-Spalte sonst breiter gezogen. */
.layout > *, .column > *, .tabbed > *, .panel { min-width: 0; }

/* Spezifischer als die allgemeine .tabbar-Regel weiter unten. */
.tabbar.tabbar-phone { display: none; }

/* Woche und Monat brauchen Breite — die Listen kommen mit weniger aus. */
.layout.wide-cal { grid-template-columns: 1.7fr 1fr; }

/* Flex statt Grid: eine ausgeblendete Kachel hinterlaesst so keine Luecke,
   die uebrigen teilen den Platz unter sich auf. */
.column {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

/* Reiter: immer nur eine Liste, dafür über die ganze Höhe. Die Zahl neben
   dem Reiter sagt, was auf der anderen Seite liegt — so muss man nicht
   umschalten, nur um zu sehen, ob dort etwas wartet. */
.tabbed {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tabbar {
  display: flex;
  gap: 8px;
  flex: none;
}

.tab {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1.05rem;
  font-family: inherit;
  cursor: pointer;
}

.tab.active {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--accent);
}

.tab-count { color: var(--text-dim); font-size: 0.9rem; }
.tab.active .tab-count { color: var(--accent); }

.panel-todos, .panel-shopping, .panel-meals { flex: 1 1 0; }
.panel-todos[hidden], .panel-shopping[hidden], .panel-meals[hidden] { display: none; }

/* --- Essensplan --- */
.meal-day {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.meal-day:last-child { border-bottom: none; }
.meal-day.is-today { background: var(--bg-raised); border-radius: 12px; }

.meal-tag {
  flex: none;
  width: 4.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.meal-day.is-today .meal-tag { color: var(--accent); font-weight: 700; }
.meal-name { flex: 1; min-width: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.meal-name.leer { color: var(--text-dim); }
.meal-meta { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }

/* Personenzahl im Gericht-Dialog */
.meal-personen {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.meal-personen-wahl { display: inline-flex; align-items: center; gap: 10px; }
.meal-personen-wahl .mic-btn { width: 46px; height: 46px; }
.meal-personen output { min-width: 2.5ch; text-align: center; font-size: 1.3rem; font-weight: 700; }
.meal-personen .hint { margin: 0; flex: 1 1 12rem; }

/* Uebersprungene Tage: sichtbar geplant, aber zurueckgenommen */
.meal-day.is-skip .meal-name { color: var(--text-dim); font-style: italic; }

.meal-skip {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
}

.meal-skip summary { cursor: pointer; color: var(--text-dim); }
.meal-skip[open] summary { margin-bottom: 10px; }

.meal-skip-gruende {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.meal-skip-gruende .is-active { border-color: var(--accent); color: var(--accent); }

.meals-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 0 20px 16px;
}

.meals-shop-info { color: var(--text-dim); font-size: 0.9rem; flex: 1 1 14rem; }
.meals-shop-info[hidden] { display: none; }

.meal-zutaten {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 30vh;
  overflow-y: auto;
}

.meal-zutaten span {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* Zubereitung: beim Kochen aus zwei Metern Abstand lesbar */
.meal-schritte {
  margin: 0;
  padding-left: 1.4em;
  max-height: 34vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-schritte li { line-height: 1.45; overflow-wrap: anywhere; }
.meal-schritte[hidden], .meal-picks[hidden] { display: none; }

.meal-quellen {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meal-quellen a { text-decoration: none; }

/* Herkunft eines Gerichts: in der Wochenliste nur das Zeichen, im Dialog
   mit Text an der Stelle, an der sonst der Link steht. */
.quelle-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
  vertical-align: middle;
}

.meal-quellen .quelle-badge { padding: 8px 14px; }
.quelle-badge[hidden] { display: none; }
.field[hidden] { display: none; }

/* Vorschlagsliste aus der Rezeptsuche bzw. dem Picnic-Kochbuch */
.meal-picks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 44vh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.meal-picks .hint { margin: 0 0 4px; }

.pick-kopf {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 2px;
}

.pick {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 10px;
  cursor: pointer;
}

.pick:hover, .pick:focus-visible { background: var(--bg-panel); }
.pick-title { overflow-wrap: anywhere; }
.pick-meta { color: var(--text-dim); font-size: 0.82rem; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 24px 0;
}

/* ------------------------------------------------------------------ buttons */

.add-btn, .ghost-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.add-btn { background: var(--accent); color: #fff; }
.add-btn:active { filter: brightness(0.9); }

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
  font-weight: 500;
}

/* ------------------------------------------------------------------ agenda */

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* ------------------------------------------------- umschalter und raster */

.viewbar { display: flex; gap: 6px; }

.view-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}

.view-btn.active { background: var(--bg-raised); color: var(--text); border-color: var(--accent); }

.cal-nav { display: flex; gap: 6px; }
.cal-nav[hidden] { display: none; }
.cal-nav .ghost-btn { padding: 9px 14px; }

/* Wochenansicht: sieben Spalten nebeneinander */
.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  height: 100%;
}

.week-day {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-raised);
  border-radius: 12px;
  padding: 8px;
  gap: 6px;
  overflow-y: auto;
}

.week-day.is-today { outline: 2px solid var(--accent); }
.week-day.is-weekend { background: #1a2335; }

.week-head { font-size: 0.85rem; color: var(--text-dim); text-align: center; }
.week-head b { display: block; color: var(--text); font-size: 1.05rem; }

.week-event {
  border-left: 4px solid var(--accent);
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 0.8rem;
  line-height: 1.25;
  overflow: hidden;
}
/* Lange Titel kürzen statt Buchstabe für Buchstabe umbrechen. Nur der Titel
   wird gekürzt, damit die Zeile „bringt … holt …“ nicht halb abgeschnitten wird. */
.week-title {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.week-event time { display: block; color: var(--text-dim); font-size: 0.78rem; }
.week-event.done { opacity: 0.5; text-decoration: line-through; }

/* Monatsraster */
.month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  /* Die Kopfzeile nur so hoch wie ihr Text — sonst bekommt sie dieselbe
     Höhe wie eine Wochenzeile und lässt eine leere Reihe stehen. */
  grid-template-rows: auto;
  grid-auto-rows: minmax(0, 1fr);
  gap: 6px;
  height: 100%;
}

.month-head {
  grid-column: span 7;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

.month-cell {
  min-width: 0;
  background: var(--bg-raised);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  cursor: pointer;
}

.month-cell.other { opacity: 0.45; }
.month-cell.is-today { outline: 2px solid var(--accent); }
.month-cell .nr { font-size: 0.85rem; color: var(--text-dim); }
.month-cell.is-today .nr { color: var(--accent); font-weight: 700; }

.month-event {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-event i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.month-more { font-size: 0.75rem; color: var(--text-dim); }

.day {
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--line);
}

.day:last-child { border-bottom: none; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.day-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.day-sub {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.day.is-today .day-name { color: var(--accent); }

.day.is-weekend .day-sub { color: #ffb36b; }

.event {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-raised);
  margin-bottom: 8px;
  border-left: 5px solid var(--accent);
}

.event-own { cursor: pointer; }
.event-own:active { filter: brightness(1.15); }

/* Heute schon vorbei: bleibt sichtbar, tritt aber zurück. */
.event-past, .week-event.past { opacity: 0.45; }

.event-check {
  align-self: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: transparent;
  color: transparent;
  font-size: 1.1rem;
  cursor: pointer;
}

.event-check.done {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.event-done .event-title,
.event-done .event-time { text-decoration: line-through; color: var(--text-dim); }

.event-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 1rem;
  padding-top: 2px;
}

.event-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.event-meta {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* Kindertermine: wer bringt, wer holt */
.event-ride { font-size: 0.9rem; margin-top: 2px; }
.event-ride.offen { color: var(--text-dim); opacity: 0.7; }
[data-ride] { cursor: pointer; }
.ride-sub { color: var(--text-dim); margin: -6px 0 4px; }
.week-ride { display: block; color: var(--text-dim); font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Packliste: Stand am Termin, Dialog zum Abhaken */
[data-pack] { cursor: pointer; }
.event-pack { font-size: 0.9rem; margin-top: 2px; }
.event-pack.fertig { color: var(--ok); }
.packliste { margin: -4px 0; }
.packliste .item { padding: 10px 4px; }
.packliste .item-body { cursor: pointer; }
.packliste .empty { padding: 8px 0; }
.pack-add { display: flex; gap: 10px; }
.pack-add input {
  flex: 1;
  min-width: 0;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 1.05rem;
  font-family: inherit;
}
/* Vorschläge kommen beim Tippen, der Pfeil daneben wäre nur Ballast. */
.pack-add input::-webkit-calendar-picker-indicator { display: none !important; }
.pack-add .add-btn { width: 58px; padding: 0; font-size: 1.5rem; }
.pack-hinweis { color: var(--text-dim); font-size: 0.85rem; margin: -4px 0 0; }

/* ------------------------------------------------------------------- lists */

/* Nachts dunkelt das Küchen-Tablet ab; antippen macht kurz wieder hell. */
body.nacht::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: background 1s ease;
}

.chips {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  padding: 9px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chip.active {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--accent);
}

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

.item:last-child { border-bottom: none; }

.check {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: transparent;
  color: transparent;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.item.done .check {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.item-body { flex: 1; min-width: 0; }
.item[data-kind="todo"] .item-body { cursor: pointer; }

.item-title {
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item.done .item-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

.item-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 3px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.overdue { color: var(--danger); font-weight: 600; }

.del {
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 10px;
}

.del:active { background: var(--bg-raised); color: var(--danger); }

/* -------------------------------------------------------------- stoerung */

.alarm {
  background: var(--danger);
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.alarm[hidden] { display: none; }
.alarm small { display: block; font-weight: 400; opacity: 0.9; margin-top: 4px; }

/* ------------------------------------------------------------------ picnic */

.picnic-line {
  padding: 10px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.95rem;
}

.picnic-line[hidden] { display: none; }
.picnic-line.error { color: var(--danger); }
.item-meta.picnic-ordered,
.item-meta .picnic-ordered { color: var(--ok); }

/* Zutaten eines Gerichts stehen gesammelt unter dessen Namen. */
.rezept-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
  font-weight: 600;
}

.rezept-kopf .rezept-name { min-width: 0; overflow-wrap: anywhere; }
.rezept-kopf small { font-weight: 400; margin-left: 4px; }
.rezept-kopf .ghost-btn { flex: none; padding: 6px 12px; font-size: 0.85rem; }

/* ------------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.7);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(520px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Passt der Dialog nicht auf den Schirm, scrollt sein Inhalt — vorher
     rutschten die Knöpfe am Handy unter den unteren Rand. dvh statt vh:
     sobald die Bildschirmtastatur aufgeht, schrumpft der sichtbare
     Bereich, und nur dvh rechnet das mit. */
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

/* Die Knöpfe bleiben dabei immer sichtbar. */
.modal-actions {
  position: sticky;
  bottom: -24px;
  background: var(--bg-panel);
  padding: 12px 0;
  margin: -12px 0 -12px;
}

/* Steckt ein Formular im Dialog (Notizen), braucht es dieselben Abstände —
   sonst schob sich die Knopfleiste mit ihrem negativen Rand über das
   Häkchen „bleibt, bis ich sie lösche“. */
.modal > form {
  display: flex;
  flex-direction: column;
  gap: inherit;
}

.modal h3 { margin: 0; font-size: 1.3rem; }

.event-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.foto-btn { padding: 8px 14px; font-size: 0.95rem; white-space: nowrap; }
.foto-btn.busy { opacity: 0.6; pointer-events: none; }
.foto-btn[hidden], .foto-status[hidden] { display: none; }
.foto-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-raised);
  font-size: 0.95rem;
  line-height: 1.35;
}
.foto-status.warn { background: rgba(240, 170, 60, 0.18); }
/* Felder, die aus dem Foto kamen, kurz hervorheben. */
.vom-foto { outline: 2px solid var(--accent); outline-offset: 1px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.input-with-mic {
  display: flex;
  gap: 10px;
}

.input-with-mic input { flex: 1; min-width: 0; }

.mic-btn {
  flex: none;
  width: 58px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.mic-btn.on { background: var(--danger); border-color: var(--danger); }

.field input, .field select, .row-person input {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 1.05rem;
  font-family: inherit;
}

.todo-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.todo-extra[hidden] { display: none; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

/* ----------------------------------------------------------- small screens */

@media (max-width: 900px) {
  /* Hochformat: Termine oben, Listen unten, je die halbe Höhe. Jede
     Kachel scrollt für sich — so bleibt keine Lücke dazwischen und nichts
     rutscht unten aus dem Bild. */
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .app-title { display: none; }

  /* Auf dem Handy wird der Uhr-Block aufgelöst (display: contents), damit
     Zeit, Datum, Status-Chips und Notizzeile eigene Zeilen im Kopfraster
     bekommen. Sonst stecken die Chips in der schmalen Uhrspalte fest. */
  body { padding: 12px; gap: 12px; }

  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "time   actions"
      "date   actions"
      "status status"
      "middle middle";
    gap: 6px 10px;
    align-items: center;
  }

  .clock { display: contents; }
  .clock .time { grid-area: time; }
  .clock .date { grid-area: date; margin-top: 0; }
  .status-row { grid-area: status; margin-top: 6px; flex-wrap: nowrap; }
  .topbar-middle { grid-area: middle; align-items: stretch; }
  .topbar-actions { grid-area: actions; align-self: center; gap: 8px; }

  /* Beide Chips teilen sich die Breite, statt übereinander zu rutschen. */
  .status-chip {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    font-size: 0.9rem;
    padding: 8px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Kleinere Knöpfe, und die Uhrzeit der letzten Aktualisierung braucht
     am Handy niemand — das schafft Platz am rechten Rand. */
  .icon-btn { width: 46px; height: 46px; font-size: 1.3rem; }
  .sync { display: none; }

  /* Volle Breite, linksbündig, und bis zu zwei Zeilen statt abgeschnitten. */
  .noteline {
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 14px;
  }

  .noteline-text {
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
  }

  .noteline-count { align-self: center; }

  .today-item { flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 12px; font-size: 1rem; }
  /* Der Mail-Vorschlag bekommt am Handy eine eigene Zeile. */
  .today-bar { flex-wrap: wrap; }
  .mail-item { flex: 1 1 100%; flex-direction: row; align-items: center; gap: 8px; }
  .mail-item .today-value { flex: 1 1 auto; min-width: 0; }
  .today-label { font-size: 0.8rem; }
  .todo-extra { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  /* Am Handy liegen alle drei Bereiche auf Reitern: immer einer über den
     ganzen Schirm, statt drei gestapelte, zwischen denen man scrollt. */
  .tabbar.tabbar-phone { display: flex; }
  .tabbed .tabbar { display: none; }
  .layout.wide-cal { grid-template-columns: 1fr; }
  .tabbed { gap: 0; }
  .panel { max-height: none; }

  /* Die Personenfilter in einer Zeile zum Wischen statt drei Reihen hoch. */
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 10px 14px 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }

  /* Lange ToDos dürfen zwei Zeilen nehmen, statt abgeschnitten zu werden. */
  .item-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .panel-calendar[hidden], .panel-todos[hidden], .panel-shopping[hidden] { display: none; }
  .panel-calendar, .panel-todos, .panel-shopping { flex: 1 1 auto; min-height: 60vh; }
  .layout { grid-template-rows: 1fr; }
  .tab { padding: 11px 12px; font-size: 1rem; }

  /* Der Kopf der Terminkachel wird kompakter, sonst bleibt kaum Platz
     für die Termine selbst. */
  .panel-head { padding: 12px 14px; gap: 8px; }
  #cal-title { font-size: 1.1rem; }
  .cal-nav .ghost-btn, .view-btn { padding: 8px 12px; font-size: 0.9rem; }
  .panel-head .add-btn { padding: 10px 14px; font-size: 0.95rem; }
  .panel-body { padding: 8px 14px 14px; }

  /* Woche: sieben Spalten sind auf 375 px unlesbar — daraus wird eine
     Liste, ein Tag je Zeile. */
  .week { grid-template-columns: 1fr; height: auto; gap: 6px; }

  .week-day {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    overflow: visible;
    padding: 10px;
  }

  .week-head { text-align: left; display: flex; align-items: baseline; gap: 6px; min-width: 52px; }
  .week-head b { display: inline; }
  .week-event { flex: 1 1 100%; font-size: 0.95rem; padding: 8px 10px; }
  .week-title { display: inline; }
  .week-event time { display: inline; margin-right: 6px; }

  /* Monat: nur farbige Punkte statt Titeln — die Zellen sind zu schmal. */
  .month { gap: 4px; }
  .month-cell { display: block; padding: 4px; }
  .month-event { display: inline-flex; font-size: 0; margin-right: 3px; }
  .month-event i { width: 8px; height: 8px; }
  .month-more { display: none; }
  .month-head { font-size: 0.75rem; }

  /* Dialoge: schmalerer Rand, damit mehr Inhalt auf den Schirm passt. */
  .modal-backdrop { padding: 10px; }
  .modal {
    padding: 18px;
    gap: 12px;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
  .modal-actions { bottom: -18px; }
  .field input, .field select { padding: 12px; }
}
