* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  background: #f5f5f5;
  color: #222;
}

#login-view {
  max-width: 320px;
  margin: 5rem auto;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#login-view h2 { margin: 0 0 0.5rem; }
#login-view input, #login-view button {
  padding: 0.6rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}
#login-view button {
  background: #4A90E2;
  color: white;
  border: none;
  cursor: pointer;
}
#login-view button:hover { background: #3a7bc8; }
#login-error { color: #c00; min-height: 1.2em; margin: 0; font-size: 0.9rem; }

header {
  padding: 0.75rem 1.5rem;
  /* iOS Notch: Header unter die Statusleiste schieben (viewport-fit=cover ist im Meta gesetzt) */
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  background: #2c3e50;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative; /* Anker für Burger-Dropdown auf Mobile */
}
header h1 { margin: 0; font-size: 1.25rem; }
header button {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 1rem;
}
header button:hover { background: rgba(255,255,255,0.1); }

.header-right { display: flex; align-items: center; gap: 0.4rem; }
/* „Mehr"-Panel: einheitlich als fixes Bottom-Sheet über der Tab-Leiste (alle Breiten).
   Wird per .open ein-/ausgeblendet; getoggelt vom „Mehr"-Tab (#tab-more). */
#header-menu {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  width: min(460px, 100%);
  max-height: 70vh;
  overflow-y: auto;
  flex-direction: column;
  align-items: stretch;
  background: var(--surface);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.28);
  padding: 0.5rem 0.6rem 0.7rem;
}
#header-menu.open { display: flex; }
#header-menu button,
#header-menu .menu-legal-link {
  display: block; width: 100%; box-sizing: border-box;
  background: transparent; color: var(--txt); border: none; border-radius: 8px;
  padding: 0.7rem 0.75rem; margin: 0; min-height: 44px;
  text-align: left; font: inherit; font-size: 0.95rem; text-decoration: none; cursor: pointer;
}
#header-menu button:hover { background: var(--surface2); }
#header-menu #user-info {
  display: block; color: var(--txt2); padding: 0.35rem 0.75rem 0.15rem; font-size: 0.85rem;
}
.menu-group-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--txt2); padding: 0.55rem 0.75rem 0.2rem;
}
.menu-group-label:first-child { padding-top: 0.2rem; }
.menu-footer { border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.2rem; }
.menu-footer .menu-legal-link,
.menu-footer button { font-size: 0.85rem; color: var(--txt2); min-height: 38px; }
/* Dezenter iOS-Installations-Hinweis im Burger-Menü */
.ios-install-hint {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--txt2);
}
#burger-btn { display: none; }
.sheet-handle { display: none; }

main {
  display: block;
  padding: 1rem;
  height: calc(100vh - 60px - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
}
/* Kalender füllt nach Wegfall der Bausteine-Sidebar die volle Breite/Höhe. */
#calendar { height: 100%; }

#template-list {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  overflow-y: auto;
}
#template-list h3 { margin: 0 0 0.5rem; }
.hint { font-size: 0.8rem; color: #666; margin: 0 0 1rem; }

/* Tagesvorlagen-Sektion in der Sidebar */
.day-templates-section { margin-bottom: 1rem; }
.day-templates-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  font-weight: 600;
}

.day-template-item {
  position: relative;
  background: #34495e;
  color: white;
  padding: 0.55rem 0.6rem 0.55rem 1.6rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.day-template-item:active { cursor: grabbing; }
.day-template-item .drag-handle {
  position: absolute;
  left: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
.day-template-item .day-template-meta { line-height: 1.3; }
.day-template-item .name { font-weight: 600; font-size: 0.88rem; }
.day-template-item .info { font-size: 0.74rem; color: rgba(255, 255, 255, 0.75); }
.day-template-item .horse-select {
  padding: 0.3rem 0.4rem;
  font-size: 0.82rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  width: 100%;
  cursor: pointer;
  /* Dropdown muss bedienbar bleiben — Block-touch-action: none gilt nicht für dieses Element */
  touch-action: auto;
}
.day-template-item .horse-select option { color: #222; }
.day-template-item.tap-selected {
  outline: 3px solid #4A90E2;
  outline-offset: 2px;
}

.template-group { margin-bottom: 0.75rem; }
.template-group:last-child { margin-bottom: 0; }
.template-group h4 {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  font-weight: 600;
}
.template-group:first-child h4 { margin-top: 0; }

.template-item {
  padding: 0.6rem;
  margin-bottom: 0.4rem;
  color: white;
  border-radius: 4px;
  cursor: grab;
  user-select: none;
  font-size: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  /* Touch-Drag: Browser-Default-Scrolling auf dem Item unterdrücken,
     sonst startet FC den Long-Press-Drag nicht zuverlässig */
  touch-action: none;
}
.template-item:active { cursor: grabbing; }
.template-item.tap-selected {
  outline: 3px solid #4A90E2;
  outline-offset: 2px;
}

/* Visuelles Feedback während FC den externen Drag-Mirror zieht */
.fc-event-dragging,
.template-item.fc-event-dragging {
  opacity: 0.8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Tap-Modus-Button im Sheet-Header */
.tap-mode-btn {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  font-size: 0.72rem;
  padding: 0.3rem 0.5rem;
  background: white;
  color: #2c3e50;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
.tap-mode-btn.active {
  background: #4A90E2;
  color: white;
  border-color: #4A90E2;
}
#template-list-header { position: relative; }

#calendar {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  overflow: auto;
}

/* Heutigen Tag deutlicher hervorheben — überschreibt FCs default --fc-today-bg-color */
.fc { --fc-today-bg-color: #fffceb; }

/* Zeitachse links — einheitliches "HH:MM"-Format, dezent */
.fc .fc-timegrid-slot-label {
  font-size: 0.8rem;
  color: #555;
  vertical-align: middle;
  text-align: right;
  padding-right: 6px;
}

/* Erledigte Termine — sowohl in Grid- als auch in List-Ansicht */
.event-completed { opacity: 0.55; }
.event-completed .fc-event-title,
.event-completed .fc-list-event-title { text-decoration: line-through; }

.fc-event { touch-action: manipulation; }

/* ==========================================================
   Swipe-Gesten auf Terminen (nur Touch-Geräte, Grid-Views).
   Rechts-Swipe = Erledigt-Toggle, Links-Swipe = Detail-Modal.
   Der Erledigen-Button wird auf Touch-Geräten in Grid-Views
   ausgeblendet (in listWeek bleibt er erhalten, da Swipe
   dort nicht implementiert ist).
   ========================================================== */
.is-touch .fc-timegrid-event .event-toggle-completed { display: none; }

/* Wir benötigen overflow:hidden und position:relative, damit das ::before
   als Action-Hintergrund den Termin hinterlegt. Inner-Content bekommt die
   Termin-Farbe per inherit, damit er beim Translaten den Hintergrund deckt. */
.is-touch .fc-timegrid-event { overflow: hidden; position: relative; }
.is-touch .fc-timegrid-event .fc-event-main {
  background-color: inherit;
  position: relative;
  z-index: 1;
}
.is-touch .fc-timegrid-event.swipe-right-active::before,
.is-touch .fc-timegrid-event.swipe-left-active::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.3rem;
  color: white;
  pointer-events: none;
}
.is-touch .fc-timegrid-event.swipe-right-active::before {
  content: '✓';
  background: #2e7d32;
  justify-content: flex-start;
  padding-left: 12px;
}
.is-touch .fc-timegrid-event.swipe-left-active::before {
  content: '✎';
  background: #1565c0;
  justify-content: flex-end;
  padding-right: 12px;
}

/* Erledigt-Toggle als sichtbarer Button oben rechts im Termin */
.event-toggle-completed {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 28px;
  min-height: 28px;
  padding: 0.25rem 0.5rem;
  background: white;
  color: #333;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  z-index: 3;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  text-decoration: none;
  white-space: nowrap;
}
.event-toggle-completed:hover { background: #f5f5f5; }
.event-toggle-completed:active { transform: scale(0.96); }
.event-toggle-completed .icon { font-weight: bold; font-size: 0.9rem; }

.event-toggle-completed.is-completed {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}
.event-toggle-completed.is-completed:hover { background: #43a047; }

/* listWeek: weiterhin rechtes Padding für den Toggle-Button */
.fc-list-event-title { position: relative; padding-right: 110px; }

/* ==========================================================
   Kompakt-Layout für kurze Termine (≤ 20 min) — Inline-Flex.
   Eigene DOM-Struktur (.event-compact-frame) via eventContent
   in app.js. Statt überlagernder absolute-Elemente liegen
   Badge, Titel und Toggle nebeneinander in einer Zeile.
   ========================================================== */
.fc-timegrid-event.event-compact .fc-event-main { padding: 0 !important; }

.event-compact-frame {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 2px 4px !important;
  font-size: 0.7rem;
  line-height: 1.1;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.event-compact-frame .fc-event-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0;
}
.event-compact-frame .event-user-badge {
  position: static;
  width: 16px;
  height: 16px;
  font-size: 9px;
  border-width: 1px;
  flex: 0 0 auto;
  margin: 0;
}
/* Bei kompakten Terminen: kompakter, aber klar erkennbarer Button (weißer BG + Border),
   nur Icon, ohne Label. Im Stil wie der normale Erledigen-Button, nur kleiner. */
.event-compact-frame .event-toggle-completed {
  position: static;
  padding: 2px 4px;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1;
  background: white;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  text-shadow: none;
}
.event-compact-frame .event-toggle-completed:hover { background: #f5f5f5; }
.event-compact-frame .event-toggle-completed:active { transform: scale(0.94); }
.event-compact-frame .event-toggle-completed.is-completed {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}
.event-compact-frame .event-toggle-completed.is-completed:hover { background: #43a047; }
.event-compact-frame .event-toggle-completed .label { display: none; }
.event-compact-frame .event-toggle-completed .icon { font-weight: bold; }

/* Mittlere Termine (21–45 min): nur den Toggle-Button etwas schlanker */
.fc-timegrid-event.event-medium .event-toggle-completed {
  padding: 0.2rem 0.4rem;
  font-size: 0.68rem;
  min-height: 24px;
}

/* Erledigt-Zeile im Termin-Modal — kompakt, token-basiert (Dark + Light lesbar) */
.modal-completed {
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.5rem !important;
  background: var(--inset);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem !important;
  color: var(--txt) !important;
  cursor: pointer;
}
.modal-completed input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
  accent-color: var(--done);
}

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#modal-panel {
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#modal-panel h2 {
  margin: 0 0 0.15rem;
  font-size: 1.1rem;
  color: var(--txt);
}

#modal-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--txt2);
  gap: 0.15rem;
  flex: 1;
}

#modal-panel input,
#modal-panel select,
#modal-panel textarea {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  min-height: 36px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  color: var(--txt);
  background: var(--surface2);
}

/* Pferd/Person und Start/Ende nebeneinander, auf sehr schmalen Schirmen gestapelt */
#modal-panel .modal-row > label { flex: 1 1 140px; min-width: 0; }

/* Von | Bis als zwei schmale Spalten in einer Zeile */
#modal-panel .time-row .field-time { flex: 1 1 86px; }

#modal-panel textarea {
  resize: vertical;
  min-height: 3rem;
}

/* Kompakte Button-Zeile; Löschen dezent in Danger-Farbe, links abgesetzt */
#modal-panel .modal-actions { margin-top: 0.25rem; }
#modal-panel .modal-actions button { padding: 0.45rem 0.85rem; font-size: 0.9rem; }
#modal-panel #modal-delete {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding-left: 0;
}
#modal-panel #modal-delete:hover { background: transparent; text-decoration: underline; }

.modal-row {
  display: flex;
  gap: 0.75rem;
}

.modal-hint {
  margin: -0.25rem 0 0;
  font-size: 0.78rem;
  color: #777;
  font-style: italic;
}

/* Dezente, schreibgeschützte „Erstellt von …"-Zeile im Termin-Modal */
.modal-created-info {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--txt3);
}

/* ============================================================
   Termin-Modal Redesign: Dauer-Chips, Personen-Tags, Aufklapper
   ============================================================ */
.modal-field-label {
  display: block; font-size: 0.78rem; font-weight: 600; color: var(--txt2); margin-bottom: 0.3rem;
}

/* Dauer: Kopf (Label + Live-Endzeit), Chips, optionales Select */
.modal-duration-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.modal-end-label { font-size: 0.8rem; color: var(--txt2); white-space: nowrap; }
.modal-duration-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.modal-duration-chip {
  flex: 0 0 auto; min-width: 52px; min-height: 40px; padding: 0.4rem 0.7rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface2);
  color: var(--txt); font: inherit; font-size: 0.9rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.modal-duration-chip:hover { background: var(--hover); }
.modal-duration-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal-duration-other { font-size: 0.85rem; }
.modal-duration-select {
  margin-top: 0.5rem; width: 100%; min-height: 44px; padding: 0.5rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2);
  color: var(--txt); font: inherit;
}

/* Zugewiesen: farbige Personen-Tags (Single-Select) */
.modal-assign-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.modal-assign-tag {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface2); color: var(--txt);
  font: inherit; font-size: 0.88rem; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.modal-assign-tag:hover { background: var(--hover); }
.modal-assign-tag.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* „niemand"-Tag ohne Badge: linksbündig etwas Luft */
.modal-assign-tag:not(:has(.agenda-user-badge)) { padding-left: 0.8rem; }
.modal-assign-tag .agenda-user-badge { width: 26px; height: 26px; font-size: 11px; }
.modal-assign-name { line-height: 1; }

/* „Weitere Optionen"-Aufklapper */
.modal-more-toggle {
  display: flex; align-items: center; gap: 0.45rem; width: 100%; min-height: 44px;
  padding: 0.5rem 0.2rem; border: none; background: transparent; color: var(--txt);
  font: inherit; font-size: 0.9rem; cursor: pointer; text-align: left;
}
.modal-more-chevron { transition: transform 0.15s ease; color: var(--txt2); }
.modal-more-toggle.is-open .modal-more-chevron { transform: rotate(90deg); }
/* Dezente Auflistung gesetzter Felder im zugeklappten Label */
.modal-more-summary { color: var(--txt3); font-size: 0.82rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-more { display: flex; flex-direction: column; gap: 0.75rem; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.modal-actions button {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  color: #222;
  cursor: pointer;
}

.modal-actions button:hover { background: #eaeaea; }

.modal-actions button.primary {
  background: #4A90E2;
  color: white;
  border-color: #4A90E2;
}
.modal-actions button.primary:hover { background: #3a7bc8; }

.modal-actions button.danger {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}
.modal-actions button.danger:hover { background: #a83224; }

#templates-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#templates-modal-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#templates-modal-panel h2 {
  margin: 0 0 0.15rem;
  font-size: 1.1rem;
}

#templates-admin-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 0.25rem;
  min-height: 100px;
}

.template-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.template-row:last-child { border-bottom: none; }

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.template-row-info {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.3;
}

.template-row-info strong { font-weight: 600; }

.template-row-actions {
  display: flex;
  gap: 0.4rem;
}

.template-row-actions button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  cursor: pointer;
}
.template-row-actions button:hover { background: #eaeaea; }
.template-row-actions button.danger {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}
.template-row-actions button.danger:hover { background: #a83224; }

#template-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}

#template-edit-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#template-edit-panel h2 {
  margin: 0 0 0.15rem;
  font-size: 1.1rem;
}

#template-edit-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: #555;
  gap: 0.25rem;
  flex: 1;
}

#template-edit-panel input,
#template-edit-panel select,
#template-edit-panel textarea {
  padding: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  color: #222;
  background: white;
}

#template-edit-panel input[type="color"] {
  padding: 0.2rem;
  height: 2.3rem;
}

#template-edit-panel textarea { resize: vertical; min-height: 60px; }

#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

#confirm-panel {
  background: white;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#confirm-panel p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #222;
}

/* ============================================================
   User-Initialen-Badge im Termin — unten links, räumlich vom
   Erledigen-Button (oben rechts) klar getrennt. Weißer Border
   sorgt für optische Abtrennung auch bei farblich ähnlichem
   Termin-Hintergrund.
   ============================================================ */
.event-user-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #777;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  user-select: none;
  border: 2px solid white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  letter-spacing: 0;
  line-height: 1;
}

.fc-event { border-width: 3px; }

/* Padding pauschal: links Platz fürs Badge, rechts für den Toggle-Button.
   Sitzt auf .fc-event-main, damit Zeit UND Titel gemeinsam einrücken. */
.fc-timegrid-event .fc-event-main {
  padding-left: 28px;
  padding-right: 92px;
}

/* listWeek: Badge inline rechts neben dem Titel, kein absolute Layout */
.fc-list-event .event-user-badge {
  position: static;
  width: 18px;
  height: 18px;
  font-size: 9px;
  margin-left: 0.5rem;
  vertical-align: middle;
  border-width: 1px;
}

/* Vorschau im Profil-Modal: gleicher Look, aber statisch positioniert und größer */
.profile-preview-badge {
  position: static;
  width: 40px;
  height: 40px;
  font-size: 15px;
}
.profile-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding-top: 0.4rem;
}
.profile-preview-label {
  font-size: 0.72rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   Profil-Modal — Look identisch zum Termin-Modal
   ============================================================ */
#profile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#profile-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#profile-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; }
#profile-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: #555;
  gap: 0.25rem;
  flex: 1;
}
#profile-panel input {
  padding: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  color: #222;
  background: white;
}
#profile-panel input:disabled { background: #f5f5f5; color: #666; }
#profile-panel input[type="color"] {
  padding: 0.2rem;
  height: 2.3rem;
  cursor: pointer;
}

/* ============================================================
   Tag-Zuweisen: klickbare Tagesköpfe + Popover
   ============================================================ */
/* Tageskopf als klickbares Bedienelement kenntlich machen:
   - dezente Unterstreichung
   - kleines ▾-Caret rechts neben dem Datum
   - sanfter Hover-/Active-Effekt */
.fc .fc-col-header-cell.day-header-clickable,
.fc .fc-list-day .fc-list-day-cushion { cursor: pointer; }

.fc .fc-col-header-cell-cushion {
  text-decoration: underline;
  text-decoration-color: #888;
  text-underline-offset: 3px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.12s ease;
}
.fc .fc-col-header-cell-cushion::after {
  content: ' ▾';
  font-size: 0.7em;
  margin-left: 0.2em;
  color: #888;
}
.fc .fc-col-header-cell.day-header-clickable:hover .fc-col-header-cell-cushion { background: #f0f4f8; }
.fc .fc-col-header-cell.day-header-clickable:active .fc-col-header-cell-cushion { background: #e1e8ef; }

/* listWeek: ganze Tageszeile bekommt den Hover, gleicher Caret + Underline */
.fc .fc-list-day-cushion {
  text-decoration: underline;
  text-decoration-color: #888;
  text-underline-offset: 3px;
  transition: background 0.12s ease;
}
.fc .fc-list-day-cushion::after {
  content: ' ▾';
  font-size: 0.85em;
  margin-left: 0.3em;
  color: #888;
}
.fc .fc-list-day:hover .fc-list-day-cushion { background: #f0f4f8; }
.fc .fc-list-day:active .fc-list-day-cushion { background: #e1e8ef; }

.day-assign-popover {
  position: fixed;
  background: white;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  padding: 0.3rem 0;
  z-index: 1200;
  max-width: 240px;
  min-width: 200px;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.9rem;
}
.day-assign-popover .popover-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  color: #222;
}
.day-assign-popover .popover-item:hover { background: #f0f0f0; }
.day-assign-popover .remove-item {
  font-style: italic;
  color: #666;
}
.day-assign-popover .popover-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 0.25rem 0;
}
.day-assign-popover .bulk-icon {
  width: 14px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.day-assign-popover .bulk-icon-complete { color: #4caf50; }
.day-assign-popover .bulk-icon-open { color: #888; }
.user-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #777;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   Tabs im Verwaltungs-Modal
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 0.25rem;
  flex: 0 0 auto;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #666;
}
.tab-btn.active {
  color: #2c3e50;
  font-weight: 600;
  border-bottom-color: #4A90E2;
}

.tab-content { display: none; flex-direction: column; flex: 1; min-height: 0; gap: 0.75rem; }
.tab-content.active { display: flex; }

.modal-actions-footer { border-top: 1px solid #eee; padding-top: 0.5rem; flex: 0 0 auto; }

/* ============================================================
   Tagesvorlage Edit-Modal
   ============================================================ */
#day-template-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}
#day-template-edit-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#day-template-edit-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; }
#day-template-edit-panel h3 { margin: 0.4rem 0 0; font-size: 0.95rem; }
#day-template-edit-panel h4 { margin: 0.4rem 0 0; font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.04em; }
#day-template-edit-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: #555;
  gap: 0.25rem;
}
#day-template-edit-panel input,
#day-template-edit-panel select,
#day-template-edit-panel textarea {
  padding: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  color: #222;
  background: white;
}

#day-template-add-item-btn {
  align-self: flex-start;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
#day-template-add-item-btn:hover { background: #ebebeb; }

.day-template-item-row {
  display: grid;
  grid-template-columns: auto 84px 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem;
  background: #fafafa;
  border-radius: 4px;
  margin-bottom: 0.3rem;
}
.day-template-item-row .sort-btns { display: flex; flex-direction: column; gap: 2px; }
.day-template-item-row .sort-btns button {
  width: 24px;
  height: 22px;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
  border: 1px solid #ccc;
  background: white;
  cursor: pointer;
  border-radius: 3px;
}
.day-template-item-row .sort-btns button:disabled { opacity: 0.3; cursor: not-allowed; }
.day-template-item-row .pause-input { width: 84px; padding: 0.4rem; }
.day-template-item-row select { padding: 0.4rem; }
.day-template-item-row .icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem 0.45rem;
  color: #c0392b;
}
.day-template-item-row .icon-btn:hover { background: rgba(192, 57, 43, 0.1); border-radius: 4px; }

/* Live-Vorschau im Anwenden-Modal: nutzt die read-only .dt-*-Timeline (siehe Editor-Block);
   begrenzte Höhe mit eigenem Scroll, damit das Modal bei langen Vorlagen handlich bleibt. */
#apply-preview.dt-timeline { max-height: 240px; overflow-y: auto; }
#apply-preview:empty::before {
  content: '— noch keine Einträge —';
  color: var(--txt2);
  font-style: italic;
  font-size: 0.85rem;
}

/* ============================================================
   Tagesvorlage-Editor: Chip-Palette + Live-Timeline + Pause-Chip
   ============================================================ */
/* Hinzufügen-Palette */
.dt-palette { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dt-palette-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px;
  padding: 0.35rem 0.7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface2); color: var(--txt); font: inherit; font-size: 0.88rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.dt-palette-chip:hover { background: var(--hover); }
.dt-palette-chip.is-pause { border-style: dashed; color: var(--txt2); margin-left: 0.25rem; }
.dt-chip-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: #4A90E2; }
.dt-chip-meta { color: var(--txt2); font-size: 0.78rem; }

/* Timeline */
.dt-timeline { display: flex; flex-direction: column; gap: 0.4rem; }
.dt-empty { color: var(--txt2); font-size: 0.85rem; padding: 0.5rem 0.2rem; }
.dt-row {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2);
}
.dt-row.dt-pause { border-style: dashed; background: transparent; }
.dt-sort { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.dt-sort-btn {
  width: 28px; height: 20px; padding: 0; line-height: 1; font-size: 0.7rem;
  border: 1px solid var(--line2); border-radius: 4px; background: var(--surface); color: var(--txt); cursor: pointer;
}
.dt-sort-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.dt-bar { flex: 0 0 auto; width: 4px; align-self: stretch; min-height: 28px; border-radius: 2px; background: #4A90E2; }
/* Zeitspanne: feste Breite, nie umbrechen (zeigt zugleich die Dauer) */
.dt-time {
  flex: 0 0 auto; min-width: 78px; white-space: nowrap; font-variant-numeric: tabular-nums;
  font-size: 0.78rem; color: var(--txt2);
}
/* Name (Block) und Label (Pause) sind die einzigen schrumpfbaren Items → Ellipsis erst am echten Zeilenende */
.dt-block-name {
  flex: 1 1 auto; min-width: 0; font-weight: 600; color: var(--txt);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-pause-label {
  flex: 1 1 auto; min-width: 0; color: var(--txt2); font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Stepper: feste Breite, schrumpft nicht → kann den ✕ nie überlappen */
.dt-stepper { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 0.4rem; }
.dt-step-btn {
  flex: 0 0 auto; width: 40px; height: 40px; padding: 0; line-height: 1; font-size: 1.1rem;
  border: 1px solid var(--line2); border-radius: 50%; background: var(--surface); color: var(--txt); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dt-step-val { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--txt); }
/* ✕ als eigenes Tap-Ziel, ganz rechts, mit eigenem Abstand zum Stepper — bündig in Block- und Pause-Zeilen */
.dt-del {
  flex: 0 0 auto; width: 40px; height: 40px; margin-left: 0.25rem; padding: 0; line-height: 1;
  border: none; background: transparent; color: var(--danger); font-size: 0.95rem; cursor: pointer; border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.dt-del:hover { background: rgba(192, 57, 43, 0.1); }

/* ============================================================
   Tagesvorlage Anwenden-Modal
   ============================================================ */
#day-template-apply-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#day-template-apply-panel {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#day-template-apply-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; }
#day-template-apply-panel h4 { margin: 0.4rem 0 0; font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.04em; }
#day-template-apply-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: #555;
  gap: 0.25rem;
  flex: 1;
}
#day-template-apply-panel input,
#day-template-apply-panel select {
  padding: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  color: #222;
  background: white;
}

/* ============================================================
   Tablet (641–1024px) — schmalere Sidebar, sonst Desktop-Layout
   ============================================================ */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait),
       (min-width: 901px) and (max-width: 1024px) and (orientation: landscape) {
  main { grid-template-columns: 180px 1fr; }
}

/* ============================================================
   Mobile (Portrait ≤640 oder Landscape ≤900)
   Burger-Menü im Header, Bausteine als Bottom-Sheet,
   Kalender vollflächig, Touch-Sizes.
   ============================================================ */
@media (max-width: 640px) and (orientation: portrait),
       (max-width: 900px) and (orientation: landscape) {

  /* --- Header --- */
  header { padding: 0.5rem 0.75rem; padding-top: calc(0.5rem + env(safe-area-inset-top)); }
  header h1 { font-size: 1rem; display: flex; gap: 0.35rem; align-items: center; }
  .title-text { font-weight: 700; }

  /* Burger entfällt überall — Navigation läuft über die Tab-Leiste/„Mehr".
     #header-menu wird global (außerhalb der Media-Query) als Bottom-Sheet gestylt. */

  /* --- Layout: einspaltig, Bottom-Sheet --- */
  main {
    display: block;
    padding: 0.5rem;
    height: calc(100vh - 56px - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
  }
  #calendar {
    height: 100%;
    padding: 0.5rem;
  }

  #template-list {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    height: 48px;
    max-height: 48px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    /* overflow: visible — Drag-Mirror darf das Sheet beim Rausziehen überlaufen.
       Die interne Scroll-Area liegt auf #templates. */
    overflow: visible;
    display: flex;
    flex-direction: column;
    z-index: 500;
    transition: max-height 0.25s ease, height 0.25s ease;
  }
  #template-list.open {
    height: 60vh;
    max-height: 60vh;
  }
  #template-list-header {
    cursor: pointer;
    padding: 0.4rem 0.5rem 0.5rem;
    text-align: center;
    flex: 0 0 auto;
    border-bottom: 1px solid #eee;
    user-select: none;
  }
  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 0.3rem;
  }
  #template-list-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
  }
  #template-list-header h3::after { content: ' ▲'; }
  #template-list.open #template-list-header h3::after { content: ' ▼'; }
  #template-list-header .hint { display: none; }

  /* Items im Bottom-Sheet kompakter, 2-spaltig */
  #templates {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
  }
  #template-list:not(.open) #templates { display: none; }
  .template-group { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .template-group h4 { grid-column: 1 / -1; margin: 0.25rem 0 0.15rem; }
  .template-item {
    font-size: 0.82rem;
    padding: 0.5rem;
    margin: 0;
  }

  /* --- FullCalendar Toolbar: umbrechen, größere Buttons --- */
  .fc .fc-toolbar.fc-header-toolbar {
    flex-wrap: wrap;
    gap: 0.4rem;
    row-gap: 0.4rem;
    margin-bottom: 0.5rem;
  }
  .fc .fc-toolbar-title { font-size: 1rem; }
  .fc .fc-button {
    min-height: 44px;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
  }

  /* --- Modals: nahezu Vollbild --- */
  #modal-panel,
  #templates-modal-panel,
  #template-edit-panel,
  #day-template-edit-panel,
  #day-template-apply-panel,
  #profile-panel {
    max-width: 95vw;
    max-height: 90vh;
    /* KEIN overflow auf dem Panel: das Panel bleibt overflow:hidden,
       gescrollt wird nur die innere .modal-body → das absolute „X" bleibt fix. */
  }
  /* #confirm-panel hat keine .modal-body und kein „X" → darf selbst scrollen. */
  #confirm-panel {
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
  }
  .day-assign-popover { max-width: 90vw; min-width: 180px; }
  .modal-row { flex-wrap: wrap; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { min-height: 44px; flex: 1 1 auto; }
  /* Tagesvorlagen-Einträge: Pause + Select untereinander auf schmalen Screens */
  .day-template-item-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "sort select del" "sort pause del";
    row-gap: 0.3rem;
  }
  .day-template-item-row .sort-btns { grid-area: sort; }
  .day-template-item-row .pause-input { grid-area: pause; width: 100%; }
  .day-template-item-row select { grid-area: select; }
  .day-template-item-row .icon-btn { grid-area: del; align-self: center; }

  /* --- iOS-Zoom-Schutz: Inputs ≥16px --- */
  input, select, textarea { font-size: 16px; }
}

/* ============================================================
   ============================================================
   REDESIGN "Klar & minimal" — Tokens, Agenda, Wochenansicht,
   Ansichts-Umschalter. Dieser Block überschreibt bewusst
   einzelne ältere Regeln (gleiche/größere Spezifität, später
   in der Quelle = gewinnt).
   ============================================================
   ============================================================ */

:root {
  --bg: #F1EFE8;            /* Seitenhintergrund */
  --surface: #ffffff;       /* Karten */
  --surface2: #ffffff;      /* Inputs / neutrale Buttons (im Dark leicht erhöht) */
  --inset: #f7f7f7;         /* eingelassene Flächen (Vorschau, Item-Zeilen) */
  --hover: rgba(0,0,0,0.05);
  --overlay: rgba(0,0,0,0.5);
  --line: rgba(0,0,0,0.12);
  --line2: rgba(0,0,0,0.22);
  --txt: #2C2C2A;
  --txt2: #5F5E5A;
  --txt3: #888780;
  --today: #E6F1FB;
  --today-txt: #0C447C;
  --done: #1D9E75;
  --danger: #c0392b;
  --accent: #4A90E2;        /* Akzent (Trichter-Aktiv, Chips, Primär-Buttons) */
  --accent-hover: #3a7bc8;
  --morning: #FAEEDA; --morning-txt: #7a4a0c;
  --evening: #E6EAF5; --evening-txt: #2b3a66;
  /* Status-Ampel für Verbrauchsgüter (Pille/Balken) */
  --status-green: #1D9E75; --status-green-bg: #E3F4EC; --status-green-txt: #0F6E4F;
  --status-yellow: #C8941E; --status-yellow-bg: #F8EFD6; --status-yellow-txt: #7A5A0C;
  --status-red: #C0392B; --status-red-bg: #F7E2DF; --status-red-txt: #8E2519;
  /* Stabile Gut-Palette für das Kosten-Diagramm (8 Töne) */
  --cseg-0: #4A90E2; --cseg-1: #1D9E75; --cseg-2: #E08A1E; --cseg-3: #9B59B6;
  --cseg-4: #2AA9A0; --cseg-5: #C0392B; --cseg-6: #C8941E; --cseg-7: #D6699B;
  --radius: 12px;
  --radius-sm: 6px;
}

/* Dunkler Token-Satz — warm abgestimmt zum Creme-Light-Theme.
   data-theme wird (vor dem ersten Paint) per Inline-Script auf html gesetzt;
   'auto' wird in JS zu light/dark aufgelöst. */
:root[data-theme="dark"] {
  --bg: #181715;
  --surface: #211f1c;
  --surface2: #2A2824;
  --inset: #1B1A17;
  --hover: rgba(255,255,255,0.06);
  --overlay: rgba(0,0,0,0.6);
  --line: rgba(255,255,255,0.12);
  --line2: rgba(255,255,255,0.20);
  --txt: #ECE9E1;
  --txt2: #B4B1A8;
  --txt3: #8A877F;
  --today: #1E2A3A;
  --today-txt: #9CC4EC;
  --done: #2BBD8E;
  --danger: #E0796B;
  --accent: #5B9BE8;
  --accent-hover: #6FA8EC;
  --morning: #3a2e18; --morning-txt: #E8C890;
  --evening: #22293C; --evening-txt: #AEBFE0;
  /* Status-Ampel (Dark): kräftige Akzente, gedämpfte Flächen */
  --status-green: #2BBD8E; --status-green-bg: #16332A; --status-green-txt: #7FE0C0;
  --status-yellow: #E0B43C; --status-yellow-bg: #3A2F12; --status-yellow-txt: #ECCD7E;
  --status-red: #E0796B; --status-red-bg: #3A201C; --status-red-txt: #F0A99E;
  /* Kosten-Palette (Dark): etwas hellere Töne für dunkle Flächen */
  --cseg-0: #5B9BE8; --cseg-1: #2BBD8E; --cseg-2: #E0A24C; --cseg-3: #B07CC6;
  --cseg-4: #46C3B8; --cseg-5: #E0796B; --cseg-6: #E0C04C; --cseg-7: #E08FB7;
}

body { background: var(--bg); color: var(--txt); }
/* Sanfter Theme-Übergang */
body, header, #template-list, #calendar, #agenda-view { transition: background-color 0.2s ease, color 0.2s ease; }

/* --- Header: ruhige helle Leiste statt dunkler Balken --- */
header {
  background: var(--surface);
  color: var(--txt);
  border-bottom: 1px solid var(--line);
  gap: 0.75rem;
}
header h1 { color: var(--txt); }
header button {
  color: var(--txt);
  border: 1px solid var(--line2);
  background: transparent;
}
header button:hover { background: rgba(0,0,0,0.05); }
#burger-btn { color: var(--txt); }

/* --- Ansichts-Umschalter (Tag ⇄ Woche) als kompaktes Segmented-Control --- */
#view-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;          /* Pill-Container */
  background: var(--inset);      /* dezenter Track */
  flex: 0 0 auto;
}
#view-toggle button {
  margin: 0;
  border: none;
  border-radius: 999px;          /* Segmente ebenfalls Pill */
  background: transparent;
  color: var(--txt2);
  padding: 0 0.8rem;
  height: 100%;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
#view-toggle button + button { border-left: none; }
#view-toggle button.active {
  background: var(--accent);     /* aktives Segment in Akzentfarbe */
  color: #fff;
  font-weight: 600;
}

/* --- Flächen abrunden --- */
#calendar { border-radius: var(--radius); border: 1px solid var(--line); }
#template-list { border-radius: var(--radius); }

/* ============================================================
   Sichtbarkeit der Ansichten
   ============================================================ */
#agenda-view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 0;
}
body.view-agenda #calendar { display: none; }
body.view-agenda #agenda-view { display: block; }
/* Agenda nimmt die volle Breite ein; Sidebar/Bottom-Sheet ausblenden,
   da die Agenda kein Drop-Ziel besitzt (Drag&Drop lebt in der Woche). */
body.view-agenda main { display: block; }
body.view-agenda #template-list { display: none; }

/* --- Futterplan-Screen: Sichtbarkeit (gleiche Body-Klassen-Mechanik) --- */
#feedplan-view { display: none; }
#feedplan-back { display: none; }            /* Zurück-Pfeil nur im Futterplan */
#feedplan-manage-btn { display: none; }      /* Zahnrad: nur im Futterplan + nur Admin */
.feedplan-title { display: none; }           /* Header-Titel „Futterplan" */
body.view-feedplan #calendar,
body.view-feedplan #agenda-view { display: none; }
body.view-feedplan #feedplan-view { display: block; }
body.view-feedplan main { display: block; }
body.view-feedplan #template-list { display: none; }
/* Header im Futterplan: Zurück + Titel statt Tag/Woche + Filter */
body.view-feedplan #feedplan-back { display: inline-flex; }
body.view-feedplan.is-admin #feedplan-manage-btn { display: inline-flex; }
body.view-feedplan .feedplan-title { display: inline; }
body.view-feedplan .title-text { display: none; }
body.view-feedplan #view-toggle,
body.view-feedplan #filter-btn,
body.view-feedplan #filter-chips,
body.view-feedplan #add-fab { display: none; }

/* --- Verbrauchsgüter-Screen: Sichtbarkeit (exakt nach Futterplan-Muster) --- */
#consumables-view { display: none; }
#consumables-back { display: none; }          /* Zurück nur in Verbrauchsgütern */
#consumables-cart { display: none; }          /* Warenkorb nur in Verbrauchsgütern */
#consumables-costs { display: none; }         /* Kosten-Icon nur in Verbrauchsgütern */
.consumables-title { display: none; }         /* Header-Titel „Verbrauchsgüter" */
body.view-consumables #calendar,
body.view-consumables #agenda-view,
body.view-consumables #feedplan-view { display: none; }
body.view-consumables #consumables-view { display: block; }
body.view-consumables main { display: block; }
body.view-consumables #template-list { display: none; }
body.view-consumables #consumables-back { display: inline-flex; }
body.view-consumables #consumables-cart { display: inline-flex; }
body.view-consumables #consumables-costs { display: inline-flex; }
body.view-consumables .consumables-title { display: inline; }
body.view-consumables .title-text { display: none; }
body.view-consumables #view-toggle,
body.view-consumables #filter-btn,
body.view-consumables #filter-chips,
body.view-consumables #add-fab { display: none; }

/* --- Bewegungs-Screen: Sichtbarkeit (exakt nach Futterplan/Verbrauchsgüter-Muster) --- */
#movement-view { display: none; }
#movement-back { display: none; }             /* Zurück nur in Bewegung */
.movement-title { display: none; }            /* Header-Titel „Bewegung" */
body.view-movement #calendar,
body.view-movement #agenda-view,
body.view-movement #feedplan-view,
body.view-movement #consumables-view { display: none; }
body.view-movement #movement-view { display: block; }
body.view-movement main { display: block; }
body.view-movement #template-list { display: none; }
body.view-movement #movement-back { display: inline-flex; }
body.view-movement .movement-title { display: inline; }
body.view-movement .title-text { display: none; }
body.view-movement #view-toggle,
body.view-movement #filter-btn,
body.view-movement #filter-chips,
body.view-movement #add-fab { display: none; }

/* --- Pflege-Screen: Sichtbarkeit (exakt nach dem gleichen Muster) --- */
#care-view { display: none; }
#care-back { display: none; }                 /* Zurück nur in Pflege */
.care-title { display: none; }                /* Header-Titel „Pflege" */
body.view-care #calendar,
body.view-care #agenda-view,
body.view-care #feedplan-view,
body.view-care #consumables-view,
body.view-care #movement-view { display: none; }
body.view-care #care-view { display: block; }
body.view-care main { display: block; }
body.view-care #template-list { display: none; }
body.view-care #care-back { display: inline-flex; }
body.view-care .care-title { display: inline; }
body.view-care .title-text { display: none; }
body.view-care #view-toggle,
body.view-care #filter-btn,
body.view-care #filter-chips,
body.view-care #add-fab { display: none; }

/* --- Übersicht/Dashboard-Screen: Sichtbarkeit (exakt nach dem gleichen Muster) --- */
#dashboard-view { display: none; }
#dashboard-back { display: none; }            /* Zurück nur in der Übersicht */
.dashboard-title { display: none; }           /* Header-Titel „Übersicht" */
body.view-dashboard #calendar,
body.view-dashboard #agenda-view,
body.view-dashboard #feedplan-view,
body.view-dashboard #consumables-view,
body.view-dashboard #movement-view,
body.view-dashboard #care-view { display: none; }
body.view-dashboard #dashboard-view { display: block; }
body.view-dashboard main { display: block; }
body.view-dashboard #template-list { display: none; }
body.view-dashboard #dashboard-back { display: inline-flex; }
body.view-dashboard .dashboard-title { display: inline; }
body.view-dashboard .title-text { display: none; }
body.view-dashboard #view-toggle,
body.view-dashboard #filter-btn,
body.view-dashboard #filter-chips,
body.view-dashboard #add-fab { display: none; }

/* --- Benachrichtigungen-Screen: Sichtbarkeit (exakt nach dem gleichen Muster) --- */
#notify-view { display: none; }
#notify-back { display: none; }               /* Zurück nur in Benachrichtigungen */
.notify-title { display: none; }              /* Header-Titel „Benachrichtigungen" */
body.view-notify #calendar,
body.view-notify #agenda-view,
body.view-notify #feedplan-view,
body.view-notify #consumables-view,
body.view-notify #movement-view,
body.view-notify #care-view,
body.view-notify #dashboard-view { display: none; }
body.view-notify #notify-view { display: block; }
body.view-notify main { display: block; }
body.view-notify #template-list { display: none; }
body.view-notify #notify-back { display: inline-flex; }
body.view-notify .notify-title { display: inline; }
body.view-notify .title-text { display: none; }
body.view-notify #view-toggle,
body.view-notify #filter-btn,
body.view-notify #filter-chips,
body.view-notify #add-fab { display: none; }

#topics-view { display: none; }
#topics-back { display: none; }               /* Zurück nur im Themen-Screen */
.topics-title { display: none; }              /* Header-Titel „Themen" */
body.view-topics #calendar,
body.view-topics #agenda-view,
body.view-topics #feedplan-view,
body.view-topics #consumables-view,
body.view-topics #movement-view,
body.view-topics #care-view,
body.view-topics #notify-view,
body.view-topics #dashboard-view { display: none; }
body.view-topics #topics-view { display: block; }
body.view-topics main { display: block; }
body.view-topics #template-list { display: none; }
body.view-topics #topics-back { display: none; }                     /* Liste = Tab-Ziel: kein Back */
body.view-topics.topics-thread #topics-back { display: inline-flex; } /* Thread = Drill-in: Back → Liste */
body.view-topics .topics-title { display: inline; }
body.view-topics .title-text { display: none; }
body.view-topics #view-toggle,
body.view-topics #filter-btn,
body.view-topics #filter-chips,
body.view-topics #add-fab { display: none; }

#settings-view { display: none; }
#settings-back { display: none; }              /* Zurück nur im Einstellungen-Screen */
.settings-title { display: none; }             /* Header-Titel „Einstellungen & Konto" */
body.view-settings #calendar,
body.view-settings #agenda-view,
body.view-settings #feedplan-view,
body.view-settings #consumables-view,
body.view-settings #movement-view,
body.view-settings #care-view,
body.view-settings #notify-view,
body.view-settings #topics-view,
body.view-settings #dashboard-view { display: none; }
body.view-settings #settings-view { display: block; }
body.view-settings main { display: block; }
body.view-settings #template-list { display: none; }
body.view-settings #settings-back { display: inline-flex; }
body.view-settings .settings-title { display: inline; }
body.view-settings .title-text { display: none; }
body.view-settings #view-toggle,
body.view-settings #filter-btn,
body.view-settings #filter-chips,
body.view-settings #add-fab { display: none; }

/* --- Dokumente-Screen: Sichtbarkeit (exakt nach dem gleichen Muster) --- */
#documents-view { display: none; }
#documents-back { display: none; }             /* Zurück nur im Dokumente-Screen */
.documents-title { display: none; }            /* Header-Titel „Dokumente" */
body.view-documents #calendar,
body.view-documents #agenda-view,
body.view-documents #feedplan-view,
body.view-documents #consumables-view,
body.view-documents #movement-view,
body.view-documents #care-view,
body.view-documents #notify-view,
body.view-documents #topics-view,
body.view-documents #settings-view,
body.view-documents #dashboard-view { display: none; }
body.view-documents #documents-view { display: block; }
body.view-documents main { display: block; }
body.view-documents #template-list { display: none; }
body.view-documents #documents-back { display: inline-flex; }
body.view-documents .documents-title { display: inline; }
body.view-documents .title-text { display: none; }
body.view-documents #view-toggle,
body.view-documents #filter-btn,
body.view-documents #filter-chips,
body.view-documents #add-fab { display: none; }

/* Dienstplan ist Tab-Ziel → KEIN Header-Back, nur Titel. */
#dienstplan-view { display: none; }
.dienstplan-title { display: none; }
body.view-dienstplan #calendar,
body.view-dienstplan #agenda-view,
body.view-dienstplan #feedplan-view,
body.view-dienstplan #consumables-view,
body.view-dienstplan #movement-view,
body.view-dienstplan #care-view,
body.view-dienstplan #notify-view,
body.view-dienstplan #topics-view,
body.view-dienstplan #settings-view,
body.view-dienstplan #documents-view,
body.view-dienstplan #dashboard-view { display: none; }
body.view-dienstplan #dienstplan-view { display: block; }
body.view-dienstplan main { display: block; }
body.view-dienstplan #template-list { display: none; }
body.view-dienstplan .dienstplan-title { display: inline; }
body.view-dienstplan .title-text { display: none; }
body.view-dienstplan #view-toggle,
body.view-dienstplan #filter-btn,
body.view-dienstplan #filter-chips,
body.view-dienstplan #add-fab { display: none; }

/* ============================================================
   Drill-in-Screens (Back-Pfeil sichtbar): Titel echt mittig im Header
   ------------------------------------------------------------
   Genau die Views mit Back-Pfeil (deckungsgleich mit der Back-Sichtbarkeit oben),
   inkl. Themen-THREAD (body.view-topics.topics-thread). Der Header wird zum
   3-Spalten-Grid 1fr|auto|1fr: Back links, Titel zentriert, Icons rechts.
   Gleich breite 1fr-Spalten → der Titel ist echt mittig zum Header, unabhängig
   von Back-Breite und rechten Icons; lange Titel ellipsen. Kalender/Übersicht/
   Dienstplan/Themen-Liste bleiben unverändert (Flex, links). #view-toggle bleibt
   unangetastet (auf diesen Views ohnehin display:none → kein Grid-Item). */
body.view-feedplan header,
body.view-consumables header,
body.view-movement header,
body.view-care header,
body.view-notify header,
body.view-settings header,
body.view-documents header,
body.view-topics.topics-thread header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 0.4rem;
  align-items: center;
}
body.view-feedplan header h1,
body.view-consumables header h1,
body.view-movement header h1,
body.view-care header h1,
body.view-notify header h1,
body.view-settings header h1,
body.view-documents header h1,
body.view-topics.topics-thread header h1 {
  grid-column: 2;
  justify-self: center;
  display: inline-flex;      /* Logo + Titel als zentrierter Block in der Mittelspalte */
  align-items: center;       /* vertikal mittig */
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}
/* Nur der Titel-Span ellipst bei langem Text; das Logo bleibt voll sichtbar. */
body.view-feedplan header h1 > span,
body.view-consumables header h1 > span,
body.view-movement header h1 > span,
body.view-care header h1 > span,
body.view-notify header h1 > span,
body.view-settings header h1 > span,
body.view-documents header h1 > span,
body.view-topics.topics-thread header h1 > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Back-Pfeil (einziges direktes .header-icon-btn-Kind) hart links … */
body.view-feedplan header > .header-icon-btn,
body.view-consumables header > .header-icon-btn,
body.view-movement header > .header-icon-btn,
body.view-care header > .header-icon-btn,
body.view-notify header > .header-icon-btn,
body.view-settings header > .header-icon-btn,
body.view-documents header > .header-icon-btn,
body.view-topics.topics-thread header > .header-icon-btn { justify-self: start; }
/* … Icons-Block hart rechts (3. Spalte) */
body.view-feedplan header .header-right,
body.view-consumables header .header-right,
body.view-movement header .header-right,
body.view-care header .header-right,
body.view-notify header .header-right,
body.view-settings header .header-right,
body.view-documents header .header-right,
body.view-topics.topics-thread header .header-right { grid-column: 3; justify-self: end; }
/* Logo bleibt sichtbar – neben dem zentrierten Titel – und schrumpft nicht. */
body.view-feedplan header .header-logo,
body.view-consumables header .header-logo,
body.view-movement header .header-logo,
body.view-care header .header-logo,
body.view-notify header .header-logo,
body.view-settings header .header-logo,
body.view-documents header .header-logo,
body.view-topics.topics-thread header .header-logo { flex: 0 0 auto; }

/* ============================================================
   Tagesansicht (Agenda) — Kartenliste
   ============================================================ */
#agenda-view {
  max-width: 760px;
  margin: 0 auto;
}

.agenda-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.3rem 0.25rem 0.45rem;   /* schlanker, ~halbe Höhe */
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.agenda-header-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
/* ‹ › als kleine, schlichte Icon-Buttons */
.agenda-nav {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--txt2);
  border-radius: var(--radius-sm);
  font-size: 1rem;        /* ~16px Chevron */
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.agenda-nav:hover { background: var(--hover); color: var(--txt); }
/* Titel mittig, kompakt, antippbar (= zu heute) */
.agenda-title { flex: 1; min-width: 0; text-align: center; cursor: pointer; }
.agenda-title-main { font-size: 0.95rem; font-weight: 700; color: var(--txt); line-height: 1.15; }
.agenda-title-date { font-size: 0.78rem; color: var(--txt2); font-variant-numeric: tabular-nums; }
/* „Heute"-Pille in einem fest reservierten Slot rechts, damit ‹ › nicht springen,
   wenn die Pille per visibility ein-/ausgeblendet wird (E). */
.agenda-today-slot {
  flex: 0 0 56px;
  display: flex;
  justify-content: flex-end;
}
.agenda-today-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 0;
  height: 24px;
}
.agenda-today-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.agenda-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.agenda-progress-segments {
  display: flex;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.agenda-progress-seg {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.agenda-progress-seg.is-done { background: var(--done); }
.agenda-progress-text {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--txt2);
  font-variant-numeric: tabular-nums;
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0.25rem 1.5rem;
}
.agenda-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--txt3);
  font-size: 0.95rem;
}

.agenda-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.12s ease, opacity 0.12s ease;
}
.agenda-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.agenda-card-bar {
  flex: 0 0 auto;
  align-self: stretch;
  width: 4px;
  min-height: 34px;
  border-radius: 4px;
  background: #4A90E2;
}
.agenda-card-body { flex: 1; min-width: 0; }
.agenda-card-time {
  font-size: 0.78rem;
  color: var(--txt3);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.agenda-card-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--txt);
  line-height: 1.3;
  word-break: break-word;
}
.agenda-card-horse {
  font-size: 0.8rem;
  color: var(--txt2);
  margin-top: 2px;
}

.agenda-user-badge {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #777;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  line-height: 1;
}

.agenda-done-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line2);
  background: var(--surface);
  color: var(--done);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.agenda-done-btn:active { transform: scale(0.94); }
.agenda-done-btn.is-completed {
  background: var(--done);
  border-color: var(--done);
  color: #fff;
}

/* Erledigte Karte: gedämpft, Titel + Uhrzeit durchgestrichen */
.agenda-card.is-completed { opacity: 0.7; }
.agenda-card.is-completed .agenda-card-title,
.agenda-card.is-completed .agenda-card-time { text-decoration: line-through; }

/* ============================================================
   Wochenansicht — heutiger Tag hervorgehoben, Pro-Tag-Fortschritt
   ============================================================ */
.fc { --fc-today-bg-color: var(--today); }
.fc .fc-col-header-cell.fc-day-today { background: var(--today); }
.fc .fc-col-header-cell.fc-day-today .day-header-label { color: var(--today-txt); }

.day-header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  padding: 2px 0;
}
.day-header-label { font-weight: 600; color: var(--txt); }

/* Spaltenkopf-Caret aus der alten Tag-Zuweisen-Optik nicht mehr anhängen,
   da der Kopf jetzt zweizeilig ist (Klick funktioniert weiterhin). */
.fc .fc-col-header-cell-cushion::after { content: none; }
.fc .fc-col-header-cell-cushion { text-decoration: none; padding: 4px 6px; }

/* Mobile: Agenda-Kopf etwas kompakter */
@media (max-width: 640px) and (orientation: portrait),
       (max-width: 900px) and (orientation: landscape) {
  #agenda-view { padding: 0 0.25rem; }
  .agenda-title-main { font-size: 1.05rem; }
  .agenda-done-btn { width: 38px; height: 38px; }
}

/* ============================================================
   Wochenansicht als kompakte Liste (dayGridWeek, Variante B)
   ============================================================ */
/* Termine als schlanke Zeilen statt gefüllter Blöcke. */
.fc .fc-daygrid-event {
  border: none;
  background: transparent;
  padding: 1px 2px;
  margin: 1px 0;
  white-space: nowrap;
}
.fc .fc-daygrid-event:hover { background: rgba(0,0,0,0.04); border-radius: 4px; }
/* FC-Standard-Punkt ausblenden — wir rendern einen eigenen. */
.fc .fc-daygrid-event-dot { display: none; }
/* Mehr Termine pro Tag: Zelle darf wachsen, Kalender scrollt über #calendar. */
.fc .fc-daygrid-day-events { min-height: 0; }

.week-event-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  cursor: pointer;
  line-height: 1.3;
}
.week-event-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4A90E2;
}
.week-event-time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--txt3);
  font-variant-numeric: tabular-nums;
}
.week-event-title {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--txt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Erledigte Termine in der Wochen-Liste: gedämpft + durchgestrichen */
.fc .fc-daygrid-event.event-completed { opacity: 0.55; }
.event-completed .week-event-title,
.event-completed .week-event-time { text-decoration: line-through; }

/* ============================================================
   ============================================================
   Uhrzeit-Picker (iOS-Stil Wheel-Picker) — token-basiert,
   funktioniert dadurch in Light + Dark.
   ============================================================
   ============================================================ */
#time-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1300; /* über allen anderen Overlays */
}
#time-picker-sheet {
  background: var(--surface);
  color: var(--txt);
  width: 100%;
  max-width: 440px;
  max-height: 94vh;           /* bei wenig Höhe (Landscape) scrollbar statt abgeschnitten */
  overflow-y: auto;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.35);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
#time-picker-sheet.open { transform: translateY(0); }

.time-picker-head { text-align: center; margin-bottom: 0.5rem; }
.time-picker-head h2 { margin: 0; font-size: 1.1rem; color: var(--txt); }
.time-picker-context {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--txt2);
}

.time-picker-wheels {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 200px; /* 5 × 40px */
  margin: 0.5rem 0 1rem;
  overflow: hidden;
}
.time-picker-colon {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--txt2);
  font-variant-numeric: tabular-nums;
  z-index: 2;
}
.time-picker-col {
  height: 200px;
  width: 72px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  /* Erste/letzte Zeile sollen die Mitte erreichen können: (200-40)/2 = 80 */
  padding: 80px 0;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;
  text-align: center;
}
.time-picker-col::-webkit-scrollbar { display: none; } /* WebKit */
.time-picker-item {
  height: 40px;
  line-height: 40px;
  scroll-snap-align: center;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--txt3);
  opacity: 0.45;
  transition: opacity 0.12s ease, color 0.12s ease, transform 0.12s ease;
  user-select: none;
}
.time-picker-item.is-selected {
  color: var(--txt);
  opacity: 1;
  transform: scale(1.06);
  font-weight: 600;
}
/* Mittiges Auswahl-Band */
.time-picker-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 80px;
  height: 40px;
  border-top: 1px solid var(--line2);
  border-bottom: 1px solid var(--line2);
  background: var(--hover);
  pointer-events: none;
  z-index: 1;
}
.time-picker-actions {
  display: flex;
  gap: 0.75rem;
}
.time-picker-actions button {
  flex: 1;
  padding: 0.7rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  cursor: pointer;
  min-height: 44px;
}
.time-picker-actions button:hover { background: var(--hover); }
.time-picker-actions button.primary {
  background: #4A90E2;
  border-color: #4A90E2;
  color: #fff;
}
.time-picker-actions button.primary:hover { background: #3a7bc8; }

/* ============================================================
   „An Termin anhängen" (davor/danach) — Picker + Modal, token-basiert
   ============================================================ */
.tp-attach { margin: 0.4rem 0 0.8rem; }
.tp-attach-result {
  margin: 0 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--today);
  color: var(--today-txt);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tp-attach-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt3);
  font-weight: 700;
  margin: 0 0 0.35rem;
}
.tp-attach-list {
  max-height: 26vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.tp-attach-empty {
  font-size: 0.82rem;
  color: var(--txt3);
  padding: 0.3rem 0.1rem;
}
.tp-attach-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
}
.tp-attach-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tp-attach-title {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tp-attach-time { font-size: 0.72rem; color: var(--txt2); font-variant-numeric: tabular-nums; }
.tp-attach-actions { flex: 0 0 auto; display: flex; gap: 0.3rem; }
.tp-attach-btn {
  min-height: 34px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  cursor: pointer;
}
.tp-attach-btn:hover { background: var(--hover); }
.tp-attach-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Modal-Variante: Auslöser-Button + aufklappbare Liste */
.modal-attach { margin: 0.2rem 0 0.1rem; }
.modal-attach-toggle {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  cursor: pointer;
}
.modal-attach-toggle:hover { background: var(--hover); }
.modal-attach-list {
  margin-top: 0.4rem;
  max-height: 30vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* ============================================================
   Anlege-Sheet („+") — Bottom-Sheet, token-basiert (Dark/Light)
   ============================================================ */
#add-sheet-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1200; /* unter dem Uhrzeit-Picker (1300) */
}
/* Portrait: hohes Bottom-Sheet, Liste = Hauptbereich */
#add-sheet {
  position: relative;
  background: var(--surface);
  color: var(--txt);
  width: 100%;
  max-width: 480px;
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.35);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  overflow: hidden;           /* runde Ecken kappen die scrollende Liste */
}
#add-sheet.open { transform: translateY(0); }

/* Schlanke, oben fixierte Leiste (scrollt nicht) */
.add-sheet-bar {
  flex: 0 0 auto;
  padding: 0.8rem 1.1rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.add-sheet-head { text-align: center; margin-bottom: 0.5rem; padding: 0 1.4rem; }
.add-sheet-head h2 { margin: 0; font-size: 1.1rem; color: var(--txt); }
.add-sheet-context { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--txt2); }

.add-sheet-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
/* Tag/Pferd je eine schlanke Zeile: Label links, Inhalt füllt */
.add-sheet-field { display: flex; align-items: center; gap: 0.5rem; }
.add-sheet-label {
  flex: 0 0 auto;
  width: 2.6rem;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt3);
  font-weight: 700;
}
.add-sheet-horse {
  flex: 1 1 auto;
  padding: 0.4rem 0.55rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  min-height: 38px;
}

/* Zieltag: kompakte Wochentag-Chips in EINER Zeile (Woche) bzw. Text (Tag) */
.add-sheet-day-selector { flex: 1 1 auto; display: flex; gap: 0.25rem; }
.add-sheet-day-static { font-size: 0.9rem; font-weight: 600; color: var(--txt); }
.add-sheet-day-chip {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--txt2);
  cursor: pointer;
  min-height: 38px;
  line-height: 1.1;
}
.add-sheet-day-chip .wd { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.02em; }
.add-sheet-day-chip .dn { font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.add-sheet-day-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Großer, scrollbarer Hauptbereich + Fade-Hinweis am unteren Rand */
.add-sheet-body-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.add-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 1.1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
}
.add-sheet-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}
.add-sheet-section:not(:empty) { margin-bottom: 0.4rem; }
.add-sheet-section-head {
  margin: 0.4rem 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt3);
  font-weight: 700;
}
.add-sheet-subhead {
  margin: 0.45rem 0 0.25rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt3);
  font-weight: 600;
}
.add-sheet-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--inset);
  color: var(--txt);
  cursor: pointer;
  min-height: 46px;
  font: inherit;
}
.add-sheet-row:hover { background: var(--hover); }
.add-sheet-row:active { transform: scale(0.99); }
.add-sheet-row-daytemplate { background: var(--surface2); }
.add-sheet-row-name { flex: 1; font-size: 0.92rem; font-weight: 500; }
.add-sheet-row-meta { font-size: 0.78rem; color: var(--txt2); font-variant-numeric: tabular-nums; }
.add-sheet-row-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }

/* Querformat: zentriertes, breites Fenster mit Raster statt hohem Bottom-Sheet (C) */
@media (orientation: landscape) {
  #add-sheet-overlay { align-items: center; padding: 1rem; }
  #add-sheet {
    width: 100%;
    max-width: 560px;
    height: auto;
    max-height: 90vh;
    border-radius: 16px;
    transform: scale(0.96);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  #add-sheet.open { transform: scale(1); opacity: 1; }

  /* Tag-Chips + Pferd in EINER Zeile oben */
  .add-sheet-controls { flex-direction: row; align-items: center; gap: 0.8rem; }
  .add-sheet-day-field { flex: 1 1 auto; min-width: 0; }
  .add-sheet-horse-field { flex: 0 0 auto; width: 38%; max-width: 220px; }

  /* Bausteine als mehrspaltiges Raster */
  #add-sheet-blocks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; align-content: start; }
  #add-sheet-blocks .add-sheet-section-head,
  #add-sheet-blocks .add-sheet-subhead { grid-column: 1 / -1; }
  #add-sheet-blocks .add-sheet-row { margin-bottom: 0; }
}
@media (orientation: landscape) and (min-width: 900px) {
  #add-sheet-blocks { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   Schwebender „+"-Button (FAB) — beide Ansichten & Ausrichtungen
   ============================================================ */
#add-fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--tabbar-h) + env(safe-area-inset-bottom, 0px));  /* über der Tab-Bar */
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  cursor: pointer;
  z-index: 600;            /* über dem Inhalt, unter den Overlays (1000+) */
  -webkit-tap-highlight-color: transparent;
}
#add-fab:hover { background: var(--accent-hover); }
#add-fab:active { transform: scale(0.95); }

/* FAB-Freiraum unten reservieren, damit Reinstellen-Banner (Tag) bzw.
   Abend-Band der Sonntagsspalte (Woche) nicht verdeckt werden. */
body.view-agenda #agenda-view { padding-bottom: 88px; }
/* Wochenansicht: Inhaltsbereich als Spalte — Kalender-Box umschließt die Wochenzeile
   (Inhaltshöhe, kein leerer Rahmen), darunter folgt inline das Tagesdetail-Panel,
   das den Rest füllt und bei viel Inhalt selbst scrollt. */
body.view-week main { display: flex; flex-direction: column; min-height: 0; }
body.view-week #calendar { flex: 0 0 auto; height: auto; padding-bottom: 0; }

/* ============================================================
   Datum-Sprung — eigener Inline-Monatspicker (token-basiert, Dark/Light)
   ============================================================ */
#date-jump-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1250; /* über dem Anlege-Sheet (1200), unter dem Uhrzeit-Picker (1300) */
}
#date-jump-popup {
  position: relative;
  background: var(--surface);
  color: var(--txt);
  width: calc(100% - 2.5rem);
  max-width: 340px;
  border-radius: 16px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 10px 34px rgba(0,0,0,0.35);
}
.date-jump-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.7rem;
  padding-right: 1.7rem;   /* Platz fürs statische × */
}
.date-jump-title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--txt);
}
.date-jump-nav {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt2);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.date-jump-nav:hover { background: var(--hover); color: var(--txt); }

.date-jump-weekdays,
.date-jump-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.date-jump-weekdays { margin-bottom: 4px; }
.date-jump-wd {
  text-align: center;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--txt3);
}
.date-jump-day {
  aspect-ratio: 1 / 1;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--txt);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.date-jump-day:hover { background: var(--hover); }
.date-jump-day.is-empty { visibility: hidden; cursor: default; }
.date-jump-day.is-today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); font-weight: 700; }
.date-jump-day.is-selected { background: var(--accent); color: #fff; font-weight: 700; }
.date-jump-day.is-selected.is-today { box-shadow: none; }

/* Theme-Toggle im Header (Sonne/Mond) */
/* Theme-Umschalter sitzt jetzt als Eintrag im Burger-Menü. */
.theme-menu-btn { display: inline-flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.theme-menu-icon { font-size: 1.05rem; line-height: 1; }

/* ============================================================
   ============================================================
   DARK MODE — FullCalendar mit-thematisieren + Alt-Flächen,
   die noch feste Farben tragen, auf die Tokens umbiegen.
   (Nur unter [data-theme="dark"]; Light bleibt unverändert.)
   ============================================================
   ============================================================ */

/* --- FullCalendar-Variablen --- */
[data-theme="dark"] .fc {
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface);
  --fc-neutral-text-color: var(--txt2);
  --fc-border-color: var(--line);
  --fc-today-bg-color: var(--today);
  --fc-list-event-hover-bg-color: var(--hover);
  --fc-button-bg-color: var(--surface2);
  --fc-button-border-color: var(--line2);
  --fc-button-text-color: var(--txt);
  --fc-button-hover-bg-color: var(--hover);
  --fc-button-hover-border-color: var(--line2);
  --fc-button-active-bg-color: var(--today);
  --fc-button-active-border-color: var(--today);
  color: var(--txt);
}
[data-theme="dark"] .fc .fc-toolbar-title,
[data-theme="dark"] .fc-col-header-cell-cushion,
[data-theme="dark"] .fc-daygrid-day-number,
[data-theme="dark"] .day-header-label { color: var(--txt); }
[data-theme="dark"] .fc .fc-button { text-transform: none; }

/* --- Kalender-Container: die weiße Grundfläche kam aus #calendar { background: white }.
   FullCalendars eigene Tabellen-/Kopf-/Toolbar-Flächen sind transparent und ließen
   dieses Weiß durchscheinen → im Dark Mode auf --surface umbiegen. --- */
[data-theme="dark"] #calendar { background: var(--surface); }
/* FC-Strukturflächen transparent halten, damit sie die dunkle #calendar-Fläche zeigen;
   den heutigen Tag ausnehmen, damit das --today-Highlight erhalten bleibt. */
[data-theme="dark"] .fc .fc-scrollgrid,
[data-theme="dark"] .fc .fc-scrollgrid-section > *,
[data-theme="dark"] .fc .fc-col-header,
[data-theme="dark"] .fc .fc-col-header-cell:not(.fc-day-today),
[data-theme="dark"] .fc .fc-daygrid-body,
[data-theme="dark"] .fc .fc-daygrid-day:not(.fc-day-today) {
  background-color: transparent;
}
/* Zelltrennlinien/Rahmen über die Token-Variable (oben gesetzt: --fc-border-color: --line). */
[data-theme="dark"] .fc .fc-scrollgrid,
[data-theme="dark"] .fc td,
[data-theme="dark"] .fc th { border-color: var(--line); }

/* --- Login --- */
[data-theme="dark"] #login-view { background: var(--surface); box-shadow: 0 2px 14px rgba(0,0,0,0.5); }
[data-theme="dark"] #login-view input { background: var(--surface2); color: var(--txt); border-color: var(--line2); }

/* --- Header-Menü (mobiles Dropdown) --- */
[data-theme="dark"] #header-menu { background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
[data-theme="dark"] #header-menu #user-info { color: var(--txt2); border-bottom-color: var(--line); }
[data-theme="dark"] #header-menu button { color: var(--txt); }
[data-theme="dark"] #header-menu button:hover { background: var(--hover); }

/* --- Bottom-Sheet / "Bausteine"-Leiste (Sidebar + mobiles Sheet) --- */
/* #template-list { background: white } (Basis + mobile Regel) → im Dark auf --surface.
   Höhere Spezifität durch [data-theme] + #id schlägt beide Basisregeln. */
[data-theme="dark"] #template-list { background: var(--surface); color: var(--txt); }
[data-theme="dark"] #template-list-header { border-bottom-color: var(--line); }
[data-theme="dark"] .sheet-handle { background: var(--line2); }
[data-theme="dark"] .tap-mode-btn { background: var(--surface2); color: var(--txt); border-color: var(--line2); }

/* --- Modale Panels + Backdrops --- */
[data-theme="dark"] #modal-overlay,
[data-theme="dark"] #templates-modal-overlay,
[data-theme="dark"] #template-edit-overlay,
[data-theme="dark"] #day-template-edit-overlay,
[data-theme="dark"] #day-template-apply-overlay,
[data-theme="dark"] #profile-overlay,
[data-theme="dark"] #confirm-overlay { background: var(--overlay); }

[data-theme="dark"] #modal-panel,
[data-theme="dark"] #templates-modal-panel,
[data-theme="dark"] #template-edit-panel,
[data-theme="dark"] #day-template-edit-panel,
[data-theme="dark"] #day-template-apply-panel,
[data-theme="dark"] #profile-panel,
[data-theme="dark"] #confirm-panel {
  background: var(--surface);
  color: var(--txt);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
[data-theme="dark"] #modal-panel h2,
[data-theme="dark"] #templates-modal-panel h2,
[data-theme="dark"] #template-edit-panel h2,
[data-theme="dark"] #day-template-edit-panel h2,
[data-theme="dark"] #day-template-edit-panel h3,
[data-theme="dark"] #day-template-apply-panel h2,
[data-theme="dark"] #profile-panel h2,
[data-theme="dark"] #confirm-panel p { color: var(--txt); }

/* Labels + Hints */
[data-theme="dark"] #modal-panel label,
[data-theme="dark"] #template-edit-panel label,
[data-theme="dark"] #day-template-edit-panel label,
[data-theme="dark"] #day-template-apply-panel label,
[data-theme="dark"] #profile-panel label { color: var(--txt2); }
[data-theme="dark"] .modal-hint,
[data-theme="dark"] .hint,
[data-theme="dark"] #day-template-edit-panel h4,
[data-theme="dark"] #day-template-apply-panel h4 { color: var(--txt3); }

/* Inputs / Selects / Textareas */
[data-theme="dark"] #modal-panel input,
[data-theme="dark"] #modal-panel select,
[data-theme="dark"] #modal-panel textarea,
[data-theme="dark"] #template-edit-panel input,
[data-theme="dark"] #template-edit-panel select,
[data-theme="dark"] #template-edit-panel textarea,
[data-theme="dark"] #day-template-edit-panel input,
[data-theme="dark"] #day-template-edit-panel select,
[data-theme="dark"] #day-template-edit-panel textarea,
[data-theme="dark"] #day-template-apply-panel input,
[data-theme="dark"] #day-template-apply-panel select,
[data-theme="dark"] #profile-panel input {
  background: var(--surface2);
  color: var(--txt);
  border-color: var(--line2);
}
[data-theme="dark"] #profile-panel input:disabled { background: var(--inset); color: var(--txt3); }
[data-theme="dark"] .modal-completed { background: var(--inset); color: var(--txt); }

/* Neutrale Buttons in Modal-Actions */
[data-theme="dark"] .modal-actions button,
[data-theme="dark"] .template-row-actions button,
[data-theme="dark"] #day-template-add-item-btn {
  background: var(--surface2);
  color: var(--txt);
  border-color: var(--line2);
}
[data-theme="dark"] .modal-actions button:hover,
[data-theme="dark"] .template-row-actions button:hover,
[data-theme="dark"] #day-template-add-item-btn:hover { background: var(--hover); }

/* Listen / Trennlinien / eingelassene Flächen */
[data-theme="dark"] #templates-admin-list { border-color: var(--line); }
[data-theme="dark"] .template-row { border-bottom-color: var(--line); }
[data-theme="dark"] .tabs { border-bottom-color: var(--line2); }
[data-theme="dark"] .tab-btn { color: var(--txt2); }
[data-theme="dark"] .tab-btn.active { color: var(--txt); }
[data-theme="dark"] .modal-actions-footer { border-top-color: var(--line); }
[data-theme="dark"] .day-template-item-row { background: var(--inset); }
[data-theme="dark"] .day-template-item-row .sort-btns button { background: var(--surface2); color: var(--txt); border-color: var(--line2); }

/* Tag-Zuweisen-Popover */
[data-theme="dark"] .day-assign-popover { background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,0.55); }
[data-theme="dark"] .day-assign-popover .popover-item { color: var(--txt); }
[data-theme="dark"] .day-assign-popover .popover-item:hover { background: var(--hover); }
[data-theme="dark"] .day-assign-popover .remove-item { color: var(--txt2); }
[data-theme="dark"] .day-assign-popover .popover-separator { background: var(--line); }

/* Erledigen-Toggle (listWeek/agenda nutzen eigene Tokens; dieser ist die Grid-Variante) */
[data-theme="dark"] .event-toggle-completed { background: var(--surface2); color: var(--txt); border-color: var(--line2); }

/* ============================================================
   Termin-Modal mobil: von unten einfahrendes Sheet (wie der Picker).
   Nur das Termin-Modal (#modal-overlay/#modal-panel); andere Modale
   bleiben unverändert. Höhere Spezifität (#overlay #panel) schlägt die
   gemeinsame Mobile-Regel.
   ============================================================ */
@media (max-width: 640px) and (orientation: portrait),
       (max-width: 900px) and (orientation: landscape) {
  #modal-overlay { align-items: flex-end; }
  #modal-overlay #modal-panel {
    max-width: none;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  #modal-overlay #modal-panel.open { transform: translateY(0); }
  /* Safe-Area-Abstand jetzt im scrollenden Body (Panel hat padding:0) */
  #modal-overlay #modal-panel .modal-body { padding-bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px)); }
  /* Schmal: Von/Bis bleiben nebeneinander */
  #modal-panel .time-row .field-time { flex: 1 1 0; }
}

/* ============================================================
   ============================================================
   Logo-Integration: Header, Login, Lade-Splash
   (Splash bewusst immer dunkel — auch im Light Mode; daher dort
   feste helle Schrift/Spinner auf dem #181715-Grund.)
   ============================================================
   ============================================================ */

/* --- Header-Logo links neben dem Titel --- */
.header-logo {
  height: 28px;
  width: auto;
  flex: 0 0 auto;
  align-self: center;
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* --- Login: Logo + Wortmarke über dem Formular --- */
.login-logo {
  align-self: center;
  width: auto;
  max-width: 140px;
  height: auto;
  margin-bottom: 0.25rem;
}
.login-wordmark {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--txt);
  margin-bottom: 0.5rem;
}

/* --- Lade-Splash --- */
#splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #181715;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#splash-overlay.splash-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo {
  width: auto;
  max-width: 140px;
  height: auto;
}
.splash-title {
  color: #ECE9E1;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.splash-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #ECE9E1;
  animation: splash-spin 0.8s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Schließen-„X" oben rechts in den Form-Modalen.
   Sticky am oberen Panel-Rand → bleibt sichtbar, auch wenn der
   Panel-Inhalt scrollt (mobiles Bottom-Sheet). Token-basiert.
   ============================================================ */
/* Statisch oben rechts am Panel verankert — außerhalb des scrollenden
   .modal-body, daher unbeweglich beim Scrollen. */
.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 6;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--txt2);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { color: var(--txt); background: var(--hover); }

/* Titel nicht unter das X laufen lassen */
#modal-panel h2,
#templates-modal-panel h2,
#template-edit-panel h2,
#day-template-edit-panel h2,
#day-template-apply-panel h2,
#profile-panel h2 { padding-right: 2.6rem; }

/* ============================================================
   Panel = fixer Positionskontext (scrollt nicht); der Inhalt
   scrollt in .modal-body. So bleibt das absolute „X" statisch.
   ============================================================ */
#modal-panel,
#templates-modal-panel,
#template-edit-panel,
#day-template-edit-panel,
#day-template-apply-panel,
#profile-panel {
  position: relative;
  overflow: hidden;   /* statt overflow-y:auto auf dem Panel */
  padding: 0;         /* Padding wandert in .modal-body */
  gap: 0;             /* Gap wandert in .modal-body */
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
}
#modal-panel .modal-body { padding: 1.1rem 1.25rem; gap: 0.55rem; }
#day-template-edit-panel .modal-body { gap: 0.6rem; }

/* ============================================================
   ============================================================
   Dienstplan: Tages-Banner (Agenda) + Wochen-Bänder + Dialog
   ============================================================
   ============================================================ */

/* Gemeinsame Symbol-/Badge-Bausteine */
.duty-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.duty-icon svg { width: 15px; height: 15px; display: block; }
.duty-badge-wrap { position: relative; flex: 0 0 auto; display: inline-flex; }
.duty-badge {
  width: 24px; height: 24px; border-radius: 50%;
  background: #777; color: #fff;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; user-select: none;
}
/* Notiz-Punkt: gleiche Optik für Dienste (.duty-note-dot, absolut am Badge)
   und Termine (.note-dot, inline an Zeit/Titel). */
.duty-note-dot, .note-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface);
}
.duty-note-dot { position: absolute; top: -2px; right: -2px; }
.note-dot {
  display: inline-block;
  flex: 0 0 auto;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.duty-add { flex: 0 0 auto; font-size: 0.8rem; font-weight: 600; opacity: 0.85; }

/* --- Tagesansicht: vollbreite Banner --- */
.duty-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0.25rem 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}
.duty-banner .duty-spacer { flex: 1 1 auto; }
.duty-banner .duty-label { font-weight: 600; }
.duty-banner .duty-note-text {
  font-size: 0.8rem;
  opacity: 0.85;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 45%;
}
.duty-banner .duty-badge { width: 28px; height: 28px; font-size: 12px; }
.duty-morning { background: var(--morning); color: var(--morning-txt); }
.duty-evening { background: var(--evening); color: var(--evening-txt); }

/* --- Wochenansicht: verdichtete Termin-Farbpunkte je Tagesspalte --- */
.fc .fc-daygrid-day-frame { position: relative; padding-top: 2px; padding-bottom: 4px; }
/* FC-eigene Event-Liste in der Woche ausblenden — wir zeigen nur Farbpunkte. */
body.view-week .fc-daygrid-day-events { display: none !important; }
.week-dots {
  display: flex; flex-wrap: wrap; align-content: flex-start;
  justify-content: center;            /* Punkt-Cluster horizontal zentrieren */
  gap: 4px; padding: 0 3px; margin-top: 6px;  /* etwas Abstand unter dem Datum */
  min-height: 10px;
}
.week-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.week-dot.is-done { opacity: 0.4; }
.week-dots-more { font-size: 0.62rem; color: var(--txt2); line-height: 10px; align-self: center; }
/* Dezentes Anzahl-Label unter den Punkten ("N Termine" / "keine"). */
.week-count {
  text-align: center;
  font-size: 0.62rem;
  color: var(--txt2);
  margin-top: 3px;
  padding-bottom: 2px;
  line-height: 1.2;
}

/* --- Zuweisungs-Dialog (token-basiert, Dark/Light) --- */
#duty-dialog-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#duty-dialog-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#duty-dialog-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }
#duty-dialog-panel label {
  display: flex; flex-direction: column;
  font-size: 0.8rem; color: var(--txt2); gap: 0.15rem;
}
#duty-dialog-panel select,
#duty-dialog-panel textarea {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  min-height: 36px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--txt);
  background: var(--surface2);
  font-family: inherit;
}
#duty-dialog-panel textarea { resize: vertical; min-height: 3rem; }

/* ============================================================
   Filter: Header-Trichter, Aktiv-Chips, Filter-Sheet
   ============================================================ */

/* --- Header-Icon-Buttons: Trichter + Burger einheitlich, schlicht --- */
.header-icon-btn, #burger-btn {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  margin: 0;                 /* überschreibt header button margin-left */
  border: none;              /* kein schwerer Rahmen */
  border-radius: 10px;
  background: transparent;
  color: var(--txt2);        /* ruhiger Default */
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}
.header-icon-btn:hover, #burger-btn:hover,
.header-icon-btn:active, #burger-btn:active {
  background: var(--hover);  /* dezente Füllfläche beim Tap/Hover */
  color: var(--txt);
}
.header-icon-btn { display: inline-flex; }  /* immer sichtbar; Burger-Display steuern Basis/Mobile */
.header-icon-btn svg { width: 20px; height: 20px; display: block; }
#burger-btn { font-size: 1.35rem; }         /* ☰-Glyph ~20px */
/* Aktiv-Punkt (JS schaltet display) */
.filter-dot {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

/* --- Aktiv-Chip-Zeile unter dem Header --- */
#filter-chips { display: none; }
#filter-chips.has-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
#filter-chips.has-filter::-webkit-scrollbar { display: none; }
/* Bei aktivem Filter den Hauptbereich um die Chip-Zeile (40px) kürzen,
   damit die Voll-Höhe-Layouts nicht überlaufen. */
#filter-chips.has-filter ~ main { height: calc(100vh - 60px - 40px - var(--tabbar-h) - env(safe-area-inset-bottom, 0px)); }

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--inset);                 /* Fallback, falls color-mix fehlt */
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid var(--line2);           /* Fallback, falls color-mix fehlt */
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  cursor: pointer;
}
.filter-chip:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.filter-chip-x { font-size: 1rem; line-height: 1; opacity: 0.8; }
.filter-clear-link {
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  padding: 0.25rem 0.4rem;
  background: transparent;
  border: none;
  color: var(--txt2);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}
.filter-clear-link:hover { color: var(--txt); }

/* --- Filter-Sheet --- */
#filter-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#filter-panel {
  position: relative;       /* Anker für statisches Schließen-X */
  overflow: hidden;         /* nur .modal-body scrollt → „X" bleibt fix */
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#filter-panel h2 { margin: 0 0 0.25rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }
.filter-section { margin-bottom: 0.5rem; }
.filter-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.filter-section-head h3 { margin: 0; font-size: 0.95rem; color: var(--txt); }
.filter-all-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--txt2);
  cursor: pointer;
}
.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  background: var(--inset);
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.4rem;
  font-size: 0.9rem;
  color: var(--txt);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 40px;
}
.filter-option:hover { background: var(--hover); }
.filter-option input[type="checkbox"],
.filter-all-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

/* Mobile: Filter-Sheet von unten (gleicher Stil wie die anderen Sheets) */
@media (max-width: 640px) and (orientation: portrait),
       (max-width: 900px) and (orientation: landscape) {
  #filter-chips.has-filter ~ main { height: calc(100vh - 56px - 40px - var(--tabbar-h) - env(safe-area-inset-bottom, 0px)); }
  #filter-overlay { align-items: flex-end; }
  #filter-panel {
    max-width: none;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }
  #filter-panel .modal-body { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* Dark Mode: Tokens decken die Flächen ab; Backdrop explizit setzen. */
[data-theme="dark"] #filter-overlay { background: var(--overlay); }
[data-theme="dark"] #filter-panel { box-shadow: 0 10px 40px rgba(0,0,0,0.6); }

/* ============================================================
   Tagesansicht: „+"-Auslöser + Baustein-Auswahl-Sheet über der Agenda
   ============================================================ */
/* ============================================================
   Wochenansicht (FullCalendar-Toolbar) — kompakte Navigationszeile
   Am Dateiende, damit es FCs CDN-CSS und die Mobile-Regeln überschreibt.
   ============================================================ */
.fc .fc-toolbar.fc-header-toolbar {
  margin-bottom: 0.3rem;
  min-height: 0;
  gap: 0.3rem;
}
/* prev/next stehen in FC in einer Button-Group mit überlappenden Rändern → sauber trennen */
.fc .fc-button-group { gap: 0.3rem; }
.fc .fc-button-group > .fc-button { margin: 0; }
/* ‹ › als kleine, schlichte Icon-Buttons */
.fc .fc-prev-button,
.fc .fc-next-button {
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--txt2);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.fc .fc-prev-button:hover,
.fc .fc-next-button:hover,
.fc .fc-prev-button:not(:disabled):active,
.fc .fc-next-button:not(:disabled):active {
  background: var(--hover);
  border-color: var(--line);
  color: var(--txt);
  box-shadow: none;
}
.fc .fc-icon { font-size: 0.85rem; }   /* kompaktere Chevrons */

/* Titel mittig, kompakt, antippbar (= Kalender-Sprung zu beliebiger Woche) */
.fc .fc-toolbar-title {
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

/* „Heute" als kleine Akzent-Pille; FC blendet den Button im aktuellen Zeitraum
   per disabled aus → wir verstecken ihn dann ganz. */
.fc .fc-today-button {
  min-height: 0;
  height: 24px;
  padding: 0.1rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
  border-radius: 999px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  opacity: 1;
  box-shadow: none;
}
.fc .fc-today-button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
/* Im aktuellen Zeitraum deaktiviert FC den Button → unsichtbar, aber Platz bleibt
   reserviert, damit Titel/Pfeile nicht springen (E). */
.fc .fc-today-button:disabled { visibility: hidden; }

/* ============================================================
   Futterplan-Screen (Schritt 1: reine Anzeige)
   ============================================================ */
#feedplan-view {
  height: 100%;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0.5rem calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* Pferd-Umschalter (Chips, horizontal scrollbar bei vielen Pferden) */
.feed-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.5rem 0 0.4rem;
}
.feed-horse-switcher {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
}
.feed-horse-switcher::-webkit-scrollbar { display: none; }
.feed-horse-chip {
  flex: 0 0 auto;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.feed-horse-chip:hover { border-color: var(--accent); }
.feed-horse-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.feed-body { padding-top: 0.5rem; }

.feed-empty {
  color: var(--txt);
  opacity: 0.7;
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

/* --- Hochformat: Karten je Fütterungszeit --- */
.feed-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.feed-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.feed-card-icon { display: inline-flex; }
.feed-card-icon svg { width: 20px; height: 20px; display: block; }
.feed-card-name { font-size: 1rem; }

/* Warm/kühl/Zusatz-Töne (Konsistenz zum Dienstplan) */
.feed-tone-morning .feed-card-head {
  background: var(--morning); color: var(--morning-txt);
  border-bottom-color: transparent;
}
.feed-tone-evening .feed-card-head {
  background: var(--evening); color: var(--evening-txt);
  border-bottom-color: transparent;
}
.feed-tone-extra .feed-card-head {
  background: var(--surface2);
  color: var(--accent);
}
.feed-tone-neutral .feed-card-head { background: var(--surface2); }

.feed-card-list { padding: 0.25rem 0; }
/* Zeile ist ein Button (antippbar → Bearbeiten); Button-Defaults zurücksetzen. */
.feed-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--txt);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.feed-row:hover { background: var(--surface2); }
.feed-row + .feed-row { border-top: 1px solid var(--line); }

/* „+ Eintrag" am Kartenende */
.feed-card-add {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  border: none;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.feed-card-add:hover { background: var(--surface2); }
.feed-row-left {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.feed-row-type { font-size: 0.95rem; }
.feed-row-note {
  font-size: 0.8rem;
  opacity: 0.7;
  font-style: italic;
}
.feed-row-amount {
  flex: 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Querformat: Matrix (Sorten × Zeiten) --- */
.feed-matrix-wrap { overflow-x: auto; }
.feed-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.feed-matrix th, .feed-matrix td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
  text-align: center;
}
.feed-matrix-corner { background: var(--surface); border: none; }
.feed-matrix-th {
  font-weight: 600;
  white-space: nowrap;
}
.feed-matrix-th.feed-tone-morning { background: var(--morning); color: var(--morning-txt); }
.feed-matrix-th.feed-tone-evening { background: var(--evening); color: var(--evening-txt); }
.feed-matrix-th.feed-tone-extra { background: var(--surface2); color: var(--accent); }
.feed-matrix-th.feed-tone-neutral { background: var(--surface2); }
.feed-matrix-icon { display: inline-flex; vertical-align: middle; margin-right: 0.3rem; }
.feed-matrix-icon svg { width: 16px; height: 16px; display: block; }
.feed-matrix-rowhead {
  text-align: left;
  font-weight: 600;
  background: var(--surface);
  white-space: nowrap;
}
.feed-matrix-cell {
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  cursor: pointer;             /* antippbar: gefüllt = bearbeiten, leer = anlegen */
}
.feed-matrix-cell:hover { background: var(--surface2); }
.feed-matrix-cell.is-empty { opacity: 0.4; }
.feed-matrix-cell.is-empty:hover { opacity: 0.7; }

/* ============================================================
   Futtereintrag-Sheet (anlegen / bearbeiten) — wie Dienst-Dialog
   ============================================================ */
#feed-entry-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#feed-entry-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#feed-entry-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }
#feed-entry-panel label {
  display: flex; flex-direction: column;
  font-size: 0.8rem; color: var(--txt2); gap: 0.15rem;
  flex: 1;
}
#feed-entry-panel .modal-row > label { flex: 1 1 120px; min-width: 0; }
#feed-entry-panel select,
#feed-entry-panel input,
#feed-entry-panel textarea {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  min-height: 40px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--txt);
  background: var(--surface2);
  font-family: inherit;
}
#feed-entry-panel textarea { resize: vertical; min-height: 3rem; }
#feed-entry-panel #feed-entry-remove {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding-left: 0;
}
#feed-entry-panel #feed-entry-remove:hover { background: transparent; text-decoration: underline; }
.modal-error {
  margin: 0;
  font-size: 0.82rem;
  color: var(--danger);
}

/* ============================================================
   Verwalten: Sorten & Zeiten (admin-only) — Liste + Edit-Sheet
   ============================================================ */
#feed-manage-overlay,
#feed-master-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#feed-manage-panel,
#feed-master-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#feed-manage-panel { max-width: 520px; }
#feed-master-panel { max-width: 420px; }
#feed-manage-panel h2,
#feed-master-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }

/* --- Liste: zwei Abschnitte --- */
.feed-manage-section { margin-bottom: 0.5rem; }
.feed-manage-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.25rem 0 0.4rem;
}
.feed-manage-section-head h3 { margin: 0; font-size: 0.95rem; color: var(--txt); }
.feed-manage-section-head button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.feed-manage-section-head button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.feed-manage-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.feed-manage-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--txt);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.feed-manage-row + .feed-manage-row { border-top: 1px solid var(--line); }
.feed-manage-row:hover { background: var(--surface2); }
.feed-manage-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1;
}
.feed-manage-row-name { font-size: 0.95rem; }
.feed-manage-row-meta { font-size: 0.78rem; color: var(--txt2); }
.feed-manage-row.is-hidden { opacity: 0.55; }
.feed-manage-hidden-badge {
  flex: 0 0 auto;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--inset);
  color: var(--txt2);
  border: 1px solid var(--line);
}

/* --- Edit-Sheet: Felder + Toggle --- */
#feed-master-panel label {
  display: flex; flex-direction: column;
  font-size: 0.8rem; color: var(--txt2); gap: 0.15rem;
}
#feed-master-panel input:not([type="checkbox"]),
#feed-master-panel select {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  min-height: 40px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--txt);
  background: var(--surface2);
  font-family: inherit;
}
.feed-master-toggle {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  background: var(--inset);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem !important;
  color: var(--txt) !important;
  cursor: pointer;
}
.feed-master-toggle input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Kalender-Abo (iCal) im Profil-Modal */
.ical-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.ical-section-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--txt);
}
.ical-link-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ical-link-row input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}
.ical-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.ical-regen-btn { margin-left: auto; }
#profile-ical-copy.is-copied {
  color: var(--accent);
  border-color: var(--accent);
}
#feed-master-panel #feed-master-delete {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding-left: 0;
}
#feed-master-panel #feed-master-delete:hover { background: transparent; text-decoration: underline; }

/* ============================================================
   Verbrauchsgüter-Screen (Übersicht + Detail)
   ============================================================ */
#consumables-view {
  height: 100%;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.6rem 0.6rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.cons-empty {
  color: var(--txt2);
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.95rem;
}
.cons-error {
  background: var(--status-yellow-bg);
  color: var(--status-yellow-txt);
  border: 1px solid var(--status-yellow);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

/* --- Statusfarben (Pille, Balken, Texte) --- */
.cons-pill {
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.cons-green { background: var(--status-green-bg); color: var(--status-green-txt); }
.cons-yellow { background: var(--status-yellow-bg); color: var(--status-yellow-txt); }
.cons-red { background: var(--status-red-bg); color: var(--status-red-txt); }
.cons-neutral { background: var(--inset); color: var(--txt2); }
.cons-text-green { color: var(--status-green-txt); }
.cons-text-yellow { color: var(--status-yellow-txt); }
.cons-text-red { color: var(--status-red-txt); }
.cons-text-neutral { color: var(--txt2); }

.cons-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--inset);
  overflow: hidden;
  margin: 0.5rem 0 0;
}
.cons-bar-fill { height: 100%; border-radius: 999px; }
.cons-bar-fill.cons-green { background: var(--status-green); }
.cons-bar-fill.cons-yellow { background: var(--status-yellow); }
.cons-bar-fill.cons-red { background: var(--status-red); }
.cons-bar-fill.cons-neutral { background: var(--txt3); }

/* --- Übersichtskarten --- */
.cons-list { display: flex; flex-direction: column; gap: 0.6rem; }
/* Pferd-Gruppenüberschrift in Verbrauchsgüter-Liste & Einkaufsliste */
.cons-group-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--txt2);
}
.cons-group-title:first-child { margin-top: 0; }
/* Dezente „extern"-Markierung */
.cons-extern-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line2);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  vertical-align: middle;
  color: var(--txt2);
}
.cons-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cons-card:hover { border-color: var(--line2); }
.cons-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}
.cons-card-titles { min-width: 0; }
.cons-card-name { font-size: 1rem; font-weight: 600; }
.cons-card-sub { font-size: 0.8rem; color: var(--txt2); margin-top: 0.05rem; }
.cons-card-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--txt2);
}
.cons-stock { font-weight: 600; color: var(--txt); white-space: nowrap; }
.cons-stock.is-low { color: var(--status-red-txt); }

.cons-open-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cons-open-btn:hover { background: var(--hover); }
.cons-open-btn-lg {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cons-open-btn-lg:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.cons-add-btn {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  border: 1px dashed var(--line2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt2);
  font: inherit;
  cursor: pointer;
}
.cons-add-btn:hover { color: var(--txt); border-color: var(--accent); }

/* --- Detail --- */
.cons-detail-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.cons-detail-back {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--txt);
  cursor: pointer;
  padding: 0;
}
.cons-detail-back:hover { background: var(--hover); }
.cons-detail-back svg { width: 22px; height: 22px; display: block; }
.cons-detail-name { margin: 0; font-size: 1.2rem; color: var(--txt); }

.cons-prognosis {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.7rem;
}
.cons-prognosis.cons-green { border-left-color: var(--status-green); }
.cons-prognosis.cons-yellow { border-left-color: var(--status-yellow); }
.cons-prognosis.cons-red { border-left-color: var(--status-red); }
.cons-prognosis.cons-neutral { border-left-color: var(--txt3); }
.cons-prognosis-line { font-size: 0.85rem; color: var(--txt2); }
.cons-prognosis-big { font-size: 1.4rem; font-weight: 700; margin: 0.2rem 0; }
.cons-prognosis-reach { font-size: 0.9rem; font-weight: 600; }
.cons-prognosis-note { font-size: 0.9rem; color: var(--txt2); }
.cons-prognosis .cons-bar { margin-top: 0.6rem; }

/* --- Vorrat-Stepper --- */
.cons-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.7rem;
}
.cons-stepper-label { font-size: 0.9rem; color: var(--txt); }
.cons-step-controls { display: flex; align-items: center; gap: 0.6rem; }
.cons-step-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--line2);
  border-radius: 50%;
  background: var(--surface2);
  color: var(--txt);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cons-step-btn:hover { border-color: var(--accent); }
.cons-step-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cons-step-val {
  min-width: 2ch;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cons-step-val.is-low { color: var(--status-red-txt); }

/* --- Verlauf + Einstellungen --- */
.cons-history, .cons-settings {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  margin-top: 0.7rem;
}
.cons-history-title { margin: 0 0 0.4rem; font-size: 0.95rem; color: var(--txt); }
#cost-horse-filter { margin: 0 0 0.8rem; flex-wrap: wrap; }
.cons-history-list { display: flex; flex-direction: column; }
.cons-history-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.88rem;
}
.cons-history-row + .cons-history-row { border-top: 1px solid var(--line); }
.cons-history-date { font-variant-numeric: tabular-nums; }
.cons-history-info { color: var(--txt2); }
.cons-history-avg { margin-top: 0.4rem; font-size: 0.82rem; color: var(--txt2); font-weight: 600; }

/* --- Verbrauchs-Diagramm „Haltbarkeit pro Gebinde" (Inline-SVG, token-basiert) --- */
.cons-chart {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  margin-top: 0.7rem;
}
.cons-chart-svg { width: 100%; height: auto; display: block; margin-top: 0.2rem; }
.cons-chart-bar { fill: var(--accent); }
.cons-chart-axis { stroke: var(--line2); stroke-width: 1; }
.cons-chart-avg {
  stroke: var(--status-yellow);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
.cons-chart-avg-label { fill: var(--status-yellow-txt); font-size: 9px; font-weight: 700; }
.cons-chart-val { fill: var(--txt2); font-size: 9px; font-weight: 600; }
.cons-chart-xlabel { fill: var(--txt3); font-size: 8px; }

.cons-setting-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  color: var(--txt2);
}
.cons-setting-row + .cons-setting-row { border-top: 1px solid var(--line); }
.cons-setting-val { color: var(--txt); font-weight: 600; }
.cons-settings-hint { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--txt3); font-style: italic; }

/* Querformat: Übersicht zweispaltig, mehr Platz nutzen */
@media (orientation: landscape) and (min-width: 700px) {
  #consumables-view { max-width: 1000px; }
  body.view-consumables .cons-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
}

/* ============================================================
   Verbrauchsgüter Schritt 2: Warenkorb-Badge, Formular, Einkaufsliste
   ============================================================ */
.cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--status-red);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* Bearbeiten-Stift im Detail-Kopf */
.cons-detail-edit {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--txt2);
  cursor: pointer;
  padding: 0;
}
.cons-detail-edit:hover { background: var(--hover); color: var(--txt); }
.cons-detail-edit svg { width: 19px; height: 19px; display: block; }
.cons-detail-head .cons-detail-name { flex: 1; }

/* --- Formular- und Einkaufs-Overlays (Stil wie feed-master/duty-dialog) --- */
#consumable-form-overlay,
#care-form-overlay,
#doc-form-overlay,
#shopping-overlay,
#shopping-item-form-overlay,
#topic-form-overlay,
#buy-qty-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
/* Eintrag-Formular liegt über der Einkaufsliste (falls beide je gleichzeitig offen) */
#shopping-item-form-overlay { z-index: 1050; }
#consumable-form-panel,
#care-form-panel,
#doc-form-panel,
#shopping-panel,
#shopping-item-form-panel,
#topic-form-panel,
#buy-qty-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#consumable-form-panel { max-width: 460px; }
#care-form-panel { max-width: 460px; }
#doc-form-panel { max-width: 460px; }
#shopping-panel { max-width: 480px; }
#shopping-item-form-panel { max-width: 460px; }
#topic-form-panel { max-width: 460px; }
#buy-qty-panel { max-width: 380px; }
#consumable-form-panel h2,
#care-form-panel h2,
#doc-form-panel h2,
#shopping-panel h2,
#shopping-item-form-panel h2,
#topic-form-panel h2,
#buy-qty-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }

#consumable-form-panel label,
#care-form-panel label,
#doc-form-panel label,
#shopping-item-form-panel label,
#topic-form-panel label {
  display: flex; flex-direction: column;
  font-size: 0.8rem; color: var(--txt2); gap: 0.15rem;
  flex: 1;
}
#consumable-form-panel .modal-row > label,
#care-form-panel .modal-row > label { flex: 1 1 130px; min-width: 0; }
#consumable-form-panel input:not([type="checkbox"]),
#care-form-panel input:not([type="checkbox"]),
#care-form-panel select,
#doc-form-panel input:not([type="checkbox"]),
#doc-form-panel select,
#shopping-item-form-panel input:not([type="checkbox"]),
#shopping-item-form-panel select,
#topic-form-panel input:not([type="checkbox"]),
#topic-form-panel select,
#topic-form-panel textarea {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  min-height: 40px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--txt);
  background: var(--surface2);
  font-family: inherit;
}
#topic-form-panel textarea { resize: vertical; line-height: 1.4; }
#consumable-form-panel #consumable-form-delete,
#care-form-panel #care-form-delete {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding-left: 0;
}
#consumable-form-panel #consumable-form-delete:hover,
#care-form-panel #care-form-delete:hover { background: transparent; text-decoration: underline; }
.care-form-context { margin: 0 0 0.4rem; font-size: 0.82rem; color: var(--txt2); }

/* ============================================================
   Dokumente (horse_documents) — Liste, Thumbs, Vollbild
   ============================================================ */
#documents-view { max-width: 760px; margin: 0 auto; }
.docs-empty {
  text-align: center;
  color: var(--txt2);
  padding: 1.2rem 0.6rem;
  font-size: 0.9rem;
}
.docs-error {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
}
.doc-horse-group { margin: 0 0 1.1rem; }
.doc-horse-title { margin: 0.4rem 0 0.3rem; font-size: 1.05rem; }
.doc-cat-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt2);
}
.doc-list { display: flex; flex-direction: column; gap: 0.4rem; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}
.doc-row:hover { background: var(--hover); }
.doc-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
  border: 1px solid var(--line2);
}
.doc-pdf-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt2);
}
.doc-pdf-icon svg { width: 24px; height: 24px; }
.doc-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.doc-row-title {
  font-size: 0.9rem;
  color: var(--txt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-row-date { font-size: 0.75rem; color: var(--txt2); }
.doc-row-del {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--txt2);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.doc-row-del:hover { color: var(--danger); background: var(--hover); }
.doc-row-del svg { width: 18px; height: 18px; display: block; }

/* Bild-Vollansicht (Dokumente + Pflege-Fotos) */
#doc-fullscreen-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 1200;
  cursor: pointer;
}
#doc-fullscreen-img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
}

/* Pflege-Verlauf: Foto-Thumb + Kamera-Button */
.care-photo-thumb {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
  border: 1px solid var(--line2);
  cursor: zoom-in;
}
.care-photo-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--txt2);
  padding: 0.3rem 0.45rem;
  cursor: pointer;
}
.care-photo-btn:hover { color: var(--txt); background: var(--hover); }
.care-photo-btn svg { width: 17px; height: 17px; display: block; }

/* --- Einkaufsliste --- */
#shopping-list { display: flex; flex-direction: column; gap: 0.5rem; }
.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.55rem 0.7rem;
}
.shop-row.cons-red { border-left-color: var(--status-red); }
.shop-row.cons-yellow { border-left-color: var(--status-yellow); }
.shop-row-main { min-width: 0; }
.shop-row-name { font-size: 0.95rem; font-weight: 600; }
.shop-row-reason { font-size: 0.8rem; margin-top: 0.1rem; }
.shop-buy-btn {
  flex: 0 0 auto;
  padding: 0.4rem 0.8rem;
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shop-buy-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
/* Freier (manueller) Eintrag: dezenter linker Rand, Aktionen rechts (gekauft + löschen) */
.shop-row-manual { border-left-color: var(--line2); }
.shop-row-actions { display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }
.shop-del-btn {
  flex: 0 0 auto;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--txt2);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shop-del-btn:hover { border-color: var(--status-red); color: var(--status-red); }

/* Mengenabfrage: Stepper als Block (Label oben, Controls darunter zentriert) */
.buy-qty-stepper { flex-direction: column; align-items: stretch; gap: 0.6rem; }
.buy-qty-stepper .cons-step-controls { justify-content: center; }

/* ============================================================
   Verbrauchsgüter Schritt 3: Kosten-Overlay (gestapeltes SVG)
   ============================================================ */
#cost-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#cost-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#cost-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }

#cost-chart { margin-top: 0.2rem; }
#cost-chart .cons-chart-svg { width: 100%; height: auto; display: block; }

/* Stapel-Segmente (SVG) + Legenden-/Aufschlüsselungs-Punkte (HTML) teilen sich die Tokens */
.cost-seg-0 { fill: var(--cseg-0); } .cost-dot.cost-seg-0 { background: var(--cseg-0); }
.cost-seg-1 { fill: var(--cseg-1); } .cost-dot.cost-seg-1 { background: var(--cseg-1); }
.cost-seg-2 { fill: var(--cseg-2); } .cost-dot.cost-seg-2 { background: var(--cseg-2); }
.cost-seg-3 { fill: var(--cseg-3); } .cost-dot.cost-seg-3 { background: var(--cseg-3); }
.cost-seg-4 { fill: var(--cseg-4); } .cost-dot.cost-seg-4 { background: var(--cseg-4); }
.cost-seg-5 { fill: var(--cseg-5); } .cost-dot.cost-seg-5 { background: var(--cseg-5); }
.cost-seg-6 { fill: var(--cseg-6); } .cost-dot.cost-seg-6 { background: var(--cseg-6); }
.cost-seg-7 { fill: var(--cseg-7); } .cost-dot.cost-seg-7 { background: var(--cseg-7); }
.cost-seg { stroke: var(--surface); stroke-width: 0.5; }
.cost-slot-sel { fill: var(--inset); }
.cost-hit { cursor: pointer; }
.cons-chart-xlabel.is-sel { fill: var(--txt); font-weight: 700; }

.cost-legend { margin-top: 0.5rem; }
.cost-legend-inner { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; }
.cost-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--txt2); }
.cost-dot {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
  display: inline-block;
}

.cost-breakdown {
  margin-top: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
}
.cost-breakdown-list { display: flex; flex-direction: column; }
.cost-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.cost-breakdown-row + .cost-breakdown-row { border-top: 1px solid var(--line); }
.cost-breakdown-name { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
.cost-breakdown-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* „Sonstiges" aufklappbar: anklickbare Zeile + Pfeil, der bei „offen" rotiert */
.cost-breakdown-row-clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cost-breakdown-caret {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.75rem;
  color: var(--txt2);
  transition: transform 0.12s ease;
}
.cost-breakdown-row-clickable.is-open .cost-breakdown-caret { transform: rotate(90deg); }
/* Einzelposten-Unterliste unter der „Sonstiges"-Zeile */
.cost-sonstiges-detail {
  display: flex;
  flex-direction: column;
  padding: 0.1rem 0 0.3rem 1rem;
  border-left: 2px solid var(--line2);
  margin: 0 0 0.2rem 0.3rem;
}
.cost-sonstiges-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
  color: var(--txt2);
}
.cost-sonstiges-title { min-width: 0; display: inline-flex; align-items: baseline; gap: 0.5rem; }
.cost-sonstiges-date { font-size: 0.75rem; color: var(--txt3, var(--txt2)); white-space: nowrap; }
.cost-sonstiges-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-breakdown-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--line2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Bewegungsstatistik-Screen
   ============================================================ */
#movement-view {
  height: 100%;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.6rem 0.6rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.mv-empty {
  color: var(--txt2);
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.95rem;
}

/* Bedienleiste: Pferd-Chips (geteilte feed-horse-*-Optik) + Zeitraum-Segmented */
.mv-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.4rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mv-seg {
  display: inline-flex;
  align-self: flex-start;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--inset);
}
.mv-seg-btn {
  border: none;
  background: transparent;
  color: var(--txt2);
  padding: 0.35rem 0.85rem;
  min-height: 34px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mv-seg-btn.is-active { background: var(--accent); color: #fff; font-weight: 600; }

/* Summary-Karten */
.mv-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.mv-sum-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.7rem;
}
.mv-sum-value { font-size: 1.2rem; font-weight: 700; color: var(--txt); }
.mv-sum-label { font-size: 0.78rem; color: var(--txt2); margin-top: 0.1rem; }
.mv-sum-sub { font-size: 0.72rem; color: var(--txt3); }

/* Allgemeine Karte */
.mv-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  margin-top: 0.7rem;
}
.mv-card-title { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--txt); }

/* 14-Tage-Punkte */
.mv-dots { display: flex; gap: 0.3rem; flex-wrap: nowrap; }
.mv-dot {
  flex: 1 1 0;
  height: 16px;
  max-width: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line2);
  background: transparent;
}
.mv-dot.is-on { background: var(--accent); border-color: var(--accent); }
.mv-dots-legend { margin-top: 0.4rem; font-size: 0.74rem; color: var(--txt3); }

/* Diagramm-Segmente: erledigt voll, offen blass (Akzent) */
.cons-chart-svg .mv-seg-done { fill: var(--accent); }
.cons-chart-svg .mv-seg-open { fill: var(--accent); opacity: 0.38; }
.mv-chart-legend { display: flex; gap: 1rem; margin-top: 0.4rem; font-size: 0.78rem; color: var(--txt2); }
.mv-leg-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.mv-leg-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.mv-leg-swatch.mv-seg-done-bg { background: var(--accent); }
.mv-leg-swatch.mv-seg-open-bg { background: var(--accent); opacity: 0.38; }

/* Nach Art */
.mv-art-row { padding: 0.4rem 0; }
.mv-art-row + .mv-art-row { border-top: 1px solid var(--line); }
.mv-art-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  margin-bottom: 0.3rem;
}
.mv-art-name { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; min-width: 0; }
.mv-art-dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; background: var(--txt3); }
.mv-art-meta { font-size: 0.8rem; color: var(--txt2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mv-art-track { height: 8px; border-radius: 999px; background: var(--inset); overflow: hidden; }
.mv-art-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 2px; }

/* Querformat: Summary vierspaltig, mehr Platz */
@media (orientation: landscape) and (min-width: 700px) {
  #movement-view { max-width: 1000px; }
  .mv-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   Pflege-Screen (Übersicht + Status)
   ============================================================ */
#care-view {
  height: 100%;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.6rem 0.6rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.care-empty {
  color: var(--txt2);
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.95rem;
}
.care-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.4rem 0 0.5rem;
}
.care-list { display: flex; flex-direction: column; gap: 0.6rem; }

.care-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.8rem;
}
/* Status-Akzent am linken Rand (überfällig hervorgehoben) */
.care-card.care-red { border-left-color: var(--status-red); }
.care-card.care-yellow { border-left-color: var(--status-yellow); }
.care-card.care-green { border-left-color: var(--status-green); }
.care-card.care-neutral { border-left-color: var(--txt3); }

.care-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}
.care-card-name { font-size: 1rem; font-weight: 600; }
.care-card-bell { font-weight: 400; font-size: 0.82rem; opacity: 0.7; }
.care-card-interval { font-size: 0.8rem; color: var(--txt2); margin-top: 0.1rem; }
.care-card .cons-bar { margin: 0.5rem 0 0; }
.care-card-last { font-size: 0.82rem; color: var(--txt2); margin-top: 0.4rem; }

.care-done-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.care-done-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Querformat: zweispaltige Karten */
@media (orientation: landscape) and (min-width: 700px) {
  #care-view { max-width: 1000px; }
  body.view-care .care-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }
}

/* --- Pflege-Detail (Status + gemeinsamer Verlauf) --- */
.care-detail-status {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.9rem;
}
.care-detail-status.care-red { border-left-color: var(--status-red); }
.care-detail-status.care-yellow { border-left-color: var(--status-yellow); }
.care-detail-status.care-green { border-left-color: var(--status-green); }
.care-detail-status.care-neutral { border-left-color: var(--txt3); }
.care-detail-pillrow { display: flex; }
.care-detail-status .cons-pill { font-size: 0.85rem; }
.care-detail-interval { font-size: 0.85rem; color: var(--txt2); margin-top: 0.45rem; }
.care-detail-status .cons-bar { margin: 0.55rem 0 0; }
.care-detail-last { font-size: 0.85rem; color: var(--txt2); margin-top: 0.45rem; }

/* Quelle-Tag im Verlauf + löschbare manuelle Zeilen */
.care-history-info { display: inline-flex; align-items: center; gap: 0.45rem; }
.care-src-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}
.care-src-manual { background: var(--accent-soft, var(--surface2)); color: var(--accent); }
.care-src-appt { background: var(--surface2); color: var(--txt2); border: 1px solid var(--line); }
.care-history-note { color: var(--txt2); }
.care-history-row.is-deletable { cursor: pointer; }
.care-history-row.is-deletable:hover { background: var(--hover); }

/* ============================================================
   Übersicht / Dashboard (Schritt 1)
   ============================================================ */
#dashboard-view {
  height: 100%;
  overflow-y: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.6rem 0.6rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.dash-empty {
  color: var(--txt2);
  text-align: center;
  padding: 1rem;
  font-size: 0.92rem;
}
.dash-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.4rem 0 0.5rem;
}
.dash-datehead { margin: 0.2rem 0 0.9rem; }
.dash-date-big {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.15;
}
.dash-date-sub { font-size: 0.85rem; color: var(--txt2); margin-top: 0.2rem; }

.dash-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.7rem;
}
.dash-section-title { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--txt); }
.dash-section .dash-empty { text-align: left; padding: 0.2rem 0; }

.dash-list { display: flex; flex-direction: column; }
.dash-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  min-height: 40px;
}
.dash-row + .dash-row { border-top: 1px solid var(--line); }
.dash-row-left { flex: 1; color: var(--txt); }
.dash-row-right { flex: 0 0 auto; }
.dash-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--txt);
  min-width: 3.2em;
}
.dash-appt-name { flex: 1; color: var(--txt); }

/* Dienst-Badges (Sonne/Mond + Label + Person) */
.dash-duty-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dash-duty {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}
.dash-duty-label { font-size: 0.85rem; font-weight: 600; }
.dash-duty .duty-icon { width: 18px; height: 18px; display: inline-flex; }
.dash-duty .duty-icon svg { width: 18px; height: 18px; }

/* KPI-Streifen: 4 antippbare Kacheln */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}
.dash-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 64px;
  padding: 0.55rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--txt);
  font: inherit;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.dash-kpi:hover { border-color: var(--accent); }
.dash-kpi-value { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.dash-kpi-label { font-size: 0.72rem; color: var(--txt2); }
/* Farbstufen (gleiche Status-Tokens wie die Pflege-/Verbrauchsgüter-Pillen) */
.dash-kpi-red { background: var(--status-red-bg); border-color: var(--status-red); }
.dash-kpi-red .dash-kpi-value { color: var(--status-red-txt); }
.dash-kpi-yellow { background: var(--status-yellow-bg); border-color: var(--status-yellow); }
.dash-kpi-yellow .dash-kpi-value { color: var(--status-yellow-txt); }
.dash-kpi-green { background: var(--status-green-bg); border-color: var(--status-green); }
.dash-kpi-green .dash-kpi-value { color: var(--status-green-txt); }

/* Dienstplan-Lücken nächste Woche: antippbare Hinweis-Karte (gelbe Status-Tokens) */
.dash-dutygap-card {
  display: block; width: 100%; box-sizing: border-box;
  padding: 0.7rem 0.8rem; margin-bottom: 0.7rem;
  border: 1px solid var(--status-yellow); border-radius: var(--radius);
  background: var(--status-yellow-bg); color: var(--status-yellow-txt);
  font: inherit; font-size: 0.92rem; font-weight: 600; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

@media (orientation: landscape) and (min-width: 700px) {
  #dashboard-view { max-width: 1000px; }
}

/* ============================================================
   Benachrichtigungen (PWA Stufe 2b) – Einstellungs-Screen
   ============================================================ */
#notify-view {
  height: 100%;
  overflow-y: auto;
  max-width: 640px;
  margin: 0 auto;
  padding: 0.6rem 0.6rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.notify-empty {
  color: var(--txt2);
  font-size: 0.9rem;
  padding: 0.2rem 0;
  line-height: 1.35;
}
.notify-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.8rem;
}
.notify-section-title { margin: 0 0 0.6rem; font-size: 0.98rem; color: var(--txt); }

/* Buttons */
.notify-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--txt);
  -webkit-tap-highlight-color: transparent;
}
.notify-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.notify-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.notify-btn-secondary:hover { border-color: var(--accent); }
.notify-btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.notify-btn-danger:hover { text-decoration: underline; }
.notify-status-on { font-size: 0.92rem; font-weight: 600; color: var(--status-green-txt); }

/* Toggle-Zeilen (vier Arten) */
.notify-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0;
  min-height: 44px;
  cursor: pointer;
}
.notify-toggle-row + .notify-toggle-row { border-top: 1px solid var(--line); }
.notify-toggle-label { color: var(--txt); font-size: 0.92rem; }
.notify-toggle-row input[type="checkbox"],
.notify-device-toggle input[type="checkbox"] {
  width: 1.3rem;
  height: 1.3rem;
  flex: 0 0 auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Versandzeiten */
.notify-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0;
  min-height: 44px;
}
.notify-time-row + .notify-time-row { border-top: 1px solid var(--line); }
.notify-time-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.notify-time-label { color: var(--txt); font-size: 0.92rem; }
.notify-time-sub { color: var(--txt2); font-size: 0.76rem; }
.notify-time-hint { color: var(--txt3); font-size: 0.72rem; }
.notify-time-input {
  flex: 0 0 auto;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  min-height: 40px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--txt);
  accent-color: var(--accent);
}

/* Geräteliste */
.notify-device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0;
}
.notify-device-row + .notify-device-row { border-top: 1px solid var(--line); }
.notify-device-namewrap { display: flex; align-items: center; gap: 0.4rem; min-width: 0; flex: 1; }
.notify-device-name { color: var(--txt); font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notify-device-badge {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft, var(--surface2));
  color: var(--accent);
}
.notify-device-edit {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--txt2);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.notify-device-edit:hover { background: var(--hover); color: var(--txt); }
.notify-device-edit svg { width: 16px; height: 16px; display: block; }
.notify-device-ctrls { display: flex; align-items: center; gap: 0.6rem; flex: 0 0 auto; }
.notify-device-remove {
  border: none;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.3rem 0.2rem;
  min-height: 44px;
}
.notify-device-remove:hover { text-decoration: underline; }
.notify-rename-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--txt);
}

/* ============================================================
   Datenschutz: dezenter Burger-Link + statische Rechtstext-Seite
   ============================================================ */
.menu-legal-link {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--txt3);
  text-decoration: none;
}
.menu-legal-link:hover { color: var(--txt2); text-decoration: underline; }

.legal-body { background: var(--bg); color: var(--txt); }
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.2rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
  line-height: 1.55;
}
.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.legal-back:hover { text-decoration: underline; }
.legal-page h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; color: var(--txt); }
.legal-page h2 { font-size: 1.1rem; margin: 1.6rem 0 0.5rem; color: var(--txt); }
.legal-page p { margin: 0.6rem 0; color: var(--txt); }
.legal-page code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--inset);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

/* ============================================================
   Themen-Board (Liste + Thread)
   ============================================================ */
#topics-view { max-width: 760px; margin: 0 auto; padding: 0.4rem 0.5rem 2rem; }
.topics-toolbar {
  display: flex; align-items: center; gap: 0.6rem;
  flex-wrap: wrap; margin: 0.2rem 0 0.8rem;
}
.topics-toolbar .feed-horse-switcher { flex: 1 1 auto; flex-wrap: wrap; }
.topics-empty { color: var(--txt2); text-align: center; padding: 1.5rem 0.5rem; }

.topics-list { display: flex; flex-direction: column; gap: 0.55rem; }
.topic-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.topic-card:hover { border-color: var(--line2); }
.topic-card.is-pinned { border-left: 3px solid var(--accent); }
.topic-card.is-done { opacity: 0.62; }
.topic-card-top { display: flex; align-items: center; gap: 0.5rem; }
.topic-cat-badge {
  flex: 0 0 auto;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: #fff; padding: 0.1rem 0.4rem; border-radius: 999px; white-space: nowrap;
}
.topic-cat-badge.cat-event   { background: var(--cseg-0); }
.topic-cat-badge.cat-frage   { background: var(--cseg-1); }
.topic-cat-badge.cat-info    { background: var(--cseg-2); }
.topic-cat-badge.cat-aufgabe { background: var(--cseg-3); }
.topic-card-title { font-size: 1rem; font-weight: 600; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-pin { flex: 0 0 auto; color: var(--accent); font-size: 0.95rem; }
.topic-done-tag {
  flex: 0 0 auto; font-size: 0.7rem; font-weight: 600;
  color: var(--status-green-txt); background: var(--status-green-bg);
  padding: 0.05rem 0.4rem; border-radius: 999px;
}
.topic-card-meta {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.6rem; margin-top: 0.3rem; font-size: 0.78rem; color: var(--txt2);
}
.topic-card-replies { flex: 0 0 auto; white-space: nowrap; }

/* Thread-Ansicht */
.topic-thread { display: flex; flex-direction: column; gap: 0.7rem; }
.topic-thread-head { display: flex; flex-direction: column; gap: 0.5rem; }
.topic-thread-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.topic-action-btn {
  padding: 0.35rem 0.7rem; min-height: 36px;
  border: 1px solid var(--line2); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--txt); font: inherit; font-size: 0.85rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.topic-action-btn:hover { border-color: var(--accent); }
.topic-post, .topic-reply {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 0.6rem 0.75rem;
}
.topic-post { border-left: 3px solid var(--accent); }
.topic-post-meta, .topic-reply-meta { font-size: 0.75rem; color: var(--txt2); margin-bottom: 0.25rem; }
.topic-post-body, .topic-reply-body { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }
.topic-replies-title { font-size: 0.8rem; color: var(--txt2); margin: 0.3rem 0 0; text-transform: uppercase; letter-spacing: 0.03em; }
.topic-reply-form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.3rem; }
.topic-reply-form textarea {
  width: 100%; padding: 0.5rem; min-height: 70px; resize: vertical; line-height: 1.4;
  border: 1px solid var(--line2); border-radius: var(--radius-sm);
  color: var(--txt); background: var(--surface2); font-family: inherit; font-size: 0.92rem;
}
.topic-reply-form .topic-reply-send { align-self: flex-end; }
.topic-error { color: var(--status-red-txt); font-size: 0.82rem; }

/* ============================================================
   Navigation: Tab-Leiste (Hochkant unten) ⇄ Side-Rail (Querformat links)
   Default-Reservierung: --nav-bottom (Bottom-Bar). Querformat: --nav-bottom auf
   reine Safe-Area, Inhalt bekommt links Platz für die Rail.
   ============================================================ */
:root {
  --tabbar-h: 56px;     /* Höhe der Bottom-Bar / Content-Reservierung unten (Hochkant) */
  --rail-w: 64px;       /* Breite der Side-Rail (Querformat) */
}

#tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;        /* Box-Unterkante = physische Bildschirmunterkante */
  z-index: 1000;
  display: flex;
  /* Box läuft bis ganz unten durch: Tap-Höhe + Home-Indicator-Inset. box-sizing ist global
     border-box, also enthält min-height das padding → Flex-Inhaltsbereich bleibt
     var(--tabbar-h) (Icons sitzen dort oben, NICHT im Inset), die zusätzliche Inset-Höhe
     wird vom Hintergrund mitgefüllt (kein schwarzer Streifen unter der Bar).
     --sab kommt aus dem JS-Helfer (iOS-Standalone-env()-Bug umgangen), Fallback 0px. */
  min-height: calc(var(--tabbar-h) + var(--sab, 0px));   /* Hintergrund deckt bis zur Unterkante */
  /* Nur dezente Klarluft über dem Home-Indicator (statt voller Inset): Icons rutschen tiefer. */
  padding-bottom: max(8px, calc(var(--sab, 0px) * 0.35));
  background: var(--surface);          /* deckt die GESAMTE Box inkl. Inset-Bereich */
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}
.tab-btn {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.12rem;
  min-height: var(--tabbar-h);
  padding: 0.3rem 0.1rem;
  background: transparent; border: none; color: var(--txt2);
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { width: 23px; height: 23px; display: block; }
.tab-label { font-size: 0.66rem; line-height: 1; }
.tab-btn.is-active { color: var(--accent); }
.tab-btn:active { background: var(--surface2); }

/* Hochkant: Buttons mittig im verbleibenden Raum (Firefox-Look), sitzen so tiefer.
   Nur Portrait — die Landscape-Rail bleibt beim Default (stretch). */
@media (orientation: portrait) {
  #tab-bar { align-items: center; }
}

/* Scrim hinter dem „Mehr"-Panel (modernes Safari/Chromium: :has()) */
#more-scrim {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--overlay); display: none;
}
body:has(#header-menu.open) #more-scrim { display: block; }

/* Inhaltsbereiche bekommen unten Luft, damit die Bar nichts verdeckt (Hochkant). */
#agenda-view, #dashboard-view, #feedplan-view, #consumables-view,
#movement-view, #care-view, #notify-view, #topics-view, #settings-view, #dienstplan-view {
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 0.6rem);
}

/* --- Querformat: dieselbe Leiste als vertikale Rail am linken Rand --- */
@media (orientation: landscape) {
  /* Keine Bottom-Reservierung mehr; Inhalt rückt rechts neben die Rail. */
  main { height: calc(100vh - 56px); }
  #filter-chips.has-filter ~ main { height: calc(100vh - 56px - 40px); }
  #agenda-view, #dashboard-view, #feedplan-view, #consumables-view,
  #movement-view, #care-view, #notify-view, #topics-view, #settings-view, #dienstplan-view { padding-bottom: 1rem; }

  /* Inhalt (Header/Chips/Main/FAB) nach rechts; fixe Rail bleibt am Viewport-Rand. */
  #app-view { padding-left: calc(var(--rail-w) + env(safe-area-inset-left, 0px)); }

  #tab-bar {
    top: 0; bottom: 0; right: auto;
    width: calc(var(--rail-w) + env(safe-area-inset-left, 0px));
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.2rem;
    border-top: none; border-right: 1px solid var(--line);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    /* Safe-Area links (Notch) + unten (Home-Indicator, via --sab) im Innenabstand;
       Rail-Hintergrund läuft per top:0/bottom:0 bündig bis an die Ränder. */
    padding: calc(0.4rem + env(safe-area-inset-top, 0px)) 0 calc(0.4rem + var(--sab, 0px)) env(safe-area-inset-left, 0px);
  }
  .tab-btn { flex: 0 0 auto; min-height: 56px; }
  /* „Mehr" ans untere Rail-Ende absetzen (Safe-Area sitzt im Rail-Padding) */
  #tab-more { margin-top: auto; margin-bottom: 0; }

  /* „Mehr"-Panel neben der Rail (links unten) statt als Bottom-Sheet */
  #header-menu {
    left: calc(var(--rail-w) + env(safe-area-inset-left, 0px) + 0.5rem);
    right: auto; bottom: 0.5rem;
    width: min(360px, 70vw);
    max-height: calc(100vh - 1rem);
    border-radius: 14px;
    padding-bottom: 0.7rem;
  }

  /* FAB braucht im Querformat keinen Bottom-Bar-Abstand (Rail ist links) */
  #add-fab { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
   „Mehr"-Sheet: Bereiche-Zeilen mit Piktogramm
   ============================================================ */
#header-menu .menu-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.6rem;
}
#header-menu .menu-row-icon { flex: 0 0 auto; width: 22px; height: 22px; color: var(--txt2); }
#header-menu .menu-row-label { flex: 1 1 auto; min-width: 0; }
#header-menu .menu-row-chevron { flex: 0 0 auto; width: 18px; height: 18px; color: var(--txt2); }
#header-menu .menu-row-settings { margin-top: 0.3rem; border-top: 1px solid var(--line); }

/* ============================================================
   Einstellungen & Konto — Screen
   ============================================================ */
#settings-view { max-width: 560px; margin: 0 auto; padding: 0.4rem 0.6rem 2rem; }
.settings-list { display: flex; flex-direction: column; }
.settings-group-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--txt2); padding: 0.9rem 0.4rem 0.3rem;
}

/* Admin-Sichtbarkeit: Zeile (Label + Segmented-Control own/all) im Settings-Stil */
.visibility-row {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; box-sizing: border-box;
  padding: 0.6rem 0.75rem; min-height: 52px;
  background: var(--surface); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 0.4rem;
}
.visibility-label { flex: 1 1 auto; min-width: 0; font-size: 0.97rem; }
.visibility-seg { flex: 0 0 auto; display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; }
.visibility-seg-btn {
  appearance: none; border: none; background: transparent; color: var(--txt2);
  font: inherit; font-size: 0.8rem; padding: 0.4rem 0.7rem; min-height: 36px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.visibility-seg-btn + .visibility-seg-btn { border-left: 1px solid var(--line2); }
.visibility-seg-btn.is-active { background: var(--accent); color: #fff; }
/* Dienstplan-Erinnerung (Admin): Tag-Select + Uhrzeit in einer visibility-row */
.dutyreminder-inputs { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 0.5rem; }
.dutyreminder-inputs select,
.dutyreminder-inputs input[type="time"] {
  font: inherit; font-size: 0.9rem; color: var(--txt);
  background: var(--surface); border: 1px solid var(--line2);
  border-radius: 8px; padding: 0.35rem 0.5rem; min-height: 36px;
}
.settings-group-label:first-child { padding-top: 0.3rem; }
.settings-row {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; box-sizing: border-box;
  padding: 0.8rem 0.75rem; min-height: 52px;
  background: var(--surface); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 0.4rem; font: inherit; font-size: 0.97rem; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.settings-row:hover { border-color: var(--line2); }
.settings-row-icon { flex: 0 0 auto; width: 22px; height: 22px; color: var(--accent); }
.settings-row-label { flex: 1 1 auto; min-width: 0; }
.settings-row-value { flex: 0 0 auto; color: var(--txt2); font-size: 0.85rem; white-space: nowrap; }
.settings-row-chevron { flex: 0 0 auto; width: 18px; height: 18px; color: var(--txt2); }
.settings-row-danger { color: var(--status-red-txt); }
.settings-row-danger .settings-row-icon { color: var(--status-red); }

.settings-footer {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem;
  margin-top: 1rem; padding: 0.8rem 0.75rem 0;
  border-top: 1px solid var(--line);
}
.settings-footer-link {
  background: transparent; border: none; padding: 0.3rem 0; margin: 0;
  color: var(--txt2); font: inherit; font-size: 0.85rem; text-decoration: none; cursor: pointer;
}
.settings-footer-link:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================
   Verbrauchsgüter: Chip-Unternavigation (Bestand · Einkauf · Kosten)
   ============================================================ */
.cons-tabs {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  padding: 0.5rem 0.1rem 0.7rem;
}
.cons-tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font: inherit; font-size: 0.88rem; font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 999px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.cons-tab:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.cons-tab.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
/* needsBuy-Zähler auf dem Einkauf-Chip */
.cons-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 0.72rem; font-weight: 700; line-height: 1;
  color: #fff; background: var(--status-red);
  border-radius: 999px;
}
.cons-tab.is-active .cons-tab-badge {
  color: var(--accent); background: #fff;
}
.cons-tab-content { display: block; }


/* ============================================================
   Dienstplan-Seite (Wochen-Raster Mo–So)
   ============================================================ */
#dienstplan-view { max-width: 680px; margin: 0 auto; padding: 0.5rem 0.6rem 2rem; }
.dienstplan-empty { color: var(--txt2); text-align: center; padding: 1.5rem 0.5rem; }

.dp-weeknav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin: 0.2rem 0 0.8rem;
}
.dp-weeknav-btn {
  flex: 0 0 auto; width: 40px; height: 40px;
  border: 1px solid var(--line2); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--txt);
  font-size: 1.4rem; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.dp-weeknav-btn:hover { border-color: var(--accent); }
.dp-weeknav-range { font-weight: 700; font-size: 1rem; color: var(--txt); font-variant-numeric: tabular-nums; }

.dp-table { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dp-row { display: grid; grid-template-columns: minmax(96px, 1.1fr) 1fr 1fr; align-items: stretch; }
.dp-row + .dp-row { border-top: 1px solid var(--line); }
.dp-head { background: var(--surface2); font-size: 0.78rem; font-weight: 700; color: var(--txt2); text-transform: uppercase; letter-spacing: 0.03em; }
.dp-cell { display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.55rem; min-width: 0; }
.dp-cell-head { justify-content: center; }
.dp-cell-head .duty-icon svg { width: 15px; height: 15px; }
.dp-cell-day { font-weight: 600; font-size: 0.9rem; color: var(--txt); font-variant-numeric: tabular-nums; }
.dp-row.is-weekend { background: color-mix(in srgb, var(--txt) 4%, transparent); }
.dp-row.is-today .dp-cell-day { color: var(--accent); }
.dp-row.is-today { box-shadow: inset 3px 0 0 var(--accent); }
.dp-cell + .dp-cell { border-left: 1px solid var(--line); }

/* Dienst-Chips */
.duty-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; width: 100%;
  padding: 0.35rem 0.5rem; min-height: 40px;
  border-radius: 999px; font: inherit; font-size: 0.82rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.duty-chip.is-filled { background: var(--surface2); border: 1px solid var(--line2); color: var(--txt); }
.duty-chip.is-filled:hover { border-color: var(--accent); }
.duty-chip.is-free { background: transparent; border: 1px dashed var(--line2); color: var(--txt2); justify-content: center; }
.duty-chip.is-free:hover { border-color: var(--accent); color: var(--accent); }
.duty-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duty-chip-free { font-style: italic; }
.duty-chip .duty-badge { width: 22px; height: 22px; font-size: 10px; flex: 0 0 auto; }
/* Zum Tausch freigegeben: dezenter Akzentrahmen + kleines Badge. */
.duty-chip.is-swap-offered { border-color: var(--accent); border-style: dashed; }
.duty-chip-swap {
  flex: 0 0 auto; margin-left: auto;
  padding: 0.1rem 0.4rem; border-radius: 999px;
  font-size: 0.68rem; line-height: 1.3; white-space: nowrap;
  background: var(--accent); color: #fff;
}

/* ============================================================
   Tagesdetail (klappt unter dem Wochenkalender auf) — Bottom-Panel
   ============================================================ */
#day-detail { display: none; }
/* Inline-Panel direkt unter dem Kalender (kein Overlay). Füllt den Restplatz im
   Inhaltsbereich (flex) und scrollt bei viel Inhalt selbst — kein Abschneiden,
   kein Überlappen der Tagesköpfe; identisch in Hoch- und Querformat. */
body.view-week.day-detail-open #day-detail {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 14px;
  /* oben bündig, damit der sticky Kopf den Inhalt ab Scrollport-Oberkante abdeckt;
     großzügiger Boden, damit der „+ Termin"-Button beim Scrollen nicht unter dem FAB liegt */
  padding: 0 0.7rem 76px;
}
/* Gemeinsamer sticky, deckender Kopf-Container: Datum oben, Dienste darunter.
   Voller Surface-Hintergrund + z-index über dem scrollenden Inhalt; die negativen
   Seitenränder + Padding decken bis an die Panel-Ränder (kein Durchscheinen). */
.day-detail-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  margin: 0 -0.7rem;
  padding: 0.5rem 0.7rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.day-detail-head { display: flex; align-items: center; gap: 0.5rem; }
.day-detail-title { font-weight: 700; font-size: 1rem; color: var(--txt); flex: 1; }
.day-detail-progress { font-size: 0.8rem; color: var(--txt2); white-space: nowrap; }

.day-detail-duties { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; padding: 0.4rem 0 0; }
.day-detail-duty { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--txt); }
.day-detail-duty .duty-icon svg { width: 15px; height: 15px; }

.day-detail-list { display: flex; flex-direction: column; }
.day-detail-empty { color: var(--txt2); padding: 0.6rem 0.2rem; font-size: 0.9rem; }
.day-detail-event {
  display: flex; align-items: center; gap: 0.55rem; width: 100%; box-sizing: border-box;
  padding: 0.55rem 0.4rem; min-height: 44px; background: transparent; border: none;
  border-top: 1px solid var(--line); font: inherit; font-size: 0.92rem; color: var(--txt);
  text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.day-detail-event:first-child { border-top: none; }
.day-detail-event:hover { background: var(--surface2); }
.day-detail-event.is-done { opacity: 0.55; }
.day-detail-event.is-done .day-detail-evtitle { text-decoration: line-through; }
/* Erledigt-Kästchen links: kompakter als der Agenda-Kreis, Terminfarbe als Ring (inline). */
.day-detail-done { width: 26px; height: 26px; font-size: 0.95rem; }
.day-detail-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--txt2); }
.day-detail-evtitle { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-detail-add {
  display: block; width: 100%; margin-top: 0.6rem; padding: 0.6rem; min-height: 44px;
  border: 1px dashed var(--line2); border-radius: var(--radius-sm); background: transparent;
  color: var(--txt2); font: inherit; cursor: pointer;
}
.day-detail-add:hover { border-color: var(--accent); color: var(--accent); }
/* Hinweis: Das frühere Querformat-Override (fixed, neben der Rail) entfällt —
   das Panel steht jetzt inline im Inhaltsbereich und erbt dessen Position/Breite. */

/* =============================================================
   Export (Pflege-Historie / Kostenübersicht): Sheet + Druckansicht
   ============================================================= */

/* Export-Sheet (nach dem Muster der Verbrauchsgüter-Overlays) */
#export-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#export-panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  color: var(--txt);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
#export-panel h2 { margin: 0 0 0.15rem; font-size: 1.1rem; color: var(--txt); padding-right: 2.6rem; }
.export-range { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.25rem 0; }

/* Einstiegs-Button auf Pflege-/Kosten-Screen (Anlehnung an .cons-add-btn) */
.export-open-btn {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  border: 1px dashed var(--line2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--txt2);
  font: inherit;
  cursor: pointer;
}
.export-open-btn:hover { color: var(--txt); border-color: var(--accent); }

/* Druckansicht: im Bildschirm-Modus unsichtbar; beim Drucken ist NUR sie sichtbar. */
#print-view { display: none; }

@media print {
  @page { margin: 15mm; }
  body > *:not(#print-view) { display: none !important; }
  body { background: #fff; }
  #print-view {
    display: block !important;
    color: #000;
    background: #fff;
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
  }
  #print-view h1 { margin: 0 0 2px; font-size: 18px; color: #000; }
  #print-view .print-subtitle { margin: 0 0 2px; font-size: 12px; color: #000; }
  #print-view .print-meta { margin: 0 0 12px; font-size: 10px; color: #444; }
  #print-view h2 { margin: 14px 0 4px; font-size: 14px; color: #000; }
  #print-view table { width: 100%; border-collapse: collapse; margin: 4px 0 10px; }
  #print-view th {
    text-align: left;
    border-bottom: 1px solid #000;
    padding: 3px 8px 3px 0;
    font-size: 11px;
    color: #000;
  }
  #print-view td {
    padding: 3px 8px 3px 0;
    border-bottom: 1px solid #bbb;
    vertical-align: top;
    color: #000;
  }
  #print-view tr { break-inside: avoid; }
}
