:root {
    --bg: #0b211b; --bg2: #051410; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #eefaf5; --muted: #b3d1c5; --accent: #5fd3a8; --accent-ink: #032018; --field: rgba(255,255,255,.08);
    --soft: rgba(95,211,168,.15); --good: #8ce99a; --warn: #ffd43b; --bad: #ffa8a8; --bad-bg: rgba(255,120,120,.12); --kid: rgba(255,255,255,.035);
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #edf7f2; --bg2: #d3eadf; --card: #fff; --line: #b9d8ca; --ink: #0b241c; --muted: #3c5a4e;
            --accent: #1d7a5b; --accent-ink: #fff; --field: #f5fbf8; --soft: #dcefe6; --good: #2b8a3e; --warn: #8a5a00; --bad: #c92a2a; --bad-bg: #fff0f0; --kid: #fafdfb; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #edf7f2; --bg2: #d3eadf; --card: #fff; --line: #b9d8ca; --ink: #0b241c; --muted: #3c5a4e;
            --accent: #1d7a5b; --accent-ink: #fff; --field: #f5fbf8; --soft: #dcefe6; --good: #2b8a3e; --warn: #8a5a00; --bad: #c92a2a; --bad-bg: #fff0f0; --kid: #fafdfb; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #0b211b; --bg2: #051410; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #eefaf5; --muted: #b3d1c5; --accent: #5fd3a8; --accent-ink: #032018; --field: rgba(255,255,255,.08);
    --soft: rgba(95,211,168,.15); --good: #8ce99a; --warn: #ffd43b; --bad: #ffa8a8; --bad-bg: rgba(255,120,120,.12); --kid: rgba(255,255,255,.035);
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-main, .col-side { display: contents; }
/* phone order: the evening check, then the add form, then each child's box */
.kids { order: 1; }
.weekcard, .settings { order: 2; }
.faq, footer { order: 3; }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .5rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label, legend { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
input[type=text], input[type=date], select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
input[type=date] { -webkit-appearance: auto; appearance: auto; }
textarea { resize: vertical; line-height: 1.4; min-height: 84px; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible, .chips input:focus-visible + span, .seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
.hint { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.hint:empty { display: none; }
.sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
[hidden] { display: none !important; }
.warn-box { margin: 0 0 .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--bad-bg); border-left: 5px solid var(--bad); font-weight: 600; }

/* buttons */
.primary, .secondary, .danger { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .8rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); margin-top: 1rem; }
.secondary { border: 1px solid var(--line); background: var(--field); color: var(--ink); font-weight: 600; }
.secondary.small { width: auto; min-height: 44px; padding: 0 .8rem; font-size: .92rem; }
.danger { border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; margin-top: .9rem; }
.link { display: block; min-height: 44px; margin-top: .3rem; padding: 0 .1rem; border: 0; background: none; color: var(--accent); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; }
.err { margin: .4rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.err:empty { margin: 0; }
.msg { margin: 0; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.msg.show { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: .8rem 0 0; padding: .5rem .75rem; border-radius: 12px; background: var(--soft); color: var(--ink); }
.msg .undo { min-height: 40px; padding: 0 .9rem; border: 1px solid var(--accent); border-radius: 10px; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.kids > .msg.show { margin: 0 0 .8rem; }
.row-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.row-btns > * { flex: 1 1 6.5rem; width: auto; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: .8rem; }
.check { display: flex; align-items: flex-start; gap: .55rem; margin: .7rem 0 0; color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; min-height: 44px; padding-top: .55rem; }
.check input { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }

.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }

/* chips and segmented choice */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips label, .seg label { margin: 0; position: relative; }
.chips input, .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span, .seg span, .chip-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.chips input:checked + span, .seg input:checked + span, .chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.small-chips { margin-top: .45rem; }
.small-chips:empty { display: none; }
.small-chips .chip-btn { min-height: 40px; font-size: .9rem; padding: 0 .75rem; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.seg span { width: 100%; justify-content: center; border-radius: 12px; }
#due { margin-top: .5rem; }
.split-box { margin-top: .5rem; padding: .2rem .8rem .7rem; border: 1px dashed var(--accent); border-radius: 12px; background: var(--soft); }
.split-preview { margin: .4rem 0 0; padding-left: 1.2rem; font-size: .92rem; }
.split-preview li { overflow-wrap: anywhere; }

/* tonight's check */
.tonight { border: 2px solid var(--accent); }
.t-kid { margin-top: .8rem; padding: .8rem .9rem; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 12px; background: var(--kid); min-width: 0; }
.t-kid h3 { margin: 0; font-size: 1.08rem; overflow-wrap: anywhere; }
.t-kid h3 small { color: var(--muted); font-weight: 600; font-size: .88rem; }
.t-head { margin: .6rem 0 .3rem; font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.t-head.late { color: var(--bad); }
.t-ok { margin: .5rem 0 0; color: var(--good); font-weight: 700; }
.t-none { margin: .5rem 0 0; color: var(--muted); }
.t-holiday { margin: .5rem 0 0; padding: .4rem .6rem; border-radius: 8px; background: var(--soft); font-size: .93rem; overflow-wrap: anywhere; }
.empty-note { margin: .6rem 0 0; padding: .8rem; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); }

/* item rows */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .5rem .6rem; border-radius: 10px; background: var(--field); border: 1px solid transparent; min-width: 0; }
.item.late { border-color: var(--bad); background: var(--bad-bg); }
.item.done .i-text { text-decoration: line-through; opacity: .7; }
.i-text { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.i-text b { font-weight: 700; }
.i-when { display: block; color: var(--muted); font-size: .86rem; font-weight: 600; }
.item.late .i-when { color: var(--bad); }
.tag { display: inline-block; margin-right: .35rem; padding: .05rem .45rem; border-radius: 6px; font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; vertical-align: .1em; background: var(--soft); color: var(--ink); }
.tag.test { background: #f59f00; color: #1f1400; }
.tag.project { background: #845ef7; color: #fff; }
.tag.reminder { background: #4dabf7; color: #04131f; }
.i-btns { display: flex; flex-wrap: wrap; gap: .35rem; }
.i-btns button { min-height: 40px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.i-btns .tick { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* each child's box */
.kid-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.kid { padding: .9rem; border: 2px solid var(--line); border-radius: 14px; background: var(--kid); min-width: 0; }
.kid-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .4rem .8rem; }
.kid-top h3 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; min-width: 0; flex: 1 1 10rem; }
.kid-meta { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.kid details { margin-top: .7rem; }
.kid summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--accent); }
.kid .t-head:first-of-type { margin-top: .8rem; }
.edit-box, .child-form { margin-top: .4rem; padding: .8rem; border: 1px solid var(--accent); border-radius: 12px; background: var(--card); min-width: 0; }
.child-form { margin: .9rem 0 0; border-width: 2px; }
.child-form h3 { margin: 0; font-size: 1.05rem; }
.edit-box label:first-child { margin-top: 0; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; }
.days span { justify-content: center; width: 100%; padding: 0; border-radius: 10px; font-size: .88rem; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.presets button { min-height: 40px; padding: 0 .7rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--accent); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.subj-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; margin-top: .5rem; }
.subj-add button { min-height: 48px; }
.hol-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: .6rem; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; }
.hol-row label { margin: 0 0 .25rem; }
.hol-row .wide { grid-column: 1 / -1; }
.hol-row .rm { grid-column: 1 / -1; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--bad); font: inherit; font-weight: 600; cursor: pointer; }
.form-btns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: 1rem; }
.form-btns .primary { margin: 0; }
.form-btns .danger { grid-column: 1 / -1; margin: 0; }

/* week */
.week-nav { display: flex; flex-wrap: wrap; gap: .4rem; }
.week-nav > * { flex: 1 1 5.5rem; }
.week-title { margin: .7rem 0 .3rem; font-weight: 700; }
.week-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .45rem; }
.week-list > li { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.week-list > li.is-today { border-color: var(--accent); border-width: 2px; }
.week-list h3 { margin: 0; font-size: .95rem; }
.week-list h3 span { color: var(--muted); font-weight: 600; }
.week-list ul { margin: .25rem 0 0; padding-left: 1.1rem; font-size: .93rem; }
.week-list ul li { overflow-wrap: anywhere; }
.week-list ul li.done { text-decoration: line-through; opacity: .65; }
.week-list .none { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }

.faq { margin-top: 1rem; }
.faq details { border-top: 1px solid var(--line); padding: .3rem 0; }
.faq summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.faq p { margin: .3rem 0 .8rem; color: var(--muted); }
footer { margin-top: 1.5rem; text-align: center; font-size: .9rem; }
footer a { color: var(--muted); }

@media (max-width: 380px) {
    .tool-grid, .form-btns, .subj-add { grid-template-columns: minmax(0, 1fr); }
    .days span { font-size: .78rem; }
}
@media print {
    body { background: #fff; color: #000; }
    .adder, .weekcard, .settings, .faq, footer, .back, .i-btns, #tonight-tools { display: none !important; }
}

@media (min-width: 900px) {
    .app { width: min(1140px, 100%); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; order: 0; }
    .col-main, .col-side { display: block; min-width: 0; }
    .app > .topbar { grid-row: 1; }
    .app > header { grid-row: 2; }
    .app > .warn-box { grid-row: 3; }
    .app > .col-main { grid-column: 1; grid-row: 4; }
    .app > .col-side { grid-column: 2; grid-row: 4; }
    .app > .faq { grid-row: 5; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.2rem; }
}
