:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --text: #141a33;
  --muted: #6b6880;
  --line: #e4e2ee;
  --brand: #0866e6;
  --brand-ink: #ffffff;
  --brand-soft: #e7f0ff;
  --star: #f7b500;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --err: #c53030;
  --err-soft: #fde8e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 16, 60, .06), 0 4px 16px rgba(20, 16, 60, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  body.mode-parent, body.mode-public:not([class*="theme-"]) {
    --bg: #14131c;
    --surface: #1e1d29;
    --text: #ecebf5;
    --muted: #a19fb5;
    --line: #2f2d3d;
    --brand: #4b9bff;
    --brand-ink: #04142e;
    --brand-soft: #14284a;
    --ok-soft: #173826;
    --warn-soft: #3a2d14;
    --err-soft: #3d1b1b;
  }
}

/* Child themes */
body.theme-bright {
  --bg: #fff8e7;
  --brand: #ff7a1a;
  --brand-soft: #ffe7d1;
  --radius: 22px;
  --font: "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
}
body.theme-clean {
  --bg: #f3f5f7;
  --brand: #2563eb;
  --brand-soft: #dbe6fd;
  --radius: 12px;
}
/* Teen (13+): dark, compact, grown-up type, one accent colour, no cartoon chrome. */
body.theme-teen {
  --bg: #0f1115;
  --surface: #181b22;
  --text: #e8eaf0;
  --muted: #9097a3;
  --line: #262a33;
  --brand: #2dd4bf;
  --brand-ink: #062621;
  --brand-soft: rgba(45, 212, 191, .14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .14);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .14);
  --radius: 12px;
  --shadow: none;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .75em; }
h3 { font-size: 1rem; margin: 0 0 .5em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.inline { display: inline; }

.wrap { max-width: 960px; margin: 0 auto; padding: 16px 16px 96px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.tabs a {
  padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500;
}
.tabs a.on, .tabs a:hover { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 640px) {
  .tabs { margin-left: 0; width: 100%; }
}
.topbar.kid { justify-content: space-between; font-size: 1.15rem; flex-wrap: nowrap; }
.kid-right { display: flex; align-items: center; gap: 10px; }
.grownups { font-size: .8rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a.tab-kid { color: var(--brand); border: 1px solid var(--brand-soft); }
.btn-kid { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); }
.btn-kid .big-icon { font-size: 1.4rem; }
.child-head-action { margin-left: auto; }
.kid-signin { text-align: center; }
.kid-signin h2 { margin-bottom: .5em; }
.balance-pill {
  background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 6px 14px; border-radius: 999px;
}

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin: 0 0 16px; display: block; color: inherit;
}
.card.narrow, .narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.danger { border: 1px solid var(--err-soft); }
a.card { text-decoration: none; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.child-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.avatar-xl { font-size: 3.5rem; line-height: 1; }
.points-lg { font-size: 1.4rem; font-weight: 700; color: var(--brand); margin: 0; }
.child-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.child-head h1 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.count {
  display: inline-block; min-width: 1.6em; padding: 0 .45em; border-radius: 999px; text-align: center;
  background: var(--brand-soft); color: var(--brand); font-size: .85rem;
}
.step { color: var(--brand); font-weight: 600; margin: 0; }

/* Forms */
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--brand); }
label.radio { display: flex; align-items: center; gap: 10px; font-weight: 400; }
label.radio.inline { display: inline-flex; margin-right: 16px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-weight: 500; margin-bottom: 6px; padding: 0; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form input:not([type="hidden"]) { flex: 1; min-width: 160px; width: auto; }
.inline-form label { flex: 1; }
.w-sm { max-width: 110px; min-width: 90px !important; flex: 0 !important; }
.w-md { max-width: 240px; }
.code-input { text-align: center; letter-spacing: .3em; font-weight: 700; font-size: 1.3rem; }
.code-input.big { font-size: 2rem; padding: 14px; }

.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker input { position: absolute; opacity: 0; pointer-events: none; }
.picker label {
  width: 48px; height: 48px; display: grid; place-items: center; font-size: 1.6rem;
  border-radius: 12px; border: 2px solid var(--line); background: var(--surface); cursor: pointer;
}
.picker input:checked + label { border-color: var(--brand); background: var(--brand-soft); }
.picker input:focus-visible + label { outline: 2px solid var(--brand); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn-lg { min-height: 54px; padding: 12px 24px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 16px; text-align: center; margin-top: 16px; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; background: var(--ok-soft); }
.flash-err { background: var(--err-soft); color: var(--err); }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); }

/* Badges */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.b-submitted, .b-pending { background: var(--warn-soft); color: var(--warn); }
.b-approved, .b-fulfilled { background: var(--ok-soft); color: var(--ok); }
.b-returned, .b-declined { background: var(--err-soft); color: var(--err); }

/* Lists */
.plain { list-style: none; margin: 0; padding: 0; }
.list-rows li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.list-rows li:last-child { border-bottom: 0; }
.list-rows li.faded { opacity: .55; }
.kid-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.kid-columns li { padding: 4px 0; }
.due-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.due-list li:last-child { border-bottom: 0; }
.btn-tick { min-width: 40px; color: var(--ok); border-color: var(--ok); font-size: 1.05rem; }
.btn-tick:hover { background: var(--ok); color: #fff; border-color: var(--ok); }
.task-row { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.task-row span { display: flex; flex-direction: column; }
.big-icon { font-size: 1.6rem; }

.table { width: 100%; border-collapse: collapse; }
.table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--err); }

/* Approvals */
.approval { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.approval:last-child { border-bottom: 0; }
.approval-main { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 220px; }
.approval-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.approval-actions form { display: flex; gap: 8px; }
.thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; display: block; }
.sendback summary { list-style: none; }
.sendback summary::-webkit-details-marker { display: none; }
.sendback[open] summary { display: none; }

/* Templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tpl {
  display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-weight: 400;
}
.tpl:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.tpl input { grid-row: span 2; }
.tpl-icon { grid-row: span 2; font-size: 1.6rem; }
.tpl-title { font-weight: 600; }
.tpl-meta { font-size: .82rem; color: var(--muted); grid-column: 3; }

/* Pairing */
.pair-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
#qr { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.pair-code { font-size: 2.2rem; font-weight: 800; letter-spacing: .15em; margin: .2em 0; font-variant-numeric: tabular-nums; }

/* Landing */
.hero { text-align: center; max-width: 620px; margin: 6vh auto 0; }
.hero-emoji { font-size: 3rem; }
.hero h1 { font-size: 2.1rem; }
.lead { font-size: 1.15rem; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 24px 0; }

/* ---------- Child mode ---------- */
.mode-child .wrap { max-width: 640px; }
.kid-title { font-size: 1.9rem; }
.kidnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.kidnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px; border-radius: 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
}
.kidnav a span { font-size: 1.6rem; line-height: 1; }
.kidnav a.on { background: var(--brand-soft); color: var(--brand); }
.theme-clean .kidnav a span { font-size: 1.25rem; filter: grayscale(1); }

.progress { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress.small { height: 8px; margin: 6px 0; }
.progress-bar { height: 100%; background: var(--brand); border-radius: inherit; transition: width .6s ease; }

.task-cards { display: grid; gap: 12px; margin: 16px 0; }
.task-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.task-card-top { display: flex; align-items: center; gap: 14px; }
.task-icon { font-size: 2.6rem; line-height: 1; }
.theme-clean .task-icon { font-size: 1.6rem; }
.task-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.task-text strong { font-size: 1.15rem; }
.task-points { font-weight: 800; font-size: 1.3rem; color: var(--brand); }
.task-card.s-approved { opacity: .7; }
.task-card.s-missed { opacity: .5; }
.task-card.s-returned { border: 2px solid var(--err-soft); }
.returned-note { background: var(--err-soft); color: var(--err); border-radius: 10px; padding: 8px 12px; margin: 12px 0 0; }
.done-form { margin-top: 12px; }
.btn-done { width: 100%; min-height: 58px; font-size: 1.2rem; background: var(--ok); border-color: var(--ok); color: #fff; border-radius: calc(var(--radius) - 6px); }
.photo-btn {
  display: flex; align-items: center; justify-content: center; min-height: 58px; font-size: 1.1rem; font-weight: 700;
  border-radius: calc(var(--radius) - 6px); border: 2px dashed var(--brand); color: var(--brand); cursor: pointer;
}
.photo-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.task-status { margin-top: 10px; text-align: right; }
.theme-bright .task-text .muted:not(.hw-when) { display: none; }

.goal-card { display: flex; align-items: center; gap: 14px; }

.jar-wrap { padding: 16px 0; }
.jar {
  position: relative; width: 200px; height: 240px; margin: 0 auto 16px;
  border: 6px solid var(--brand); border-top-width: 14px; border-radius: 24px 24px 60px 60px;
  overflow: hidden; background: var(--surface);
}
.jar-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--fill);
  background: linear-gradient(180deg, #ffd34d, #ffb000); transition: height 1s ease;
}
.theme-clean .jar-fill { background: linear-gradient(180deg, #7aa7ff, var(--brand)); }
.jar-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; }
.jar-num { font-size: 3rem; line-height: 1; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shop-item {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.shop-item form, .shop-item .progress { width: 100%; }
.shop-item .btn { width: 100%; }
.shop-item.locked .shop-icon { filter: grayscale(.8); opacity: .6; }
.shop-icon { font-size: 2.8rem; }
.shop-cost { font-weight: 800; color: var(--brand); }

/* Celebration */
.celebrate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 16, 40, .55); animation: fade .25s ease;
}
.celebrate-card {
  background: var(--surface); border-radius: 24px; padding: 28px 24px; text-align: center; max-width: 360px; width: 100%;
  animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.celebrate-card h2 { font-size: 2rem; color: var(--brand); margin: .2em 0; }
.celebrate-burst { font-size: 3.5rem; }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 51; border-radius: 2px; animation: fall linear forwards; pointer-events: none; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) {
  .celebrate, .celebrate-card, .confetti { animation: none; }
  .confetti { display: none; }
}

@media (max-width: 480px) {
  .cols-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  .hero h1 { font-size: 1.7rem; }
  .card { padding: 16px; }
}

/* ---------- Child app: shared additions ---------- */
.kid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.progress-label { margin: 6px 0 14px; text-align: center; }
.section-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.section-label .muted { font-weight: 400; }
.late { color: var(--warn) !important; }
.kid-avatar { font-size: 1.2em; }
.nav-ico { display: grid; place-items: center; height: 26px; }
.nav-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty p { margin: 0; }

/* Clean: no emoji filter needed now that it uses line icons */
.theme-clean .kidnav a span { filter: none; }
.theme-clean .section-label, .theme-teen .section-label { text-align: left; }

/* ---------- Teen ---------- */
.theme-teen .topbar { background: rgba(15, 17, 21, .92); backdrop-filter: blur(8px); border-color: var(--line); font-size: 1rem; }
.theme-teen .kid-avatar { font-size: 1rem; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--line); }
.theme-teen .balance-pill { background: var(--brand-soft); color: var(--brand); font-variant-numeric: tabular-nums; }
.theme-teen .grownups { color: var(--muted); }
.theme-teen h1, .theme-teen h2 { letter-spacing: -.01em; }
.theme-teen .kid-title { font-size: 1.5rem; margin: .5em 0 .2em; }
.theme-teen .progress { height: 6px; }
.theme-teen .progress-label { text-align: left; font-size: .9rem; }
.theme-teen .card { border: 1px solid var(--line); }
.theme-teen .btn { border-color: var(--line); background: var(--surface); color: var(--text); }
.theme-teen .btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.theme-teen input, .theme-teen select { background: var(--bg); }

.theme-teen .task-cards { gap: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.theme-teen .task-card {
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
  border-radius: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); background: none;
}
.theme-teen .task-card:last-child { border-bottom: 0; }
.theme-teen .task-card-top { gap: 12px; min-width: 0; }
.theme-teen .task-icon { font-size: 1.15rem; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--line); flex: none; }
.theme-teen .task-text strong { font-size: 1rem; font-weight: 600; }
.theme-teen .task-points { font-size: .95rem; font-weight: 600; color: var(--muted); margin-left: auto; padding-left: 8px; }
.theme-teen .done-form, .theme-teen .task-status { margin: 0; }
.theme-teen .btn-done {
  width: auto; min-height: 38px; padding: 6px 14px; font-size: .9rem; border-radius: 999px;
  background: var(--brand-soft); border: 1px solid transparent; color: var(--brand);
}
.theme-teen .btn-done:hover { background: var(--brand); color: var(--brand-ink); }
.theme-teen .photo-btn { min-height: 38px; padding: 6px 14px; font-size: .9rem; border-radius: 999px; border: 1px dashed var(--brand); }
.theme-teen .returned-note { grid-column: 1 / -1; margin: 8px 0 0; font-size: .9rem; }
.theme-teen .task-card.s-approved, .theme-teen .task-card.s-missed { opacity: .55; }
.theme-teen .task-card.s-returned { border: 0; border-bottom: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--err); }
.theme-teen .goal-card { margin-top: 16px; }
.theme-teen .goal-card .task-icon { background: var(--brand-soft); }
.theme-teen .kidnav { background: rgba(15, 17, 21, .96); backdrop-filter: blur(8px); }
.theme-teen .kidnav a { font-size: .78rem; font-weight: 500; }
.theme-teen .kidnav a.on { background: none; color: var(--brand); }
@media (max-width: 380px) {
  .theme-teen .task-points { display: none; }
}

.tomorrow summary { cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.tomorrow[open] summary { margin-bottom: 8px; }

/* Teen points screen */
.stat-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.stat-big { font-size: 3rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-big span { font-size: 1rem; color: var(--muted); font-weight: 500; }
.stat-side { display: flex; flex-direction: column; gap: 4px; text-align: right; font-size: .95rem; }
.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 140px; align-items: end; margin-bottom: 8px; }
.week-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.week-bar { width: 100%; max-width: 28px; min-height: 2px; background: var(--brand); border-radius: 6px 6px 2px 2px; }
.week-val { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; }
.week-day { font-size: .75rem; color: var(--muted); }

/* Rewards as rows for Clean and Teen */
.theme-clean .shop-grid, .theme-teen .shop-grid { grid-template-columns: 1fr; gap: 8px; }
.theme-clean .shop-item, .theme-teen .shop-item { flex-direction: row; text-align: left; gap: 14px; padding: 12px 14px; }
.theme-teen .shop-item { border: 1px solid var(--line); }
.theme-clean .shop-icon, .theme-teen .shop-icon { font-size: 1.6rem; }
.theme-teen .shop-icon { font-size: 1.15rem; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--line); flex: none; }
.shop-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.theme-clean .shop-action, .theme-teen .shop-action { width: 120px; flex: none; text-align: right; }
.theme-teen .shop-cost { color: var(--muted); font-weight: 600; }
.theme-teen .shop-item.locked .shop-icon { filter: grayscale(1); }

/* Teen toast instead of a celebration pop-up */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: 2px; max-width: calc(100% - 32px); width: max-content;
  background: var(--surface); color: var(--text); border: 1px solid var(--brand); border-radius: 12px;
  padding: 10px 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  animation: toast-in .3s ease, toast-out .4s ease 4.6s forwards;
}
.toast strong { color: var(--brand); }
.toast span { font-size: .85rem; color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 12px); visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Weekly plan ---------- */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 500; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.week-head h1 { margin-bottom: .3em; }
.week-card { padding: 12px; }
.week-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.week-grid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 560px; }
.week-grid th, .week-grid td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.week-grid thead th { font-size: .8rem; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.wg-day span, .wg-day small { display: block; line-height: 1.2; }
.wg-day small { font-weight: 400; }
.week-grid .is-today { background: var(--brand-soft); }
.wg-day.is-today { color: var(--brand); border-radius: 8px 8px 0 0; }
.wg-task { text-align: left !important; font-weight: 500; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 150px; max-width: 220px; }
.wg-task-inner { display: flex; gap: 8px; align-items: center; }
.wg-icon { font-size: 1.15rem; flex: none; }
.wg-title { display: flex; flex-direction: column; line-height: 1.25; }
.wg-title small { font-size: .75rem; font-weight: 400; }
.wg-group th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 14px; border-bottom: 0; }
.wg-pts { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.wg-cell { width: 44px; font-size: 1.05rem; }
.wg-cell form { margin: 0; }
.wg-toggle {
  width: 34px; height: 34px; border-radius: 8px; border: 1px dashed var(--line); background: transparent;
  color: inherit; font: inherit; cursor: pointer; line-height: 1;
}
.wg-toggle:hover { border-color: var(--brand); border-style: solid; }
.st-planned .wg-toggle, .st-todo .wg-toggle { border-style: solid; border-color: var(--brand); color: var(--brand); font-weight: 700; }
.st-planned, .st-todo { color: var(--brand); font-weight: 700; }
.st-approved { color: var(--ok); font-weight: 700; }
.st-submitted { color: var(--warn); font-weight: 700; }
.st-returned, .st-missed { color: var(--err); }
.week-grid tfoot td, .week-grid tfoot th { font-size: .85rem; color: var(--muted); border-bottom: 0; font-variant-numeric: tabular-nums; }
.wg-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 4px 0; }
.wg-legend b { color: var(--text); }
.wg-earned { margin-left: auto; }

.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker label { display: block; }
.day-picker input { position: absolute; opacity: 0; pointer-events: none; }
.day-picker span {
  display: grid; place-items: center; min-width: 48px; height: 40px; padding: 0 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
}
.day-picker input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day-picker input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Bright: sticker-chart feel */
.theme-bright .week-grid .wg-cell { font-size: 1.3rem; }
.theme-bright .st-planned, .theme-bright .st-todo { color: var(--muted); }

/* Teen grid */
.theme-teen .week-grid thead th, .theme-teen .wg-task { background: var(--surface); }

/* Child nav with four items */
.kidnav a { min-width: 0; }

/* Print: a fridge chart */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, .kidnav, .no-print, .flash, .chip-row { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .week-scroll { overflow: visible; }
  .week-grid { min-width: 0; font-size: 12pt; }
  .week-grid th, .week-grid td { border: 1px solid #999; padding: 8px 6px; }
  .week-grid .is-today { background: none; }
  .wg-cell { width: 70px; }
  .wg-toggle { border: 0; width: auto; height: auto; color: #000; }
  .st-planned .wg-toggle, .st-todo .wg-toggle, .st-planned span, .st-todo span { font-size: 0; }
  .st-planned .wg-toggle::after, .st-todo .wg-toggle::after, .st-planned span::after, .st-todo span::after {
    content: ""; display: inline-block; width: 18px; height: 18px; border: 2px solid #000; border-radius: 4px;
  }
  .wg-task, .week-grid thead th { position: static; background: #fff; }
}

/* Week grid on phones: fit all seven days without sideways scrolling */
@media (max-width: 600px) {
  .week-card { padding: 10px 6px; }
  .week-grid { min-width: 0; table-layout: fixed; }
  .week-grid th, .week-grid td { padding: 6px 1px; }
  .week-grid .wg-task { width: 36%; min-width: 0; max-width: none; }
  .wg-task-inner { gap: 4px; }
  .wg-icon { font-size: 1rem; }
  .wg-title { font-size: .85rem; overflow-wrap: anywhere; }
  .wg-pts { display: none; }
  .wg-cell { width: auto; font-size: .95rem; }
  .theme-bright .week-grid .wg-cell { font-size: 1.05rem; }
  .wg-toggle { width: 26px; height: 30px; }
  .wg-day small { font-size: .7rem; }
  .wg-legend { gap: 4px 10px; }
  .wg-earned { margin-left: 0; width: 100%; }
}

/* ---------- Homework ---------- */
.subject-chip {
  display: inline-block; vertical-align: 1px; margin-right: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  color: var(--subj); background: color-mix(in srgb, var(--subj) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--subj) 30%, transparent);
}
.theme-teen .subject-chip { color: color-mix(in srgb, var(--subj) 60%, #fff); }
.hw-detail { margin-top: 10px; }
.theme-teen .hw-detail { grid-column: 1 / -1; margin: 8px 0 0 44px; }
.hw-notes { margin: 0 0 8px; font-size: .9rem; color: var(--muted); white-space: pre-line; }
.hw-steps-head { margin-bottom: 4px; }
.hw-steps li { margin: 2px 0; }
.hw-steps form { margin: 0; }
.hw-step-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 4px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px;
}
.hw-step-btn:hover { background: var(--brand-soft); }
.hw-box {
  flex: none; width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 6px;
  border: 2px solid var(--line); font-size: .8rem; font-weight: 800; color: var(--brand-ink); margin-right: 8px;
}
.hw-step-btn .hw-box { margin-right: 0; }
.hw-steps li.done .hw-box { background: var(--ok); border-color: var(--ok); color: #fff; }
.hw-steps li.done .hw-step-btn, .hw-steps li.done { color: var(--muted); text-decoration: line-through; }
.theme-bright .hw-box { width: 26px; height: 26px; border-radius: 8px; }

/* Parent homework list */
.hw-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hw-row:last-child { border-bottom: 0; }
.hw-main { flex: 1; min-width: 0; }
.hw-title { margin-bottom: 2px; }
.hw-actions { display: flex; gap: 6px; flex: none; }
.hw-actions form { margin: 0; }
.hw-row .progress.small { max-width: 240px; }
.hw-row.is-late .hw-due { color: var(--err); font-weight: 600; }
.hw-row.is-soon .hw-due { color: var(--warn); font-weight: 600; }
.hw-more summary { cursor: pointer; color: var(--brand); margin-top: 4px; }
textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical; }

/* Week grid: homework open days and hand-in day */
.st-span { color: var(--muted); }
.week-grid td.st-span { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.week-grid td.wg-due { box-shadow: inset 0 -3px 0 var(--brand); }
.theme-teen .hw-detail + .done-form { grid-column: 1 / -1; justify-self: end; margin-top: 8px; }

/* ---------- Activity planner ---------- */
.planner-month { display: grid; gap: 14px; }
.planner-week {
  width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.planner-week th, .planner-week td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); vertical-align: top; }
.planner-week tr > :first-child { border-left: 0; }
.planner-week tbody tr:last-child > * { border-bottom: 0; }
.pl-slot-h { width: 84px; text-align: left; padding: 8px 10px; font-weight: 400; }
.pl-day { padding: 8px 6px; text-align: left; font-size: .85rem; color: var(--muted); font-weight: 500; }
.pl-day strong { color: var(--text); font-size: 1rem; margin-left: 2px; }
.pl-day.is-today { background: var(--brand-soft); color: var(--brand); }
.pl-day.is-today strong { color: var(--brand); }
.pl-slot { padding: 8px 10px; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; vertical-align: middle; }
.pl-row-am .pl-slot { background: color-mix(in srgb, #f59e0b 8%, transparent); }
.pl-row-pm .pl-slot { background: color-mix(in srgb, #0ea5e9 8%, transparent); }
.pl-row-evening .pl-slot { background: color-mix(in srgb, #6366f1 10%, transparent); }
.pl-cell { position: relative; height: 64px; padding: 4px 4px 22px; }
.pl-cell.is-today { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.pl-cell.is-other, .pl-day.is-other { opacity: .45; }
.pl-add {
  position: absolute; right: 4px; bottom: 3px; width: 22px; height: 18px; line-height: 16px; text-align: center;
  border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 700; opacity: 0; transition: opacity .15s;
}
.pl-cell:hover .pl-add, .pl-add:focus { opacity: 1; background: var(--brand-soft); color: var(--brand); }
@media (hover: none) { .pl-add { opacity: .6; } }

.act-chip {
  display: flex; gap: 5px; align-items: flex-start; margin-bottom: 3px; padding: 3px 6px; border-radius: 7px;
  background: var(--brand-soft); color: var(--text); text-decoration: none; font-size: .8rem; line-height: 1.25;
  border-left: 3px solid var(--brand); overflow: hidden;
}
a.act-chip:hover { filter: brightness(.96); }
.act-icon { flex: none; }
.act-text { display: flex; flex-direction: column; min-width: 0; }
.act-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-meta { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-date-actions { margin-bottom: 12px; }
.act-date-actions form { display: flex; gap: 8px; flex-wrap: wrap; }

/* Phone agenda (hidden on wide screens) */
.planner-agenda { display: none; }
.ag-day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.ag-day.is-today { box-shadow: inset 3px 0 0 var(--brand), var(--shadow); }
.ag-day h3 { margin: 0 0 8px; font-size: 1rem; }
.ag-day p { margin: 0; }
.ag-slot { display: grid; grid-template-columns: 82px 1fr; gap: 8px; padding: 4px 0; }
.ag-slot-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding-top: 5px; }
.ag-slot .act-chip { font-size: .9rem; }
.ag-slot .act-meta { font-size: .8rem; }
@media (max-width: 760px) {
  .planner-month { display: none; }
  .planner-agenda { display: block; }
}

/* Child view of activities */
.kid-acts .ag-slot { grid-template-columns: 90px 1fr; }

@media print {
  .planner-month { display: grid !important; gap: 8mm; }
  .planner-agenda, .pl-add { display: none !important; }
  .planner-week { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  .planner-week th, .planner-week td { border-color: #999; }
  .pl-cell { height: 18mm; }
  .act-chip { background: none; border: 1px solid #999; border-left-width: 3px; color: #000; }
  .act-meta { color: #333; }
}
.act-where { display: block; margin: -1px 0 4px 6px; }
.theme-bright .section-label { text-align: left; }
.page-wide .wrap { max-width: 1280px; }
.pl-slot-h { width: 104px; }
.pl-slot { font-size: .68rem; letter-spacing: .04em; }
.mode-child.page-wide .wrap { max-width: 1100px; }
.pl-cell.read-only { padding-bottom: 4px; }
.kidnav a { padding: 6px 2px; }
@media (max-width: 380px) { .kidnav a { font-size: .74rem; } }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-word { display: inline-flex; }
.brand-word img { height: 20px; width: auto; display: block; }
.public-bar { display: flex; justify-content: center; padding: 16px 16px 0; }
.public-bar .brand-mark { width: 40px; height: 40px; }
.public-bar .brand-word img { height: 24px; }
.hero { margin-top: 3vh; }
.hero-mark { width: 160px; height: 160px; display: block; margin: 0 auto 8px; filter: drop-shadow(0 10px 24px rgba(8, 102, 230, .18)); }
.mode-public .public-bar + .wrap .hero h1 { margin-top: .2em; }
@media (max-width: 420px) {
  .topbar .brand-word img { height: 16px; }
  .topbar .brand-mark { width: 28px; height: 28px; }
}
@media print { .public-bar { display: none; } }

/* ---------- Planner on phones: compact Mon–Sun grid + details for the tapped day ---------- */
.d-short, .s-short, .ag-hint { display: none; }
@media (max-width: 760px) {
  .planner-month { display: grid; gap: 10px; }
  .pl-slot-h { width: 36px; padding: 4px 2px; }
  .pl-slot-h span { display: none; }
  .d-long, .s-long { display: none; }
  .d-short, .s-short { display: inline; }
  .pl-day { padding: 5px 0 4px; text-align: center; font-size: .7rem; cursor: pointer; }
  .pl-day strong { display: block; margin: 0; font-size: .95rem; }
  .pl-slot { padding: 2px 1px; font-size: .62rem; letter-spacing: 0; text-align: center; }
  .pl-cell { height: auto; min-height: 42px; padding: 3px 1px; text-align: center; cursor: pointer; }
  .pl-cell .act-chip { display: inline-flex; background: none; border: 0; padding: 0 1px; margin: 0; font-size: 1.05rem; line-height: 1.3; }
  .pl-cell .act-text, .pl-add { display: none; }
  .planner-week .is-selected { box-shadow: inset 0 0 0 2px var(--brand); }
  .pl-day.is-selected { background: var(--brand); color: var(--brand-ink); }
  .pl-day.is-selected strong { color: var(--brand-ink); }
  .planner-agenda { display: block; margin-top: 12px; }
  .ag-hint { display: block; margin: 0 0 6px; }
  .planner-agenda.js-filter .ag-day:not(.is-selected-day) { display: none; }
  .theme-bright .pl-cell .act-chip { font-size: 1.25rem; }
}
@media (max-width: 760px) {
  .pl-cell { height: 36px; vertical-align: middle; }
}
@media (max-width: 760px) {
  .planner-month .planner-agenda { margin: 0; }
  .planner-month .ag-day { margin-bottom: 0; }
}

/* ---------- Planner: Day / Week / Month switch ---------- */
.planner-controls { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg a { padding: 6px 16px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; min-height: 36px; display: inline-flex; align-items: center; }
.seg a.on { background: var(--brand); color: var(--brand-ink); }
.planner-controls .btn-sm { min-width: 40px; }

/* Week view */
.pw-wide { margin-bottom: 14px; }
.pw-wide .pw-cell { height: 92px; }
.pw-phone { display: none; }
@media (max-width: 760px) {
  .pw-wide { display: none; }
  .pw-phone {
    display: table; width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  }
  .pw-phone th, .pw-phone td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
  .pw-phone tr > :first-child { border-left: 0; width: 50px; }
  .pw-phone tbody tr:last-child > * { border-bottom: 0; }
  .pw-phone thead th { font-size: .7rem; letter-spacing: .05em; color: var(--muted); text-align: center; padding: 6px 2px; }
  .pw-phone thead .pl-row-am { background: color-mix(in srgb, #f59e0b 8%, transparent); }
  .pw-phone thead .pl-row-pm { background: color-mix(in srgb, #0ea5e9 8%, transparent); }
  .pw-phone thead .pl-row-evening { background: color-mix(in srgb, #6366f1 10%, transparent); }
  .pw-phone tbody th { text-align: center; font-weight: 500; color: var(--muted); font-size: .72rem; vertical-align: middle; }
  .pw-phone tbody th span, .pw-phone tbody th strong { display: block; }
  .pw-phone tbody th strong { color: var(--text); font-size: 1rem; }
  .pw-phone tr.is-today > * { background: var(--brand-soft); }
  .pw-phone tr.is-today th strong { color: var(--brand); }
  .pw-phone td { height: 48px; }
  .pw-phone .act-chip { font-size: .74rem; padding: 2px 4px; margin-bottom: 2px; gap: 3px; }
  .pw-phone .act-meta { font-size: .66rem; }
  .pw-add { display: block; text-align: center; color: var(--muted); text-decoration: none; opacity: .5; font-weight: 700; padding-top: 8px; }
}

/* Day view */
.planner-day { display: grid; gap: 12px; max-width: 720px; }
.pd-slot { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; border-left: 4px solid var(--line); }
.pd-slot.pl-row-am { border-left-color: #f59e0b; }
.pd-slot.pl-row-pm { border-left-color: #0ea5e9; }
.pd-slot.pl-row-evening { border-left-color: #6366f1; }
.pd-slot-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.pd-empty { margin: 0; }
.pd-item { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.pd-slot-label + .pd-item { border-top: 0; }
a.pd-item:hover strong { color: var(--brand); }
.pd-icon { font-size: 1.8rem; line-height: 1; flex: none; }
.pd-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pd-text strong { font-size: 1.05rem; }
.pd-time { font-weight: 600; color: var(--brand); font-size: .9rem; }
.pd-notes { font-style: italic; }
.pd-add { display: inline-block; margin-top: 6px; font-size: .88rem; text-decoration: none; }
.theme-bright .pd-icon { font-size: 2.3rem; }
.theme-teen .pd-slot { border: 1px solid var(--line); border-left-width: 4px; }

@media print {
  .pw-phone { display: none !important; }
  .pw-wide { display: table !important; }
  .pd-slot { box-shadow: none; border: 1px solid #999; border-left-width: 4px; }
}
@media (max-width: 760px) {
  .pw-phone .act-title { white-space: normal; overflow-wrap: anywhere; }
  .pw-phone .act-meta { white-space: normal; }
}
