/* Andy Stories mobile-only, never touches desktop StPageFlip or the video browser. */
@media(max-width:700px){
 #reader.andy-mobile-reading .flipFrame{display:none!important}
 #reader.andy-mobile-reading .readingStage{display:block!important;overflow:visible!important;padding:8px!important;min-height:0!important;margin:10px auto!important;background:#fbfaf7!important}
 #reader.andy-mobile-reading .andy-mobile-page{display:flex;flex-direction:column;align-items:stretch;gap:16px;width:100%;background:#fffdf8;border-radius:14px;padding:12px;box-shadow:0 6px 24px #332b2718}
 #reader.andy-mobile-reading .andy-mobile-words{font:normal clamp(21px,5.4vw,27px)/1.48 Georgia,'Times New Roman',serif;white-space:pre-wrap;overflow-wrap:break-word;color:#2e2834;padding:12px 5px 4px;text-align:left}
 #reader.andy-mobile-reading .andy-mobile-illustration{display:block;max-width:100%;width:100%;height:auto;max-height:65vh;object-fit:contain;border-radius:12px;background:#e8e3d9}
 #reader.andy-mobile-reading .andy-mobile-cover{display:block;max-width:100%;max-height:73vh;width:auto;height:auto;object-fit:contain;margin:auto;border-radius:12px}
 #reader.andy-mobile-reading .andy-mobile-fallback-text{display:block;width:100%;height:auto;max-height:45vh;object-fit:contain}
 #reader.andy-mobile-reading .readerTop{margin-top:12px}
 #reader.andy-mobile-reading .controls{position:sticky;bottom:0;z-index:4;background:#fffdf9ed;padding:10px 4px;border-radius:12px;box-shadow:0 -3px 14px #0001}
}
@media(min-width:701px){#andyMobilePage{display:none!important}}

/* V3: portrait-phone layout. Desktop CSS is untouched. */
@media(max-width:700px){
 html,body{max-width:100%;overflow-x:clip}
 body{min-width:0}
 header{min-height:64px;height:auto;padding:12px 14px;align-items:center;gap:8px;flex-wrap:wrap}
 header .brand{font-size:clamp(18px,5.4vw,22px);line-height:1.2;flex:1 1 148px;min-width:0}
 header .top{display:flex;flex:0 1 auto;max-width:100%;justify-content:flex-end;gap:6px;align-items:center}
 header #language{max-width:138px;min-height:44px;font-size:14px;padding:8px 6px}
 main{padding:0 12px 30px}
 .hero{padding:28px 0 18px}
 .hero h1{font-size:clamp(31px,9vw,42px);line-height:1.14;overflow-wrap:break-word}
 .hero>p:last-child{font-size:15px;line-height:1.45}
 .sectionTitle{margin:12px 0 16px;gap:8px}
 .sectionTitle h2{font-size:clamp(23px,7vw,29px)}
 .books{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 12px}
 .bookCard{max-width:none;min-width:0;cursor:pointer;touch-action:manipulation}
 .bookCard .cover{height:auto;aspect-ratio:0.72;border-radius:7px 13px 13px 7px}
 .bookCard h3{font-size:14px;line-height:1.35;margin:11px 0 4px;overflow-wrap:anywhere}
 .readerTop{margin-top:12px;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:6px;align-items:center}
 .readerTop #backBtn{font-size:12px;min-height:44px;padding:8px 5px}
 .readerTop #bookTitle{font-size:clamp(14px,4vw,17px);line-height:1.24;text-align:center;overflow-wrap:anywhere}
 .readerTop #fullscreen{min-height:44px;min-width:38px;padding:7px}
 #reader.andy-mobile-reading .readingStage{padding:0!important;margin:12px auto!important;border-radius:15px;overflow:visible!important;background:transparent!important}
 #reader.andy-mobile-reading .andy-mobile-page{padding:9px;gap:10px;border-radius:13px;box-shadow:0 3px 18px #332b2714}
 #reader.andy-mobile-reading .andy-mobile-illustration{max-height:min(54dvh,510px);width:100%;object-fit:contain;object-position:center;border-radius:10px;background:#efece4}
 #reader.andy-mobile-reading .andy-mobile-words{font:normal clamp(17px,4.35vw,20px)/1.45 Georgia,'Times New Roman',serif;padding:9px 8px 12px;white-space:pre-wrap}
 #reader.andy-mobile-reading .andy-mobile-fallback-text{width:100%;max-height:none;height:auto;object-fit:contain}
 #reader.andy-mobile-reading .andy-mobile-cover{max-height:min(66dvh,600px)}
 #reader.andy-mobile-reading .controls{position:sticky;bottom:env(safe-area-inset-bottom,0px);z-index:15;background:#fffdf9f7;backdrop-filter:blur(8px);display:grid;grid-template-columns:44px minmax(96px,1fr) minmax(80px,auto) 44px;gap:5px;padding:9px 6px;box-shadow:0 -3px 14px #0001;margin:10px -2px 0;border:1px solid #e9e3d9}
 #reader.andy-mobile-reading .controls>button{min-height:44px;padding:6px 4px;font-size:14px}
 #reader.andy-mobile-reading #play{white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis}
 #reader.andy-mobile-reading .speedControl{display:flex;align-items:center;gap:3px;font-size:11px;min-width:0;white-space:nowrap}
 #reader.andy-mobile-reading .speedControl select{font-size:12px;padding:8px 3px;min-height:44px;width:57px}
 #reader.andy-mobile-reading #pageCount{grid-column:1/3;justify-self:center;font-size:12px;color:#6f6572}
 #reader.andy-mobile-reading #coverBtn{grid-column:3/5;justify-self:end;font-size:12px;min-height:34px}
 #reader #voiceNote{min-height:20px;margin:7px 0}
 footer{padding:22px 12px;font-size:11px}
}
@media(max-width:355px){
 header{flex-direction:column;align-items:stretch}
 header .brand{flex:0 0 auto}
 header .top{justify-content:flex-start}
 #reader.andy-mobile-reading .controls{grid-template-columns:40px minmax(84px,1fr) 72px 40px}
 #reader.andy-mobile-reading .speedControl>span{display:none}
}

/* V4: fixed reader geometry on touch-size portrait, with an independently scrollable
   text block. Prevents image/text pushing controls over the story and stops jumps. */
@media (max-width:700px) {
 #reader.andy-mobile-reading .readingStage {
   width:100%;max-width:100%;height:auto!important;min-height:0!important;
   padding:0!important;margin:10px auto 0!important;
 }
 #reader.andy-mobile-reading .andy-mobile-page {
   box-sizing:border-box;width:100%;min-height:0;
   height:clamp(390px,calc(100dvh - 300px),620px);
   max-height:none;gap:8px;padding:9px;
   display:flex;align-items:stretch;justify-content:flex-start;
   overflow:hidden;perspective:1100px;transform-origin:center center;
 }
 #reader.andy-mobile-reading .andy-mobile-illustration {
   flex:0 0 auto;width:100%;height:55%;max-height:55%;min-height:0;
   object-fit:contain;object-position:center;background:#f4f0e9;
 }
 #reader.andy-mobile-reading .andy-mobile-words {
   flex:1 1 auto;min-height:0;max-height:none;
   overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
   font-size:clamp(16px,4.25vw,19px);line-height:1.43;
   padding:9px 10px 16px;scrollbar-width:thin;
 }
 #reader.andy-mobile-reading .andy-mobile-fallback-text {
   flex:1 1 auto;min-height:0;max-height:100%;object-fit:contain;
 }
 #reader.andy-mobile-reading .andy-mobile-cover {
   width:100%;height:100%;max-height:100%;object-fit:contain;
 }
 #reader.andy-mobile-reading .controls {
   position:relative!important;bottom:auto!important;
   margin:7px 0 0!important;box-shadow:none!important;
   z-index:2;backdrop-filter:none;
 }
 #reader.andy-mobile-reading .andy-mobile-page.andy-turn-out {
   animation:andy-mobile-turn-out 160ms ease-in forwards;
 }
 #reader.andy-mobile-reading .andy-mobile-page.andy-turn-in {
   animation:andy-mobile-turn-in 180ms ease-out both;
 }
 #reader.andy-mobile-reading #voiceNote{margin:3px 0;min-height:12px}
}
@keyframes andy-mobile-turn-out {
 from{transform:perspective(1100px) rotateY(0deg);opacity:1}
 to{transform:perspective(1100px) rotateY(-22deg);opacity:.25}
}
@keyframes andy-mobile-turn-in {
 from{transform:perspective(1100px) rotateY(22deg);opacity:.25}
 to{transform:perspective(1100px) rotateY(0deg);opacity:1}
}
@media (max-width:700px) and (max-height:650px) {
 #reader.andy-mobile-reading .andy-mobile-page {height:clamp(250px,calc(100dvh - 250px),390px)}
 #reader.andy-mobile-reading .andy-mobile-illustration {height:45%;max-height:45%}
}
@media (prefers-reduced-motion:reduce) {
 #reader.andy-mobile-reading .andy-mobile-page.andy-turn-out,
 #reader.andy-mobile-reading .andy-mobile-page.andy-turn-in {animation:none!important}
}

/* V5: portrait-storybook immersion; keep existing desktop untouched. */
@media(max-width:700px){
 #reader.andy-mobile-reading .readingStage { margin:8px auto 0!important; overflow:visible!important; }
 #reader.andy-mobile-reading .andy-mobile-page{
   position:relative;isolation:isolate;display:block;overflow:hidden;
   padding:0!important;gap:0!important;width:100%;
   height:min(calc(100dvh - 214px),calc((100vw - 24px)*1.5422),740px)!important;
   min-height:min(380px,calc(100dvh - 214px));max-height:none!important;
   border-radius:15px;box-shadow:0 8px 24px #231a2a25;
   background:#eee8df;
 }
 #reader.andy-mobile-reading .andy-mobile-illustration{
   display:block;position:absolute;inset:0;width:100%;height:100%!important;
   min-height:0;max-height:none!important;object-fit:cover;object-position:center;
   border-radius:0;background:#eee8df;
 }
 #reader.andy-mobile-reading .andy-mobile-cover{
   position:absolute;inset:0;width:100%;height:100%;max-height:none;
   object-fit:contain;object-position:center;background:#eee8df;border-radius:0;
 }
 #reader.andy-mobile-reading .andy-mobile-text-overlay{
   position:absolute;left:0;right:0;bottom:0;z-index:2;
   max-height:48%;display:flex;flex-direction:column;justify-content:flex-end;
   padding:33px 12px 12px;min-height:0;
   background:linear-gradient(to bottom,transparent 0%,rgba(21,20,30,.42) 20%,rgba(18,19,29,.88) 100%);
   transition:opacity .2s ease,transform .2s ease;
 }
 #reader.andy-mobile-reading .andy-mobile-words{
   flex:0 1 auto;display:block;max-height:min(33dvh,230px);min-height:0;
   overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;
   -webkit-overflow-scrolling:touch;
   font:normal clamp(18px,4.85vw,22px)/1.52 Georgia,'Times New Roman',serif;
   color:#fffdf9;text-align:left;white-space:pre-wrap;overflow-wrap:break-word;
   letter-spacing:.005em;text-shadow:0 1px 3px rgba(0,0,0,.8);
   border-radius:13px;background:rgba(18,18,26,.35);
   backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
   padding:12px 13px;margin:0;box-shadow:0 2px 14px #0002;
 }
 #reader.andy-mobile-reading .andy-mobile-fallback-text{
   flex:0 1 auto;max-height:170px;max-width:100%;width:100%;
   background:#fffdf8eb;border-radius:9px;object-fit:contain;
   padding:3px;
 }
 #reader.andy-mobile-reading .andy-mobile-text-toggle{
   position:absolute;right:11px;top:11px;z-index:3;
   width:44px;height:44px;min-width:44px;min-height:44px;
   border-radius:24px;color:#fff;background:rgba(20,21,32,.7);
   border:1px solid #ffffff66;backdrop-filter:blur(5px);
   font:700 16px/1 Georgia,serif;padding:0;touch-action:manipulation;
 }
 #reader.andy-mobile-reading .andy-mobile-page.andy-text-hidden .andy-mobile-text-overlay{
   opacity:0;pointer-events:none;transform:translateY(10px);
 }
 #reader.andy-mobile-reading .controls{margin:8px 0 0!important}
}
@media(max-width:700px) and (max-height:650px){
 #reader.andy-mobile-reading .andy-mobile-page{height:max(285px,calc(100dvh - 205px))!important;min-height:0}
 #reader.andy-mobile-reading .andy-mobile-text-overlay{max-height:56%;padding-top:25px}
 #reader.andy-mobile-reading .andy-mobile-words{max-height:150px;font-size:17px;line-height:1.4}
}
@media(prefers-reduced-motion:reduce){
 #reader.andy-mobile-reading .andy-mobile-text-overlay{transition:none}
}

/* V6: child-friendly warm reading overlay instead of black screen. */
@media(max-width:700px){
 #reader.andy-mobile-reading .andy-mobile-page{
   background:#f3eadf;
 }
 #reader.andy-mobile-reading .andy-mobile-illustration,
 #reader.andy-mobile-reading .andy-mobile-cover{
   background:#f3eadf;
 }
 #reader.andy-mobile-reading .andy-mobile-text-overlay{
   padding:46px 12px 12px;
   max-height:50%;
   background:linear-gradient(to bottom,
     rgba(255,247,236,0) 0%,
     rgba(255,244,224,0.14) 16%,
     rgba(253,242,223,0.60) 34%,
     rgba(249,236,214,0.88) 68%,
     rgba(247,232,205,0.96) 100%);
 }
 #reader.andy-mobile-reading .andy-mobile-words{
   max-height:min(31dvh,220px);
   font:normal clamp(18px,4.75vw,21px)/1.54 Georgia,'Times New Roman',serif;
   color:#3f3127;
   text-shadow:none;
   background:rgba(255,244,223,0.92);
   backdrop-filter:blur(8px);
   -webkit-backdrop-filter:blur(8px);
   border:1px solid rgba(132,97,66,.18);
   box-shadow:0 8px 24px rgba(70,44,24,.14);
   padding:13px 14px 14px;
 }
 #reader.andy-mobile-reading .andy-mobile-fallback-text{
   background:rgba(255,249,239,.94);
   border:1px solid rgba(132,97,66,.15);
   box-shadow:0 8px 24px rgba(70,44,24,.14);
 }
 #reader.andy-mobile-reading .andy-mobile-text-toggle{
   color:#4a372b;
   background:rgba(255,248,237,.84);
   border:1px solid rgba(114,85,60,.24);
   box-shadow:0 4px 14px rgba(64,43,25,.12);
 }
 #reader.andy-mobile-reading .andy-mobile-page.andy-text-hidden .andy-mobile-text-toggle{
   background:rgba(255,248,237,.7);
 }
}
@media(max-width:700px) and (max-height:650px){
 #reader.andy-mobile-reading .andy-mobile-text-overlay{padding-top:34px;max-height:58%}
 #reader.andy-mobile-reading .andy-mobile-words{max-height:155px;font-size:17px;line-height:1.46}
}

/* V9: fit the full reader including the second-row Cover button in the
   visible mobile viewport. No changes to desktop PageFlip or page assets. */
@media(max-width:700px){
 #reader.andy-mobile-reading .andy-mobile-page{
   height:var(--andy-fit-height, min(calc(100dvh - 330px), calc((100vw - 24px)*1.5422), 740px))!important;
   min-height:0!important;
   max-height:none!important;
 }
 #reader.andy-mobile-reading .readingStage{
   margin:5px auto 0!important;
 }
 #reader.andy-mobile-reading .readerTop{
   margin-top:5px;
 }
 #reader.andy-mobile-reading .controls{
   margin:5px 0 0!important;
   padding:5px 5px!important;
   row-gap:3px;
   box-shadow:none!important;
 }
 #reader.andy-mobile-reading #pageCount{line-height:1.1}
 #reader.andy-mobile-reading #coverBtn{
   min-height:38px;
   padding:4px 9px;
 }
 #reader.andy-mobile-reading #voiceNote{
   margin:2px 0!important;
   min-height:0!important;
 }
 /* Less opaque cream, but keep dark lettering for child-friendly contrast. */
 #reader.andy-mobile-reading .andy-mobile-words{
   background:rgba(255,244,223,.78)!important;
   backdrop-filter:blur(7px);
   -webkit-backdrop-filter:blur(7px);
 }
 #reader.andy-mobile-reading .andy-mobile-text-overlay{
   background:linear-gradient(to bottom,
     rgba(255,247,236,0) 0%,
     rgba(255,244,224,.06) 16%,
     rgba(253,242,223,.33) 40%,
     rgba(249,236,214,.61) 73%,
     rgba(247,232,205,.78) 100%)!important;
 }
}
@media(max-width:700px) and (max-height:650px){
 #reader.andy-mobile-reading .andy-mobile-page{
   height:var(--andy-fit-height, calc(100dvh - 280px))!important;
   min-height:0!important;
 }
}

/* V12 — real animated front cover on narrow/mobile portrait.
   Never affects desktop StPageFlip and never changes the child-friendly overlay. */
@media(max-width:700px){
 #reader.andy-mobile-reading .andy-mobile-page{perspective:1350px!important;overflow:hidden!important;}
 #reader.andy-mobile-reading .andy-mobile-cover-leaf{
   position:absolute;inset:0;z-index:20;pointer-events:none;
   transform-style:preserve-3d;transform-origin:0% 50%;
   box-shadow:inset -5px 0 8px #583f2b1a;
   will-change:transform;
 }
 #reader.andy-mobile-reading .andy-mobile-cover-face{
   position:absolute;inset:0;overflow:hidden;backface-visibility:hidden;
   -webkit-backface-visibility:hidden;background:#f3eadf;
 }
 #reader.andy-mobile-reading .andy-mobile-cover-face img{
   display:block;width:100%;height:100%;object-fit:contain;background:#f3eadf;
 }
 #reader.andy-mobile-reading .andy-mobile-cover-back{transform:rotateY(180deg)}
 #reader.andy-mobile-reading .andy-cover-opening{transform:rotateY(0deg)}
 #reader.andy-mobile-reading .andy-cover-opening.andy-cover-turn-active{
   transform:rotateY(-170deg);transition:transform 950ms cubic-bezier(.35,.06,.38,1);
 }
 #reader.andy-mobile-reading .andy-cover-closing{transform:rotateY(-170deg)}
 #reader.andy-mobile-reading .andy-cover-closing.andy-cover-turn-active{
   transform:rotateY(0deg);transition:transform 950ms cubic-bezier(.25,.62,.28,1);
 }
}
@media(prefers-reduced-motion:reduce){
 #reader.andy-mobile-reading .andy-mobile-cover-leaf{transition:none!important}
}
