/* 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: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(31, 36, 48, 0.05);
  --shadow-md: 0 6px 20px rgba(31, 36, 48, 0.09);

  --tap: 44px;
}

/* 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 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
}

* { 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: 15px;
  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: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top menu bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.brand:hover { background: var(--surface-2); }
.brand-icon { font-size: 1.5rem; }
.brand-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topnav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap);
  white-space: nowrap;
  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.3rem; }

/* Dropdown menus hanging off the top bar. */
.menu { position: relative; }
.menu-caret { font-size: 0.7rem; opacity: 0.7; }
.menu-trigger.open { background: var(--surface-2); color: var(--ink); }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(31, 36, 48, 0.16);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 70;
}
.menu-panel-right { left: auto; right: 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap);
  transition: background 120ms;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.active { background: var(--accent-soft); color: var(--accent); }
.menu-theme { padding: 4px 8px; }
.menu-theme .theme-picker { margin-top: 0; }

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.clock-top {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  border: none;
  padding: 0;
  text-align: right;
}
.clock-top .clock-time { font-size: 1.15rem; letter-spacing: 0; }
.clock-top .clock-date { font-size: 0.72rem; margin-top: 0; }

/* Hamburger — hidden on desktop, shown by the mobile media block. */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.hamburger svg { width: 22px; height: 22px; }

/* Full-width dropdown panel behind the hamburger. */
.mobile-menu {
  position: sticky;
  top: 61px;
  z-index: 55;
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 14px 28px rgba(31, 36, 48, 0.14);
}
.mobile-menu-group {
  padding: 12px 14px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-faint);
}

/* "Signed in as" pill. The bare form is the roomy one used in modals;
   .compact is the top-bar trigger variant. */
.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px 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: 1px 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); }
.user-pill.compact {
  width: auto;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  gap: 8px;
}
.user-pill.compact .user-pill-avatar { width: 32px; height: 32px; font-size: 1.1rem; }
.user-pill.compact .user-pill-name { max-width: 130px; }

.clock { text-align: center; 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: 1.5rem;
  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: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.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.05rem; padding: 32px; 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: 8px 16px;
  min-height: 38px;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-btn {
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--ink);
  padding: 8px 16px;
  min-height: 38px;
  font-size: 0.92rem;
}
.ghost-btn:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); }
.ghost-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.danger-btn {
  background: var(--danger-soft);
  border: none;
  color: var(--danger);
  padding: 8px 16px;
  min-height: 38px;
  font-size: 0.92rem;
}
.danger-btn:hover { background: color-mix(in srgb, var(--danger) 18%, var(--danger-soft)); }

.icon-btn {
  background: var(--surface-2);
  border: none;
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); }

.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: 7px 14px;
  min-height: 38px;
  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 ============== */
/* Two explicit columns of self-sized cards. The JS balancer
   (balanceHomePanels) tunes each column's expandable card so both
   columns end level just above the Notes panel. */
.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  /* Columns stretch to the taller one; the last pane in each column
     absorbs any residual as empty space, so the bottoms ALWAYS align
     exactly with the Notes panel below. */
  align-items: stretch;
}
.home-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.home-card { min-height: 0; }
.home-col > .home-card:last-child { flex: 1 1 auto; }
.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: 3px 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 { 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: 1px 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: 1px 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: 1px 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; }
/* Read-only state — a note opened by someone who can't edit it. */
.assignee-chip:disabled {
  opacity: 0.55;
  cursor: default;
}
.assignee-chip:disabled:hover {
  border-color: var(--line);
  background: var(--surface);
}

/* 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: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  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: 32px; height: 32px; font-size: 1.05rem; }

/* ============== Shopping ============== */
.shopping-add {
  display: grid;
  grid-template-columns: 1fr 90px 170px;
  gap: 10px;
}
.qty-num { min-width: 0; }
.qty-pair {
  display: grid;
  grid-template-columns: 110px 1fr;
  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: 1px 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: 4px 10px;
  font-size: 0.84rem;
  min-height: 30px;
  border-radius: 999px;
}
.big-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.92rem;
  min-height: 38px;
}
.big-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.big-input { min-height: 80px; resize: vertical; }
.qty-select {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  min-height: 38px;
  font-size: 0.92rem;
}
.suggestion-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.suggest-chip {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 1px 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); }
/* Quantity sits right beside the name (was pushed to the far edge). */
.shopping-qty { color: var(--ink-soft); font-size: 0.95rem; }

/* 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;
  /* Sits between the prev/next arrows — centred, not hugging the left one. */
  text-align: center;
}
.cal-actions { display: flex; gap: 10px; }
/* The Calendars toggle lives inside a .menu wrapper for its dropdown —
   without this it kept its natural height while its flex siblings
   (+ New event, Feeds) stretched to match each other. */
.cal-actions .menu { display: flex; }
.cal-actions .menu > .ghost-btn { height: 100%; }

.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; }
/* Visible feedback while the user drags a range of cells to stage a new
   all-day event. Sticks out without competing with .today. */
.day-cell.drag-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.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; }

/* ===== Time grid (day + week) ===== */
/* Layout: a left-hand hour axis next to one or seven event columns.
   Heights come from inline style so JS controls the px-per-hour, which
   makes pointer-y → minutes math trivial. */
.time-grid-view {
  padding: 16px;
  /* Stop the browser's native text-selection rectangle from painting
     across columns while the user drags. Pointer events still fire and
     drive our own drag preview. */
  user-select: none;
  -webkit-user-select: none;
}
.day-allday {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.day-allday .day-chip {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.time-grid {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  position: relative;
}
.time-axis {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}
.time-axis-row {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: right;
  padding-right: 8px;
  padding-top: 2px;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}
.time-col {
  position: relative;
  background: var(--surface);
  /* Tells the browser this surface is for dragging, not panning, which
     stops the iPad from intercepting our pointer events for scroll. */
  touch-action: none;
  user-select: none;
}
.time-row {
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}
.time-event {
  position: absolute;
  left: 4px;
  right: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
}
.time-event-time { font-weight: 700; font-size: 0.72rem; opacity: 0.75; }
.time-event-title { font-weight: 600; }
.time-drag-preview {
  position: absolute;
  left: 4px;
  right: 4px;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 8px;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 2;
}
/* Week-grid variant: replaces the side-by-side flex columns with the
   same time-axis-and-column layout, but with 7 event columns. */
.time-grid.week {
  grid-template-columns: 60px repeat(7, 1fr);
}
.time-grid.week .time-col { border-right: 1px solid var(--line); }
.time-grid.week .time-col:last-child { border-right: none; }
.week-day-headers {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 0;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  background: var(--surface-2);
}
.week-day-headers .spacer { border-right: 1px solid var(--line); }
.week-day-headers .col-header {
  text-align: center;
  padding: 8px 6px;
  border-right: 1px solid var(--line);
  font-size: 0.85rem;
}
.week-day-headers .col-header:last-child { border-right: none; }
.week-day-headers .col-header.today { background: #fff7ed; }
.week-day-headers .col-header .week-dow { font-weight: 600; color: var(--ink-soft); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.5px; }
.week-day-headers .col-header .week-num { font-weight: 700; font-size: 1.1rem; }
.time-grid-view.week .time-grid { border-top-left-radius: 0; border-top-right-radius: 0; }
.week-allday-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.week-allday-cell {
  padding: 4px;
  min-height: 32px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.week-allday-cell:last-child { border-right: none; }
.week-allday-cell .day-chip {
  font-size: 0.72rem;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ===== Event hover tooltip ===== */
/* Single floating element near </body>. position: fixed so its coords
   are viewport-relative — the JS handler reads getBoundingClientRect()
   on the hovered chip and writes top/left here. pointer-events: none
   so the tooltip can't intercept the parent's mouseleave. */
.event-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 400px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.18));
  padding: 14px 16px;
  font-size: 0.98rem;
  color: var(--ink);
  pointer-events: none;
  /* display is controlled by eventTooltipStyle() returning 'display:
     none' when no event is hovered — see comment on the binding. */
}
.event-tooltip.tooltip-above {
  /* Top/left already point at the hovered element's top-left; translate
     the tooltip fully above it. */
  transform: translateY(-100%);
}
.evt-tt-title {
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.25;
}
.evt-tt-time {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.evt-tt-notes {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  white-space: pre-wrap;
  font-size: 0.82rem;
  line-height: 1.4;
  max-height: 200px;
  overflow: auto;
}
.evt-tt-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  display: flex;
  gap: 4px;
  align-items: center;
}
.evt-tt-assignees {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.evt-tt-assignees .assignee-avatar-mini {
  font-size: 0.75rem;
  padding: 2px 6px 2px 4px;
}

/* Small member avatar pill — used inside event chips, time-grid
   event blocks, the day-detail row title, and the hover tooltip
   to show who an event is assigned to. Borders pick up the
   member's colour for at-a-glance scanning. */
.assignee-avatar-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  border: 1px solid;
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.time-event-avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 2px;
}

.evt-tt-source {
  font-style: italic;
  opacity: 0.85;
}

/* ============== 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: 24px 28px 18px;
  width: 100%;
  /* Roomier by default: editors were too thin, forcing scrolls. Small
     stays compact for confirmations. */
  max-width: 720px;
  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: 860px; }
.modal.xl { max-width: 1100px; }
.modal.small { max-width: 460px; }
.modal h2 { margin: 0; font-size: 1.15rem; }
@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: 16px; height: 16px; vertical-align: middle; margin-right: 6px; accent-color: var(--accent); }

.color-strip, .emoji-strip, .dow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.color-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.color-dot.selected { border-color: var(--ink); }
.emoji-dot {
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 1.3rem;
  background: var(--surface-2);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.emoji-dot.selected { border-color: var(--accent); background: var(--accent-soft); }
.dow-btn {
  min-width: 52px; min-height: 36px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px 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: 1px 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); }

/* ── ONE action row for every dialog ──────────────────────────────────
   Both class spellings (.actions / .modal-actions) get the identical
   layout: buttons on one flex row, destructive/utility actions on the
   left, the Cancel+Save cluster (.right-group) pushed right, everything
   pinned above the modal's bottom edge while long content scrolls.
   Offsets match the modal's 18px bottom padding exactly. */
.modal .actions,
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  position: sticky;
  bottom: -18px;
  background: var(--surface);
  padding-bottom: 18px;
  margin-bottom: -18px;
  z-index: 2;
}
/* A left-side button (Delete, Plan this recipe…) parks the save cluster
   on the right automatically. */
.modal .actions .right-group,
.modal-actions .right-group { margin-left: auto; }
.modal-actions.between { justify-content: space-between; align-items: center; }
.right-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 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: 1px 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: 38px;
  padding: 8px 14px;
  font-size: 0.92rem;
  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. */
/* Above the topbar (60), its menus (70), and the wizard (200) — the
   sign-in gate must cover the whole shell including navigation. */
.login-backdrop { z-index: 320; }
.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: 10px 16px; font-size: 0.98rem; }
.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: 1px 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: 1px solid;
}
.wizard-member-avatar { font-size: 2rem; }
/* Inline-editable member rows in the setup wizard's roster step. */
.wizard-member-fields { flex: 1; min-width: 0; }
.wizard-member-fields .field { margin-bottom: 8px; }
.wizard-member-fields label { text-align: left; }
.wizard-error { margin-top: 16px; }
.hint-inline { color: var(--ink-soft); font-weight: 400; font-size: 0.85rem; }
.wizard-review {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px 0 8px;
  text-align: left;
}
.wizard-review-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
}
.wizard-review-label { font-weight: 700; white-space: nowrap; }
.wizard-invites {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px 0 8px;
  text-align: left;
}
.wizard-invite {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
}
.wizard-invite-who { font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.wizard-invite-link {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.wizard-invite-link code {
  font-size: 0.8rem;
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}
/* The backdrop gradient above is light-only; give dark theme a matching
   dark ground so the wizard doesn't blast a light screen at night. */
html[data-theme="dark"] .wizard-backdrop {
  background: linear-gradient(160deg, #171a21 0%, #10131a 100%);
}
.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 ============== */
/* The bar carries more now (Comments, theme control) — collapse the
   inline nav into the hamburger earlier so nothing overlaps. */
@media (max-width: 1100px) {
  .topnav { display: none; }
  .topbar-right .menu-right { display: none; }
  .hamburger { display: flex; }
  .clock-top .clock-date { display: none; }
}

@media (max-width: 900px) {
  .topbar { padding: 6px 12px; gap: 8px; }
  .brand-name { max-width: 42vw; }

  .content { padding: 18px 18px 28px; }
  .home-grid { grid-template-columns: 1fr; }
  .task-columns { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  /* Mobile: item name on its own row, amount + unit side by side under it. */
  .shopping-add { grid-template-columns: 100px 1fr; }
  .shopping-add > input[type="text"] { grid-column: 1 / -1; }
  /* 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: 38px; height: 38px; }
  .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: 1px 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: 1px 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: 1px 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: 1px 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: 1px 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; }
}

/* ────────────────────────────────────────────────────────────────────────
   Menu Planner — Meals & Recipes tab
   ──────────────────────────────────────────────────────────────────────── */
.meals-page .header-actions { display: flex; gap: 0.5rem; align-items: center; }
.meals-page .week-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0 1rem;
  flex-wrap: wrap;
}
.meals-page .week-toolbar .week-range {
  margin-left: auto;
  font-size: 0.9rem;
}
.meals-page .empty-state {
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}
.meals-page .empty-state p { margin: 0 0 1rem; }

/* The grid itself: rows=meal events, cols=days. Cells are scroll-tolerant
   on narrow screens; on desktop they sit happily side-by-side. */
/* All menu-planner grid rules are scoped under .meals-plan to keep
   them clear of the calendar's `.week-grid` selector at line ~927,
   which uses the same class name for an unrelated layout. Without
   the scope, the menu planner's grid-template-columns would override
   the calendar's whenever the menu planner CSS loaded second. */
.meals-plan .week-grid-wrap {
  overflow-x: auto;
  /* Fill the rest of the browser window (viewport minus topbar, header,
     toolbar, overview bar) so the grid grows and shrinks with it. */
  min-height: calc(100vh - 340px);
  display: flex;
  flex-direction: column;
}

/* CSS Grid layout (NOT <table>): nested <template x-for> inside <tr>
   trips HTML5 foster-parenting and the day-header cells get moved out
   of <thead>, leaving the day labels stacked as a column on the left.
   CSS Grid has no such parsing quirk. .wg-row uses display:contents to
   lift its children (the row label + the 7 day cells) directly into
   the parent grid so each meal-event row occupies the next 8 grid
   tracks. --col-count is set inline from plannedWeek.days?.length so
   header and body share the same column count. */
.meals-plan .week-grid {
  display: grid;
  grid-template-columns: 110px repeat(var(--col-count, 7), minmax(0, 1fr));
  /* Header row stays natural height; every meal row stretches so the
     grid uses the full height the wrap gives it. */
  grid-template-rows: auto;
  grid-auto-rows: minmax(72px, 1fr);
  gap: 4px;
  min-width: 720px;
  flex: 1;
}
.meals-plan .week-grid .wg-row { display: contents; }
.meals-plan .week-grid .wg-corner,
.meals-plan .week-grid .wg-day,
.meals-plan .week-grid .wg-rowhead,
.meals-plan .week-grid .wg-cell {
  padding: 0.4rem;
  border-radius: 8px;
  background: var(--bg-soft);
}
.meals-plan .week-grid .wg-corner { background: transparent; }
.meals-plan .week-grid .wg-day { text-align: center; font-weight: 500; }
.meals-plan .week-grid .wg-day .wg-dow { font-size: 0.8rem; color: var(--ink-soft); }
.meals-plan .week-grid .wg-day .wg-date { font-size: 1.2rem; }
.meals-plan .week-grid .wg-rowhead {
  background: var(--bg);
  display: flex;
  align-items: center;
  font-weight: 600;
}
.meals-plan .week-grid .wg-cell {
  position: relative;
  min-height: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.meals-plan .week-grid .wg-add {
  display: block;
  width: 100%;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 6px;
  padding: 0.2rem;
  cursor: pointer;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}
.meals-plan .week-grid .wg-add:hover { background: var(--bg-soft); color: var(--ink); }

.planned-chip {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: var(--accent-soft, #6366f133);
  color: var(--ink);
  border-left: 3px solid var(--accent, #6366f1);
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.2;
}
.planned-chip .pc-title { display: block; font-weight: 500; }
.planned-chip:hover { filter: brightness(1.05); }

/* ─── Recipe library ─── */
.recipes-toolbar {
  padding: 0.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.recipes-toolbar .notes-search { flex: 1; min-width: 220px; }
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.recipe-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  background: var(--bg-soft);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.recipe-card:hover { background: var(--bg); border-color: var(--accent, #6366f1); }
.recipe-card .rc-title { font-weight: 600; margin-bottom: 0.25rem; }
.recipe-card .rc-meta { font-size: 0.85rem; }
.recipe-card .rc-planned { color: var(--accent, #6366f1); }

/* ─── Recipe editor modal ─── */
.recipe-modal { max-width: 720px; }
.ingredient-table {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}
.ing-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
}
.ing-row.ing-head { font-size: 0.85rem; padding: 0 0.2rem; }
.ing-row .ing-opt { text-align: center; }
.ing-row .small-btn { padding: 0.2rem 0.5rem; }
@media (max-width: 600px) {
  /* On narrow screens, stack name above the inline quantity controls. */
  .ing-row { grid-template-columns: 1fr 1fr auto auto; }
  .ing-row.ing-head { display: none; }
}

/* ────────────────────────────────────────────────────────────────────────
   Meal Planner split: week banner, consolidated overview, month grid,
   and the shopping page's meal-plan tie-in line.
   ──────────────────────────────────────────────────────────────────────── */
/* Loud "which week am I looking at" banner — shared by the planner and
   the shopping page so the two ranges are visually comparable. */
.week-banner { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.5rem 0 1rem; }
.week-focus {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
}
.week-focus-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}
.week-focus-shopping { background: color-mix(in srgb, #10b981 14%, var(--surface)); }
.week-focus-shopping .week-focus-tag { color: #0d9268; }

/* Consolidated week overview on the planner. */
.week-overview {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}
.wo-block { display: flex; align-items: baseline; gap: 8px; }
.wo-num { font-size: 1.4rem; font-weight: 800; }
.wo-label { color: var(--ink-soft); font-size: 0.88rem; }
.wo-jump { margin-left: auto; }

/* Month grid — 7 columns, padded to whole weeks. */
.meals-month-wrap { overflow-x: auto; }
.meals-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  min-width: 700px;
}
.mm-dow {
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink-soft);
  padding: 4px 0;
}
.mm-cell {
  position: relative;
  min-height: 96px;
  padding: 6px 6px 26px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mm-cell.other-month { opacity: 0.45; }
.mm-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mm-daynum { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.mm-cell.today .mm-daynum { color: var(--accent); }
.mm-chip {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  padding: 3px 6px;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1.25;
  overflow: hidden;
}
.mm-chip-event {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 700;
}
.mm-chip-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.mm-add {
  position: absolute;
  right: 6px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms;
}
.mm-cell:hover .mm-add, .mm-add:focus-visible { opacity: 1; }
@media (hover: none) { .mm-add { opacity: 1; } }

/* Shopping page: meal-plan tie-in line under the week banner. */
.plan-sync-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.92rem;
}
.plan-sync-line .link-btn { margin-left: auto; }

/* Repeating-task marker in task-meta rows. */
.repeat-chip { padding: 2px 8px; font-size: 0.8rem; }

/* Basket header: restore-all sits beside the count. */
.basket-actions { display: inline-flex; align-items: center; gap: 10px; }

/* Calendars visibility menu (calendar page header). */
.cal-toggle-row { min-width: 240px; gap: 10px; }
.cal-toggle-row.is-static { cursor: default; }
.cal-toggle-row.is-static:hover { background: transparent; }
.cal-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cal-toggle-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-toggle-state { font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; }

/* ── Tabbed Settings ── */
.options-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin: 4px 0 18px;
}
.options-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 40px;
  transition: background 120ms, color 120ms;
}
.options-tab:hover { color: var(--ink); }
.options-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(31,36,48,0.12); }
/* ❓ Help sits at the right end of the tab strip, styled like a tab so the
   strip reads as one control. */
.options-help-btn {
  margin-left: auto;
  align-self: center;
  border: none;
  background: transparent;
  color: var(--accent);
  min-height: 40px;
  white-space: nowrap;
}
.options-help-btn:hover { background: var(--surface); }

/* In-depth per-tab help (opened by the ❓ Help button). */
.settings-help-modal { max-width: 620px; }
.settings-help-list { display: flex; flex-direction: column; gap: 14px; }
.settings-help-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.settings-help-item .option-title { margin-bottom: 4px; }
.settings-help-body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}
.settings-help-body strong { color: var(--ink); }

/* While any dialog is open the page behind it must not scroll — the
   wheel should only ever move the dialog's own content. */
body.modal-open { overflow: hidden; }

/* Dialogs that can open on top of the Settings modal (profile, invite,
   password, 2FA…). All backdrops share z-index 300; these must paint
   above whichever one launched them. */
.modal-backdrop.modal-over { z-index: 310; }

/* Member cards embedded in the Settings → Family tab: tighter columns so
   up to three fit across the dialog. */
.member-grid.in-settings {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.family-manage-head {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.family-manage-head .primary-btn { flex-shrink: 0; }

/* Multi-recipient picker in the Send dialog. */
.send-recipient-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.send-recipient {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  cursor: pointer;
}
.send-recipient input { width: 18px; height: 18px; accent-color: var(--accent); }
.options-panel { display: flex; flex-direction: column; gap: 16px; }
.options-intro {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}
.option-block {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.option-block-text { flex: 1; min-width: 0; }
.option-block .option-title { font-weight: 700; }
.option-block .option-sub { color: var(--ink-soft); font-size: 0.88rem; margin-top: 2px; }
.option-inset { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-md); }
.account-line { display: flex; align-items: center; gap: 10px; font-size: 1rem; }
.account-avatar { font-size: 1.6rem; }

/* Audit trail table */
.audit-table-wrap { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.audit-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.audit-table th {
  position: sticky; top: 0;
  background: var(--surface-2);
  text-align: left;
  padding: 8px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
}
.audit-table td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.audit-when { white-space: nowrap; color: var(--ink-soft); }
.audit-who { white-space: nowrap; font-weight: 600; }
.audit-detail { display: block; font-size: 0.8rem; }
@media (max-width: 700px) {
  .options-tab { padding: 8px 10px; font-size: 0.85rem; }
  .audit-when { white-space: normal; }
}

/* ── Colour schemes ──
   Each scheme sets a light accent (--scheme-500) and a brighter dark-mode
   accent (--scheme-300); --accent/-soft derive from them so every scheme
   works in both light and dark. No data-scheme (or "indigo") = original. */
html[data-scheme]:not([data-scheme="indigo"]) {
  --accent: var(--scheme-500);
  --accent-soft: color-mix(in srgb, var(--scheme-500) 12%, var(--surface));
}
html[data-theme="dark"][data-scheme]:not([data-scheme="indigo"]) {
  --accent: var(--scheme-300);
  --accent-soft: color-mix(in srgb, var(--scheme-300) 24%, var(--surface));
}
html[data-scheme="blue"]    { --scheme-500: #2563eb; --scheme-300: #60a5fa; }
html[data-scheme="sky"]     { --scheme-500: #0284c7; --scheme-300: #38bdf8; }
html[data-scheme="cyan"]    { --scheme-500: #0891b2; --scheme-300: #22d3ee; }
html[data-scheme="teal"]    { --scheme-500: #0d9488; --scheme-300: #2dd4bf; }
html[data-scheme="emerald"] { --scheme-500: #059669; --scheme-300: #34d399; }
html[data-scheme="green"]   { --scheme-500: #16a34a; --scheme-300: #4ade80; }
html[data-scheme="lime"]    { --scheme-500: #65a30d; --scheme-300: #a3e635; }
html[data-scheme="amber"]   { --scheme-500: #d97706; --scheme-300: #fbbf24; }
html[data-scheme="orange"]  { --scheme-500: #ea580c; --scheme-300: #fb923c; }
html[data-scheme="red"]     { --scheme-500: #dc2626; --scheme-300: #f87171; }
html[data-scheme="rose"]    { --scheme-500: #e11d48; --scheme-300: #fb7185; }
html[data-scheme="pink"]    { --scheme-500: #db2777; --scheme-300: #f472b6; }
html[data-scheme="fuchsia"] { --scheme-500: #c026d3; --scheme-300: #e879f9; }
html[data-scheme="purple"]  { --scheme-500: #9333ea; --scheme-300: #c084fc; }
html[data-scheme="violet"]  { --scheme-500: #7c3aed; --scheme-300: #a78bfa; }
html[data-scheme="navy"]    { --scheme-500: #1e40af; --scheme-300: #93c5fd; }
html[data-scheme="forest"]  { --scheme-500: #15803d; --scheme-300: #86efac; }
html[data-scheme="slate"]   { --scheme-500: #475569; --scheme-300: #94a3b8; }
html[data-scheme="coffee"]  { --scheme-500: #8b5e34; --scheme-300: #c49a6c; }

/* ── Compact header theme control (always visible, tooltips on hover) ── */
.theme-ctl { display: flex; align-items: center; gap: 6px; }
.mode-mini {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 999px;
}
.mode-mini-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: background 120ms, opacity 120ms;
}
.mode-mini-btn:hover { opacity: 1; }
.mode-mini-btn.active { background: var(--surface); opacity: 1; box-shadow: 0 1px 3px rgba(31,36,48,0.18); }
.scheme-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.scheme-btn:hover { border-color: var(--accent); }
.scheme-btn-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }
.scheme-panel { padding: 10px; }
.scheme-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-faint);
  padding: 2px 4px 8px;
}
.scheme-grid {
  display: grid;
  grid-template-columns: repeat(5, 30px);
  gap: 8px;
}
.scheme-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 100ms;
}
.scheme-swatch:hover { transform: scale(1.15); }
.scheme-swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
@media (max-width: 900px) {
  /* Keep the control in the bar on phones, just tighter. */
  .theme-ctl { gap: 4px; }
  .mode-mini-btn { width: 24px; height: 24px; }
  .scheme-btn { width: 28px; height: 28px; }
}

/* ── Profile photos ── an avatar span with a photo shows it as a round
   cover image; the emoji text underneath goes transparent. Sizing is
   only forced on spans that were previously text-sized. */
.has-photo {
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-radius: 50%;
  overflow: hidden;
  color: transparent !important;
  flex-shrink: 0;
}
.assignee-avatar.has-photo,
.member-avatar.has-photo,
.nav-icon.has-photo {
  display: inline-flex;
  width: 1.35em;
  height: 1.35em;
  vertical-align: middle;
}
.assignee-avatar-mini.has-photo { padding: 0; width: 18px; }
.member-avatar-big.has-photo { width: 64px; height: 64px; display: inline-flex; }
.photo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}

/* ── Sample-data marking ── every row the demo dataset created wears
   this pill so test content is unmistakable next to real family data. */
.sample-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px dashed var(--warm, #f59e0b);
  color: var(--warm, #b45309);
  background: color-mix(in srgb, var(--warm, #f59e0b) 10%, var(--surface));
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  vertical-align: middle;
  line-height: 1.4;
}
.pc-sample { margin-right: 3px; font-size: 0.75rem; }
.evt-tt-sample { margin: 4px 0; }

/* ── Fast custom tooltips ── elements with data-tip get a styled bubble
   that appears after ~0.15s (native title tooltips are small and slow).
   Used on compact icon controls where the label isn't visible. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: var(--ink);
  color: var(--surface);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 400;
  transition: opacity 120ms ease-out 150ms, transform 120ms ease-out 150ms;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* First-run starter page: big choice cards. */
.starter-options { display: flex; flex-direction: column; gap: 12px; margin: 20px 0 8px; text-align: left; }
.starter-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms, background 120ms;
}
.starter-option:hover { border-color: var(--accent); }
.starter-option.chosen { border-color: var(--accent); background: var(--accent-soft); }
.starter-option .option-title { font-weight: 700; }
.starter-option .option-sub { color: var(--ink-soft); font-size: 0.88rem; margin-top: 2px; }
.option-row.is-static { cursor: default; }
.option-row.is-static:hover { background: var(--surface); }

/* ── Wizard form rhythm ── the card centres its hero copy, but form
   fields inside read better left-aligned with clear separation between
   sections (labels were hugging the strip above them). */
.wizard-card .field,
.wizard-card .field-row { text-align: left; margin: 20px 0 0; }
.wizard-card .field-row .field { margin: 0; }
.wizard-card .field > label {
  display: block;
  text-align: left;
  font-weight: 700;
  margin-bottom: 8px;
}
.wizard-card .hint { text-align: left; }
.wizard-card .color-strip,
.wizard-card .emoji-strip { justify-content: flex-start; }
.wizard-card .wizard-input { text-align: center; } /* app-name hero field stays centred */
.wizard-card .field:has(.wizard-input) > .hint { text-align: center; }
.wizard-photo-row { margin-top: 4px; }
.wizard-photo-row input[type="file"] { flex: 1; min-width: 200px; }
.rolled-mark { cursor: default; display: inline-flex; align-items: center; justify-content: center; }
.rolled-note { font-weight: 600; }

/* Planner recipe speed-search. */
.recipe-lookup { position: relative; }
.recipe-lookup-results {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.recipe-lookup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 11px 14px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
}
.recipe-lookup-row:last-child { border-bottom: none; }
.recipe-lookup-row:hover { background: var(--accent-soft); }
.starter-check { font-size: 1.5rem; line-height: 1; color: var(--accent); flex-shrink: 0; width: 1.4em; text-align: center; }
.rolled-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 14px 0 0;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  font-size: 0.9rem;
}
.rolled-mark { cursor: pointer; }

/* Empty check circles show a ghost tick so it's obvious they're tappable;
   hover previews the done state. */
.check-btn:not(.checked)::after {
  content: '✓';
  color: var(--ink-faint);
  opacity: 0.45;
}
.check-btn:not(.checked):hover {
  border-color: var(--cool);
  background: color-mix(in srgb, var(--cool) 12%, #fff);
}
.check-btn:not(.checked):hover::after { color: var(--cool); opacity: 1; }

/* Read-only done-task dialog. */
.done-task-title { font-size: 1.3rem; font-weight: 700; margin: 6px 0 10px; }
.done-task-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.done-task-facts { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.done-task-facts > div { display: flex; gap: 12px; align-items: baseline; }
.done-task-facts dt { font-weight: 700; color: var(--ink-soft); font-size: 0.85rem; min-width: 90px; text-transform: uppercase; letter-spacing: 0.5px; }
.done-task-facts dd { margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Modal form consistency ── every create/edit dialog shares the same
   rhythm: left-aligned bold labels with breathing room, identically
   sized inputs/selects/dates, and two-column rows where space allows. */
.modal .field,
.modal .field-row { text-align: left; }
.modal .field > label { font-weight: 700; }
.modal select.big-input,
.modal input[type="date"].big-input,
.modal input[type="search"].big-input {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.92rem;
}
.modal input[type="file"] {
  padding: 10px 0;
  font-size: 0.95rem;
}
.modal textarea.big-input { line-height: 1.5; }
.modal h2 { font-size: 1.15rem; }
/* Confirmations keep centred copy. */
.modal.small { text-align: left; }
@media (max-width: 760px) {
  .modal { padding: 22px 18px 18px; }
}

/* ── Print: the shopping page prints as a compact two-column checklist.
   Row height, type size and chrome are all pared right down so a full
   week's list fits on one page. ── */
@media print {
  /* Print is always ink-on-paper: force the light palette even when the
     screen theme is dark, or token-coloured text (near-white in dark
     mode) vanishes on the page. */
  html, html[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --ink: #000; --ink-soft: #444; --ink-faint: #777;
    --line: #ddd; --line-strong: #bbb; --accent-soft: #fff;
  }
  .card { background: #fff !important; }
  .topbar, .mobile-menu, .header-actions, .week-toolbar .ghost-btn,
  .week-overview, .plan-sync-line, .shopping-add, .match-area, .row-del-btn,
  .basket-actions, .past-list, nav, .toast, .sample-pill,
  .print-hide { display: none !important; }
  .page > *:not(.card):not(.week-toolbar):not(.page-header) { display: none; }
  body, .app-shell, .content { background: #fff !important; color: #000 !important; }
  body { font-size: 11px; }
  .content { padding: 0 !important; }
  .page { gap: 2px !important; }
  .page-header h1 { font-size: 15px; margin: 0; }
  .page-header .subtitle { display: none; }
  .week-banner { padding: 0 0 6px; }
  .week-focus { background: none !important; padding: 0; font-size: 11px; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; }
  .card-title { font-size: 12px; margin-bottom: 4px; }
  .card-title .count { font-size: 10px; }
  /* Two tight columns of rows. */
  .shopping-list { display: block !important; column-count: 2; column-gap: 26px; }
  .aisle-wrap { column-count: 2; column-gap: 26px; }
  .aisle-wrap .shopping-list { column-count: unset; column-gap: unset; }
  .aisle-group { break-inside: avoid; margin: 0 0 8px; }
  .aisle-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 2px; }
  .shopping-row {
    background: none !important;
    border-radius: 0;
    border-bottom: 1px solid #e2e2e2;
    padding: 2px 0 !important;
    gap: 7px !important;
    min-height: 0;
    break-inside: avoid;
  }
  .shopping-name { font-size: 11px; font-weight: 500; }
  .shopping-qty { font-size: 10px; }
  .check-btn, .check-btn.big {
    width: 11px !important; height: 11px !important;
    border: 1.2px solid #000 !important; background: #fff !important;
    border-radius: 2px; font-size: 0;
  }
  .check-btn::after { content: '' !important; }
  /* x-show hides the non-active layout via inline style — never resurrect
     it in print, or the list prints twice. Bought rows and the details
     table stay off the printout too. */
  .shopping-list[style*="none"], .aisle-wrap[style*="none"] { display: none !important; }
  .shopping-row.checked, .details-wrap, .aisle-group:has(.shopping-row.checked):not(:has(.shopping-row:not(.checked))) { display: none !important; }
}

/* ── WhatsApp settings + send dialog ── */
.options-subhead {
  font-size: 1.02rem;
  margin: 26px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.seg-row { display: flex; gap: 10px; }
/* Segmented single-choice rows: the ghost-btn default is a filled pill,
   which made every option look "selected". Unselected segments are
   outline-only so the one active choice reads unmistakably. */
.seg-row .ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 500;
}
.seg-row .ghost-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.seg-row .ghost-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft, transparent);
  font-weight: 600;
}

/* Respect the OS-level reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Shopping list tools row — sits between the stat bar and the add form,
   keeping the page header identical to the planner's so the week bars
   don't shift when switching between the two pages. */
.list-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* The shopping page lays its bars out with the section's 20px gap; the
   planner nests toolbar + overview with none. Cancel the gap so the
   stat bar sits at the identical height on both pages. */
.shopping-overview { margin-top: -20px; }

/* Phone-width topbar: drop the date line and the user's name so the bar
   always fits — avatar, time and menu remain. */
@media (max-width: 560px) {
  .clock-top .clock-date { display: none; }
  .user-pill .user-pill-name, .user-pill .user-pill-role { display: none; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .topbar-right { gap: 8px; min-width: 0; }
  .brand { min-width: 0; flex: 0 1 auto; }
  .brand-name { max-width: 26vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Display modes for Tasks + Shopping (same switch as Notes) ──
   'list' is the default: one full-width column, one line per row. */

/* Shared details table */
.details-wrap { overflow-x: auto; }
.details-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.details-table th {
  text-align: left; font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-soft);
  border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0;
}
.details-table td { border-bottom: 1px solid var(--line); padding: 5px 10px 5px 0; vertical-align: middle; }
.details-table tr.tappable { cursor: pointer; }
.details-table tr:hover td { background: var(--surface-2); }
.details-table tr.done td, .details-table tr.done .dt-title { color: var(--ink-soft); }
.dt-title { font-weight: 600; }

/* Tasks: one-line list rows */
.tasks-mode-list .task-row { padding: 5px 10px; gap: 10px; align-items: center; }
.tasks-mode-list .task-body { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tasks-mode-list .task-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95rem; }
.tasks-mode-list .task-meta { margin-left: auto; flex-wrap: nowrap; align-items: center; margin-top: 0; }
.tasks-mode-list .assignee-name { display: none; }
.tasks-mode-list .assignee-badge { padding: 2px; }

/* Tasks: card grids */
.tasks-mode-large { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tasks-mode-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.tasks-mode-icons .task-row { padding: 8px 10px; }
.tasks-mode-icons .due, .tasks-mode-icons .overdue-badge,
.tasks-mode-icons .assignee-badge, .tasks-mode-icons .rolled-note { display: none; }

/* Shopping: one-line list rows (tighter than the base row) */
.shopping-mode-list .shopping-row { padding: 5px 10px; gap: 10px; min-height: 0; }

/* Shopping: card grids */
/* max(…, 24%) caps the grids at four columns on any screen width. */
.shopping-mode-large { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(240px, 24%), 1fr)); gap: 8px; }
.shopping-mode-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(170px, 24%), 1fr)); gap: 8px; }
.shopping-mode-icons .shopping-row { padding: 8px 10px; }
.shopping-mode-icons .row-del-btn { display: none; }

/* Home shopping card week controls */
.home-week-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.home-week-label { font-size: 0.82rem; color: var(--ink-soft); margin-left: 2px; }



/* Tooltips on controls near the top of the screen open BELOW the element —
   above the topbar they'd render off-screen. */
.topbar [data-tip]::after,
.page-header [data-tip]::after,
.list-tools [data-tip]::after,
.notes-toolbar [data-tip]::after,
.week-toolbar [data-tip]::after,
.week-overview [data-tip]::after,
.home-week-row [data-tip]::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-2px);
}
.topbar [data-tip]:hover::after, .topbar [data-tip]:focus-visible::after,
.page-header [data-tip]:hover::after, .page-header [data-tip]:focus-visible::after,
.list-tools [data-tip]:hover::after, .list-tools [data-tip]:focus-visible::after,
.notes-toolbar [data-tip]:hover::after, .notes-toolbar [data-tip]:focus-visible::after,
.week-toolbar [data-tip]:hover::after, .week-toolbar [data-tip]:focus-visible::after,
.week-overview [data-tip]:hover::after, .week-overview [data-tip]:focus-visible::after,
.home-week-row [data-tip]:hover::after, .home-week-row [data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

/* Home-card mini controls */
.card-title-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.home-mini-select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 3px 6px;
  max-width: 130px;
}

/* Home Top Tasks: same compressed one-line rows as the tasks page's list
   mode, so the dashboard shows more in less height and the two columns
   land close to level. */
.home-card .task-list .task-row { padding: 5px 10px; gap: 10px; align-items: center; }
.home-card .task-list .task-body { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.home-card .task-list .task-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95rem; }
.home-card .task-list .task-meta { margin-left: auto; margin-top: 0; flex-wrap: nowrap; align-items: center; }
.home-card .task-list .assignee-badge > span:last-child:not(.assignee-avatar) { display: none; }
.home-card .task-list .sample-pill { display: none; }

/* ── Meal planner polish ── */
/* Today's column glows gently so the eye lands on it. */
.week-grid .wg-day.today {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: 700;
}
.week-grid .wg-cell.today { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
/* Whole cell is the add target: pointer + a ghost + on hover of an
   empty area (replaces the old per-cell + button). */
.week-grid .wg-cell.tappable { cursor: pointer; position: relative; }
.week-grid .wg-cell.tappable:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.week-grid .wg-cell.tappable:hover::after {
  content: '+';
  position: absolute;
  right: 6px;
  bottom: 2px;
  color: var(--accent);
  font-weight: 700;
  opacity: 0.7;
}
.wg-add { display: none; }

/* Settings → Meals slot editor */
.meal-slot-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.meal-slot-row { display: flex; align-items: center; gap: 8px; }
.meal-slot-row .big-input { flex: 1; }
.meal-slot-order { display: flex; gap: 4px; }
.meal-slot-add { display: flex; gap: 8px; align-items: center; }
.meal-slot-add .big-input { flex: 1; }

/* Wizard meal-slot picker */
.wizard-meals { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 8px; }
.wizard-meal-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}
.wizard-meal-row.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.wizard-meal-row .big-input { flex: 1; border: none; background: transparent; min-height: 30px; padding: 4px 6px; }
.wizard-meal-row .big-input:disabled { color: var(--ink-faint); }

/* Recipes display modes (same switch as Notes/Tasks/Shopping; four
   columns maximum on any width). */
.recipes-mode-large { grid-template-columns: repeat(auto-fill, minmax(max(200px, 24%), 1fr)); gap: 8px; }
.recipes-mode-large .recipe-card { padding: 0.5rem 0.7rem; }
.recipes-mode-large .rc-title { font-size: 0.92rem; margin-bottom: 0.1rem; }
.recipes-mode-large .rc-meta { font-size: 0.78rem; }
.recipes-mode-icons { grid-template-columns: repeat(auto-fill, minmax(max(140px, 24%), 1fr)); gap: 6px; }
.recipes-mode-icons .recipe-card { padding: 0.35rem 0.55rem; }
.recipes-mode-icons .rc-title { font-size: 0.85rem; font-weight: 500; margin: 0; }
.recipes-mode-icons .rc-meta { display: none; }
.recipes-mode-list { display: flex; flex-direction: column; gap: 6px; }
.recipes-mode-list .recipe-card { display: flex; align-items: center; gap: 12px; padding: 5px 12px; }
.recipes-mode-list .rc-title { margin-bottom: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipes-mode-list .rc-meta { margin-left: auto; white-space: nowrap; }

/* ── Shared cookbook ── */
.shared-pill, .personal-pill {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: middle;
}
.shared-pill { background: var(--accent-soft); color: var(--accent); }
.personal-pill { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.rating-inline { color: #d97706; font-weight: 600; white-space: nowrap; }

.modal.shared-recipe-modal {
  gap: 12px;
  max-width: none;
  width: calc(100vw - 48px);
  overflow-x: hidden;
}
.shared-recipe-modal .options-subhead { margin-top: 0; padding-top: 0; border: none; margin-bottom: 10px; }
.shared-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.shared-head .right-group { display: flex; gap: 8px; flex-wrap: wrap; }
/* flex-shrink: 0 — the modal is a flex column and an iframe has no
   intrinsic min-height, so without this the pane collapses to 0. */
.pdf-frame-wrap { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; flex-shrink: 0; }
.pdf-frame { width: 100%; height: 42vh; min-height: 260px; border: none; display: block; background: #525659; }
.shared-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding-top: 2px; }
@media (max-width: 760px) { .shared-columns { grid-template-columns: 1fr; } }
.shared-ing-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem; }
.shared-ing-qty { font-weight: 600; margin-right: 6px; }
.shared-method { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.5; max-height: 220px; overflow-y: auto; margin-top: 2px; }
.shared-columns h3.options-subhead + .shared-method,
.shared-columns .nutrition-table { margin-bottom: 14px; }
.nutrition-table { border-collapse: collapse; font-size: 0.9rem; width: 100%; max-width: 260px; }
.nutrition-table td { border-bottom: 1px solid var(--line); padding: 2px 10px 2px 0; }
.nutrition-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.star-row { display: inline-flex; gap: 2px; }
.star-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 2px;
  color: var(--line-strong);
  transition: color 80ms, transform 80ms;
}
.star-btn.lit { color: #f59e0b; }
.star-btn:hover { transform: scale(1.15); }
.shared-ratings {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr);
  gap: 14px 32px;
  align-items: start;
}
@media (max-width: 760px) { .shared-ratings { grid-template-columns: 1fr; } }
.shared-ratings > .publisher-note, .shared-ratings > .muted { grid-column: 1 / -1; }
.rate-mine { flex-direction: column; align-items: flex-start; gap: 6px; }
.rate-mine .star-row .star-btn { font-size: 1.45rem; }
.rate-mine { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.rate-dist { display: flex; flex-direction: column; gap: 3px; max-width: 340px; }
.rate-dist-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.rate-dist-label { width: 26px; text-align: right; color: var(--ink-soft); }
.rate-dist-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rate-dist-fill { display: block; height: 100%; background: #f59e0b; border-radius: 4px; }
.rate-dist-n { width: 34px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.publisher-note { background: var(--surface-2); border-radius: var(--radius-md); padding: 10px 14px; font-size: 0.9rem; }

.nutrition-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; margin: 6px 0 12px; }
@media (max-width: 760px) { .nutrition-grid { grid-template-columns: repeat(2, 1fr); } }
.nutrition-cell { display: flex; flex-direction: column; gap: 3px; }
.nutrition-name { font-size: 0.75rem; color: var(--ink-soft); }
.recipe-modal .field { margin-bottom: 4px; }
.lodge-block { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 10px; }
.lodge-block .share-actions { margin-top: 8px; gap: 10px; }
.recipe-modal .actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.starter-option.is-static { cursor: default; }
/* A second heading within a viewer column (e.g. Method after Nutrition)
   gets air above it. */
.shared-columns .options-subhead:not(:first-child) { margin-top: 14px; }

/* Standard app spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pdf-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px; color: var(--ink-soft); font-size: 0.92rem;
  position: absolute; inset: 0; background: var(--surface); z-index: 1;
}
.pdf-frame-wrap { position: relative; }

/* Greeting lives in the topbar now; the home page starts straight at
   the panes. */
.topbar-greeting {
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 900px) { .topbar-greeting { display: none; } }
.help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }

/* ── A–Z jump rail — hugs the left edge on big alphabetical lists ── */
.az-rail {
  position: fixed;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 1px;
  backdrop-filter: blur(4px);
}
.az-letter {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 5px;
  line-height: 1.45;
}
.az-letter.off { color: var(--ink-faint); opacity: 0.4; cursor: default; }
.az-letter:not(.off):hover { transform: scale(1.4); }
@media (max-height: 700px) { .az-letter { font-size: 0.56rem; line-height: 1.3; } }
