:root {
  --ground: #F1F2F4;
  --card: #FFFFFF;
  --ink: #0C0D10;
  --muted: #5A5E66;
  --line: #ECEDF0;
  --edge: #C4C8D0;
  --lime: #D4FF3A;
  --danger: #B3261E;
  --display: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs: 17px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--fs)/1.25 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body.board { --fs: 20px; overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.ellipsis { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; gap: 16px; }
body.board .app { height: 100%; padding: 32px; }
body.phone .app { min-height: 100%; padding: 20px 12px 104px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 4px; }
body.board .top { height: 72px; flex: none; }
body.phone .top { padding: 8px 12px 0; }
.top h1, .clock { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: 1; white-space: nowrap; }
body.board .top h1, body.board .clock { font-size: 40px; }
body.phone .top h1 { font-size: 26px; }
body.phone .clock { display: none; }
.clock { font-variant-numeric: tabular-nums; }
.top-right { display: flex; align-items: center; gap: 16px; }

.grid { display: flex; flex-direction: column; gap: 16px; }
body.board .grid {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1.12fr) minmax(0, 1fr);
}
body.board #today { grid-column: 1; grid-row: 1; }
body.board #dinner { grid-column: 2; grid-row: 1; }
body.board #shopping { grid-column: 3; grid-row: 1 / span 2; }
body.board #stickers { grid-column: 1 / span 2; grid-row: 2; }

body.phone .card { display: none; }
body.phone[data-view="home"] .card[data-views~="home"],
body.phone[data-view="shopping"] .card[data-views~="shopping"],
body.phone[data-view="stickers"] .card[data-views~="stickers"] { display: flex; }
body.phone[data-view="shopping"] #shopping { min-height: calc(100dvh - 220px); }

.card { background: var(--card); border-radius: 28px; padding: 24px; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
.label { font-size: 16px; line-height: 20px; font-weight: 600; color: var(--muted); }
.card > .label { margin-bottom: 12px; }
.fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---------- Controls ---------- */
.chip { display: inline-flex; align-items: center; padding: 10px 14px; border-radius: 999px; background: var(--ground); font-size: 14px; line-height: 1; font-weight: 600; white-space: nowrap; }
.top .chip { background: var(--card); }
.tag { margin-left: auto; flex: 0 100 auto; min-width: 44px; padding: 6px 10px; border-radius: 999px; background: var(--ground); font-size: 13px; line-height: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn { height: 48px; padding: 0 20px; border-radius: 16px; border: 1.5px solid transparent; font: 600 16px/1 var(--text); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-dark { background: var(--ink); color: #FFFFFF; }
.btn-dark:disabled { background: var(--edge); color: #FFFFFF; cursor: default; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--edge); }
.btn-lime { background: var(--lime); color: var(--ink); }
.btn-wide { width: 100%; }
.btn-small { height: 44px; padding: 0 14px; font-size: 15px; border-radius: 14px; }
.link-btn { height: 44px; padding: 0 2px; margin: -8px 0; border: none; background: none; font: 600 15px/1 var(--text); text-decoration: underline; text-underline-offset: 4px; white-space: nowrap; }
.icon-btn { width: 48px; height: 48px; border-radius: 16px; border: none; background: var(--card); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.square-btn { width: 52px; height: 52px; border-radius: 16px; border: none; background: var(--ink); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; flex: none; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; min-width: 0; height: 52px; border-radius: 16px; border: 1.5px solid var(--edge); background: var(--card);
  padding: 0 16px; font: 400 17px/1.2 var(--text);
}
textarea { height: auto; min-height: 96px; padding: 14px 16px; resize: vertical; }
input[type="checkbox"] { width: 24px; height: 24px; margin: 0; accent-color: var(--ink); flex: none; }
.form-error { min-height: 20px; margin-top: 8px; color: var(--danger); font-size: 15px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Today ---------- */
.events li { min-height: 50px; display: flex; align-items: center; gap: 14px; padding: 6px 0; }
.events li + li { border-top: 1px solid var(--line); }
.ev-time { width: 64px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-title { flex: 1; font-weight: 500; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; font-weight: 600; background: var(--ground); }
.sub-label { margin: 10px 0 2px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---------- Dinner ---------- */
.meal-name { font-family: var(--display); font-weight: 800; font-size: 32px; line-height: 36px; letter-spacing: -0.03em; }
body.phone .meal-name { font-size: 28px; line-height: 32px; }
.meal-sub { margin-top: 6px; font-size: 16px; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 16px 0; }
.week li { height: 52px; border-radius: 14px; background: var(--ground); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; line-height: 1; font-weight: 600; }
.week li.none { background: none; border: 1.5px dashed #A9AEB8; color: var(--muted); }
.week li.now { background: var(--ink); color: #FFFFFF; border: none; }
.week .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.week li.now .dot { background: var(--lime); }
.push-down { margin-top: auto; }

/* ---------- Shopping ---------- */
.add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.item { min-height: 50px; display: flex; align-items: center; gap: 14px; font-weight: 500; padding: 4px 0; }
.item .name { flex: 0 1 auto; overflow-wrap: break-word; }
.item .qty { color: var(--muted); font-size: 0.8em; font-weight: 400; white-space: nowrap; }
.item.done { color: var(--muted); font-weight: 400; }
.item.done .name { text-decoration: line-through; }
.group-label { padding: 12px 0 2px; font-size: 13px; line-height: 1; font-weight: 600; color: var(--muted); }
.ticked { margin-top: 6px; border-top: 1px solid var(--line); }
.ticked-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }

/* ---------- Stickers ---------- */
.kids { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.kid { border-radius: 20px; padding: 20px; display: flex; flex-direction: column; min-width: 0; background: var(--ground); }
.kid-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kid-name { border: none; background: none; padding: 0; min-height: 44px; margin: -8px 0; font: 800 22px/28px var(--display); letter-spacing: -0.02em; text-align: left; }
.kid-count { display: inline-flex; align-items: center; gap: 6px; font: 800 22px/28px var(--display); white-space: nowrap; }
.bar { margin-top: 10px; height: 10px; border-radius: 999px; background: #FFFFFF; overflow: hidden; }
.bar > div { height: 100%; background: var(--ink); border-radius: 999px; }
.kid-goal { margin: 6px 0 14px; font-size: 15px; line-height: 20px; color: #2B2D33; }
.chores { margin-top: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chore { min-height: 44px; padding: 6px 8px; border-radius: 14px; border: none; background: #FFFFFF; color: var(--ink); font: 600 15px/1.1 var(--text); overflow: hidden; text-overflow: ellipsis; }
.chore[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.kid.pop { animation: pop 0.5s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .kid.pop { animation: none; } }

/* ---------- Tabs (phone) ---------- */
.tabs { display: none; }
body.phone .tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(76px + env(safe-area-inset-bottom, 0px)); padding: 0 12px env(safe-area-inset-bottom, 0px);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font: 500 12px/1 var(--text); }
.tabs button[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- Sheets ---------- */
.sheet { border: none; border-radius: 28px; padding: 28px; width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--card); color: var(--ink); overflow-y: auto; }
.sheet::backdrop { background: rgba(12, 13, 16, 0.45); }
.sheet-small { width: min(420px, calc(100vw - 32px)); }
body.phone .sheet:not(.sheet-small) { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 32px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-title { font: 800 26px/1.1 var(--display); letter-spacing: -0.03em; }
.sheet h3 { margin: 24px 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.rows li { min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: none; }
.rows .grow { flex: 1; min-width: 0; }
.rows .small { font-size: 14px; color: var(--muted); }
.day-name { width: 96px; flex: none; font-weight: 600; }
.form-grid { display: grid; gap: 8px; }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-inline > input, .form-inline > select { flex: 1 1 140px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; flex: none; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.pick-list button { min-height: 52px; padding: 8px 14px; border-radius: 16px; border: none; background: var(--ground); font: 500 16px/1.2 var(--text); text-align: left; }

/* ---------- Gate ---------- */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--ground); }
.gate-card { width: min(380px, 100%); background: var(--card); border-radius: 28px; padding: 32px; display: grid; gap: 12px; }
.gate-card h1 { font: 800 32px/1 var(--display); letter-spacing: -0.03em; margin-bottom: 8px; }
.gate-card label { font-size: 15px; font-weight: 600; color: var(--muted); }

/* ---------- Screensaver ---------- */
.saver { position: fixed; inset: 0; z-index: 20; background: #0C0D10; color: #C9CCD3; display: flex; align-items: center; justify-content: center; }
.saver-inner { text-align: center; transition: transform 2s ease; }
.saver-time { font: 800 160px/1 var(--display); letter-spacing: -0.04em; color: #FFFFFF; font-variant-numeric: tabular-nums; }
.saver-date { margin-top: 16px; font-size: 28px; }
.saver-dinner { margin-top: 24px; font-size: 24px; color: var(--lime); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(108px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px); padding: 14px 20px; border-radius: 16px; background: var(--ink); color: #FFFFFF; font-size: 16px; font-weight: 500; text-align: center; }
body.board .toast { bottom: 40px; }
