/* ── 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;
  --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 img {
  height: 32px;
  display: block;
}

.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;
  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-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;
}

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

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

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);
}

.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;
}

.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;
}

.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);
}

.section-card .habit-sparkline {
  width: 5rem;
  height: 1.4rem;
}

.section-card .streak-day {
  width: 0.65rem;
}

.section-card .streak-dot {
  width: 0.65rem;
  height: 0.65rem;
}

.section-card .streak-label {
  display: none;
}

/* ── 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);
}

.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;
}

.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-item.completed-today {
  opacity: 0.65;
}

.habit-item.completed-today:hover {
  opacity: 1;
}

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

.btn-done.is-done,
.btn-done.is-done[type="submit"] {
  background: color-mix(in srgb, var(--color-success) 18%, var(--color-surface));
  color: var(--color-success);
  border-color: color-mix(in srgb, var(--color-success) 35%, transparent);
}

.btn-done.is-done:hover,
.btn-done.is-done[type="submit"]:hover {
  background: color-mix(in srgb, var(--color-success) 30%, var(--color-surface));
}

.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);
}

.habit-trend {
  display: inline-block;
  font-weight: 600;
  margin-left: 0.4rem;
}

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

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

.habit-trend.down {
  color: #c97a00;
}

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

.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-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

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

/* ── Streak Row ──────────────────────────────────────────── */
.streak-row {
  display: flex;
  gap: 0;
  align-items: center;
}

.streak-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 0.75rem;
  overflow: visible;
}

.streak-label {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}

.streak-dot {
  width: 0.75rem;
  height: 0.75rem;
  background: color-mix(in srgb, var(--color-error) 35%, var(--color-surface));
  transition: background 0.15s;
}

.streak-day.filled .streak-dot {
  background: var(--color-success);
}

.streak-day.today .streak-dot {
  outline: 2px solid var(--color-error);
  outline-offset: -1px;
}

.streak-day.today.filled .streak-dot {
  outline: 2px solid var(--color-success);
  outline-offset: -1px;
}

/* ── Habit Mini Sparkline ────────────────────────────────── */
.habit-sparkline {
  position: relative;
  width: 8rem;
  height: 2rem;
  flex: 0 0 auto;
}

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


.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;
}

.btn-done:hover,
.btn-done[type="submit"]:hover {
  background: var(--color-text);
  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;
  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;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

/* ── 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-xs { width: 32px; height: 32px; }
.avatar-sm { width: 40px; height: 40px; }
.avatar-lg { width: 100px; height: 100px; }

.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;
}

.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;
}

.detail-card ul li {
  padding: 0.25rem 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;
}

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

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

/* ── 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);
}

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 lange Formulare; der fixierte Verlauf liegt
   deckungsgleich auf dem body-Hintergrund und ist dadurch unsichtbar */
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-bottom: 0;
  padding: 0.75rem 0;
  background: var(--bg-gradient) fixed;
}

/* 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 */
.actions form:has(.btn-destroy) {
  margin-left: auto;
}

.actions .btn-destroy,
.actions .btn-destroy[type="submit"] {
  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;
}

.flash.notice {
  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;
}

.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-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;
}

.journal-timeline {
  display: grid;
  grid-template-columns: auto repeat(14, minmax(1.6rem, 1fr));
  gap: 0.15rem 0.1rem;
  padding: 0.6rem 0.6rem 0.6rem 0.4rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.journal-timeline-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.2rem;
  font-size: 1rem;
  line-height: 1.2;
  min-height: 1.6rem;
}

.journal-timeline-cell.label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  justify-content: flex-end;
  padding-right: 0.6rem;
  white-space: nowrap;
}

.journal-timeline-cell.date {
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.journal-timeline-cell.date .wday {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.journal-timeline-cell.date.today {
  color: var(--color-primary);
  font-weight: 600;
}

.journal-timeline-cell.date.has-entry a {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
}

.journal-timeline-cell.scale-cell {
  background: color-mix(
    in srgb,
    color-mix(in srgb, var(--color-error), var(--color-success) calc(var(--scale-weight, 0.5) * 100%)) calc(var(--scale-opacity, 0) * 55%),
    transparent
  );
  border-radius: 4px;
  color: var(--color-text-muted);
}

.journal-timeline-cell.weather-cell {
  flex-direction: column;
  gap: 1px;
  line-height: 1;
  color: var(--color-text-muted);
}

.journal-timeline-cell.weather-cell .weather-temps {
  font-size: 0.55rem;
}

.journal-timeline-cell.bp-cell {
  flex-direction: column;
  gap: 1px;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--color-text-muted);
  background: color-mix(
    in srgb,
    color-mix(in srgb, var(--color-success), var(--color-error) calc(var(--bp-weight, 0.5) * 100%)) calc(var(--bp-opacity, 0) * 32%),
    transparent
  );
  border-radius: 4px;
}

.journal-timeline-cell.bp-cell .bp-dia {
  opacity: 0.7;
}

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

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

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

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

.journal-memory h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: 0 0 0.4rem;
  font-weight: 600;
}

.journal-memory p {
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.journal-memory strong {
  color: var(--color-text-muted);
  font-weight: 600;
  margin-right: 0.25rem;
}

.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;
}

.journal-photo {
  max-width: 100%;
  max-height: 600px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  display: block;
}

.journal-photo-preview {
  margin-top: 0.5rem;
  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 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.journal-timeline-cell.photo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.journal-photo-indicator {
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
}

.journal-entry-photo-col {
  flex: 0 0 auto;
}

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

.journal-memory-photo {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-bottom: 0.5rem;
  display: block;
}

.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;
}

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

.bible-verse-text {
  margin: 0 0 0.3rem;
  font-style: italic;
  line-height: 1.5;
}

.bible-verse-ref {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.bible-verse-button {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

.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.5rem;
  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);
}

.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;
}

/* ── 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;
}

.tab-panel.active {
  display: block;
}

/* ── 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: 768px) {
  .streak-row .streak-day:nth-child(-n+4) {
    display: none;
  }
}

@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;
  }

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

  .streak-row {
    order: 99;
    width: 100%;
  }

  .streak-row .streak-day:nth-child(-n+7) {
    display: none;
  }

  .habit-sparkline {
    order: 100;
    width: 100%;
    height: 2.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-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);
}

/* ── 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-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;
}

@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;
}
