@font-face { font-family: 'Baloo Bhaijaan 2'; src: url(fonts/baloo-bhaijaan-2.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: Tajawal; src: url(/assets/Tajawal-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Tajawal; src: url(/assets/Tajawal-Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: Nunito; src: url(/assets/Nunito-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Nunito; src: url(/assets/Nunito-Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: Nunito; src: url(/assets/Nunito-Black.ttf) format('truetype'); font-weight: 800 900; font-display: swap; }

:root {
  --paper: #FBF3E1; --desk: #EBDDC0; --ink: #282828; --ink-2: #5d564c; --white: #fff;
  --sun: #FFD044; --accent: #16AAAE; --teal: #006E73; --coral: #F28A68; --now: #F7C531;
  --lift: 0 1px 0 rgba(40,30,10,.06), 0 10px 28px rgba(96,64,16,.14);
  --pop: cubic-bezier(.34,1.56,.64,1); --ease: cubic-bezier(.2,.8,.2,1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .35 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  --gut: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  color-scheme: light;
  font-family: 'Baloo Bhaijaan 2', Tajawal, system-ui, sans-serif;
}
:root:lang(en) { font-family: Nunito, 'Baloo Bhaijaan 2', system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { overflow: hidden; -webkit-touch-callout: none; overscroll-behavior: none; }
body[data-screen=paint], body[data-screen=home], body[data-screen=book] { -webkit-user-select: none; user-select: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; border: 0; background: none; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
img { max-width: 100%; height: auto; display: block; -webkit-user-drag: none; }
.i { width: 26px; height: 26px; flex: none; }
.i.big { width: 44px; height: 44px; }
[dir=ltr] .i.flip:not(.back-next), [dir=rtl] .i.flip.back-next { transform: scaleX(-1); }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.25; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.fine { font-size: 15px; color: var(--ink-2); line-height: 1.7; }
[hidden] { display: none !important; }
.app { position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden; background: var(--paper) var(--grain); -webkit-overflow-scrolling: touch; }
body[data-screen=paint] .app { overflow: hidden; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
::view-transition-old(root) { animation: .16s ease-in both fade-out; }
::view-transition-new(root) { animation: .3s var(--ease) both fade-in; }

/* ---------- buttons ---------- */
.kbtn { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; background: #fff; box-shadow: var(--lift); transition: transform .2s var(--pop); flex: none; }
.kbtn:active:not(:disabled) { transform: scale(.9); }
.kbtn.sm { width: 46px; height: 46px; border-radius: 15px; }
.kbtn.sure, .ghost.sure { background: #fde0da; color: #a3261c; }
.kdone { height: 60px; padding: 0 24px; border-radius: 30px; background: var(--sun); display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 21px; box-shadow: 0 4px 0 #c99a14; transition: transform .15s, box-shadow .15s; flex: none; }
.kdone:active { transform: translateY(3px); box-shadow: 0 1px 0 #c99a14; }
.primary { min-height: 58px; padding: 8px 26px; border-radius: 30px; background: var(--teal); color: #fff; font-weight: 800; font-size: 19px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 4px 0 #00484b; text-align: center; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #00484b; }
.primary.danger { background: #b3362a; box-shadow: 0 4px 0 #7c2219; }
.ghost { min-height: 54px; padding: 8px 22px; border-radius: 28px; background: #fff; box-shadow: var(--lift); font-weight: 800; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.ghost.sm { min-height: 46px; padding: 4px 18px; font-size: 16px; }
.ghost.quiet { background: transparent; box-shadow: none; color: var(--ink-2); }
.btns { display: flex; flex-wrap: wrap; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); translate: -50% 16px; opacity: 0; background: var(--ink); color: #fff; font-weight: 800; font-size: 18px; line-height: 1.5; padding: 14px 24px; border-radius: 24px; z-index: 90; transition: opacity .25s, translate .3s var(--ease); pointer-events: none; text-align: center; width: max-content; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; translate: -50% 0; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #fff; flex: none; }
.avatar.lg { width: 72px; height: 72px; }
.tag { position: absolute; top: 10px; inset-inline-start: 10px; background: var(--sun); color: var(--ink); font-weight: 800; font-size: 15px; padding: 3px 12px; border-radius: 14px; display: grid; place-items: center; }
.tag.new { background: var(--coral); }
.book.set { background: #fffdf8; border-radius: 12px; box-shadow: var(--lift); overflow: hidden; }
.book.set img { box-shadow: none; border-radius: 0; aspect-ratio: 262/300; object-position: top; }
.book.set strong { display: grid; place-items: center; min-height: 19%; padding: 6px 10px; font-size: clamp(15px, 1.8vw, 20px); line-height: 1.25; text-align: center; background: var(--sun); }
.tag.lock { background: rgba(40,40,40,.82); color: #fff; padding: 7px; border-radius: 50%; }
.tag.lock .i { width: 20px; height: 20px; }

/* ---------- top bar ---------- */
.hbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) var(--gut) 12px; background: linear-gradient(var(--paper) 72%, transparent); }
.hbar .ktitle { flex: 1; min-width: 0; font-size: 24px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-bar { justify-content: space-between; }
.hlogo { width: 96px; height: auto; }
.hbar-end { display: flex; gap: 10px; align-items: center; }
.hbtn { min-height: 54px; padding: 0 18px; border-radius: 28px; background: #fff; box-shadow: var(--lift); display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; flex: none; }
.hbtn.quiet { background: transparent; box-shadow: none; color: var(--ink-2); padding: 0 8px; }
.who { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 16px 0 7px; border-radius: 28px; background: #fff; box-shadow: var(--lift); font-weight: 800; font-size: 17px; max-width: 190px; }
[dir=rtl] .who { padding: 0 7px 0 16px; }
.who:disabled { opacity: 1; box-shadow: none; background: transparent; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- home: the bookshelf ---------- */
.home { padding: 4px var(--gut) 56px; max-width: 1280px; margin: 0 auto; }
.home h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; margin: 6px 0 18px; }
.again { margin-bottom: 22px; }
.again h2 { font-size: 22px; margin-bottom: 10px; }
.again-row { display: flex; gap: 16px; }
.sheet-card { width: clamp(104px, 22vw, 168px); flex: none; }
.sheet-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #fff; border-radius: 10px; box-shadow: 0 0 0 4px #fff, var(--lift); transition: transform .35s var(--pop); }
.sheet-card:nth-child(odd) img { rotate: -1.5deg; } .sheet-card:nth-child(even) img { rotate: 1.2deg; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 20vw, 220px), 1fr)); gap: clamp(16px, 2.4vw, 28px); }
.book { position: relative; display: block; border-radius: 12px; transition: transform .35s var(--pop); }
.book img { width: 100%; aspect-ratio: 262/371; object-fit: cover; border-radius: 12px; box-shadow: var(--lift); background: #fff; }
.book:active, .sheet-card:active img { transform: scale(.95) rotate(-1deg); }
@media (hover: hover) { .book:hover { transform: translateY(-6px) rotate(-1.2deg); } }
.book.blank { aspect-ratio: 262/371; background: #fffdf8; box-shadow: var(--lift); display: grid; align-content: center; justify-items: center; gap: 6px; padding: 14px; text-align: center; }
.blank-sheet { width: 64px; height: 64px; border-radius: 50%; background: var(--sun); display: grid; place-items: center; margin-bottom: 8px; }
.blank-sheet .i { width: 34px; height: 34px; stroke-width: 2.6; }
.book.blank strong { font-size: 22px; } .book.blank small { font-size: 16px; color: var(--ink-2); font-weight: 700; }

/* ---------- a story ---------- */
.story { display: grid; grid-template-columns: minmax(200px, 270px) minmax(0, 1fr); gap: 32px; padding: 4px var(--gut) 56px; max-width: 1280px; margin: 0 auto; align-items: start; }
.story-side { display: grid; gap: 18px; position: sticky; top: 92px; }
.story-cover { width: 100%; border-radius: 12px; box-shadow: var(--lift); }
.cast h2, .prompts h2 { font-size: 20px; margin-bottom: 8px; }
.cast p { font-size: 16px; line-height: 1.7; margin-bottom: 8px; font-family: Tajawal, 'Baloo Bhaijaan 2', sans-serif; }
:lang(en) .cast p { font-family: inherit; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 17vw, 190px), 1fr)); gap: 22px 18px; }
.pcard { display: grid; gap: 6px; grid-template-columns: auto 1fr; align-items: start; }
.pimg { grid-column: 1 / -1; position: relative; display: block; }
.pimg img { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #fff; border-radius: 10px; box-shadow: var(--lift); transition: transform .35s var(--pop); }
.pcard:active .pimg img { transform: scale(.95) rotate(-1deg); }
@media (hover: hover) { .pcard:hover .pimg img { transform: translateY(-4px) rotate(-1.2deg); } }
.pcard.locked .pimg img { opacity: .55; }
.pnum { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px; background: var(--sun); display: inline-grid; place-items: center; font-weight: 800; font-size: 15px; line-height: 1; }
.pline { font-weight: 700; font-size: 16px; line-height: 1.45; padding-top: 2px; }
.prompts { margin-top: 34px; }
.prompt-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.prompt { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 16px; border-radius: 20px; background: #fffdf8; box-shadow: var(--lift); font-weight: 700; font-size: 17px; line-height: 1.4; }
.prompt .i { color: var(--teal); }

/* ---------- paint ---------- */
/* Landscape: paint pots on one side, the tool tray on the other, the page in the middle. */
.kpaint { position: fixed; inset: 0; display: grid; grid-template-columns: 184px minmax(0, 1fr) 184px; grid-template-rows: auto minmax(0, 1fr); background: var(--desk) var(--grain); touch-action: pan-x pan-y; }
.kpaint.lefty { grid-template-columns: 184px minmax(0, 1fr) 184px; }
.kbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.kline { flex: 1; min-width: 0; font-size: clamp(18px, 2.2vw, 24px); font-weight: 800; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pots { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 66px; gap: 6px 8px; align-content: start; justify-items: center; padding: 6px 12px 16px; overflow-y: auto; scrollbar-width: none; }
.kpaint.lefty .pots { grid-column: 3; }
.pot { width: 66px; height: 66px; transition: transform .3s var(--pop); }
.pot svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 3px rgba(60,40,10,.2)); }
.pot:nth-child(3n) svg { rotate: 40deg; } .pot:nth-child(3n+1) svg { rotate: -25deg; }
.pot path { fill: var(--c); stroke: rgba(0,0,0,.14); stroke-width: 1.5; }
.pot[aria-pressed=true] { transform: scale(1.12); }
.pot[aria-pressed=true] path { stroke: var(--ink); stroke-width: 4.5; }
.pot .dish-paint { fill: var(--c, #BDBDBD); stroke: none; }
.pot.dish svg, .pot.pick svg, .pot.swap svg { rotate: none !important; }
.pot.swap circle:first-child { fill: #fff; }
.pot.swap circle { stroke: none; }
.pot.dish[aria-pressed=true] ellipse:first-child { stroke-width: 5; }
.pot.pick { display: grid; place-items: center; }
.pot.pick .i { width: 62%; height: 62%; padding: 16%; border-radius: 50%; background: #fff; box-shadow: var(--lift); filter: none; }
.pot.pick[aria-pressed=true] .i { background: var(--sun); box-shadow: 0 0 0 3px var(--ink); }
.mixer { display: grid; gap: 18px; justify-items: center; }
.mix-dish { width: min(46vw, 190px); aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 10px #fff, inset 0 0 0 12px #d9cfbb, var(--lift); transition: background .3s; }
.mix-pots { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; width: 100%; }
.mix-pots .pot { position: relative; width: 100%; height: auto; aspect-ratio: 1; }
.mix-pots .pot b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.pot.dip { animation: dip .45s var(--pop); }
@keyframes dip { 40% { transform: scale(.86) rotate(-6deg); } }
.board { grid-column: 2; grid-row: 2; position: relative; min-height: 0; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1 1 0; min-height: 0; }
.viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fffdf8 var(--grain); box-shadow: 0 2px 0 rgba(0,0,0,.05), 0 20px 50px rgba(70,45,10,.25); border-radius: 3px; will-change: transform; }
.c-paper { mix-blend-mode: multiply; z-index: 0; }
.papers { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.papers button { display: grid; gap: 8px; justify-items: center; padding: 10px; border-radius: 18px; background: #fff; box-shadow: var(--lift); font-weight: 800; font-size: 16px; }
.papers button[aria-pressed=true] { box-shadow: 0 0 0 4px var(--teal); }
.papers i { width: 100%; aspect-ratio: 4/3; border-radius: 10px; box-shadow: inset 0 0 0 2px #e3d9c5; }
.sheet canvas, .paint-layers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stickers { position: absolute; inset: 0; pointer-events: none; }
.fit { position: absolute; top: 8px; inset-inline-end: 8px; z-index: 3; }
.tray { grid-column: 3; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr 1fr; align-content: start; justify-items: center; gap: 4px 6px; padding: 6px 10px 16px; overflow-y: auto; scrollbar-width: none; }
.kpaint.lefty .tray { grid-column: 1; }
.ktool { width: 54px; min-height: 68px; display: grid; justify-items: center; align-content: center; padding: 4px 0; border-radius: 24px; transition: background .2s, transform .3s var(--pop); flex: none; }
.ktool .art { width: 40px; height: 52px; display: block; transition: transform .35s var(--pop); }
.ktool .art svg { width: 100%; height: 100%; }
.ktool .nm { display: none; }
.ktool[aria-pressed=true] { background: #fff; box-shadow: var(--lift); }
.ktool[aria-pressed=true] .art { transform: translateY(-4px) rotate(-10deg) scale(1.15); }
.ktool[aria-pressed=true] .nm { color: var(--ink); }
.ktool:active .art { transform: scale(.88); }
/* Line thickness sits on the page edge, only while a drawing tool is in the hand. */
.ksizes { flex: none; align-self: center; margin: 2px 0 8px; display: flex; flex-wrap: wrap; justify-content: center; max-width: 100%; gap: 6px; padding: 6px; border-radius: 26px; background: rgba(255,255,255,.92); box-shadow: var(--lift); transition: opacity .2s, transform .3s var(--pop); }

.ksize { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; }
.ksize i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--now); box-shadow: inset 0 0 0 2px rgba(0,0,0,.18); }
.ksize[aria-pressed=true] { background: #fff; box-shadow: 0 0 0 3px var(--ink); }
/* The inside-the-lines switch shows what it does: a scribble that stays in its box, or one that runs out. */
.lines svg { width: 46px; height: 34px; }
.lines .shape { fill: #fffdf8; stroke: var(--ink); stroke-width: 3; }
.lines .scrib { fill: none; stroke: var(--now); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; transition: opacity .25s; }
.lines[aria-pressed=true] .scrib.out, .lines[aria-pressed=false] .scrib.in { opacity: 0; }
.lines[aria-pressed=true] .scrib.in, .lines[aria-pressed=false] .scrib.out { animation: scribble .6s var(--ease); stroke-dasharray: 160; }
@keyframes scribble { from { stroke-dashoffset: 160; } to { stroke-dashoffset: 0; } }
/* With a small tool box the tools are large and named; once it has grown they sit three across. */
.tray.few { grid-template-columns: 1fr 1fr; gap: 4px 6px; }
.tray.few .ktool { width: 80px; min-height: 84px; } .tray.few .ktool .art { width: 44px; height: 56px; }
.tray.few .ktool .nm { display: block; font-size: 13px; font-weight: 800; color: var(--ink-2); line-height: 1.15; text-align: center; }
.ktool.fresh { position: relative; }
.ktool.fresh::after { content: ""; position: absolute; top: 4px; inset-inline-end: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px #fff; animation: rise .5s var(--pop); }
.gift { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 20px; padding: 10px 16px; box-shadow: var(--lift); font-size: 18px; font-weight: 700; line-height: 1.4; animation: rise .6s var(--pop) .5s both; }
.gift .art { width: 44px; height: 56px; flex: none; } .gift .art svg { width: 100%; height: 100%; }
.voice[aria-pressed=false] { opacity: .55; }
.hbtn.voice { width: 54px; padding: 0; justify-content: center; color: var(--ink); }
.kstamps, .kfills, .kwater { display: flex; gap: 6px; align-items: center; }
.kwet .i { fill: #8CC8F0; stroke: rgba(0,0,0,.45); stroke-width: 1.6; }
.versions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.versions button { display: grid; gap: 6px; justify-items: center; font-weight: 700; font-size: 14px; }
.versions img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; background: #fff; box-shadow: var(--lift); }
.ksizes[data-mode=fill] > .ksize, .ksizes[data-mode=none] > .ksize { display: none; }
.kname { align-self: center; padding: 0 10px 0 12px; font-size: 15px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.bin { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; } .bin div { display: grid; gap: 6px; justify-items: center; } .bin img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; box-shadow: 0 0 0 1px #e3d9c5; }
.kfill i { width: 30px; height: 30px; border-radius: 9px; background: var(--now); box-shadow: inset 0 0 0 2px rgba(0,0,0,.18); }
.kfill[data-k=soft] i { background: radial-gradient(circle at 35% 35%, #fff 0, var(--now) 70%); }
.kfill[data-k=dots] i { background: radial-gradient(circle, rgba(255,255,255,.75) 28%, transparent 30%) 0 0 / 10px 10px, var(--now); }
.kfill[data-k=stripes] i { background: repeating-linear-gradient(45deg, var(--now) 0 5px, rgba(255,255,255,.65) 5px 9px); background-color: var(--now); }
.kfill[data-k=stars] i { background: radial-gradient(circle at 30% 30%, #fff 12%, transparent 14%), radial-gradient(circle at 72% 68%, #fff 9%, transparent 11%), var(--now); }
.kfill[data-k=rainbow] i { background: linear-gradient(135deg, #E0473C, #F7C531, #5E9B4A, #16AAAE, #3565C8, #8757C1); }
.kfill[data-k=gold] i { background: linear-gradient(135deg, #8a6a1c, #e9c85f 25%, #fff0b0 40%, #c19a35 58%, #f5d777 76%, #9c7a24); }
@media (max-height: 720px) and (min-width: 601px) and (min-aspect-ratio: 1/1) { .pots { grid-auto-rows: 54px; } .pots .pot { width: 54px; height: 54px; } }
@media (max-height: 720px) and (min-width: 601px) { .ktool { min-height: 70px; } .ktool .art { width: 38px; height: 46px; } .ktool .nm { font-size: 11px; } }
.rest { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px; background: linear-gradient(#f6e7c4, var(--paper)); }
.rest h1 { font-size: clamp(34px, 6vw, 56px); font-weight: 800; } .rest p { font-size: 22px; font-weight: 700; color: var(--ink-2); margin-bottom: 18px; }
.avatar.xl { width: 160px; height: 160px; box-shadow: var(--lift); }
.kid { display: grid; gap: 10px; } .kid + .kid { margin-top: 14px; }
.kid h3 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 20px; }
.kid-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; } .kid-row img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; box-shadow: 0 0 0 1px #e3d9c5; background: #fff; }
.kid-books { display: grid; gap: 8px; } .kid-books li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 16px; }
.row select { min-height: 48px; padding: 4px 12px; border-radius: 14px; border: 2px solid #b9ae9a; background: #fffdf8; font: inherit; font-weight: 700; }
.kstamp svg { width: 26px; height: 26px; fill: var(--now); stroke: rgba(0,0,0,.35); stroke-width: 1.2; }
.is-blank .lines { display: none; }

/* ---------- the guide hand ---------- */
.coach { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.coach .hand { position: absolute; left: var(--x); top: var(--y); width: 58px; margin: -6px 0 0 -18px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.25)); }
.coach .hand svg { width: 100%; display: block; }
.coach.in .hand { animation: hand-in .5s var(--pop) both; }
.coach[data-move=tap] .hand svg { animation: tap 1.1s ease-in-out .5s infinite; }
.coach[data-move=drag] .hand svg { animation: drag 1.8s ease-in-out .5s infinite; }
.coach .hand::after { content: ""; position: absolute; left: 18px; top: 6px; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--accent); opacity: 0; animation: ring 1.1s ease-out .5s infinite; }
.coach[data-move=drag] .hand::after { display: none; }
@keyframes hand-in { from { opacity: 0; transform: translate(40px, 60px) scale(.8); } }
@keyframes tap { 0%, 100% { transform: translateY(0) scale(1); } 45% { transform: translateY(8px) scale(.92); } }
@keyframes ring { 0%, 40% { opacity: 0; transform: scale(.5); } 55% { opacity: 1; } 100% { opacity: 0; transform: scale(1.8); } }
@keyframes drag { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-90px, 30px); } }
.coach .bubble { position: absolute; left: clamp(120px, var(--x), calc(100vw - 120px)); top: var(--y); translate: -50% calc(-100% - 30px); background: #fff; color: var(--ink); font-weight: 800; font-size: 21px; line-height: 1.4; padding: 12px 20px; border-radius: 20px; box-shadow: 0 12px 30px rgba(0,0,0,.2); text-align: center; width: max-content; max-width: min(80vw, 300px); animation: rise .4s var(--pop) both; }
.coach[data-low="1"] .bubble { translate: -50% 78px; }

/* ---------- dialogs ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(30,22,10,.55); backdrop-filter: blur(6px); animation: fade-in .25s ease; overflow-y: auto; }
.modal-card { position: relative; width: min(520px, 100%); background: var(--paper) var(--grain); border-radius: 32px; padding: 30px 26px 26px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: rise .5s var(--pop); display: grid; gap: 16px; }
.modal-card h2 { font-size: 26px; padding-inline-end: 54px; }
.modal-x { position: absolute; top: 14px; inset-inline-end: 14px; width: 48px; height: 48px; border-radius: 16px; }
.celebrate .modal-card { width: min(760px, 100%); }
.cel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: center; }
/* The finished page drops into the child's book. */
.cel-book { position: relative; padding: 4% 6% 6% 10%; }
.cel-cover { position: absolute; inset: 0 12% 4% 0; width: 86%; height: 94%; object-fit: cover; border-radius: 10px; box-shadow: var(--lift); rotate: -5deg; }
.cel-page { position: relative; border-radius: 8px; box-shadow: var(--lift); background: #fff; width: 100%; aspect-ratio: 3/4; rotate: 2deg; animation: tuck .9s var(--pop) .15s both; }
@keyframes tuck { 0% { opacity: 0; transform: translateY(-46%) rotate(-14deg) scale(1.18); } 60% { opacity: 1; } 100% { transform: none; } }
.cel-side { display: grid; gap: 14px; }
.cel-side h2 { font-size: clamp(26px, 3.4vw, 36px); padding: 0; }
.cel-actions { display: grid; gap: 10px; }
.who-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.who-pick { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 22px; background: #fff; box-shadow: var(--lift); font-weight: 800; font-size: 18px; }
.ask { display: grid; justify-items: center; gap: 14px; padding-top: 22px; text-align: center; font-size: 19px; font-weight: 700; line-height: 1.6; }
.ask .i { color: var(--teal); }
.recovery { display: grid; gap: 14px; }
.recovery p { line-height: 1.7; font-size: 17px; }
.recovery output { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: clamp(18px, 4.6vw, 24px); font-weight: 700; letter-spacing: .04em; background: #fff; border-radius: 16px; padding: 16px; text-align: center; user-select: all; -webkit-user-select: all; }

/* ---------- my book ---------- */
.reader { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 24px); padding: 0 var(--gut) 24px; min-height: calc(100dvh - 100px); touch-action: pan-y; }
.leaf { flex: 0 1 auto; min-width: 0; }
.leaf-page { margin: 0; display: grid; justify-items: center; gap: 14px; }
.leaf-page img { height: min(62dvh, 110vw); width: auto; aspect-ratio: 3/4; object-fit: contain; background: #fff; border-radius: 8px; box-shadow: 0 2px 0 rgba(0,0,0,.05), 0 20px 50px rgba(70,45,10,.22); animation: rise .35s var(--ease); }
.leaf-page.cover img { aspect-ratio: 262/371; }
.leaf-page figcaption { font-size: clamp(19px, 2.6vw, 26px); font-weight: 800; line-height: 1.5; text-align: center; max-width: 30ch; }
.turn:disabled { visibility: hidden; }

/* ---------- my pictures ---------- */
.gallery, .parents, .about { padding: 0 var(--gut) 56px; max-width: 1100px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 18vw, 190px), 1fr)); gap: 18px; }
.g-item { position: relative; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--lift); }
.g-item img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.g-acts { position: absolute; bottom: 8px; inset-inline-start: 8px; display: flex; gap: 8px; }
.empty { font-size: 22px; color: var(--ink-2); text-align: center; padding: 80px 0; font-weight: 700; }

/* ---------- parents ---------- */
.parents, .about { font-family: Tajawal, 'Baloo Bhaijaan 2', system-ui, sans-serif; -webkit-user-select: text; user-select: text; }
:lang(en) .parents, :lang(en) .about { font-family: Nunito, system-ui, sans-serif; }
.parents { display: grid; gap: 18px; max-width: 760px; }
.parents section { background: #fff; border-radius: 26px; padding: 24px; box-shadow: var(--lift); display: grid; gap: 14px; }
.parents h2 { font-size: 22px; }
.parents p { line-height: 1.8; font-size: 17px; }
.parents form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-weight: 700; font-size: 16px; }
.field input, .child input, .gate input { min-height: 52px; padding: 8px 14px; border-radius: 14px; border: 2px solid #b9ae9a; background: #fffdf8; font-size: 18px; width: 100%; }
.field input:focus-visible, .child input:focus-visible, .gate input:focus-visible { outline-offset: 0; border-color: var(--teal); }
.err { color: #a3261c; font-weight: 700; font-size: 16px; min-height: 0; }
.err:empty { display: none; }
.warn { color: #a3261c; font-weight: 700; }
.alt { display: flex; flex-wrap: wrap; gap: 8px 22px; font-weight: 700; }
.alt a, .legal-links a, .about a:not(.primary):not(.ghost) { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.avatars { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.avatars legend { font-weight: 700; font-size: 16px; margin-bottom: 8px; padding: 0; }
.avatars input { position: absolute; opacity: 0; }
.avatars label { border-radius: 50%; cursor: pointer; }
.avatars .avatar { width: 60px; height: 60px; box-shadow: 0 0 0 2px #e3d9c5; }
.avatars input:checked + .avatar { box-shadow: 0 0 0 4px var(--teal); }
.avatars input:focus-visible + .avatar { outline: 3px solid var(--teal); outline-offset: 6px; }
.child { grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px !important; }
.child .avatar.lg { width: 52px; height: 52px; }
details summary { list-style: none; width: max-content; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 14px; }
.price { font-size: 30px !important; font-weight: 800; line-height: 1.2 !important; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; font-weight: 700; font-size: 17px; }
.row input { width: 28px; height: 28px; accent-color: var(--teal); flex: none; }
.gate { background: #fff; border-radius: 26px; padding: 28px 24px; box-shadow: var(--lift); justify-items: center; text-align: center; font-size: 19px; font-weight: 700; max-width: 440px; margin: 24px auto 0; width: 100%; }
.gate input { max-width: 160px; text-align: center; font-size: 24px; font-weight: 800; }
.legal-links a { display: inline-block; padding: 12px 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 0 22px; font-size: 16px; font-weight: 700; justify-content: center; padding-top: 4px; }
.parents section .legal-links { justify-content: flex-start; }

/* ---------- about, privacy, terms ---------- */
.about { display: grid; gap: 28px; max-width: 820px; }
.about-art { display: flex; justify-content: center; padding-top: 6px; }
.about-art img { width: clamp(100px, 26vw, 200px); border-radius: 10px; box-shadow: var(--lift); }
.about-art img:nth-child(1) { rotate: -5deg; translate: 14% 4%; } .about-art img:nth-child(2) { z-index: 1; } .about-art img:nth-child(3) { rotate: 5deg; translate: -14% 4%; }
.about-text { display: grid; gap: 14px; }
.about-text h2 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; font-family: 'Baloo Bhaijaan 2', Tajawal, sans-serif; }
:lang(en) .about-text h2 { font-family: Nunito, sans-serif; font-weight: 900; }
.about-text p { font-size: 18px; line-height: 1.85; }
.offer { background: #fff; border-radius: 22px; padding: 18px 20px; box-shadow: var(--lift); }
.offer strong { display: block; font-size: 24px; }
.about-go { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0; }

/* ---------- portrait tablets and phones: tools, then colours, along the bottom ---------- */
/* Upright tablets: narrower side columns, so the page stays large and nothing sits under a resting wrist. */
@media (max-aspect-ratio: 1/1) and (min-width: 601px) {
  .kpaint, .kpaint.lefty { grid-template-columns: 148px minmax(0, 1fr) 148px; }
  .pots { grid-auto-rows: 64px; gap: 4px; padding: 6px 6px 16px; } .pot { width: 62px; height: 62px; }
  .tray { gap: 4px 0; padding: 6px 2px 16px; } .ktool { width: 46px; min-height: 62px; } .ktool .art { width: 36px; height: 46px; }
  .tray.few { gap: 4px 4px; } .tray.few .ktool { width: 68px; min-height: 80px; } .tray.few .ktool .art { width: 40px; height: 50px; } .tray.few .ktool .nm { font-size: 11px; }
}
@media (max-width: 760px) {
  .story { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .story-side { position: static; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr); align-items: start; }
  .story-side .primary { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 600px) {
  .kpaint, .kpaint.lefty { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .board { grid-column: 1; grid-row: 2; }
  .tray, .kpaint.lefty .tray { grid-column: 1; grid-row: 3; grid-template-columns: repeat(10, minmax(0, 1fr)); overflow: visible; padding: 6px 10px 2px; gap: 4px; max-width: 720px; width: 100%; margin: 0 auto; }
  .pots, .kpaint.lefty .pots { grid-column: 1; grid-row: 4; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: auto; gap: 2px; overflow: visible; padding: 4px 10px calc(22px + env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
  .pot { width: 100%; max-width: 76px; height: auto; aspect-ratio: 1; }
  .ktool { width: 100%; min-width: 0; min-height: 76px; border-radius: 18px; } .ktool .art { width: 38px; height: 48px; } .ktool .nm { font-size: 12px; }
  .cel { grid-template-columns: 1fr; } .cel-book { width: min(60%, 30dvh); margin: 0 auto; }
}
@media (max-width: 560px) {
  .kbar { gap: 8px; flex-wrap: wrap; padding-bottom: 4px; }
  .kbar [data-act=home] { margin-inline-end: auto; }
  .kline { order: 9; flex: 1 0 100%; font-size: 17px; -webkit-line-clamp: 2; min-height: 0; }
  .kbtn { width: 48px; height: 48px; border-radius: 16px; }
  .kdone { height: 48px; padding: 0 14px; font-size: 17px; }
  .tray, .kpaint.lefty .tray { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .tray.few, .kpaint.lefty .tray.few { grid-template-columns: repeat(6, minmax(0, 1fr)); } .tray.few .ktool { width: 100%; min-height: 50px; } .tray.few .ktool .art { width: 32px; height: 42px; }
  .ktool { min-height: 50px; border-radius: 16px; } .ktool .nm, .tray.few .ktool .nm { display: none; } .ktool .art { width: 32px; height: 42px; }
  .ksizes { gap: 2px; padding: 4px; }
  .lines svg { width: 38px; height: 28px; }
  .ksize { width: 44px; height: 44px; }
  .hbar { gap: 8px; } .hbar .ktitle { font-size: 20px; }
  .hlogo { width: 76px; }
  .hbtn { min-height: 48px; padding: 0 12px; font-size: 15px; } .hbtn span { display: none; } .hbtn.quiet span { display: inline; }
  .who { min-height: 48px; max-width: 120px; font-size: 15px; } .who .avatar { width: 34px; height: 34px; }
  .reader { gap: 4px; padding: 0 8px 20px; } .turn { width: 44px; height: 44px; }
  .leaf-page img { height: min(56dvh, 96vw); }
  .parents section { padding: 20px 18px; border-radius: 22px; }
  .child { grid-template-columns: auto minmax(0, 1fr) auto; } .child .del { grid-column: 3; }
  .pline { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
.kbtn.lines[aria-pressed=true] { box-shadow: 0 0 0 3px var(--accent), var(--lift); }
figcaption .kbtn { display: inline-grid; vertical-align: middle; margin-inline-start: 6px; }
