*{box-sizing:border-box}body{margin:0;background:#f8f4e9;color:#263f36;font:1rem/1.5 system-ui,sans-serif}header,nav,footer{display:flex;align-items:center;justify-content:space-between;gap:.6rem}header{padding:1rem 6vw;border-bottom:1px solid #cbc8b6}header a{text-decoration:none;color:inherit;font: bold 1.4rem Georgia,serif}header span,small,.label{font-size:.83rem;letter-spacing:.09em}main{max-width:1120px;margin:auto;padding:2.4rem 5vw}.label{color:#716047;font-weight:bold;margin:1rem 0 .5rem}h1,h2,:is(#words,.copy-words),#storyTitle{font-family:Georgia,serif}h1{font-size:clamp(2.5rem,6vw,5rem);line-height:1.03;letter-spacing:-.055em;margin:.5rem 0 2rem}#cards{display:grid;grid-template-columns:repeat(2,1fr);gap:2rem}.card{text-align:left;background:white;border:1px solid #d0c7af;box-shadow:4px 5px 0 #ddd7c8;border-radius:.4rem 1rem 1rem .4rem;overflow:hidden;padding:0;color:inherit}.card img{width:100%;height:clamp(11rem,23vw,18rem);object-fit:cover;display:block}.card div{padding:1rem 1.4rem 1.4rem;border-left:8px solid #416958}.card:nth-child(2) div{border-color:#ab6137}h2{font-size:clamp(1.6rem,3vw,2.35rem);margin:.2rem 0}button{font:inherit;cursor:pointer}nav,footer{padding:.8rem 0}nav button,footer button{background:#fffdf7;color:#29463a;border:1px solid #acb4a4;border-radius:2rem;padding:.6rem 1rem;min-height:44px}#listen,#next{background:#325843;color:white}button:disabled{opacity:.4;cursor:default}#book{background:#fffdf4;display:grid;grid-template-columns:1fr 1fr;overflow:hidden;border:1px solid #c5bda6;border-radius:6px 16px 16px 6px;box-shadow:0 3px #ddd6bf,0 5px #a89c82,0 10px 22px #473a2120}:is(#paper,.copy-paper){align-self:center;padding:clamp(1rem,4vw,3.2rem)}:is(#words,.copy-words){white-space:pre-line;font-size:clamp(1.3rem,2.4vw,2rem);line-height:1.45;margin:.6rem 0}:is(#scene,.copy-scene){width:100%;height:100%;min-height:15rem;object-fit:contain;background:#f5edda}#info{margin:.5rem 0}audio{max-width:100%}#choose{padding:.6rem}#storyTitle{font-weight:bold}#book{touch-action:pan-y}@media(orientation:portrait){:is(#book,.leaf){grid-template-columns:1fr}:is(#scene,.copy-scene){grid-row:1;height:min(38svh,23rem);min-height:0}}@media(max-width:580px){main{padding:1rem}header span{display:none}#cards{grid-template-columns:1fr;gap:1.3rem}footer button{padding:.5rem .75rem}}@media(prefers-reduced-motion:reduce){.turn{animation:none}}[hidden]{display:none!important}
@media(orientation:landscape) and (max-height:540px){
 body:has(#reader:not([hidden])) header{display:none}
 main:has(#reader:not([hidden])){padding:.3rem 3vw}
 nav,footer{padding:.25rem 0}
 :is(#scene,.copy-scene){height:calc(100svh - 8rem);min-height:0}
 :is(#paper,.copy-paper){padding:.75rem 1.2rem}
 :is(#words,.copy-words){font-size:clamp(1.25rem,5.7vh,1.65rem);line-height:1.32}
}

#book{position:relative;isolation:isolate;user-select:none}
.page-motion,.leaf,.fold{position:absolute;inset:0;pointer-events:none}
.page-motion{z-index:1}
.leaf{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));background:#fffdf4;overflow:hidden}
@media(orientation:portrait){.leaf{grid-template-columns:1fr}}
.reading-now{background:#ffdf83;color:#263f36;border-radius:.18em;box-decoration-break:clone;-webkit-box-decoration-break:clone}
/* Square picture-book plates keep the same framing on the shelf and inside the book. */
#cards{grid-template-columns:repeat(auto-fit,minmax(min(100%,15rem),1fr));align-items:start}
.card img{width:100%;height:auto;aspect-ratio:1;object-fit:contain;background:#f5edda}
:is(#scene,.copy-scene){
  align-self:center;justify-self:center;width:min(100%,58svh);height:auto;min-height:0;
  aspect-ratio:1;object-fit:contain
}
@media(orientation:portrait){
  :is(#scene,.copy-scene){width:min(100%,46svh)}
}
@media(orientation:landscape) and (max-height:540px){
  :is(#scene,.copy-scene){width:min(100%,calc(100svh - 7rem))}
}
@media(max-width:580px){
  #cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
  .card{height:100%}
  .card div{padding:.65rem;border-left-width:4px}
  .card h2{font-size:clamp(1.15rem,5.3vw,1.55rem);line-height:1.12}
}

.binding {position:relative;isolation:isolate}
#book,.leaf {background:#fffaf0 url('papel.png') repeat}
#book {border:0;border-radius:0;box-shadow:none}
#folio,.copy-folio {
  position:absolute;right:.65rem;bottom:.6rem;padding:.15rem .5rem;
  background:#fffaf0ed;color:#455346;border-radius:.75rem;
  font:500 .85rem/1.4 system-ui,sans-serif;letter-spacing:0;pointer-events:none;
}
:is(#scene,.copy-scene) {
  max-width:calc(100% - 1.5rem);
  margin-block:.65rem;
  outline:1px solid #aa90682e;
  outline-offset:2px;
}
@media(orientation:portrait) {
  #book,.leaf {
    --page-light:linear-gradient(90deg,#d6c7ab 0%,#ecdfc6 1.6%,#faf2e2 4%,#fffaef 10%,#fffaf0 87%,#f5ecd9 100%);
  }
  :is(#scene,.copy-scene){margin-block:.85rem 0}
}
@media (orientation:landscape) and (max-height:540px) {
  main:has(#reader:not([hidden])) {padding:3px max(7px,1vw)}
  #reader {display:grid;grid-template-columns:1fr 1fr;align-items:center}
  #reader nav {display:contents}
  .binding {grid-area:1/1/2/3;margin-bottom:6px}
  :is(#scene,.copy-scene) {width:min(calc(100% - 14px),calc(100svh - 28px));margin-block:3px}
  :is(#paper,.copy-paper) {padding:48px clamp(12px,1.8vw,22px) 48px}
  .book-heading,#back,#reader footer {grid-area:1/1;z-index:2}
  .book-heading {align-self:start;margin:5px 48px 0 52px;font:600 .93rem/1.15 Georgia,serif;align-content:center;min-height:30px}
  #back {align-self:start;justify-self:start;margin:5px 0 0 8px}
  #reader footer {justify-self:start;align-self:end;display:flex;align-items:center;gap:0;margin:0 8px 8px;padding:0}
  #info,#choose {grid-column:1/-1}
  #info:empty {display:none}
}
main:fullscreen {width:100%;height:100%;max-width:none;overflow:auto;background:#f8f4e9}
#expand {display:grid;place-items:center;min-width:44px;min-height:44px;padding:0;flex-shrink:0}
@media (orientation:landscape) and (max-height:540px) {
  #expand {grid-area:1/1;align-self:start;justify-self:end;margin:5px 3px 0 0;z-index:2}
  #expand svg {grid-area:1/1;z-index:1}
  #expand::after {display:none}

}

.book-heading {display:flex;align-items:center;min-width:0;gap:2px}
#reader #aboutStory {font:normal 1.05rem Georgia,serif;color:#476152;background:transparent;border:0;flex:0 0 44px;min-width:44px;width:44px;min-height:44px;padding:0}
#aboutStory::before,#aboutStory::after {display:none}
#aboutDialog {width:min(25rem,92vw);max-height:88dvh;padding:1.5rem;border:1px solid #bcaa88;border-radius:12px;color:#294538;background:#fffbef;box-shadow:0 8px 35px #31241244;overflow:auto}
#aboutDialog h2 {margin:.4rem 0;font: bold 1.6rem Georgia,serif}
#aboutStory svg {display:block;margin:auto;transition:color .15s}
#aboutStory:hover svg,#aboutStory:focus-visible svg {color:#805630}
#aboutDialog form {margin-top:1rem}
#aboutDialog button {min-height:44px;padding:.5rem 1rem;border:0;border-radius:2rem;background:#365a46;color:white}
#aboutDialog::backdrop {background:#231e1675}
@media (orientation:landscape) and (max-height:540px) {
 .book-heading #storyTitle {overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 #reader #aboutStory {display:block}
}

/* Wide windows use one control row and reserve the rest of the height for the spread. */
@media (min-width:1000px) and (min-height:541px) and (orientation:landscape) {
  main {max-width:100rem;padding:2rem clamp(1.25rem,3vw,3rem)}
  #cards {grid-template-columns:repeat(auto-fill,minmax(15rem,1fr));gap:1.5rem}
  body:has(#reader:not([hidden])) header {display:none}
  main:has(#reader:not([hidden])) {
    --outer-y:clamp(8px,1.8vh,20px);
    max-width:unset;
    padding:var(--outer-y) clamp(14px,2.4vw,56px);
  }
  main:fullscreen:has(#reader:not([hidden])) {--outer-y:6px;padding-inline:clamp(8px,1vw,20px)}
  #reader {
    --spread-height:calc(100dvh - var(--outer-y) - var(--outer-y) - 74px);
    display:grid;grid-template-columns:auto minmax(0,1fr) auto auto auto auto;
    align-items:center;gap:0 clamp(5px,.7vw,12px)
  }
  #reader nav,#reader footer {display:contents}
  #back,.book-heading,#prev,#listen,#next,#expand {grid-row:1}
  #back {grid-column:1}
  .book-heading {grid-column:2;padding-left:.4rem;font-size:clamp(1.05rem,1.6vw,1.65rem)}
  #storyTitle {line-height:1.15}
  #prev {grid-column:3}
  #listen {grid-column:4}
  #next {grid-column:5}
  #audio {display:none}
  #expand {grid-column:6}
  .binding {grid-row:2;grid-column:1/-1;margin-top:8px}
  #book {min-height:var(--spread-height)}
  :is(#scene,.copy-scene) {
    width:min(calc(100% - 2rem),calc(var(--spread-height) - 1.5rem));
    margin-block:.75rem;
  }
  :is(#paper,.copy-paper) {
    width:100%;max-width:46rem;justify-self:center;
    padding:clamp(1.25rem,3vw,4rem)
  }
  :is(#words,.copy-words) {font-size:clamp(1.65rem,min(2.7vw,4.8vh),3.6rem);line-height:1.4}
  #folio,.copy-folio {font-size:clamp(.88rem,1.1vw,1.15rem)}
  #info,#choose {grid-column:1/-1}
  #info:empty {display:none}
}

@media (orientation:portrait) and (max-width:700px), (orientation:landscape) and (max-height:540px) {
  #reader button {display:grid;place-items:center;width:44px;height:44px;min-width:44px;min-height:44px;border:0;padding:0;background:transparent;color:#294538;font-size:0}
  #reader button::before,#reader button::after {content:"";grid-area:1/1}
  #reader button::before {width:30px;height:30px;border-radius:50%;background:rgba(255,252,240,.83);border:1px solid #70553c52;box-shadow:0 1px 3px #44352733}
  #reader button::after {width:16px;height:16px;background:currentColor;mask:var(--glyph) center/contain no-repeat}
  #reader #listen::before {background:rgba(44,78,59,.9)}
  #reader #listen {color:white}
  #reader button:focus-visible {outline:2px solid #325843;outline-offset:-3px}
  #back{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M3%205q5-2%209%201%204-3%209-1v14q-5-2-9%201-4-3-9-1z%20M12%206v14%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #prev{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22m15%205-7%207%207%207%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #next{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22m9%205%207%207-7%207%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #listen{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M8%205v14l11-7z%22%20fill%3D%22black%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #listen[data-playing]{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M8%205v14%20M16%205v14%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #next[data-last]{--glyph:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22m4%2012%205%205L20%206%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E")}
  #audio {display:none}
  body:has(#reader:not([hidden])) > header {display:none}
  main:has(#reader:not([hidden])) {
    padding:0;
  }
  #expand svg {grid-area:1/1;z-index:1}
  #reader #expand::after {display:none}
  #reader .favorite-control {font:1.1rem/1 Georgia,serif;background:radial-gradient(circle,#fffaf0 0 15px,transparent 16px)}
  #reader .favorite-control::before,#reader .favorite-control::after {display:none}
  .book-heading {pointer-events:none}
  .book-heading button {pointer-events:auto}
  #info:empty {display:none}
}
@media (orientation:portrait) and (max-width:700px) {
  #reader {display:grid;grid-template-columns:minmax(0,1fr);align-items:start}
  #reader nav {display:contents}
  .binding,#reader #back,#reader #expand,#reader .book-heading,#reader footer {grid-area:1/1}
  #reader #back,#reader #expand,#reader .book-heading,#reader footer {z-index:2}
  #back {justify-self:start;margin:4px 0 0 12px}
  #expand {justify-self:end;margin:4px 5px 0 0}
  .book-heading {justify-self:center;margin:4px 50px 0 56px;gap:0;max-width:calc(100% - 106px)}
  #storyTitle {font-size:.94rem;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #reader footer {align-self:end;justify-self:center;gap:2px;margin:0 0 8px;padding:0}
  #book {grid-template-rows:auto 1fr}
  :is(#scene,.copy-scene) {width:min(calc(100% - 1.5rem),39dvh);margin:48px 0 0}
  :is(#paper,.copy-paper) {padding:8px clamp(12px,3.4vw,20px) 54px;align-self:center}
  :is(#words,.copy-words) {font-size:clamp(1.4rem,6.1vw,1.85rem);line-height:1.38}
  #reader #info,#reader #choose {grid-column:1}
}
main.reading-expanded {position:fixed;inset:0;z-index:10;width:100%;height:100dvh;max-width:none;overflow:auto;background:#f8f4e9}
body:has(main.reading-expanded) {overflow:hidden}
#reader #audio {display:none}

/* The cover and page edges are painted behind the printing, within the existing sheet. */
#book,.leaf {
  --cover-width:clamp(3px,.55vw,7px);
  --page-edge:clamp(5px,.8vw,8px);
  --cover-opacity:.78;
  --gutter:linear-gradient(transparent,transparent);
  isolation:isolate;
  background-image:var(--gutter),radial-gradient(ellipse 85% 24px at 50% 100%,#8b5e3019,transparent 95%),url('papel.png');
}
:is(#book,.leaf)::before,:is(#book,.leaf)::after {
  content:"";position:absolute;pointer-events:none;z-index:-1;
}
:is(#book,.leaf)::before {
  inset:0 0 var(--page-edge);
  opacity:var(--cover-opacity);
  background:repeating-linear-gradient(3deg,transparent 0 2px,#f8dfbd55 2px 3px),
             repeating-linear-gradient(92deg,#61412e88 0 1px,transparent 1px 3px),#966d50;
  clip-path:polygon(0 0,100% 0,100% 100%,calc(100% - var(--cover-width)) 100%,
    calc(100% - var(--cover-width)) var(--cover-width),var(--cover-width) var(--cover-width),var(--cover-width) 100%,0 100%);
}
:is(#book,.leaf)::after {
  inset:auto 1px 0;height:var(--page-edge);border-radius:0 0 45% 12% / 0 0 2px 1px;
  background:repeating-linear-gradient(to bottom,#91785575 0 1px,#fff6de8c 1px 2px,#dccbae70 2px 3px);
}
@media (orientation:landscape) {
  #book,.leaf {
    --gutter:linear-gradient(90deg,transparent calc(50% - 9px),#99836519 calc(50% - 3px),
      #78604448 50%,#fffcf0a8 calc(50% + 2px),transparent calc(50% + 8px));
  }
}
@media (orientation:portrait) and (max-width:700px), (orientation:landscape) and (max-height:540px) {
  .binding {margin:0}
  #book {min-height:100dvh}
  #book,.leaf {--cover-width:3px;--cover-opacity:.52;--page-edge:9px}
  :is(#book,.leaf)::before {
    right:var(--page-edge);
    clip-path:polygon(0 0,100% 0,100% var(--cover-width),var(--cover-width) var(--cover-width),var(--cover-width) 100%,0 100%);
  }
  :is(#book,.leaf)::after {
    inset:0;height:auto;border-radius:0;
    background:none;
    /* Each inset follows the same sheet around the bottom-right corner. */
    box-shadow:
      inset -1px -1px 0 #927657a6, inset -3px -3px 0 #f9efd9cf,
      inset -4px -4px 0 #9a806391, inset -6px -6px 0 #fff5dfc4,
      inset -7px -7px 0 #a28a6e85, inset -9px -9px 0 #faf0dbab;
  }
  #reader #back {margin-left:max(8px,env(safe-area-inset-left))}
  #reader :is(#back,#expand,.book-heading) {margin-top:max(5px,env(safe-area-inset-top))}
  #reader #expand {margin-right:max(5px,env(safe-area-inset-right))}
  #reader footer {margin-bottom:max(8px,env(safe-area-inset-bottom))}
  #folio,.copy-folio {right:max(.65rem,env(safe-area-inset-right));bottom:max(.6rem,env(safe-area-inset-bottom))}
}﻿#account {display:flex;flex-wrap:wrap;gap:.6rem;margin:.75rem 0 1rem}
#account button,#familyDialog button,#familyDialog a {font:inherit;color:#34523f;border:1px solid #c9b99d;background:#fffbef;border-radius:1.25rem;padding:.55rem .9rem;cursor:pointer}
#familyDialog {box-sizing:border-box;width:min(26rem,92vw);max-height:88dvh;overflow:auto;border:1px solid #bcaa88;border-radius:14px;padding:1.3rem;color:#294538;background:#fffbef;box-shadow:0 8px 35px #31241244}
#familyDialog::backdrop {background:#231e1675}
#familyDialog h2 {font: bold 1.55rem Georgia,serif;margin:0 0 .75rem}
#familyDialog p {line-height:1.5}
#familyDialog button,#familyDialog a {display:inline-block;margin:.2rem .3rem .2rem 0}
#familyDialog button:first-of-type {background:#365a46;color:white}
#familyDialog input {box-sizing:border-box;display:block;width:100%;font:inherit;margin:.5rem 0;padding:.65rem;border-radius:.45rem;border:1px solid #a99b85}


#familyDialog button.google-login,#familyDialog button.google-login:first-of-type {
 display:inline-flex;align-items:center;gap:12px;min-height:44px;padding:0 16px;background:#fff;color:#1f1f1f;border:1px solid #747775;font:500 15px/1.3 system-ui,sans-serif;
}
.theme-toggle,#reader .theme-toggle {display:grid;place-items:center;min-width:44px;min-height:44px;padding:0;border:0;border-radius:50%;color:#344d42;background:radial-gradient(circle,#fffaf0 0 15px,#94887499 16px,transparent 17px);font:24px/1 system-ui,sans-serif}
#reader .theme-toggle::before,#reader .theme-toggle::after {display:none}
@media (min-width:1000px) and (min-height:541px) and (orientation:landscape){
 #reader {grid-template-columns:auto minmax(0,1fr) repeat(5,auto)}
 #reader .theme-toggle {grid-row:1;grid-column:6} #expand {grid-column:7}
}
html[data-theme=dark] {color-scheme:dark;background:#181b1b;color:#efe7d8}
[data-theme=dark] :is(body,main:fullscreen,main.reading-expanded){background:#181b1b;color:#efe7d8}
[data-theme=dark] header {border-color:#544d42}
[data-theme=dark] :is(.label,#folio,.copy-folio){color:#e2cea6}
[data-theme=dark] :is(.card,#familyDialog,#aboutDialog){background:#282a28;color:#f4ecdd;border-color:#655c4e;box-shadow:0 2px 7px #0005}
[data-theme=dark] :is(#book,.leaf){background-color:#282724;background-image:var(--gutter),linear-gradient(to top,#332d27,transparent 24px);color:#f7eddb}
[data-theme=dark] :is(#folio,.copy-folio){background:#302f2ae6}
[data-theme=dark] .reading-now{background:#766039;color:#fff7de}
[data-theme=dark] :is(#account button,#familyDialog button:not(.google-login),#familyDialog a,nav button,footer button,#aboutDialog button){background:#343b35;color:#f5eede;border-color:#857966}
[data-theme=dark] #familyDialog input{color:#f7eddb;background:#202321;border-color:#877b69}
[data-theme=dark] :is(.theme-toggle,#reader .theme-toggle,#reader .favorite-control){background:radial-gradient(circle,#39443b 0 16px,transparent 17px);color:#ffdfa2}
@media (orientation:portrait) and (max-width:700px),(orientation:landscape) and (max-height:540px){
 [data-theme=dark] #reader button:not(.theme-toggle):not(.favorite-control){background:transparent;color:#f5ecdb}
 [data-theme=dark] #reader button::before{background:#343b35eb;border-color:#8a7d65}
 [data-theme=dark] #reader #aboutStory{color:#324b3d}
}
