/* Family Calendar — warm paper-planner look. */
:root {
  --paper: #fdf8f2;
  --card: #fffdf9;
  --ink: #2b2118;
  --muted: #8a7a6a;
  --line: #e8ddd0;
  --coral: #d96a4f;
  --coral-dark: #b95136;
  --blue: #4a7fb5;
  --green: #4d8a5f;
  --purple: #7a5ea8;
  --amber: #c08a2d;
  --pink: #c05f8a;
  --teal: #3d8a8a;
  --grey: #7a756e;
  /* One spacing scale (4px base), one type scale, one radius scale. */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-brand: 24px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--coral-dark); outline-offset: 2px; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line);
  background: var(--card); flex-wrap: wrap;
}
.brand { display: flex; gap: var(--sp-3); align-items: center; }
.date-tile {
  flex: 0 0 auto; width: 42px; height: 44px;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.date-tile-month {
  background: var(--coral-dark); color: #fff; font-size: var(--fs-2xs); font-weight: bold;
  letter-spacing: 1px; text-transform: uppercase; text-align: center; padding: 2px 0 2px 1px; line-height: 1.2;
}
.date-tile-day { font-size: 20px; font-weight: bold; text-align: center; line-height: 1.25; padding-top: 1px; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: var(--fs-brand); letter-spacing: 0.5px; }
.subtitle { margin: 0; color: var(--muted); font-size: var(--fs-sm); font-style: italic; }
.top-actions { display: flex; gap: var(--sp-2); align-items: center; }
.top-actions .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.profile { position: relative; flex: 0 0 auto; }
.avatar-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--coral-dark);
  background: var(--coral-dark); color: #fff; font-weight: bold; font-size: var(--fs-md);
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.avatar-btn:hover { filter: brightness(0.92); }
.avatar-btn:focus-visible { outline: 2px solid var(--coral-dark); outline-offset: 2px; }
.profile-menu {
  position: absolute; right: 0; top: calc(100% + var(--sp-3)); z-index: 70;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(43, 33, 24, 0.18);
  min-width: 240px; max-width: calc(100vw - 24px); padding: var(--sp-4);
}
.profile-name { margin: 0; font-weight: bold; font-size: var(--fs-md); }
.profile-email { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.profile-role {
  display: inline-block; margin: var(--sp-2) 0 0; padding: 2px 10px;
  border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-xs); color: var(--muted);
}
.btn.menu-signout { width: 100%; margin-top: var(--sp-3); min-height: 44px; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); cursor: pointer;
  min-height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--coral); }
.btn-primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-danger { background: #fff; border-color: #c0392b; color: #c0392b; }
.btn-ghost { background: transparent; }
.toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5); flex-wrap: wrap;
  max-width: 1200px; width: 100%; margin: 0 auto;
}
.nav-group { display: flex; gap: var(--sp-2); }
.period-title { margin: 0; font-size: var(--fs-xl); text-align: center; }
.view-switch { display: flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.view-btn { border: 0; background: var(--card); padding: var(--sp-2) var(--sp-3); cursor: pointer; min-height: 40px; }
.view-btn.active { background: var(--coral); color: #fff; }
main { padding: 0 var(--sp-5) var(--sp-5); max-width: 1200px; margin: 0 auto; }
.status { color: var(--muted); font-style: italic; }
.hidden { display: none !important; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-2); }
/* A grid item's automatic minimum size is its content: a long nowrap chip
   would force its track wider and scroll the whole grid sideways (the
   360px bug). min-width: 0 on the items lets the tracks stay 1fr. */
.grid > * { min-width: 0; }
.dow {
  text-align: center; font-size: var(--fs-xs); letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted); padding: var(--sp-2) 0;
}
.day {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-2); cursor: pointer; text-align: left; display: block; width: 100%;
  /* Fixed shape (26 Nov 2026): a day tile never grows with its content.
     Chips are truncated and capped at 3 + a "+N more" line (app.js), so
     the content always fits the heights set below; overflow: hidden clips
     any excess. */
  overflow: hidden; min-width: 0;
}
/* Fixed tile heights — the natural height of a full tile (day number +
   3 chips + "+N more" + padding), so a full day fits exactly and an empty
   day keeps the same shape. The today circle (26px) is the binding
   constraint at desktop/tablet. */
#monthView .day { height: 140px; }
#weekView .day { height: 140px; }
.day:hover { border-color: var(--coral); }
.day.other-month { opacity: 0.45; }
/* Today: coral border + a filled coral circle on the date number (Apple/M3
   pattern) — recognisable by shape, not by colour alone. Week cells show
   "Tue 25", too long for a circle, so they get a tinted background instead. */
.day.today { border-color: var(--coral); }
#monthView .day.today .day-num {
  background: var(--coral-dark); color: #fff; border-radius: 50%;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
}
#weekView .day.today { background: #f6ddd2; border-left: 3px solid var(--coral); }
#weekView .day:hover { border-color: #cbb9a8; }
.day-num { font-weight: bold; font-size: var(--fs-md); }
.chip {
  display: block; margin-top: var(--sp-1); padding: 3px 6px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); line-height: 1.35; color: #fff; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; text-align: left; cursor: pointer; border: 0; width: 100%;
}
.chip.coral { background: var(--coral); } .chip.blue { background: var(--blue); }
.chip.green { background: var(--green); } .chip.purple { background: var(--purple); }
.chip.amber { background: var(--amber); } .chip.pink { background: var(--pink); }
.chip.teal { background: var(--teal); } .chip.grey { background: var(--grey); }
/* "+N more" is a <button>: display:block (an inline-block button sits on a
   line box whose strut adds ~5px) and nowrap+ellipsis (at 360px the cell
   is ~35px wide and "+1 more" would wrap to two lines and break the
   fixed tile height — the count stays readable as "+1…"). */
.more { display: block; font-size: var(--fs-2xs); color: var(--muted); margin-top: 2px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-day { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-lg); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.agenda-item {
  display: flex; gap: var(--sp-3); align-items: baseline; padding: var(--sp-2) var(--sp-1);
  border-bottom: 1px dashed var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left;
}
.agenda-item:hover { background: #f7ece2; }
.agenda-time { min-width: 92px; color: var(--muted); font-size: var(--fs-base); }
/* The agenda body is the flex item that must shrink: without min-width: 0
   a long unbroken title forces the row (and the page) wider at 360px. */
.agenda-body { min-width: 0; overflow-wrap: break-word; }
.agenda-title { font-weight: bold; }
.agenda-meta { color: var(--muted); font-size: var(--fs-sm); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.coral { background: var(--coral); } .dot.blue { background: var(--blue); }
.dot.green { background: var(--green); } .dot.purple { background: var(--purple); }
.dot.amber { background: var(--amber); } .dot.pink { background: var(--pink); }
.dot.teal { background: var(--teal); } .dot.grey { background: var(--grey); }
.empty { color: var(--muted); font-style: italic; padding: var(--sp-4) 0; }
.foot {
  display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5) var(--sp-6); color: var(--muted); font-size: var(--fs-sm);
  max-width: 1200px; margin: 0 auto;
}
/* Wall display */
.wall {
  position: fixed; inset: 0; z-index: 50; background: #201512; color: #fdf8f2;
  padding: 48px 6vw; overflow-y: auto; text-align: center;
}
.wall-close {
  position: absolute; top: 16px; right: 20px; font-size: 22px;
  background: transparent; border: 1px solid #fdf8f2; color: #fdf8f2;
  border-radius: var(--r-md); padding: 6px 12px; cursor: pointer; min-height: 44px; min-width: 44px;
}
.wall-clock { font-size: clamp(64px, 14vw, 150px); line-height: 1; letter-spacing: 2px; }
.wall-date { font-size: clamp(20px, 3.5vw, 32px); color: #e8c9b8; margin-top: 8px; }
.wall-heading { font-size: clamp(24px, 4vw, 40px); margin: 32px 0 8px; }
.wall-events { list-style: none; padding: 0; max-width: 760px; margin: 0 auto; text-align: left; }
.wall-events li { font-size: clamp(18px, 2.6vw, 26px); padding: 10px 4px; border-bottom: 1px solid #5a4038; overflow-wrap: break-word; }
.wall-events li.wall-error { color: #ffb4a0; border-bottom: none; }
.wall-events li.wall-stale { color: #c9a795; font-size: 16px; border-bottom: none; }
.wall-note { color: #c9a795; margin-top: 28px; }
/* Editor modal */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(32, 21, 18, 0.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 32px 12px; overflow-y: auto;
}
.modal-card {
  background: var(--card); border-radius: var(--r-lg); padding: var(--sp-5); width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.modal-card h2 { margin: 0 0 4px; }
.modal-card label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-base); color: var(--muted); }
.modal-card label.check { flex-direction: row; align-items: center; gap: var(--sp-2); color: var(--ink); }
.modal-card input, .modal-card select, .modal-card textarea {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 10px; background: #fff; color: var(--ink); width: 100%;
}
.form-row { display: flex; gap: var(--sp-3); }
.form-row label { flex: 1; }
.form-error { color: #c0392b; margin: 0; min-height: 1em; }
/* In-app confirmation bar (replaces window.confirm): sits inside the
   editor modal, above the action buttons. */
.confirm-bar {
  background: #fdf0e8; border: 1px solid var(--coral); border-radius: var(--r-md);
  padding: var(--sp-3);
}
.confirm-bar p { margin: 0 0 var(--sp-2); font-weight: bold; }
.confirm-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }
/* Shared hover tooltip for event chips: one fixed-position element, so it
   is never clipped by the fixed-height day tiles. Shown only on devices
   with a mouse (app.js gates on hover/pointer media queries); the text
   keeps its line breaks (title, time, location, notes). z-index sits
   below the editor modal (60) so a lingering tip can never cover it, and
   max-height + overflow keep a 1000-char note readable. */
.chip-tip {
  position: fixed; z-index: 55; max-width: 280px; max-height: 60vh; overflow-y: auto;
  background: #2b2118; color: #fffdf9;
  font-size: var(--fs-sm); line-height: 1.45; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  white-space: pre-line; overflow-wrap: break-word; pointer-events: none;
}
.modal-actions { display: flex; gap: var(--sp-2); align-items: center; }
.spacer { flex: 1; }
@media (max-width: 640px) {
  .topbar { padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); }
  .brand { flex: 1 1 auto; min-width: 0; gap: var(--sp-2); }
  .brand h1 { font-size: var(--fs-lg); }
  .subtitle { font-size: var(--fs-sm); }
  /* m5: shrink the tile on phones so the sticky header stays short. */
  .date-tile { width: 36px; height: 40px; }
  .date-tile-month { font-size: 10px; }
  .date-tile-day { font-size: 17px; }
  .profile { order: 2; }
  .top-actions { order: 3; flex: 1 1 100%; }
  .top-actions .btn { flex: 1 1 0; min-height: 44px; padding: var(--sp-2); }
  .toolbar { padding: var(--sp-2) var(--sp-3); }
  .period-title { font-size: var(--fs-lg); order: 3; width: 100%; }
  main { padding: 0 12px 16px; }
  .grid { gap: 4px; }
  .day { padding: var(--sp-1); }
  #monthView .day { height: 120px; }
  .day-num { font-size: var(--fs-sm); }
  #monthView .day.today .day-num { width: 22px; height: 22px; font-size: var(--fs-xs); }
  .chip { font-size: var(--fs-2xs); padding: 2px 5px; }
  /* Week view stacks into one full-width day row each on phones: 7 narrow
     columns are unreadable at 360px, a list is not (same events, same order). */
  #weekView .grid { grid-template-columns: 1fr; }
  /* Stacked week rows size to their content (an empty day stays a short
     row); the 3-chip cap bounds a busy day, so no fixed height is needed. */
  #weekView .day { height: auto; min-height: 0; }
  .foot { padding: 12px; font-size: var(--fs-xs); }
  /* Wall display at phone width: the clock clipped at 360px (64px minimum
     + letter-spacing overflowed the 6vw gutters) and event lines ran hard
     to the edge — shrink the clock, keep it on one line, tighten the
     gutters and the event text. */
  .wall { padding: 24px 16px; }
  .wall-clock { font-size: clamp(40px, 11vw, 64px); letter-spacing: 1px; white-space: nowrap; }
  .wall-date { font-size: 18px; }
  .wall-heading { font-size: 22px; margin: 20px 0 8px; }
  .wall-events li { font-size: 16px; padding: 10px 8px; }
  .wall-note { font-size: 13px; }
}
/* m4: tablet tier ends at 1023px so it cannot overlap the desktop tier at 1024px. */
@media (min-width: 641px) and (max-width: 1023px) {
  .topbar { padding: var(--sp-3) var(--sp-4); }
  .toolbar, main, .foot { padding-left: 16px; padding-right: 16px; }
  .brand h1 { font-size: var(--fs-xl); }
}
.storage-banner {
  background: #c0392b; color: #fff; border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3); font-weight: bold;
}


/* --- sign-in overlay --- */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); padding: 20px;
}
.login.hidden { display: none; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-6); max-width: 380px; width: 100%; text-align: center;
}
.login-card h2 { margin: 0 0 8px; font-size: var(--fs-brand); }
.login-card p { color: var(--muted); font-size: var(--fs-md); }
.login-card #googleBtn { display: flex; justify-content: center; margin: 16px 0 4px; }
.login-card #devLogin { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.login-card #devLogin input {
  width: 100%; padding: 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); color: var(--ink);
}

.owner-line { color: var(--muted); font-size: var(--fs-sm); font-style: italic; margin: 0 0 4px; }
