/* 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 {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #1f2430;
  --ink-soft: #5a6170;
  --ink-faint: #9ba3b4;
  --line: #e6e1d6;
  --line-strong: #d0cabc;

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

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

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

  --tap: 60px;
}

/* Dark theme — applied when <html data-theme="dark">. The theme picker in
 * the sidebar sets this; "System" resolves to dark/light based on the
 * prefers-color-scheme media query and updates live. */
html[data-theme="dark"] {
  --bg: #14171d;
  --surface: #1b1f27;
  --surface-2: #242932;
  --ink: #f1edde;
  --ink-soft: #a8b0bc;
  --ink-faint: #6c7382;
  --line: #2d333f;
  --line-strong: #3b4252;

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

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

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

* { box-sizing: border-box; }

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

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

button, input, select, textarea { font: inherit; color: inherit; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Assignee chip & filter strip — used on Tasks page and in the task modal. */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}
.assignee-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.assignee-chip {
  --chip-color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  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%, #fff);
}
.assignee-chip.selected {
  border-color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 18%, #fff);
  color: var(--ink);
}
.assignee-chip .assignee-avatar { font-size: 1.2rem; line-height: 1; }

/* Smaller non-interactive version used inline in the task-meta row. */
.assignee-badge {
  --chip-color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip-color) 15%, #fff);
  border: 1px solid color-mix(in srgb, var(--chip-color) 40%, transparent);
  font-size: 0.82rem;
  font-weight: 600;
}
.assignee-badge.unassigned {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink-soft);
}
.assignee-badge .assignee-avatar { font-size: 1rem; line-height: 1; }

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

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

/* ============== Shopping ============== */
.shopping-add {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 10px;
}
.big-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: #fff;
  font-size: 1.05rem;
  min-height: var(--tap);
}
.big-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea.big-input { min-height: 90px; resize: vertical; }
.qty-select {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--line);
  background: #fff;
  min-height: var(--tap);
  font-size: 1.05rem;
}
.suggestion-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.suggest-chip {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  min-height: 44px;
  font-size: 0.95rem;
  overflow: hidden;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.suggest-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.suggest-chip.learned { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.suggest-chip-main {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.suggest-chip .suggest-chip-main { padding-right: 6px; }
.suggest-chip-x {
  border: none;
  background: transparent;
  padding: 0 12px 0 4px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.suggest-chip-x:hover { color: var(--danger); }

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Feeds modal */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.feed-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border-left: 5px solid var(--accent);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  font-weight: 600;
}

/* ============== Responsive tweaks ============== */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--line);
    padding: 8px 8px 14px;
    z-index: 20;
  }
  .brand, .clock { display: none; }
  .nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    gap: 4px;
  }
  .nav-btn { flex-direction: column; gap: 2px; padding: 8px; min-height: 56px; font-size: 0.75rem; }
  .nav-icon { font-size: 1.3rem; }
  .content { padding: 18px 18px 110px; }
  .home-grid, .task-columns { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .shopping-add { grid-template-columns: 1fr 1fr; }
  .shopping-add .primary-btn { grid-column: span 2; }
  .week-grid { grid-template-columns: repeat(7, minmax(140px, 1fr)); overflow-x: auto; }
  .month-grid .day-cell { min-height: 80px; }
}

@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: 64px; }
  .day-chip { font-size: 0.72rem; }
}
