:root {
  --bg: #F6F1E9;
  --surface: #FFFFFF;
  --surface-2: #EFE8DC;
  --ink: #1E2229;
  --ink-2: #5B6270;
  --ink-3: #8D93A0;
  --line: #E3DACB;
  --accent: #3B5BDB;
  --good: #2F9E44;
  --good-bg: #E3F5E6;
  --bad: #E03131;
  --bad-bg: #FDE7E7;
  --today: #E8890C;
  --today-bg: #FFF1DC;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --radius: 18px;
  --me: #3B5BDB;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181D;
    --surface: #20232A;
    --surface-2: #2A2E37;
    --ink: #F1F2F4;
    --ink-2: #B2B7C2;
    --ink-3: #7E8491;
    --line: #333844;
    --accent: #5C7CFA;
    --good: #51CF66;
    --good-bg: #1D3324;
    --bad: #FF6B6B;
    --bad-bg: #3A2224;
    --today: #FFA94D;
    --today-bg: #3A2C1A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 28px);
}
#app.with-tabs { padding-bottom: calc(env(safe-area-inset-bottom) + 96px); }

.splash { min-height: 80dvh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- avatars ---------- */
.av {
  --c: var(--accent);
  width: var(--s, 40px); height: var(--s, 40px);
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--c);
  font-size: calc(var(--s, 40px) * .52);
  line-height: 1;
  overflow: hidden;
}
.av img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- login ---------- */
.login-head { text-align: center; padding: 28px 0 22px; }
.login-head .house { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.login-head p { margin: 6px 0 0; color: var(--ink-2); }
.people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.person {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .12s;
}
.person:active { transform: scale(.97); }
.person .nm { font-weight: 600; font-size: 18px; }
.parents-label { margin: 26px 2px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.people.small .person { flex-direction: row; padding: 12px 14px; justify-content: flex-start; }
.people.small .person .nm { font-size: 16px; }

/* PIN pad */
.pin-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 18px; }
.pin-wrap .who { margin-top: 12px; font-size: 22px; font-weight: 600; }
.pin-wrap .hint { color: var(--ink-2); margin-top: 2px; min-height: 22px; text-align: center; }
.pin-wrap .hint.error { color: var(--bad); }
.dots { display: flex; gap: 16px; margin: 22px 0 26px; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-3); transition: background .1s; }
.dots span.on { background: var(--ink); border-color: var(--ink); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; }
.key {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 28px; font-weight: 500;
}
.key:active { background: var(--surface-2); }
.key.ghost { background: none; box-shadow: none; font-size: 16px; color: var(--ink-2); }
.back-link { align-self: flex-start; color: var(--ink-2); font-weight: 500; padding: 8px 2px; }

/* ---------- forms ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 13px; }
.input, select.input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: 17px; appearance: none;
}
.input:focus { border-color: var(--accent); outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: 14px; font-weight: 600; font-size: 17px;
  background: var(--accent); color: #fff; width: 100%;
}
.btn:active { filter: brightness(.92); }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: none; color: var(--bad); }
.btn[disabled] { opacity: .5; }
.row-btns { display: flex; gap: 10px; }
.form-error { color: var(--bad); min-height: 20px; font-size: 15px; margin: -4px 0 10px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 3px var(--surface); border: 2px solid transparent; }
.swatch.on { border-color: var(--ink); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 10px; font-size: 22px; background: var(--surface-2); }
.emoji-grid button.on { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .small { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.topbar .title .big { font-size: 22px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- week navigation ---------- */
.weeknav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.weeknav .label { font-weight: 600; text-align: center; }
.weeknav .label small { display: block; font-weight: 500; font-size: 12px; color: var(--accent); }
.weeknav .label button { color: var(--accent); font-size: 12px; font-weight: 600; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 18px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 8px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  position: relative;
}
.day .dw { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.day .dn { font-size: 18px; font-weight: 600; }
.day .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 2px; background: transparent; }
.day .dot.pending { background: var(--ink-3); opacity: .5; }
.day .dot.done { background: var(--good); }
.day .dot.overdue { background: var(--bad); }
.day.is-today .dw { color: var(--today); }
.day.sel { background: var(--ink); box-shadow: none; }
.day.sel .dw, .day.sel .dn { color: var(--bg); }
.day.sel.is-today .dw { color: var(--today); }

/* ---------- day content ---------- */
.dayhead { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 12px; }
.dayhead h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.dayhead .count { color: var(--ink-2); font-size: 15px; }
.section-label { margin: 22px 2px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }

.mine { display: flex; flex-direction: column; gap: 10px; }
.chore-card {
  --c: var(--me);
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow), inset 4px 0 0 var(--c);
  transition: transform .1s;
}
.chore-card:not(:disabled):active { transform: scale(.98); }
.chore-card .ic { font-size: 28px; width: 36px; text-align: center; flex: none; }
.chore-card .txt { flex: 1; min-width: 0; }
.chore-card .nm { font-size: 18px; font-weight: 600; }
.chore-card .sub { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.chore-card.done .nm { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: color-mix(in srgb, var(--good) 60%, transparent); }
.check {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--ink-3); display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check svg { width: 22px; height: 22px; opacity: 0; transform: scale(.5); transition: all .15s; color: #fff; }
.done .check { background: var(--good); border-color: var(--good); }
.done .check svg { opacity: 1; transform: none; }
.overdue .check { border-color: var(--bad); }
.chore-card.locked .check { border-style: dashed; opacity: .6; }
.chore-card.busy { opacity: .7; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; letter-spacing: .02em; vertical-align: 1px; }
.pill.done { background: var(--good-bg); color: var(--good); }
.pill.overdue { background: var(--bad-bg); color: var(--bad); }
.pill.today { background: var(--today-bg); color: var(--today); }
.pill.upcoming { background: var(--surface-2); color: var(--ink-2); }

.celebrate {
  background: var(--good-bg); color: var(--good); border-radius: var(--radius);
  padding: 14px 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; margin-bottom: 10px;
}
.empty { color: var(--ink-2); background: var(--surface); border-radius: var(--radius); padding: 18px; text-align: center; box-shadow: var(--shadow); }

/* groups (other people) */
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; }
.group-head .nm { font-weight: 600; flex: 1; }
.group-head .ct { font-size: 14px; color: var(--ink-2); }
.bar { height: 5px; border-radius: 9px; background: var(--surface-2); margin: 0 14px 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 9px; transition: width .3s; }
.line {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; border-top: 1px solid var(--line);
}
.line .ic { font-size: 20px; width: 26px; text-align: center; }
.line .nm { flex: 1; min-width: 0; }
.line .nm small { display: block; color: var(--ink-3); font-size: 12px; }
.line .check { width: 30px; height: 30px; border-width: 2px; }
.line .check svg { width: 17px; height: 17px; }
.line.done .nm { color: var(--ink-2); }
.line.tappable:active { background: var(--surface-2); }

/* ---------- admin tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

/* chores list (admin) */
.list { display: flex; flex-direction: column; gap: 10px; }
.chore-row { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; }
.chore-row .top { display: flex; align-items: center; gap: 12px; }
.chore-row .top .ic { font-size: 24px; }
.chore-row .top .nm { font-weight: 600; font-size: 17px; flex: 1; }
.week-mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-mini .cell { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.week-mini .cell .av { --s: 28px; font-size: 14px; }
.week-mini .cell .blank { width: 28px; height: 28px; border-radius: 50%; border: 1.5px dashed var(--line); }
.mover { display: flex; gap: 2px; }
.mover button { width: 32px; height: 32px; border-radius: 8px; color: var(--ink-3); display: grid; place-items: center; }
.mover button:active { background: var(--surface-2); }
.mover svg { width: 18px; height: 18px; }

.member-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; width: 100%; text-align: left; }
.member-row .nm { flex: 1; font-weight: 600; font-size: 17px; }
.member-row .nm small { display: block; color: var(--ink-3); font-weight: 500; font-size: 13px; }
.chev { color: var(--ink-3); width: 20px; height: 20px; }
.add-btn { margin-top: 14px; }
.note { color: var(--ink-2); font-size: 14px; margin: 10px 2px; }

/* schedule editor */
.sched { display: flex; flex-direction: column; gap: 2px; margin: 0 -18px; }
.sched-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 18px; }
.sched-row:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.sched-row .dl { width: 36px; font-weight: 600; color: var(--ink-2); flex: none; padding-top: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; flex: 1; }
.chip {
  --c: var(--ink-3);
  flex: none; display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px;
  border-radius: 99px; background: var(--surface-2); font-weight: 500; font-size: 15px;
  border: 2px solid transparent;
}
.chip .av { --s: 24px; font-size: 13px; }
.chip.none { padding: 7px 12px; color: var(--ink-2); }
.chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.chip.none.on { border-color: var(--ink-3); background: var(--surface); }

.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-row .av { --s: 64px; }
.link-btn { color: var(--accent); font-weight: 600; padding: 6px 0; }
.link-btn.danger { color: var(--bad); }

/* ---------- bottom sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 40; animation: fade .18s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 16px; font-size: 21px; display: flex; align-items: center; justify-content: space-between; }
.sheet h3 button { font-size: 16px; color: var(--ink-2); font-weight: 500; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 4px; font-size: 17px; font-weight: 500; border-bottom: 1px solid var(--line); text-align: left; }
.menu-item:last-child { border-bottom: 0; }
.menu-item svg { width: 22px; height: 22px; color: var(--ink-2); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
body.has-tabs .toast { bottom: calc(env(safe-area-inset-bottom) + 92px); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  display: flex; gap: 14px; align-items: center; font-weight: 500; max-width: calc(100% - 32px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25); animation: fade .2s;
}
.toast button { color: var(--today); font-weight: 700; }
.toast.err { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 420px) {
  .people { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- v2: families, help, permissions, owner ---------- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.landing { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }
.brand { text-align: center; padding: 8px 4px 6px; }
.brand img { border-radius: 18px; box-shadow: var(--shadow); }
.brand h1 { margin: 14px 0 6px; font-size: 30px; letter-spacing: -.02em; }
.brand p { margin: 0 auto; max-width: 340px; color: var(--ink-2); }
.join .field { margin-bottom: 12px; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-transform: lowercase; letter-spacing: .08em; }
.foot-links { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 22px; color: var(--ink-3); font-size: 15px; }
.foot-links .link-btn { font-weight: 500; text-decoration: none; }
a.link-btn { text-decoration: none; }
.back-link { display: inline-block; }

.code-card { text-align: center; }
.code-big { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 34px; font-weight: 700; letter-spacing: .12em; margin: 4px 0 6px; word-break: break-all; }
.code-link { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; word-break: break-all; }
.code-card .row-btns .btn { padding: 12px 10px; font-size: 16px; }
.callout { margin: 14px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--today-bg); color: var(--ink); line-height: 1.45; font-size: 15px; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 6px 2px 16px; font-weight: 600; }
.check-row input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }

a.btn { text-decoration: none; }
.btn svg { width: 20px; height: 20px; }
.btn.small { padding: 10px 12px; font-size: 15px; border-radius: 12px; }
.btn.danger-outline { background: none; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.btn.danger-solid { background: var(--bad); color: #fff; }

.switch-row { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.switch-row > span { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.switch-row b { font-weight: 600; font-size: 16px; }
.switch-row small { color: var(--ink-3); font-size: 13px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.seg button { font-size: 15px; padding: 10px 6px; }

.confirm-chore { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.confirm-chore .ic { font-size: 30px; }
.confirm-chore small { display: block; color: var(--ink-2); margin-top: 2px; }
.line.busy { opacity: .6; }

.fam-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.fam-name { font-weight: 700; font-size: 18px; }
.fam-sub { color: var(--ink-2); font-size: 14px; }
.fam-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 6px 12px; font-size: 16px; margin: 4px 0; }
.fam-card .row-btns { margin-top: 4px; }

.export-btns { display: flex; flex-direction: column; gap: 10px; }
