/* ============================================================
   FamilyHub styles, using the Gift Registry look: warm cream
   background, plum text, a berry accent, serif headings, rounded
   "pill" buttons and tabs, and soft white cards.
   Works on phones and computers, with automatic dark mode.
   ============================================================ */

:root {
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-2: #f6f0e9;
  --ink: #2b2230;
  --ink-soft: #6f6475;
  --line: #e7dfd6;
  --brand: #b23a5b;          /* the Gift Registry berry */
  --brand-ink: #ffffff;
  --brand-soft: #f8e4ea;
  --accent: #a8741a;         /* gold */
  --accent-soft: #f7ecd6;
  --pos: #2f7a55;
  --pos-soft: #e2f1e9;
  --neg: #b3261e;
  --warn-bg: #f7ecd6;
  --err-bg: #fbe5e3;
  --ok-bg: #e2f1e9;
  --shadow: 0 1px 2px rgba(43, 34, 48, .06), 0 6px 20px rgba(43, 34, 48, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sans: var(--sans-base);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b161f; --surface: #26202b; --surface-2: #2f2834; --ink: #f3ecf4; --ink-soft: #b3a7b8; --line: #3a313f;
    --brand: #e8789a; --brand-ink: #2a0f18; --brand-soft: #46232f;
    --accent: #e6b961; --accent-soft: #3f3220;
    --pos: #7fd0a5; --pos-soft: #1f3a2d; --neg: #ff8a80;
    --warn-bg: #3f3220; --err-bg: #45211f; --ok-bg: #1f3a2d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }

h1, h2, h3, .brand { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; overflow-wrap: anywhere; }
p { margin: .4rem 0 .75rem; overflow-wrap: anywhere; }
a { color: var(--brand); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
[hidden] { display: none !important; }
small, .small { font-size: .85rem; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--ink-soft); font-size: .88rem; margin-top: .75rem; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 700; color: var(--brand); margin: 0 0 .2rem; }
.link { font-weight: 600; text-decoration: none; font-size: .9rem; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }
.field { margin-bottom: .8rem; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea {
  display: block; width: 100%; margin-top: .25rem;
  font: inherit; font-weight: 400; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .75rem; min-height: 42px;
}
textarea { resize: vertical; }
/* Phones: boxes never poke out of their card. Date and time boxes have a built-in minimum width on some
   phones (Android, iOS), so that is switched off and they shrink like the others. */
input, select, textarea { max-width: 100%; min-width: 0; }
input[type=date], input[type=time], input[type=datetime-local], input[type=month], input[type=week] {
  -webkit-appearance: none; appearance: none; min-width: 0; text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; }
select { text-overflow: ellipsis; }
.card, .modal, .two-col > *, .row-2 > *, label, .field { min-width: 0; }
.card { overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; cursor: pointer; }
label.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); margin: .2rem 0 0; flex: none; }
.row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .8rem; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .5rem; }
.validation-message { color: var(--neg); font-size: .85rem; margin: -.5rem 0 .75rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand);
  border-radius: 999px; padding: .6rem 1.1rem; min-height: 42px;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-small { padding: .35rem .8rem; min-height: 34px; font-size: .88rem; }
.btn-big { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; margin-top: .5rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-soft); filter: none; }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--neg); border-color: var(--line); }
.btn-danger-ghost:hover { border-color: var(--neg); filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.small-gap { margin-top: .5rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1.1rem; cursor: pointer; flex: none; padding: 0;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.small { width: 30px; height: 30px; font-size: .9rem; border-color: transparent; background: transparent; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: .7rem .9rem; margin-bottom: 1rem; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-error { background: var(--err-bg); color: var(--neg); }
.alert-ok { background: var(--ok-bg); color: var(--pos); }
.alert-warn, .banner { background: var(--warn-bg); }
.banner { border-radius: var(--radius-sm); padding: .7rem 1rem; margin-bottom: 1rem; }
.ok-line { font-weight: 600; color: var(--pos); }

/* ---------- Top bar (same as Gift Registry) ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem max(16px, calc((100% - 1080px) / 2)); padding-top: calc(.7rem + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .45rem; margin: 0; text-decoration: none; color: var(--ink); font-size: 1.25rem; }
.brand-mark-wrap { display: inline-flex; }
.tabs { display: flex; gap: .2rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .me {
  padding: .45rem .85rem; border-radius: 999px; color: var(--ink-soft); text-decoration: none; white-space: nowrap; font-weight: 600; font-size: .95rem;
}
.tabs a:hover, .me:hover { color: var(--ink); background: var(--bg); }
.tabs a.active { color: var(--brand); background: var(--brand-soft); }
.top-actions { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; color: var(--ink-soft); text-decoration: none;
}
.bell:hover, .bell.active { background: var(--brand-soft); color: var(--brand); }
.bell svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: 2px; right: 0; min-width: 1.2rem; padding: 0 .3rem; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-size: .7rem; font-weight: 700; text-align: center; line-height: 1.2rem;
}
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.me { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); color: var(--ink); }
.menu[open] .me { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.me-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.caret { font-size: .7rem; color: var(--ink-soft); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .45rem); z-index: 40; min-width: 230px; padding: .45rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 34px rgba(43, 34, 48, .16);
}
.menu-panel a { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.menu-panel a:hover { background: var(--bg); }
.menu-panel a.active { background: var(--brand-soft); color: var(--brand); }
.menu-who { padding: .45rem .7rem .55rem; border-bottom: 1px solid var(--line); margin-bottom: .2rem; }
.menu-who strong, .menu-who small { display: block; }
.menu-who small { color: var(--ink-soft); }
.menu-heading { padding: .55rem .7rem .15rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.count { margin-left: auto; background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .72rem; padding: 0 .45rem; line-height: 1.25rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

.public-nav { display: flex; align-items: center; gap: 1rem; margin-left: auto; font-weight: 600; }
.public-nav a:not(.btn) { text-decoration: none; color: var(--ink); }

/* ---------- Page ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-intro { max-width: 70ch; margin-top: -.25rem; color: var(--ink-soft); }
.footer { text-align: center; padding: 2rem 1rem; color: var(--ink-soft); font-size: .9rem; }

/* ---------- Welcome page ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2rem; align-items: center; padding: 2rem 0 2.5rem; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.1rem); }
.lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 36ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.4rem; }
.hero-art { display: grid; gap: .7rem; }
.mini-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem 1.1rem;
  display: flex; align-items: center; gap: .6rem; font-weight: 600; border-left: 4px solid var(--brand); }
.mini-card:nth-child(2) { margin-left: 2rem; border-left-color: var(--accent); }
.mini-card:nth-child(3) { border-left-color: var(--pos); }
.mini-card:nth-child(4) { margin-left: 1rem; border-left-color: #7a5fb5; }
.mini-card small { color: var(--ink-soft); font-weight: 400; }
.mini-card i { width: 10px; height: 10px; border-radius: 50%; margin-left: auto; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: .9rem; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); border-top: 4px solid var(--brand); }
.feature:nth-child(3n+2) { border-top-color: var(--accent); }
.feature:nth-child(3n) { border-top-color: var(--pos); }
.feature > span { font-size: 1.5rem; }
.feature h3 { margin: .3rem 0 .3rem; }
.feature p { color: var(--ink-soft); margin: 0; }

.auth-card { width: min(440px, 100%); margin: 2.5rem auto; padding: 1.8rem; }
.auth-card h1 { font-size: 1.7rem; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card.narrow { max-width: 640px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.section-head h2, .section-head h3 { margin: 0; }
.empty-state { text-align: center; padding: 2rem 1.25rem; }
.empty-emoji { font-size: 2.5rem; }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); padding: 2rem 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.two-col > .card { margin-bottom: 0; }
.two-col + .two-col, .two-col + .card, .two-col + .hint { margin-top: 1rem; }

/* ---------- Dashboard ---------- */
.daily-cards { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.daily-cards .card { margin: 0; }
.card-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 700; color: var(--accent); margin-bottom: .5rem; }
.quote-card { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.quote-card .card-kicker { color: var(--brand-ink); opacity: .8; }
.quote-card blockquote { margin: 0 0 .6rem; font-family: var(--serif); font-size: clamp(1.15rem, 2.2vw, 1.45rem); line-height: 1.35; }
.quote-card figcaption { font-weight: 700; opacity: .9; }
.quote-card .credit { display: block; margin-top: .6rem; opacity: .75; }
.quote-card .credit a { color: inherit; }
.word { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; }
.pos-tag { font-family: var(--sans); font-size: .85rem; font-style: italic; color: var(--ink-soft); font-weight: 600; }
.meaning { margin: .3rem 0; font-weight: 600; }
.example { color: var(--ink-soft); font-style: italic; margin: 0; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.dash-grid .card { margin: 0; }
.member-stack { display: flex; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--c, var(--brand)); color: #fff; font-weight: 700; text-decoration: none; flex: none;
  border: 2.5px solid var(--bg);
}
.member-stack .avatar + .avatar { margin-left: -8px; }
.avatar.big { width: 64px; height: 64px; font-size: 1.6rem; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 1rem; }
.quick { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.1rem; margin: 0; }

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-day + .agenda-day { margin-top: .75rem; }
.agenda-date { display: block; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: .25rem; }
.agenda ul { list-style: none; margin: 0; padding: 0; }
.agenda li li, .agenda.flat li {
  display: flex; align-items: baseline; gap: .6rem; padding: .45rem .6rem; border-left: 4px solid var(--c, var(--brand));
  background: var(--surface-2); border-radius: 0 8px 8px 0; margin-bottom: .35rem;
}
.agenda small { margin-left: auto; }
.agenda-time { font-weight: 700; min-width: 3.4rem; font-size: .9rem; }

.progress, .bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .25rem 0 .75rem; }
.progress span, .bar span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .3s ease; }
.bar.over span { background: var(--neg); }

.pill-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.pill-list li { background: var(--surface-2); border-radius: 999px; padding: .25rem .7rem; font-weight: 700; font-size: .9rem; }
.quick-add { display: flex; gap: .5rem; align-items: center; }
.quick-add input { margin: 0 !important; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .5rem; }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats b { font-size: 1.1rem; }

/* ---------- Share toggle ---------- */
.share-toggle { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; cursor: pointer; margin: 0; }
.share-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.share-toggle .track { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.share-toggle .thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.share-toggle.on .track { background: var(--brand); }
.share-toggle.on .thumb { transform: translateX(18px); }
.share-toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-soft); }
.share-label { font-size: .9rem; }
.share-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem; margin: .25rem 0 1rem; display: grid; gap: .5rem; }
.share-box label.check { margin: 0; }

/* ---------- Calendar ---------- */
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(min(280px, 100%), 1fr); gap: 1rem; align-items: start; }
.calendar-layout .card { margin: 0; }
.month-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.month-head h2 { margin: 0; min-width: 9.5rem; text-align: center; }
.month-head label.check { margin: 0; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; padding: .25rem 0; }
.day-cell {
  min-height: 96px; display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left;
  font: inherit; color: var(--ink); background: var(--surface-2); border: 2px solid transparent; border-radius: 10px;
  padding: 4px; cursor: pointer; overflow: hidden;
}
.day-cell:hover { border-color: var(--line); }
.day-cell.other { opacity: .45; }
.day-cell.selected { border-color: var(--brand); }
.day-cell.today .day-num { background: var(--brand); color: var(--brand-ink); }
.day-num { font-weight: 700; font-size: .85rem; width: 1.6rem; height: 1.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.chip { display: block; font-size: .72rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 18%, var(--surface)); border-left: 3px solid var(--c); border-radius: 4px; padding: 1px 4px; }
.chip b { font-weight: 700; }
.more { font-size: .7rem; color: var(--ink-soft); font-weight: 700; padding-left: 2px; }
.dots { display: none; gap: 3px; justify-content: center; margin-top: auto; }
.dots i { width: 6px; height: 6px; border-radius: 50%; }

.day-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; }
.day-card-head h2 { margin: 0; }
.day-card-head p { margin: 0; }
.empty-line { padding: 1rem 0; }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.event-item { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem; border-radius: 10px;
  background: var(--surface-2); border-left: 4px solid var(--c, var(--brand)); }
.event-time { min-width: 3.4rem; font-weight: 700; font-size: .9rem; display: flex; flex-direction: column; }
.event-time small { color: var(--ink-soft); font-weight: 600; }
.event-body { flex: 1; min-width: 0; }
.event-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .82rem; color: var(--ink-soft); margin-top: .15rem; }
.event-notes { font-size: .88rem; margin: .3rem 0 0; color: var(--ink-soft); white-space: pre-line; }
.who-tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 999px; padding: 0 .5rem; }

@media (max-width: 1000px) {
  .calendar-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .day-cell { min-height: 54px; align-items: center; padding: 3px 1px; }
  .day-cell .chip, .day-cell .more { display: none; }
  .day-cell .dots { display: flex; }
  .month-head h2 { min-width: 0; font-size: 1.1rem; }
}

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(30, 20, 35, .5); z-index: 50; }
.modal {
  position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 1.25rem;
}
.modal-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }

/* ---------- Chores ---------- */
.chore-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.chore { display: flex; align-items: flex-start; gap: .7rem; padding: .55rem .6rem; border-radius: 10px; background: var(--surface-2); }
.chore-list.compact .chore { padding: .4rem .45rem; gap: .5rem; }
.tick {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2.5px solid var(--c, var(--brand)); background: var(--surface);
  color: #fff; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.done .tick { background: var(--c, var(--brand)); }
.chore-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chore-title { font-weight: 700; }
.done .chore-title { text-decoration: line-through; color: var(--ink-soft); }
.chore-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; color: var(--ink-soft); }
.chore-notes { font-size: .85rem; color: var(--ink-soft); }
.celebrate { margin-top: .75rem; font-weight: 700; color: var(--pos); }
h3.sub { margin-top: 1.25rem; font-size: 1rem; }

.day-picker, .people-picker, .colour-picker { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.day-chip, .person-chip {
  font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; border-radius: 999px; padding: .35rem .8rem; min-height: 36px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.day-chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.person-chip { border-color: var(--c); }
.person-chip.on { background: var(--c); color: #fff; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--ink); }

.date-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.date-label { font-weight: 700; min-width: 9rem; text-align: center; }
.today-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.today-layout .card { margin: 0; }
.today-layout + .card { margin-top: 1rem; }

.week-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.week-day { margin: 0; padding: .9rem; min-height: 140px; }
.week-day h3 { font-size: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.week-day h3 small { font-family: var(--sans); color: var(--ink-soft); font-weight: 700; }
.week-day.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.week-day.anyday { background: var(--accent-soft); }
.week-bottom { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.week-bottom .card { margin: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }

/* ---------- Shopping ---------- */
.add-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.add-row input, .add-row select { margin: 0 !important; width: auto; }
.add-row .grow { flex: 1 1 220px; }
.add-row .qty { flex: 0 1 120px; }
.add-row select { flex: 0 1 160px; }
.shop-group h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-family: var(--sans); font-weight: 700; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.shop-list li:last-child { border-bottom: 0; }
.shop-name { flex: 1; font-weight: 700; cursor: pointer; }
.qty-tag { background: var(--surface-2); border-radius: 999px; padding: 0 .5rem; margin-left: .3rem; font-weight: 700; }
.shop-list li.done .shop-name { text-decoration: line-through; color: var(--ink-soft); }
.shop-list li.done .tick { background: var(--brand); }
.shop-edit { flex-wrap: wrap; }
.shop-edit input, .shop-edit select { width: auto; flex: 1 1 140px; margin: 0 !important; }
.shop-edit .qty { flex: 0 1 100px; }
.bought { opacity: .85; }

/* ---------- Budget ---------- */
.month-switch { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.month-switch h2 { margin: 0; min-width: 10rem; text-align: center; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column; }
.stat-label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.budget-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.budget-layout .card { margin: 0; }
.budget-layout + .card { margin-top: 1rem; }
.seg { display: inline-flex; flex-wrap: wrap; gap: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .25rem; margin-bottom: .75rem; }
.seg button { font: inherit; font-weight: 700; border: 0; background: transparent; color: var(--ink-soft); border-radius: 999px; padding: .4rem 1rem; cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.cat-line { display: flex; justify-content: space-between; gap: .5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-list .bar { margin: .25rem 0 0; }
.income-line { padding-top: .35rem; border-top: 1px dashed var(--line); }
.cat-edit { width: 100%; border-collapse: collapse; }
.cat-edit td { padding: .25rem .2rem; vertical-align: middle; }
.cat-edit input, .cat-edit select { margin: 0 !important; min-height: 38px; padding: .35rem .5rem; }
.cat-edit td.kind { font-size: .8rem; font-weight: 700; color: var(--ink-soft); width: 2.5rem; text-align: center; }
.cat-edit td.actions { white-space: nowrap; width: 1%; }
.cat-edit td:nth-child(3) { width: 7.5rem; }
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.entry-list li:last-child { border-bottom: 0; }
.entry-date { font-weight: 700; font-size: .85rem; color: var(--ink-soft); min-width: 3.5rem; }
.entry-desc { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-actions { display: flex; }

/* ---------- Family ---------- */
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.invite-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 2rem; font-weight: 700; letter-spacing: .2em;
  background: var(--accent-soft); color: var(--accent); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: .6rem; text-align: center; margin: .5rem 0; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.member-link { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); flex: 1; }
.member-link small { display: block; }
.member-actions { display: flex; gap: .3rem; }
.confirm { width: 100%; background: var(--err-bg); border-radius: var(--radius-sm); padding: .6rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-weight: 700; }
.danger-zone { margin-top: 1rem; }
.person-head { display: flex; align-items: center; gap: .9rem; }
.chore-form h3 { margin-bottom: .75rem; }

/* ---------- Notifications ---------- */
.note-list { list-style: none; padding: 0; }
.note-list li + li { border-top: 1px solid var(--line); }
.note-list a { display: flex; flex-direction: column; padding: .75rem .5rem; text-decoration: none; color: var(--ink); border-radius: 8px; }
.note-list a:hover { background: var(--surface-2); }
.note-list li.unread a { background: var(--brand-soft); }
.note-list li.unread strong::before { content: "● "; color: var(--brand); }

/* ---------- Terms ---------- */
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.5rem; }
.prose ul { padding-left: 1.3rem; }

/* ---------- Blazor error bar ---------- */
#blazor-error-ui {
  background: var(--warn-bg); color: var(--ink); bottom: 0; box-shadow: 0 -1px 4px rgba(0,0,0,.2);
  display: none; left: 0; padding: .75rem 1.25rem; position: fixed; width: 100%; z-index: 1000; font-weight: 700;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

/* ---------- Phones ---------- */
@media (max-width: 1100px) {
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .daily-cards, .dash-grid, .two-col, .today-layout, .budget-layout, .week-bottom, .hero { grid-template-columns: minmax(0, 1fr); }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-card:nth-child(n) { margin-left: 0; }
}
@media (max-width: 520px) {
  .row-2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .week-grid { grid-template-columns: minmax(0, 1fr); }
  .week-day { min-height: 0; }
  .card { padding: 1rem; }
  .stat-value { font-size: 1.1rem; }
  .invite-code { font-size: 1.5rem; }
  .page-head { align-items: flex-start; }
}

/* ---------- Phones: tabs move to their own row and scroll sideways (as in Gift Registry) ---------- */
@media (max-width: 760px) {
  .top { gap: .5rem .8rem; padding-bottom: .5rem; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -4px; }
  .me-name { max-width: 6.5rem; }
  h1 { font-size: 1.6rem; }
  .page { padding-top: 1.1rem; }
}
@media (max-width: 420px) {
  .me-name { display: none; }
  .public-nav { gap: .6rem; }
}

/* ============================================================
   Themes (chosen in Settings). The page is wrapped in .theme-root;
   a theme sets the colours on it, and everything inside follows.
   ============================================================ */
.theme-root { min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--sans); }
.theme-root.has-colours {
  --brand: var(--theme-main); --brand-ink: var(--theme-main-ink, #fff);
  --brand-soft: color-mix(in srgb, var(--theme-main) 15%, var(--surface));
  --accent: var(--theme-accent); --accent-soft: color-mix(in srgb, var(--theme-accent) 16%, var(--surface));
  --warn-bg: var(--accent-soft);
}
.theme-root.has-colours:not(.kids):not(.theme-custom) {
  --surface-2: color-mix(in srgb, var(--theme-main) 7%, var(--surface));
  --line: color-mix(in srgb, var(--theme-main) 14%, #e4e0e6);
}
@media (prefers-color-scheme: dark) {
  .theme-root.has-colours:not(.kids):not(.theme-custom) { --line: color-mix(in srgb, var(--theme-main) 25%, #3a313f); }
}
@media (prefers-color-scheme: dark) {
  /* Everyday themes follow dark mode: colours are lightened so they stay readable. */
  .theme-root.has-colours:not(.kids) {
    --brand: color-mix(in srgb, var(--theme-main) 62%, #fff); --brand-ink: #1b161f;
    --brand-soft: color-mix(in srgb, var(--theme-main) 28%, var(--surface));
    --accent: color-mix(in srgb, var(--theme-accent) 62%, #fff);
    --accent-soft: color-mix(in srgb, var(--theme-accent) 22%, var(--surface));
  }
}

/* Fun themes: their own background picture, font and chunkier shapes. */
.theme-root.theme-sea {
  --bg: #d9f3f7; --surface: #f5fdff; --surface-2: #e3f6fa; --ink: #0b3a4a; --ink-soft: #4a7684; --line: #b9e2ea;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, #e3f8fb 0%, #bfe9f1 60%, #9ad8e6 100%);
  background-attachment: fixed;
}
.theme-root.theme-pirates {
  --bg: #f1e2c2; --surface: #fbf3e1; --surface-2: #f3e6c8; --ink: #3b2414; --ink-soft: #7a5b3f; --line: #dcc59a;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: Georgia, var(--sans-base); --serif: "Trattatello", "Papyrus", "Luminari", Georgia, serif;
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, #f6e9cc 0%, #ead6ab 100%);
  background-attachment: fixed;
}
.theme-root.theme-princess {
  --bg: #fde7f2; --surface: #fff7fb; --surface-2: #fcebf4; --ink: #4a1d3a; --ink-soft: #8a5b78; --line: #f5c8de;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, #fff0f7 0%, #fadcec 100%);
  background-attachment: fixed;
}
.theme-root.theme-space {
  --bg: #141a3a; --surface: #1f2752; --surface-2: #29325f; --ink: #eef0ff; --ink-soft: #aab2e0; --line: #38427a;
  --pos: #7fd0a5; --neg: #ff8a80;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: dark;
  background: var(--pattern-img, none) 0 0 / 180px 180px, radial-gradient(ellipse at top, #26306a 0%, #141a3a 60%, #0b0f26 100%);
  background-attachment: fixed;
}
.theme-root.theme-dinosaurs {
  --bg: #eef5dc; --surface: #fbfdf4; --surface-2: #eef4dc; --ink: #2c3a18; --ink-soft: #62704a; --line: #d3e2b0;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, #f3f8e4 0%, #dfecbf 100%);
  background-attachment: fixed;
}
.theme-root.theme-unicorns {
  --bg: #f6efff; --surface: #ffffff; --surface-2: #f6f0ff; --ink: #3a2457; --ink-soft: #7a689a; --line: #e5d6fb;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(135deg, #ffe9f4 0%, #f1e6ff 35%, #e3f1ff 70%, #eafff3 100%);
  background-attachment: fixed;
}
.theme-root.theme-superheroes {
  --bg: #fdf1d6; --surface: #ffffff; --surface-2: #fdf4dc; --ink: #1d1a33; --ink-soft: #5c5873; --line: #f0dba5;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Avenir Next Condensed", "Arial Narrow", var(--sans-base); --serif: "Impact", "Avenir Next Condensed", "Arial Black", sans-serif;
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, radial-gradient(circle, rgba(210,45,45,.10) 1.5px, transparent 1.6px) 0 0 / 14px 14px, linear-gradient(180deg, #fff6dd 0%, #fbe7b8 100%);
  background-attachment: fixed;
}
.theme-root.theme-jungle {
  --bg: #e6f2dc; --surface: #f8fcf3; --surface-2: #ecf5e2; --ink: #1f3317; --ink-soft: #58704b; --line: #cbe2b6;
  --pos: #2f7a55; --neg: #b3261e;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base); --serif: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, #eef7e6 0%, #d3e9c0 100%);
  background-attachment: fixed;
}
.theme-root.kids { --radius: 20px; --radius-sm: 14px; }
.theme-root.kids .top { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.theme-root.kids .card, .theme-root.kids .stat { border: 2px solid color-mix(in srgb, var(--brand) 22%, var(--line)); }
.theme-root.kids .btn:not(.btn-ghost):not(.btn-danger-ghost) { box-shadow: 0 3px 0 color-mix(in srgb, var(--brand) 65%, #000); }
.theme-root.kids .btn:active { transform: translateY(2px); box-shadow: none; }
.theme-root.kids h1 { letter-spacing: .01em; }
.theme-root.theme-superheroes h1, .theme-root.theme-superheroes h2 { text-transform: uppercase; letter-spacing: .03em; }
.theme-root.theme-space .quote-card { background: linear-gradient(135deg, #5b5fd6, #3a2f99); color: #fff; }
.theme-emoji { font-size: 1.15rem; margin-left: .1rem; }

/* ---------- Settings: theme picker ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: .7rem; margin-bottom: .6rem; }
.theme-card {
  display: flex; flex-direction: column; gap: .45rem; padding: .5rem; cursor: pointer; text-align: left;
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.theme-card:hover { border-color: var(--ink-soft); }
.theme-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.theme-preview {
  position: relative; display: block; height: 78px; border-radius: 10px; overflow: hidden;
  background: var(--pb); border: 1px solid rgba(0, 0, 0, .06);
}
.pv-bar { position: absolute; left: 0; right: 0; top: 0; height: 18px; background: var(--ps); display: flex; gap: 4px; align-items: center; padding: 0 6px; }
.pv-bar i { width: 18px; height: 7px; border-radius: 99px; background: color-mix(in srgb, var(--pm) 25%, transparent); }
.pv-bar i:first-child { background: var(--pm); }
.pv-card { position: absolute; left: 8px; right: 34px; bottom: 8px; top: 26px; background: var(--ps); border-radius: 7px; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.pv-card b { display: block; width: 60%; height: 7px; border-radius: 99px; background: var(--pa); }
.pv-card em { display: block; width: 42%; height: 12px; border-radius: 99px; background: var(--pm); }
.pv-emoji { position: absolute; right: 6px; bottom: 6px; font-size: 1.3rem; }
.theme-name { font-weight: 600; font-size: .92rem; display: flex; justify-content: space-between; }
.tick-mark { color: var(--brand); }
.colour-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .8rem; align-items: center; margin: .3rem 0 .8rem; }
.colour-field { display: flex; align-items: center; gap: .6rem; margin: 0; font-weight: 400; }
.colour-field small { display: block; }
input[type=color] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; flex: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 9px; }
.theme-sample { display: flex; gap: .5rem; align-items: center; padding: .55rem .7rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.sample-btn { background: var(--m); color: var(--mi); border-radius: 999px; padding: .3rem .8rem; font-weight: 600; font-size: .85rem; }
.sample-tab { background: color-mix(in srgb, var(--m) 15%, var(--surface)); color: var(--m); border-radius: 999px; padding: .3rem .8rem; font-weight: 600; font-size: .85rem; }
.sample-kicker { color: var(--a); font-weight: 700; font-size: .72rem; letter-spacing: .08em; }

/* ---------- Settings: tabs and calendar colours ---------- */
.tab-toggles { list-style: none; margin: 0 0 .5rem; padding: 0; }
.tab-toggles li { border-bottom: 1px solid var(--line); }
.tab-toggles li:last-child { border-bottom: 0; }
.tab-toggles label.check { margin: .55rem 0; }
.tab-toggles small { display: inline; margin-left: .3rem; }
.cat-edit-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .45rem; }
.cat-edit-list li { display: flex; align-items: center; gap: .5rem; }
.cat-edit-list input:not([type=color]) { margin: 0 !important; }
.cat-edit-list input[type=color], .quick-add input[type=color] { width: 40px; height: 40px; }

/* ---------- Calendar colour groups ---------- */
.cat-picker { display: flex; flex-wrap: wrap; gap: .35rem; }
.cat-choice {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
}
.cat-choice i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.cat-choice i.mine { background: conic-gradient(#b23a5b, #3b6ea8, #2f7a55, #c99a2e, #b23a5b); }
.cat-choice.on { border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 14%, var(--surface)); }
.cat-tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 999px; padding: 0 .5rem; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .8rem; font-size: .85rem; color: var(--ink-soft); align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; }
.legend-edit { margin-left: auto; font-weight: 600; text-decoration: none; }

/* ---------- School / varsity planner ---------- */
.term-select { width: auto !important; min-height: 34px !important; padding: .3rem .7rem !important; margin: 0 !important; border-radius: 999px !important; font-weight: 600 !important; }
.term-progress { margin: -.4rem 0 1rem; }
.study-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.study-item { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--c); }
.study-item.assessment { background: color-mix(in srgb, var(--c) 10%, var(--surface-2)); }
.study-item .tick { --c: var(--brand); }
.study-item.done .tick { background: var(--brand); }
.study-item.done .study-title { text-decoration: line-through; color: var(--ink-soft); }
.study-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; background: none; border: 0; padding: 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.study-title { font-weight: 600; overflow-wrap: anywhere; }
.study-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.kind-tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.mark { font-size: .78rem; font-weight: 700; color: var(--pos); background: var(--ok-bg); border-radius: 999px; padding: 0 .5rem; }
.due { font-size: .85rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.due.soon { color: var(--accent); }
.due.late { color: var(--neg); }

.timetable { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: .6rem; }
.tt-day { background: var(--surface-2); border-radius: var(--radius-sm); padding: .55rem; min-height: 90px; display: flex; flex-direction: column; gap: .35rem; }
.tt-day.today { box-shadow: inset 0 0 0 2px var(--brand); }
.tt-day h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 0 0 .1rem; font-family: var(--sans); }
.tt-class {
  display: flex; flex-direction: column; text-align: left; gap: 0; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface); border: 0; border-left: 4px solid var(--c); border-radius: 8px; padding: .35rem .5rem;
}
.tt-class b { font-size: .75rem; color: var(--ink-soft); font-weight: 700; }
.tt-class span { font-weight: 600; font-size: .9rem; }
.tt-class small { color: var(--ink-soft); font-size: .75rem; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: .6rem; }
.subject-card {
  display: flex; flex-direction: column; gap: .1rem; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius-sm); padding: .65rem .8rem;
}
.subject-card:hover { border-color: var(--c); }

.term-weeks { list-style: none; margin: 0; padding: 0; }
.term-week { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .8rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); align-items: start; }
.term-week:last-child { border-bottom: 0; }
.term-week.past { opacity: .6; }
.term-week.now { background: var(--brand-soft); border-radius: var(--radius-sm); padding: .55rem .6rem; border-bottom-color: transparent; }
.tw-head { display: flex; flex-direction: column; }
.now-tag { align-self: flex-start; font-size: .7rem; font-weight: 700; color: var(--brand-ink); background: var(--brand); border-radius: 999px; padding: 0 .5rem; margin-top: .2rem; }
.tw-items { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.tw-item {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--ink);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-radius: 999px; padding: .2rem .65rem;
}
.tw-item.big { border-width: 2px; border-color: var(--c); }
.tw-item.done { text-decoration: line-through; opacity: .6; }
.tw-add { width: 28px; height: 28px; border-radius: 50%; border: 1px dashed var(--line); background: none; color: var(--ink-soft); cursor: pointer; font: inherit; }
.tw-add:hover { border-color: var(--brand); color: var(--brand); }
.kind-seg button { font-size: .85rem; padding: .35rem .7rem; }

@media (max-width: 640px) {
  .colour-fields { grid-template-columns: minmax(0, 1fr); }
  .term-week { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .tw-head { flex-direction: row; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Everyday themes: a soft tint of the theme's colours behind everything (the fun themes have pictures). */
.theme-root:not(.kids):not(.theme-custom) {
  background:
    radial-gradient(1100px 620px at 105% -10%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 70%),
    radial-gradient(900px 560px at -10% 110%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    color-mix(in srgb, var(--brand) 8%, var(--bg));
  background-attachment: fixed;
}
.theme-root:not(.kids):not(.theme-custom) .top { background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* "Make your own" theme: background colour + the person's emoji pattern. */
.theme-root.theme-custom {
  --bg: var(--theme-bg);
  --surface: color-mix(in srgb, var(--theme-bg) 10%, #ffffff);
  --surface-2: color-mix(in srgb, var(--theme-bg) 35%, #ffffff);
  --ink: #2b2230; --ink-soft: #6f6475;
  --line: color-mix(in srgb, var(--theme-bg) 55%, #c9c0c9);
  --pos: #2f7a55; --neg: #b3261e;
  color-scheme: light;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, color-mix(in srgb, var(--theme-bg) 70%, #fff) 0%, var(--theme-bg) 100%);
  background-attachment: fixed;
}
.theme-root.theme-custom.custom-dark {
  --surface: color-mix(in srgb, var(--theme-bg) 82%, #ffffff);
  --surface-2: color-mix(in srgb, var(--theme-bg) 70%, #ffffff);
  --ink: #f3eff7; --ink-soft: #c2bacb;
  --line: color-mix(in srgb, var(--theme-bg) 60%, #ffffff);
  --pos: #7fd0a5; --neg: #ff8a80;
  color-scheme: dark;
  background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, color-mix(in srgb, var(--theme-bg) 80%, #fff) 0%, var(--theme-bg) 100%);
  background-attachment: fixed;
}
@media (prefers-color-scheme: dark) {
  /* The home-made theme keeps exactly the colours that were picked, in dark mode too. */
  .theme-root.theme-custom.has-colours:not(.kids) {
    --brand: var(--theme-main); --brand-ink: var(--theme-main-ink, #fff);
    --brand-soft: color-mix(in srgb, var(--theme-main) 15%, var(--surface));
    --accent: var(--theme-accent); --accent-soft: color-mix(in srgb, var(--theme-accent) 16%, var(--surface));
  }
}
.theme-root.theme-custom .top { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.theme-root.playful {
  --radius: 20px; --radius-sm: 14px;
  --sans: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", var(--sans-base);
  --serif: var(--sans);
}
.theme-root.playful .btn:not(.btn-ghost):not(.btn-danger-ghost) { box-shadow: 0 3px 0 color-mix(in srgb, var(--brand) 65%, #000); }

.theme-builder { background: var(--surface-2); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: .4rem 0 .8rem; }
.theme-builder input[type=range] { width: 100%; accent-color: var(--brand); margin-top: .4rem; }
.emoji-suggest { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.3rem 0 .9rem; }
.chip-btn { font: inherit; font-size: 1rem; cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .2rem .65rem; }
.chip-btn:hover { border-color: var(--brand); }

/* ---------- Calendar / Budget: family or mine ---------- */
.section-switch { margin: 0; }
.seg a { display: inline-block; font-weight: 700; text-decoration: none; color: var(--ink-soft); border-radius: 999px; padding: .4rem 1rem; }
.seg a.on { background: var(--brand-soft); color: var(--brand); }

/* ============================================================
   Games
   ============================================================ */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: .9rem; margin-bottom: 1rem; }
.game-card {
  display: flex; flex-direction: column; gap: .3rem; padding: 1.1rem 1.2rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--c); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.game-card:hover { transform: translateY(-2px); border-color: var(--c); }
.game-emoji { font-size: 2.2rem; line-height: 1; }
.game-card strong { font-family: var(--serif); font-size: 1.2rem; }
.game-best { margin-top: auto; padding-top: .4rem; font-size: .85rem; font-weight: 600; color: var(--c); }
.play-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(min(260px, 100%), 1fr); gap: 1rem; align-items: start; }
.play-layout .card { margin: 0; }
.play-card { display: flex; flex-direction: column; align-items: center; }
.game-host { width: 100%; max-width: 520px; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; min-height: 2rem; }
.game-stat { font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); border-radius: 999px; padding: .2rem .75rem; }
.game-msg { font-weight: 700; color: var(--brand); text-align: center; flex: 1; }
.game-msg.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.center-row { justify-content: center; }
.result-box { width: 100%; max-width: 520px; margin: 1rem auto 0; text-align: center; padding: 1rem; border-radius: var(--radius); background: var(--surface-2); }
.result-box.best { background: var(--accent-soft); }
.result-big { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }

/* leaderboards */
.leaderboard h3 { margin: 0; }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.lb-period { margin: 0; }
.lb-period button { padding: .25rem .7rem; font-size: .82rem; min-height: 0; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem .4rem; border-bottom: 1px solid var(--line); }
.lb-list li:last-child { border-bottom: 0; }
.lb-list li.me { background: var(--brand-soft); border-radius: var(--radius-sm); }
.lb-rank { width: 2rem; text-align: center; font-weight: 700; }
.lb-name { flex: 1; font-weight: 600; }
.lb-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar.small { width: 28px; height: 28px; font-size: .8rem; border-width: 2px; }

/* match three */
.m3-board { position: relative; width: 100%; aspect-ratio: 1; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.m3-tile {
  position: absolute; left: 0; top: 0; display: grid; place-items: center; border: 0; padding: 0; background: none; cursor: pointer;
  transition: transform .2s ease, opacity .2s ease; line-height: 1;
}
.m3-tile::before { content: ""; position: absolute; inset: 6%; border-radius: 28%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); z-index: -1; }
.m3-tile.sel::before { background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand); }
.m3-tile.pop-out { opacity: 0; transform-origin: center; }
.m3-tile.nope { animation: nope .2s ease; }
@keyframes nope { 50% { filter: brightness(.8); } }
.m3-board.over { opacity: .55; pointer-events: none; }

.m3-tile svg { width: 78%; height: 78%; display: block; pointer-events: none; }
.m3-progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: .25rem; }
.m3-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 99px; transition: width .4s ease; }
.m3-progress-text { text-align: center; margin-bottom: .5rem; }
.m3-board.levelup { animation: levelup .7s ease; }
@keyframes levelup { 30% { box-shadow: 0 0 0 6px var(--accent); transform: scale(1.015); } }

/* the bar above each game: how to play, choices, restart */
.play-tools { width: 100%; max-width: 520px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: .4rem; margin-bottom: .6rem; }
.play-tools .spacer { flex: 1; }
.how-to { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.how-to[open] { flex-basis: 100%; order: 5; }
.how-to summary { cursor: pointer; font-weight: 700; font-size: .88rem; padding: .35rem .8rem; list-style: none; }
.how-to summary::-webkit-details-marker { display: none; }
.how-to-body { padding: 0 .9rem .7rem; font-size: .92rem; }
.how-to-body p { margin: .35rem 0; }
.set-picker { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .7rem; }
.set-choice { display: flex; flex-direction: column; align-items: center; gap: .1rem; font: inherit; cursor: pointer; padding: .4rem .6rem;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); min-width: 92px; }
.set-choice.on, .piece-choice.on { border-color: var(--brand); background: var(--brand-soft); }
.set-preview { font-size: 1.05rem; letter-spacing: .05em; }
.set-choice b { font-size: .8rem; }
.piece-choice { font-size: 1.5rem; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; }
.short-input { max-width: 8rem; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* meowdoku */
.mw-grid { display: grid; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; touch-action: manipulation; }
.mw-cell { border: solid #2b2230; border-width: 1px 0 0 1px; padding: 0; font: inherit; font-size: clamp(1rem, 6vw, 2rem); line-height: 1;
  display: grid; place-items: center; cursor: pointer; color: #2b2230; min-width: 0; }
.mw-cell.mark { font-size: clamp(.8rem, 3.6vw, 1.2rem); color: rgba(43, 34, 48, .45); }
.mw-cell.cat { animation: pop .3s ease; }
.mw-cell.clash { box-shadow: inset 0 0 0 3px #d32f2f; background-image: linear-gradient(rgba(211, 47, 47, .25), rgba(211, 47, 47, .25)); }
.mw-grid.solved { box-shadow: 0 0 0 4px var(--pos); }

/* arrow out */
.ar-board { display: grid; gap: 4px; width: 100%; aspect-ratio: 1; padding: 6px; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; }
.ar-cell { position: relative; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: var(--surface); cursor: pointer; min-width: 0; }
.ar-cell.empty { background: transparent; cursor: default; }
.ar-arrow { display: block; width: 72%; height: 72%; transition: transform .2s ease; }
.ar-arrow svg { width: 100%; height: 100%; display: block; fill: currentColor; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .2)); }
.ar-cell.bump { animation: bump .45s ease; background: #ffd9d6; }
.ar-cell.blocker { box-shadow: inset 0 0 0 3px #d32f2f; }
@keyframes bump { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.ar-board.solved { box-shadow: 0 0 0 4px var(--pos); }

/* match three: board layers, goals, power-ups */
.m3-board { position: relative; }
.m3-bg { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); }
.m3-cell { margin: 6%; border-radius: 26%; transition: background .3s ease; }
.m3-board.cover-grass .m3-cell.covered { background: #7cc96b; box-shadow: inset 0 -3px 0 #5aa94a; }
.m3-board.cover-water .m3-cell.covered { background: #6cc3ee; box-shadow: inset 0 -3px 0 #3d9fd0; }
.m3-board.cover-sauce .m3-cell.covered { background: #e8654a; box-shadow: inset 0 -3px 0 #c2452c; }
.m3-board.cover-icing .m3-cell.covered { background: #f7a8cb; box-shadow: inset 0 -3px 0 #e07aa8; }
.m3-board.cover-stardust .m3-cell.covered { background: #a593f0; box-shadow: inset 0 -3px 0 #7d69d6; }
.m3-cell.box { margin: 3%; border-radius: 12%; background: repeating-linear-gradient(45deg, #b07a43 0 6px, #9c6936 6px 12px);
  box-shadow: inset 0 0 0 3px #7a4f25, 0 2px 3px rgba(0, 0, 0, .25); position: relative; }
.m3-cell.box.hits-2 { box-shadow: inset 0 0 0 3px #7a4f25, inset 0 0 0 7px #c9cdd2, 0 2px 3px rgba(0, 0, 0, .25); }
.m3-cell.hit { animation: bump .3s ease; }
.m3-board .m3-tile::before { inset: 9%; }
.m3-board .m3-tile::before { background: rgba(255, 255, 255, .55); }
.m3-tile img { width: 80%; height: 80%; object-fit: cover; border-radius: 50%; pointer-events: none; display: block; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.m3-tile.sp-row::after, .m3-tile.sp-col::after { content: ""; position: absolute; inset: 14%; border-radius: 24%; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .0) 0 4px, rgba(255, 60, 60, .35) 4px 7px); }
.m3-tile.sp-col::after { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .0) 0 4px, rgba(255, 60, 60, .35) 4px 7px); }
.m3-tile.sp-row::before, .m3-tile.sp-col::before { box-shadow: 0 0 0 2px #ff5a3c; }
.m3-tile.sp-bomb::before { box-shadow: 0 0 0 3px #222, 0 0 10px 2px #ffb300; background: #fff3c4; }
.m3-tile.sp-bomb { animation: glow 1.4s ease-in-out infinite; }
.m3-tile.sp-rainbow::before { background: conic-gradient(#ff5252, #ffb300, #ffee58, #66bb6a, #42a5f5, #7e57c2, #ff5252); box-shadow: 0 0 8px rgba(0, 0, 0, .25); border-radius: 50%; }
@keyframes glow { 50% { filter: brightness(1.15) drop-shadow(0 0 4px #ffb300); } }
.m3-goals { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-bottom: .55rem; }
.m3-goal { display: inline-flex; align-items: center; gap: .25rem; background: var(--surface-2); border-radius: 999px; padding: .2rem .65rem; font-weight: 700; font-size: .88rem; }
.m3-goal.done { background: #d9f2dc; color: #1e6b32; }
.m3-goal-face { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; }
.m3-goal-face svg, .m3-goal-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.game-stat.low { background: #fde4e2; color: #b3261e; }
.sd-time { margin: -.3rem 0 .4rem; }

/* end of a level / paused */
.sd-grid, .mw-grid, .ar-board, .bf-board, .m3-board { position: relative; }
.game-over-box { position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(86%, 320px);
  background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.1rem; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.game-over-box strong { display: block; font-family: var(--serif); font-size: 1.3rem; margin-bottom: .3rem; }
.game-over-box p { margin: 0 0 .8rem; }
.game-host { position: relative; }
.game-pause { position: absolute; inset: -4px; z-index: 50; display: grid; place-items: center; border-radius: var(--radius);
  background: rgba(30, 24, 36, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.game-pause-box { background: var(--surface); border-radius: var(--radius); padding: 1.3rem 1.6rem; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.game-pause-box strong { display: block; font-size: 1.4rem; margin-bottom: .2rem; }

/* sudoku */
.sd-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--surface); }
.sd-cell {
  position: relative; display: grid; place-items: center; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: clamp(1rem, 4.6vw, 1.5rem); font-weight: 500; padding: 0; cursor: pointer;
}
.sd-cell.bx { border-right: 2px solid var(--ink); }
.sd-cell.by { border-bottom: 2px solid var(--ink); }
.sd-cell.given { color: var(--ink); font-weight: 800; }
.sd-cell.peer { background: var(--surface-2); }
.sd-cell.same { background: var(--brand-soft); }
.sd-cell.sel { background: color-mix(in srgb, var(--brand) 28%, var(--surface)); }
.sd-cell.wrong { color: #d32f2f; font-weight: 800; background: #fde4e2; }
.sd-notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); font-size: .55em; color: var(--ink-soft); }
.sd-notes i { font-style: normal; display: grid; place-items: center; line-height: 1; }
.sd-grid.solved { box-shadow: 0 0 0 4px var(--pos); }
.sd-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: .3rem; margin-top: .7rem; }
.sd-num { font: inherit; font-size: 1.25rem; font-weight: 700; padding: .5rem 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--brand); cursor: pointer; }
.sd-num.used { opacity: .3; }
.sd-tools { display: flex; justify-content: center; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.btn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* colour sort */
.cs-area { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem 1rem; padding: 1rem .2rem; }
.cs-tube {
  display: flex; flex-direction: column-reverse; gap: 4px; width: 52px; padding: 6px 5px 8px; cursor: pointer;
  background: color-mix(in srgb, var(--surface) 70%, transparent); border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent);
  border-top: 0; border-radius: 0 0 24px 24px; transition: transform .15s ease;
}
.cs-tube.picked { transform: translateY(-8px); border-color: var(--brand); }
.cs-tube.full { border-color: var(--pos); }
.cs-slot { width: 38px; height: 38px; display: grid; place-items: center; }
.cs-ball { width: 36px; height: 36px; border-radius: 50%; box-shadow: inset -4px -6px 0 rgba(0, 0, 0, .18), inset 4px 4px 0 rgba(255, 255, 255, .25); transition: transform .15s ease; }
.cs-ball.lift { transform: translateY(-26px); }
.cs-area.solved .cs-tube { border-color: var(--pos); }

/* block fill */
.bf-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; width: 100%; aspect-ratio: 1; padding: 6px; background: var(--surface-2); border-radius: var(--radius); touch-action: none; }
.bf-cell { border-radius: 5px; background: color-mix(in srgb, var(--ink) 7%, var(--surface)); }
.bf-cell.full { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), inset 0 3px 0 rgba(255, 255, 255, .25); }
.bf-cell.ghost { opacity: .55; }
.bf-cell.bad { background: color-mix(in srgb, var(--neg) 25%, var(--surface)) !important; }
.bf-board.over { opacity: .6; }
.bf-tray { display: flex; justify-content: space-around; align-items: center; gap: .5rem; margin-top: .8rem; min-height: 120px; touch-action: none; }
.bf-piece { --mini: 20px; flex: 1; min-height: 110px; display: grid; place-items: center; border: 2px dashed transparent; border-radius: var(--radius-sm); background: none; cursor: grab; padding: .3rem; }
.bf-piece.chosen { border-color: var(--brand); background: var(--brand-soft); }
.bf-piece.stuck { opacity: .35; }
.bf-piece.used { cursor: default; }
.bf-mini { display: grid; gap: 2px; }
.bf-mini i, .bf-drag i { border-radius: 4px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.bf-drag { position: fixed; left: 0; top: 0; z-index: 2000; display: grid; gap: 3px; pointer-events: none; opacity: .9; }

@media (max-width: 880px) {
  .play-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .cs-tube { width: 44px; }
  .cs-slot { width: 32px; height: 32px; }
  .cs-ball { width: 30px; height: 30px; }
  .bf-piece { --mini: 16px; }
}
.game-stat:empty { display: none; }

/* ============================================================
   Fitness & food
   ============================================================ */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 1rem; margin: .8rem 0 1.2rem; }
.goal-grid .card { margin: 0; }
.goal-card { display: flex; flex-direction: column; gap: .6rem; border-top: 5px solid var(--c); }
.goal-card.reached { box-shadow: 0 0 0 2px var(--c), var(--shadow); }
.goal-head { display: flex; justify-content: space-between; gap: .5rem; }
.goal-head h3 { margin: .15rem 0 .1rem; }
.goal-visual { display: flex; justify-content: center; }
.goal-route { width: 100%; height: auto; display: block; }
.goal-meter { width: 130px; height: auto; display: block; }
.meter-wave { animation: wave 3.5s ease-in-out infinite alternate; }
@keyframes wave { from { transform: translateX(-12px); } to { transform: translateX(12px); } }
.meter-bubble { animation: bubble 3s ease-in infinite; }
@keyframes bubble { from { transform: translateY(0); opacity: .8; } to { transform: translateY(-60px); opacity: 0; } }
.route-walker { animation: bob 1.2s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .meter-wave, .meter-bubble, .route-walker { animation: none; } }
.goal-bar { position: relative; width: 100%; height: 34px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 1.2rem 0; }
.goal-bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--c); border-radius: inherit; transition: width .5s ease; }
.goal-bar i { position: absolute; top: 6px; bottom: 6px; width: 2px; background: rgba(255, 255, 255, .55); }
.goal-bar-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: var(--ink); mix-blend-mode: normal; text-shadow: 0 0 6px var(--surface); }
.goal-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.reward { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.reward.unlocked { background: var(--accent-soft); animation: pop .6s ease; }
.reward-icon { font-size: 1.5rem; }
.reward small { display: block; color: var(--ink-soft); }
.goal-preview { margin-top: .8rem; display: flex; justify-content: center; max-width: 360px; margin-inline: auto; }
.look-picker, .activity-picker { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0; }
.chip-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.mini-chart { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin: .4rem 0 1rem; }
.mini-chart span { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 4px; }
.mini-chart span.today { box-shadow: inset 0 0 0 2px var(--brand); }
.mini-chart i { display: block; width: 100%; background: var(--brand); border-radius: 4px; min-height: 0; }
.food-nav { margin-bottom: .8rem; }
.food-add { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.food-add select { width: auto !important; flex: 0 1 130px; margin: 0 !important; }
.food-add input { margin: 0 !important; flex: 1 1 180px; }
.food-add input.kcal { flex: 0 1 90px; }
.water-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.water-count { font-size: 1.2rem; margin-bottom: .5rem; }
.water-count b { font-size: 2rem; font-family: var(--serif); }
.weight-chart { width: 100%; height: auto; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: .6rem; }
.weight-stats { margin-top: 1rem; }

/* ============================================================
   Cycle tracker
   ============================================================ */
.cycle-now { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.cycle-ring { width: 190px; height: 190px; flex: none; }
.cycle-facts { flex: 1; min-width: 200px; }
.cycle-facts h2 { font-size: 1.5rem; margin-bottom: .2rem; }
.fertile-line { background: color-mix(in srgb, #35b5a5 14%, var(--surface)); border-radius: var(--radius-sm); padding: .45rem .7rem; }
.insights { margin: 0; padding-left: 1.1rem; }
.insights li { margin: .35rem 0; }
.cycle-legend { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); }
.cycle-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-left: .4rem; }
.cycle-legend i.period, .cycle-cell.period { background: #f3c1c5; }
.cycle-legend i.predicted { background: repeating-linear-gradient(45deg, #f3c1c5 0 3px, transparent 3px 6px); border: 1px solid #e0555f; }
.cycle-legend i.fertile, .cycle-cell.fertile { background: #c9ece6; }
.cycle-legend i.ovulation { background: #1e7f73; }
.cycle-cell { min-height: 64px; align-items: center; }
.cycle-cell.predicted { background: repeating-linear-gradient(45deg, color-mix(in srgb, #f3c1c5 70%, transparent) 0 6px, var(--surface-2) 6px 12px); }
.cycle-cell.ovulation { background: #c9ece6; box-shadow: inset 0 0 0 2px #1e7f73; }
.cycle-cell.period .day-num, .cycle-cell.fertile .day-num, .cycle-cell.ovulation .day-num { color: #2b2230; }
.cycle-marks { display: flex; gap: 2px; font-size: .75rem; }
.cycle-marks i { font-style: normal; }
.preg-card { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.preg-ring { --p: 0; width: 140px; height: 140px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0); }
.preg-ring::before { content: ""; grid-area: 1 / 1; width: 112px; height: 112px; border-radius: 50%; background: var(--surface); }
.preg-emoji { grid-area: 1 / 1; font-size: 3.2rem; z-index: 1; }
.preg-weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46px, 100%), 1fr)); gap: .3rem; }
.preg-weeks span { display: flex; flex-direction: column; align-items: center; padding: .3rem 0; border-radius: 10px; background: var(--surface-2); font-size: .8rem; }
.preg-weeks span.past { opacity: .55; }
.preg-weeks span.now { background: var(--brand); color: var(--brand-ink); }
.preg-weeks i { font-style: normal; font-size: 1.2rem; }

/* ============================================================
   Baby book
   ============================================================ */
.child-picker { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.child-chip { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 700; cursor: pointer; padding: .25rem .8rem .25rem .3rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.child-chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.baby-hero { display: flex; gap: 1rem; align-items: center; border-top: 5px solid var(--c); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 16%, var(--surface)), var(--surface) 60%); }
.baby-hero h2 { font-size: 1.6rem; margin: 0; }
.baby-tabs { margin: .2rem 0 1rem; }
.milestone-list, .vaccine-list, .memory-list { list-style: none; margin: 0; padding: 0; }
.milestone-list li { display: flex; align-items: center; gap: .7rem; padding: .5rem .3rem; border-bottom: 1px solid var(--line); }
.milestone-list li:last-child { border-bottom: 0; }
.milestone-list li.reached { background: color-mix(in srgb, var(--pos) 8%, transparent); border-radius: var(--radius-sm); }
.milestone-list li.now b::after { content: " · around now"; color: var(--accent); font-weight: 600; font-size: .8rem; }
.milestone-list small { display: block; }
.ms-emoji { font-size: 1.5rem; width: 2rem; text-align: center; }
.ms-note { font-style: italic; color: var(--ink); }
.memory-list li { padding: .7rem .2rem; border-bottom: 1px solid var(--line); }
.memory-list p { margin: .2rem 0; white-space: pre-line; }
.memory-date { display: block; font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.vaccine-group { margin-bottom: .9rem; }
.vg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .3rem; }
.vaccine {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm); padding: .45rem .6rem; margin-bottom: .3rem;
}
.vaccine small { display: block; }
.vaccine.given { background: color-mix(in srgb, var(--pos) 10%, var(--surface)); }
.vaccine.due-soon { border-color: var(--accent); }
.vaccine.overdue { border-color: var(--neg); }
.vx-tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); color: #fff; font-weight: 800; flex: none; }
.vaccine.given .vx-tick { background: var(--pos); border-color: var(--pos); }
.quick-log { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: .8rem; }
.ml-input { width: 80px !important; min-height: 36px !important; padding: .3rem .5rem !important; margin: 0 !important; }
.big-line { font-size: 1.3rem; font-weight: 700; margin: .3rem 0; }
.btn-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--brand); font-weight: 600; font-size: .9rem; }

/* ---------- Baby book: measuring tape, about me, school, the book ---------- */
.avatar.photo { object-fit: cover; padding: 0; border: 3px solid var(--c, var(--brand)); }
.hidden-file { display: none; }
label.btn { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.tape-section { grid-column: 1 / -1; }
.tape-card { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.tape-styles { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; }
.tape-style { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 1.3rem; cursor: pointer; transition: transform .15s; }
.tape-style:hover { transform: scale(1.1); }
.tape-style.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
svg.tape { width: 100%; max-width: 340px; height: auto; max-height: 70vh; }
.book-page svg.tape { max-height: 340px; }

.cover-preview { width: 160px; height: 160px; border-radius: 50%; overflow: hidden; margin: .5rem auto 1rem; background: var(--brand-soft); display: grid; place-items: center; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-empty { font-size: 4rem; }
.photo-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.photo-pick button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; width: 58px; height: 58px; cursor: pointer; background: var(--surface-2, #f3eee8); }
.photo-pick button:hover { border-color: var(--brand); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-tile { width: 58px; height: 58px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; align-content: center; font-size: 1.4rem; color: var(--ink-soft); cursor: pointer; }
.upload-tile small { font-size: .65rem; }
.upload-tile:hover { border-color: var(--brand); color: var(--brand); }
.upload-tile input { display: none; }
.gallery .upload-tile { width: 130px; height: 130px; }

.school-year .section-head h2 small { font-family: var(--sans, inherit); font-size: .9rem; font-weight: 600; }
.school-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: .2rem 1rem; }
.school-facts p { margin: .2rem 0; }
.school-highlights { background: var(--brand-soft); border-radius: var(--radius-sm); padding: .7rem .9rem; white-space: pre-line; }
.gallery { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: .5rem; }
.gallery-item { position: relative; margin: 0; width: 130px; }
.gallery-item img { width: 130px; height: 130px; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.gallery-item input { font-size: .8rem; padding: .25rem .4rem; margin-top: .3rem; }
.gallery-item .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.9); }

/* the book */
.book-wrap { outline: none; }
.book-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.book-count { font-weight: 700; color: var(--ink-soft); min-width: 7.5rem; text-align: center; }
.book { position: relative; max-width: 620px; margin: 0 auto; aspect-ratio: 3 / 4; perspective: 1800px; touch-action: pan-y; user-select: none; }
.book-spine { position: absolute; left: -8px; top: 6px; bottom: 6px; width: 16px; border-radius: 8px 0 0 8px; background: color-mix(in srgb, var(--brand) 70%, #000); box-shadow: inset -3px 0 6px rgba(0,0,0,.25); }
.book-page { position: absolute; inset: 0; border-radius: 4px 14px 14px 4px; overflow: hidden; background: #fffdf7; color: #3b2f2a;
  box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 14px 34px rgba(43,34,48,.18), inset 14px 0 18px -14px rgba(0,0,0,.25);
  transform-origin: left center; backface-visibility: hidden; }
.book-page .muted { color: #8a7a70; }
.page-content { position: absolute; inset: 0; padding: 7% 8% 9%; overflow: hidden; }
.page-content .pb { height: 100%; overflow: hidden; }
.page-num { position: absolute; bottom: 2.5%; right: 5%; font-size: .8rem; color: #a8988c; font-family: var(--serif); }
.page-title { font-family: var(--serif); font-size: clamp(1.3rem, 4vw, 2rem); color: color-mix(in srgb, var(--c) 55%, #3b2f2a); margin-bottom: 1rem;
  border-bottom: 3px dotted color-mix(in srgb, var(--c) 60%, transparent); padding-bottom: .3rem; }
.handwritten { font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; font-size: 1.05rem; line-height: 1.5; white-space: pre-line; }
.big-line { font-size: 1.15rem; font-weight: 700; }
.page-hint { margin-top: 30%; }

/* page turning */
.book-page.turn-out-next { z-index: 3; animation: page-out-next .55s ease-in forwards; }
.book-page.turn-out-prev { z-index: 3; animation: page-out-prev .55s ease-in forwards; transform-origin: right center; }
.book-page.turn-in { z-index: 1; animation: page-in .55s ease-out; }
@keyframes page-out-next { from { transform: rotateY(0); } to { transform: rotateY(-100deg); opacity: .6; } }
@keyframes page-out-prev { from { transform: rotateY(0); } to { transform: rotateY(100deg); opacity: .6; } }
@keyframes page-in { from { filter: brightness(.85); } to { filter: none; } }
@media (prefers-reduced-motion: reduce) { .book-page.turn-out-next, .book-page.turn-out-prev { animation: none; display: none; } .book-page.turn-in { animation: none; } }

/* page backgrounds */
.bg-paper { background: #fffdf7; }
.bg-dots { background: #fffdf7 radial-gradient(circle, #e9dccd 1.5px, transparent 1.6px) 0 0 / 22px 22px; }
.bg-grid { background: #fbfdff linear-gradient(#e2ebf3 1px, transparent 1px) 0 0 / 22px 22px, linear-gradient(90deg, #e2ebf3 1px, transparent 1px) 0 0 / 22px 22px; }
.bg-kraft { background: #d9bf98 radial-gradient(circle at 20% 30%, rgba(255,255,255,.12), transparent 40%); }
.bg-stars { background: #1f2a5a radial-gradient(circle, #ffe9a8 1.4px, transparent 1.6px) 0 0 / 34px 34px; color: #f6f1ff; }
.bg-stars .page-title, .bg-stars .page-num { color: #fff3c4; }
.bg-hearts { background: #fff0f5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 30 C8 22 8 12 14 12 c3 0 5 2 6 4 c1-2 3-4 6-4 c6 0 6 10-6 18z' fill='%23ffd0e0'/%3E%3C/svg%3E") 0 0 / 40px 40px; }
.bg-lined { background: #fffefa repeating-linear-gradient(#fffefa 0 27px, #cfe0f0 27px 28px); }
.bg-rainbow { background: linear-gradient(160deg, #ffe1ec, #fff3d1 30%, #e3f8dd 55%, #dcefff 80%, #efe2ff); }
.bg-cover { background: linear-gradient(150deg, color-mix(in srgb, var(--c) 55%, #fff), color-mix(in srgb, var(--c) 85%, #000)); color: #fff; }
.bg-cover .page-num { display: none; }

.cover { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .6rem; }
.cover-kicker { text-transform: uppercase; letter-spacing: .2em; font-size: .8rem; opacity: .9; margin: 0; }
.cover-name { font-family: var(--serif); font-size: clamp(2.2rem, 8vw, 3.6rem); margin: 0; text-shadow: 0 2px 8px rgba(0,0,0,.2); }
.cover-photo { width: 58%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 6px solid rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.cover-emoji { font-size: clamp(4rem, 16vw, 7rem); }
.cover-date { font-family: var(--serif); font-style: italic; margin: 0; }
.end-page { color: #3b2f2a; }

.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; margin: .8rem 0; }
.about-box { background: color-mix(in srgb, var(--c) 14%, #fff); border-radius: 12px; padding: .6rem .75rem; transform: rotate(-.6deg); }
.about-box:nth-child(even) { transform: rotate(.8deg); }
.about-box p { margin: .25rem 0 0; font-size: .92rem; }
.birth-card { background: color-mix(in srgb, var(--c) 12%, #fff); border: 2px dashed color-mix(in srgb, var(--c) 60%, #fff); border-radius: 16px; padding: 1rem 1.2rem; }
.birth-card p { margin: .35rem 0; }
.book-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.book-list li { display: flex; gap: .7rem; align-items: flex-start; }
.book-list li > span:last-child { display: flex; flex-direction: column; }
.book-list small { color: #8a7a70; }
.book-list em { font-family: "Segoe Print", "Bradley Hand", cursive; font-size: .9rem; }
.book-list.compact { gap: .3rem; font-size: .9rem; }
.book-emoji { font-size: 1.5rem; line-height: 1; }
.book-photos { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .6rem; }
.polaroid { margin: 0; background: #fff; padding: 6px 6px 18px; box-shadow: 0 3px 10px rgba(0,0,0,.18); border-radius: 2px; }
.polaroid img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; pointer-events: none; }
.polaroid figcaption { font-family: "Segoe Print", "Bradley Hand", cursive; font-size: .75rem; text-align: center; color: #3b2f2a; margin-top: 4px; }
.polaroid.small { width: 28%; transform: rotate(-2deg); }
.polaroid.small:nth-child(even) { transform: rotate(2.5deg); }

/* scrapbook items */
.scrap-item { position: absolute; touch-action: none; }
.book.editing .scrap-item { cursor: grab; outline: 1px dashed transparent; }
.book.editing .scrap-item:hover { outline-color: rgba(0,0,0,.25); }
.scrap-item.selected { outline: 2px dashed var(--brand) !important; outline-offset: 3px; }
.scrap-item.dragging { cursor: grabbing; opacity: .9; }
.sticker-glyph { display: block; text-align: center; line-height: 1; font-size: calc(var(--w, 14) * 0.42cqw + 1rem); filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.book { container-type: inline-size; }
.bubble-shape { position: relative; padding: .6em .9em; border-radius: 1.2em; border: 2px solid #3b2f2a; font-weight: 700; font-size: clamp(.8rem, 2.6cqw, 1.15rem); line-height: 1.25; color: #3b2f2a; text-align: center; }
.bubble-shape::after { content: ""; position: absolute; left: 18%; bottom: -14px; border: 7px solid transparent; border-top: 9px solid #3b2f2a; border-left: 4px solid #3b2f2a; transform: skewX(-15deg); }
.scrap-words { font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; font-weight: 700; font-size: clamp(.9rem, 3.4cqw, 1.6rem); line-height: 1.2; text-shadow: 0 1px 0 rgba(255,255,255,.6); }
.scrap-photo .polaroid { pointer-events: auto; }
.scrap-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: nwse-resize; }

.scrap-tools { max-width: 620px; margin: 1rem auto 0; }
.scrap-tool-row { margin-bottom: .9rem; }
.scrap-tool-row > b { display: block; margin-bottom: .35rem; }
.scrap-tool-row .food-add { margin-top: 0; }
.sticker-grid { display: flex; flex-wrap: wrap; gap: .25rem; }
.sticker-grid button { font-size: 1.4rem; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.sticker-grid button:hover { transform: scale(1.15); border-color: var(--brand); }
.selected-tools { background: var(--brand-soft); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.book-thumbs { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin-top: 1rem; }
.book-thumbs .thumb { width: 36px; height: 44px; border-radius: 3px 8px 8px 3px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.05rem; }
.book-thumbs .thumb.on { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-3px); }

@media (max-width: 640px) {
  .book { aspect-ratio: 3 / 4.4; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .page-content { padding: 8% 7% 10%; }
}

/* ---------- Photo albums ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 1rem; }
.album-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease; }
.album-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.album-cover { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-empty { font-size: 3rem; opacity: .6; }
.album-info { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .9rem; }
.album-info strong { font-family: var(--serif); font-size: 1.1rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 30%), 1fr)); gap: .4rem; }
.photo-tile { position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; background: var(--surface-2); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.photo-tile:hover img { transform: scale(1.04); }
.photo-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: .9rem .5rem .35rem; font-size: .75rem; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-note { background: var(--brand-soft); border-radius: var(--radius-sm); padding: .6rem .9rem; font-weight: 600; }
.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(12, 10, 14, .94); color: #fff; display: flex; flex-direction: column; outline: none; }
.lightbox .muted { color: #c9c2cc; }
.lightbox-top { display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem; padding-top: calc(.6rem + env(safe-area-inset-top)); }
.lightbox .icon-btn { color: #fff; background: rgba(255, 255, 255, .12); border-color: transparent; text-decoration: none; }
.lightbox-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 .5rem; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; }
.lightbox-nav.prev { left: .6rem; }
.lightbox-nav.next { right: .6rem; }
.lightbox-nav:disabled { opacity: .25; cursor: default; }
.lightbox-bottom { padding: .6rem .9rem; padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.lightbox-bottom input { flex: 1 1 220px; margin: 0 !important; background: rgba(255, 255, 255, .1) !important; color: #fff !important; border-color: rgba(255, 255, 255, .25) !important; }
.lightbox-bottom .btn-ghost, .lightbox-bottom .btn-danger-ghost { color: #fff; border-color: rgba(255, 255, 255, .3); }

/* ---------- Profile photos ---------- */
img.avatar { object-fit: cover; padding: 0; background: var(--surface-2); border: 2px solid var(--c, var(--brand)); }
.profile-photo { display: flex; gap: .9rem; align-items: center; margin-bottom: 1rem; }
.profile-photo .avatar.big { width: 72px; height: 72px; flex: none; }
.profile-photo p { margin: .1rem 0 .3rem; }
.tabs .count { margin-left: .3rem; }

/* ---------- Messages ---------- */
.chat-layout { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 1rem; align-items: stretch; }
.chat-layout .card { margin: 0; }
.chat-list { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 140px); overflow-y: auto; }
.chat-list .section-head { flex-wrap: wrap; gap: .4rem; }
.people-pick { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: .6rem; }
.people-pick p { width: 100%; margin: 0 0 .2rem; }
.person-chip { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-weight: 600; cursor: pointer; padding: .2rem .7rem .2rem .25rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); }
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-row { display: flex; align-items: center; gap: .65rem; padding: .55rem .5rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
.thread-row:hover { background: var(--surface-2); }
.thread-row.on { background: var(--brand-soft); }
.thread-face .avatar { width: 42px; height: 42px; font-size: 1.1rem; }
.thread-emoji { background: var(--surface-2) !important; color: var(--ink) !important; border: 0; font-size: 1.3rem !important; }
.thread-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row .count { margin-left: 0; }
.chat-thread { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 1.15rem; }
.chat-back { display: none; text-decoration: none; font-size: 1.4rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: .8rem 1rem; display: flex; flex-direction: column; gap: .2rem; background: var(--surface-2); }
.center-block { align-self: center; margin-bottom: .5rem; }
.chat-day { align-self: center; font-size: .75rem; font-weight: 700; color: var(--ink-soft); background: var(--surface); border-radius: 999px; padding: .15rem .7rem; margin: .6rem 0 .3rem; }
.chat-msg { display: flex; align-items: flex-end; gap: .4rem; max-width: 82%; }
.chat-msg.first { margin-top: .35rem; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-face { width: 28px; flex: none; }
.bubble { background: var(--surface); border-radius: 16px 16px 16px 4px; padding: .45rem .7rem .3rem; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); min-width: 0; }
.chat-msg.mine .bubble { background: var(--brand); color: var(--brand-ink); border-radius: 16px 16px 4px 16px; }
.chat-name { display: block; font-size: .78rem; margin-bottom: .1rem; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-time { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; font-size: .68rem; opacity: .7; margin-top: .1rem; }
.link-btn { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; opacity: .8; }
.chat-location { display: flex; flex-direction: column; color: inherit; font-weight: 700; text-decoration: none; }
.chat-location small { font-weight: 400; opacity: .8; }
.chat-send { display: flex; gap: .5rem; align-items: flex-end; padding: .6rem .8rem; padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.chat-send textarea { margin: 0 !important; resize: none; max-height: 140px; field-sizing: content; min-height: 42px; }
.chat-thread > .alert { margin: .4rem .8rem; }
@media (max-width: 879px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-layout.show-thread .chat-list { display: none; }
  .chat-layout.show-list .chat-thread { display: none; }
  .chat-back { display: inline-grid; place-items: center; }
  .chat-thread { height: calc(100vh - 120px); height: calc(100dvh - 120px); }
  .chat-list { max-height: none; }
}

/* ---------- Family map ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.map-layout .card { margin: 0; }
.map-card { padding: .5rem; }
.family-map { height: min(68vh, 560px); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); z-index: 0; }
.pin-list { list-style: none; margin: 0 0 .8rem; padding: 0; }
.pin-list li { display: flex; align-items: center; gap: .3rem; }
.pin-row { flex: 1; display: flex; align-items: center; gap: .6rem; padding: .45rem .3rem; border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; border-radius: var(--radius-sm); min-width: 0; }
.pin-row:hover { background: var(--surface-2); }
.pin-row .grow { display: flex; flex-direction: column; }
.share-off { border-left: 4px solid var(--accent); }
.live-check { margin-top: .5rem; }
.map-pin { background: none; border: 0; }
.map-pin-face { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c); box-shadow: 0 3px 8px rgba(0, 0, 0, .35); border: 3px solid #fff; overflow: hidden; }
.map-pin-face img, .map-pin-face b { transform: rotate(45deg); }
.map-pin-face img { width: 100%; height: 100%; object-fit: cover; }
.map-pin-face b { color: #fff; font-size: 1.1rem; }
@media (max-width: 879px) { .map-layout { grid-template-columns: minmax(0, 1fr); } .family-map { height: 55vh; } }

/* ==== AUTO: color-mix fallbacks (generated) ==== */
@supports not (color: color-mix(in srgb, red, blue)) {
  .chip { background: var(--surface); }
  .who-tag { background: transparent; }
  .theme-root.has-colours { --brand-soft: var(--surface); --accent-soft: var(--surface); }
  .theme-root.has-colours:not(.kids):not(.theme-custom) { --surface-2: var(--surface); --line: #e4e0e6; }
  @media (prefers-color-scheme: dark) { .theme-root.has-colours:not(.kids):not(.theme-custom) { --line: #3a313f; } }
  @media (prefers-color-scheme: dark) { .theme-root.has-colours:not(.kids) { --brand: var(--theme-main); --brand-soft: var(--surface); --accent: var(--theme-accent); --accent-soft: var(--surface); } }
  .theme-root.kids .top { background: var(--surface); }
  .theme-root.kids .card, .theme-root.kids .stat { border: 2px solid var(--line); }
  .theme-root.kids .btn:not(.btn-ghost):not(.btn-danger-ghost) { box-shadow: 0 3px 0 var(--brand); }
  .pv-bar i { background: transparent; }
  .sample-tab { background: var(--surface); }
  .cat-choice.on { background: var(--surface); }
  .cat-tag { background: transparent; }
  .study-item.assessment { background: var(--surface-2); }
  .tw-item { background: var(--surface); border: 1px solid transparent; }
  .theme-root:not(.kids):not(.theme-custom) { background:
    radial-gradient(1100px 620px at 105% -10%, transparent, transparent 70%),
    radial-gradient(900px 560px at -10% 110%, transparent, transparent 70%),
    var(--bg); }
  .theme-root:not(.kids):not(.theme-custom) .top { background: var(--surface); }
  .theme-root.theme-custom { --surface: #ffffff; --surface-2: #ffffff; --line: var(--theme-bg); background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, var(--theme-bg) 0%, var(--theme-bg) 100%); }
  .theme-root.theme-custom.custom-dark { --surface: var(--theme-bg); --surface-2: var(--theme-bg); --line: var(--theme-bg); background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, var(--theme-bg) 0%, var(--theme-bg) 100%); }
  @media (prefers-color-scheme: dark) { .theme-root.theme-custom.has-colours:not(.kids) { --brand-soft: var(--surface); --accent-soft: var(--surface); } }
  .theme-root.theme-custom .top { background: var(--surface); }
  .theme-root.playful .btn:not(.btn-ghost):not(.btn-danger-ghost) { box-shadow: 0 3px 0 var(--brand); }
  .sd-cell.sel { background: var(--surface); }
  .cs-tube { background: var(--surface); border: 2px solid transparent; }
  .bf-cell { background: var(--surface); }
  .bf-cell.bad { background: var(--surface) !important; }
  .fertile-line { background: var(--surface); }
  .cycle-cell.predicted { background: repeating-linear-gradient(45deg, #f3c1c5 0 6px, var(--surface-2) 6px 12px); }
  .child-chip.on { background: var(--surface); }
  .baby-hero { background: linear-gradient(135deg, var(--surface), var(--surface) 60%); }
  .milestone-list li.reached { background: transparent; }
  .vaccine.given { background: var(--surface); }
  .book-spine { background: var(--brand); }
  .page-title { color: var(--c); border-bottom: 3px dotted var(--c); }
  .bg-cover { background: linear-gradient(150deg, var(--c), var(--c)); }
  .about-box { background: #fff; }
  .birth-card { background: #fff; border: 2px dashed var(--c); }
/* Themes: the colours worked out on the server (ThemeCatalog.Style) instead of mixed here. */
  .theme-root.has-colours { --brand-soft: var(--fb-brand-soft, var(--surface)); --accent-soft: var(--fb-accent-soft, var(--surface)); }
  .theme-root.has-colours:not(.kids):not(.theme-custom) { --surface-2: var(--fb-surface-2); --line: var(--fb-line); }
  .theme-root:not(.kids):not(.theme-custom) { background: var(--fb-tint, var(--bg)); }
  .theme-root .top { background: var(--surface); }
  .theme-root.theme-custom, .theme-root.theme-custom.custom-dark {
    --surface: var(--fb-surface); --surface-2: var(--fb-surface-2); --line: var(--fb-line);
    background: var(--pattern-img, none) 0 0 / 180px 180px, linear-gradient(180deg, var(--fb-bg-top, var(--theme-bg)) 0%, var(--theme-bg) 100%);
    background-attachment: fixed;
  }
  @media (prefers-color-scheme: dark) {
    .theme-root.has-colours:not(.kids):not(.theme-custom) { --line: var(--fb-line-d); }
    .theme-root.has-colours:not(.kids) {
      --brand: var(--fb-brand-d, var(--theme-main)); --brand-soft: var(--fb-brand-soft-d, var(--surface));
      --accent: var(--fb-accent-d, var(--theme-accent)); --accent-soft: var(--fb-accent-soft-d, var(--surface));
    }
    .theme-root:not(.kids):not(.theme-custom) { background: var(--fb-tint-d, var(--bg)); }
    .theme-root.theme-custom.has-colours:not(.kids) {
      --brand: var(--theme-main); --brand-soft: var(--fb-brand-soft); --accent: var(--theme-accent); --accent-soft: var(--fb-accent-soft);
    }
  }
}
/* ==== END AUTO ==== */
