/* Family Hub. Yoto brand language: fruit-punch coral, marshmallow, wool greys,
   primary card colours, Castledown type, chunky rounded shapes. */
@font-face { font-family: 'Castledown'; font-weight: 400; font-display: swap; src: local('Castledown Regular'), local('Castledown'), url('/fonts/castledown-regular.woff2') format('woff2'); }
@font-face { font-family: 'Castledown'; font-weight: 700; font-display: swap; src: local('Castledown Bold'), url('/fonts/castledown-bold.woff2') format('woff2'); }
@font-face { font-family: 'Castledown'; font-weight: 900; font-display: swap; src: local('Castledown Heavy'), url('/fonts/castledown-heavy.woff2') format('woff2'); }

:root {
  --punch: #f45436; --punch-hover: #d7543b; --punch-deep: #e92f0c;
  --marsh: #efeee9; --marsh-2: #deddd8; --peach: #ffdac5;
  --wool: #eae6e6; --wool-60: #938e8e; --ink: #1e1c1c; --ink-2: #4a4848; --white: #fff;
  --blue: #1471d9; --forest: #003c1f; --green: #2fb36b; --yellow: #ffc62c; --pink: #ff8fc1; --orange: #ff8a1f;
  --surface: #fff; --bg: var(--marsh); --line: var(--wool);
  --r-sm: 12px; --r: 20px; --r-lg: 28px;
  --display: 'Castledown', 'Fredoka', ui-rounded, system-ui, sans-serif;
  --body: 'Castledown', 'Nunito', ui-rounded, system-ui, sans-serif;
  --shadow: 0 2px 0 rgba(30, 28, 28, .06), 0 8px 24px rgba(30, 28, 28, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3 { font-family: var(--display); font-weight: 900; letter-spacing: -.01em; margin: 0; line-height: 1.05; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 19px; font-weight: 700; }
.muted { color: var(--wool-60); }
.px { image-rendering: pixelated; display: block; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 20px 16px 120px; }
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.logo { width: 46px; height: 46px; border-radius: 50%; background: var(--punch); display: grid; place-items: center; flex: none; }
.logo svg { width: 26px; height: 26px; }
.top .clock { margin-left: auto; text-align: right; font-family: var(--display); font-weight: 900; font-size: 26px; }
.top .clock small { display: block; font-family: var(--body); font-weight: 400; font-size: 14px; color: var(--wool-60); }

.tabs { position: fixed; z-index: 20; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; background: var(--ink); border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 20px); overflow-x: auto; }
.tabs a { color: #fff; text-decoration: none; padding: 11px 16px; border-radius: 999px; font-weight: 700; font-size: 15px; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.tabs a svg { width: 20px; height: 20px; }
.tabs a.on { background: var(--punch); }
@media (max-width: 620px) { .tabs a span { display: none; } .tabs a { padding: 11px 13px; } }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--surface); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head .spacer { flex: 1; }

.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 12px 20px; font-weight: 700; background: var(--punch); color: #fff; transition: transform .15s, background .15s; }
.btn:hover { background: var(--punch-hover); }
.btn:active { transform: scale(.96); }
.btn.ghost { background: var(--marsh); color: var(--ink); }
.btn.ghost:hover { background: var(--marsh-2); }
.btn.dark { background: var(--ink); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.icon { width: 48px; height: 48px; padding: 0; }
.btn:disabled { opacity: .45; pointer-events: none; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 700; font-size: 14px; }
.input, select.input, textarea.input { width: 100%; border: 2px solid var(--wool); background: #fff; border-radius: var(--r-sm); padding: 12px 14px; outline: none; }
.input:focus { border-color: var(--ink); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--marsh); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.empty { text-align: center; padding: 28px 10px; color: var(--wool-60); }
.empty .px { margin: 0 auto 10px; }
.notice { background: var(--peach); border-radius: var(--r-sm); padding: 12px 14px; font-size: 15px; }
.err { background: #ffe1db; color: #9c1e08; }

/* ---------- today: live schedule ---------- */
.live-head { display: flex; align-items: baseline; gap: 10px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--punch); position: relative; top: -2px; }
.live-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--punch); animation: ping 1.6s ease-out infinite; }
@keyframes ping { to { transform: scale(2.6); opacity: 0; } }
.sched { display: grid; gap: 6px; }
.sched-row { display: grid; grid-template-columns: 74px 6px 48px 1fr auto; gap: 12px; align-items: center; padding: 10px 10px; border-radius: var(--r-sm); transition: background .2s, transform .2s; }
.sched-row:hover { background: var(--marsh); }
@media (max-width: 620px) {
  .sched-row { grid-template-columns: 56px 40px 1fr auto; gap: 10px; padding: 8px 4px; }
  .sched-row .sched-bar { display: none; }
  .sched-row .px { width: 40px; height: 40px; }
  .sched-time { font-size: 17px; }
  .badge { font-size: 10px; padding: 4px 7px; }
  .top h1 { font-size: 24px; }
  .top .clock { font-size: 20px; }
}
.sched-row.now { background: #fff3ee; }
.sched-row.past { opacity: .5; }
.sched-time { font-family: var(--display); font-weight: 900; font-size: 22px; text-align: right; }
.sched-bar { height: 100%; min-height: 40px; border-radius: 3px; background: var(--wool); position: relative; overflow: hidden; }
.sched-bar i { position: absolute; left: 0; top: 0; width: 100%; background: var(--c, var(--punch)); }
.sched-title { font-weight: 700; }
.sched-meta { font-size: 14px; color: var(--wool-60); }
.badge { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; padding: 5px 10px; border-radius: 999px; border: 2px solid var(--wool); white-space: nowrap; }
.badge.now { background: var(--punch); border-color: var(--punch); color: #fff; display: inline-flex; gap: 6px; align-items: center; }
.badge.now::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.badge.next { border-color: var(--punch); color: var(--punch-deep); }
.badge.tonight { border-color: var(--blue); color: var(--blue); }
.badge.done { color: var(--wool-60); }

/* ---------- week calendar ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: #fff; border-radius: var(--r-sm); padding: 10px; min-height: 180px; display: flex; flex-direction: column; gap: 6px; }
.day.today { outline: 3px solid var(--punch); }
.day-h { display: flex; align-items: baseline; justify-content: space-between; font-weight: 700; }
.day-h b { font-family: var(--display); font-size: 26px; font-weight: 900; }
.ev { text-align: left; border-radius: 10px; padding: 7px 8px; background: color-mix(in srgb, var(--c) 16%, white); border: 0; display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; font-size: 14px; line-height: 1.2; }
.ev .px { width: 22px; height: 22px; }
.ev b { display: block; font-weight: 700; }
.ev small { color: var(--ink-2); }
@media (max-width: 860px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
}
.legend { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- routines (parent) ---------- */
.routine-list { display: grid; gap: 8px; }
.routine-cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); }
.r-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: var(--r-sm); background: var(--marsh); }
.r-item .px { width: 52px; height: 52px; }
.r-item.done { background: #e3f6ea; }
.progress { height: 14px; background: var(--wool); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .5s cubic-bezier(.3,1.4,.5,1); }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.icon-pick button { padding: 6px; border-radius: 12px; background: var(--marsh); border: 3px solid transparent; }
.icon-pick button.on { border-color: var(--punch); background: #fff; }
.icon-pick .px { width: 40px; height: 40px; margin: 0 auto; }

/* ---------- music ---------- */
.now-card { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; }
.now-art { width: 120px; aspect-ratio: 1; border-radius: var(--r-sm); background: var(--wool) center/cover; }
.controls { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.ctl { width: 56px; height: 56px; border-radius: 50%; background: var(--marsh); display: grid; place-items: center; }
.ctl.big { width: 68px; height: 68px; background: var(--punch); color: #fff; }
.ctl svg { width: 26px; height: 26px; }
input[type=range] { accent-color: var(--punch); width: 100%; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.tile { position: relative; text-align: left; }
/* Yoto card proportions (54 x 85.6 mm) */
.ycard { aspect-ratio: 54 / 85.6; border-radius: 18px; background: var(--c, var(--punch)); padding: 10px; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .2s cubic-bezier(.3,1.5,.5,1); }
.ycard .art { flex: 1; border-radius: 12px; background: #fff center/cover; }
.ycard .name { color: #fff; font-family: var(--display); font-weight: 900; font-size: 16px; line-height: 1.1; padding: 10px 2px 2px; min-height: 2.4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile:active .ycard { transform: scale(.94); }
.tile .x { position: absolute; top: -6px; right: -6px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 900; }
.result { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 6px; border-radius: var(--r-sm); }
.result:hover { background: var(--marsh); }
.result .thumb { width: 52px; height: 52px; border-radius: 8px; background: var(--wool) center/cover; }
.eq { display: inline-flex; gap: 3px; align-items: flex-end; height: 18px; }
.eq i { width: 4px; background: currentColor; border-radius: 2px; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%,100% { height: 4px; } 50% { height: 18px; } }

/* ---------- shopping ---------- */
.shop-add { display: flex; gap: 8px; margin-bottom: 14px; }
.shop-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 2px solid var(--marsh); }
.check { width: 30px; height: 30px; border-radius: 10px; border: 3px solid var(--ink); display: grid; place-items: center; transition: background .2s; }
.shop-item.done .check { background: var(--green); border-color: var(--green); }
.shop-item.done .t { text-decoration: line-through; color: var(--wool-60); }
.check svg { width: 18px; height: 18px; opacity: 0; transform: scale(.4); transition: .25s cubic-bezier(.3,1.6,.5,1); }
.shop-item.done .check svg { opacity: 1; transform: scale(1); }

/* ---------- sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(30,28,28,.4); z-index: 50; display: grid; place-items: end center; animation: fade .2s; }
.sheet { background: #fff; width: min(560px, 100%); max-height: 92dvh; overflow: auto; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 22px 18px 28px; animation: up .3s cubic-bezier(.2,1,.3,1); }
@media (min-width: 700px) { .sheet-bg { place-items: center; } .sheet { border-radius: var(--r-lg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- lock ---------- */
.lock { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.lock .card { width: min(380px, 100%); text-align: center; }
.pin { font-size: 32px; letter-spacing: .4em; text-align: center; font-family: var(--display); font-weight: 900; }

/* =========================================================
   KID MODE: big, picture-first, almost no words
   ========================================================= */
body.kid { background: var(--marsh); }
.kid-app { min-height: 100dvh; display: flex; flex-direction: column; padding: 16px 16px 130px; max-width: 1180px; margin: 0 auto; }
.kid-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.kid-top h1 { font-size: clamp(30px, 5vw, 48px); }
.stars { margin-left: auto; display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 6px 16px 6px 8px; font-family: var(--display); font-weight: 900; font-size: 26px; }
.stars .px { width: 38px; height: 38px; }
.stars.bump { animation: bump .5s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.25); } }
.kid-lock { width: 52px; height: 52px; border-radius: 50%; background: #fff; display: grid; place-items: center; position: relative; }
.kid-lock svg { width: 22px; height: 22px; }
.kid-lock .ring { position: absolute; inset: -4px; border-radius: 50%; border: 4px solid var(--punch); clip-path: inset(0 100% 0 0); }
.kid-lock.holding .ring { animation: wipe 2s linear forwards; }
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }

.kid-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--marsh) 30%); }
.kid-tabs a { width: 92px; height: 92px; border-radius: 26px; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow); transition: transform .2s cubic-bezier(.3,1.6,.5,1); }
.kid-tabs a .px { width: 60px; height: 60px; }
.kid-tabs a.on { background: var(--punch); transform: translateY(-6px); }
@media (max-width: 520px) { .kid-tabs a { width: 64px; height: 64px; border-radius: 20px; } .kid-tabs a .px { width: 42px; height: 42px; } }

/* today / tomorrow */
.kid-days { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .kid-days { grid-template-columns: 1fr; } }
.kid-day { background: #fff; border-radius: var(--r-lg); padding: 18px; }
.kid-day.is-today { box-shadow: 0 0 0 5px var(--punch); }
.kid-day h2 { font-size: clamp(30px, 4vw, 42px); margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.kid-day h2 .px { width: 48px; height: 48px; }
.kid-ev { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center; padding: 10px; border-radius: 22px; margin-bottom: 10px; background: color-mix(in srgb, var(--c) 14%, white); }
.kid-ev .pic { width: 112px; height: 112px; border-radius: 20px; background: #fff; display: grid; place-items: center; }
.kid-ev .pic .px { width: 88px; height: 88px; }
.kid-ev b { font-family: var(--display); font-weight: 900; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.05; display: block; }
.kid-ev .when { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 19px; color: var(--ink-2); margin-top: 6px; }
.kid-ev .when .px { width: 28px; height: 28px; }
.kid-ev.now { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 45%, transparent); } }
.kid-ev.past { opacity: .4; }

/* routine runner */
.runner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.steps { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.step { width: 76px; height: 76px; border-radius: 20px; background: #fff; display: grid; place-items: center; position: relative; border: 4px solid transparent; transition: transform .25s; }
.step .px { width: 54px; height: 54px; }
.step.cur { border-color: var(--punch); transform: scale(1.1); }
.step.done { background: #e3f6ea; }
.step.done .px { opacity: .45; }
.step .tick { position: absolute; right: -8px; top: -8px; width: 32px; height: 32px; border-radius: 50%; background: var(--green); display: grid; place-items: center; animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
.step .tick svg { width: 18px; height: 18px; }
@keyframes pop { from { transform: scale(0) rotate(-90deg); } }
.hero-step { position: relative; width: min(440px, 100%, 36dvh); aspect-ratio: 1; background: #fff; border-radius: 44px; display: grid; place-items: center; box-shadow: var(--shadow); }
.hero-step .px { width: 72%; height: 72%; }
.hero-step.yay .px { animation: yay .9s cubic-bezier(.3,1.6,.5,1); }
@keyframes yay { 0% { transform: scale(1); } 30% { transform: scale(.82) rotate(-8deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: scale(1); } }
.hero-step.enter .px { animation: enter .5s cubic-bezier(.3,1.5,.5,1); }
@keyframes enter { from { transform: translateX(60px) scale(.6); opacity: 0; } }
.hero-title { font-family: var(--display); font-weight: 900; font-size: clamp(34px, 5vw, 56px); text-align: center; }
.done-btn { width: min(440px, 100%); height: clamp(80px, 12dvh, 108px); border-radius: 999px; background: var(--green); color: #fff; font-family: var(--display); font-weight: 900; font-size: 44px; display: flex; align-items: center; justify-content: center; gap: 14px; box-shadow: 0 8px 0 #1e8a50; transition: transform .1s, box-shadow .1s; }
.done-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #1e8a50; }
.done-btn svg { width: 48px; height: 48px; }
.back-btn { background: #fff; border-radius: 999px; padding: 12px 22px; font-weight: 700; }

.celebrate { text-align: center; display: grid; justify-items: center; gap: 14px; padding: 30px 0; }
.celebrate .px { width: min(300px, 70vw); height: auto; aspect-ratio: 1; animation: spinpop 1.1s cubic-bezier(.3,1.5,.5,1); }
@keyframes spinpop { from { transform: scale(0) rotate(-200deg); } }
.celebrate h1 { font-size: clamp(40px, 7vw, 72px); }

/* jobs grid */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.job { background: #fff; border-radius: 30px; padding: 18px; display: grid; justify-items: center; gap: 10px; position: relative; transition: transform .2s; }
.job .px { width: 130px; height: 130px; }
.job b { font-family: var(--display); font-weight: 900; font-size: 24px; text-align: center; }
.job.done { background: #e3f6ea; }
.job.done .px { opacity: .5; }
.job .tick { position: absolute; top: 12px; right: 12px; width: 48px; height: 48px; border-radius: 50%; background: var(--green); display: grid; place-items: center; animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
.job .tick svg { width: 28px; height: 28px; }
.job:active { transform: scale(.95); }

/* kid music */
.kid-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.kid-tiles .ycard .name { font-size: 20px; }
.tile.playing .ycard { box-shadow: 0 0 0 6px var(--ink); }
.tile .eqbadge { position: absolute; left: 12px; top: 12px; background: var(--ink); color: #fff; border-radius: 12px; padding: 8px; }
.kid-player { position: fixed; z-index: 19; left: 50%; transform: translateX(-50%); bottom: 124px; display: flex; gap: 14px; background: var(--ink); padding: 10px; border-radius: 999px; }
.kid-player .ctl { width: 76px; height: 76px; background: #fff; color: var(--ink); }
.kid-player .ctl.big { background: var(--punch); color: #fff; }
.kid-player .ctl svg { width: 36px; height: 36px; }
@media (max-width: 520px) { .kid-player { bottom: 92px; } }

/* ---------- celebration particles ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.fx i { position: absolute; width: 14px; height: 14px; left: var(--x); top: var(--y); background: var(--c); animation: burst var(--d, .9s) cubic-bezier(.2,.8,.3,1) forwards; }
.fx i.s { width: 30px; height: 30px; background: none; }
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.4); opacity: 0; }
}
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 120; animation: up .3s; max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-height: 900px) and (min-width: 521px) {
  .kid-tabs { padding-top: 8px; padding-bottom: 8px; }
  .kid-tabs a { width: 76px; height: 76px; border-radius: 22px; }
  .kid-tabs a .px { width: 50px; height: 50px; }
  .kid-app { padding-bottom: 110px; }
  .runner { gap: 12px; }
}
@media (max-width: 460px) { .routine-cols { grid-template-columns: 1fr; } }
