/* Family Hub: warm, rounded, big touch targets. Colours are tokens so dark mode is one block. */
:root {
  --bg: #f7f4ee; --card: #ffffff; --ink: #2b2723; --muted: #8a8279; --line: #ece6dc;
  --accent: #e8734a; --accent-ink: #ffffff; --soft: #f1ece3; --good: #3aa676; --bad: #d64545;
  --shadow: 0 2px 10px rgba(60, 44, 24, .08); --radius: 16px; --nav-h: 64px;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19; --card: #292724; --ink: #f2ede6; --muted: #a39b90; --line: #3a3732;
    --accent: #f08a63; --accent-ink: #2b1a10; --soft: #34312d; --shadow: 0 2px 12px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.35; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.6rem; font-weight: 800; } h2 { font-size: 1.15rem; font-weight: 800; } h3 { font-size: 1rem; font-weight: 700; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { text-align: center; margin-top: 30vh; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.end { justify-content: flex-end; gap: 10px; margin-top: 14px; }
.stack { display: grid; gap: 16px; width: 100%; max-width: 440px; }
.errmsg { color: var(--bad); font-weight: 600; margin: 8px 0; min-height: 1.2em; }
[hidden] { display: none !important; }

/* ---- cards, buttons, chips ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.btn { border: 0; border-radius: 14px; padding: 12px 18px; min-height: 48px; font-weight: 700; cursor: pointer; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .9rem; border-radius: 12px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.round { width: 48px; padding: 0; font-size: 1.5rem; flex: none; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 14px; cursor: pointer; width: 100%; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.3rem; border-radius: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; border: 0;
  background: color-mix(in srgb, var(--c, var(--muted)) 20%, transparent); color: var(--ink); }
.chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip.status, .chip.offline { --c: var(--accent); } .chip.offline { --c: var(--bad); }
.chip.status::before { display: none; }
.chip.pick { cursor: pointer; opacity: .55; min-height: 40px; padding: 6px 14px; } .chip.pick.on { opacity: 1; box-shadow: inset 0 0 0 2px var(--c); }
.chip.pick.day::before { display: none; } .chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- forms ---- */
.field { display: grid; gap: 6px; margin: 12px 0; } .field label { font-weight: 700; font-size: .9rem; }
.field.inline { display: flex; align-items: center; gap: 10px; } .field.inline label { order: 2; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=time], input[type=number], input:not([type]), select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; min-height: 48px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--accent); }
input[type=color] { width: 80px; height: 48px; border: 1.5px solid var(--line); border-radius: 12px; background: none; padding: 4px; }
input.tiny { width: 76px; text-align: center; }
dialog.modal { border: 0; border-radius: 20px; padding: 20px; width: min(94vw, 440px); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.3); max-height: 92vh; overflow: auto; }
dialog.modal::backdrop { background: rgba(20, 15, 10, .5); }
dialog.modal h2 { margin-bottom: 6px; }

/* ---- first-run / sign-in screens ---- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.hero { width: 100%; max-width: 440px; text-align: center; padding: 24px 20px; margin: 0; }
.hero h1 { margin: 4px 0 8px; } .hero form, .hero .field { text-align: left; } .hero h2 { text-align: left; }
.logo.big { font-size: 3rem; } .logo { margin-right: 2px; }

/* ---- app shell ---- */
#shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.brand { font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.famname { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
#view { padding: 4px 14px 14px; max-width: 980px; margin: 0 auto; }
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; overflow-x: auto; gap: 2px; background: var(--card);
  box-shadow: 0 -2px 14px rgba(60,44,24,.1); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { flex: 1 0 64px; display: grid; justify-items: center; gap: 1px; padding: 6px 4px; border-radius: 14px; color: var(--muted); font-size: .7rem; font-weight: 700; }
#nav a .ni { font-size: 1.35rem; } #nav a.on { color: var(--ink); background: var(--soft); }
@media (min-width: 900px) {
  #shell { padding-bottom: 0; padding-left: 92px; }
  #nav { top: 0; right: auto; width: 92px; flex-direction: column; overflow: visible; padding: 70px 6px 6px; box-shadow: 2px 0 14px rgba(60,44,24,.08); }
  #nav a { flex: 0 0 auto; padding: 10px 4px; }
  .top { padding-left: 106px; margin-left: -92px; } /* header spans the whole width above the rail */
  .top { margin-left: -92px; }
}
.view-head { display: flex; align-items: center; gap: 10px; margin: 8px 0 14px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: none; border-radius: 10px; padding: 8px 20px; font-weight: 700; min-height: 40px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.weeknav { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 12px; }
.pending { opacity: .5; } .removing { text-decoration: line-through; }

/* ---- avatars ---- */
.avatar { width: var(--s, 40px); height: var(--s, 40px); border-radius: 50%; flex: none; position: relative; overflow: hidden; display: grid; place-items: center;
  background: var(--c); color: #fff; font-weight: 800; font-size: calc(var(--s, 40px) * .38); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---- calendar ---- */
.day-card h3.today { color: var(--accent); } .day-card h3 { margin-bottom: 8px; }
.event { display: flex; gap: 10px; padding: 8px 0; align-items: stretch; }
.etime { width: 68px; flex: none; font-size: .85rem; font-weight: 700; color: var(--muted); padding-top: 2px; }
.ebar { width: 5px; border-radius: 3px; background: var(--c); flex: none; }
.etitle { font-weight: 700; } .esub { font-size: .82rem; color: var(--muted); }
.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 14px; }
.wcell { border: 0; background: var(--card); border-radius: 12px; padding: 6px 3px; min-height: 120px; display: flex; flex-direction: column; gap: 3px; text-align: center; cursor: pointer; box-shadow: var(--shadow); }
.wcell.today .wn { background: var(--accent); color: var(--accent-ink); } .wcell.sel { outline: 2px solid var(--accent); }
.wd { font-size: .68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.wn { font-weight: 800; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; margin: 0 auto; }
.wev { font-size: .64rem; line-height: 1.15; border-radius: 6px; padding: 2px 3px; background: color-mix(in srgb, var(--c) 22%, transparent); border-left: 3px solid var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.wmore { font-size: .68rem; color: var(--muted); }

/* ---- lists ---- */
.list-card h2 { margin-right: 8px; } .count { font-size: .85rem; }
.quickadd { display: flex; gap: 8px; margin: 12px 0 6px; }
.items { list-style: none; padding: 0; margin: 0; }
.item { display: flex; align-items: center; border-bottom: 1px solid var(--line); } .item:last-child { border-bottom: 0; }
.itemmain { flex: 1; display: flex; align-items: center; gap: 12px; background: none; border: 0; text-align: left; padding: 10px 0; min-height: 52px; cursor: pointer; }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-weight: 800; color: var(--accent-ink); }
.item.done .check, .task.done .check, .btask.done .check { background: var(--good); border-color: var(--good); color: #fff; }
.item.done .txt { text-decoration: line-through; color: var(--muted); }
.x { background: none; border: 0; color: var(--muted); width: 44px; height: 44px; cursor: pointer; font-size: 1rem; }

/* ---- chores / routines / habits columns ---- */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.col { margin: 0; } .colhead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.stars { font-size: .85rem; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; margin-top: 4px; } .bar i { display: block; height: 100%; background: var(--c); border-radius: 4px; }
.task { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 14px; padding: 10px 12px; min-height: 56px; margin-bottom: 8px; cursor: pointer; text-align: left;
  background: color-mix(in srgb, var(--c) 14%, var(--card)); }
.task .txt { flex: 1; font-weight: 700; } .task.done { opacity: .6; } .task.done .txt { text-decoration: line-through; }
.emoji { font-size: 1.4rem; } .bigemoji { font-size: 2rem; }
.secname { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; margin: 10px 0 6px; }
details.more summary { cursor: pointer; font-weight: 800; min-height: 40px; display: flex; align-items: center; }
.listrow { padding: 8px 0; border-top: 1px solid var(--line); }
.goals h3 { margin: 14px 0 4px; } .pre { white-space: pre-wrap; color: var(--muted); margin: 6px 0; }
.dots { display: flex; gap: 6px; margin: 8px 0 12px; justify-content: space-between; }
.dot { flex: 1; max-width: 48px; min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: none; display: grid; place-items: center; align-content: center; cursor: pointer; font-weight: 800; color: #fff; }
.dot small { color: var(--muted); font-size: .65rem; } .dot.on { background: var(--c); border-color: var(--c); } .dot.on small { color: #fff; } .dot.off { opacity: .35; }
.streak { font-weight: 800; font-size: .85rem; }
.countdown { align-items: center; }
.daysleft { text-align: center; line-height: 1.05; min-width: 56px; } .daysleft b { display: block; font-size: 1.6rem; font-weight: 800; } .daysleft span { font-size: .75rem; color: var(--muted); } .daysleft.past b { color: var(--muted); }
.mealrow { width: 100%; display: flex; gap: 12px; border: 0; background: none; padding: 10px 0; min-height: 46px; text-align: left; border-top: 1px solid var(--line); cursor: pointer; align-items: center; }
.slot { width: 86px; flex: none; text-transform: capitalize; font-size: .8rem; font-weight: 800; color: var(--muted); }
.recipe summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.person { margin: 0; display: grid; justify-items: center; gap: 10px; text-align: center; }
.avwrap { cursor: pointer; position: relative; } .avwrap.pending { opacity: .5; }
.joincode { font-size: 2rem; font-weight: 800; letter-spacing: .25em; background: var(--soft); padding: 8px 18px; border-radius: 14px; }

/* ---- toasts ---- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; justify-items: center; z-index: 50; pointer-events: none; padding: 0 12px; }
.is-board #toasts { bottom: 16px; }
.toast { background: #2b2723; color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.3); max-width: 480px; font-weight: 700; animation: pop .25s ease; transition: opacity .3s; }
.toast.error { background: var(--bad); } .toast.out { opacity: 0; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
@media (min-width: 900px) { #toasts { bottom: 20px; } }

/* =========================== #board: wall display =========================== */
body.is-board { overflow: hidden; }
#boardroot { height: 100vh; height: 100dvh; padding: 14px; }
.board { height: 100%; display: grid; gap: 14px; grid-template-columns: 1.2fr 1fr 1fr; grid-template-rows: auto minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas: "head head head" "cal cal cal" "chores list count"; font-size: clamp(14px, 1.45vmin + 6px, 24px); }
.board .card { margin: 0; overflow: hidden; padding: 1.1em; }
.board h2 { margin-bottom: .6em; font-size: 1.15em; }
.bhead { grid-area: head; display: flex; align-items: center; gap: 1.2em; padding: .7em 1.2em; }
.bclock { font-size: 3.4em; font-weight: 800; line-height: 1; letter-spacing: -.02em; cursor: pointer; }
.bdate { font-size: 1.35em; font-weight: 800; line-height: 1.2; } .bdate .muted { font-size: .8em; font-weight: 600; }
.bwx { display: flex; align-items: center; gap: .6em; } .wxicon { font-size: 2.6em; } .bwx b { font-size: 1.9em; }
.bcal { grid-area: cal; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6em; padding: .8em; }
.bday { background: var(--bg); border-radius: 12px; padding: .5em; display: flex; flex-direction: column; gap: .35em; min-height: 0; overflow: hidden; }
.bday.today { background: color-mix(in srgb, var(--accent) 14%, var(--card)); outline: 2px solid var(--accent); }
.bdh { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; color: var(--muted); } .bdh b { color: var(--ink); font-size: 1.5em; }
.bev { background: color-mix(in srgb, var(--c) 22%, var(--card)); border-left: .3em solid var(--c); border-radius: 8px; padding: .25em .45em; font-size: .85em; font-weight: 700; line-height: 1.2; }
.bev small { display: block; font-weight: 600; color: var(--muted); font-size: .8em; } .bnone { text-align: center; }
.bchores { grid-area: chores; display: flex; flex-direction: column; } .blist { grid-area: list; } .bcount { grid-area: count; }
.bpeople { display: grid; grid-template-columns: repeat(auto-fit, minmax(11em, 1fr)); gap: .8em; overflow: auto; min-height: 0; }
.bperson { background: color-mix(in srgb, var(--c) 12%, var(--card)); border-radius: 12px; padding: .6em; display: grid; gap: .4em; align-content: start; }
.btask { display: flex; align-items: center; gap: .5em; font-weight: 700; } .btask.done { opacity: .55; text-decoration: line-through; }
.btask .check, .board .check { width: 1.4em; height: 1.4em; font-size: .9em; }
.bitems { list-style: none; margin: 0; padding: 0; columns: 2 12em; column-gap: 1em; font-weight: 700; } .bitems li { padding: .3em 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.bcd { display: flex; align-items: center; gap: .8em; padding: .4em 0; border-bottom: 1px solid var(--line); } .bcd .bigemoji { font-size: 2em; }
.board .daysleft b { font-size: 1.8em; }
@media (orientation: portrait) {
  #boardroot { overflow-y: auto; }
  .board { height: auto; min-height: 100%; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto auto;
    grid-template-areas: "head head" "cal cal" "chores chores" "list count"; }
  .bcal { min-height: 50vh; } .bclock { font-size: 3em; }
}
@media (max-width: 700px) {
  .board { font-size: 14px; } .bcal { grid-template-columns: 1fr; } .bday { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .board { grid-template-columns: 1fr; grid-template-areas: "head" "cal" "chores" "list" "count"; }
}
