:root {
  --bg: #0f1218; --panel: #191d26; --panel2: #222733; --text: #f1f3f7; --muted: #9aa3b2; --line: #2b313d;
  --green: #5fd38d; --red: #ff8a7a; --amber: #f0b840; --family: #c79bff; --accent: #6ea8fe;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); }
body { font-family: "Inter", system-ui, sans-serif; color: var(--text); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: "Space Grotesk", "Inter", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; }
.bar { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; min-height: 54px; }
.bar h1 { font-size: 22px; flex: 1; }
.main { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 20px; }
.tabs { flex: none; display: flex; border-top: 1px solid var(--line); background: #12151c; padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; padding: 9px 2px 8px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.tabs button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--text); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--red); color: #1c1210; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; padding: 0 5px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1522; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.on { outline: 2px solid var(--accent); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--amber); }
.err { color: var(--red); }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea { width: 100%; background: #12151c; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); }

/* login */
.center { margin: auto; width: 100%; max-width: 380px; padding: 24px; }
.center h1 { font-size: 30px; margin-bottom: 6px; }
.center .btn { width: 100%; margin-top: 18px; }

/* chips (kid switcher, thread picker) */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.chips button { flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 600; font-size: 14px; }
.chips button.on { background: var(--c, var(--accent)); border-color: transparent; color: #0d1522; }

/* item lists */
h2.sec { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-family: "Inter", sans-serif; margin: 18px 0 8px; }
.card { background: var(--panel); border-radius: 16px; padding: 4px 14px; }
.card.pad { padding: 14px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 52px; }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; text-align: left; }
.item .title { overflow-wrap: anywhere; }
.item.done .title { color: var(--muted); text-decoration: line-through; }
.item .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.item .meta .late { color: var(--red); }
.item .meta .wait { color: var(--amber); }
.item .meta .fam { color: var(--family); }
.box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #c9cfda; flex: none; position: relative; }
.box.done { background: var(--green); border-color: var(--green); }
.box.done::after { content: ""; position: absolute; left: 8px; top: 3px; width: 7px; height: 13px; border: solid #10241a; border-width: 0 3px 3px 0; transform: rotate(42deg); }
.box.waiting { border-color: var(--green); background: linear-gradient(90deg, var(--green) 50%, transparent 50%); }
.box.none { border-style: dashed; border-color: #5b6372; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.empty { color: var(--muted); padding: 14px 0; font-size: 14px; }
.fab { position: fixed; right: max(18px, calc(50% - 342px)); bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #0d1522; font-size: 30px; line-height: 1; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 16px; background: var(--panel); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: #24406b; }
.msg.bot { background: #1f2430; border: 1px solid var(--line); }
.msg .who { font-size: 12px; font-weight: 700; color: var(--c, var(--muted)); margin-bottom: 2px; }
.msg .when { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg .undo { margin-top: 7px; }
.compose { flex: none; display: flex; gap: 8px; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.compose input { flex: 1; border-radius: 999px; padding-left: 16px; }
.compose .btn { border-radius: 999px; }
.note { margin: 0 16px 8px; padding: 9px 12px; border-radius: 12px; background: #2a2416; color: #ffd98a; font-size: 13px; }

/* sheet */
#sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto; background: var(--panel); border-radius: 22px 22px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 20px; margin-bottom: 4px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.sheet .actions .btn { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); background: #f1f1ee; color: #14171d; padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 20; max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* parent panel */
details { background: var(--panel); border-radius: 16px; margin-bottom: 10px; }
summary { padding: 15px 14px; font-weight: 700; font-family: "Space Grotesk", sans-serif; font-size: 17px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 22px; transition: transform .15s; }
details[open] summary::after { transform: rotate(90deg); }
details .in { padding: 0 14px 14px; }
.pill { font-size: 12px; font-weight: 700; background: var(--red); color: #1c1210; border-radius: 999px; padding: 1px 8px; }
.req { padding: 10px 0; border-bottom: 1px solid var(--line); }
.req:last-child { border-bottom: 0; }
.req.old .age { color: var(--red); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; overflow-wrap: anywhere; }
