:root {
  --accent: #2e7cf6;
  --bg: #f2f2f7;
  --card-bg: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --border: #e5e5ea;
  --danger: #ff3b30;
  --success: #34c759;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 20px; margin-top: 20px; }
h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; margin-top: 18px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }

.screen { min-height: 100vh; }

/* PIN / identity cards */
.pin-card {
  max-width: 360px;
  margin: 15vh auto 0;
  padding: 32px 24px;
  text-align: center;
}
.pin-card h1 { font-size: 26px; }
.pin-card input[type="password"] {
  width: 100%;
  font-size: 22px;
  text-align: center;
  letter-spacing: 6px;
  padding: 14px;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
}

.identity-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.identity-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 17px;
  font-weight: 500;
}
.identity-option:active { background: #eef4ff; }

/* Buttons */
.primary-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:active { opacity: 0.85; }
.secondary-btn {
  width: 100%;
  padding: 14px;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn { background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.icon-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.icon-btn.danger { color: var(--danger); }
.icon-btn-round { background: var(--card-bg); border: none; border-radius: 50%; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.error { color: var(--danger); font-size: 14px; }

/* App header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.app-header h1 { font-size: 22px; font-weight: 700; }

main {
  padding: 0 16px 96px;
  max-width: 480px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.view-header h2 { margin: 0; flex: 1; text-align: center; }
.back-btn { background: none; border: none; color: var(--accent); font-size: 16px; cursor: pointer; padding: 0; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 4px;
}

.section-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.section-row h2 { margin: 0; }

/* Home greeting */
.greeting { font-size: 26px; font-weight: 700; margin-top: 16px; }
.home-date { margin-top: -4px; margin-bottom: 16px; }

/* Weather card */
.weather-card { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.weather-card .wx-icon { font-size: 40px; }
.weather-card .wx-temp { font-size: 34px; font-weight: 700; }
.weather-card .wx-meta { text-align: right; }
.weather-card .wx-condition { font-weight: 600; }

.weather-current { text-align: center; padding: 28px 14px; }
.weather-current .wx-icon-big { font-size: 64px; }
.weather-current .wx-temp-big { font-size: 56px; font-weight: 700; }
.weather-current .wx-hilo { color: var(--muted); font-size: 16px; }

.forecast-list { padding: 4px 14px; }
.forecast-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.forecast-row:last-child { border-bottom: none; }
.forecast-day { width: 90px; font-weight: 600; }
.forecast-icon { font-size: 20px; flex: 1; text-align: center; }
.forecast-hilo { width: 90px; text-align: right; }
.forecast-hilo .hi { font-weight: 600; }
.forecast-hilo .lo { color: var(--muted); }

/* Task lists */
.task-list { padding: 4px 14px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white;
}
.task-check.checked { background: var(--success); border-color: var(--success); }
.task-person-avatar { flex-shrink: 0; }
.task-main { flex: 1; min-width: 0; }
.task-name { font-weight: 500; }
.task-name.done { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: 13px; color: var(--muted); }
.task-delete { background: none; border: none; color: var(--danger); font-size: 13px; cursor: pointer; padding: 4px; }
.empty-state { padding: 16px; text-align: center; color: var(--muted); }

/* Avatars */
.avatar-row { display: flex; gap: 16px; padding: 8px 0 4px; overflow-x: auto; }
.avatar-item { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; flex-shrink: 0; }
.avatar-circle {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 20px;
}
.avatar-circle.small { width: 36px; height: 36px; font-size: 15px; }
.avatar-circle.tiny { width: 22px; height: 22px; font-size: 10px; }
.avatar-name { font-size: 12px; font-weight: 500; }

/* A real uploaded photo renders as an <img> with the same avatar-circle
   sizing classes, so it drops into every spot the colored-initial circle
   already appears without any other markup changing. */
img.avatar-photo { object-fit: cover; background: var(--border); }

/* "Change photo" button overlaid on each row in the "Who is this?"
   picker — the only entry point for uploading/replacing an avatar. */
.identity-avatar-wrap { position: relative; flex-shrink: 0; }
.identity-avatar-upload {
  position: absolute; bottom: -2px; right: -2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: white; border: 2px solid var(--card-bg);
  font-size: 10px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* People / Person Tasks master-detail. Mobile: single pane at a time,
   toggled via the "show-detail" class on #view-people (list by default,
   detail full-screen with a back button once a person is picked).
   Desktop overrides both to always show side by side — see the
   breakpoint at the bottom of this file. */
#people-detail-pane { display: none; }
#view-people.show-detail #people-list-pane { display: none; }
#view-people.show-detail #people-detail-pane { display: block; }
.person-placeholder { padding: 48px 20px; text-align: center; }

/* People list */
.people-list { padding: 4px 14px; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.person-row:last-child { border-bottom: none; }
.person-row.active { background: #eef4ff; border-radius: 10px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.person-row-main { flex: 1; }
.person-row-name { font-weight: 600; }
.person-row-count { font-size: 13px; color: var(--muted); }
.chevron { color: var(--muted); font-size: 18px; }

/* Person header */
.person-header { display: flex; align-items: center; gap: 14px; padding: 10px 0 16px; }
.person-header-name { font-size: 22px; font-weight: 700; }

/* Tasks / Schedule tabs on a person's detail pane */
.person-detail-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.person-detail-tab {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); font-weight: 600; font-size: 14px; cursor: pointer;
}
.person-detail-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.2s; }
.progress-label { margin-top: 6px; }

/* Verse card */
.verse-card { margin-top: 20px; }
.verse-text { font-style: italic; font-size: 16px; line-height: 1.4; }
.verse-ref { color: var(--accent); font-weight: 600; margin-top: 8px; }
.verse-actions { margin-top: 10px; display: flex; gap: 10px; }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-day {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
}
.cal-day.today { border: 1.5px solid var(--accent); }
.cal-day.selected { background: var(--accent); color: white; }
.cal-day.empty { visibility: hidden; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-top: 2px; }
.cal-day.selected .cal-dot { background: white; }

.notif-list { padding: 4px 14px; }
.notif-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-row:last-child { border-bottom: none; }
.notif-avatar { flex-shrink: 0; margin-top: 2px; }
.notif-text-wrap { flex: 1; min-width: 0; }
.notif-text { font-size: 15px; }
.notif-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

.more-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.more-row:last-child { border-bottom: none; }

/* Desktop-only sidebar (see the breakpoint at the bottom of this file for
   its actual layout) — hidden on mobile, where the bottom nav is used. */
.sidebar-nav { display: none; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.nav-btn.active { color: var(--accent); }
.nav-icon { font-size: 20px; }
.nav-add {
  flex: 0 0 52px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 52px; height: 52px;
  margin-top: -22px;
  box-shadow: 0 2px 8px rgba(46,124,246,0.4);
}
.nav-add .nav-icon { font-size: 26px; }

/* Push prompt */
.push-prompt {
  display: flex; align-items: center; justify-content: space-between;
  background: #eef4ff; border-radius: 12px; padding: 10px 12px;
  margin: 12px 0; font-size: 13px; gap: 8px;
}
.push-prompt-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Sheet (Quick Add) */
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 20;
  display: flex; align-items: flex-end;
}
.sheet-content {
  background: var(--card-bg);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
}
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 4px auto 14px; }

.add-type-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.add-type-tab {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); font-weight: 600; font-size: 14px; cursor: pointer;
}
.add-type-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

#add-form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
#add-form input, #add-form select, #add-form textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; background: var(--bg); font-family: inherit;
}
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 26px; transition: 0.2s; }
.slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

.offline-banner {
  position: sticky; top: 0; z-index: 15;
  background: #ffe9a8; color: #5c4400; text-align: center; font-size: 13px; padding: 6px;
}

/* ============================================================
   Desktop layout (~900px+) — sidebar nav + wider multi-column
   views. Nothing above this point changes for phones; everything
   here is additive/overriding only above the breakpoint.
   ============================================================ */
@media (min-width: 900px) {
  /* App shell: persistent sidebar replaces the bottom tab bar */
  #app-screen { display: flex; align-items: stretch; min-height: 100vh; }
  .app-header { display: none; }
  .bottom-nav { display: none; }
  .app-content { flex: 1; min-width: 0; }

  main {
    max-width: 1100px;
    margin: 0;
    padding: 32px 40px 56px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 240px;
    flex-shrink: 0;
    padding: 24px 16px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
  }
  .sidebar-brand { font-size: 19px; font-weight: 700; padding: 0 10px; margin-bottom: 18px; }
  .sidebar-add-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 16px;
  }
  .sidebar-add-btn:active { opacity: 0.85; }
  .sidebar-btn {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    font-size: 15px;
    padding: 10px;
    border-radius: 10px;
    width: 100%;
  }
  .sidebar-btn .nav-icon { font-size: 18px; }
  .sidebar-btn.active { background: #eef4ff; color: var(--accent); }

  /* Home: weather / today's tasks / verse side by side instead of stacked */
  .home-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1fr;
    gap: 20px;
    align-items: start;
  }
  .home-tasks-col .section-row { margin-top: 0; }
  .home-grid .verse-card { margin-top: 0; }
  .home-family-block { margin-top: 28px; }

  /* Weather: current conditions beside the forecast instead of above it */
  .weather-layout { display: flex; gap: 28px; align-items: flex-start; }
  .weather-current-col { flex: 0 0 320px; }
  .weather-forecast-col { flex: 1; }

  /* Calendar: a larger grid with the day's agenda alongside it */
  .calendar-layout { display: flex; gap: 28px; align-items: flex-start; }
  .calendar-grid-col { flex: 1.5; max-width: 640px; }
  .calendar-day-col { flex: 1; position: sticky; top: 32px; }
  .cal-grid { gap: 6px; }
  .cal-day { font-size: 16px; }

  /* People / Tasks: master-detail — both panes always visible side by
     side, overriding the mobile single-pane "show-detail" toggle. */
  #view-people { display: flex; gap: 28px; align-items: flex-start; }
  #people-list-pane, #people-detail-pane { display: block !important; }
  #people-list-pane { flex: 0 0 320px; }
  #people-detail-pane { flex: 1; }
  #person-back-btn { display: none; }

  /* PIN gate + "Who is this?" picker: centered modal dialogs instead of
     full-screen takeovers. */
  #pin-screen, #identity-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 28, 30, 0.45);
  }
  #pin-screen .pin-card, #identity-screen .pin-card {
    margin: 0;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
  }

  /* Quick Add: a centered dialog instead of a bottom sheet */
  .sheet { align-items: center; }
  .sheet-content {
    width: 100%;
    max-width: 480px;
    border-radius: 20px;
    max-height: 82vh;
  }
  .sheet-handle { display: none; }
}
