/* ---------- design tokens ---------- */
:root {
  --ink:        #0c1c2c;
  --ink-soft:   #2a3d52;
  --paper:      #f6f1e8;   /* warm sand */
  --paper-2:    #ece4d4;
  --line:       #c8bba1;
  --line-soft:  #d9cfb6;
  --accent:     #b8390e;   /* signal red — buoy */
  --accent-2:   #1e5573;   /* deep harbor */
  --sea:        #2d6e87;
  --sea-light:  #d7e4ea;
  --muted:      #6f7d8c;
  --shadow:     0 1px 0 #fff inset, 0 12px 32px -16px rgba(12, 28, 44, .35);
  --radius:     2px;       /* tight, editorial */
}

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Work+Sans:wght@400;500;600&display=swap");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Work Sans", -apple-system, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 10% 0%, rgba(45,110,135,.06), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(184,57,14,.05), transparent 40%);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

.display {
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -.01em;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: .04em;
  font-size: 13px;
  text-transform: uppercase;
  transition: transform .08s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.ghost   { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger  { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.danger:hover { background: var(--accent); color: var(--paper); }
/* Disabled state — applies to any .btn variant. The default browser greying
   on our custom-styled buttons is too subtle to read at a glance, so we
   explicitly drop opacity + lock the cursor. */
.btn:disabled,
.btn[disabled] {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- auth ---------- */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3rem 2.5rem 2rem;
  box-shadow: var(--shadow);
  position: relative;
}
.auth-card::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  pointer-events: none;
}
.auth-head { text-align: center; margin-bottom: 2rem; }
.seal {
  display: inline-grid;
  place-items: center;
  width: 56px; height: 56px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-size: 24px;
  margin-bottom: .75rem;
}
.seal.small { width: 32px; height: 32px; font-size: 15px; border-width: 1px; margin: 0; }

/* Burgee — the real LSYC pennant logo. The source JPG has a white background
   that we drop into the sand background via mix-blend-mode: multiply. White
   pixels multiply with sand to become sand; blues and reds stay vivid. */
.burgee {
  display: block;
  mix-blend-mode: multiply;
  /* Slight contrast boost compensates for the multiply darkening blues */
  filter: contrast(1.05) saturate(1.05);
}
.burgee-hero {
  width: 200px;
  height: auto;
  margin: 0 auto;
}

/* Topbar mark — the burgee at small size. Detail (sun, martini, waves) is
   fuzzy here; we accept that as a trade for brand recognition. The topbar
   background is sand, so multiply still drops the white correctly. */
.burgee-mark {
  height: 56px;
  width: auto;
}
@media (max-width: 640px) {
  .burgee-mark { height: 44px; }
}
.auth-head h1 { font-size: 2.5rem; margin: 0; }
.subtitle {
  margin: .25rem 0 0;
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: 11px;
  color: var(--muted);
}
.auth-foot {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- forms ---------- */
.form { display: grid; gap: 1rem; }
.form.narrow { max-width: 420px; }
.form label { display: grid; gap: .35rem; }
.form label span {
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.form input, .form select, .form textarea, .search {
  font: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .65rem .8rem;
  color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus, .search:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
  border-color: var(--accent-2);
}
.form textarea { min-height: 80px; resize: vertical; }

.error { color: var(--accent); font-size: 13px; margin: 0; }
.msg { font-size: 13px; margin: 0; }
.msg.ok { color: #1e6f3f; }
.msg.err { color: var(--accent); }

/* ---------- app shell ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-name { font-size: 1.5rem; }
.tabs { display: flex; gap: .25rem; justify-content: center; }
.tab {
  font: inherit;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 1rem; font-size: 13px; color: var(--muted); }

.content { padding: 2rem; max-width: 1280px; margin: 0 auto; }
.view-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.view-head h2 { margin: 0; font-size: 2.25rem; }
.view-actions { display: flex; gap: .5rem; align-items: center; }
.search { min-width: 240px; }

/* ---------- calendar ---------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.calendar .cal-header {
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  padding: .75rem .5rem;
  text-align: center;
}
.calendar .day {
  min-height: 110px;
  border-top: 1px solid var(--line-soft);
  border-left: 1px solid var(--line-soft);
  padding: .4rem;
  position: relative;
  cursor: pointer;
  transition: background .12s ease;
}
.calendar .day:hover { background: var(--paper-2); }
.calendar .day.other-month { background: #fafaf6; color: var(--muted); }
.calendar .day.today .daynum {
  background: var(--accent); color: var(--paper);
  border-radius: 50%; width: 24px; height: 24px;
  display: inline-grid; place-items: center; font-weight: 600;
}

.calendar .day.blackout {
  background:
    repeating-linear-gradient(
      45deg,
      #fff4e6,
      #fff4e6 8px,
      #ffeaca 8px,
      #ffeaca 16px
    );
}
.calendar .day.blackout:hover { filter: brightness(.97); }
.blackout-banner {
  background: var(--accent);
  color: var(--paper);
  font-size: 10px;
  text-align: center;
  padding: 3px 4px;
  margin: 4px 0;
  border-radius: 1px;
  line-height: 1.25;
}
.blackout-banner strong {
  letter-spacing: .1em;
  display: block;
  font-size: 9px;
}
.blackout-banner span {
  font-style: italic;
  font-size: 10px;
}

/* Clickable contact links — phone (sms:) + email (mailto:) */
.contact-link {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-2);
}
.contact-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.daynum { font-size: 13px; font-weight: 500; }
.event-pill {
  display: block;
  font-size: 11px;
  background: var(--sea-light);
  color: var(--accent-2);
  border-left: 2px solid var(--sea);
  padding: 2px 6px;
  margin-top: 3px;
  border-radius: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-pill.mine { background: #f3e0d6; color: var(--accent); border-left-color: var(--accent); }
.event-pill.rsvp-going { background: #def0e0; color: #1e6f3f; border-left-color: #1e6f3f; }
.event-pill.rsvp-not_going { background: #efe5e2; color: #6f7d8c; border-left-color: #6f7d8c; opacity: .7; text-decoration: line-through; }
.event-pill.rsvp-pending { box-shadow: 0 0 0 1px var(--accent-2) inset; }
.event-pill:hover { filter: brightness(.95); }
.event-more { font-size: 10px; color: var(--muted); margin-top: 2px; }

.legend { margin-top: .75rem; }

/* ---------- directory ---------- */
.member-list {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line);
}
.member-list li {
  background: #fff;
  padding: 1rem 1.2rem;
  display: grid;
  gap: .2rem;
}
.member-list .name { font-weight: 600; font-size: 15px; }
.member-list .meta { font-size: 12px; color: var(--muted); }
.member-list .badge {
  display: inline-block;
  font-size: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 1px 6px;
  letter-spacing: .1em;
  margin-left: .35rem;
  vertical-align: middle;
}

/* ---------- admin table ---------- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.admin-table th {
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 500;
}
.admin-table tr.inactive { opacity: .5; }
/* Action buttons sit in one row — nowrap + compact padding + no
   letter-spacing so the five buttons (Edit / Reset pw / WA / Email / Deactivate)
   fit without wrapping on a typical desktop. On phones the whole table
   converts to a card layout further down. */
.admin-table .row-actions {
  display: flex;
  gap: .25rem;
  flex-wrap: nowrap;
  align-items: center;
}
.admin-table .row-actions .btn {
  padding: .3rem .55rem;
  font-size: 10.5px;
  letter-spacing: 0;
  white-space: nowrap;
}
.admin-table td.row-actions,
.admin-table td.actions { white-space: nowrap; }
/* Keep the Name column on a single line. Email is the long-tail column —
   let it absorb the squeeze and truncate if needed. */
.admin-table td[data-label="Name"],
.admin-table td[data-label="WhatsApp"],
.admin-table td[data-label="Digest"],
.admin-table td[data-label="Role"],
.admin-table td[data-label="Status"] {
  white-space: nowrap;
}
.admin-table td[data-label="Email"] {
  word-break: break-all;
  max-width: 280px;
}
/* Members with missing/invalid contact info — the name is highlighted red
   so an admin can spot them at a glance and follow up to collect real
   contact details. The class is added in the row renderer when either the
   email is a placeholder (@lsyc.invalid) or phone_e164 is null. */
.name-needs-info {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- visibility (admin metrics dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 0 0 2rem;
}
.stat-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem 1.5rem;
}
.stat-card .label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.stat-card .value { font-size: 2.25rem; font-weight: 600; line-height: 1.1; margin-top: .35rem; color: var(--ink); }
.stat-card .sub   { font-size: 12px; color: var(--ink-soft); margin-top: .25rem; }
.stat-card.accent .value { color: var(--accent); }
.stat-card.good   .value { color: #2b7a3a; }
.stat-card.warn   .value { color: #b8590e; }
.vis-section-head { margin: 2rem 0 .75rem; display: flex; align-items: baseline; gap: .75rem; }
.vis-section-head h3 { margin: 0; font-size: 1.15rem; }
.vis-section-head .muted { font-size: 12px; }
.vis-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--paper-2); border: 1px solid var(--line); }
.vis-table th, .vis-table td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft, #e0d8c5); }
.vis-table th { background: var(--paper-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.vis-table tr:last-child td { border-bottom: none; }
.vis-empty { color: var(--ink-soft); font-size: 13px; padding: .8rem; font-style: italic; }
.vis-needs { color: var(--accent); font-weight: 600; }
.ratio-bar { display: inline-block; width: 80px; height: 4px; background: var(--line); margin-left: .5rem; vertical-align: middle; border-radius: 2px; overflow: hidden; }
.ratio-bar > span { display: block; height: 100%; background: var(--accent-2); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(12, 28, 44, .5);
  display: grid; place-items: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.75rem;
  margin: 0 0 1.25rem;
  font-weight: 600;
}
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ---------- invitee picker ---------- */
.invitee-picker {
  border: 1px solid var(--line-soft);
  padding: .75rem 1rem;
  background: #fff;
  border-radius: var(--radius);
}
.invitee-picker summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  outline: none;
}
.invitee-picker summary strong { font-weight: 600; }
.invitee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .25rem .75rem;
  max-height: 260px;
  overflow-y: auto;
  padding: .5rem 0;
}
.invitee-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem 0;
  font-size: 13px;
  cursor: pointer;
}
.invitee-row input { margin: 0; }
.invitee-list { list-style: none; padding: 0; margin: .5rem 0; font-size: 14px; }
.invitee-list li { padding: .25rem 0; border-bottom: 1px solid var(--line-soft); }
.invitee-list li:last-child { border: none; }
.badge.going    { background: #1e6f3f; }
.badge.not_going { background: #6f7d8c; }
.badge.pending  { background: var(--muted); }
.rsvp-summary { padding-top: .5rem; border-top: 1px solid var(--line-soft); margin-top: .5rem; }

.my-rsvp {
  background: var(--paper-2);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.rsvp-buttons { display: flex; gap: .5rem; }
.rsvp-buttons .btn { padding: .4rem .8rem; font-size: 11px; }

/* ---------- avatars ---------- */
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper-2);
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--line-soft);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-placeholder {
  background: var(--accent-2);
  color: var(--paper);
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 600;
}
.avatar-lg { width: 120px; height: 120px; }
.avatar-lg.avatar-placeholder { font-size: 56px; }

/* ---------- account grid ---------- */
/* Layout (wide ≥ 860px):
     Col 1: Photo → Password → Privacy (Photo+Password share Family's height)
     Col 2: Family → House Rules
   HTML source order: 1 Photo, 2 Privacy, 3 Family, 4 Password, 5 House Rules

   Trick: use named areas that span rows so columns grow independently.
   Photo and Password each take half of Family's row span; Privacy and
   House Rules share their own row band. */
.account-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.6fr);
  grid-template-areas:
    "photo    family"
    "password family"
    "privacy  rules"
    "privacy  rules";
  gap: 1.25rem;
  align-items: stretch;
}
.account-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.account-card h3 { margin: 0 0 1.25rem; font-size: 1.3rem; }

/* Source order: 1 Photo, 2 Privacy, 3 Family, 4 Password, 5 House Rules */
.account-grid > :nth-child(1) { grid-area: photo;    }
.account-grid > :nth-child(2) { grid-area: privacy;  }
.account-grid > :nth-child(3) { grid-area: family;   }
.account-grid > :nth-child(4) { grid-area: password; }
.account-grid > :nth-child(5) { grid-area: rules;    }

@media (max-width: 860px) {
  .account-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "photo"
      "password"
      "privacy"
      "family"
      "rules";
  }
}

.avatar-uploader {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.avatar-actions { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.avatar-actions .btn { width: max-content; }

.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.checkbox-row input { margin: 0; }
.checkbox-row span {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 14px !important;
  color: var(--ink) !important;
}

/* ---------- member directory with avatars ---------- */
.member-list li {
  display: flex !important;
  gap: 1rem;
  align-items: center;
}
.member-list .member-info { flex: 1; }
.member-list .meta.family {
  font-style: italic;
  color: var(--ink-soft);
}

/* Two-column form rows (used in Family card) */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 540px) {
  .row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr; padding: 1rem; }
  .tabs { justify-content: flex-start; flex-wrap: wrap; }
  .content { padding: 1rem; }
  .calendar .day { min-height: 70px; }
  .calendar .day .event-pill { font-size: 9px; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: .4rem .5rem; }
}

/* Decline reason — italicized small text beneath a "not going" badge */
.decline-reason {
  display: block;
  margin-top: 2px;
  font-style: italic;
  color: var(--muted, #666);
}

/* ============================================================ */
/* Mobile overrides — iPhone-first.                              */
/* Two breakpoints:                                              */
/*   ≤ 640px → phones (everything stacks, list calendar)         */
/*   ≤ 900px → small tablets / large phones in landscape         */
/* Largest-viewport rules come first so cascade lands properly.  */
/* ============================================================ */

/* ---- 900px and below: tablet-ish ---- */
@media (max-width: 900px) {
  .content { padding: 1.25rem; }
  .topbar  { padding: 1rem 1.25rem; }
  .tabs    { gap: .15rem; flex-wrap: wrap; }
  .tabs button {
    font-size: 13px;
    padding: .55rem .8rem;
    min-height: 38px;
  }
  /* Adapt member cards / family grid to slightly narrower min */
  .account-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

/* ---- 640px and below: phones ---- */
@media (max-width: 640px) {

  /* ---- typography ---- */
  body { font-size: 16px; -webkit-text-size-adjust: 100%; }
  h1, .display { font-size: 1.5rem; line-height: 1.2; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.1rem; }

  /* ---- top chrome ---- */
  .content { padding: .9rem; }
  .topbar {
    padding: .8rem .9rem;
    grid-template-columns: 1fr;
    gap: .6rem;
    text-align: center;
  }
  .brand { justify-content: center; }
  .topbar .who {
    justify-content: center;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: 13px;
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: .25rem;
    margin: 0 -.9rem;
    padding-left: .9rem;
    padding-right: .9rem;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button {
    flex-shrink: 0;
    min-height: 44px;
    padding: .6rem .9rem;
    font-size: 14px;
  }

  /* ---- buttons: minimum 44px tap target ---- */
  .btn, .btn.ghost, .btn.primary {
    min-height: 44px;
    padding: .65rem 1rem;
    font-size: 15px;
  }

  /* ---- forms ---- */
  .form label { font-size: 14px; }
  .form input, .form select, .form textarea {
    font-size: 16px;          /* prevents iOS Safari zoom on focus */
    min-height: 44px;
    padding: .55rem .7rem;
  }
  .form textarea { min-height: 88px; }
  .row-2 { grid-template-columns: 1fr; gap: .5rem; }

  /* ---- calendar: switch from month grid to agenda list ---- */
  /* Day cells live DIRECTLY inside #calendar (no wrapper element),
     so the agenda layout must restyle .calendar itself — a .day-grid
     selector here would be dead code and the 7-col grid would persist. */
  .calendar {
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: .5rem;
  }
  .calendar .cal-header { display: none; }
  .calendar .day {
    min-height: auto;
    padding: .75rem .8rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    /* For Sat/Sun/etc rows that the desktop grid colours, neutralize */
    color: var(--ink);
  }
  /* Hide days that don't belong to the visible month and have no events */
  .calendar .day.other-month:not(.has-events) { display: none; }
  .calendar .day.other-month { background: #fafaf6; opacity: .65; }

  /* Hide empty in-month days so the agenda is tight */
  .calendar .day:not(.has-events):not(.today):not(.blackout) {
    display: none;
  }
  .calendar .day.today {
    border-color: var(--accent);
    border-width: 2px;
  }
  .calendar .day .daynum {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: .35rem;
    display: flex;
    align-items: baseline;
    gap: .5rem;
  }
  /* Append weekday name to date number on mobile via ::after on the daynum */
  .calendar .day .daynum::after {
    content: attr(data-dayname);
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .calendar .day.today .daynum {
    background: transparent;
    color: var(--accent);
    padding: 0;
    border-radius: 0;
    width: auto;
    height: auto;
  }
  .calendar .day.today .daynum::before {
    content: "Today · ";
    color: var(--accent);
  }
  .calendar .day.blackout { padding: .75rem .8rem; }

  /* event pills: bigger, full-width on mobile */
  .event-pill {
    display: block;
    padding: .55rem .65rem;
    font-size: 14px;
    margin-bottom: .3rem;
    border-radius: 4px;
    border-left-width: 4px;
    text-align: left;
    white-space: normal;
    line-height: 1.3;
  }
  .event-pill:last-child { margin-bottom: 0; }

  /* "+N more" overflow indicator stays visible — app.js caps pills at 3
     per day, so hiding the indicator would silently hide events. */
  .event-more { font-size: 12px; padding: .2rem 0; }

  /* Calendar month controls — real markup is .view-head > .view-actions
     holding ← / Today / → / + New event */
  #view-calendar .view-head {
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
  }
  #view-calendar .view-actions { flex-wrap: wrap; }
  #view-calendar .view-actions .btn { flex: 1 1 auto; }
  #newEventBtn { flex: 1 1 100%; }

  /* ---- directory — real markup is ul.member-list > li ---- */
  .member-list {
    grid-template-columns: 1fr;
    gap: .75rem;
    background: transparent;
    border: none;
  }
  .member-list li {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .85rem;
  }
  .member-list .avatar { width: 56px; height: 56px; }
  .member-list .name { font-size: 16px; }
  .member-list .meta { font-size: 13.5px; }

  /* ---- account / family cards ---- */
  .account-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .account-card { padding: 1rem; }
  .account-card h3 { font-size: 1.05rem; }
  .avatar-uploader {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .avatar-uploader .avatar-preview {
    align-self: center;
  }

  /* ---- admin members table → card list ---- */
  .admin-table {
    display: block;
  }
  .admin-table thead { display: none; }
  .admin-table tbody { display: block; }
  .admin-table tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: .75rem;
    padding: .85rem;
  }
  .admin-table td {
    display: block;
    padding: .2rem 0;
    border: none;
    font-size: 14px;
  }
  .admin-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: .3rem;
  }
  /* Action buttons go to a row beneath the data, full-width-ish */
  .admin-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid var(--line-soft);
  }
  .admin-table td.actions::before { display: none; }
  .admin-table td.actions .btn {
    flex: 1 1 auto;
    min-width: 110px;
    font-size: 13px;
    padding: .55rem .7rem;
  }

  /* ---- modals: full-screen sheet style ---- */
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.1rem 1rem 5.5rem;
  }
  .modal-actions {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    margin: 0;
    z-index: 1;
  }
  .modal-actions .btn { flex: 1 1 auto; }

  /* ---- toasts / banners ---- */
  .banner { font-size: 14px; padding: .6rem .8rem; }

  /* ---- avoid horizontal scrollbars from rogue elements ---- */
  body { overflow-x: hidden; }
}

/* ---- very narrow (sub-380px iPhone SE-ish) ---- */
@media (max-width: 380px) {
  .content { padding: .7rem; }
  .topbar  { padding: .7rem; }
  .admin-table td.actions .btn { min-width: 90px; font-size: 12.5px; }
  .event-pill { font-size: 13.5px; }
}

/* ============================================================ */
/* Family directory cards                                        */
/* ============================================================ */

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.family-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.family-header {
  display: flex;
  align-items: center;
  gap: .85rem;
  border-bottom: 1px solid var(--line-soft, #eee);
  padding-bottom: .85rem;
}
.family-photo {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f3eee1;
}
.family-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--muted);
  background: #f3eee1;
}
.family-title { min-width: 0; }
.family-name {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: .15rem;
}
.family-adults {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.family-adults .adult {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
}
.family-adults .adult .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}
.family-adults .adult-info { min-width: 0; flex: 1; }
.family-adults .adult-info .name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  margin-bottom: .15rem;
}
.family-adults .adult-info .meta {
  font-size: 13px;
  word-break: break-word;
}

/* mobile: family cards stack to single column already via min-width:340px */
@media (max-width: 640px) {
  .family-grid { grid-template-columns: 1fr; gap: .85rem; }
  .family-card { padding: .85rem; }
  .family-photo { width: 56px; height: 56px; }
  .family-photo-placeholder { font-size: 22px; }
  .family-name { font-size: 1.1rem; }
}

/* ============================================================ */
/* Admin: subtabs + family-action row                            */
/* ============================================================ */
.subtabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--line);
  margin: 1rem 0 1.5rem;
}
.subtab {
  background: transparent;
  border: 0;
  padding: .65rem 1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab.active {
  color: var(--ink, #222);
  border-bottom-color: var(--accent, #2a5);
}
.subtab:hover:not(.active) { color: var(--ink, #222); }

.sub-view { animation: fadeIn .15s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Admin family card has an actions row below the adults */
.admin-family-card .family-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-soft, #eee);
  padding-top: .85rem;
  margin-top: .35rem;
}
.admin-family-card .family-actions .btn { flex: 1 1 auto; min-width: 130px; }
.admin-family-card.inactive { opacity: .55; }

@media (max-width: 640px) {
  .subtabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    margin-left: -.9rem;
    margin-right: -.9rem;
    padding-left: .9rem;
    padding-right: .9rem;
    scrollbar-width: none;
  }
  .subtabs::-webkit-scrollbar { display: none; }
  .subtab { flex-shrink: 0; min-height: 44px; padding: .55rem .8rem; font-size: 14px; }
}

/* ============================================================ */
/* Event modal: family-based invitee picker                      */
/* ============================================================ */
.family-picker-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .5rem .75rem;
}
.invitee-row.family-row {
  align-items: flex-start;
  padding: .55rem .65rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.invitee-row.family-row:hover { background: var(--paper-2); }
.invitee-row.family-row input[type="checkbox"] { margin-top: 3px; }
.invitee-row.family-row:has(input:checked) {
  border-color: var(--accent-2);
  background: var(--sea-light);
}
.family-row-info { min-width: 0; flex: 1; }
.family-row-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.2;
}
.family-adult-line {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.35;
}

/* ---------- service request lists ---------- */
/* ul.service-list was never styled — default UA bullets + 40px indent
   showed on both views. Items carry inline borders from app.js. */
.service-list { list-style: none; padding: 0; margin: .75rem 0 0; }
.service-list .service-item { background: #fff; }



