:root {
  --base: #EDF2EF;      /* mint-grey wall */
  --surface: #FFFFFF;
  --sunk: #E2E9E5;
  --ink: #1E2A32;       /* deep slate */
  --ink-2: #51616B;
  --ink-3: #82919A;
  --line: #D3DDD8;
  --star: #F2B705;
  --star-deep: #B98600;
  --danger: #C2412D;
  --ok: #2F7D5B;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --rail: 104px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--base); color: var(--ink);
  font: 17px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2B6CB0; outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; height: 100vh; height: 100dvh; }
.rail {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 10px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.rail .logo { font-size: 30px; text-align: center; margin-bottom: 14px; }
.rail button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; border-radius: var(--radius);
  padding: 12px 4px; font-size: 14px; color: var(--ink-2); font-weight: 700;
}
.rail button .ic { font-size: 26px; line-height: 1; filter: grayscale(.4); }
.rail button[aria-current="page"] { background: var(--ink); color: #fff; }
.rail button[aria-current="page"] .ic { filter: none; }
.rail .spacer { flex: 1; }
.rail button { position: relative; }
.navbadge { position: absolute; top: 4px; right: 14px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 13px; font-weight: 700; line-height: 22px; text-align: center; }
.reviewcard { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; box-shadow: inset 0 0 0 2px var(--star); }
.reviewhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.reviewcard .li { padding: 10px 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 16px 28px 10px;
}
.clock { font-family: var(--display); font-weight: 800; font-size: 46px; line-height: 1; letter-spacing: -.02em; }
.datebig { display: flex; flex-direction: column; }
.datebig strong { font-family: var(--display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.datebig span { color: var(--ink-2); font-size: 15px; }
.topbar .grow { flex: 1; }
.lockbtn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 10px 16px; font-weight: 700; font-size: 15px;
}
.lockbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.content { flex: 1; overflow: auto; padding: 8px 28px 28px; min-height: 0; }

.viewhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.viewhead h1 { font-family: var(--display); font-weight: 800; font-size: 32px; margin: 0; letter-spacing: -.01em; }
.viewhead .grow { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 700;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; }
.plusbtn {
  width: 52px; height: 52px; border-radius: 999px; border: 0; background: var(--ink); color: #fff;
  font-size: 32px; font-weight: 400; line-height: 1; display: inline-grid; place-items: center; padding-bottom: 3px;
}
.plusbtn[aria-expanded="true"] { background: var(--ink-2); }
.addmenu {
  position: fixed; z-index: 40; background: var(--surface); border-radius: var(--radius); padding: 6px; min-width: 230px;
  box-shadow: 0 12px 32px rgba(30,42,50,.22), 0 0 0 1px var(--line);
}
.addmenu button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 14px;
  border: 0; background: none; border-radius: var(--radius-sm); font-weight: 700; text-align: left;
}
.addmenu button span { font-size: 22px; width: 26px; text-align: center; }
.addmenu button:hover, .addmenu button:focus-visible { background: var(--sunk); }
.iconbtn {
  width: 48px; height: 48px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; display: inline-grid; place-items: center;
}
.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 9px 18px; font-weight: 700; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(30,42,50,.15); }

/* ---------- people columns ---------- */
.people { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.person {
  background: var(--surface); border-radius: var(--radius-lg);
  border-top: 8px solid var(--c); min-height: 200px;
  display: flex; flex-direction: column;
}
.person-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--c) 18%, white);
  display: grid; place-items: center; font-size: 28px;
  box-shadow: inset 0 0 0 3px var(--c);
}
.avatar.has-photo { background: var(--c); padding: 3px; box-shadow: none; overflow: hidden; }
.avatar.sm.has-photo { padding: 2px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #fff; }
.avatar.sm { width: 36px; height: 36px; font-size: 19px; box-shadow: inset 0 0 0 2px var(--c); }
.person-name { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.05; }
.starcount {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--display); font-weight: 800; font-size: 26px; color: var(--ink);
}
.starcount .s { color: var(--star); font-size: 26px; display: inline-block; }
.starcount.pop .s { animation: pop .7s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { 0% { transform: scale(1) rotate(0); } 40% { transform: scale(1.8) rotate(-18deg); } 100% { transform: scale(1) rotate(0); } }
.section { padding: 6px 16px 14px; }
.section + .section { border-top: 1px solid var(--line); padding-top: 12px; }
.section h3 { margin: 0 0 8px; font-size: 15px; color: var(--ink-2); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section h3 .count { margin-left: auto; font-weight: 400; color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 15px; padding: 4px 0; }

.ev { display: flex; gap: 10px; padding: 7px 0; align-items: baseline; }
.ev .t { width: 66px; flex: none; color: var(--ink-2); font-size: 14px; font-weight: 700; }
.ev .n { font-weight: 700; }
.ev .loc { display: block; color: var(--ink-3); font-size: 14px; font-weight: 400; }
.ev.past { opacity: .5; }

.chore {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: color-mix(in srgb, var(--c) 7%, white); border-radius: var(--radius);
  padding: 11px 12px; margin-bottom: 8px; min-height: 60px;
}
.chore .emo { font-size: 24px; width: 30px; text-align: center; flex: none; }
.chore .txt { flex: 1; font-weight: 700; line-height: 1.2; }
.chore .txt small { display: block; font-weight: 400; color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.chore .val { color: var(--star-deep); font-weight: 700; font-size: 15px; white-space: nowrap; }
.check {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  border: 3px solid var(--c); display: grid; place-items: center; color: #fff; font-weight: 800;
  transition: background .15s;
}
.chore.done { background: var(--sunk); }
.chore.done .txt { text-decoration: line-through; color: var(--ink-3); }
.chore.done .check { background: var(--c); }
.progress { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; margin: 0 16px 10px; }
.progress i { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .3s; }

.meal { display: flex; gap: 10px; padding: 4px 0; }
.meal .slot { width: 66px; flex: none; color: var(--ink-2); font-size: 14px; font-weight: 700; text-transform: capitalize; }

.familystrip {
  background: var(--surface); border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-start;
}
.familystrip h3 { margin: 0 0 6px; font-size: 15px; color: var(--ink-2); }
.familystrip .col { min-width: 220px; flex: 1; }

/* ---------- calendar ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 7px 14px 7px 8px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, white);
  font-weight: 700; font-size: 15px;
}
.chip[aria-pressed="false"] { background: var(--surface); border-color: var(--line); color: var(--ink-3); }
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 10px; overflow-x: auto; }
.day { background: var(--surface); border-radius: var(--radius); min-height: max(340px, calc(100dvh - 290px)); padding: 10px; }
.day.today { box-shadow: inset 0 0 0 3px var(--ink); }
.dayhead { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.dayhead b { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1; }
.dayhead span { color: var(--ink-2); font-weight: 700; }
.evchip {
  display: block; width: 100%; text-align: left; border: 0;
  background: color-mix(in srgb, var(--c) 15%, white); border-left: 5px solid var(--c);
  border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: 14px; line-height: 1.25;
}
.evchip b { display: block; font-size: 15px; }
.evchip.allday { background: var(--c); color: #fff; border-left-color: var(--c); }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .dow { text-align: center; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.mcell { background: var(--surface); border-radius: var(--radius-sm); min-height: 112px; padding: 6px; border: 0; text-align: left; display: flex; flex-direction: column; gap: 3px; }
.mcell.other { opacity: .45; }
.mcell.today { box-shadow: inset 0 0 0 3px var(--ink); }
.mcell .num { font-family: var(--display); font-weight: 800; font-size: 18px; }
.mchip { font-size: 13px; line-height: 1.2; padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 18%, white); border-left: 4px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 13px; color: var(--ink-2); font-weight: 700; }
.calerr { background: #FDECE8; color: var(--danger); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 15px; }

/* ---------- meals ---------- */
.mealgrid { display: grid; grid-template-columns: 110px repeat(7, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; }
.mealgrid .hd { font-weight: 700; color: var(--ink-2); padding: 4px 6px; }
.mealgrid .hd b { font-family: var(--display); font-size: 22px; color: var(--ink); display: block; line-height: 1; }
.mealgrid .hd.today b { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; }
.mealgrid .slotname { font-weight: 700; text-transform: capitalize; align-self: center; padding-left: 4px; }
.mcellm { background: var(--surface); border-radius: var(--radius-sm); min-height: 84px; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.mitem { border: 0; text-align: left; background: var(--sunk); border-radius: 8px; padding: 6px 8px; font-weight: 700; font-size: 15px; line-height: 1.2; border-left: 4px solid var(--c, var(--ink-3)); }
.mitem small { display: block; font-weight: 400; color: var(--ink-2); font-size: 13px; }
.addcell { border: 1.5px dashed var(--line); background: none; border-radius: 8px; color: var(--ink-3); font-size: 20px; min-height: 34px; margin-top: auto; }

/* ---------- rewards ---------- */
.balances { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 26px; }
.balance { background: var(--surface); border-radius: var(--radius-lg); border-top: 8px solid var(--c); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.balance .row { display: flex; align-items: center; gap: 10px; }
.bignum { font-family: var(--display); font-weight: 800; font-size: 56px; line-height: .9; letter-spacing: -.03em; }
.bignum .s { color: var(--star); font-size: 40px; vertical-align: 6px; }
.subhead { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 4px 0 12px; }
.rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 26px; }
.reward { background: var(--surface); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.reward .emo { font-size: 44px; line-height: 1; }
.reward .title { font-weight: 700; font-size: 19px; line-height: 1.2; }
.reward .cost { font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--star-deep); }
.reward .who { color: var(--ink-3); font-size: 14px; }
.reward .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.list { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 26px; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .meta { color: var(--ink-3); font-size: 14px; }
.delta { font-family: var(--display); font-weight: 800; font-size: 18px; }
.delta.plus { color: var(--ok); }
.delta.minus { color: var(--danger); }
.badge { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--sunk); color: var(--ink-2); }
.badge.pending { background: #FFF2C6; color: #7A5A00; }
.badge.approved { background: #DDF1E6; color: var(--ok); }
.badge.denied { background: #FDECE8; color: var(--danger); }

/* ---------- settings ---------- */
.settings { max-width: 760px; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 18px; }
.card h2 { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 0 0 12px; }
.help { color: var(--ink-2); font-size: 15px; }
.help ol { padding-left: 20px; margin: 6px 0; }

/* ---------- forms & modal ---------- */
dialog {
  border: 0; border-radius: var(--radius-lg); padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 60px rgba(30,42,50,.3);
}
dialog.wide { width: min(860px, calc(100vw - 24px)); }
.ptable { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ptable table { width: 100%; border-collapse: collapse; font-size: 15px; }
.ptable th { position: sticky; top: 0; background: var(--sunk); text-align: left; padding: 8px 10px; font-weight: 700; }
.ptable td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.ptable td:first-child { color: var(--ink-3); width: 48px; }
.ptable tr.bad td { color: var(--danger); background: #FDF3F0; }
.ptable tr.bad + tr.bad td { border-top: 0; padding-top: 0; }
dialog::backdrop { background: rgba(30,42,50,.45); }
.mhead { display: flex; align-items: center; padding: 18px 20px 6px; gap: 12px; }
.mhead h2 { font-family: var(--display); font-weight: 800; font-size: 24px; margin: 0; flex: 1; }
.mbody { padding: 8px 20px 4px; }
.mfoot { display: flex; gap: 10px; padding: 14px 20px 20px; flex-wrap: wrap; }
.mfoot .grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 700; font-size: 15px; }
.field small { color: var(--ink-3); font-size: 14px; }
.input {
  width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; padding: 10px 14px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--ink); outline: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.pick[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.pick.emo { font-size: 22px; padding: 0; width: 46px; justify-content: center; }
.pick.emo[aria-pressed="true"] { background: var(--sunk); color: inherit; box-shadow: inset 0 0 0 2px var(--ink); }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); background: var(--c); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.err { color: var(--danger); font-weight: 700; font-size: 15px; min-height: 1em; }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper output { font-family: var(--display); font-weight: 800; font-size: 28px; min-width: 70px; text-align: center; }

/* PIN pad */
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin: 10px 0; }
.pinpad button { height: 68px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-family: var(--display); font-weight: 700; font-size: 28px; }
.pindots { display: flex; gap: 14px; justify-content: center; margin: 4px 0 6px; }
.pindots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.pindots i.on { background: var(--ink); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.authcard { width: min(440px, 100%); background: var(--surface); border-radius: 28px; padding: 30px; }
.authcard h1 { font-family: var(--display); font-weight: 800; font-size: 38px; margin: 0 0 4px; letter-spacing: -.02em; }
.authcard .lede { color: var(--ink-2); margin: 0 0 20px; }
.authcard .swap { margin-top: 16px; text-align: center; color: var(--ink-2); }
.linkbtn { border: 0; background: none; color: var(--ink); font-weight: 700; text-decoration: underline; padding: 4px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, calc(100% + 48px));
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 999px; font-weight: 700;
  transition: transform .25s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  :root { --rail: 0px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .rail .logo, .rail .spacer { display: none; }
  .rail button { flex: 1; min-width: 0; padding: 8px 0; font-size: 11px; }
  .rail button .ic { font-size: 22px; }
  .balances { grid-template-columns: 1fr 1fr; }
  .bignum { font-size: 44px; }
  .datebig span { font-size: 13px; }
  .topbar { padding: 12px 16px 6px; }
  .clock { font-size: 34px; }
  .content { padding: 6px 16px 20px; }
  .people { grid-auto-flow: row; grid-auto-columns: auto; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
