/* ============================================================
   STANDARD B · Ordered grid (local trial, 2026-11-16)
   One set of values; every page reads them. Real pixels (page zoom off).
   12 columns, 32 px gutter, 1152 px wide: shelf cover = 2 columns,
   collection pile = 3 columns, Continue reading = 8, Reading = 4.
   ============================================================ */
:root{
  --frame:min(1152px, calc(100vw / var(--z, 1) * 0.8)); /* at least 10% of the window on each side (the user, 2026-11-17) */
  --gut:32px;
  --col:calc((var(--frame) - 11 * var(--gut)) / 12);
  --shelf:calc(2 * var(--col) + var(--gut));
  --pile:calc(3 * var(--col) + 2 * var(--gut));
  --feat:220px; --mini:72px; --read:660px;
  --xs:8px; --s:16px; --m:32px; --l:64px; --xl:96px;
  --title-top:64px;
  --t1:44px; --t2:28px; --t3:22px; --tb:19px; --tl:14px;
}
@media (max-width:900px){:root{
  --frame:calc(100vw / var(--z, 1) - 40px); --gut:16px;
  --col:calc((var(--frame) - var(--gut)) / 2); --shelf:var(--col); --pile:var(--col);
  --feat:170px; --mini:58px; --read:100%;
  --xs:8px; --s:16px; --m:24px; --l:48px; --xl:64px;
  --title-top:32px;
  --t1:34px; --t2:25px; --t3:20px; --tb:18px; --tl:14px;
}}

/* ---------- 1. the page frame: same width, same left edge, same title height ---------- */
html body #app#app main.booksp, html body #app#app main.libp, html body #app#app main.youp,
html body #app#app main.profp, html body #app#app main.bookp{
  width:var(--frame)!important; max-width:none!important; margin-left:auto!important; margin-right:auto!important;
  padding-left:0!important; padding-right:0!important; padding-top:var(--title-top)!important; padding-bottom:var(--xl)!important;
  position:relative!important; box-sizing:border-box!important}
html body #app#app main.booksp > *, html body #app#app main.libp > *, html body #app#app main.youp > *,
html body #app#app main.profp > *, html body #app#app main.bookp > *{margin-left:0!important; margin-right:0!important; padding-left:0!important; padding-right:0!important; max-width:none!important; width:auto!important}
html body #app#app main .absec.abtitle, html body #app#app main .libhead, html body #app#app main .khead, html body #app#app main .chead{margin-top:0!important; padding-top:0!important}

/* back link sits in the space above the title and never pushes it down */
html body #app#app main .kback{position:absolute!important; top:calc(var(--title-top) - 30px)!important; left:0!important; margin:0!important; font-size:15px!important; line-height:20px!important}

/* ---------- 2. text sizes: one per role ---------- */
html body #app#app main:not(.readp):not(.bookp) h1:not(.rg){font-size:var(--t1)!important; line-height:1.1!important; margin:0!important}
html body #app#app main:not(.readp) h2:not(.chh){font-size:var(--t2)!important; line-height:1.15!important; margin:0!important; text-align:left!important}
html body #app#app main h3.libgh{font-size:var(--t3)!important; line-height:1.2!important; margin:0!important}
html body #app#app main.bookp h1{font-size:var(--t2)!important; line-height:1.15!important}
html body #app#app main .libsort button, html body #app#app main .libseg a, html body #app#app main .pf-btns a,
html body #app#app main .setgo, html body #app#app main .setr.out, html body #app#app main .btns a, html body #app#app main .btns button,
html body #app#app main .resume .go, html body #app#app main .kseg a{font-size:var(--tl)!important}
/* the library's Date · Theme · Recent switch: 30% larger than the other word buttons (the user, 2026-11-19). Its padding, the
   gap between words and the pull-left that lines its first word up with the column all scale with it. */
html body #app#app main .libsort.libsort.libsort{--k:1.3; gap:calc(16px * var(--k)) calc(22px * var(--k))!important; margin-left:calc(-14px * var(--k))!important}
html body #app#app main .libsort button{font-size:calc(var(--tl) * var(--k))!important; padding:calc(9px * var(--k)) calc(14px * var(--k)) calc(8px * var(--k))!important}

/* ---------- 3. gaps: XS 8 · S 16 · M 32 · L 64 · XL 96 ---------- */
/* title → page: L */
html body #app#app main .absec.abtitle, html body #app#app main .libhead, html body #app#app main .khead, html body #app#app main .chead{margin-bottom:var(--l)!important}
html body #app#app main.libp .libhead{margin-bottom:var(--s)!important}
html body #app#app main.libp .libtools{margin:0 0 var(--l)!important}
html body #app#app main.profp .chead + nav.kseg{margin-top:calc(var(--s) - var(--l))!important; margin-bottom:var(--l)!important}
html body #app#app main.setp .chead{margin-bottom:var(--s)!important}
html body #app#app main.setp .setnote{margin:0 0 var(--l)!important}
/* heading → content: M */
html body #app#app main .libhd, html body #app#app main .lsh, html body #app#app main .rh, html body #app#app main .row.cont > h2,
html body #app#app main .pf-rh{margin-bottom:var(--m)!important}
/* between sections: XL */
html body #app#app main .lshelf + .lshelf{margin-top:var(--xl)!important}
html body #app#app main .lshelf{margin:0!important}
html body #app#app main .lshelf + .lshelf{margin-top:var(--xl)!important}
/* eras: era → era L, era heading → grid S */
html body #app#app main .libgrp{margin:0!important; padding:0!important}
html body #app#app main .libgrp + .libgrp{margin-top:var(--l)!important}
html body #app#app main h3.libgh{margin-bottom:var(--s)!important; padding:0!important}

/* ---------- 4. grids on the 12 columns ---------- */
html body #app#app main .lbgrid{display:grid!important; grid-template-columns:repeat(6, var(--shelf))!important; column-gap:var(--gut)!important; row-gap:var(--m)!important; width:var(--frame)!important; margin:0!important; padding:0!important}
html body #app#app main .lbgrid > a.lb{width:var(--shelf)!important; margin:0!important}
html body #app#app main .lbgrid .lbcv{width:var(--shelf)!important; height:calc(var(--shelf) * 1.5)!important}
html body #app#app main .lbgrid .lbcv img{width:100%!important; height:100%!important; object-fit:cover}
/* All books: Reading lives on Home and in Your library, not here */
html body #app#app main.booksp .absec.abfirst{display:none!important}
html body #app#app main.booksp .libhd{margin-top:0!important}
html body #app#app main.booksp #library{margin-top:0!important; padding-top:0!important}
html body #app#app main.booksp #library .libhd h2{display:none!important}
html body #app#app main.booksp #library .libhd{position:absolute!important; top:var(--title-top)!important; right:0!important; left:auto!important; height:var(--t1)!important; display:flex!important; align-items:center!important; margin:0!important}

/* ---------- 5. covers: feature · shelf · mini ---------- */
html body #app#app main .lrow{display:flex!important; gap:var(--gut)!important; margin:0!important; padding:0!important}
html body #app#app main .lrow > .lbk{width:var(--shelf)!important; flex:0 0 var(--shelf)!important; margin:0!important}
html body #app#app main .lrow > .lbk img{width:var(--shelf)!important; height:calc(var(--shelf) * 1.5)!important; object-fit:cover}
html body #app#app main .pf-covers{display:flex!important; gap:var(--gut)!important; justify-content:flex-start!important; margin:0!important}
html body #app#app main .pf-book{width:var(--shelf)!important; flex:0 0 var(--shelf)!important}
html body #app#app main .pf-book img{width:var(--shelf)!important; height:calc(var(--shelf) * 1.5)!important}
html body #app#app main .row2.withcover img, html body #app#app main .row2 .rcv, html body #app#app main .row2.withcover > img{width:var(--mini)!important; height:calc(var(--mini) * 1.5)!important; flex:0 0 var(--mini)!important}
html body #app#app main .row2{margin-left:0!important; margin-right:0!important; max-width:calc(var(--read) + var(--mini) + var(--m))!important}
html body #app#app main .citems{max-width:calc(var(--read) + var(--mini) + var(--m))!important}

/* ---------- 6. Home ---------- */
html body #app#app main.home .hp1{min-height:0!important; padding-bottom:0!important}
html body #app#app main.home .hp1 > .below{width:var(--frame)!important; margin:var(--xl) auto 0!important; padding:0!important}
html body #app#app main.home .toprow.tr2{display:grid!important; grid-template-columns:calc(8 * var(--col) + 7 * var(--gut)) calc(4 * var(--col) + 3 * var(--gut))!important; column-gap:var(--gut)!important; width:var(--frame)!important; margin:0!important; padding:0!important}
html body #app#app main.home .toprow .row{margin:0!important; padding:0!important; min-width:0}
html body #app#app main.home .toprow .row.prog .rh{justify-content:flex-start!important; text-align:left!important}
html body #app#app main.home .resume{padding:0!important; gap:var(--m)!important}
/* height from the width (2:3), not its own calc: under the page zoom the two calcs came out 161 x 222 instead of 161 x 242, and the
   cover spilled out above and below its own outline (the user, 2026-11-20: "what's wrong with the book cover") */
html body #app#app main.home .resume > img{width:var(--shelf)!important; height:auto!important; aspect-ratio:2/3!important; overflow:hidden!important; flex:0 0 var(--shelf)!important}
html body #app#app main.home .rail{gap:var(--gut)!important; justify-content:flex-start!important; margin:0!important; padding-top:0!important; padding-left:0!important}
html body #app#app main.home .rail .bc{width:var(--shelf)!important; flex:0 0 var(--shelf)!important; margin:0!important}
html body #app#app main.home .rail .bc img{width:var(--shelf)!important; height:calc(var(--shelf) * 1.5)!important}
html body #app#app main.home .homelib{margin-top:var(--xl)!important; padding-bottom:var(--xl)!important}
html body #app#app main.home .homelib .ablib{width:var(--frame)!important; margin:0 auto!important; padding:0!important}
html body #app#app main.home .homelib .libhd{width:var(--frame)!important; margin:0 0 var(--m)!important; padding:0!important}
html body #app#app main.home .homelib .libgrp{width:var(--frame)!important}

/* ---------- 7. Collections: piles on 3 columns (4 to a row) ---------- */
html body #app#app main.youp .pls{display:grid!important; grid-template-columns:repeat(4, var(--pile))!important; column-gap:var(--gut)!important; row-gap:var(--l)!important; margin:0!important; padding:0!important}
html body #app#app main.youp .pls > .pl{width:var(--pile)!important; margin:0!important}
html body #app#app main.youp .pl-name{font-size:var(--tb)!important}

/* ---------- 8. Profile: same frame; the numbers as one line of text ---------- */
html body #app#app main.profp.pfp .pfa{width:var(--frame)!important; margin:0!important; padding:0!important}
html body #app#app main.profp .pfa-top{margin:0 0 var(--s)!important; padding:0!important}
html body #app#app main.profp .pf-embs{display:flex!important; flex-wrap:wrap!important; gap:0 var(--m)!important; margin:0 0 var(--l)!important; padding:0!important; justify-content:flex-start!important}
html body #app#app main.profp .pf-emb{display:inline-flex!important; flex-direction:row!important; align-items:baseline!important; gap:6px!important; width:auto!important; padding:0!important; margin:0!important; min-height:0!important}
html body #app#app main.profp .pf-emb .pf-ic{display:none!important}
html body #app#app main.profp .pf-emb .pf-fig, html body #app#app main.profp .pf-emb span{font-size:var(--tb)!important; line-height:1.4!important; margin:0!important}
html body #app#app main.profp .pf-reading{text-align:left!important; margin:0 0 var(--xl)!important; padding:0!important}
html body #app#app main.profp .pfa-bars{margin:0!important; padding:0!important}

/* ---------- 9. Settings and comments: the reading column ---------- */
html body #app#app main.setp .setl{max-width:var(--read)!important; width:100%!important}
html body #app#app main.setp .setnote{max-width:var(--read)!important}

/* ---------- 10. Book page: contents level with the top of the cover ---------- */
html body #app#app main.bookp .bklay{display:grid!important; grid-template-columns:calc(4 * var(--col) + 3 * var(--gut)) 1fr!important; column-gap:calc(2 * var(--gut))!important; align-items:start!important; margin:0!important; padding:0!important; min-height:0!important}
html body #app#app main.bookp .bk{margin:0!important; padding:0!important; position:static!important; top:auto!important}
html body #app#app main.bookp .bk img, html body #app#app main.bookp .bk .bcv{width:var(--feat)!important; height:auto!important}
html body #app#app main.bookp .bkmain{margin:0!important; padding:0!important; max-width:var(--read)!important}
html body #app#app main.bookp .tochead{margin:0 0 var(--m)!important}

/* ---------- phone ---------- */
@media (max-width:900px){
  html body #app#app main .lbgrid{grid-template-columns:repeat(2, var(--shelf))!important}
  html body #app#app main.youp .pls{grid-template-columns:repeat(2, var(--pile))!important}
  html body #app#app main.home .toprow.tr2{grid-template-columns:1fr!important; row-gap:var(--xl)!important}
  html body #app#app main.home .toprow .row.prog .rh{justify-content:flex-start!important}
  html body #app#app main.home .rail{overflow-x:auto!important; margin-right:-20px!important}
  html body #app#app main.bookp .bklay{grid-template-columns:1fr!important; row-gap:var(--xl)!important}
  html body #app#app main.booksp #library .libhd{position:static!important; margin:0 0 var(--l)!important}
  html body #app#app main.profp .pfa-top{flex-wrap:wrap!important}
}

/* sign-in stays centred; topics joins the frame; profile Reading left */
html body #app#app main:has(.af-demo) h1{margin:0 auto!important; text-align:center!important}
html body #app#app .onboard{width:var(--frame)!important; max-width:none!important; margin:0 auto!important; padding:var(--title-top) 0 var(--xl)!important; box-sizing:border-box!important}
html body #app#app .onboard h1{font-size:var(--t1)!important; margin:0 0 var(--l)!important}
html body #app#app main.profp .pf-reading{display:block!important}
html body #app#app main.profp .pf-reading .pf-rh{display:block!important}

/* Home: eras are no longer stretched to a full screen and centred (that added up to 300+ px of empty space) */
html body #app#app main.home .homelib .libgrp, html body #app#app main.home .homelib .libhd + .libgrp{min-height:0!important; display:block!important; padding:0!important}
html body #app#app main.home .homelib .libgrp + .libgrp{margin-top:var(--l)!important}
/* a cover never paints outside its own box (object-fit:cover with overflow:visible let it spill past its outline) */
html body #app img[src*="covers/"]{overflow:hidden!important}
/* Continue with Google (2026-11-20): only when the server has Google's keys (html.g-auth); above the email form, an "or" rule between */
.af-social{display:none}
html.g-auth .af-social{display:block;width:100%}
.af-google{all:unset;box-sizing:border-box;display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:48px;padding:0 18px;cursor:pointer;
  background:#fff;color:#1f1f1f;border:1px solid rgba(60,48,36,.28);border-radius:10px;font:500 16px/1 var(--ui,-apple-system,"Helvetica Neue",system-ui,sans-serif)}
.af-google:hover{background:#f7f7f7;border-color:rgba(60,48,36,.42)}
.af-google:disabled{opacity:.6;cursor:default}
.af-g{width:20px;height:20px;flex:none}
.af-or{display:flex;align-items:center;gap:12px;margin:18px 0 14px;font:400 14px var(--text);color:var(--ink3)}
.af-or::before,.af-or::after{content:"";flex:1;height:1px;background:var(--line)}
html.night .af-google{background:#1f1d1a;color:#efe8dc;border-color:rgba(239,232,220,.24)}
/* the sign-in box fits any phone: it scrolls inside when the screen is short, and the round "…" button steps aside while it is open (2026-11-20) */
html body #kmodal .signbox{max-height:calc(100dvh - 32px);overflow-y:auto;overscroll-behavior:contain}
/* one button per sign-in provider that is switched on (html.p-google, p-microsoft, p-github, p-reddit), stacked */
.af-sbtn{display:none!important}
html.p-google .af-sbtn.af-p-google,html.p-microsoft .af-sbtn.af-p-microsoft,html.p-github .af-sbtn.af-p-github,html.p-reddit .af-sbtn.af-p-reddit{display:flex!important}
.af-google span{white-space:nowrap}
@media (max-width:360px){.af-google{font-size:15px;gap:10px;padding:0 12px}}
html.g-auth .af-social{display:flex;flex-direction:column;gap:10px}
html.g-auth .af-social .af-or{margin:8px 0 4px}
.af-mono{color:#1f1f1f}html.night .af-mono{color:#efe8dc}
/* Settings: Sign out and Delete account on one line, on the list's edges, the same small capitals (the user, 2026-11-21) */
html body #app .setends{display:flex!important;justify-content:space-between!important;align-items:center!important;padding:18px 0 0!important;margin:0!important}
html body #app .setends>button{margin:0!important;padding:0!important;height:auto!important;line-height:1!important;align-self:center!important;
  font:400 13px/1 "Times New Roman",Times,Tinos,serif!important;letter-spacing:.1em!important;text-transform:uppercase!important;border:0!important;background:none!important}
html body #app .setends>.setr.out{color:var(--ink)!important;-webkit-text-fill-color:currentColor!important;-webkit-text-stroke:0!important}
html body #app .setends>.setdel{color:var(--ink3)!important}
@media (hover:hover){html body #app .setends>button:hover{color:var(--red)!important}}
/* Sign out in plain ink like Delete account: no engraved outline (the user, 2026-11-21) */
html body #app#app main .setends>.setr.out{-webkit-text-stroke:0!important;text-shadow:none!important;background:none!important;-webkit-background-clip:border-box!important;background-clip:border-box!important;-webkit-text-fill-color:var(--ink)!important;color:var(--ink)!important;box-shadow:none!important;filter:none!important}
html body #app#app main .setends>.setr.out::before,html body #app#app main .setends>.setr.out::after{content:none!important;display:none!important}
@media (hover:hover){html body #app#app main .setends>.setr.out:hover{-webkit-text-fill-color:var(--red)!important;color:var(--red)!important}}
/* sign-in box: square corners (the user, 2026-11-21) */
html body #kmodal .kmbox.signbox{border-radius:0!important}
/* phones, All books: the Date · Theme · Recent words closer together, and room before the first group */
@media (max-width:700px){
  html body #app#app main .libsort.libsort.libsort{--k:1!important;gap:6px 18px!important;margin:6px 0 34px -14px!important}
}
/* phones, a book's page: the pressed pattern and the paper grain show (they were at 14% and nearly invisible); no rule under the bar */
@media (max-width:900px){
  html.bk-tint body .bk-ground .rise-press.rise-press.stacked{-webkit-mask:linear-gradient(rgba(0,0,0,.7),rgba(0,0,0,.7))!important;mask:linear-gradient(rgba(0,0,0,.7),rgba(0,0,0,.7))!important}
  html.bk-tint .bk-ground::after{content:"";position:absolute;inset:0;background:url("img/paper-soft.svg?v=3") repeat;mix-blend-mode:multiply;opacity:.9;pointer-events:none}
  html.bk-tint body header.top,html.bk-tint body.scrolled header.top{border-bottom:0!important;box-shadow:none!important}
  html.bk-tint body.scrolled header.top::after{display:none!important}
  html body #app#app main.bookp{padding-top:28px!important}
}
/* Safari never drew the book page's ground (a fixed layer at z-index -1 under a coloured html); it sits at 0 now with the page above it */
html.bk-tint body .bk-ground{z-index:-1!important}
html.bk-tint body #app{position:relative}
/* phones: unnumbered contents entries (Introduction, Preface, Conclusion) start on the same left edge as the chapter titles (the user, 2026-11-21) */
@media (max-width:700px){html body #app#app#app#app main.bookp .chl li:has(.num:empty) > a .tt{grid-column:2!important}}
#selbar [data-rb="copytext"].copied{color:var(--red)!important}
/* notices: option B, a small square slip of the page's paper with a hairline (the user, 2026-11-21) */
html body #toast{background:var(--paper,#FCFBF9) url("img/paper-soft.svg?v=3")!important;color:var(--ink)!important;border:1px solid var(--line)!important;border-radius:0!important;
  padding:7px 16px!important;font:400 15.5px/1.2 "EB Garamond",Georgia,serif!important;box-shadow:0 8px 20px -14px rgba(30,20,10,.35)!important}
html body #toast :is(a,.undo){color:var(--red)!important;font:400 15px "EB Garamond",serif!important;letter-spacing:0;text-transform:none;margin-left:12px}
html.night body #toast{background:#1F1B16!important;color:#EFE8DC!important;border-color:rgba(239,232,220,.16)!important}
/* Settings → People (owners only) */
html body #app .setpeople{margin:28px 0 8px;padding-top:18px;border-top:1px solid var(--line)}
html body #app .setpeople h2{font:400 22px "EB Garamond",serif;margin:0 0 4px}
html body #app .setpn{margin:0 0 12px;font-size:15px;color:var(--ink3)}
html body #app .peoplel{list-style:none;margin:0;padding:0}
html body #app .peoplel li{display:flex;justify-content:space-between;align-items:center;padding:10px 0;border-bottom:1px solid var(--line);font-size:17px}
html body #app .peoplel select{font:400 15px "EB Garamond",serif;color:var(--ink);background:none;border:1px solid var(--line);padding:4px 8px}
/* sidebar socials: grow a little on hover, and all three (email too) turn red (the user, 2026-11-21) */
/* People: the role as three words, the chosen one red and underlined (like Most Popular / Your Quotes) */
html body #app .roleseg{display:inline-flex;gap:18px}
html body #app .roleseg button{all:unset;cursor:pointer;position:relative;padding:4px 0;font:400 16px "EB Garamond",serif;color:var(--ink3)}
html body #app .roleseg button:hover{color:var(--ink)}
html body #app .roleseg button.on{color:var(--red)}
html body #app .roleseg button.on::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:1.5px;background:var(--red)}
/* photo placing box */
html body #kmodal .avcrop{width:auto!important;max-width:360px;border-radius:0!important;text-align:center}
html body .avcrop h3{font:400 24px "EB Garamond",serif;margin:0 0 16px}
html body .avc-frame{position:relative;margin:0 auto;overflow:hidden;background:#000;cursor:grab;touch-action:none;user-select:none}
html body .avc-frame:active{cursor:grabbing}
html body .avc-frame img{position:absolute;max-width:none;pointer-events:none}
html body .avc-ring{position:absolute;inset:0;border-radius:50%;box-shadow:0 0 0 999px rgba(252,251,249,.72);pointer-events:none;outline:1px solid rgba(255,255,255,.6);outline-offset:-1px}
html body .avc-zoom{display:flex;align-items:center;gap:12px;margin:16px 0 4px;font:400 15px "EB Garamond",serif;color:var(--ink3)}
html body .avc-zoom input{flex:1;accent-color:var(--red)}
html body .avcrop footer{display:flex;gap:10px;margin-top:14px}
/* names: display name in bold, @username grey beside it (comments) or under it (profile) */
html body .cmw .cmh{color:var(--ink3);font-size:.92em;margin-left:6px}
html body #app .pf-handle{font:400 17px "EB Garamond",serif;color:var(--ink3);margin-top:2px}
/* email confirmation and forgotten password */
html body .setunv{display:block;font:400 14px "EB Garamond",serif;color:var(--red);margin-top:2px;text-align:right}
html body .setunv a{color:inherit;text-decoration:underline}
html body .af-forgot{margin:-4px 0 6px;text-align:right;font-size:14px}
html body .af-forgot a{color:var(--ink3)}html body .af-forgot a:hover{color:var(--red)}
/* sign-in by email link */
html body .af-magic{all:unset;cursor:pointer;display:block;width:100%;text-align:center;margin:12px 0 2px;font:400 15px "EB Garamond",serif;color:var(--ink2);text-decoration:underline;text-underline-offset:3px}
html body .af-magic:hover{color:var(--red)}
html body .af-sent{font:400 18px/1.5 "EB Garamond",serif;color:var(--ink);text-align:center;margin:10px 0 6px}
/* the email-link card under Google; when chosen, the form asks only for the email */
html.g-auth .af-social .af-mailcard{display:flex!important}
html body .af-mailcard.on{border-color:var(--red)!important;color:var(--red)!important}
html body .authf.magic :is(label:has(input[name="password"]),.af-forgot,.af-name,.af-swap){display:none!important}
