/* Apple's colours: iOS system backgrounds and greys here, system colours
   (with their dark-mode variants) written per person by the server in
   base.html. Dark is the default; Light, Automatic and your own background
   are one tap away. */
:root,
:root[data-theme="dark"] {
  /* iOS dark appearance: systemBackground, secondary/tertiary grouped, separator, labels */
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --line: #38383A;
  --text: #FFFFFF;
  --muted: #98989F;
  --warn: #FF9F0A;          /* systemOrange: flagged notes, high temperature */
  --warn-bg: #3A2A12;
  --good: #30D158;          /* systemGreen */
  --good-bg: #13301C;
  color-scheme: dark;
}
:root[data-theme="light"] {
  /* iOS light appearance: grouped background, white cells, systemGray5, separator */
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #E5E5EA;
  --line: #C6C6C8;
  --text: #000000;
  --muted: #6C6C70;
  --warn: #C93400;          /* systemOrange, accessible on white */
  --warn-bg: #FFEBD9;
  --good: #248A3D;          /* systemGreen, accessible on white */
  --good-bg: #DDF5E3;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #F2F2F7;
    --surface: #FFFFFF;
    --surface-2: #E5E5EA;
    --line: #C6C6C8;
    --text: #000000;
    --muted: #6C6C70;
    --warn: #C93400;
    --warn-bg: #FFEBD9;
    --good: #248A3D;
    --good-bg: #DDF5E3;
    color-scheme: light;
  }
}
/* Your own background: everything else is mixed from it and the text colour. */
:root[data-theme="custom"] {
  --surface: color-mix(in oklab, var(--bg) 90%, var(--text));
  --surface-2: color-mix(in oklab, var(--bg) 82%, var(--text));
  --line: color-mix(in oklab, var(--bg) 74%, var(--text));
  --muted: color-mix(in oklab, var(--text) 62%, var(--bg));
  --warn-bg: color-mix(in oklab, var(--bg) 78%, var(--warn));
  --good: color-mix(in oklab, #34c759 70%, var(--text));
  --good-bg: color-mix(in oklab, var(--bg) 80%, #34c759);
}
:root {
  --accent: #007aff;         /* systemBlue */
  --accent-ink: #fff;
  --font-size: 18px;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --tab-h: 64px;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(var(--font-size) * 0.8889); }
body {
  /* Accent as text: nudged towards the text colour so it reads on any background.
     Declared on body so a section's own accent flows into it. */
  --accent-text: color-mix(in oklab, var(--accent) 72%, var(--text));
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.warn { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- buttons ----------------------------------------------------------- */
button, .ghost, .primary {
  font: inherit;
  min-height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 1.1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.ghost { background: transparent; }
.danger { color: var(--warn); border-color: var(--warn-bg); }
.wide { width: 100%; }
button:disabled, button.htmx-request { opacity: .6; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- bottom tabs ------------------------------------------------------- */
.tabs {
  position: fixed; inset: auto 0 0 0;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.tabs a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .02em;
}
.tabs .ico { font-size: 1.25rem; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--tab-c, var(--accent-text)); box-shadow: inset 0 3px 0 var(--tab-c, var(--accent)); }

/* ---- Now --------------------------------------------------------------- */
.eyebrow { color: var(--muted); margin: .5rem 0 1rem; font-size: 1rem; }
.summary p { font-size: 1.25rem; line-height: 1.45; margin: 0 0 .7rem; }
.summary p.warn { color: var(--warn); }

.note {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-left: 4px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.note p { margin: 0 0 .5rem; font-size: 1.15rem; font-style: italic; }
.note cite { display: block; text-align: right; color: var(--muted); font-style: normal; font-size: .95rem; }
.note.flagged { background: var(--warn-bg); border-left-color: var(--warn); }
.note.flagged p { color: var(--warn); font-style: normal; font-weight: 600; }

.figures { margin: 2rem 0 1.5rem; }
.figures h2 { color: var(--muted); font-size: .9rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; }
.figures dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.figures dl div { background: var(--surface); border-radius: var(--radius); padding: .8rem; }
.figures dt { color: var(--muted); font-size: .9rem; }
.figures dd { margin: 0; font-size: 1.6rem; font-weight: 650; }

.now-actions { display: grid; gap: .6rem; }

/* ---- Log --------------------------------------------------------------- */
/* Buttons sit in the lower half so a thumb reaches them while holding a baby. */
.log .log-state {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: calc(100dvh - var(--tab-h) - 56px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
}
.recent { margin: 0; display: grid; gap: .5rem; }
.recent div { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.recent dt { color: var(--muted); }
.recent dd { margin: 0; text-align: right; }

.big-buttons { display: grid; gap: .75rem; padding-top: 2rem; }
.big-buttons form { margin: 0; }
.big {
  width: 100%;
  min-height: 80px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--surface-2);
}
.asleep { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .75rem;
  background: var(--surface); border-radius: var(--radius); padding: .5rem .5rem .5rem 1rem; }
.asleep .wake { width: auto; min-width: 9rem; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
[data-style="full"] .asleep .wake { background: var(--c-sleep); color: var(--c-sleep-ink); }
.asleep-text { font-size: 1.1rem; }
.more { min-height: 48px; font-size: 1.5rem; letter-spacing: .2em; }
.timer-badge { font-size: 1rem; font-weight: 600; color: inherit; letter-spacing: 0; }

/* ---- sheets ------------------------------------------------------------ */
dialog.sheet {
  margin: auto auto 0;
  width: 100%; max-width: 560px;
  max-height: 92dvh;
  padding: 1.25rem 16px calc(1rem + env(safe-area-inset-bottom));
  border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .6); }
dialog.sheet[open] { animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: .5; } }

form { display: grid; gap: 1rem; }
label { display: grid; gap: .3rem; color: var(--muted); font-size: .95rem; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 48px;
  padding: .5rem .75rem;
  width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
label.check { display: flex; align-items: center; gap: .6rem; color: var(--text); min-height: 48px; }
label.check input { width: 24px; min-height: 24px; height: 24px; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .75rem; align-items: end; }

fieldset { border: 0; margin: 0; padding: 0; }
fieldset legend { color: var(--muted); font-size: .95rem; margin-bottom: .3rem; }
.seg { display: flex; gap: 0; background: var(--bg); border-radius: var(--radius); padding: 4px; }
.seg.seg-wrap { flex-wrap: wrap; }
.seg legend { width: 100%; }
.seg label { flex: 1; display: block; color: var(--text); font-size: 1rem; }
.seg input { position: absolute; opacity: 0; width: 1px; min-height: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 10px; padding: 0 .5rem; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }

.timer { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--bg); border-radius: var(--radius); padding: .5rem .5rem .5rem 1rem; }
.timer output { font-size: 2rem; font-weight: 700; }
.timer.running output { color: var(--accent-text); }

.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: .75rem; margin-top: .5rem; }
.sheet-actions .primary { min-height: 60px; font-size: 1.15rem; }
.sheet-actions:has(> :only-child) { grid-template-columns: 1fr; }

.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; }
.more-grid button { min-height: 72px; }

/* ---- toast ------------------------------------------------------------- */
#toast {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none; z-index: 20; padding: 0 16px;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 1rem;
  background: var(--text); color: var(--bg);
  padding: .4rem .5rem .4rem 1.1rem; border-radius: 999px;
  font-weight: 600; box-shadow: 0 6px 24px rgb(0 0 0 / .5);
}
.toast-error { background: var(--warn); color: #fff; }
.toast-undo { background: transparent; border-color: transparent; color: inherit; text-decoration: underline; min-height: 44px; }

/* ---- timeline / edit --------------------------------------------------- */
.page-head { display: flex; align-items: baseline; gap: 1rem; }
.back { text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.day { margin-top: 1.5rem; }
.day h2 { position: sticky; top: 0; background: var(--bg); padding: .5rem 0; color: var(--muted); font-weight: 500; }
.day ol { list-style: none; margin: 0; padding: 0; }
.event {
  display: grid; grid-template-columns: 3.5rem 6.5rem 1fr; gap: .5rem; align-items: baseline;
  padding: .8rem .25rem; min-height: 48px;
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line);
}
.event time { font-weight: 650; }
.event .kind { color: var(--muted); font-size: .95rem; }
.event .who { display: block; color: var(--muted); font-size: .85rem; }
.event.flagged .what { color: var(--warn); }
@media (max-width: 380px) {
  .event { grid-template-columns: 3.2rem 1fr; }
  .event .kind { display: none; }
}

.edit-form { margin-top: 1rem; }
.login h1 { margin-top: 2rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- sections ---------------------------------------------------------- */
.help { color: var(--muted); font-size: .85rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.section-head .primary, .section-head .ghost { min-height: 44px; padding: 0 1rem; }
.lede { color: var(--muted); margin: 0 0 1rem; }
.card { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin: 0 0 .75rem; display: block;
  color: var(--text); text-decoration: none; }
.card h3 { margin: 0 0 .2rem; font-size: 1.1rem; }
.card p { margin: .2rem 0 0; }
.card.soon { border-left: 4px solid var(--accent); }
.card.done { opacity: .7; }
.card.alert { background: var(--warn-bg); border-left: 4px solid var(--warn); }
.card .meta { color: var(--muted); font-size: .95rem; }
.pill { display: inline-block; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.due { background: var(--warn-bg); color: var(--warn); }
h2.sub { color: var(--muted); font-size: .9rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  margin: 1.75rem 0 .6rem; }

.grid-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 1rem; min-height: 104px;
  display: flex; flex-direction: column; justify-content: space-between; color: var(--text); text-decoration: none; }
.tile .ico { font-size: 1.6rem; color: var(--accent-text); }
.tile strong { font-size: 1.1rem; }
.tile span.meta { color: var(--muted); font-size: .85rem; }

table.days { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.days th { color: var(--muted); font-weight: 500; font-size: .85rem; text-align: right; padding: .4rem .3rem; }
table.days th:first-child, table.days td:first-child { text-align: left; }
table.days td { text-align: right; padding: .6rem .3rem; border-top: 1px solid var(--line); }
table.days tr.today td { font-weight: 650; }

.figures dl.two { grid-template-columns: repeat(2, 1fr); }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0; }
.actions-row .primary, .actions-row .ghost, .actions-row button { min-height: 56px; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: .75rem 0; }
.gallery a, .gallery figure { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px;
  background: var(--surface-2); margin: 0; }
.gallery img, .gallery video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .badge { position: absolute; right: 6px; bottom: 6px; background: rgb(0 0 0 / .65); color: #fff;
  font-size: .75rem; padding: .1rem .4rem; border-radius: 6px; }
.moment-media { display: grid; gap: .75rem; margin: 1rem 0; }
.moment-media figure { margin: 0; }
.moment-media img, .moment-media video { width: 100%; border-radius: var(--radius); display: block; background: #000; }
.moment-media figcaption { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.moment-media figcaption form { display: block; }
.moment-media figcaption .ghost { min-height: 40px; font-size: .9rem; }
.upload { display: grid; gap: .5rem; background: var(--surface); padding: 1rem; border-radius: var(--radius); }
.upload input[type=file] { padding: .6rem; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.empty { color: var(--muted); padding: 1.5rem 0; }
.money-total { font-size: 2rem; font-weight: 700; }
.money-in { color: var(--good); }
.bar { height: 8px; border-radius: 4px; background: var(--accent); }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; margin: .6rem 0; }
.cat-row .bar-wrap { grid-column: 1 / -1; background: var(--surface-2); border-radius: 4px; }
.month-nav { display: flex; justify-content: space-between; align-items: center; margin: .5rem 0 1rem; }
.month-nav a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.tel { font-size: 1.1rem; font-weight: 650; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: 1rem; scrollbar-width: none; }
.chips a { white-space: nowrap; padding: 0 .9rem; min-height: 40px; display: inline-flex; align-items: center;
  border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .95rem; }
.chips a[aria-current] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.section-head:has(> h2.sub) { margin-top: 1.75rem; }
.section-head > h2.sub { margin: 0; }

/* ---- appearance -------------------------------------------------------- */
.appearance fieldset { display: grid; gap: .5rem; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: .6rem; }
.swatch { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: var(--sw);
  border: 3px solid transparent; box-shadow: inset 0 0 0 2px rgb(0 0 0 / .15); }
.swatch.on { border-color: var(--text); }
.swatch.any { position: relative; display: grid; place-items: center; overflow: hidden; font-size: .7rem; color: #fff;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch.any input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; cursor: pointer; }
.swatch.any span { text-shadow: 0 1px 2px #000; font-weight: 700; pointer-events: none; }
input[type=color] { padding: 2px; width: 56px; min-width: 56px; height: 44px; min-height: 44px; border-radius: 10px; cursor: pointer; }
.colour-row { display: flex; align-items: center; gap: .75rem; }
.section-colour { display: grid; grid-template-columns: auto 1fr auto auto; gap: .75rem; align-items: center; color: var(--text); }
.section-colour .ghost { min-height: 44px; padding: 0 .75rem; }
.dot-lg { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.preview-strip { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; background: var(--surface);
  padding: .75rem; border-radius: var(--radius); }
.preview-strip .primary { min-height: 40px; }

/* ---- baby header, notes, files ----------------------------------------- */
.baby-head { display: flex; align-items: center; gap: 1rem; margin: .25rem 0 .75rem; }
.baby-head h1 { margin: 0; line-height: 1.1; }
.baby-head p { margin: .1rem 0 0; }
.avatar { position: relative; width: 64px; height: 64px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--c-moments, var(--accent)));
  color: var(--accent-ink); font-size: 1.8rem; font-weight: 700; text-decoration: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.dot { display: none; width: 10px; height: 10px; border-radius: 50%; margin-right: .55rem; vertical-align: .1em; }
[data-style="full"] .summary .dot { display: inline-block; }
.note-link { display: block; color: inherit; text-decoration: none; }
.note .gallery { margin-top: .75rem; }
.compose { background: var(--surface); padding: 1rem; border-radius: var(--radius); }
dialog .compose { background: none; padding: 0; }
.compose .upload { background: var(--bg); }
.file-chip { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; margin-top: .5rem;
  padding: .6rem .75rem; min-height: 48px; border-radius: 10px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.file-ext { font-size: .75rem; font-weight: 700; padding: .2rem .4rem; border-radius: 6px; background: var(--accent); color: var(--accent-ink); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: .85rem; }

/* ---- full colour ------------------------------------------------------- */
[data-style="full"] .tile[style*="--tc"] { background: var(--tc); color: var(--tc-ink); }
[data-style="full"] .tile[style*="--tc"] .ico,
[data-style="full"] .tile[style*="--tc"] span.meta { color: inherit; opacity: .85; }
[data-style="full"] .big[style*="--tc"] { background: var(--tc); color: var(--tc-ink); border-color: transparent; }
[data-style="full"] .event .kind { color: var(--kc, var(--muted)); font-weight: 600; }

/* ---- shopping ---------------------------------------------------------- */
.quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.quick form { margin: 0; display: block; }
.chip { min-height: 40px; border-radius: 999px; padding: 0 .9rem; font-size: .95rem; background: var(--surface-2); }
.item { display: grid; gap: .6rem; }
.item.urgent { border-left: 4px solid var(--warn); }
.item-text { color: inherit; text-decoration: none; display: block; }
.tick { display: grid; grid-template-columns: 1fr auto; gap: .5rem; margin: 0; }
.tick input { min-height: 44px; }
.tick .primary { min-height: 44px; }
.tick form { margin: 0; display: block; }
.tick form button { width: 100%; min-height: 44px; }

/* ---- countdown to the due date ---------------------------------------- */
.countdown { background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 22%, var(--surface)),
  color-mix(in oklab, var(--c-moments, var(--accent)) 18%, var(--surface)));
  border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1.25rem; }
.countdown-big { font-size: 1.25rem; font-weight: 600; }
.countdown-big .num { font-size: 2.6rem; font-weight: 800; color: var(--accent-text); margin-right: .2rem; }
.countdown-live { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1rem; letter-spacing: .03em; min-height: 1.5em; }
.countdown-bar { height: 10px; border-radius: 5px; background: color-mix(in oklab, var(--text) 12%, transparent); margin: .75rem 0 .4rem; overflow: hidden; }
.countdown-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.countdown-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; margin: 0; font-size: .95rem; }
.countdown-meta span { white-space: nowrap; }
.countdown .help { margin: .5rem 0 0; }

/* ---- themes ------------------------------------------------------------ */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.theme-grid form { margin: 0; display: block; }
.theme-card { width: 100%; height: 100%; min-height: 0; padding: .5rem .5rem .7rem; display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start; gap: .35rem; text-align: left; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 40%, transparent); }
.theme-mini { position: relative; display: grid; gap: 6px; padding: 10px; height: 74px; border-radius: 10px;
  background: var(--tb); color: var(--tt); box-shadow: inset 0 0 0 1px rgb(127 127 127 / .25); overflow: hidden; }
.theme-mini[data-split] { background: linear-gradient(135deg, #f2f2f7 50%, #000000 50%); }
.theme-mini-dots { display: flex; gap: 4px; }
.theme-mini-dots i { width: 14px; height: 14px; border-radius: 50%; display: block; }
.theme-mini-line { height: 6px; width: 70%; border-radius: 3px; background: var(--tt); opacity: .55; }
.theme-mini-btn { position: absolute; right: 8px; bottom: 8px; font-size: .75rem; font-weight: 700; padding: .1rem .5rem;
  border-radius: 999px; background: var(--ta); color: var(--ti); }
.theme-name { font-weight: 650; font-size: .95rem; color: var(--text); }
.theme-tick { color: var(--accent-text); }
.theme-blurb { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.theme-button { margin-left: auto; width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%;
  font-size: 1.3rem; background: var(--surface); }
.text-colour { display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center; color: var(--muted); }
.text-colour label.check { min-height: 44px; }
.text-colour input[type=color]:disabled { opacity: .35; }
#sheet-themes .theme-grid { max-height: 60dvh; overflow-y: auto; padding: 2px; }

/* ---- alerts ------------------------------------------------------------ */
.alerts-banner { display: grid; gap: .5rem; margin: 0 0 1rem; }
.alert-row { display: grid; grid-template-columns: auto 1fr; gap: .75rem; align-items: center; padding: .7rem .9rem;
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: color-mix(in oklab, var(--ac, var(--accent)) 14%, var(--surface));
  border-left: 4px solid var(--ac, var(--accent)); }
.alert-row.is-due { background: color-mix(in oklab, var(--ac, var(--accent)) 30%, var(--surface)); }
.alert-row.is-due .alert-bell { animation: ring 1.2s ease-in-out 2; }
.alert-text { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .1rem .75rem; }
.alert-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.alert-row.is-due .alert-when { color: var(--text); font-weight: 650; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }
.rule-row { display: grid; gap: .3rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.rule-minutes { display: grid; grid-template-columns: 6rem 1fr; gap: .75rem; align-items: center; padding-left: 2.2rem; }
.push-card h3 { margin-bottom: .3rem; }
.device-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem 0; }
.device-row .ghost { min-height: 40px; }

/* ---- people ------------------------------------------------------------ */
.avatar-sm { width: var(--s); height: var(--s); border-radius: 50%; object-fit: cover; flex: none;
  display: inline-grid; place-items: center; vertical-align: middle; color: #fff; font-weight: 700;
  font-size: calc(var(--s) * .42); font-style: normal; line-height: 1; }
.by { display: inline-flex; align-items: center; gap: .4rem; }
cite.by { display: flex; justify-content: flex-end; }
.me-head { display: flex; align-items: center; gap: 1rem; margin: .5rem 0 1rem; }
.me-card { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; }
.me-card .meta { display: block; }
.me-card .chev { color: var(--muted); font-size: 1.6rem; }

/* ---- photo editor ------------------------------------------------------ */
.avatar-edit { position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; background: var(--surface-2); color: var(--text);
  box-shadow: 0 0 0 2px var(--bg); font-weight: 400; }
.photo-edit-link { position: relative; display: inline-block; text-decoration: none; }
.pe-current { display: grid; place-items: center; margin: .5rem 0 1.25rem; }
.pe-circle { width: 180px; height: 180px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--c-moments, var(--accent))); color: var(--accent-ink);
  font-size: 4.5rem; font-weight: 700; box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--accent); }
.pe-circle img { width: 100%; height: 100%; object-fit: cover; }
.pe-choices, .pe-crop { display: grid; gap: .75rem; }
.file-button { cursor: pointer; min-height: 56px; }
.pe-stage { position: relative; width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; touch-action: none;
  border-radius: 16px; overflow: hidden; background: #000; cursor: grab; }
.pe-stage:active { cursor: grabbing; }
.pe-stage canvas { width: 100%; height: 100%; display: block; }
.pe-mask { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle closest-side at center, transparent 99.4%, rgb(0 0 0 / .55) 100%); }
.pe-mask::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgb(255 255 255 / .85); }
.pick-moment { padding: 0; min-height: 0; aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 0; background: var(--surface-2); }
.pick-moment img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- feeling, get ready, what to expect --------------------------------- */
.moods { display: grid; grid-template-columns: repeat(5, 1fr); }
.moods label span { flex-direction: column; gap: .1rem; min-height: 64px; font-size: .85rem; padding: 0 .2rem; }
.moods .emoji { font-size: 1.5rem; font-weight: 400; line-height: 1; }
.ticks { display: flex; flex-wrap: wrap; gap: .4rem; }
.tick-chip { display: inline-flex; position: relative; }
.tick-chip input { position: absolute; opacity: 0; width: 1px; min-height: 0; }
.tick-chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .85rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: .95rem; }
.tick-chip input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tick-chip.urgent input:checked + span { background: var(--warn); color: #000; }
.tick-chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.urgent-ticks summary { cursor: pointer; color: var(--warn); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.urgent-card h3 { color: var(--warn); }
.urgent-card .actions-row .primary { background: var(--warn); border-color: var(--warn); color: #000; }
.checkin-mood { font-size: 1.1rem; margin: .4rem 0 .2rem; }
.share-card { margin-top: 1rem; }
.prep-row { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; padding: .7rem 0;
  border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.prep-row form { margin: 0; display: block; }
.prep-check { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--line);
  background: transparent; color: var(--accent-ink); font-weight: 800; }
.prep-row.is-done .prep-check { background: var(--accent); border-color: var(--accent); }
.prep-row.is-done strong { text-decoration: line-through; color: var(--muted); }
.prep-text { display: grid; gap: .15rem; }
.prep-text .meta { font-size: .9rem; }
.prep-actions { display: flex; gap: .3rem; }
.prep-actions .ghost { min-height: 40px; padding: 0 .6rem; }
.briefing h3 { margin: 1rem 0 .3rem; font-size: 1.05rem; color: color-mix(in oklab, var(--c-expect) 65%, var(--text)); }
.briefing h3:first-of-type { margin-top: .4rem; }
.briefing p, .briefing li { line-height: 1.5; }
.briefing ul { padding-left: 1.2rem; margin: .3rem 0; }
.cite a { text-decoration: none; font-size: .75em; padding: 0 .15em; }
.sources { padding-left: 1.4rem; display: grid; gap: .4rem; font-size: .95rem; }
.sources li:target { background: color-mix(in oklab, var(--accent) 20%, transparent); border-radius: 6px; }
.disclaimer { margin-top: 1rem; }

/* ---- ask chat ---------------------------------------------------------- */
.chat { display: grid; gap: .9rem; margin: .5rem 0 1rem; }
.chat-q, .chat-a { display: grid; gap: .3rem; scroll-margin-top: 80px; }
.chat-q { justify-items: end; }
.chat-who { font-size: .9rem; }
.bubble { padding: .7rem .95rem; border-radius: 18px; max-width: 92%; line-height: 1.45; }
.bubble.mine { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.bubble.theirs { background: var(--surface); border-bottom-left-radius: 6px; }
.bubble p { margin: 0 0 .5rem; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: .3rem 0; padding-left: 1.2rem; }
.chat-star { margin: 0; }
.chat-star .ghost { min-height: 36px; font-size: .85rem; padding: 0 .7rem; }
.chat-star .ghost.on { color: var(--c-diary, var(--accent)); border-color: currentColor; }
.chat-a .sources { font-size: .85rem; margin: .2rem 0 0; }
.ask-box textarea { min-height: 5rem; }
.midwife-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center; padding: .6rem 0;
  border-bottom: 1px solid var(--line); }
.midwife-row form { margin: 0; }
.midwife-row .ghost { min-height: 40px; }
.appt-questions { margin: .6rem 0 .2rem; padding: .6rem .75rem; border-radius: 10px; background: var(--surface-2); }
.appt-questions ul { margin: .3rem 0; padding-left: 1.2rem; }
.channel-table { width: 100%; border-collapse: collapse; }
.channel-table th { color: var(--muted); font-weight: 500; font-size: .85rem; text-align: center; padding: .3rem; }
.channel-table td { padding: .5rem .3rem; border-top: 1px solid var(--line); }
.channel-table td:not(:first-child) { text-align: center; width: 4.5rem; }
.channel-table input[type=checkbox] { width: 24px; height: 24px; min-height: 24px; accent-color: var(--accent); }

/* ---- read aloud -------------------------------------------------------- */
.listen-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: -.25rem 0 1rem; }
.listen { min-height: 44px; padding: 0 1rem; border-radius: 999px; }
.listen-big { min-height: 52px; font-weight: 650; background: var(--c-expect, var(--accent)); color: var(--c-expect-ink, #fff);
  border-color: transparent; }
.listen.is-playing { background: var(--warn); color: #000; border-color: transparent; }
.voice-settings summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.voice-settings[open] { width: 100%; display: grid; gap: .5rem; background: var(--surface); padding: .75rem; border-radius: var(--radius); }
.briefing-teaser { display: grid; gap: .5rem; }
.briefing-teaser .teaser-link { color: inherit; text-decoration: none; }
.briefing-teaser .listen { justify-self: start; min-height: 40px; }
.chat-a .listen { justify-self: start; min-height: 36px; font-size: .85rem; padding: 0 .8rem; }

/* ---- letterhead -------------------------------------------------------- */
/* Apple's large-title header: small grey date, big bold name, the page in its
   tint colour, the profile photo at top right. System font throughout. */
.letterhead { margin: 0 0 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.lh-row { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; }
.lh-text { min-width: 0; }
.lh-date { font-size: .8rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.lh-name { margin: .1rem 0 0; font-size: 2.1rem; font-weight: 700; line-height: 1.12; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lh-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; margin-top: .15rem; font-size: 1rem; }
.lh-section { font-weight: 600; color: var(--lh); }
.lh-stage { color: var(--muted); }
.lh-stage::before { content: "·"; margin-right: .5rem; color: var(--muted); }
.lh-sub > .lh-stage:first-child::before { content: none; }
.lh-actions { display: flex; align-items: center; gap: .5rem; flex: none; padding-bottom: .2rem; }
.lh-theme { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; font-size: 1rem;
  background: var(--surface-2); border-color: transparent; }
.lh-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  text-decoration: none; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 1.15rem; }
.lh-avatar img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 360px) { .lh-name { font-size: 1.75rem; } }

