/* styles.css — FAMager
 *
 * Design notes:
 *  - Target device: 15" Android tablet (~1280x800 landscape), but works
 *    down to phones. Tap targets >= 48px, primary buttons >= 60px.
 *  - Warm palette (soft indigos, creams, corals) to avoid feeling clinical.
 *  - Sidebar navigation on wide screens collapses to bottom bar on narrow screens.
 */

:root {
  /* Tells the browser to render native widgets (date pickers, scrollbars,
     form controls) in their light-mode style. The dark theme below
     overrides this so the native UI follows our app theme. */
  color-scheme: light;

  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #1f2430;
  --ink-soft: #5a6170;
  --ink-faint: #9ba3b4;
  --line: #e6e1d6;
  --line-strong: #d0cabc;

  --accent: #6366f1;
  --accent-soft: #eef2ff;
  --warm: #f59e0b;
  --cool: #10b981;
  --danger: #ef4444;
  --danger-soft: #fee2e2;

  --banner-bg: #fff7e6;
  --banner-border: #f0c36d;
  --banner-ink: #7c4a03;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 6px rgba(31, 36, 48, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 36, 48, 0.12);

  --tap: 60px;
}

/* Dark theme — applied when <html data-theme="dark">. The theme picker in
 * the sidebar sets this; "System" resolves to dark/light based on the
 * prefers-color-scheme media query and updates live. */
html[data-theme="dark"] {
  /* Dark mode for native widgets (date pickers, scrollbars, etc.) */
  color-scheme: dark;

  --bg: #14171d;
  --surface: #1b1f27;
  --surface-2: #242932;
  --ink: #f1edde;
  --ink-soft: #a8b0bc;
  --ink-faint: #6c7382;
  --line: #2d333f;
  --line-strong: #3b4252;

  --accent: #818cf8;
  --accent-soft: #24284a;
  --warm: #fbbf24;
  --cool: #34d399;
  --danger: #f87171;
  --danger-soft: #3a1f22;

  --banner-bg: #2a2418;
  --banner-border: #c99a4a;
  --banner-ink: #f5d89a;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
/* Make sure placeholders are visible in both themes — without an explicit
   color the browser default (often very light gray) gets lost on the
   off-white light surface and on the dark slate dark surface. */
input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: 1; }

/* ============== App shell ============== */
.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  padding: 6px 6px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-icon { font-size: 1.6rem; }

.nav { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap);
  transition: background 120ms, color 120ms, border-color 120ms;
}
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.nav-icon { font-size: 1.5rem; }

/* "Signed in as" pill — sidebar on desktop, sticky-top on mobile.
   The same .user-pill class is reused; the .compact modifier shrinks it
   for the mobile bar, and .mobile-top-bar is hidden on desktop. */
.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 120ms, border-color 120ms;
}
.user-pill:hover { background: var(--accent-soft); border-color: var(--accent); }
.user-pill-avatar {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
}
.user-pill-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.user-pill-name {
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-pill-role { font-size: 0.78rem; color: var(--ink-soft); }

.mobile-top-bar { display: none; }
/* Drawer handle + backdrop — mobile-only, see the @media block below. */
.mobile-drawer-handle, .mobile-drawer-backdrop { display: none; }

.clock {
  text-align: center;
  padding: 14px 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
}
.clock-time { font-size: 1.9rem; font-weight: 700; color: var(--ink); letter-spacing: -1px; }
.clock-date { font-size: 0.95rem; margin-top: 2px; }

.content {
  padding: 28px 32px 48px;
  max-width: 100%;
  overflow-x: hidden;
}

.page { display: flex; flex-direction: column; gap: 20px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 2rem;
  margin: 0;
  letter-spacing: -0.5px;
}
.subtitle {
  color: var(--ink-soft);
  margin: 0;
}
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ============== Generic card ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.count {
  color: var(--ink-faint);
  font-size: 0.95rem;
  font-weight: 500;
}
.empty {
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0;
}
.empty.big { font-size: 1.2rem; padding: 40px; text-align: center; }

/* ============== Buttons ============== */
.primary-btn, .ghost-btn, .danger-btn, .icon-btn, .link-btn {
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: transform 80ms, background 120ms, border-color 120ms;
}
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 22px;
  min-height: var(--tap);
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { background: #4f52d9; }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-btn {
  background: var(--surface-2);
  border: 2px solid transparent;
  color: var(--ink);
  padding: 12px 18px;
  min-height: 48px;
  font-size: 1rem;
}
.ghost-btn:hover { background: #e8e3d6; }
.ghost-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.danger-btn {
  background: var(--danger-soft);
  border: none;
  color: var(--danger);
  padding: 12px 18px;
  min-height: 48px;
  font-size: 1rem;
}
.danger-btn:hover { background: #fecaca; }

.icon-btn {
  background: var(--surface-2);
  border: none;
  width: 52px;
  height: 52px;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #e8e3d6; }

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 6px;
  font-size: 0.95rem;
}

/* ============== Toggle group ============== */
.toggle-group {
  display: inline-flex;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}
.toggle-group button {
  border: none;
  background: transparent;
  padding: 10px 16px;
  min-height: 48px;
  border-radius: calc(var(--radius-md) - 4px);
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.98rem;
}
.toggle-group button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.toggle-group button.prio-low.active { color: #065f46; }
.toggle-group button.prio-medium.active { color: #92400e; }
.toggle-group button.prio-high.active { color: #991b1b; }

/* ============== Home ============== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.home-card { min-height: 240px; }
.event-list, .task-list, .mini-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event-row {
  display: flex;
  gap: 14px;
  align-items: center;
  border-left: 5px solid var(--accent);
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}
.event-time { font-weight: 700; min-width: 110px; }
.event-meat { flex: 1; }
.event-title { font-weight: 600; }
.event-sub { font-size: 0.9rem; color: var(--ink-soft); }

.mini-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--line);
}
.mini-list li:last-child { border-bottom: none; }
.mini-list .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warm);
}
.mini-list .qty { margin-left: auto; color: var(--ink-soft); }
.mini-list .more { color: var(--accent); font-weight: 600; }

.member-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.member-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid;
}
.member-avatar { font-size: 1.4rem; }
.member-name { font-weight: 700; }
.member-sub { font-size: 0.85rem; color: var(--ink-soft); }
.add-chip {
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  border: 2px dashed var(--line-strong);
  cursor: pointer;
  color: var(--ink-soft);
}

/* ============== Tasks ============== */
.task-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 120ms;
}
.task-row:hover { background: #ece8da; }
.task-row.overdue { border-color: color-mix(in srgb, var(--danger) 70%, transparent); background: #fff5f5; }
.task-row.done { opacity: 0.65; }
.task-body { flex: 1; }
.task-title { font-weight: 600; font-size: 1.05rem; }
.task-title.struck { text-decoration: line-through; color: var(--ink-faint); }
.task-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.chip {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chip.prio-low { background: #d1fae5; color: #065f46; }
.chip.prio-medium { background: #fef3c7; color: #92400e; }
.chip.prio-high { background: #fee2e2; color: #991b1b; }
.overdue-badge {
  background: var(--danger);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Assignee chip & filter strip — used on Tasks page and in the task modal. */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}
.assignee-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.assignee-chip {
  --chip-color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  transition: background 120ms, border-color 120ms;
}
.assignee-chip:hover {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 10%, var(--surface));
}
.assignee-chip.selected {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 18%, var(--surface));
  color: var(--ink);
}
.assignee-chip .assignee-avatar { font-size: 1.2rem; line-height: 1; }

/* Smaller non-interactive version used inline in the task-meta row. */
.assignee-badge {
  --chip-color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  /* Mix the chip-color with the current surface, not white, so the chip
     stays readable in dark mode (where mixing into #fff produced a pale
     pastel that washed out the cream text). */
  background: color-mix(in srgb, var(--chip-color) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--chip-color) 40%, transparent);
  font-size: 0.82rem;
  font-weight: 600;
}
.assignee-badge.unassigned {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink-soft);
}
.assignee-badge .assignee-avatar { font-size: 1rem; line-height: 1; }

.label-hint {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: 0.82rem;
  margin-left: 6px;
}
.assignee-hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  align-self: center;
}

.check-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms, border-color 120ms;
}
.check-btn.checked {
  background: var(--cool);
  border-color: var(--cool);
}
.check-btn.big { width: 48px; height: 48px; font-size: 1.6rem; }

/* ============== Shopping ============== */
.shopping-add {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 10px;
}

/* Live-filtered matches that appear under the form while the user is
   typing. Same look on mobile and desktop — no chip strip, no popup. */
.match-area { margin-top: 14px; }
.match-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.match-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  min-height: 44px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.match-chip:hover, .match-chip:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.match-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-faint);
}
.match-chip-x:hover, .match-chip-x:active { color: var(--danger); }
.match-hint { margin: 4px 2px 0; font-size: 0.95rem; }

/* Past-list viewer: bulk copy bar above the items, plus a tighter
   "+ Add" button at the trailing edge of each row. */
.past-list-bulk { display: flex; justify-content: flex-end; margin: 4px 0 12px; }
.ghost-btn.small {
  padding: 6px 12px;
  font-size: 0.9rem;
  min-height: 36px;
  border-radius: 999px;
}
.big-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--surface);
  font-size: 1.05rem;
  min-height: var(--tap);
}
.big-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea.big-input { min-height: 90px; resize: vertical; }
.qty-select {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--surface);
  min-height: var(--tap);
  font-size: 1.05rem;
}
.suggestion-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.suggest-chip {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  min-height: 44px;
  font-size: 0.95rem;
  overflow: hidden;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.suggest-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.suggest-chip.learned { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.suggest-chip-main {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.suggest-chip .suggest-chip-main { padding-right: 6px; }
.suggest-chip-x {
  border: none;
  background: transparent;
  padding: 0 12px 0 4px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.suggest-chip-x:hover { color: var(--danger); }

.shopping-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shopping-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  min-height: var(--tap);
  cursor: pointer;
}
.shopping-row.checked { opacity: 0.6; }
.shopping-body {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.shopping-name { font-weight: 600; font-size: 1.1rem; }
.shopping-name.struck { text-decoration: line-through; color: var(--ink-faint); }
.shopping-qty { color: var(--ink-soft); font-size: 0.95rem; margin-left: auto; }

/* Inline per-row remove. Sized like a finger tap on touch devices and
   tucked at the row's trailing edge so it doesn't compete with the
   tap-to-edit gesture on the row body. */
.row-del-btn {
  border: none;
  background: transparent;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  flex-shrink: 0;
}
.row-del-btn:hover, .row-del-btn:active { color: var(--danger); background: var(--surface); }

.muted { color: var(--ink-soft); font-weight: 400; }

.past-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.past-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}
.past-list-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.past-list-dates { font-weight: 600; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.past-list-meta { font-size: 0.9rem; display: flex; gap: 6px; flex-wrap: wrap; }
.past-list-chev { font-size: 1.6rem; color: var(--ink-faint); line-height: 1; }

/* ============== Members ============== */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}
.member-card {
  border: 3px solid;
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.member-avatar-big { font-size: 4rem; line-height: 1; margin-bottom: 6px; }
.member-name-big { font-size: 1.45rem; font-weight: 700; }
.member-role-big { color: var(--ink-soft); margin-bottom: 2px; font-weight: 600; }
.member-age-big { font-weight: 600; }
.member-dob { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 10px; }
.member-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ============== Calendar ============== */
.calendar-header {
  gap: 18px;
}
.cal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cal-title h1 {
  min-width: 240px;
}
.cal-actions { display: flex; gap: 10px; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dow {
  background: var(--surface-2);
  font-weight: 700;
  text-align: center;
  padding: 10px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.day-cell {
  background: var(--surface);
  min-height: 110px;
  padding: 8px 8px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 100ms;
}
.day-cell:hover { background: var(--accent-soft); }
.day-cell.other-month { background: #f8f5ee; color: var(--ink-faint); }
.day-cell.today { background: #fff7ed; }
.day-cell.today .day-num {
  background: var(--accent);
  color: #fff;
}
.day-num {
  font-weight: 700;
  font-size: 0.95rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
}
.day-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}
.day-chip {
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.82rem;
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.day-chip .chip-time { font-weight: 700; opacity: 0.7; }
.day-chip .chip-label { overflow: hidden; text-overflow: ellipsis; }
.day-chip.external { opacity: 0.78; font-style: italic; }
.day-chip.task-chip { border-left-style: dashed !important; }
.day-chip.task-chip.done { opacity: 0.55; text-decoration: line-through; }
.day-chip .chip-icon {
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.9;
}
.ext-badge {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 1px 6px;
  margin-left: auto;
  font-weight: 700;
  font-style: normal;
}

/* Inline "owner" chip shown next to external-event titles so the family
   knows whose calendar an appointment came from at a glance. The bg/border
   colors are bound to the owning member's color from the member list. */
.ev-owner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  margin-left: 6px;
  white-space: nowrap;
}
/* Compact variant for the week chip — wraps onto its own line under the
   title to avoid squeezing the time/title. */
.ev-owner-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.more-chip {
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding: 2px 6px;
}

/* Week view */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.week-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}
.week-col.today { border-color: var(--accent); background: #fff7ed; }
.week-header {
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.week-dow {
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 1px;
  font-weight: 600;
}
.week-num {
  font-size: 1.4rem;
  font-weight: 700;
}
.week-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}
.week-event {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
}
.week-event.external { font-style: italic; opacity: 0.82; }
.week-event.task-chip { border-left-style: dashed; }
.week-event.task-chip.done { opacity: 0.55; text-decoration: line-through; }
.event-time-sm { font-weight: 700; font-size: 0.78rem; opacity: 0.7; }
.event-time-sm.task-label { text-transform: uppercase; letter-spacing: 0.5px; }
.event-title-sm { font-weight: 600; }

/* Day view */
.day-view {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.day-header {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 18px;
  text-align: center;
}
.day-events-full {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.day-full-row {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  gap: 18px;
  cursor: pointer;
  min-height: var(--tap);
}
.day-full-row:hover { background: #ece8da; }
.day-full-row.task-row-cal { border-left-style: dashed !important; }
.day-full-row.task-row-cal.done { opacity: 0.6; }
.day-full-row.task-row-cal.done .day-full-title { text-decoration: line-through; }
.day-full-time { font-weight: 700; min-width: 130px; text-transform: capitalize; }
.day-full-title { font-size: 1.1rem; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.day-full-notes { color: var(--ink-soft); margin-top: 6px; white-space: pre-wrap; }

/* ============== Modals ============== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Above the wizard (z-index: 200) so modals opened from the wizard
     (e.g. the Add Member form) render on top of it. */
  z-index: 300;
  padding: 20px;
  overflow-y: auto;
  animation: fade 140ms ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 28px 22px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: pop 160ms ease-out;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal.wide { max-width: 720px; }
.modal.xl { max-width: 1040px; }
.modal.small { max-width: 420px; }
.modal h2 { margin: 0; font-size: 1.4rem; }
@keyframes pop {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chk { width: 24px; height: 24px; vertical-align: middle; margin-right: 6px; }

.color-strip, .emoji-strip, .dow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.color-dot {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid transparent;
  cursor: pointer;
  padding: 0;
}
.color-dot.selected { border-color: var(--ink); }
.emoji-dot {
  width: 52px; height: 52px;
  border-radius: 12px;
  font-size: 1.7rem;
  background: var(--surface-2);
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.emoji-dot.selected { border-color: var(--accent); background: var(--accent-soft); }
.dow-btn {
  min-width: 64px; min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
}
.dow-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Large done/restart toggle inside the Edit Task modal. */
.completion-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  min-height: var(--tap);
  text-align: left;
  transition: background 120ms, border-color 120ms;
}
.completion-toggle:hover {
  background: #ece8da;
  border-color: var(--ink-faint);
}
.completion-toggle.done {
  background: color-mix(in srgb, var(--cool) 15%, var(--surface));
  border: 2px solid var(--cool);
  color: #065f46;
}
.completion-toggle .toggle-icon { font-size: 1.8rem; line-height: 1; }
.completion-toggle .toggle-label { flex: 1; }

/* Visual hint that a block is clickable — subtle, so it doesn't clash with
   full-weight buttons but still hints at interactivity on a touchscreen. */
.tappable { cursor: pointer; }
.tappable:hover { filter: brightness(0.97); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  flex-wrap: wrap;
}
.modal-actions.between { justify-content: space-between; align-items: center; }
.right-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* Feeds modal */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.feed-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border-left: 5px solid var(--accent);
}
/* Inline owner + privacy pickers under the feed URL. Saves on @change so
   the user doesn't need a separate "Save" step. */
.feed-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.feed-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  min-width: 180px;
}
.feed-control select {
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: var(--surface);
  font: inherit;
  font-size: 0.95rem;
  min-height: 36px;
}

/* Traffic-light status dot for each ICS feed. */
.feed-status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px transparent;
  transition: box-shadow 200ms;
}
.feed-status-dot.status-ok {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.feed-status-dot.status-waiting {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
  animation: status-pulse 1.4s ease-in-out infinite;
}
.feed-status-dot.status-failed {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}
@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.feed-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-status-text {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 999px;
}
.feed-status-text.status-ok { background: #d1fae5; color: #065f46; }
.feed-status-text.status-waiting { background: #fef3c7; color: #92400e; }
.feed-status-text.status-failed { background: #fee2e2; color: #991b1b; }

/* Small indicator dot we can hang off a button — used on the Feeds button
   to surface a failing connection without opening the modal. */
.feeds-btn { position: relative; }
.btn-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
}
.btn-dot.status-failed { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
.feed-main { flex: 1; overflow: hidden; }
.feed-label { font-weight: 700; }
.feed-url {
  color: var(--ink-soft);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-status { font-size: 0.82rem; color: var(--ink-faint); margin-top: 3px; }
.feed-error { color: var(--danger); margin-left: 8px; }
.feed-actions { display: flex; gap: 8px; }

/* ============== Options modal ============== */
.nav-footer-btn {
  border-top: 1px solid var(--line);
  border-radius: 0;
  margin: 6px -16px 0;
  padding-left: 22px;
  padding-right: 22px;
}
.inline-save {
  display: flex;
  gap: 10px;
}
.inline-save .big-input { flex: 1; }
.hint { color: var(--ink-soft); font-size: 0.88rem; margin: 4px 2px 0; }

.share-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.share-sep { color: var(--ink-faint); }
.subscribe-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  min-height: 48px;
  padding: 12px 18px;
  font-size: 1rem;
  margin-right: 6px;
}

.danger-zone h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.options-modal { gap: 8px; }
.options-section {
  padding: 14px 0 10px;
  border-top: 1px solid var(--border, #e5e0d1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.options-section:first-of-type { border-top: none; padding-top: 4px; }
.options-section-title {
  margin: 0 0 2px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}
.options-section-title.danger-title { color: var(--danger, #991b1b); }
.options-section .option-row { margin-bottom: 0; }
.first-run-banner {
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  border-radius: var(--radius-md, 12px);
  padding: 12px 14px;
  color: var(--banner-ink);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Two-column layout inside the Settings modal. Collapses to single-column
 * when the modal isn't wide enough (narrow viewports). */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.options-grid .options-section {
  border-top: none;
  padding-top: 4px;
}
@media (max-width: 820px) {
  .options-grid { grid-template-columns: 1fr; }
}

/* Login modal — full-screen blocker, higher z so nothing peeks behind it. */
.login-backdrop { z-index: 50; }
.login-modal { text-align: center; }
.login-modal .subtitle { font-size: 1.1rem; margin-bottom: 12px; }
.login-modal .big-input { text-align: center; font-size: 1.1rem; }
.wide-btn { width: 100%; padding: 14px 18px; font-size: 1.05rem; }
.error-hint { color: var(--danger, #991b1b); font-weight: 600; }
.success-hint { color: #047857; font-weight: 600; }
[data-theme="dark"] .success-hint { color: #6ee7b7; }

.nav-signout { color: var(--ink-soft); }
.nav-signout:hover { background: var(--danger-soft); color: var(--danger); }

/* Status pill shown next to each password label ("set" / "not set"). */
.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--cool);
  color: #fff;
  vertical-align: middle;
}
.pill.pill-muted {
  background: var(--surface-2);
  color: var(--ink-soft);
}

/* Compact danger button used to remove passwords. Sits below the save row
 * so it's visually distinct from the primary action. */
.link-danger {
  align-self: flex-start;
  margin-top: 4px;
  padding: 8px 14px;
  font-size: 0.9rem;
  min-height: auto;
}

/* Theme picker — compact 3-button segmented control in the sidebar footer. */
.theme-picker {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  align-self: center;
}
.theme-opt {
  flex: 1;
  min-width: 44px;
  min-height: 36px;
  padding: 4px 10px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 120ms;
  color: var(--ink);
}
.theme-opt:hover { background: var(--surface); }
.theme-opt.active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.option-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  margin-bottom: 10px;
  transition: background 120ms, border-color 120ms;
}
.option-row:hover { background: #ece8da; }
.option-row.danger { background: #fff5f5; }
.option-row.danger:hover { background: #fee2e2; border-color: var(--danger); }
.option-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.option-text { flex: 1; }
.option-title { font-weight: 700; font-size: 1.05rem; }
.option-sub { color: var(--ink-soft); font-size: 0.9rem; margin-top: 2px; }
.option-chev { font-size: 1.4rem; color: var(--ink-faint); }

/* ============== First-run wizard ============== */
.wizard-backdrop {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #fdfaf4 0%, #ede8d9 100%);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
  animation: fade 200ms ease-out;
}
.wizard-card {
  background: var(--surface);
  border-radius: 28px;
  box-shadow: 0 18px 60px rgba(31, 36, 48, 0.14);
  padding: 38px 40px 32px;
  max-width: 640px;
  width: 100%;
  text-align: center;
  animation: pop 200ms ease-out;
}
.wizard-card h1 {
  font-size: 2.2rem;
  margin: 12px 0 8px;
  letter-spacing: -0.5px;
}
.wizard-card .subtitle { font-size: 1.05rem; }
.wizard-step {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.wizard-input { text-align: center; font-size: 1.25rem; padding: 18px; }
.wizard-actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}
.wizard-actions-row {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.big-btn {
  padding: 18px 32px;
  font-size: 1.1rem;
  min-height: 64px;
}
.wizard-members {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px 0 8px;
  text-align: left;
}
.wizard-member {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 2px solid;
}
.wizard-member-avatar { font-size: 2rem; }
.wizard-member-body { flex: 1; }
.wizard-member-name { font-weight: 700; font-size: 1.1rem; }
.wizard-member-sub { color: var(--ink-soft); font-size: 0.9rem; }

/* External (read-only) event detail modal. */
.external-event-modal { position: relative; padding-top: 22px; }
.ext-modal-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.ext-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.ext-badge-lg {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.readonly-pill {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.ext-modal-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.3px;
}

.ext-meta {
  margin: 14px 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ext-meta-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: baseline;
}
.ext-meta-row dt {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}
.ext-meta-row dd {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ext-source-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}
.ext-description {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--line-strong);
}
.ext-description h3 {
  margin: 0 0 6px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
}
.ext-description p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Toast — uses dedicated bg/fg vars so dark mode flips to a light
 * pill-on-dark instead of becoming cream-on-cream. The same vars apply
 * to any future "snackbar" style notifications. */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg, #1f2430);
  color: var(--toast-fg, #ffffff);
  padding: 14px 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  font-weight: 600;
  border: 1px solid var(--toast-border, transparent);
}
html[data-theme="dark"] {
  --toast-bg: #2d333f;
  --toast-fg: #f1edde;
  --toast-border: #3b4252;
}

/* ============== Responsive tweaks ============== */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  /* Slide-in drawer. Lives off-screen by default and slides in when
     .mobile-nav-open is on the app-shell (set by toggleMobileNav()). */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: min(280px, 82vw);
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    border-right: 1px solid var(--line);
    border-top: none;
    padding: 18px 14px 22px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-nav-open .sidebar { transform: translateX(0); }
  .nav {
    flex-direction: column;
    width: 100%;
    gap: 4px;
    overflow: visible;
  }
  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    font-size: 1rem;
    text-align: left;
    gap: 14px;
  }
  .nav-icon { font-size: 1.4rem; }
  /* User pill stays inside the drawer (no compact override needed). */
  .sidebar > .user-pill { width: 100%; }
  /* Brand + clock hidden on mobile to keep the drawer focused on nav. */
  .brand, .clock { display: none; }

  /* Edge handle — always visible on mobile, sits halfway down the left
     edge. Tap to toggle, swipe right to open, swipe left to close. */
  .mobile-drawer-handle {
    display: flex;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 88px;
    border: 1px solid var(--line);
    border-left: none;
    background: var(--surface);
    color: var(--ink-soft);
    border-radius: 0 14px 14px 0;
    box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 45;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: left 220ms ease-out, background 120ms;
  }
  .mobile-drawer-handle:hover { background: var(--accent-soft); color: var(--accent); }
  .mobile-drawer-handle svg { width: 18px; height: 24px; pointer-events: none; }
  /* When the drawer is open, slide the handle out with it so it sits at
     the right edge of the open drawer (a familiar "pull tab"). */
  .mobile-nav-open .mobile-drawer-handle { left: min(280px, 82vw); }

  /* Backdrop covers the rest of the page so taps outside the drawer
     close it. Display block here overrides the global "display:none"
     baseline so x-show can toggle it. */
  .mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    cursor: pointer;
  }

  .content { padding: 18px 18px 28px; }
  .home-grid, .task-columns { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .shopping-add { grid-template-columns: 1fr 1fr; }
  /* Larger tap targets on mobile and a bit more breathing room between
     items so it's easy to hit the right control without zooming. */
  .shopping-row { padding: 14px 10px 14px 14px; gap: 10px; }
  .shopping-list { gap: 10px; }
  .check-btn.big { width: 52px; height: 52px; }
  .row-del-btn { width: 48px; height: 48px; }
  /* Calendar — both views need usable cell widths on a phone, so we let
     them scroll horizontally rather than squeezing 7 days into 320px.
     The grid itself becomes the scroll container; its children sum to
     wider than the viewport, which kicks in the scrollbar. */
  .week-grid {
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .month-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    grid-template-columns: repeat(7, minmax(96px, 1fr));
  }
  .month-grid .day-cell { min-height: 88px; min-width: 96px; }
  .month-grid .dow { min-width: 96px; }
  /* Tame the scrollbar so the calendar still looks like a clean grid;
     touch users get momentum, mouse users get a thin bar on hover. */
  .month-grid::-webkit-scrollbar, .week-grid::-webkit-scrollbar { height: 6px; }
  .month-grid::-webkit-scrollbar-thumb, .week-grid::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 3px;
  }
}

@media (max-width: 560px) {
  .page-header h1 { font-size: 1.5rem; }
  .cal-title h1 { min-width: 0; font-size: 1.3rem; }
  .day-cell { min-height: 72px; }
  .day-chip { font-size: 0.72rem; }
  /* Even tighter cell minimums on tiny phones; user can scroll to see
     the rest of the week. */
  .month-grid { grid-template-columns: repeat(7, minmax(84px, 1fr)); }
  .month-grid .day-cell, .month-grid .dow { min-width: 84px; }
}

/* ============== Notes ============== */
/* List view */
/* Notes list — Explorer-style display modes. Each mode is a class on
   the same .note-list ul so toggling is a single class swap and the
   data binding stays identical. */
.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Large icons (default) — generous tiles, multi-line snippet. */
.note-list.notes-mode-large {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

/* Small icons — denser grid, tighter tiles, snippet hidden. */
.note-list.notes-mode-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.note-list.notes-mode-icons .note-row {
  min-height: 96px;
  padding: 12px;
  gap: 4px;
}
.note-list.notes-mode-icons .note-row-avatar { font-size: 1.5rem; }
.note-list.notes-mode-icons .note-row-title { font-size: 0.95rem; }
.note-list.notes-mode-icons .note-row-snippet { display: none; }
.note-list.notes-mode-icons .note-row-meta { font-size: 0.72rem; }

/* List — single-column row per note, condensed. */
.note-list.notes-mode-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.note-list.notes-mode-list .note-row {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.note-list.notes-mode-list .note-row-head { flex: 1; min-width: 0; }
.note-list.notes-mode-list .note-row-snippet {
  flex: 2;
  margin-top: 0;
  -webkit-line-clamp: 1;
  font-size: 0.85rem;
  display: none;
}
@media (min-width: 900px) {
  .note-list.notes-mode-list .note-row-snippet { display: -webkit-box; }
}
.note-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.note-row:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.note-row:active { transform: translateY(1px); }
.note-row-head { display: flex; align-items: center; gap: 10px; }
.note-row-avatar { font-size: 1.8rem; line-height: 1; }
.note-row-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.note-row-title {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-row-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 0.78rem; color: var(--ink-soft); }
.note-row-snippet {
  font-size: 0.92rem;
  line-height: 1.45;
  /* Multi-line clamp so long bodies show as a teaser without breaking
     the tile's grid cell. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
}

/* Note editor / viewer modal */
.note-modal { display: flex; flex-direction: column; gap: 12px; }
.note-modal-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note-title { flex: 1; font-size: 1.15rem; font-weight: 600; min-width: 200px; }
.note-body-rich {
  min-height: 320px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 16px 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 1.02rem;
  line-height: 1.55;
  outline: none;
  cursor: text;
}
.note-body-rich:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.note-body-rich[contenteditable="false"] { background: var(--surface-2); cursor: default; }
.note-body-rich:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  font-style: italic;
  pointer-events: none;
}
.note-body-rich h1, .note-body-rich h2, .note-body-rich h3 { margin: 14px 0 8px; }
.note-body-rich h1 { font-size: 1.5rem; }
.note-body-rich h2 { font-size: 1.25rem; }
.note-body-rich h3 { font-size: 1.1rem; }
.note-body-rich p { margin: 0 0 10px; }
.note-body-rich ul, .note-body-rich ol { margin: 0 0 10px 1.4em; }
.note-body-rich blockquote {
  margin: 0 0 10px;
  padding: 4px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.note-body-rich code, .note-body-rich pre {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.note-body-rich pre { padding: 10px 14px; overflow-x: auto; }
.note-body-rich a { color: var(--accent); text-decoration: underline; }

.note-attachments h3 { font-size: 0.95rem; margin: 0 0 6px; color: var(--ink-soft); }
.attach-chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.attach-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.attach-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 4px 6px 12px;
  cursor: pointer;
  color: inherit;
}
.attach-chip-main:hover { color: var(--accent); }
.attach-chip-target { font-weight: 600; }
.attach-chip-x {
  border: none;
  background: transparent;
  padding: 0 12px 0 6px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.attach-chip-x:hover { color: var(--danger); }

.note-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.85rem; }

/* Per-item "Notes" panel embedded in task / event / shopping / external modals */
.item-notes {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.item-notes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.item-notes-head h3 { font-size: 1rem; margin: 0; }
.item-notes-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item-notes-attach {
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  min-height: 34px;
}
.item-notes-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.item-note-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.item-note-row:hover { background: var(--accent-soft); }
.item-note-avatar { font-size: 1.3rem; }
.item-note-title { font-weight: 600; font-size: 0.95rem; }
.item-note-meta { font-size: 0.8rem; }
.item-note-empty { padding: 6px 12px; font-size: 0.9rem; }

/* ============== Notes editor — friendlier styling ============== */
/* Wider modal so side-by-side editor + preview has room to breathe. */
.note-modal { max-width: min(1100px, 95vw); }

.note-modal-head {
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.note-modal .note-title {
  font-size: 1.4rem;
  font-weight: 700;
  border-color: transparent;
  background: transparent;
  padding: 8px 4px;
  border-radius: 0;
}
.note-modal .note-title:focus {
  border-color: transparent;
  box-shadow: none;
  background: var(--surface-2);
}

.note-dirty-pill {
  align-self: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--warm);
  background: color-mix(in srgb, var(--warm) 15%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Rich-text toolbar — icon-button strip above the note editor.
 * Buttons are 36×36 (40×40 on touch) with stroke SVGs that pick up
 * currentColor so they theme cleanly. .active is set by the Alpine
 * noteRefreshActive() poll so a button looks "pressed in" when the
 * caret is inside text the command would toggle. */
.note-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.note-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.note-toolbar-divider {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 4px 4px;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  padding: 0;
  transition: background 100ms, border-color 100ms, color 100ms;
}
.tb-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}
.tb-btn:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.tb-btn:active { transform: translateY(1px); }
.tb-btn.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}
.tb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (max-width: 900px) {
  /* Bigger touch targets on phones/tablets without bloating desktop. */
  .tb-btn { width: 40px; height: 40px; }
  .tb-btn svg { width: 20px; height: 20px; }
}


/* Subtle pulse on the Save button when there are unsaved edits — gives
   the user a passive nudge without being annoying. */
.primary-btn.primary-btn-pulse {
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
  animation: famager-pulse 1.6s ease-out infinite;
}
@keyframes famager-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* ============== Dark-mode overrides for hard-coded tints ==============
 * These selectors used cream / beige / pale-red literals tuned for the
 * light theme. In dark mode they were turning rows white-on-cream-text
 * (unreadable). Each rule below picks a dark-theme equivalent that keeps
 * the same semantic intent (hover lift, "today" highlight, danger tint). */
html[data-theme="dark"] .ghost-btn:hover { background: var(--line-strong); }
html[data-theme="dark"] .icon-btn:hover { background: var(--line-strong); }
html[data-theme="dark"] .danger-btn:hover { background: color-mix(in srgb, var(--danger) 30%, var(--surface-2)); }
html[data-theme="dark"] .primary-btn:hover { background: color-mix(in srgb, var(--accent) 80%, #000); }

html[data-theme="dark"] .task-row:hover,
html[data-theme="dark"] .day-full-row:hover,
html[data-theme="dark"] .completion-toggle:hover,
html[data-theme="dark"] .option-row:hover {
  background: var(--line-strong);
}
html[data-theme="dark"] .task-row.overdue {
  background: color-mix(in srgb, var(--danger) 18%, var(--surface-2));
}
html[data-theme="dark"] .option-row.danger {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface-2));
}
html[data-theme="dark"] .option-row.danger:hover {
  background: color-mix(in srgb, var(--danger) 22%, var(--surface-2));
}

html[data-theme="dark"] .day-cell.other-month {
  background: color-mix(in srgb, var(--surface-2) 50%, var(--bg));
  color: var(--ink-faint);
}
html[data-theme="dark"] .day-cell.today {
  background: color-mix(in srgb, var(--warm) 18%, var(--surface));
}
/* Week view: the "today" column was using the same warm cream as the
   month cell, which read as glaring white in dark mode. Tone it down
   to a subtle warm tint that still calls out the column. */
html[data-theme="dark"] .week-col.today {
  background: color-mix(in srgb, var(--warm) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--warm) 40%, var(--line-strong));
}

/* Status pills (feed list) keep their semantic pastel + dark-text in
   light mode but need inverse colors in dark mode so the text reads. */
html[data-theme="dark"] .feed-status-text.status-ok {
  background: color-mix(in srgb, var(--cool) 25%, var(--surface-2));
  color: var(--cool);
}
html[data-theme="dark"] .feed-status-text.status-waiting {
  background: color-mix(in srgb, var(--warm) 25%, var(--surface-2));
  color: var(--warm);
}
html[data-theme="dark"] .feed-status-text.status-failed {
  background: color-mix(in srgb, var(--danger) 25%, var(--surface-2));
  color: var(--danger);
}

/* Priority chips on tasks. Same reasoning — light pastels are unreadable
   on a dark surface; flip to a tinted-on-dark scheme. */
html[data-theme="dark"] .chip.prio-low,
html[data-theme="dark"] .toggle-group button.prio-low.active {
  background: color-mix(in srgb, var(--cool) 22%, var(--surface-2));
  color: var(--cool);
}
html[data-theme="dark"] .chip.prio-medium,
html[data-theme="dark"] .toggle-group button.prio-medium.active {
  background: color-mix(in srgb, var(--warm) 22%, var(--surface-2));
  color: var(--warm);
}
html[data-theme="dark"] .chip.prio-high,
html[data-theme="dark"] .toggle-group button.prio-high.active {
  background: color-mix(in srgb, var(--danger) 22%, var(--surface-2));
  color: var(--danger);
}
html[data-theme="dark"] .completion-toggle.done {
  background: color-mix(in srgb, var(--cool) 18%, var(--surface-2));
  color: var(--cool);
}

/* ============== Shopping by aisle ============== */
.aisle-group { margin-top: 12px; }
.aisle-group:first-child { margin-top: 0; }
.aisle-title {
  margin: 4px 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}

/* Note due-date row in the editor */
.note-due {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.note-due label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.note-due label > span {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}
.note-due .big-input { flex: 1; min-width: 200px; }

/* ============== Dashboard: Notes summary pane ============== */
.home-notes { margin-top: 0; }
.card-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.home-notes-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.home-note-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  min-height: 120px;
  transition: background 120ms, border-color 120ms;
}
.home-note-tile:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.home-note-head { display: flex; align-items: center; gap: 10px; }
.home-note-avatar { font-size: 1.4rem; line-height: 1; }
.home-note-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.home-note-title {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-note-meta { font-size: 0.78rem; color: var(--ink-soft); display: flex; gap: 6px; flex-wrap: wrap; }
.home-note-snippet {
  font-size: 0.9rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-note-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

/* ============== Notes view layout ============== */
/* Notes view spans the full content area like every other top-level
   page. The grid below tiles the available width with auto-fill. */
.notes-page { width: 100%; }

.notes-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.notes-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}
.notes-search input {
  flex: 1;
  width: 100%;
  padding: 10px 38px 10px 38px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1rem;
  min-height: 44px;
}
.notes-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.notes-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--ink-faint);
  pointer-events: none;
}
.notes-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.notes-search-clear:hover { color: var(--danger); background: var(--surface); }

.notes-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.notes-sort select {
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: inherit;
  font-size: 0.95rem;
  min-height: 44px;
}

/* ============== Notes Display: toggle + details table ============== */
.notes-display {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.display-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
}
.display-btn svg { width: 18px; height: 18px; pointer-events: none; }
.display-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.display-btn.active {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
}

.note-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.note-table thead th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
}
.note-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.note-table tbody tr:hover { background: var(--accent-soft); }
.note-table td { padding: 10px; vertical-align: middle; }
.note-table .nt-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.note-table .nt-avatar { font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.note-table .nt-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-table .nt-attach { text-align: center; color: var(--ink-soft); }
@media (max-width: 700px) {
  /* Drop the less-essential columns on tiny screens so the table doesn't
     overflow horizontally. */
  .note-table .nt-owner, .note-table .nt-attach { display: none; }
}
