@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ground: #ecebe6;
  --paper: #ffffff;
  --ink: #17181c;
  --ink-soft: #4a4b52;
  --rule: #dcdad3;
  --sun: #ffe36e;
  --danger: #b3261e;
  --swatch-ring: transparent;
  --radius: 16px;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121317;
    --paper: #1d1e23;
    --ink: #f2f1ec;
    --ink-soft: #b2b2ba;
    --rule: #33343b;
    --danger: #ff8a80;
    /* Keeps a black family color visible on dark chips. */
    --swatch-ring: rgba(255, 255, 255, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.45 "Figtree", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Shell: a bottom bar on phones, a side rail on wide screens. */
.shell { min-height: 100vh; }
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(110px + env(safe-area-inset-bottom));
}
nav.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 var(--rule);
}
nav.tabs button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 8px 2px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
nav.tabs button::before {
  content: "";
  width: 28px;
  height: 5px;
  border-radius: 3px;
  background: transparent;
}
nav.tabs button[aria-current="page"] { color: var(--ink); font-weight: 800; }
nav.tabs button[aria-current="page"]::before { background: var(--ink); }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--sun);
  color: #17181c;
  font-size: 12px;
  font-weight: 800;
}
nav.tabs .count { position: absolute; top: 2px; right: calc(50% - 30px); }

.fab {
  position: fixed;
  right: max(16px, calc(50% - 304px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: 18px;
  background: var(--ink);
  color: var(--ground);
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
}

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  nav.tabs {
    position: sticky;
    top: 0;
    inset: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 28px 16px;
    border-radius: 0;
    box-shadow: 1px 0 0 var(--rule);
  }
  nav.tabs::before {
    content: "Family Calendar";
    font: 800 22px/1.1 var(--display);
    color: var(--ink);
    padding: 0 12px 24px;
  }
  nav.tabs button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
    padding: 0 12px;
    font-size: 16px;
  }
  nav.tabs button::before { display: none; }
  nav.tabs button[aria-current="page"] { background: var(--ground); }
  nav.tabs .count { position: static; }
  main { max-width: 760px; padding: 36px 32px 120px; margin: 0; }
  .fab { right: 40px; bottom: 40px; }
}

/* Type */
h1 { font: 800 34px/1.1 var(--display); letter-spacing: -0.02em; margin: 4px 0 16px; }
h2 { font: 800 21px/1.2 var(--display); margin: 28px 0 10px; }
h3 { font-size: 17px; margin: 0; }
p { margin: 0 0 8px; }
.soft { color: var(--ink-soft); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }

/* Surfaces */
.panel { background: var(--paper); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.row > .grow, .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.two > * { min-width: 0; }

/* Controls */
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
textarea { min-height: 96px; resize: vertical; }
input[type="color"] { width: 48px; min-height: 48px; padding: 4px; flex: none; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--ground);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, .button.secondary { background: var(--ground); color: var(--ink); }
button.ghost { background: transparent; color: var(--ink); padding: 10px 12px; }
button.danger { background: transparent; color: var(--danger); padding: 10px 12px; }
button.wide { width: 100%; }
button:disabled { opacity: 0.55; cursor: progress; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Check boxes drawn as rounded squares in the person's color. */
.tick {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 26px;
  height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 3px solid var(--c, var(--ink));
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.tick:checked { background: var(--c, var(--ink)); }
.tick:checked::after {
  content: "";
  width: 7px;
  height: 12px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: translateY(-1px) rotate(45deg);
}
label.check { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--ink); font-size: 16px; font-weight: 500; cursor: pointer; }
.done { color: var(--ink-soft); text-decoration: line-through; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 12px; padding-inline: 16px; scrollbar-width: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; background: var(--c); box-shadow: 0 0 0 1px var(--swatch-ring); }
.who { display: grid; gap: 3px; padding-top: 5px; }

/* Calendar */
.title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.now-weather { font-size: 15px; color: var(--ink-soft); white-space: nowrap; }
.now-weather strong { font: 800 22px/1 var(--display); color: var(--ink); }
.nudge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--sun);
  color: #17181c;
  font-weight: 700;
}
.day { margin: 22px 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.day h2 { margin: 0; }
.dinner-link { background: transparent; color: var(--ink-soft); min-height: 40px; padding: 4px 0; font-weight: 600; font-size: 15px; }
.event {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  font-weight: 500;
  justify-content: flex-start;
  align-items: flex-start;
}
.event .time { width: 78px; flex: none; white-space: nowrap; font-weight: 800; font-size: 15px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.event .title { font-weight: 700; font-size: 17px; }
.empty-day { color: var(--ink-soft); font-size: 15px; margin: 0 0 8px; }

/* Home */
.segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 16px; background: var(--paper); margin-bottom: 16px; }
.segments button { min-height: 44px; background: transparent; color: var(--ink-soft); border-radius: 12px; }
.segments button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.kid { border-radius: var(--radius); overflow: hidden; background: var(--paper); margin-bottom: 12px; }
.kid > header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--c); color: var(--on, #fff); }
.kid > header h3 { font: 800 22px/1.1 var(--display); }
.kid > div { padding: 6px 16px 12px; }
.meal { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 12px; margin-bottom: 8px; }
.meal span { font-weight: 700; }
.meal.today span::after { content: " · today"; color: var(--ink-soft); font-weight: 500; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos div { position: relative; aspect-ratio: 1; }
.photos img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.photos button { position: absolute; top: 4px; right: 4px; min-height: 36px; padding: 4px 10px; background: rgb(0 0 0 / 0.65); color: #fff; font-size: 13px; }

/* Files: a styled label around the real input. */
.file { position: relative; display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px; border-radius: 14px; background: var(--ground); color: var(--ink); font-weight: 700; font-size: 16px; cursor: pointer; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Sheets */
dialog.sheet {
  width: min(560px, 100%);
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  color: var(--ink);
}
dialog.sheet::backdrop { background: rgb(20 20 24 / 0.45); }
dialog.sheet > div { padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); }
dialog.sheet header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
dialog.sheet header h2 { margin: 0; }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; } }
.menu { display: grid; gap: 8px; }
.menu button { justify-content: flex-start; text-align: left; background: var(--ground); color: var(--ink); min-height: 56px; font-size: 17px; }
.menu button small { margin-left: auto; color: var(--ink-soft); font-weight: 500; font-size: 14px; }

#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(160px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 420px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--ground);
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

.signin { min-height: 80vh; display: grid; align-content: center; justify-items: center; gap: 14px; text-align: center; }
.signin h1 { font-size: 44px; }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}

/* Who an event is for: chips that wrap inside the sheet instead of scrolling. */
.field { display: grid; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.field .soft { margin: 0; }
button.text-button { justify-self: start; background: transparent; color: var(--ink); padding: 4px 0; min-height: 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
[hidden] { display: none !important; }
.chips.wrap .chip:not([aria-pressed="true"]) { background: var(--ground); }

/* Calendar paging: Day, Week and Month, each with back, Today and forward. */
.pager { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.pager h2 { flex: 1; margin: 0; min-width: 0; font: 800 20px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager .step { width: 44px; height: 44px; padding: 0; border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 24px; line-height: 1; flex: none; }
.pager .today-button { min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--paper); color: var(--ink); flex: none; }
.pager .today-button:disabled { opacity: 0.45; cursor: default; }
.day.past, .day.past + .empty-day { opacity: 0.6; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month .dow { font-size: 12px; font-weight: 800; color: var(--ink-soft); text-align: center; padding: 2px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.month .cell {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px;
  min-height: 64px; padding: 6px; border-radius: 10px;
  background: var(--paper); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.month .cell.other { background: transparent; color: var(--ink-soft); }
.month .cell.past { opacity: 0.55; }
.month .cell.today { box-shadow: inset 0 0 0 2.5px var(--ink); }
.month .num { font: 800 15px/1 var(--display); }
.month .dots { display: flex; flex-wrap: wrap; gap: 3px; }
.month .dots .swatch { width: 8px; height: 8px; border-radius: 3px; }
.month .names { display: none; }
@media (min-width: 900px) {
  .month .cell { min-height: 112px; padding: 8px; }
  .month .dots { display: none; }
  .month .names { display: grid; gap: 3px; width: 100%; }
  .month .name { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; min-width: 0; }
  .month .name .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .month .name .swatch { width: 8px; height: 8px; border-radius: 3px; }
}

/* Chores that take turns: the order as color pills, this week's filled in. */
.turns h3 { font-size: 18px; }
.turns .chips { margin: 8px 0 6px; }
.turn { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 2px solid var(--c); font-size: 14px; font-weight: 700; color: var(--ink); }
.turn.now { background: var(--c); color: var(--on); }
.turns .two button { min-height: 44px; }
.segments.two-way { grid-template-columns: repeat(2, 1fr); margin-bottom: 4px; background: var(--ground); }
.turn-pos:not(:empty) { font-weight: 800; opacity: 0.8; }
button.chore-row { width: 100%; text-align: left; background: transparent; color: var(--ink); padding: 8px 0; border-radius: 0; font-weight: 400; }
button.choice { width: 100%; text-align: left; background: var(--ground); color: var(--ink); padding: 0 14px; border-radius: 12px; font-weight: 600; }
button.choice[aria-checked="true"] { outline: 2px solid var(--ink); background: var(--paper); }
