@font-face{font-family:'LemonTuesday';src:url('/fonts/LemonTuesday.otf') format('opentype');font-weight:normal;font-style:normal;font-display:swap}
@font-face{font-family:'Mahuta';src:url('/fonts/Mahuta.ttf') format('truetype');font-weight:normal;font-style:normal;font-display:swap}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:Georgia,serif;background:#0c0b09;color:#e4dcc8;min-height:100vh}
a{color:inherit;text-decoration:none}
button{cursor:pointer;font-family:inherit}
code{font-size:.85em;background:#1e1c18;padding:.1em .3em;border-radius:3px}

/* ── Library & book pages ── */
.page{max-width:880px;margin:0 auto;padding:2.5rem 1.5rem}
.page--library{max-width:90vw}
.site-header{text-align:center;margin-bottom:3rem}
.page--library .site-header{position:sticky;top:0;z-index:10;background:#0c0b09;padding:.5rem 0 .75rem;margin-bottom:1.5rem}
.site-title{font-family:'Mahuta',Georgia,serif;font-size:2.2rem;font-weight:normal;letter-spacing:.06em;color:#f0e6cc}
.page--library .site-title{color:#cc2200;-webkit-text-stroke:2px #fff;paint-order:stroke fill}
.library-subtitle{font-family:Arial,Helvetica,sans-serif;font-size:1rem;color:#8a7a60;margin-top:.6rem;letter-spacing:.03em}
.subtitle{margin-top:.5rem;font-style:italic;color:#8a7a60;font-size:.95rem}
.subtitle--author{font-size:.82rem;color:#6a5a40;margin-top:.25rem}
.subtitle--narrator{font-size:.8rem;color:#6a5a40;margin-top:.2rem}
.book-description{margin-top:1.25rem;font-size:.9rem;color:#9a8e78;line-height:1.65;max-width:56ch;margin-left:auto;margin-right:auto}
.book-total-time{margin-top:.75rem;font-size:.8rem;color:#5a4a30;letter-spacing:.04em;font-family:monospace}
.back-link{display:inline-block;margin-bottom:1.2rem;color:#7a6a50;font-size:.88rem;transition:color .15s}
.back-link:hover{color:#e4dcc8}
.empty-state{color:#5a5040;font-style:italic;font-size:.95rem;padding:2rem 0}

/* Books grid */
.books-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:1.75rem}
.book-card{display:grid;grid-template:1fr/1fr;border:1px solid #1e1c18;border-radius:6px;overflow:hidden;transition:border-color .2s}
.book-card>*{grid-area:1/1}
.book-card:hover{border-color:#7a5c2e}
.book-cover{aspect-ratio:var(--cover-ratio,2/3);overflow:hidden;background:#151310}
@media(orientation:portrait){.books-grid{grid-template-columns:1fr}}

/* ── Mobile library: one card per screen ── */
@media(max-width:640px) and (orientation:portrait){
  html{scroll-snap-type:y mandatory}
  .page--library{padding:.85rem 1rem 0}
  .page--library .site-header{margin-bottom:.65rem}
  .page--library .site-title{font-size:1.5rem}
  .library-subtitle{font-size:.82rem;margin-top:.2rem}
  .books-grid{gap:.5rem}
  html{scroll-snap-type:y mandatory;scroll-padding-top:105px}
  .book-card{height:calc(100svh - 105px);scroll-snap-align:start;scroll-snap-stop:always}
  .page--library .book-cover{aspect-ratio:unset}
}
.book-cover img{width:100%;height:100%;object-fit:cover}
.book-cover-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:3.5rem;color:#3a3020}
.book-info{position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:1.25rem 1rem;background:linear-gradient(to top,rgba(0,0,0,.72) 0%,rgba(0,0,0,.04) 52%,rgba(0,0,0,.32) 100%)}
.book-title{font-family:'LemonTuesday',Georgia,serif;font-size:.9rem;font-weight:normal;color:#f0e6cc;line-height:1.3;text-shadow:0 1px 8px rgba(0,0,0,.95)}
.book-subtitle{font-size:.78rem;color:rgba(228,220,200,.8);font-style:italic;margin-top:.3rem;text-shadow:0 1px 6px rgba(0,0,0,.9)}
.book-author{font-size:.72rem;color:rgba(228,220,200,.55);margin-top:.4rem;text-shadow:0 1px 5px rgba(0,0,0,.9)}
.book-narrator{font-size:.68rem;color:rgba(228,220,200,.38);font-style:italic;margin-top:.15rem;text-shadow:0 1px 5px rgba(0,0,0,.9)}
.book-card .book-desc{display:none}

/* ── Chapter full-screen view ── */
.chapter-view{position:fixed;inset:0;z-index:200;background:#000}
#chapterCanvas{position:absolute;inset:0;display:block}
.chapter-view-vignette{position:absolute;inset:0;background:linear-gradient(to top,rgba(0,0,0,.88) 0%,rgba(0,0,0,.22) 45%,rgba(0,0,0,.52) 100%);pointer-events:none}
.chapter-view-ui{position:relative;z-index:1;display:flex;flex-direction:column;height:100svh;padding:1.5rem 2rem;animation:ui-fadein .4s ease}
.cv-top{flex-shrink:0}
.cv-close-btn{background:none;border:none;color:rgba(228,220,200,.5);font-size:.82rem;cursor:pointer;font-family:inherit;padding:0;transition:color .15s}
.cv-close-btn:hover{color:rgba(228,220,200,.9)}
.cv-meta{flex-shrink:0;display:flex;flex-direction:column;align-items:center;text-align:center;gap:.35rem;padding:.5rem 0 .85rem}
.cv-book-name{font-size:1.45rem;font-weight:normal;letter-spacing:.06em;color:#f0e6cc;text-shadow:0 2px 12px rgba(0,0,0,.95)}
.cv-book-subtitle{font-size:.95rem;color:rgba(180,150,100,.7);font-style:italic;text-shadow:0 1px 6px rgba(0,0,0,.8)}
.cv-chapter-name{font-size:1rem;font-weight:normal;color:rgba(228,220,200,.65);letter-spacing:.04em;text-shadow:0 1px 6px rgba(0,0,0,.8)}
.cv-playlist{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;margin:0 -2rem;padding:0 2rem;min-height:0}
.cv-chapter-item{display:flex;align-items:baseline;gap:.65rem;padding:.72rem 0;border-bottom:1px solid rgba(255,255,255,.07);cursor:pointer;color:rgba(228,220,200,.5);font-size:.88rem;transition:color .15s}
.cv-chapter-item:hover{color:rgba(228,220,200,.82)}
.cv-chapter-item.active{color:#f0e6cc}
.cv-chapter-item .cv-chapter-num{font-family:monospace;font-size:.74rem;color:#5a4a30;min-width:1.8rem;flex-shrink:0}
.cv-chapter-item.active .cv-chapter-num{color:#c8983c}
.cv-bottom{flex-shrink:0;display:flex;flex-direction:column;gap:.7rem}
.cv-progress-area{cursor:pointer;width:100%;max-width:460px;align-self:center}
.cv-track{height:3px;background:rgba(255,255,255,.12);border-radius:2px;transition:height .1s}
.cv-track:hover{height:4px}
.cv-fill{height:100%;background:#c8983c;border-radius:2px;width:0%;transition:width .2s linear}
.cv-times{display:flex;justify-content:space-between;margin-top:.4rem;font-size:.72rem;color:rgba(228,220,200,.4);font-family:monospace}
.cv-controls{display:flex;align-items:center;justify-content:center;gap:1.5rem}
.cv-btn{background:none;border:1px solid rgba(255,255,255,.18);color:rgba(228,220,200,.75);border-radius:6px;padding:.45rem .95rem;font-size:.82rem;cursor:pointer;font-family:inherit;transition:border-color .15s,color .15s}
.cv-btn:hover{border-color:#c8983c;color:#f0e6cc}
.cv-btn-play{width:3.4rem;height:3.4rem;border-radius:50%;padding:0;font-size:1.05rem;border-color:rgba(255,255,255,.28)}
.cv-chapter-nav{display:flex;justify-content:space-between;align-items:center}
.cv-nav-btn{background:none;border:1px solid rgba(255,255,255,.1);border-radius:5px;color:rgba(228,220,200,.5);font-size:.78rem;padding:.35rem .7rem;cursor:pointer;font-family:inherit;transition:border-color .15s,color .15s;max-width:45%}
.cv-nav-btn:hover{border-color:#7a5c2e;color:rgba(228,220,200,.9)}
.cv-nav-btn:disabled{opacity:0;pointer-events:none}
@media(max-width:500px){
  .chapter-view-ui{padding:1rem 1.1rem}
  .cv-book-name{font-size:1.2rem}
  .cv-chapter-name{font-size:.88rem}
  .cv-playlist{margin:0 -1.1rem;padding:0 1.1rem}
}

/* Book page inline player */
.book-player{background:rgba(8,7,5,.88);border:1px solid #252118;border-radius:8px;padding:.9rem 1.1rem;margin-bottom:1.25rem;backdrop-filter:blur(6px)}
.bp-info{display:flex;align-items:baseline;gap:.6rem;margin-bottom:.65rem;min-width:0}
.bp-num{font-family:monospace;font-size:.75rem;color:#5a4a30;flex-shrink:0}
.bp-title{font-size:.88rem;color:#e4dcc8;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bp-track-area{cursor:pointer;margin-bottom:.55rem}
.bp-track{height:3px;background:rgba(255,255,255,.1);border-radius:2px;transition:height .1s}
.bp-track:hover{height:4px}
.bp-fill{height:100%;background:#c8983c;border-radius:2px;width:0%;transition:width .2s linear}
.bp-times{display:flex;justify-content:space-between;margin-top:.3rem;font-size:.7rem;color:rgba(228,220,200,.35);font-family:monospace}
.bp-controls{display:flex;align-items:center;justify-content:center;gap:1rem}
.bp-btn{background:none;border:1px solid rgba(255,255,255,.15);color:rgba(228,220,200,.7);border-radius:5px;padding:.35rem .8rem;font-size:.78rem;cursor:pointer;font-family:inherit;transition:border-color .15s,color .15s}
.bp-btn:hover{border-color:#c8983c;color:#f0e6cc}
.bp-btn-play{width:2.8rem;height:2.8rem;border-radius:50%;padding:0;font-size:.95rem;border-color:rgba(255,255,255,.22)}
.chapter-row.playing{border-color:#7a5c2e !important;background:rgba(18,12,6,.6) !important}
.has-cover .chapter-row.playing{background:rgba(122,92,46,.2) !important}

/* Book page cover background */
.book-bg{position:fixed;inset:0;z-index:0;background-size:cover;background-position:center;transform:scale(1.04)}
.book-bg-vignette{position:absolute;inset:0;background:rgba(6,5,3,.82)}
.has-cover .page{position:relative;z-index:1}

/* Chapters list */
.chapters-list{display:flex;flex-direction:column;gap:.4rem}
.chapter-row{display:flex;align-items:center;gap:1rem;padding:.9rem 1.1rem;border:1px solid #1a1816;border-radius:6px;transition:border-color .2s,background .2s}
.has-cover .chapter-row{background:rgba(0,0,0,.3);border-color:rgba(255,255,255,.07)}
.chapter-row:hover{border-color:#7a5c2e;background:#13110d}
.has-cover .chapter-row:hover{background:rgba(18,12,6,.75)}
.chapter-num{font-family:monospace;font-size:.8rem;color:#5a4a30;min-width:1.8rem;padding-top:.15rem}
.chapter-body{flex:1;display:flex;flex-direction:column;gap:.25rem}
.chapter-title{font-size:.95rem}
.chapter-desc{font-size:.78rem;color:#6a5a40;line-height:1.45}
.chapter-stats{display:flex;flex-direction:column;align-items:flex-end;gap:.2rem;justify-content:center}
.cstat{font-size:.7rem;font-family:monospace;color:#4a3a28;white-space:nowrap}
.cstat-likes{color:#6a3a30}
.chapter-arrow{color:#5a4a30;font-size:.8rem;padding-top:.15rem;padding-left:.4rem}

/* Scroll arrow */
@keyframes scroll-bounce{from{transform:translateX(-50%) translateY(0)}to{transform:translateX(-50%) translateY(7px)}}
.scroll-arrow{position:fixed;bottom:1.5rem;left:50%;transform:translateX(-50%);font-size:1.6rem;color:rgba(228,220,200,.35);opacity:0;transition:opacity .35s ease;pointer-events:none;animation:scroll-bounce .9s ease-in-out infinite alternate}
.scroll-arrow.visible{opacity:1}

/* ── Player ── */
@keyframes ui-fadein{from{opacity:0}to{opacity:1}}
.player-body{background:#000;height:100svh;overflow:hidden}
.player-wrap{position:relative;width:100%;height:100svh}

.stage{position:absolute;inset:0;z-index:0}
#coverCanvas{position:absolute;inset:0;display:block}
.stage-vignette{position:absolute;inset:0;background:linear-gradient(to top,rgba(0,0,0,.88) 0%,rgba(0,0,0,.25) 45%,rgba(0,0,0,.55) 100%)}

.player-ui{position:relative;z-index:1;display:flex;flex-direction:column;height:100%;padding:1.5rem 2rem;animation:ui-fadein .4s ease}
.top-nav{flex-shrink:0}
.nav-link{font-size:.82rem;color:rgba(228,220,200,.5);transition:color .15s}
.nav-link:hover{color:rgba(228,220,200,.9)}

.player-body-inner{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;padding-bottom:3.5rem;gap:2rem}
.chapter-meta{text-align:center}
.book-name{font-size:2.2rem;font-weight:normal;letter-spacing:.06em;color:#f0e6cc;text-shadow:0 2px 12px rgba(0,0,0,.95)}
.chapter-name{font-size:1rem;font-weight:normal;color:rgba(228,220,200,.6);letter-spacing:.04em;margin-top:.65rem;text-transform:capitalize;text-shadow:0 1px 6px rgba(0,0,0,.8)}
.chapter-desc-player{font-size:.78rem;color:rgba(228,220,200,.45);margin-top:.3rem;line-height:1.5;max-width:42ch}
.player-stats{display:flex;align-items:center;gap:.5rem;margin-top:.75rem;justify-content:center}
.pstat-plays{font-size:.72rem;font-family:monospace;color:rgba(228,220,200,.3)}
.pstat-sep{font-size:.72rem;color:rgba(228,220,200,.2)}
.like-btn{background:none;border:none;font-size:1.2rem;color:rgba(228,220,200,.4);cursor:pointer;padding:.1rem .3rem;transition:color .15s,transform .15s;line-height:1}
.like-btn:hover{color:rgba(220,100,80,.7)}
.like-btn.liked{color:rgba(220,80,60,.85)}
.like-btn:active{transform:scale(1.3)}
.like-count{font-size:.75rem;font-family:monospace;color:rgba(228,220,200,.4);min-width:1ch}
.book-subtitle-player{font-size:.95rem;color:rgba(180,150,100,.7);margin-top:.4rem;font-style:italic}
.book-narrator-player{font-size:.72rem;color:rgba(180,150,100,.4);margin-top:.15rem}

/* Progress */
.progress-area{width:100%;max-width:460px;cursor:pointer}
.progress-track{height:3px;background:rgba(255,255,255,.12);border-radius:2px;position:relative}
.progress-track:hover{height:4px}
.progress-fill{height:100%;background:#c8983c;border-radius:2px;width:0%;transition:width .2s linear}
.time-row{display:flex;justify-content:space-between;margin-top:.4rem;font-size:.72rem;color:rgba(228,220,200,.4);font-family:monospace}

/* Buttons */
.controls{display:flex;align-items:center;justify-content:center;gap:1.5rem}
.btn{background:none;border:1px solid rgba(255,255,255,.18);color:rgba(228,220,200,.75);border-radius:6px;padding:.45rem .95rem;font-size:.82rem;transition:border-color .15s,color .15s}
.btn:hover{border-color:#c8983c;color:#f0e6cc}
.btn-play{width:3.4rem;height:3.4rem;border-radius:50%;padding:0;font-size:1.05rem;border-color:rgba(255,255,255,.28)}

.bottom-nav{flex-shrink:0;display:flex;justify-content:space-between;align-items:center}
.bottom-nav .nav-link{padding:.35rem .7rem;border:1px solid rgba(255,255,255,.1);border-radius:5px}
.bottom-nav .nav-link:hover{border-color:#7a5c2e}

@media(max-width:500px){
  .player-ui{padding:1rem 1.1rem}
  .chapter-name{font-size:1.3rem}
}
