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

:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2d2a26;
  --color-text-muted: #8a8480;
  --color-primary: #c06830;
  --color-primary-hover: #a85828;
  --color-primary-light: #fdf0e8;
  --color-border: #e8e4df;
  --color-success: #3a8a5c;
  --color-success-light: #edf7f0;
  --color-error: #c4403a;
  --color-error-light: #fdf0ef;
  --color-people: #2563eb;
  --color-people-hover: #1d4ed8;
  --color-interactions: #059669;
  --color-interactions-hover: #047857;
  --color-todos: #a855f7;
  --color-todos-hover: #9333ea;
  --color-habits: #e67e22;
  --color-habits-hover: #d35400;
  --color-habits-light: #fef3e7;
  --color-culture: #0891b2;
  --color-culture-hover: #0e7490;
  --color-culture-light: #ecfeff;
  --color-tours: #16a34a;
  --color-tours-hover: #15803d;
  --color-tours-light: #f0fdf4;
  --color-books: #b45309;
  --color-books-hover: #92400e;
  --color-forecasts: #6366f1;
  --color-forecasts-hover: #4f46e5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(45, 42, 38, 0.06), 0 1px 2px rgba(45, 42, 38, 0.04);
  --shadow-md: 0 4px 12px rgba(45, 42, 38, 0.08), 0 2px 4px rgba(45, 42, 38, 0.04);
  --max-width: 860px;
  /* Hoehe des sticky .header – gemessen, nicht erzwungen. Nur als Offset fuer
     Elemente, die unter ihm kleben (z. B. .todos-side). Wenn sich der Header-
     Inhalt aendert, hier nachziehen. */
  --header-height: 57px;
  --bg-gradient: linear-gradient(135deg, #faf8f5 0%, #f0e6da 50%, #e8ddd0 100%);
}

/* ── Color scheme overrides ──────────────────────────────────
   Default (:root) is the "warm" scheme. "system" follows the OS
   preference via prefers-color-scheme below. */

[data-color-scheme="dark"] {
  --color-bg: #1a1a1f;
  --color-surface: #25252c;
  --color-text: #f0eee9;
  --color-text-muted: #b8b2ac;
  --color-primary: #f08a50;
  --color-primary-hover: #ff9d65;
  --color-primary-light: #4a3020;
  --color-border: #3a3a42;
  --color-success: #5dd99e;
  --color-success-light: #1f3a2a;
  --color-error: #f57570;
  --color-error-light: #3a1f1f;
  --color-people: #6ea3ff;
  --color-people-hover: #87b3ff;
  --color-interactions: #4dd99e;
  --color-interactions-hover: #5cdda6;
  --color-todos: #c89dff;
  --color-todos-hover: #d4b3ff;
  --color-habits: #ff9d4d;
  --color-habits-hover: #ffae70;
  --color-habits-light: #3a2a1f;
  --color-culture: #4dd2e8;
  --color-culture-hover: #6ddae8;
  --color-culture-light: #1a3340;
  --color-tours: #5dd87a;
  --color-tours-hover: #7adfa3;
  --color-tours-light: #1f3327;
  --color-books: #f5a55a;
  --color-books-hover: #ffb870;
  --color-forecasts: #a5b4fc;
  --color-forecasts-hover: #c4cdfd;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  --bg-gradient: linear-gradient(135deg, #1a1a1f 0%, #25252c 50%, #1a1a1f 100%);
}

[data-color-scheme="cool"] {
  --color-bg: #f4f7fb;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-border: #e2e8f0;
  --bg-gradient: linear-gradient(135deg, #f4f7fb 0%, #e0eaf5 50%, #c9d6e8 100%);
}

[data-color-scheme="forest"] {
  --color-bg: #f5f7f1;
  --color-surface: #ffffff;
  --color-text: #1f2e1a;
  --color-text-muted: #6b7c5e;
  --color-primary: #4a7c3a;
  --color-primary-hover: #3a6230;
  --color-primary-light: #e8efd8;
  --color-border: #d8e0cc;
  --bg-gradient: linear-gradient(135deg, #f5f7f1 0%, #e3e8d8 50%, #cdd6b8 100%);
}

[data-color-scheme="sunset"] {
  --color-bg: #fff5f7;
  --color-surface: #ffffff;
  --color-text: #3a1f2c;
  --color-text-muted: #8a6a76;
  --color-primary: #d4407a;
  --color-primary-hover: #b8336a;
  --color-primary-light: #fde8ef;
  --color-border: #f0d8e0;
  --bg-gradient: linear-gradient(135deg, #fff5f7 0%, #ffe0ec 30%, #ffd0a8 70%, #ffb37a 100%);
}

[data-color-scheme="terminal"] {
  --color-bg: #0a0e0a;
  --color-surface: #0f1410;
  --color-text: #7aff7a;
  --color-text-muted: #50c060;
  --color-primary: #8affb3;
  --color-primary-hover: #a0ffc4;
  --color-primary-light: #1a3a22;
  --color-border: #2a5a32;
  --color-success: #8affb3;
  --color-success-light: #1a3a22;
  --color-error: #ff7575;
  --color-error-light: #3a1010;
  --color-people: #8affb3;
  --color-people-hover: #a0ffc4;
  --color-interactions: #8affb3;
  --color-interactions-hover: #a0ffc4;
  --color-todos: #8affb3;
  --color-todos-hover: #a0ffc4;
  --color-habits: #8affb3;
  --color-habits-hover: #a0ffc4;
  --color-habits-light: #1a3a22;
  --color-culture: #8affb3;
  --color-culture-hover: #a0ffc4;
  --color-culture-light: #1a3a22;
  --color-tours: #8affb3;
  --color-tours-hover: #a0ffc4;
  --color-tours-light: #1a3a22;
  --color-books: #8affb3;
  --color-books-hover: #a0ffc4;
  --color-forecasts: #8affb3;
  --color-forecasts-hover: #a0ffc4;
  --shadow: 0 1px 3px rgba(0, 255, 100, 0.08), 0 1px 2px rgba(0, 255, 100, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 255, 100, 0.1), 0 2px 4px rgba(0, 255, 100, 0.06);
  --bg-gradient: linear-gradient(135deg, #0a0e0a 0%, #0f1410 50%, #0a0e0a 100%);
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  [data-color-scheme="system"] {
    --color-bg: #1a1a1f;
    --color-surface: #25252c;
    --color-text: #f0eee9;
    --color-text-muted: #b8b2ac;
    --color-primary: #f08a50;
    --color-primary-hover: #ff9d65;
    --color-primary-light: #4a3020;
    --color-border: #3a3a42;
    --color-success: #5dd99e;
    --color-success-light: #1f3a2a;
    --color-error: #f57570;
    --color-error-light: #3a1f1f;
    --color-people: #6ea3ff;
    --color-people-hover: #87b3ff;
    --color-interactions: #4dd99e;
    --color-interactions-hover: #5cdda6;
    --color-todos: #c89dff;
    --color-todos-hover: #d4b3ff;
    --color-habits: #ff9d4d;
    --color-habits-hover: #ffae70;
    --color-habits-light: #3a2a1f;
    --color-culture: #4dd2e8;
    --color-culture-hover: #6ddae8;
    --color-culture-light: #1a3340;
    --color-tours: #5dd87a;
    --color-tours-hover: #7adfa3;
    --color-tours-light: #1f3327;
    --color-books: #f5a55a;
    --color-books-hover: #ffb870;
    --color-forecasts: #a5b4fc;
    --color-forecasts-hover: #c4cdfd;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
    --bg-gradient: linear-gradient(135deg, #1a1a1f 0%, #25252c 50%, #1a1a1f 100%);
  }
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  color: var(--color-text);
  background: var(--bg-gradient) fixed;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header .content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.header .logo a {
  position: relative;
  display: inline-block;
}

.header .logo img {
  height: 32px;
  display: block;
}

/* Der Todo-Zähler sitzt als Badge in der Ecke des Logos, wenn dieses zur
   Todo-Liste führt. Der Rand in Header-Farbe hebt ihn vom Logo darunter ab. */
.logo-bubble {
  position: absolute;
  top: -0.4rem;
  right: -0.6rem;
}

.logo-bubble .nav-bubble {
  margin-left: 0;
  border: 2px solid var(--color-surface);
}

.header .signin {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.header .signin a {
  color: var(--color-text-muted);
}

.header .signin a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.btn-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-help:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.footer {
  text-align: center;
  padding: 2rem 1.5rem;
}

.footer .notifications {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.footer .notifications:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.footer .notifications:disabled {
  opacity: 0.5;
  cursor: default;
}

[data-keyboard-shortcut-key] {
  white-space: nowrap;
}

[data-keyboard-shortcut-key]::after {
  content: attr(data-keyboard-shortcut-key);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  margin-left: 0.35rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  vertical-align: middle;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-nav a {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.header-nav a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

.nav-dropdown-toggle::-webkit-details-marker {
  display: none;
}

.nav-dropdown-toggle::after {
  content: "▾";
  margin-left: 0.3rem;
  font-size: 0.7rem;
  line-height: 1;
}

.nav-dropdown-toggle:hover {
  color: var(--color-primary);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 100;
  padding: 0.5rem 0;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text);
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.nav-dropdown-menu a:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-dropdown[open] .nav-dropdown-menu {
  display: block;
}

.nav-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  margin-left: 0.3rem;
  background: var(--color-primary);
  color: var(--color-surface);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.nav-bubble-dot {
  min-width: 0.5rem;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
}

/* ── Main Content ────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Typography ──────────────────────────────────────────── */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.last-seen {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.last-seen a,
.last-seen .overdue-badge {
  white-space: nowrap;
}

.interaction-kind {
  display: inline-block;
  background: var(--color-primary-light, #f5ebe4);
  color: var(--color-primary);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  margin-right: 0.35em;
  vertical-align: baseline;
}

/* ── Navigation Links ────────────────────────────────────── */
.nav-links {
  display: flex;
  gap: 0.75rem;
}

.nav-group {
  display: flex;
  gap: 0.25rem;
}


.nav-group-right {
  margin-left: auto;
}

.nav-links a,
.nav-links button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.15rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.nav-links a:hover,
.nav-links button:hover,
.btn:hover {
  background: var(--color-primary-hover);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
}

.nav-links a.people,
.btn.people {
  background: var(--color-people);
}
.nav-links a.people:hover,
.btn.people:hover {
  background: var(--color-people-hover);
}

.nav-links a.interactions,
.btn.interactions {
  background: var(--color-interactions);
}
.nav-links a.interactions:hover,
.btn.interactions:hover {
  background: var(--color-interactions-hover);
}

.nav-links a.todos,
.nav-links button.todos,
.btn.todos {
  background: var(--color-todos);
}
.nav-links a.todos:hover,
.nav-links button.todos:hover,
.btn.todos:hover {
  background: var(--color-todos-hover);
}

.nav-links a.habits,
.btn.habits {
  background: var(--color-habits);
}
.nav-links a.habits:hover,
.btn.habits:hover {
  background: var(--color-habits-hover);
}

.nav-links a.culture,
.btn.culture {
  background: var(--color-culture);
}
.nav-links a.culture:hover,
.btn.culture:hover {
  background: var(--color-culture-hover);
}

.nav-links a.tours,
.btn.tours {
  background: var(--color-tours);
}
.nav-links a.tours:hover,
.btn.tours:hover {
  background: var(--color-tours-hover);
}

.nav-links button.notifications,
.btn.notifications {
  background: #6b7280;
}
.nav-links button.notifications:hover,
.btn.notifications:hover {
  background: #4b5563;
}

.nav-links button:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn-secondary.active,
.btn-secondary.active:hover {
  background: var(--color-culture-light);
  border-color: var(--color-culture);
  color: var(--color-culture);
}

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

.btn-danger:hover {
  background: #a83632;
  color: #fff;
  text-decoration: none;
}

/* ── Home Grid ───────────────────────────────────────────── */
.container:has(.home-grid) {
  max-width: 1400px;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.container:has(.tour-controls) {
  max-width: 1100px;
}

.container:has(.calendar) {
  max-width: min(1600px, 96vw);
  padding-top: 1rem;
  padding-bottom: 1rem;
}

form.tour-controls {
  max-width: none;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.home-grid .section-card + .section-card {
  margin-top: 0;
}

/* ── Section Cards (Homepage) ────────────────────────────── */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-card + .section-card {
  margin-top: 1.5rem;
}

.section-card.people {
  border-top-color: var(--color-people);
}
.section-card.people a {
  color: var(--color-people);
}
.section-card.people a:hover {
  color: var(--color-people-hover);
}

.section-card.interactions {
  border-top-color: var(--color-interactions);
}
.section-card.interactions a {
  color: var(--color-interactions);
}
.section-card.interactions a:hover {
  color: var(--color-interactions-hover);
}

.section-card.todos {
  border-top-color: var(--color-todos);
}
.section-card.todos a {
  color: var(--color-todos);
}
.section-card.todos a:hover {
  color: var(--color-todos-hover);
}

.section-card.habits {
  border-top-color: var(--color-habits);
}
.section-card.habits a {
  color: var(--color-habits);
}
.section-card.habits a:hover {
  color: var(--color-habits-hover);
}

/* Wochen-Kachel über die volle Breite des Dashboards. */
.section-card.calendar-week {
  grid-column: 1 / -1;
  border-top-color: var(--color-primary);
}
.section-card.calendar-week .calendar-columns {
  margin-top: 0.5rem;
}

.section-card.culture {
  border-top-color: var(--color-culture);
}
.section-card.culture a {
  color: var(--color-culture);
}
.section-card.culture a:hover {
  color: var(--color-culture-hover);
}

.section-card.tours {
  border-top-color: var(--color-tours);
}
.section-card.tours a {
  color: var(--color-tours);
}
.section-card.tours a:hover {
  color: var(--color-tours-hover);
}

.section-card.books {
  border-top-color: var(--color-books);
}
.section-card.books a {
  color: var(--color-books);
}
.section-card.books a:hover {
  color: var(--color-books-hover);
}

.section-card.forecasts {
  border-top-color: var(--color-forecasts);
}
.section-card.forecasts a {
  color: var(--color-forecasts);
}
.section-card.forecasts a:hover {
  color: var(--color-forecasts-hover);
}

.home-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

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

.muted {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.home-grid .section-card {
  font-size: 0.875rem;
}

.section-card h2 {
  margin-bottom: 0.1rem;
  font-size: 1.1rem;
}

.home-grid .section-card h2 {
  font-size: 0.95rem;
}

.section-card .subtitle {
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}

.home-grid .section-card .subtitle {
  font-size: 0.7rem;
  margin-bottom: 0.3rem;
}

.home-grid .last-seen,
.home-grid .todo-meta {
  font-size: 0.75rem;
}

.birthdays-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg-soft, rgba(0, 0, 0, 0.02));
  font-size: 0.8rem;
}

.birthdays-banner-icon {
  font-size: 1rem;
}

/* Fällige Gratulationen sind kein Ausblick, sondern eine Aufgabe: Der Streifen
   hebt sich deshalb vom Vorschau-Streifen ab und bleibt stehen, bis abgehakt. */
.congratulations-banner {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.congratulations-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Der Button steckt in einer <form> von button_to. Sie darf weder die globale
   form-Breite mitbringen noch den Button auf der Textbasislinie absetzen –
   dort saß er sichtbar zu hoch. */
.congratulations-item form {
  display: flex;
  align-items: center;
  margin: 0;
  max-width: none;
}

/* Dezent: Der Streifen erinnert, er drängt nicht. Gefüllt (btn-done) zog der
   Button mehr Aufmerksamkeit auf sich als der Geburtstag daneben.
   Die Klasse .btn-done steht weiter unten im Stylesheet – ohne den zusätzlichen
   Elternselektor gewänne sie bei gleicher Spezifität. */
.congratulations-banner .btn-congratulate,
.congratulations-banner .btn-congratulate[type="submit"] {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.1rem 0.45rem;
  transform: none;
}

.congratulations-banner .btn-congratulate:hover,
.congratulations-banner .btn-congratulate[type="submit"]:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: none;
}

.birthdays-banner-item {
  text-decoration: none;
  color: inherit;
}

.birthdays-banner-item:hover {
  text-decoration: underline;
}

.birthdays-banner-item.is-today {
  font-weight: 600;
}

.birthdays-banner-sep {
  color: var(--color-muted, #888);
}

.birthdays-banner-more {
  margin-left: auto;
  color: var(--color-muted, #888);
  font-style: italic;
}

.section-card .people {
  gap: 0;
}

.section-card .scrollable-list {
  max-height: calc(8 * 2.2rem);
  overflow-y: auto;
}

.section-card.todos .scrollable-list,
.section-card.habits .scrollable-list {
  max-height: calc(9 * 2.2rem);
}

.section-card.people .scrollable-list {
  max-height: calc(6 * 2.2rem);
}

.section-card.overdue .scrollable-list {
  overflow: visible;
}

.section-card .people .person {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border);
  box-shadow: none;
  padding: 0.3rem 0.5rem;
}

.section-card .people .person:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-card .people .person:first-child {
  padding-top: 0;
}

.section-card .people .person:hover {
  background: var(--color-primary-light);
  box-shadow: none;
  border-radius: var(--radius-sm);
  margin: 0 -0.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Lists (People, Interactions, Todos) ─────────────────── */
.interactions,
.people,
.todos {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.interactions .interaction,
.people .person,
.todos .todo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.interactions .interaction:hover,
.people .person:hover,
.todos .todo:hover {
  box-shadow: var(--shadow-md);
}

.interactions .interaction div,
.people .person div,
.todos .todo div {
  padding-right: 0;
}

.col {
  flex: 1;
  min-width: 0;
}

/* ── Todo Styles ─────────────────────────────────────────── */
.todo-due-date {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.todo-priority {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.todo-priority-hoch {
  background: var(--color-error-light);
  color: var(--color-error);
}

.todo-priority-mittel {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.todo-priority-niedrig {
  background: var(--color-border);
  color: var(--color-text-muted);
}

.todo-priority-buttons {
  display: inline-flex;
  gap: 0.2rem;
}

.btn-priority,
.btn-priority[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.15rem 0.4rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-priority:hover,
.btn-priority[type="submit"]:hover {
  transform: translateY(-1px);
  border-color: var(--color-text-muted);
}

.btn-priority-hoch.selected,
.btn-priority-hoch.selected[type="submit"] {
  background: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error);
}

.btn-priority-mittel.selected,
.btn-priority-mittel.selected[type="submit"] {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-priority-niedrig.selected,
.btn-priority-niedrig.selected[type="submit"] {
  background: var(--color-border);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.todo-due-date.due-today {
  color: var(--color-primary);
  font-weight: 500;
}

.todo-day-heading {
  margin: 1rem 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.todo-day-heading:first-child {
  margin-top: 0;
}

.todo-day-heading.due-today {
  color: var(--color-primary);
}

.todo-section-heading {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.todo-section-heading:first-child {
  margin-top: 0;
}

.todos .todos-future {
  display: flex;
  flex-direction: column;
  gap: inherit;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.section-card .todos .todo:has(+ .todos-future) {
  border-bottom: none;
}

.todo-day-heading.overdue {
  color: var(--color-error);
}

.overdue-badge {
  display: inline-block;
  background: var(--color-error-light);
  color: var(--color-error);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.todo-due-date.overdue {
  color: var(--color-error);
  font-weight: 500;
}

.todo-people {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.todo-meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

.todo-people-names {
  margin-left: 0.5rem;
}

.todo-people-avatars {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.todos .todo.completed {
  opacity: 0.5;
}

.todos .todo.future,
.todo-day-heading.future {
  opacity: 0.6;
}

/* ── Kalender-Termine in der Todo-Liste ──────────────────── */
.todos .todo.calendar-event {
  border-left: 3px solid var(--color-culture);
  background: var(--color-culture-light);
}

.calendar-event-marker {
  margin-right: 0.35rem;
}

/* Termin steht unmittelbar bevor (Klasse kommt vom imminent-event-Controller,
   der clientseitig tickt). Der Akzent wechselt vom ruhigen Kalender-Blau auf
   die Warnfarbe und die Zeile pulsiert dezent, damit sie im Blick aufploppt,
   ohne dass die Seite neu geladen wird. */
.todos .todo.calendar-event.is-imminent {
  border-left-color: var(--color-error);
  background: var(--color-error-light);
  animation: imminent-pulse 2s ease-in-out infinite;
}

/* Bevorstehende Termine sind nie ausgegraut – auch wenn der Tag als
   "zukuenftig" gefadet wird, ist genau dieser Termin gerade dringend. */
.todos .todo.calendar-event.is-imminent.future {
  opacity: 1;
}

.todos .todo.calendar-event.is-imminent .todo-due-date {
  color: var(--color-error);
  font-weight: 600;
}

@keyframes imminent-pulse {
  50% { border-left-color: var(--color-culture); }
}

@media (prefers-reduced-motion: reduce) {
  .todos .todo.calendar-event.is-imminent {
    animation: none;
  }
}

/* ── Unter-Todos ─────────────────────────────────────────── */
.subtodos {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.25rem 0 0 1.75rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
}

.todos .subtodos .todo.subtodo {
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
}

.subtodo-marker {
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

/* Das Haupt-Todo hinter einer eigenstaendigen Unter-Todo-Zeile der Tagesliste
   (siehe _todo_row). Bewusst zurueckgenommen: Der eigene Titel fuehrt die
   Zeile, die Herkunft ist nur der Kontext dazu. */
.todo-parent-hint {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.todo-parent-hint::before {
  content: "aus ";
}

.todo-subtodo-progress {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Inline-editierbarer Titel: Anzeige und Eingabefeld liegen uebereinander im
   selben Platz, umgeschaltet wird per [hidden]. Die display-Regeln brauchen
   deshalb :not([hidden]) – eine display-Angabe schlaegt sonst die
   [hidden]-Regel des Browsers und das Feld staende immer offen. */

/* display: contents nimmt den Wrapper aus dem Layout: Der Titel muss im
   Textfluss der Zeile bleiben, damit das Kategorie-Badge neben seiner letzten
   Zeile sitzt. Ein eigener Kasten (inline-flex) ist atomar – daneben passt
   nichts mehr, und das Badge rutscht eine Zeile tiefer. */
.inline-title {
  display: contents;
}

.inline-title-display:not([hidden]) {
  display: inline;
}

.inline-title-form:not([hidden]) {
  display: inline-flex;
  width: 100%;
}

/* Erbt die Schrift vom umgebenden Titel, damit die Zeile beim Umschalten
   nicht springt. */
.inline-title-form input[type="text"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: inherit;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
}

/* Der Titel editiert beim Klick, statt zu navigieren – er darf deshalb nicht
   wie ein Link aussehen. Der Textcursor ist der Hinweis darauf; navigiert wird
   ueber die Zeile ringsum (row_link_controller), die dafuer den Zeigefinger
   bekommt. */
.todos .todo {
  cursor: pointer;
}

.inline-title-display {
  cursor: text;
}

.inline-title-display a {
  color: inherit;
}

.inline-title-display a:hover {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.2em;
}

/* Der Stift erscheint nur bei Tastatur-Fokus. Mit der Maus klickt man den Titel
   direkt an; per Tastatur gehoert Enter auf dem Titel dem Link (Detailseite),
   deshalb braucht das Editieren dort einen eigenen Knopf.
   Breite 0 statt display: none – so belegt er nichts (das Kategorie-Badge
   bliebe sonst eine Zeile tiefer haengen), bleibt aber in der Tab-Reihenfolge. */
.inline-title-edit {
  width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 0.8em;
  line-height: 1;
  vertical-align: middle;
  opacity: 0;
}

.inline-title-edit:focus-visible {
  width: auto;
  margin-left: 0.35rem;
  opacity: 1;
}

/* Auf der Detailseite ist der Titel eine H1 – das Feld muss deren Schrift
   uebernehmen, sonst schrumpft es beim Aufklappen auf Fliesstextgroesse. */
.todo-show-header .inline-title {
  display: flex;
}

.todo-show-header .inline-title-form {
  margin: 0 0 0.85rem;
}

.todo-show-header .inline-title-form input[type="text"] {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Erledigte Unter-Todos stecken in der Liste hinter einer Faltung: eingeklappt
   eine dezente Zeile, aufgeklappt die gewohnten Zeilen. Nativ per <details>,
   damit sie auch ohne JavaScript aufgeht (ADR 0009). */
/* Kein align-self: flex-start – das <details> ist Flex-Item in .subtodos und
   wuerde samt der aufgeklappten Zeilen auf Inhaltsbreite schrumpfen. Die
   Klickflaeche haelt das inline-flex am summary schmal. */
.subtodos-done > summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  list-style: none;
  user-select: none;
}

.subtodos-done > summary::-webkit-details-marker {
  display: none;
}

.subtodos-done > summary:hover {
  color: var(--color-text);
}

/* Marker hinter dem Text – anders als bei den übrigen <details>-Blöcken, weil
   die Zeile mit dem Haken beginnt: "✓ 2 erledigt ▸". */
.subtodos-done > summary::after {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
}

.subtodos-done[open] > summary::after {
  transform: rotate(90deg);
}

.subtodos-done-check {
  color: var(--color-success);
}

/* Spiegelt den Abstand von .subtodos – die aufgeklappten Zeilen sollen sitzen
   wie die offenen darüber, nicht wie ein Fremdkörper. */
.subtodos-done-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-add-subtodo {
  align-self: flex-start;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.todo-show-subtodos {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}

.todo-show-subtodo-list {
  margin: 0;
  padding-left: 1.25rem;
}

.todo-show-subtodo-list li.completed {
  opacity: 0.5;
  text-decoration: line-through;
}

.interactions .person.completed {
  opacity: 0.5;
  text-decoration: line-through;
}

.section-card .todos {
  gap: 0;
}

.section-card .todos .todo {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border);
  box-shadow: none;
  padding: 0.3rem 0.5rem;
}

.section-card .todos .todo:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-card .todos .todo:first-child {
  padding-top: 0;
}

.section-card .todos .todo:hover {
  background: var(--color-primary-light);
  box-shadow: none;
  border-radius: var(--radius-sm);
  margin: 0 -0.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.section-card .habits-list {
  gap: 0.25rem;
}

.section-card .habits-list .habit-item {
  padding: 0.3rem 0.5rem;
  gap: 0.6rem;
  border-radius: var(--radius-sm);
}

/* ── Inline Actions (small edit/delete links) ────────────── */
.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.inline-actions a {
  color: var(--color-text-muted);
}

/* button_to umschließt den Delete-Button mit einem <form>. Ohne Eingriff ist
   dieses <form> der Flex-Sohn und – weil es einen inline-flex-Button per
   Baseline ausrichtet – ~8px höher als der Edit-Link; der Button sitzt oben
   im Form-Kasten, wodurch Edit ~4px tiefer rutscht. display: contents blendet
   die Form-Box aus, sodass der Button selbst zum Flex-Sohn wird und exakt wie
   der Edit-Link zentriert sitzt. (Gleiche Technik wie .actions .button_to.) */
.inline-actions .button_to {
  display: contents;
}

.inline-actions a:hover {
  color: var(--color-primary);
}

.inline-actions .btn-destroy,
.inline-actions .btn-destroy[type="submit"] {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: normal;
  padding: 0;
  cursor: pointer;
  transform: none;
  /* Gleiche line-height wie der Edit-Link (link_to), damit der button_to-
     Button dieselbe Box-Höhe hat und beide exakt auf einer Höhe sitzen.
     Ohne dies ist der Button (line-height: normal) ~2px niedriger. */
  line-height: inherit;
}

.inline-actions .btn-destroy:hover,
.inline-actions .btn-destroy[type="submit"]:hover {
  background: none;
  color: var(--color-text);
  transform: none;
  text-decoration: underline;
}

.inline-actions .inline-form {
  max-width: none;
}

/* ── Habit Styles ────────────────────────────────────────── */
.habits-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.habits-list .habit-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--color-success) calc(var(--habit-progress, 0) * 28%), var(--color-surface));
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.habits-list .habit-item:hover {
  box-shadow: var(--shadow-md);
}

.habit-item.target-reached .col a {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.habit-check {
  color: var(--color-success);
  font-weight: 700;
  margin-right: 0.25rem;
}

/* Der Done-Button sieht im "heute erledigt"-Zustand (is-done) genauso aus wie
   sonst – das Erledigt-Signal ist das Haekchen vor dem Habit-Namen. Die Klasse
   bleibt als Markup-Hook erhalten, hat aber keine eigene Optik mehr. */

.habit-meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

.habit-progress {
  font-weight: 600;
}

.habit-progress.complete {
  color: var(--color-success);
}

.habit-progress.incomplete {
  color: var(--color-error);
}

/* Bei mehreren Wochenzielen die Badges inline voneinander abheben. */
.habit-progress + .habit-progress {
  margin-left: 0.4rem;
}

/* Mehrere Wochenziele (Tage/km/Minuten) nebeneinander, umbrechend. */
.habit-goals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.1rem 0.5rem;
  text-align: right;
}

/* Im Flex-Container regelt gap den Abstand – Sibling-Margin zuruecksetzen. */
.habit-goals .habit-progress + .habit-progress {
  margin-left: 0;
}

.habit-item.trend-warn {
  border-left: 3px solid var(--color-error);
  padding-left: calc(0.75rem - 3px);
}

.habit-trend-sentence {
  margin-top: 0.5rem;
  color: var(--color-text-muted, #555);
  font-size: 0.95em;
}

.habit-trend {
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 0.25rem;
}

.habit-trend.up {
  color: var(--color-success);
}

.habit-trend.flat {
  color: var(--color-text-muted, #666);
}

.habit-trend.down {
  color: var(--color-warning);
}

.habit-trend.warn {
  color: var(--color-error);
}

.habit-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

/* Habit Tiles Grid */
/* Kopfzeile: Aktions-Buttons links, Wochenziel-Ring rechts. */
.habits-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.habits-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Zusammenfassung "X/Y Wochenziele erreicht" als Fortschrittsring. */
.habits-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.habits-ring {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.habits-ring-track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 3.5;
}

.habits-ring-fill {
  fill: none;
  stroke: var(--color-success);
  stroke-width: 3.5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dasharray 0.4s ease;
}

.habits-ring-text {
  fill: var(--color-text);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.habits-summary-label {
  font-size: 0.75rem;
  line-height: 1.15;
  color: var(--color-text-muted);
}

/* ── Todo-Seite: Todos links, Hinweise + Habits rechts ───────
   Die rechte Spalte (.todos-side) traegt oben die Hinweis-Streifen und darunter
   die Habits. Auf schmalen Screens loest sie sich auf (siehe unten).
   Ein-/Ausblenden der Habits per habits-panel-Controller (nicht gespeichert). */
.todos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.todos-main {
  min-width: 0;
}

.todos-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Ab Desktop zweispaltig, sobald rechts etwas Sichtbares steht: Hinweise oder
   nicht-ausgeblendete Habits.
   Hinweis: :has() darf nicht in :has() verschachtelt werden – der Selektor waere
   ungueltig und wuerde komplett ignoriert. Deshalb Nachfahren-Kombinator bzw.
   :not(:has(…)) auf gleicher Ebene statt :has(… :has(…)). */
@media (min-width: 960px) {
  .todos-layout:has(.todos-banners),
  .todos-layout:has(.todos-habits):not(.habits-hidden) {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  /* Bleibt beim Scrollen der Liste stehen und scrollt bei Ueberlaenge selbst –
     .todos-layout hat align-items:start, sonst haette das Grid-Item volle
     Zeilenhoehe und koennte gar nicht kleben.
     Der Scroll-Container klippt auch quer (overflow-y:auto macht overflow-x
     automatisch zum Scroll-Container), sonst schnitte er den Kachel-Schatten
     ringsum ab. Das Padding gibt ihm Luft, der negative Margin holt die Spalte
     optisch wieder an ihren Platz. Scrollbar schmal und zurueckhaltend. */
  .todos-side {
    position: sticky;
    top: calc(var(--header-height) + 1rem);
    max-height: calc(100vh - var(--header-height) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.35rem 0.5rem;
    margin: -0.35rem -0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
  }

  .container:has(.todos-layout .todos-banners),
  .container:has(.todos-layout:not(.habits-hidden) .todos-habits) {
    max-width: 1240px;
  }
}

/* Ausgeblendet: nur der Habits-Block verschwindet, Einblenden-Button erscheint.
   Die Spalte selbst bleibt stehen, solange Hinweise da sind. */
.todos-layout.habits-hidden .todos-habits { display: none; }
.todos-habits-show { display: none; }
.todos-layout.habits-hidden .todos-habits-show { display: inline-flex; }

/* Ohne Hinweise ist die ausgeblendete Spalte leer – zurueck zur normalen
   (schmalen) Todo-Breite. Die .habits-grid des versteckten Blocks wuerde den
   Container sonst breit halten. Mit Hinweisen bleibt es bei 1240px (oben). */
.container:has(.todos-layout.habits-hidden):not(:has(.todos-banners)) {
  max-width: var(--max-width);
}

/* Ueberschrift der Hinweise – wie bei den Habits ausserhalb der weissen Box. */
.todos-notes-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.todos-notes-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* Ein weisser Kasten fuer alle Streifen zusammen – dasselbe Vokabular wie eine
   .habit-tile daneben. Die Streifen geben darin ihren eigenen Rahmen auf,
   sonst steckte Box in Box; getrennt wird per Haarlinie. */
.todos-side .todos-banners {
  gap: 0;
  padding: 0 0.9rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Klippt den randvollen Gratulations-Balken an den runden Ecken – egal ob er
     oben, unten oder als einziger Streifen steht. */
  overflow: hidden;
}

.todos-side .todos-banners .birthdays-banner {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.7rem 0;
}

.todos-side .todos-banners .birthdays-banner + .birthdays-banner {
  border-top: 1px solid var(--color-border);
}

/* Faellige Gratulationen bleiben die Ausnahme: sie sind eine Aufgabe, kein
   Ausblick, und behalten darum ihre Farbe – als randvoller Akzent-Balken. */
.todos-side .todos-banners .congratulations-banner {
  margin: 0 -0.9rem;
  padding: 0.7rem 0.9rem;
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
}

/* Die Streifen sind fuer die volle Breite gebaut (flex-Zeile mit „·"-Trennern).
   In der schmalen Spalte stattdessen: fuehrendes Icon links im Bundsteg,
   Eintraege untereinander rechts. Streifen ohne fuehrendes Icon (upcoming,
   congratulations – die tragen es pro Eintrag) lassen Spalte 1 auf 0 fallen. */
.todos-side .birthdays-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.3rem 0.5rem;
}

.todos-side .birthdays-banner > .birthdays-banner-icon { grid-row: 1 / -1; }
.todos-side .birthdays-banner > *:not(.birthdays-banner-icon) { grid-column: 2; }
.todos-side .birthdays-banner-sep { display: none; }

/* Einspaltig loest sich die Spalte auf, damit die Streifen oben bleiben und die
   Habits – wie bisher – unter der Liste landen. */
@media (max-width: 959px) {
  .todos-side { display: contents; }
  .todos-notes { order: -1; }
}

.todos-habits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.todos-habits-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.todos-habits-title h2 {
  margin: 0;
  font-size: 1.1rem;
}

.todos-habits-title h2 a {
  color: var(--color-text);
  text-decoration: none;
}

.todos-habits-title h2 a:hover {
  text-decoration: underline;
}

/* Ring in der Spaltenueberschrift kompakt halten. */
.todos-habits-title .habits-summary-label {
  display: none;
}

.todos-habits-title .habits-ring {
  width: 34px;
  height: 34px;
}

/* In der schmalen Spalte immer eine Kachel pro Reihe (schlaegt die
   mehrspaltige .habits-grid-Regel via hoeherer Spezifitaet). */
.todos-habits .habits-grid {
  grid-template-columns: minmax(0, 1fr);
}

.habits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Auf grossen Bildschirmen drei Habits nebeneinander. Der globale Container ist
   auf --max-width (860px) gedeckelt, daher passen sonst nur zwei. iPad (<=1024)
   und Handy behalten ihre 2- bzw. 1-Spalten-Ansicht. */
@media (min-width: 1100px) {
  .container:has(.habits-grid) {
    max-width: 1100px;
  }

  .habits-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.habit-tile {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

/* Der Rand kodiert nur das erreichte Wochenziel (gruener Ring, passend zur
   gruenen Zaehlerfarbe 4/4). Heute erledigt zeigt das Haekchen im Titel, der
   Trend der Pfeil im Titel.
   Erledigtes treten ausgegraut in den Hintergrund und wird im Controller ans
   Ende sortiert – so bleibt der Blick auf den noch offenen Habits. Das gilt
   fuer erreichte Wochenziele wie auch fuer heute schon erledigte Habits;
   letztere erscheinen am naechsten Tag von selbst wieder normal, weil
   completed_today? auf das aktuelle Datum eingegrenzt ist. Beim Hovern wird die
   Kachel wieder voll sichtbar, damit man weiterhin bequem nachloggen kann. */
.habit-tile.target-reached {
  box-shadow: 0 0 0 2px var(--color-success) inset;
}

.habit-tile.target-reached,
.habit-tile.completed-today {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.habit-tile.target-reached:hover,
.habit-tile.target-reached:focus-within,
.habit-tile.completed-today:hover,
.habit-tile.completed-today:focus-within {
  opacity: 1;
}

.habit-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.habit-tile-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.habit-tile-header h3 a {
  color: var(--color-text);
  text-decoration: none;
}

.habit-tile-header h3 a:hover {
  text-decoration: underline;
}

.habit-tile-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.habit-tile-sparkline {
  margin: 0.5rem 0;
  height: 76px;
}

.habit-tile-sparkline canvas {
  width: 100%;
  height: 100%;
}

.habit-tile-trend-periods {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.habit-tile-trend-periods .current {
  font-weight: 600;
  color: var(--color-text);
}

/* Untere Zeile: Info (Vorher/Aktuell bzw. Min./Kilometer) links, Aktionen rechts. */
.habit-tile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.habit-tile-footer-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.habit-tile-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* button_to (Done) rendert ein <form>, link_to (Detail) ein <a>. Mit
   display:contents verschwindet die Form-Box, sodass der <button> zum direkten
   Flex-Kind neben dem <a> wird – beide sind dann identische Geschwister und
   werden gleich ausgerichtet. */
.habit-tile-actions form {
  display: contents;
}

.habit-tile-actions .btn-done {
  line-height: normal;
}

/* Taktiles Feedback beim Klick auf Done/Detail. */
.habit-tile-actions .btn-done:active {
  transform: scale(0.92);
}

/* ── Done-Feuerwerk ──────────────────────────────────────────
   Wird vom habit-done-Controller beim Klick auf Done ausgeloest:
   das Tile pulst kurz und in der Mitte explodiert ein Feuerwerk aus
   bunten Partikeln, bevor Turbo die Liste neu morpht. Die Partikel
   werden per JS erzeugt und ueber --dx/--dy nach aussen geschleudert. */
.habit-tile.is-celebrating {
  animation: habit-done-tile 0.6s ease-out;
}

/* Wochenziel erreicht: kraeftigerer Puls mit goldenem Aufblitzen. */
.habit-tile.is-celebrating-big {
  animation: habit-done-tile-big 1.1s ease-out;
}

.habit-firework {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 3;
}

.habit-firework-particle {
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  opacity: 0;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: habit-firework 0.7s cubic-bezier(0.15, 0.6, 0.4, 1) forwards;
}

@keyframes habit-done-tile {
  0% { transform: scale(1); }
  35% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes habit-done-tile-big {
  0% { transform: scale(1); box-shadow: var(--shadow); }
  18% { transform: scale(1.06); box-shadow: 0 0 0 4px var(--color-success), 0 0 56px 8px rgba(255, 215, 0, 0.6); }
  45% { transform: scale(1.02); }
  100% { transform: scale(1); box-shadow: var(--shadow); }
}

/* Partikel schiessen nach aussen (--dx/--dy) und sinken am Ende leicht ab. */
@keyframes habit-firework {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 10px)) scale(0.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .habit-tile.is-celebrating,
  .habit-tile.is-celebrating-big { animation: none; }
  .habit-firework { display: none; }
}

/* button_to (Done) rendert ein <form>, link_to (Detail) ein <a>. Mit
   display:contents wird der <button> zum direkten Flex-Kind neben dem <a>,
   sodass beide identische Geschwister sind und gleich hoch ausgerichtet werden. */
.habit-actions form {
  max-width: none;
  display: contents;
}

.habit-actions .btn-done {
  line-height: normal;
}


.section-card .habits-list {
  gap: 0;
}

.section-card .habits-list .habit-item {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border);
  box-shadow: none;
  padding: 0.65rem 0.5rem;
}

.section-card .habits-list .habit-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-card .habits-list .habit-item:first-child {
  padding-top: 0;
}

.section-card .habits-list .habit-item:hover {
  background: var(--color-primary-light);
  box-shadow: none;
  border-radius: var(--radius-sm);
  margin: 0 -0.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ── Done Button ─────────────────────────────────────────── */
.col-auto {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-done,
.btn-done[type="submit"] {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: var(--color-text-muted);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

/* Ist der Button ein <a> (etwa „Detail“ auf den Habit-Kacheln), gewinnt a:hover
   mit seiner höheren Spezifität und färbt die Schrift dunkelgrün samt Unterstrich
   – auf dem dunklen Hover-Hintergrund war sie kaum noch zu lesen. Farbe und
   Unterstreichung deshalb hier festnageln, wie .btn und .btn-postpone es tun. */
.btn-done:hover,
.btn-done[type="submit"]:hover {
  background: var(--color-text);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.section-card .btn-done,
.section-card .btn-done[type="submit"] {
  background: var(--color-text-muted);
}

.section-card .btn-done:hover,
.section-card .btn-done[type="submit"]:hover {
  background: var(--color-text);
}

.section-card a.btn-done,
.section-card a.btn-done:hover {
  color: #fff;
}

.actions .btn-done,
.actions .btn-done[type="submit"] {
  background: var(--color-text-muted);
  font-size: 0.8125rem;
  /* line-height vereinheitlichen, damit Button (button_to) und Link
     (link_to) mit derselben Klasse gleich hoch sind. */
  line-height: normal;
  padding: 0.4rem 0.75rem;
}

.actions .btn-done:hover,
.actions .btn-done[type="submit"]:hover {
  background: var(--color-text);
}

/* ── Postpone Button ─────────────────────────────────────── */
.btn-postpone,
.btn-postpone[type="submit"] {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.btn-postpone:hover,
.btn-postpone[type="submit"]:hover {
  background: var(--color-text-muted);
  color: #fff;
  transform: translateY(-1px);
}

/* ── Date Shortcuts (Todo-Formular) ─────────────────────── */
.date-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
  /* #338: mehr Abstand zwischen den Datumsvorgaben und dem Datumsfeld */
  margin-bottom: 0.75rem;
}

/* ── Snooze Dropdown ────────────────────────────────────── */
.snooze-dropdown {
  position: relative;
}

.snooze-dropdown > .btn-snooze-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: background 0.15s, color 0.15s;
}

.snooze-dropdown > .btn-snooze-toggle::-webkit-details-marker {
  display: none;
}

.snooze-dropdown > .btn-snooze-toggle:hover {
  background: var(--color-text-muted);
  color: #fff;
}

.snooze-dropdown .snooze-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
  min-width: 120px;
}

.snooze-menu .snooze-option,
.snooze-menu .snooze-option[type="submit"] {
  display: block;
  width: 100%;
  padding: 0.35rem 0.6rem;
  background: none;
  border: none;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.snooze-menu .snooze-option:hover,
.snooze-menu .snooze-option[type="submit"]:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.snooze-menu .button_to {
  margin: 0;
}

/* ── Avatars ─────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-bg);
}

.avatar-xxs { width: 24px; height: 24px; }
.avatar-xs { width: 32px; height: 32px; }
.avatar-sm { width: 40px; height: 40px; }
.avatar-lg { width: 100px; height: 100px; }

/* Personen-Erwähnung im Tagebuch-Freitext: Avatar vor dem Namen.
   Der Span bleibt inline, damit die Textbaseline (und damit die
   Satzzeichen hinter dem Namen) nicht verrutscht. */
.journal-mention {
  white-space: nowrap;
}

.journal-mention .avatar {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.2rem;
}

.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  line-height: 1;
}

.avatar-initials.avatar-xs { font-size: 0.7rem; }
.avatar-initials.avatar-sm { font-size: 0.8rem; }
.avatar-initials.avatar-lg { font-size: 2rem; }

.person-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.person-header h2 {
  margin: 0;
}

.person-header-meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.avatar-preview-container {
  text-align: center;
  margin: 0.75rem 0;
}

.avatar-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 3px solid var(--color-border);
}

.avatar-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.avatar-option label {
  font-size: 0.8125rem;
  display: block;
  margin-bottom: 0.2rem;
}

.avatar-option select {
  width: 100%;
}

@media (max-width: 600px) {
  .avatar-options-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Avatar Editor Page ─────────────────────────────────── */
form:has(.avatar-editor-page) {
  max-width: 780px;
}

.avatar-editor-page {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 140px);
}

.avatar-editor-page .avatar-preview-container {
  flex-shrink: 0;
  text-align: center;
  padding: 1rem 0;
}

.avatar-options-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0 0.5rem;
}

.avatar-category {
  margin-bottom: 1.25rem;
}

.avatar-category > label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.avatar-box-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.avatar-box {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.avatar-box:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.avatar-box.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.avatar-box.selected:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.avatar-box input[type="radio"] {
  display: none;
}

.avatar-color-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  user-select: none;
}

.avatar-color-circle:hover {
  border-color: var(--color-primary);
  transform: scale(1.1);
}

.avatar-color-circle.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
  transform: scale(1.1);
}

.avatar-color-circle input[type="radio"] {
  display: none;
}

/* ── Detail Views ────────────────────────────────────────── */
.detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.detail-card p {
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.detail-card strong {
  display: inline-block;
  min-width: 100px;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Absätze brauchen ihren Abstand am .markdown-body selbst: Der globale Reset
   nimmt <p> jede Margin, und .detail-card p gibt sie nur dort zurück, wo der
   Text in einer detail-card steht – in einer Bewertungszeile etwa nicht, und
   die Leerzeilen aus dem Markdown verschwanden dort spurlos. */
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

/* Markdown-Inhalt: **fett** soll fett sein und nicht das Label-Styling
   der detail-card erben (sonst Großbuchstaben, grau, 100px Mindestbreite) */
.markdown-body strong {
  display: inline;
  min-width: 0;
  color: inherit;
  font-weight: 700;
  font-size: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.reading-note {
  margin-top: 0.35rem;
}

.reading-note p:last-child {
  margin-bottom: 0;
}

.search-link {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  vertical-align: middle;
  line-height: 1.4;
}

.search-link:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.detail-card ul {
  list-style: none;
  padding: 0;
  margin-top: 0.25rem;
}

/* Die Szenario-Liste bringt ihre eigene Auffüllung mit, sonst kleben
   Prozentwert und Badge am Rahmen. */
.detail-card ul:not(.forecast-scenarios) li {
  padding: 0.25rem 0;
}

/* Markdown-Listen sollen Aufzählungszeichen behalten und nicht das
   list-style: none der detail-card erben */
.markdown-body ul,
.markdown-body ol {
  list-style: revert;
  padding-left: 1.5rem;
}

.markdown-body li {
  padding: 0;
}

.detail-card-columns {
  display: flex;
  gap: 2rem;
}

.detail-card-main {
  flex: 1;
}

.detail-card-sidebar {
  flex: 0 0 auto;
  border-left: 1px solid var(--color-border);
  padding-left: 2rem;
}

.people-list-avatars {
  list-style: none;
  padding: 0;
  margin-top: 0.5rem;
}

.people-list-avatars li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
}

/* ── Todo Show ─────────────────────────────────────────────── */
.todo-show-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.todo-show-title {
  margin: 0 0 0.85rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

/* Meta-Leiste: Priority/Status/Fälligkeit etc. als scanbare Badges
   statt verteilter Label-Zeilen. */
.todo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.meta-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.8125rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  white-space: nowrap;
}

.meta-badge-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.meta-badge-open {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: transparent;
  font-weight: 600;
}

.meta-badge-done {
  background: var(--color-success-light);
  color: var(--color-success);
  border-color: transparent;
  font-weight: 600;
}

.meta-badge-deadline .meta-badge-label {
  color: var(--color-error);
}

/* ID zum Nachschlagen für die API/CLI — rechts abgesetzt und bewusst leise,
   damit sie die Badge-Leiste nicht mitliest. Doppelklick markiert sie ganz. */
.todo-meta-id {
  margin-left: auto;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  user-select: all;
}

a.meta-badge-link {
  text-decoration: none;
}

a.meta-badge-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Beschreibung ist der Hauptinhalt — abgesetzt mit eigener Hintergrundfarbe,
   volle Breite, kein Label-Styling. */
.todo-show-description {
  line-height: 1.7;
  margin-bottom: 1.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
}

.todo-show-description p {
  margin-bottom: 0.9rem;
}

.todo-show-description p:last-child {
  margin-bottom: 0;
}

.todo-show-url {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  word-break: break-word;
}

.todo-show-url-icon {
  flex: 0 0 auto;
  font-size: 0.9em;
}

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

.actions a {
  font-size: 0.875rem;
}

/* button_to umschließt den Button mit einem <form>. display: contents
   blendet die Form-Box aus dem Layout, sodass der Button zum direkten
   Flex-Kind von .actions wird – identisch behandelt wie die Link-Aktionen,
   wodurch Button- und Link-Aktionen browserübergreifend auf einer Linie
   sitzen. (Die margin-left:auto-Rechtsbündigkeit von Delete wandert dadurch
   vom <form> auf den Button selbst, siehe .actions .btn-destroy.) */
.actions .button_to {
  display: contents;
}

/* ── Forms ────────────────────────────────────────────────── */
form {
  max-width: 480px;
}

.form-group {
  margin-bottom: 1.25rem;
}

label,
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(192, 104, 48, 0.12);
}

/* #338: Date-/Time-Inputs (z.B. die Deadline-Box in „Mehr Optionen") dürfen
   ihren umgebenden Container nicht überlaufen. max-width als harmlose
   Absicherung auf allen Browsern. */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  max-width: 100%;
}

/* iOS-Safari-spezifisch: Das native Date-/Time-Control ignoriert dort
   width: 100% und behält seine intrinsische Breite → es sprengt den
   Container (.form-group der Deadline). @supports (-webkit-touch-callout)
   greift ausschließlich in iOS-Safari, daher bleibt der Desktop (inkl.
   Kalender-Icon) unangetastet. appearance: none macht das Control zu einer
   normalen, breiten-respektierenden Box; min-height hält die Feldhöhe. */
@supports (-webkit-touch-callout: none) {
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 0;
    min-height: 2.6rem;
  }
}

textarea {
  min-height: 120px;
  resize: vertical;
}

select[multiple] {
  min-height: 140px;
}

select:not([multiple]) {
  height: auto;
}

input[type="submit"],
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

input[type="submit"]:hover,
button[type="submit"]:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* Sticky Submit für Formulare (#284): Die Aktions-Buttons bleiben am
   unteren Rand fixiert, sodass man bei langen Formularen nicht scrollen
   muss, um sie zu erreichen. Der fixierte Verlauf liegt deckungsgleich
   auf dem body-Hintergrund und ist dadurch unsichtbar.

   Zentral angewandt auf den letzten Aktions-Container eines Formulars
   (das .form-group bzw. .actions mit einem Submit-Button als direktem
   Kind). Inline-Such-/Filterformulare ohne solchen Wrapper bleiben
   unberührt. .form-actions-sticky dient als expliziter Opt-in-Alias. */
form > .form-group:has(> input[type="submit"]),
form > .form-group:has(> button[type="submit"]),
form > .actions:has(> input[type="submit"]),
form > .actions:has(> button[type="submit"]),
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 1rem;
  margin-bottom: 0;
  padding: 0.75rem 0;
  background: var(--bg-gradient) fixed;
}

/* Platz unter dem Formularinhalt, damit der sticky Button-Streifen
   die letzten Eingabefelder nicht verdeckt. */
.container form {
  padding-bottom: 0.5rem;
}

/* Sign out button in header */
.header button[type="submit"] {
  background: none;
  color: var(--color-text-muted);
  padding: 0;
  font-size: 0.875rem;
  border: none;
  transform: none;
}

.header button[type="submit"]:hover {
  color: var(--color-primary);
  background: none;
  transform: none;
}

/* Destroy buttons – per margin-left:auto rechtsbündig. Da der button_to-
   Form via display: contents kein Box mehr bildet, sitzt das auto-Margin
   direkt auf dem Button. */
.actions .btn-destroy,
.actions .btn-destroy[type="submit"] {
  margin-left: auto;
  background: none;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: normal;
  padding: 0;
  border: none;
  transform: none;
}

.actions .btn-destroy:hover,
.actions .btn-destroy[type="submit"]:hover {
  background: none;
  color: var(--color-error);
  transform: none;
  text-decoration: underline;
}

/* ── Inline Forms ────────────────────────────────────────── */
.inline-form {
  display: inline;
  max-width: none;
}

/* ── Checkbox Labels ─────────────────────────────────────── */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

/* ── People Toggle Buttons (Interaction Form) ────────────── */
.people-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.people-toggle-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.people-toggle-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.people-toggle-btn.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.people-toggle-btn.selected:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.people-toggle-btn input[type="checkbox"],
.people-toggle-btn input[type="radio"] {
  display: none;
}

/* ── Journal Scale Buttons ───────────────────────────────── */
.scale-hint {
  margin: 0 0 0.5rem 0;
  color: var(--color-text-muted, #666);
}

.scale-btn {
  padding: 0.35rem 0.6rem;
}

.scale-emoji {
  font-size: 1.4rem;
  line-height: 1;
}

/* ── Journal Entry Form ──────────────────────────────────── */
form.journal-form {
  max-width: 780px;
}

.journal-form input[type="date"] {
  width: auto;
  min-width: 11rem;
}

.journal-scale-pairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1.5rem;
}

.journal-form .temperature-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
}

.journal-form .bp-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.journal-form .bp-row {
  display: grid;
  grid-template-columns: 6rem 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
}

.journal-form .bp-label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.journal-form .bp-sep {
  color: var(--color-text-muted);
  text-align: center;
}

@media (max-width: 600px) {
  .journal-scale-pairs {
    grid-template-columns: 1fr;
  }
}

/* ── Time Picker (Interaction Form) ──────────────────────── */
.time-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.time-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.time-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.time-btn.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.time-btn.selected:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.mt-label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

/* ── Flash Messages ──────────────────────────────────────── */
.flash-messages {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
}

/* .notice rendert das Layout bewusst nicht (Rails-Standardmeldungen sollen
   nicht überall aufpoppen); .info ist der Kanal für selbst geschriebene
   Hinweise, die sichtbar sein sollen. Optisch dieselbe ruhige Kachel. */
.flash.notice,
.flash.info {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid #b6dbc4;
}

.flash.alert {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid #f0c4c2;
}

/* ── Form Errors ─────────────────────────────────────────── */
.form-errors {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid #f0c4c2;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.form-errors h2 {
  font-size: 0.9375rem;
  color: var(--color-error);
  margin-bottom: 0.5rem;
}

.form-errors ul {
  padding-left: 1.25rem;
  margin: 0;
}

.form-errors li {
  margin-bottom: 0.25rem;
}

/* ── Auth Pages ──────────────────────────────────────────── */
fieldset {
  border: none;
  padding: 0;
}

fieldset table {
  width: 100%;
  border-collapse: collapse;
}

fieldset th {
  text-align: left;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  padding: 0.5rem 1rem 0.5rem 0;
  white-space: nowrap;
}

fieldset td {
  padding: 0.5rem 0;
  width: 100%;
}

fieldset td input[type="email"],
fieldset td input[type="password"] {
  width: 100%;
}

section {
  margin-top: 1.25rem;
}

/* ── Cultural Memory Styles ─────────────────────────────── */
.cultural-memories {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cultural-memory-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.cultural-memory-item:hover {
  box-shadow: var(--shadow-md);
}

.cultural-memory-date {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  flex: none;
}

.photo-exhibition-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.photo-exhibition-card:hover {
  box-shadow: var(--shadow-md);
}

.photo-exhibition-thumb {
  flex: none;
  display: block;
  width: 96px;
  height: 96px;
}

.photo-exhibition-thumb img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

/* Title and description share this column's left edge, so they line up. */
.photo-exhibition-main {
  flex: 1;
  min-width: 0;
}

.photo-exhibition-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
}

.photo-exhibition-title {
  font-weight: 600;
}

.photo-exhibition-date {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  flex: none;
}

.photo-exhibition-venue {
  margin-top: 0.3rem;
}

.photo-exhibition-desc {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.cultural-memory-category {
  display: inline-block;
  background: var(--color-culture-light);
  color: var(--color-culture);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  margin-left: 0.35em;
  vertical-align: baseline;
}

.cultural-memory-rating {
  flex: none;
  color: var(--color-culture);
}

.rating-stars {
  color: var(--color-culture);
  letter-spacing: 0.05em;
}

.cultural-memory-image-container {
  margin-bottom: 1rem;
}

.cultural-memory-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.cultural-memory-image-preview {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-top: 0.5rem;
}

.memento-image-container {
  margin-bottom: 1rem;
}

.memento-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.memento-image-preview {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-top: 0.5rem;
}

.book-author {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-left: 0.25em;
}

.book-author::before {
  content: "— ";
}

.book-tags {
  display: inline-block;
  font-size: 0.65rem;
  font-style: italic;
  margin-left: 0.35em;
}

.tag-link {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-style: normal;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  margin-right: 0.25rem;
}

.tag-link:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.tag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.5rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.tag-cloud-link {
  background: color-mix(in srgb, var(--tag-color, var(--color-primary)) 12%, var(--color-surface));
  border-color: color-mix(in srgb, var(--tag-color, var(--color-primary)) 35%, transparent);
  color: var(--tag-color, var(--color-primary));
  line-height: 1.4;
}

.tag-cloud-link:hover {
  background: color-mix(in srgb, var(--tag-color, var(--color-primary)) 22%, var(--color-surface));
  border-color: var(--tag-color, var(--color-primary));
  color: var(--tag-color, var(--color-primary));
}

.tag-cloud-link.active {
  background: var(--tag-color, var(--color-primary));
  border-color: var(--tag-color, var(--color-primary));
  color: var(--color-surface);
  font-weight: 600;
}

.tag-count {
  opacity: 0.6;
  font-size: 0.75em;
  margin-left: 0.2em;
}

.active-filter {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.journal-pager {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.journal-pager-next {
  margin-left: auto;
}

/* ── Blutdruck (Verlauf-Sektion) ─────────────────────────── */
.journal-bp-row {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.journal-bp-row .journal-trend-box-chart {
  flex: 1;
  min-width: 0;
}

@media (max-width: 480px) {
  .journal-bp-row {
    flex-direction: column;
    align-items: stretch;
  }
}

.journal-bp-summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.2rem;
  flex: 0 0 auto;
  min-width: 6rem;
}

.journal-bp-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.journal-bp-summary-days {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.journal-bp-summary-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.journal-bp-trend {
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 1px;
}

.journal-bp-trend.up {
  color: var(--color-error);
}

.journal-bp-trend.down {
  color: var(--color-success);
}

.journal-entry-snippet {
  margin-top: 0.25rem;
  margin-bottom: 0.6rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.journal-photo-section {
  margin-bottom: 1rem;
}

/* Das Titelbild steht groß über dem Eintrag, wie bei den Touren. */
.journal-cover-photo {
  display: block;
  margin-bottom: 0.6rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: zoom-in;
  line-height: 0;
}

.journal-cover-photo-image {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

/* Die übrigen Fotos als Kacheln darunter — Tippziel groß genug fürs Tablet. */
.journal-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.journal-photo-gallery-item {
  display: block;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.journal-photo-gallery-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.journal-photo-gallery-item:hover .journal-photo-gallery-image {
  transform: scale(1.04);
}

.journal-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.journal-photo-preview {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
}

.journal-photo-thumb {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.journal-photo-remove,
.journal-photo-cover {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.journal-photo-preview.is-cover .journal-photo-thumb {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

.journal-photo-preview.is-cover .journal-photo-cover {
  color: var(--color-primary);
  font-weight: 600;
}

.journal-entry-photo-thumb {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  display: block;
}

/* ── Ältere Einträge (Karten) ────────────────────────────── */
.journal-entries {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.journal-entry-card {
  display: flex;
  gap: 0.9rem;
  padding: 0.8rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, transform 0.1s;
}

.journal-entry-card:hover {
  box-shadow: var(--shadow-md);
}

.journal-entry-card-photo {
  flex: 0 0 auto;
  line-height: 0;
  position: relative;
}

/* Zählt die weiteren Bilder, von denen die Karte nur das erste zeigt. */
.journal-entry-photo-count {
  position: absolute;
  right: 0.2rem;
  bottom: 0.2rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.4;
}

.journal-entry-card-body {
  flex: 1;
  min-width: 0;
}

.journal-entry-card-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}

.journal-entry-card-date {
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
}

.journal-entry-card-date:hover {
  text-decoration: underline;
}

.journal-entry-card-age {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.journal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-text-muted) 8%, transparent);
  border-radius: 999px;
  white-space: nowrap;
}

/* Skalen-Tags je nach Wert rot (schlecht) → grün (gut) hinterlegt */
.tag-scale {
  color: var(--color-text);
  background: color-mix(
    in srgb,
    color-mix(in srgb, var(--color-error), var(--color-success) calc(var(--scale-weight, 0.5) * 100%)) 22%,
    transparent
  );
}

/* ── Pagination ──────────────────────────────────────────── */
.journal-year-nav,
.journal-month-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

/* Folgt direkt die Monats-Leiste, bleiben Jahr und Monat enger gruppiert. */
.journal-year-nav:has(+ .journal-month-nav) {
  margin-bottom: 0.75rem;
}

.journal-year-nav .btn,
.journal-month-nav .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

.journal-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.journal-pagination-status {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.journal-memory-card-photo {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin: 0.4rem 0;
  display: block;
}

.journal-entry-snippet strong {
  font-weight: 600;
  margin-right: 0.25rem;
}

.journal-prompt {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 0.4rem 0;
}

.journal-prompt-text {
  margin: 0 0 0.3rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.journal-prompt-snippet {
  margin: 0 0 0.3rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--color-border);
  line-height: 1.5;
}

.journal-prompt-snippet strong {
  color: var(--color-text-muted);
}

.journal-prompt-snippet-full {
  margin-top: 0.3rem;
}

.journal-prompt-snippet-full > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-primary);
  list-style: none;
  user-select: none;
}

.journal-prompt-snippet-full > summary::-webkit-details-marker {
  display: none;
}

.journal-prompt-snippet-full > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 0.15s ease;
}

.journal-prompt-snippet-full[open] > summary::before {
  transform: rotate(90deg);
}

.journal-prompt-snippet-full > .journal-section:first-of-type {
  margin-top: 0.6rem;
}

.journal-prompt-snippet-full > .journal-section:last-child {
  margin-bottom: 0;
}

.journal-prompt-snippet-full .journal-section h2 {
  font-size: 1rem;
}

.journal-prompt-snippet-full .journal-cover-photo-image {
  max-height: 300px;
}

.journal-prompt-question {
  margin: 0;
  font-style: italic;
  line-height: 1.5;
}

.journal-entry-prompt {
  margin: 0 0 0.6rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--color-border);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.journal-entry-prompt-label {
  font-weight: 600;
}

.journal-entry-prompt-question {
  font-style: italic;
}

.forecast-group {
  margin-top: 1rem;
}

.forecast-group-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.forecast-group-overdue .forecast-group-heading {
  color: var(--color-error);
}

.forecast-group-happened .forecast-group-heading {
  color: var(--color-success);
}

.forecast-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.forecast-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

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

.forecast-item.overdue {
  background: color-mix(in srgb, var(--color-error) 7%, var(--color-surface));
}

.forecast-item.resolved {
  opacity: 0.8;
}

.forecast-title {
  min-width: 0;
}

.forecast-probability {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.forecast-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.forecast-scenarios {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.forecast-scenarios li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.forecast-scenarios li.selected {
  border-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 10%, var(--color-surface));
}

.forecast-scenarios li.remainder {
  border-style: dashed;
  color: var(--color-text-muted);
}

.forecast-scenarios .scenario-prob {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 3.5rem;
}

.forecast-scenarios .scenario-title {
  flex: 1;
}

.forecast-scenarios .scenario-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-success);
  font-weight: 600;
}

.forecast-scenarios-summary {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.scenarios-fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.scenarios-fieldset legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

.scenarios-fieldset .form-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.6rem;
}

.scenario-fields {
  margin-bottom: 0.5rem;
}

.scenario-row {
  display: grid;
  grid-template-columns: 1fr 6rem auto;
  gap: 0.6rem;
  align-items: end;
}

.scenario-row .form-group {
  margin-bottom: 0;
}

.scenario-row .btn-remove {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.scenario-row .btn-remove:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}

.resolve-scenarios {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.resolve-option {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.resolve-option:last-child {
  border-bottom: none;
}

.resolve-option .scenario-prob {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 3.5rem;
}

.book-cover-container {
  margin-bottom: 1rem;
}

.book-cover {
  max-width: 200px;
  max-height: 300px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.book-cover-list {
  width: 35px;
  height: 50px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.book-cover-thumb {
  flex: 0 0 35px;
}

.book-cover-preview {
  max-width: 150px;
  max-height: 225px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-top: 0.5rem;
}

.culture-tabs {
  display: flex;
  gap: 0.5rem;
}

/* ── Tour Styles ──────────────────────────────────────── */
#filter-year,
#filter-type,
#filter-region,
#filter-sort,
#tour-filters {
  scroll-margin-top: 4rem;
}

.tour-stats {
  margin-bottom: 1.5rem;
}

.tour-stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.5rem;
}

.tour-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-tours);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.tour-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-tours);
}

.tour-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tour-record-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.5rem;
}

.tour-record-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-tours);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.tour-record-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tour-record-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-tours);
}

.tour-record-name {
  font-size: 0.85rem;
  line-height: 1.2;
}

.tour-record-date {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.tour-memory-thumb-link {
  display: block;
  margin-top: 0.25rem;
  line-height: 0;
}

.tour-memory-thumb {
  width: 100%;
  height: 4.5rem;
  background: var(--color-tours-light);
  border-radius: var(--radius);
  display: block;
  cursor: pointer;
}

.tour-memory-attribution {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  text-align: right;
}

.tour-memory-attribution a {
  color: inherit;
  text-decoration: underline;
}

.tour-memory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.tour-memory-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 0.35rem;
  overflow: hidden;
}

.tour-memory-bar-fill {
  height: 100%;
  background: var(--color-tours);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.tours-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tour-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.tour-item:hover {
  box-shadow: var(--shadow-md);
}

/* Eine Bewertung kann ein langer Markdown-Text sein. Datum und Aktionen sollen
   dann nicht in dessen Mitte schweben, sondern oben an der ersten Zeile stehen. */
.review-item {
  align-items: flex-start;
}

.tour-date {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  flex: none;
}

.tour-meta {
  flex: none;
  display: flex;
  gap: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.tour-activity-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  margin-left: 0.35em;
  vertical-align: baseline;
}

.aquarium-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.aquarium-log-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: box-shadow 0.15s, background 0.15s;
}

.aquarium-log-item:hover {
  box-shadow: var(--shadow-md);
}

.aquarium-log-date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.aquarium-log-tank {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.aquarium-log-body p {
  margin: 0 0 0.5rem 0;
}

.aquarium-log-body p:last-child {
  margin-bottom: 0;
}

.aquarium-log-actions {
  display: flex;
  justify-content: flex-end;
  font-size: 0.85rem;
}


.tour-map-container {
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 0;
}

.tour-map {
  width: 100%;
  height: 800px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.tour-photo-marker {
  background: transparent;
  border: none;
}

.tour-photo-marker img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  object-fit: cover;
  display: block;
}

.tour-photo-marker {
  cursor: pointer;
}

.tours-map-container {
  margin-bottom: 1.5rem;
}

.tours-map-full {
  width: 100%;
  height: 70vh;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.chart-card h3 {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.chart-total {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-tours);
}

.chart-container {
  position: relative;
  height: 200px;
}

.chart-container-chronicle {
  height: 300px;
}

/* ── Filter Buttons ────────────────────────────────────── */
.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn-filter {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-filter:hover {
  border-color: var(--color-culture);
  background: var(--color-culture-light);
  color: var(--color-culture);
  text-decoration: none;
}

.btn-filter.active {
  background: var(--color-culture);
  border-color: var(--color-culture);
  color: #fff;
}

.btn-filter.active:hover {
  background: var(--color-culture-hover);
  border-color: var(--color-culture-hover);
  color: #fff;
}

.btn-filter.tours:hover {
  border-color: var(--color-tours);
  background: var(--color-tours-light);
  color: var(--color-tours);
}

.btn-filter.tours.active {
  background: var(--color-tours);
  border-color: var(--color-tours);
  color: #fff;
}

.btn-filter.tours.active:hover {
  background: var(--color-tours-hover);
  border-color: var(--color-tours-hover);
  color: #fff;
}

.btn-filter.habits:hover {
  border-color: var(--color-habits);
  background: var(--color-habits-light);
  color: var(--color-habits);
}

.btn-filter.habits.active {
  background: var(--color-habits);
  border-color: var(--color-habits);
  color: #fff;
}

.btn-filter.habits.active:hover {
  background: var(--color-habits-hover);
  border-color: var(--color-habits-hover);
  color: #fff;
}

/* ── Tour Filter Form ───────────────────────────────────── */
.tour-filter-form {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.tour-filter-form > summary {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  list-style: none;
}

.tour-filter-form > summary::-webkit-details-marker {
  display: none;
}

.tour-filter-form > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s;
}

.tour-filter-form[open] > summary::before {
  transform: rotate(90deg);
}

.tour-filter-form[open] {
  padding-bottom: 0.85rem;
}

.tour-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0 0.85rem;
}


.tour-filter-field label {
  margin-bottom: 0.25rem;
}

.tour-filter-field--wide {
  grid-column: 1 / -1;
}

.tour-filter-range {
  display: flex;
  gap: 0.4rem;
}

.tour-filter-range input {
  min-width: 0;
}

.tour-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.85rem;
}

.tour-filter-grid .people-toggle-grid {
  gap: 0.35rem;
}

.tour-filter-grid .people-toggle-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  margin: 1rem 0 1.5rem;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.tab {
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  cursor: pointer;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel {
  display: none;
}

/* Der Inhalt eines Tabs stand nackt auf dem Seitenhintergrund, während sonst
   überall Karten stehen – er bekommt dieselbe weiße Fläche. */
.tab-panel.active {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.tab-panel > p:first-child {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.preference-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.25rem 1rem;
  margin-bottom: 1.25rem;
}

.preference-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.preference-checkbox:hover {
  background: var(--color-primary-light);
}

.preference-checkbox input {
  margin: 0;
}

/* ── Books Timeline ──────────────────────────────────────── */
.books-timeline-scroll {
  overflow-x: auto;
  padding: 0.4rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.books-timeline-heatmap {
  border-collapse: separate;
  border-spacing: 0.15rem;
  font-size: 0.8rem;
}

.books-timeline-heatmap th {
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 0.2rem 0.35rem;
  text-align: center;
}

.books-timeline-heatmap th.tag-col {
  text-align: left;
}

.books-timeline-heatmap td {
  padding: 0;
}

.books-timeline-heatmap td.tag-col {
  padding: 0.15rem 0.4rem 0.15rem 0.2rem;
  white-space: nowrap;
}

.books-timeline-heatmap td.total-col,
.books-timeline-heatmap th.total-col {
  padding: 0.15rem 0.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.books-timeline-heatmap td.heatmap-cell {
  min-width: 2.2rem;
  height: 1.7rem;
  text-align: center;
  background: color-mix(in srgb, var(--color-primary) calc(var(--cell-weight, 0) * 70%), transparent);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.books-timeline-heatmap .heatmap-cell-link {
  display: block;
  width: 100%;
  height: 100%;
  line-height: 1.7rem;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.timeline-recommendations {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.timeline-recommendations li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.timeline-recommendations .recommendation-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ── Favorite Authors ────────────────────────────────────── */
.favorite-authors {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.favorite-author {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.favorite-author-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.favorite-author-name {
  font-size: 1.1rem;
  margin: 0;
}

.favorite-author-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.favorite-author-avg {
  font-weight: 600;
}

.favorite-author-books {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.favorite-author-books li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.favorite-author-book-year {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  min-width: 2.5rem;
}

/* ── Utilities ───────────────────────────────────────────── */
.mt-2 {
  margin-top: 1.5rem;
}

.mt-3 {
  margin-top: 2.25rem;
}

.mb-2 {
  margin-bottom: 1.5rem;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-sm {
  font-size: 0.85rem;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5rem 0;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .home-grid {
    grid-template-columns: 1fr;
  }

  .home-grid .section-card + .section-card {
    margin-top: 1.5rem;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 1rem 0.75rem;
  }

  .section-card {
    padding: 1rem;
  }

  /* Wrap instead of stack — avatar + name + button stay on row 1,
     meta info (last-seen / todo-meta) wraps to row 2 */
  .interactions .interaction,
  .people .person,
  .todos .todo {
    flex-wrap: wrap;
    column-gap: 0.5rem;
    row-gap: 0.15rem;
  }

  .cultural-memory-item,
  .tour-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Meta wraps to its own row below */
  .last-seen {
    order: 1;
    flex: 0 0 100%;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 0.35rem;
    font-size: 0.75rem;
  }

  .todo-meta {
    order: 1;
    flex: 0 0 100%;
    text-align: left;
  }

  /* Auf dem Handy ueberladen die Prio- (H/M/N) und Verschiebe-Buttons
     (+1d, →Mo, Move) die schmale Zeile und machen die Liste unbrauchbar –
     daher ausblenden. Aendern geht weiter ueber die Detailseite; "Done"
     bleibt zum schnellen Abhaken erhalten. */
  .todos .todo-priority-buttons,
  .todos .btn-postpone {
    display: none;
  }

  /* Auf der Detailseite die Verschiebe-/Move-Buttons-Reihe umbrechen, statt
     ueber die Box hinauszulaufen. */
  .todo-show .actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .habits-list .habit-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .section-card .people .person:hover,
  .section-card .todos .todo:hover,
  .section-card .habits-list .habit-item:hover {
    margin: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  form {
    max-width: 100%;
  }

  h1 {
    font-size: 1.5rem;
  }
}

/* ── Keyboard Shortcut Help Overlay ─────────────────────── */
#keyboard-shortcut-help {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.keyboard-shortcut-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.keyboard-shortcut-modal h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
}

.shortcut-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.shortcut-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.shortcut-section dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  align-items: center;
}

.shortcut-section dt {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.shortcut-section dd {
  font-size: 0.875rem;
  color: var(--color-text);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.15rem 0.4rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  box-shadow: 0 1px 0 rgba(45, 42, 38, 0.1);
}

@media (max-width: 1024px) {
  .header .content {
    flex-wrap: wrap;
  }

  .header .logo {
    order: 1;
  }

  .header .signin {
    order: 2;
    margin-left: auto;
  }

  .header-nav {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 0.875rem;
    padding-top: 0.5rem;
  }
}

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

/* ── Tour Photos & Lightbox ──────────────────────────────── */
.tour-header {
  margin-bottom: 1rem;
}

.tour-header-meta {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tour-header-meta .tour-activity-badge {
  margin-left: 0;
}

.tour-header-name {
  margin: 0;
}

.tour-header-regions {
  margin: 0.4rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tour-region-chip {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-decoration: none;
}

.tour-region-chip:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

dl.tour-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tour-stat {
  min-width: 0;
}

.tour-stat-label {
  display: block;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.tour-stat-value {
  display: block;
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  word-break: break-word;
}

@media (min-width: 600px) {
  dl.tour-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tour-cover-photo {
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tour-cover-photo-image {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

.tour-cover-thumb {
  flex: none;
}

.tour-cover-thumb-image {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.tour-route-thumb {
  background: var(--color-tours-light);
  color: var(--color-tours);
  padding: 2px;
}

.tour-cover-thumb-placeholder {
  background: var(--color-tours-light);
}

.tour-photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tour-photo-thumb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.tour-photo-thumb-item.is-cover .tour-photo-thumb {
  outline: 3px solid var(--color-tours);
  outline-offset: -3px;
}

.tour-photo-cover-badge {
  font-size: 0.75rem;
  color: var(--color-tours);
  font-weight: 600;
}

.tour-photo-thumb {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.tour-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tour-photo-gallery-item {
  display: block;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tour-photo-gallery-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.tour-photo-gallery-item:hover .tour-photo-gallery-image {
  transform: scale(1.04);
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.75rem;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  font-size: 2rem;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-counter {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
}

/* Auf Touch-Geräten gibt es kein Hover: größere Flächen zum Tippen. */
@media (pointer: coarse) {
  .lightbox-close {
    width: 3rem;
    height: 3rem;
  }

  .lightbox-prev,
  .lightbox-next {
    width: 3.5rem;
    height: 3.5rem;
  }
}

/* ── Interaction Preparation ─────────────────────────────── */
.prepare-history {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.prepare-history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.prepare-history-note {
  white-space: pre-wrap;
  line-height: 1.6;
}

.journal-section {
  margin-bottom: 1.5rem;
}

.journal-section h2 {
  margin: 0 0 0.5rem;
}

.journal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.journal-trend-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.journal-trend-box h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.journal-trend-box-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.journal-trend-box-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.journal-trend-box-card.wide {
  grid-column: span 2;
}

.journal-trend-box-card.trend-warn {
  border-left: 3px solid var(--color-error);
  padding-left: calc(0.8rem - 3px);
}

.journal-trend-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.journal-trend-box-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.journal-trend-box-period {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.2;
}

.journal-trend-box-sparkline {
  height: 56px;
  position: relative;
}

.journal-trend-box-chart {
  height: 180px;
  position: relative;
}

a.journal-memory-card {
  color: inherit;
  text-decoration: none;
}

a.journal-memory-card:hover {
  background: var(--color-surface-2, rgba(0, 0, 0, 0.03));
}

.journal-memory-card-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.journal-memory-card-body {
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}

@media (min-width: 600px) {
  .journal-trend-box-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .journal-trend-box-card.wide {
    grid-column: span 4;
  }
}

.journal-stat {
  min-width: 0;
}

.journal-stat-label {
  display: block;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.journal-stat-value {
  display: block;
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  word-break: break-word;
}

.journal-stat-note {
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.journal-stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal-stat-list li + li {
  margin-top: 0.25rem;
}

.journal-stat-list-inline {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
}

.journal-stat-list-inline li + li {
  margin-top: 0;
}

@media (min-width: 600px) {
  .journal-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .journal-stat-wide {
    grid-column: span 2;
  }
}

/* ── Todo Categories ────────────────────────────────────── */
.category-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.category-swatch {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.people-toggle-btn.category-toggle:hover {
  border-color: var(--category-color, var(--color-primary));
  background: color-mix(in srgb, var(--category-color, var(--color-primary)) 12%, transparent);
}

.people-toggle-btn.category-toggle.selected,
.people-toggle-btn.category-toggle.selected:hover {
  background: var(--category-color, var(--color-primary));
  border-color: var(--category-color, var(--color-primary));
  color: #fff;
}

.people-toggle-btn.category-toggle.selected .category-swatch {
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-filter.category-filter:hover {
  border-color: var(--category-color, var(--color-primary));
  background: color-mix(in srgb, var(--category-color, var(--color-primary)) 14%, transparent);
  color: var(--color-text);
}

.btn-filter.category-filter.active,
.btn-filter.category-filter.active:hover {
  background: var(--category-color, var(--color-primary));
  border-color: var(--category-color, var(--color-primary));
  color: #fff;
}

.category-inline-form {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.category-inline-form[hidden] {
  display: none;
}

.category-inline-form input[type="text"] {
  flex: 1;
  min-width: 8rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.category-inline-form input[type="color"] {
  width: 2.5rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  background: var(--color-primary);
  border: 1px solid var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  cursor: pointer;
}

.btn-small:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-link {
  background: none;
  border: none;
  padding: 0.3rem 0;
  margin-top: 0.4rem;
  color: var(--color-primary);
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

.form-error {
  flex-basis: 100%;
  color: var(--color-error);
  font-size: 0.8125rem;
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.category-row .category-count {
  color: var(--color-text-muted, #888);
  font-size: 0.8125rem;
}

.category-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

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

/* ── Kalender ─────────────────────────────────────────────── */
.calendar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.calendar-title {
  flex: 1 1 100%;
  order: -1;
  font-size: 1.25rem;
  margin: 0;
}

.calendar-nav {
  display: inline-flex;
  gap: 0.25rem;
}

.calendar-nav-btn {
  min-width: 2.25rem;
  text-align: center;
}

.calendar-views {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.calendar-view-btn.is-active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.calendar-new-btn {
  margin-left: auto;
}

/* Wochentags-Spalten (Tag, 3 Tage, Woche) */
.calendar-columns {
  display: grid;
  gap: 0.5rem;
}

.calendar-columns--tag {
  grid-template-columns: 1fr;
}

.calendar-columns--drei {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calendar-columns--woche {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* Tablet quer: Woche in zwei Reihen (4 + 3), bleibt als Raster lesbar. */
@media (max-width: 1024px) {
  .calendar-columns--woche {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Tablet hoch / kleine Geräte: 3 Tage nebeneinander, Woche in zwei Spalten. */
@media (max-width: 760px) {
  .calendar-columns--woche {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-columns--drei {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Handy: alles gestapelt. */
@media (max-width: 520px) {
  .calendar-columns--woche,
  .calendar-columns--drei {
    grid-template-columns: 1fr;
  }
}

.calendar-day {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.calendar-day.is-today {
  border-color: var(--color-primary);
  box-shadow: inset 0 2px 0 var(--color-primary);
}

.calendar-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}

.calendar-day-weekday {
  font-weight: 600;
  font-size: 0.85rem;
}

.calendar-day-date {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.calendar-day-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem;
}

.calendar-empty {
  color: var(--color-text-muted);
  text-align: center;
  font-size: 0.85rem;
}

.cal-item {
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--cal-color, var(--color-primary));
  background: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.82rem;
  min-width: 0;
}

.cal-item:hover {
  background: var(--color-primary-light);
}

.cal-item-time {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  flex: 0 0 auto;
}

.cal-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-item--event { --cal-color: var(--color-primary); }
.cal-item--habit { --cal-color: var(--color-habits); }
.cal-item--todo { --cal-color: var(--color-todos); }
.cal-item--cultural_memory { --cal-color: var(--color-culture); }
.cal-item--interaction { --cal-color: var(--color-interactions); }
.cal-item--appointment { --cal-color: var(--color-error); }

/* Kalender-Filter: ausgeblendete Kategorien (Klasse am Wrapper).
   Nur echte Kalender-Items (.cal-item / .cal-event) ausblenden – die
   Filter-Pills tragen zwar cal-item--<kind> (für die Punktfarbe), aber
   weder .cal-item noch .cal-event und bleiben so sichtbar. */
.cal-filter-hide-event .cal-item.cal-item--event,
.cal-filter-hide-event .cal-event.cal-item--event,
.cal-filter-hide-habit .cal-item.cal-item--habit,
.cal-filter-hide-habit .cal-event.cal-item--habit,
.cal-filter-hide-todo .cal-item.cal-item--todo,
.cal-filter-hide-todo .cal-event.cal-item--todo,
.cal-filter-hide-cultural_memory .cal-item.cal-item--cultural_memory,
.cal-filter-hide-cultural_memory .cal-event.cal-item--cultural_memory,
.cal-filter-hide-interaction .cal-item.cal-item--interaction,
.cal-filter-hide-interaction .cal-event.cal-item--interaction,
.cal-filter-hide-appointment .cal-item.cal-item--appointment,
.cal-filter-hide-appointment .cal-event.cal-item--appointment {
  display: none;
}

.calendar-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}

.calendar-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.calendar-filter-item:has(input:not(:checked)) {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.calendar-filter-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.calendar-filter-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--cal-color, var(--color-primary));
  flex: 0 0 auto;
}

.calendar-filter-item:has(input:not(:checked)) .calendar-filter-dot {
  background: var(--color-text-muted);
}

.calendar-filter-item:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* Monatsgitter */
.calendar-month {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calendar-month-head,
.calendar-month-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-month-weekday {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}

.calendar-month-cell {
  min-height: 6.5rem;
  min-width: 0;
  padding: 0.3rem;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calendar-month-cell.is-outside {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.calendar-month-cell.is-today {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.calendar-month-daynum {
  font-size: 0.8rem;
  text-decoration: none;
  color: inherit;
  align-self: flex-start;
}

.calendar-month-items {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-content: flex-start;
}

.cal-event {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--cal-color, var(--color-primary));
  background: color-mix(in srgb, var(--cal-color, var(--color-primary)) 14%, transparent);
  color: var(--color-text);
  font-size: 0.72rem;
  line-height: 1.25;
  text-decoration: none;
}

.cal-event:hover {
  background: color-mix(in srgb, var(--cal-color, var(--color-primary)) 24%, transparent);
}

.cal-event-time {
  font-weight: 600;
  color: var(--cal-color, var(--color-primary));
  flex-shrink: 0;
}

.cal-event-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 800px) {
  .calendar-month-cell {
    min-height: 4.5rem;
  }
}

/* Habit-Ziele */
.calendar-goals {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.calendar-goals summary {
  cursor: pointer;
  font-weight: 600;
}

.calendar-goals-range {
  color: var(--color-text-muted);
  font-weight: 400;
  margin-left: 0.5rem;
  font-size: 0.85rem;
}

.calendar-goals-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 0.4rem;
}

.calendar-goal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border-left: 3px solid var(--color-habits);
}

.calendar-goal.is-reached {
  border-left-color: var(--color-success);
  background: var(--color-success-light);
}

.calendar-goal-name {
  text-decoration: none;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-goal-stats {
  display: inline-flex;
  gap: 0.5rem;
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* Termin-Detailseite */
.calendar-event-time {
  color: var(--color-text-muted);
}

.calendar-event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* "Löschen" ist ein button_to (<form><button>), die anderen sind link_to (<a>).
   display: contents nimmt die Form-Box aus dem Flex-Layout, line-height normal
   vereinheitlicht die Höhe von Button und Links – sonst sind sie verschieden hoch. */
.calendar-event-actions .button_to {
  display: contents;
}

.calendar-event-actions .btn {
  line-height: normal;
}

.form-hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.form-subgroup {
  margin-top: 0.5rem;
}

/* Auswahl „nur diesen Termin" / „ganze Serie" beim Bearbeiten eines
   Serien-Termins. */
.edit-scope {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  background: var(--color-surface);
}

.edit-scope legend {
  font-weight: 600;
  padding: 0 0.35rem;
}

.edit-scope-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-weight: 400;
  cursor: pointer;
}

/* Progressive-disclosure block in the create/edit forms (#306) */
.more-options {
  margin: 1rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 0.9rem;
  background: var(--color-surface);
}

.more-options > summary {
  cursor: pointer;
  padding: 0.7rem 0;
  font-weight: 600;
  color: var(--color-text-muted);
  list-style: none;
  user-select: none;
}

.more-options > summary::-webkit-details-marker {
  display: none;
}

.more-options > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.15s ease;
}

.more-options[open] > summary::before {
  transform: rotate(90deg);
}

.more-options[open] > summary {
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.6rem;
}

.more-options > .form-group:last-child {
  margin-bottom: 0.9rem;
}

/* Quick-add bar on the todo/calendar index pages (#306) */
.quick-add {
  margin: 0 0 1rem;
}

/* Eingeklappter Zustand: nur ein schlanker Auslöser, spart Platz. */
.quick-add > summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  padding: 0.3rem 0.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  list-style: none;
  user-select: none;
}

.quick-add > summary::-webkit-details-marker {
  display: none;
}

.quick-add > summary:hover {
  color: var(--color-primary-hover);
}

.quick-add[open] > summary {
  margin-bottom: 0.5rem;
}

.quick-add[open] .quick-add-bar {
  margin-top: 0;
}

.quick-add-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.quick-add-bar input[type="text"] {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.25rem 0;
}

.quick-add-bar .quick-add-icon {
  color: var(--color-primary);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.quick-add-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

/* Leere Vorschau nimmt keinen Platz weg (mehr Liste sichtbar). */
.quick-add-preview:empty {
  display: none;
}

.quick-add-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.quick-add-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

/* Kategorie-Chips zum Einfügen des #Tags ins Textfeld (statt Abtippen). */
.quick-add-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.quick-add-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.quick-add-cat:hover {
  border-color: var(--category-color, var(--color-primary));
  background: color-mix(in srgb, var(--category-color, var(--color-primary)) 12%, transparent);
}

/* Inline-Quick-Add für Unter-Todos auf der Detailseite: nur ein Titel nötig. */
.subtodo-quick-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.subtodo-quick-add-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9rem;
}

.subtodo-quick-add-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Kompakter Kopfbereich der Todo-Seite (#306): Überschrift und Aktionen in
   einer Zeile, verdichtete Abstände, damit mehr von der Liste sichtbar ist. */
.todos-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.todos-header h1 {
  margin-bottom: 0;
  font-size: 1.4rem;
}

.todos-header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Abstand nach unten kommt vom Spalten-Gap (.todos-side) bzw. vom Grid-Gap,
   wenn sich die Spalte einspaltig auflöst. */
.todos-banners {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.todos-filters {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  box-shadow: var(--shadow);
}

.todos-filters .culture-tabs {
  flex-wrap: wrap;
}

/* Kategorie-Filter kleiner und zurückhaltender; aktiv/hover behalten Farbe. */
.category-tabs {
  gap: 0.3rem;
}

.category-tabs .btn-filter {
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
}

.category-tabs .btn-filter:not(.active) {
  color: var(--color-text-muted);
  background: transparent;
  border-color: transparent;
}

/* Inline-Icon im kombinierten Anstehend-Banner (#306). */
.upcoming-banner-icon {
  margin-right: 0.15rem;
}

/* Quick-Add auf der verdichteten Todo-Seite etwas enger anschließen. */
.todos-filters + .quick-add {
  margin-top: 0;
}

/* ── Todo-Explosion ──────────────────────────────────────────
   Beim Klick auf Done (todo-done-Controller) zerbirst die Zeile in Partikel;
   die Wucht richtet sich nach der Prioritaet. Raeumt der Klick den heutigen
   Tag leer, zuendet zusaetzlich ein seitenweites Tages-Feuerwerk. */
/* Zeile bebt kurz, loest sich in Rauch auf und verschwindet dann zuegig (Turbo
   morpht sie kurz danach weg). Bewusst kurz, damit die Liste nicht haengt. */
.todo.is-exploding {
  position: relative;
  z-index: 1;
  animation: todo-disintegrate 0.55s cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

/* Morph-festes Overlay am <body> (data-turbo-permanent): haelt Partikel und
   Feuerwerk am Leben, auch nachdem Turbo die erledigte Zeile schon entfernt
   hat. Bursts werden per left/top an ihre Position gesetzt. */
.todo-fx-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.todo-explosion,
.todo-day-fireworks-burst {
  position: absolute;
  width: 0;
  height: 0;
}

.todo-explosion-particle {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  opacity: 0;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: todo-explosion 1.15s cubic-bezier(0.17, 0.85, 0.32, 1) forwards;
}

/* Zeile faded ganz aus, bevor sie entfernt wird. */
@keyframes todo-disintegrate {
  0%   { transform: scale(1); opacity: 1; filter: blur(0); }
  14%  { transform: scale(1.05) translateX(-3px); }
  30%  { transform: scale(1.03) translateX(3px); }
  85%  { opacity: 0; }
  100% { transform: scale(0.72); opacity: 0; filter: blur(5px); }
}

/* Partikel schiessen schnell raus, werden langsamer (ease-out) und sinken
   durch etwas "Schwerkraft" ab, bevor sie ausfaden. */
@keyframes todo-explosion {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  15%  { opacity: 1; }
  80%  { opacity: 0.9; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 44px)) scale(0.35); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .todo.is-exploding { animation: none; }
  .todo-fx-overlay { display: none; }
}

/* Screen-Shake nur bei Hoch-Prio: der Inhalt jolted kurz, das Partikel-Overlay
   (Body-Geschwister) bleibt stabil. clip verhindert horizontalen Scroll durch
   die Verschiebung, ohne position:sticky zu brechen. */
html { overflow-x: clip; }

.container.todo-shake {
  animation: todo-screen-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes todo-screen-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 2px); }
  30% { transform: translate(4px, -3px); }
  45% { transform: translate(-4px, 2px); }
  60% { transform: translate(3px, -2px); }
  78% { transform: translate(-2px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  .container.todo-shake { animation: none; }
}

/* ── Verschieben-Button ──────────────────────────────────────
   Standard inert (kein eigener Kasten); nur in der Todo-Listenzeile bildet
   der Wrapper die untere Kante der benachbarten button_to-<form>s nach, damit
   der Button auf gleicher Höhe wie +1d/→Mo/Done sitzt. */
.btn-reschedule-wrap {
  display: contents;
}

.todos .todo .btn-reschedule-wrap {
  display: block;
  padding-bottom: 0.5rem;
}

/* ── Verschieben-Overlay (reschedule_controller) ─────────────── */
.reschedule-dialog {
  /* Der globale Reset setzt margin: 0 auf alles und hebelt damit die native
     Zentrierung modaler <dialog> aus – hier wieder herstellen. */
  margin: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  width: 100%;
  /* Breiter und mit kompakteren Chips: So passen die Tages-Chips in zwei statt
     drei Zeilen und die Wochentage in eine – der Dialog passt ohne Scrollen aufs
     Handy. Auf schmalen Displays begrenzt width: 100% die Breite ohnehin. */
  max-width: 560px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 1.2rem;
}

/* Der ganze Dialog-Inhalt steckt in einem <form>, und global gilt
   form { max-width: 480px } – im 560px breiten Dialog blieb rechts sonst ein
   ungenutzter weißer Streifen stehen. */
.reschedule-dialog form {
  max-width: none;
}

.reschedule-dialog::backdrop {
  background: rgba(20, 18, 16, 0.45);
}

.reschedule-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.reschedule-title {
  font-weight: 600;
}

.reschedule-current {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.reschedule-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
}

.reschedule-group {
  margin-bottom: 0.8rem;
}

.reschedule-lbl {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.reschedule-scope-hint {
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.reschedule-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  background: var(--color-bg);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.reschedule-tabs button {
  flex: 1;
  padding: 0.45rem;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: 6px;
  cursor: pointer;
}

.reschedule-tabs button.sel {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}

.reschedule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.reschedule-chip {
  /* Die Chips wachsen in die Zeile hinein: Sonst blieb rechts im breiteren
     Dialog Luft stehen, während ein Chip mit langem Label („Nächste Woche (Mo)")
     schon in die nächste Zeile umbrach. */
  flex: 1 1 auto;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  min-height: 30px;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.reschedule-chip:hover:not(:disabled) {
  border-color: var(--color-primary);
}

.reschedule-chip.sel {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.reschedule-chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reschedule-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.reschedule-stepper button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.reschedule-stepper button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.reschedule-stepper .val {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Uhrzeit-Stepper im Todo-Formular: dieselbe Optik wie das Verschieben-Overlay,
   die Mitte ist aber ein editierbares <input type="time"> statt reiner Text. */
.time-stepper .val {
  height: 44px;
  padding: 0 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  box-sizing: border-box;
}

.reschedule-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-top: 0.55rem;
}

.reschedule-weekdays .reschedule-chip {
  padding: 0.4rem 0;
  text-align: center;
}

.reschedule-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.reschedule-cal-head button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
}

.reschedule-cal-head .m {
  font-weight: 600;
}

.reschedule-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.reschedule-cal-grid .dow {
  font-size: 0.62rem;
  text-align: center;
  color: var(--color-text-muted);
  font-weight: 600;
  padding-bottom: 0.2rem;
}

.reschedule-cal-grid .day {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  color: var(--color-text);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  min-height: 34px;
}

.reschedule-cal-grid .day:hover:not(:disabled) {
  background: var(--color-primary-light);
}

.reschedule-cal-grid .day.today {
  outline: 1px solid var(--color-primary);
}

.reschedule-cal-grid .day.sel {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.reschedule-cal-grid .day.out {
  color: var(--color-text-muted);
  opacity: 0.4;
}

.reschedule-cal-grid .day:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.reschedule-preview {
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  text-align: center;
  margin: 1rem 0;
  color: var(--color-primary-hover);
  font-variant-numeric: tabular-nums;
}

.reschedule-actions {
  display: flex;
  gap: 0.6rem;
}

.reschedule-btn {
  flex: 1;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
}

.reschedule-btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.reschedule-btn.primary:hover {
  background: var(--color-primary-hover);
}

/* Mobil: als Bottom-Sheet vom unteren Rand. */
@media (max-width: 560px) {
  .reschedule-dialog {
    max-width: none;
    margin: auto auto 0;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
  }
}

/* ── Zustands-Tabs ─────────────────────────────────────────────────────────
   Übersichten, die mehrere Zustände desselben Dings zeigen (Mementos, Prognosen),
   zeigen einen davon auf einmal und schalten hier um. */

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 0.85rem;
  text-decoration: none;
}

.page-tab.sel {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
  font-weight: 600;
}

/* ── Mementos-Übersicht ────────────────────────────────────────────────────
   Die Sammlung ist gemischt: Bücher, Fotos, Links, lose Gedanken. Ohne Bild,
   Quelle und Notiz sahen die alle gleich aus – die Zeile zeigt deshalb, was
   ein Memento ausmacht. */

.memento-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.memento-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

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

.memento-row.resolved {
  opacity: 0.8;
}

.memento-row-thumb {
  flex: 0 0 auto;
  line-height: 0;
}

.memento-row-thumb img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius);
}

/* min-width: 0 – sonst sprengt eine lange URL die Zeile statt umzubrechen. */
.memento-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.memento-row-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.memento-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.memento-row-meta > * + *::before {
  content: "· ";
}

.memento-row-note {
  margin-top: 0.2rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.memento-row .actions {
  flex: 0 0 auto;
}

/* ── Betrachtung: Fotos & Dateianhänge ───────────────────── */
.betrachtung-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.betrachtung-photo-thumb {
  display: block;
  line-height: 0;
}

.betrachtung-photo-thumb img {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.betrachtung-attachment-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.betrachtung-attachment-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.betrachtung-attachment-remove {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Verknüpfungen auf der Übersicht: klein und abgesetzt, wie Unter-Todos */
.betrachtung-links {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.35rem 0 0;
  padding-left: 0.6rem;
  border-left: 2px solid var(--color-border);
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.betrachtung-links-label {
  color: var(--color-text-muted);
  font-weight: 600;
  margin-right: 0.3rem;
}

/* ── Haupt-Todo auswählen ────────────────────────────────────
   Suchfeld über einer scrollenden Radio-Liste: bei rund 60 offenen Wurzeln
   braucht die Auswahl eine Höhenbegrenzung, sonst schiebt sie im Formular
   alles Weitere aus dem Bild. Optik wie die übrigen Auswahlkacheln
   (.people-toggle-btn), nur einzeilig. */
.parent-picker-search {
  width: 100%;
  margin-bottom: 0.4rem;
}

.parent-picker-options {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 15rem;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.3rem;
}

.parent-picker-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.86rem;
}

.parent-picker-option:hover {
  background: var(--color-bg);
}

.parent-picker-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

/* Der Titel nimmt den Rest der Zeile; Kategorie und Termin bleiben rechts
   stehen und werden nicht umgebrochen. */
.parent-picker-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.parent-picker-due {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.parent-picker-empty {
  margin: 0.4rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Im Overlay darf die Liste mehr Höhe nehmen – dort steht sonst nichts. */
.parent-picker-dialog .parent-picker-options {
  max-height: min(22rem, 55dvh);
}

/* Der „↳“-Knopf in der Listenzeile: gleiche Höhe wie die Nachbarn, aber
   schmal, weil das Zeichen allein steht. */
.btn-demote {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

/* ── Rückgängig-Streifen ─────────────────────────────────────
   Steht unten über der Seite, damit er den Blick nicht von der Liste nimmt,
   und blendet sich nach acht Sekunden aus (undo_toast_controller). Über dem
   Dialog-Backdrop liegt er bewusst nicht – ein offenes Overlay hat Vorrang. */
.undo-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  transition: opacity 0.3s, transform 0.3s;
}

.undo-toast.leaving {
  opacity: 0;
  transform: translate(-50%, 0.5rem);
  pointer-events: none;
}

.undo-toast-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.undo-toast-action {
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.undo-toast-action:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

@media (max-width: 640px) {
  .undo-toast {
    left: 1rem;
    right: 1rem;
    transform: none;
    justify-content: space-between;
  }

  .undo-toast.leaving {
    transform: translateY(0.5rem);
  }
}
