.book-shelf{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:22px;margin:24px 0 48px}
.book-card{overflow:hidden;background:#fff;border:1px solid var(--line);border-radius:26px;box-shadow:0 8px 22px #2148520d;display:flex;flex-direction:column}
.book-cover{height:280px;background:#e4f4f2;display:grid;place-items:center;color:var(--teal);font-size:5rem;overflow:hidden}
.book-cover img{width:100%;height:100%;object-fit:contain}
.book-card-copy{padding:20px;display:grid;gap:10px;align-content:start}
.book-card-copy h2{margin:0;font-size:1.25rem}
.book-card-copy p{margin:0;color:var(--muted);line-height:1.5}
.book-card-copy small{color:var(--muted)}
.book-card-copy .btn{justify-self:start;margin-top:5px}
.book-empty{grid-column:1/-1;padding:64px 24px;text-align:center;border:2px dashed #c9dfdc;border-radius:28px;background:#fff}
.book-empty span{font-size:4rem}
.book-empty h2{margin:12px 0 5px}
.book-empty p{color:var(--muted)}
.book-card-progress{display:inline-flex;align-items:center;gap:5px;color:#087e80!important;font-weight:700;font-variant-numeric:tabular-nums}
body.book-reader-mode{overflow:hidden;background:#102f32}
body.book-reader-mode #app{width:100%;height:100dvh;min-height:0}
body.book-reader-mode #main{width:100%;height:100%;max-width:none;margin:0;padding:0;overflow:hidden}
body.book-reader-mode .book-reader{
 box-sizing:border-box;position:fixed;inset:0;z-index:1000;width:100%;height:100vh;height:100dvh;
 display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden;background:#102f32;color:#fff;
 padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
}
.book-reader-top{min-height:48px;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;gap:10px}
.book-reader-title{min-width:0;margin:0;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:clamp(.9rem,2vw,1.2rem);font-weight:700}
.book-close,.book-fullscreen{display:grid;place-items:center;width:44px;height:44px;border:1px solid #ffffff30;border-radius:14px;background:#ffffff16;color:#fff;text-decoration:none;font-size:1.45rem;line-height:1;cursor:pointer}
.book-close:hover,.book-fullscreen:hover,.book-arrow:not(:disabled):hover{background:#ffffff32}
.book-close:focus-visible,.book-fullscreen:focus-visible,.book-arrow:focus-visible{outline:3px solid #ffd765;outline-offset:2px}
.book-page-stage{min-width:0;min-height:0;display:grid;grid-template-columns:clamp(40px,5vw,62px) minmax(0,1fr) clamp(40px,5vw,62px);gap:clamp(2px,1vw,14px);align-items:stretch;overflow:hidden;touch-action:pan-y}
.book-page{width:100%;height:100%;min-width:0;min-height:0;margin:0;display:flex;align-items:center;justify-content:center;overflow:hidden}
.book-page img{display:block;width:100%;height:100%;object-fit:contain;user-select:none;-webkit-user-drag:none}
.book-arrow{align-self:center;justify-self:center;display:grid;place-items:center;width:clamp(38px,4vw,52px);height:clamp(38px,4vw,52px);border:1px solid #ffffff30;border-radius:50%;background:#ffffff16;color:#fff;font-size:1.65rem;line-height:1}
.book-arrow:disabled{opacity:.25;cursor:default}
.book-reader-bottom{min-height:36px;display:grid;place-items:center;font-size:.9rem;font-weight:700;font-variant-numeric:tabular-nums;color:#d8edea}
.book-reader:fullscreen,.book-reader:-webkit-full-screen{width:100%;height:100%;inset:0}
@media(max-width:720px){.book-shelf{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.book-cover{height:210px}.book-card-copy{padding:15px}.book-card-copy h2{font-size:1.05rem}}
@media(max-width:420px){.book-shelf{grid-template-columns:1fr}.book-cover{height:260px}.book-reader-top{gap:5px}.book-reader-title{font-size:.9rem}.book-page-stage{grid-template-columns:40px minmax(0,1fr) 40px;gap:2px}}
@media(max-height:460px){body.book-reader-mode .book-reader{padding-top:max(4px,env(safe-area-inset-top));padding-bottom:max(4px,env(safe-area-inset-bottom))}.book-reader-top{min-height:40px}.book-reader-bottom{min-height:28px}.book-close,.book-fullscreen{height:38px;width:38px}}
.book-page-builder{display:grid;gap:12px;margin-top:16px}
.book-page-row{display:grid;gap:10px;border:1px solid var(--line);border-radius:14px;padding:12px;background:#f9fcfb}
.book-page-row.dragging{opacity:.5}
.book-page-row-head{display:flex;align-items:center;gap:10px}
.book-page-row-head>b{flex:1}
.book-page-row-body{display:grid;grid-template-columns:90px 1fr;gap:14px;align-items:center}
.book-page-thumb{width:90px;height:110px;display:grid;place-items:center;overflow:hidden;border-radius:10px;background:#e3f2ef;font-size:2rem;color:var(--teal)}
.book-page-thumb img{width:100%;height:100%;object-fit:contain}
.book-page-actions{margin-top:8px}
.book-admin-preview{display:grid;gap:12px;place-items:center;min-height:180px;padding:18px;text-align:center;border-radius:18px;background:#eaf7f4;color:var(--muted)}
.book-preview{display:grid;gap:18px;justify-items:center}
.book-preview-image{width:min(680px,80vw);height:min(72vh,760px);display:grid;place-items:center;background:#102f32;border-radius:18px;overflow:hidden}
.book-preview-image img{width:100%;height:100%;object-fit:contain}
.book-preview .preview-nav{display:flex;align-items:center;gap:20px}
@media(max-width:580px){.book-page-row-body{grid-template-columns:70px 1fr}.book-page-thumb{width:70px;height:90px}.book-preview-image{width:82vw;height:65vh}}

/* Story reader viewport: show the complete uploaded page without cover cropping. */
.story-reader{box-sizing:border-box;height:calc(100dvh - 148px);min-height:0;max-height:calc(100dvh - 148px);display:flex;flex-direction:column;gap:8px;overflow:auto}
.story-reader>.back{flex:0 0 auto;align-self:flex-start}
.story-reader-top{flex:0 0 auto;min-height:46px;margin:0;display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:16px}
.story-reader-top>div:first-child{min-width:0}
.story-reader-top h1{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.story-reader-actions{display:flex;align-items:center;gap:8px}
.story-fullscreen,.story-fullscreen-control{display:inline-grid;place-items:center;width:44px;height:44px;border:1px solid var(--line);border-radius:14px;background:#fff;color:var(--ink);font-size:1.5rem;line-height:1}
.story-fullscreen-control{display:none}
.story-fullscreen-close{font-size:1.85rem}
.story-reader .story-layout{flex:1;min-height:0;height:auto;grid-template-columns:minmax(0,1fr) 263px;align-items:stretch;overflow:hidden}
.story-reader .book{min-width:0;min-height:0;height:100%;display:flex;flex-direction:column}
.story-reader .book-picture{flex:1 1 auto;min-height:0;height:auto;display:flex;align-items:center;justify-content:center;background:#f4f8f7}
.story-reader .book-picture>img,.story-reader .book-picture>video{display:block;width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;user-select:none;-webkit-user-drag:none}
.story-reader .story-object{z-index:1}
.story-reader .book-text{flex:0 0 auto;min-height:0;overflow:visible}
.story-reader .reader-controls{justify-content:flex-start;margin-top:18px}
.story-reader .story-aside{min-height:0;overflow:auto}
.story-reader-fullscreen{overflow:hidden}
.story-reader:fullscreen,.story-reader.is-fullscreen{position:fixed;z-index:1000;inset:0;width:100vw;height:100dvh;max-height:none;min-height:0;padding:max(12px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));background:#102f32;color:#fff;overflow:hidden}
.story-reader:fullscreen>.back,.story-reader.is-fullscreen>.back{color:#fff}
.story-reader:fullscreen .story-reader-top,.story-reader.is-fullscreen .story-reader-top{color:#fff}
.story-reader:fullscreen .story-reader-top .eyebrow,.story-reader.is-fullscreen .story-reader-top .eyebrow{color:#d7efec}
.story-reader:fullscreen .story-fullscreen,.story-reader.is-fullscreen .story-fullscreen{display:none}
.story-reader:fullscreen .story-fullscreen-control,.story-reader.is-fullscreen .story-fullscreen-control{display:inline-grid;background:#fff;color:#102f32;border-color:#fff}
.story-reader:fullscreen .book,.story-reader.is-fullscreen .book{background:#102f32;border-color:#ffffff22;box-shadow:none}
.story-reader:fullscreen .book-picture,.story-reader.is-fullscreen .book-picture{background:#102f32}
.story-reader:fullscreen .book-text,.story-reader.is-fullscreen .book-text{color:#fff}
.story-reader:fullscreen .book-text>.translation,.story-reader.is-fullscreen .book-text>.translation{color:#d7efec}
.story-reader:fullscreen .talk-card,.story-reader:fullscreen .story-word-list,.story-reader.is-fullscreen .talk-card,.story-reader.is-fullscreen .story-word-list{background:#173e42;color:#fff;border-color:#ffffff22}
.story-reader:fullscreen .talk-card p,.story-reader.is-fullscreen .talk-card p{color:#d7efec}
.story-reader:fullscreen .story-aside,.story-reader.is-fullscreen .story-aside{overflow:auto}
.story-reader{touch-action:pan-y}
.story-reader img,.story-reader video{user-select:none;-webkit-user-drag:none}
@media(max-width:720px){
 .story-reader{height:calc(100dvh - 112px);max-height:calc(100dvh - 112px);gap:8px}
 .story-reader-top{grid-template-columns:minmax(0,1fr) auto;gap:8px}
 .story-reader-top .mini-badge{grid-column:2;grid-row:1}
 .story-reader-actions{grid-column:1/-1;grid-row:2;justify-content:flex-end}
 .story-reader .story-layout{height:auto;flex:0 0 auto;grid-template-columns:1fr;overflow:visible}
 .story-reader .book{height:auto}
 .story-reader .book-picture{height:min(42dvh,420px);flex:none}
 .story-reader .book-text{overflow:visible}
 .story-reader .story-aside{overflow:visible}
 .story-fullscreen,.story-fullscreen-control{width:40px;height:40px}
 .story-reader:fullscreen,.story-reader.is-fullscreen{padding-left:max(8px,env(safe-area-inset-left));padding-right:max(8px,env(safe-area-inset-right))}
 .story-reader:fullscreen .story-layout,.story-reader.is-fullscreen .story-layout{height:auto;flex:0 0 auto}
}
@media(max-width:420px){
 .story-reader{height:calc(100dvh - 82px);max-height:calc(100dvh - 82px)}
 .story-reader-top{gap:6px}
 .story-reader-top h1{font-size:1.35rem}
 .story-reader-top .mini-badge{font-size:.8rem}
 .story-reader .book-picture{height:min(40dvh,360px)}
 .story-reader .book-text{padding:20px 16px}
 .story-reader .book-text>p[lang=so]{font-size:1.35rem}
}

/* Shared page composition for the child reader and the Admin live preview. */
body.story-reader-mode .story-reader{max-height:none}
.story-reader .story-page-book,
body.story-reader-mode .story-reader .story-page-book{
 min-width:0;min-height:0;width:100%;height:100%;display:flex;flex-direction:column;gap:0;align-items:stretch;
}
body.story-reader-mode .story-reader .book.story-page-book{
 display:flex;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;gap:0;align-items:stretch;height:auto;
}
body.story-reader-mode .story-reader .story-layout{overflow:visible;flex:0 0 auto}
.story-page-composition{
 --story-image-size:70%;
 box-sizing:border-box;display:grid;grid-template-columns:minmax(0,var(--story-image-size)) minmax(0,1fr);
 grid-template-rows:minmax(0,1fr);width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;background:#f4f8f7;
}
.story-page-composition .story-page-art.book-picture{
 box-sizing:border-box;position:relative;grid-column:1;grid-row:1;display:grid;place-items:center;
 width:100%;height:100%;min-width:0;min-height:0;margin:0;overflow:hidden;background:#f4f8f7;
}
.story-page-composition .story-page-art>img,
.story-page-composition .story-page-art>video{
 display:block;width:100%;height:100%;max-width:none;max-height:none;object-fit:contain;user-select:none;-webkit-user-drag:none;
}
.story-page-empty-media{display:grid;place-items:center;width:100%;height:100%;font-size:clamp(3rem,10vw,8rem);color:#66817e}
.story-page-composition .story-page-copy.book-text{
 box-sizing:border-box;grid-column:2;grid-row:1;display:flex;flex-direction:column;justify-content:center;gap:clamp(8px,1.5vw,20px);
 width:100%;height:100%;min-width:0;min-height:0;margin:0;padding:clamp(16px,3vw,42px);overflow:auto;background:#fff;
}
.story-page-copy>p[lang=so]{margin:0;font-size:clamp(1.25rem,2.3vw,2.25rem);line-height:1.5}
.story-page-composition.text-large .story-page-copy>p[lang=so]{font-size:clamp(1.6rem,3vw,2.7rem)}
.story-page-copy>.translation{margin:0;color:#58716e;font-size:clamp(.95rem,1.4vw,1.2rem);line-height:1.5}
.story-page-composition.text-large .story-page-copy>.translation{font-size:clamp(1.1rem,1.8vw,1.45rem)}
.story-page-composition.align-center .story-page-copy{text-align:center}
.story-page-composition.align-left .story-page-copy{text-align:left}
.story-page-composition.layout-split-right{grid-template-columns:minmax(0,1fr) minmax(0,var(--story-image-size))}
.story-page-composition.layout-split-right .story-page-art{grid-column:2}
.story-page-composition.layout-split-right .story-page-copy{grid-column:1}
.story-page-composition.layout-image-top{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,var(--story-image-size)) minmax(0,1fr)}
.story-page-composition.layout-image-top .story-page-art{grid-column:1;grid-row:1}
.story-page-composition.layout-image-top .story-page-copy{grid-column:1;grid-row:2}
.story-page-composition.layout-large-image-text{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,var(--story-image-size)) minmax(0,1fr)}
.story-page-composition.layout-large-image-text .story-page-art{grid-column:1;grid-row:1}
.story-page-composition.layout-large-image-text .story-page-copy{grid-column:1;grid-row:2;gap:4px;padding:8px 18px}
.story-page-composition.layout-large-image-text .story-page-copy>p[lang=so]{font-size:clamp(1rem,1.7vw,1.45rem);line-height:1.3}
.story-page-composition.layout-large-image-text .story-page-copy>.translation{font-size:clamp(.8rem,1.2vw,1rem);line-height:1.25}
.story-page-composition.layout-image-only{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
.story-page-composition.layout-image-only .story-page-art{grid-column:1;grid-row:1}
.story-page-composition.layout-image-only .story-page-copy{display:none}
.story-page-book>.story-page-controls{flex:0 0 auto;justify-content:center;margin:0;padding:8px 12px}
body.story-reader-mode .story-reader .story-page-composition{flex:1 1 auto;min-height:0}
body.story-reader-mode .story-reader .story-page-composition{height:min(58dvh,650px);flex:0 0 auto}
body.story-reader-mode .story-reader .story-page-composition .story-page-art.book-picture{height:100%;max-height:none}
body.story-reader-mode .story-reader .story-page-copy.book-text{min-height:0;overflow:auto}
@media(max-width:720px){
 .story-page-composition.layout-split-left,
 .story-page-composition.layout-split-right{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,var(--story-image-size)) minmax(0,1fr)}
 .story-page-composition.layout-split-left .story-page-art,
 .story-page-composition.layout-split-right .story-page-art{grid-column:1;grid-row:1}
 .story-page-composition.layout-split-left .story-page-copy,
 .story-page-composition.layout-split-right .story-page-copy{grid-column:1;grid-row:2}
 .story-page-copy>p[lang=so]{font-size:clamp(1.15rem,5vw,1.7rem)}
 body.story-reader-mode .story-reader .story-page-book{height:100%;min-height:0}
 body.story-reader-mode .story-reader .story-page-composition{height:min(58dvh,650px)}
 body.story-reader-mode .story-reader .story-page-controls{padding-bottom:max(8px,env(safe-area-inset-bottom))}
}
@media(max-height:460px){
 .story-page-book>.story-page-controls{padding-top:4px;padding-bottom:4px}
 .story-page-copy.book-text{padding:12px}
}
@media(min-width:721px) and (max-height:680px){
 .story-reader{height:calc(100dvh - 120px);max-height:calc(100dvh - 120px)}
}

/* Child book pages support Somali copy and a deliberate, human-audio replay. */
.book-page{
 box-sizing:border-box;display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.58fr);
 gap:clamp(12px,2.2vw,28px);align-items:center;padding:clamp(12px,2vw,24px);
 border-radius:20px;background:#faf5e8;color:#304b3c;
}
.book-page:not(.has-copy){display:flex}
.book-page:not(.has-copy)>img{width:100%;height:100%;object-fit:contain}
.book-page.has-copy:not(.has-media){grid-template-columns:minmax(0,1fr)}
.book-page>img{display:block;width:100%;height:100%;min-height:0;object-fit:contain}
.book-page-copy{display:grid;align-content:center;gap:14px;width:100%;max-height:100%;overflow:auto;padding:clamp(8px,1.5vw,18px)}
.book-page-copy>p[lang=so]{margin:0;color:#304b3c;font:500 clamp(1.3rem,2.4vw,2.2rem)/1.45 Fredoka,'Trebuchet MS',sans-serif}
.book-page-copy>.book-page-translation{margin:0;color:#617267;font-size:clamp(.92rem,1.3vw,1.1rem);line-height:1.5}
.book-page-audio{justify-self:start;display:inline-flex;align-items:center;justify-content:center;min-height:46px;padding:0 16px;border:1px solid #d6e2d5;border-radius:999px;background:#e7efe5;color:#365b46;font-weight:700;touch-action:manipulation}
.book-page-audio:hover{background:#dce9dc}
.book-page-audio:focus-visible{outline:3px solid #ffd765;outline-offset:2px}
.book-page-copy:empty{display:none}
@media(max-width:720px){
 .book-page{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1.2fr) minmax(0,.8fr);gap:6px;padding:9px}
 .book-page.has-copy:not(.has-media){grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
 .book-page>img{width:100%;height:100%}
 .book-page-copy{justify-items:center;gap:8px;padding:7px;overflow:auto;text-align:center}
 .book-page-copy>p[lang=so]{font-size:clamp(1.05rem,4.8vw,1.55rem);line-height:1.35}
 .book-page-copy>.book-page-translation{font-size:.88rem}
 .book-page-audio{min-height:44px}
}
@media(max-height:520px) and (orientation:landscape){
 .book-page{grid-template-columns:minmax(0,1fr) minmax(190px,.58fr);grid-template-rows:minmax(0,1fr)}
}