:root {
  --bg: #11162b; --card: #1b2340; --tile: #262f55; --line: #2b3558; --ink: #eef0fa; --muted: #98a0c0;
  --moon: #f4e3a1; --accent: #7686f0; --accent-ink: #11162b; --mint: #8fd19e; --peanut: #f0b27a; --danger: #ef7480;
  --block: #6b7bd8; --track: #26305a; --r-card: 22px; --r-tile: 18px; --r-btn: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, "SF Pro Text", system-ui, "Segoe UI", sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--muted); }
svg { display: block; flex: none; }

/* header */
header { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 16px; }
header small { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 12px; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; padding: 8px; cursor: pointer; }

/* moon: a crescent that glows while she sleeps */
.moon { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px; box-shadow: inset -24px -11px 0 0 var(--moon); opacity: .3; transition: opacity .5s, filter .5s; }
.moon.on { opacity: 1; filter: drop-shadow(0 0 18px rgba(244, 227, 161, .38)); animation: breathe 5s ease-in-out infinite; }
.moon.sm { width: 36px; height: 36px; margin: 0; box-shadow: inset -12px -5px 0 0 var(--moon); animation: none; }
.moon.sm.on { filter: drop-shadow(0 0 9px rgba(244, 227, 161, .4)); }
@keyframes breathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 12px rgba(244, 227, 161, .28)); }
  50% { transform: scale(1.045); filter: drop-shadow(0 0 34px rgba(244, 227, 161, .62)); }
}

/* bottom navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: rgba(27, 35, 64, .96); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.nav div { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nav button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 8px 0 6px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; transition: background .2s, color .2s; }
.nav button[aria-selected="true"] { color: var(--moon); background: var(--tile); }

/* cards and headings */
.card { background: var(--card); border-radius: var(--r-card); padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 650; }
.sectionhead { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 4px 10px; font-weight: 650; }
.sub { color: var(--muted); font-size: 14px; }
.sub.right { text-align: right; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tile); color: var(--ink); border-radius: 12px; padding: 5px 11px; font-size: 13px; font-weight: 600; }

/* hero */
.hero { text-align: center; padding: 30px 18px 18px; }
.hero.asleep { background: radial-gradient(130% 95% at 50% 0%, #2a3568 0%, var(--card) 64%); }
.big { font-size: 60px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.05; margin: 8px 0 4px; letter-spacing: -.02em; }
.hero.awake .big { font-size: 46px; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 58px; border: 0; border-radius: var(--r-btn); padding: 14px 18px; font: inherit; font-size: 18px; font-weight: 650; background: var(--accent); color: var(--accent-ink); cursor: pointer; text-align: center; text-decoration: none; margin-top: 14px; transition: transform .12s, opacity .2s; }
.btn:active, .tile:active, .vitrow:active, .nav button:active, .row:active { transform: scale(.97); }
.btn.moonbtn { background: var(--moon); color: #1b2340; }
.btn.secondary { background: var(--tile); color: var(--ink); font-size: 16px; min-height: 52px; font-weight: 600; }
.btn.danger { background: none; color: var(--danger); border: 2px solid var(--line); font-size: 16px; min-height: 52px; font-weight: 600; }
.btn.small { width: auto; min-height: 44px; margin-top: 0; padding: 10px 18px; font-size: 15px; border-radius: 14px; }
.btn:disabled { opacity: .5; }

/* slept today and the timeline */
.total { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 4px; }
.tot { font-size: 36px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.02em; }
.track { position: relative; height: 26px; background: var(--track); border-radius: 9px; margin: 14px 0 6px; overflow: hidden; }
.track.mini { height: 12px; border-radius: 5px; margin: 8px 0 0; }
.grid { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .07); }
.blk { position: absolute; top: 3px; bottom: 3px; background: var(--block); border-radius: 7px; }
.mini .blk { top: 2px; bottom: 2px; border-radius: 3px; }
.blk.live { background: var(--moon); }
.now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--moon); box-shadow: 0 0 6px var(--moon); }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* list rows */
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 0; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: transform .12s; }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row b { font-variant-numeric: tabular-nums; font-weight: 650; }
.dot { width: 38px; height: 38px; border-radius: 50%; background: var(--tile); color: var(--moon); display: flex; align-items: center; justify-content: center; flex: none; }
.dot.live { background: var(--moon); color: #1b2340; }
.pill { background: var(--tile); border-radius: 12px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.pill.live { background: var(--moon); color: #1b2340; }

/* history */
.day { border-top: 1px solid var(--line); padding: 14px 0; }
.day:first-of-type { border-top: 0; padding-top: 4px; }
.day-head { display: block; width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.day-head .line { display: flex; justify-content: space-between; align-items: center; }

/* banners and errors */
.banner { background: var(--card); border: 1.5px dashed var(--line); border-radius: var(--r-card); padding: 14px 16px; margin-bottom: 14px; font-size: 14px; display: flex; gap: 12px; align-items: flex-start; }
.banner .ic { color: var(--moon); padding-top: 2px; }
.banner .btn { margin-top: 10px; }
.error { color: var(--danger); min-height: 1.4em; font-size: 14px; margin: 4px 2px; }

/* forms and the bottom sheet */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input { width: 100%; min-width: 0; max-width: 100%; min-height: 52px; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus { outline: none; border-color: var(--accent); }
/* iOS Safari gives date inputs their own intrinsic width and centred text; pin them to the sheet. */
input[type="datetime-local"] { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 52px; text-align: left; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }
input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }
dialog { border: 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 26px 26px 0 0; background: var(--card); color: var(--ink); overflow-x: hidden; animation: sheet .28s cubic-bezier(.2, .8, .2, 1); }
dialog h1:focus { outline: none; }
dialog::backdrop { background: rgba(5, 8, 20, .62); }
dialog::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -8px auto 14px; }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

/* login: the moon, the name and the form sit in the middle of the screen */
main.bare { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.login { min-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))); display: flex; flex-direction: column; justify-content: center; margin: 0 auto; max-width: 420px; text-align: left; }
.login .moon { margin: 0 auto 14px; opacity: 1; }
.login h1 { font-size: 34px; margin-bottom: 18px; text-align: center; }

/* Groei: the Eten / Ontwikkeling switch and card glyphs */
.subtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card); border-radius: 18px; padding: 5px; margin-bottom: 14px; }
.subtabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 650; padding: 12px 8px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: background .2s, color .2s; }
.subtabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.card h2.withicon { display: flex; align-items: center; gap: 8px; }
.card h2.withicon svg { color: var(--moon); }

/* Groei: the week strip */
.wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 6px 0 12px; text-align: center; }
.wk .d { padding: 7px 0 8px; border-radius: 12px; }
.wk .d.today { background: var(--tile); }
.wk .d.future { opacity: .45; }
.wk .dow { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.wk .dots { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 7px; }
.wk .dt { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #4a5690; }
.wk .dt.pinda.on { background: var(--peanut); border-color: var(--peanut); }
.wk .dt.ei.on { background: var(--moon); border-color: var(--moon); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Groei: tiles and rows */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.tiles > div { display: flex; flex-direction: column; }
.tile { width: 100%; min-height: 136px; justify-content: center; border: 0; border-radius: var(--r-tile); padding: 16px 10px 14px; background: var(--tile); color: var(--ink); font: inherit; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; text-align: center; transition: transform .12s, background .25s; }
.tile b { font-size: 16px; font-weight: 650; }
.tile span { font-size: 12px; opacity: .8; min-height: 2.6em; }
.tile.done { background: var(--moon); color: #1b2340; cursor: default; }
.tile.done.pinda { background: var(--peanut); }
.undo { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 8px 0 0; cursor: pointer; width: 100%; }
.vitrow { width: 100%; border: 0; border-radius: var(--r-card); padding: 16px 18px; display: flex; align-items: center; gap: 14px; background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: transform .12s, background .25s; }
.vitrow .ic { color: var(--moon); }
.vitrow .grow { flex: 1; }
.vitrow b { font-size: 16px; font-weight: 650; }
.vitrow.done { background: #22362c; cursor: default; }
.vitrow.done .ic { color: var(--mint); }
.check { width: 30px; height: 30px; border-radius: 50%; background: var(--tile); color: #11162b; display: flex; align-items: center; justify-content: center; }
.vitrow.done .check { background: var(--mint); }
.stack { margin-bottom: 14px; }
.stack .undo { text-align: center; padding-top: 6px; }
.addrow { display: flex; gap: 10px; align-items: center; margin: 4px 0 8px; }
.addrow .btn.small { min-width: 52px; padding: 0; justify-content: center; border-radius: 50%; height: 52px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--tile); display: flex; align-items: center; justify-content: center; font-weight: 650; color: var(--moon); text-transform: uppercase; flex: none; }
.row .chev { color: var(--muted); }
.tag { display: inline-block; font-size: 12px; font-weight: 650; color: #1b2340; background: var(--moon); border-radius: 8px; padding: 3px 9px; margin: 8px 0 6px; }
.milk-head { display: flex; gap: 14px; align-items: flex-start; }
.milk-head .ic { color: var(--moon); padding-top: 2px; }
.datepill { display: inline-block; margin-top: 12px; }
.donetext { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); margin-top: 12px; }
.donetext .undo { text-align: left; padding: 4px 0 0; }
.src { color: var(--muted); font-size: 12px; margin-top: 12px; }
.ctx { padding: 5px 0 5px 18px; position: relative; color: var(--ink); }
.ctx::before { content: ""; position: absolute; left: 2px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--moon); opacity: .8; }
.fixednote { color: var(--muted); font-size: 14px; margin: 10px 0; }
details.card summary { cursor: pointer; font-weight: 650; }
.logrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.logrow:first-of-type { border-top: 0; }

/* Groei: development */
details.ms { border-top: 1px solid var(--line); }
details.ms:first-of-type { border-top: 0; }
details.ms summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 0; cursor: pointer; font-weight: 650; }
details.ms summary::-webkit-details-marker { display: none; }
.mstitle { flex: 1; min-width: 0; }
.seen { width: 24px; height: 24px; border-radius: 50%; background: var(--moon); color: #1b2340; display: flex; align-items: center; justify-content: center; flex: none; }
.ms .chev { color: var(--muted); transition: transform .15s; }
details.ms[open] .chev { transform: rotate(90deg); }
.msbody { padding: 0 0 16px; }
.msbody .q { margin-top: 2px; }
.gloss { color: var(--muted); font-size: 14px; margin-top: 2px; font-style: italic; }
.p90 { color: var(--muted); font-size: 13px; margin-top: 10px; }
.msbtns { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 12px; }
.msbtns .link { text-decoration: underline; text-underline-offset: 3px; padding: 8px 0; }
.srclink { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; display: inline-block; margin-top: 10px; }
.src .srclink, .src.tight .srclink { margin-top: 0; font-size: inherit; }
.src.tight { margin-top: 2px; }
.seg { display: inline-flex; gap: 6px; margin: 2px 0 10px; }
.seg button { border: 0; border-radius: 12px; padding: 8px 16px; background: var(--tile); color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; text-transform: uppercase; }
.seg button.on { background: var(--moon); color: #1b2340; }
details.card summary { font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .moon.on { animation: none; }
  dialog { animation: none; }
  .btn, .tile, .vitrow, .row, .nav button { transition: none; }
}
