/* MIANU library: the same oak bookcase as the home page, a shelf of books per collection, and an open book per file. */

/* Literata (SIL Open Font License, fonts/LICENSE.txt), served from here because system serifs such as Iowan Old Style
   have no ơ, ư or their toned forms, so Vietnamese came out with a stray hook. Each subset loads only when a page uses it. */
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(fonts/literata-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(fonts/literata-latin-wght-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(fonts/literata-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(fonts/literata-latin-ext-wght-italic.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Literata; font-style: normal; font-weight: 200 900; font-display: swap; src: url(fonts/literata-vietnamese-wght-normal.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: Literata; font-style: italic; font-weight: 200 900; font-display: swap; src: url(fonts/literata-vietnamese-wght-italic.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }

:root {
  --oak-1: #dcbb93; --oak-2: #c8a075; --oak-3: #a98159; --oak-edge: #e8cfae;
  --wall: #2c2926; --wall-2: #24211f; --ink: #3a2a1b; --cream: #f7efe1; --muted: #cbbfae; --gold: #e7bd62;
  --paper: #fbf7ee; --paper-2: #f3ecdd; --text: #2b2117; --text-2: #6b5a48; --link: #a5552f;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Literata, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .75, .2, 1); --spring: cubic-bezier(.34, 1.4, .5, 1);
  --board-h: 58px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--oak-2); color: var(--cream); font: 400 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; }
.lib { display: grid; grid-template-rows: var(--board-h) minmax(0, 1fr); height: 100vh; height: 100dvh;
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / .05) 0 1px, transparent 1px 7px), repeating-linear-gradient(90deg, rgb(120 80 40 / .06) 0 2px, transparent 2px 19px), linear-gradient(180deg, var(--oak-1), var(--oak-2)); }

/* ---------- The oak top board ---------- */
.board { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 clamp(14px, 1.6vw, 24px);
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / .06) 0 1px, transparent 1px 9px), linear-gradient(180deg, #e6c8a3, var(--oak-1));
  box-shadow: inset 0 -2px 0 var(--oak-3), 0 6px 12px -6px rgb(60 35 15 / .45); color: var(--ink); }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; white-space: nowrap; }
.crumbs a { color: #5a4430; text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs b { font-weight: 700; letter-spacing: .32em; margin-right: -.32em; color: var(--ink); }
.crumbs span[aria-hidden] { color: rgb(58 42 27 / .4); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 0; border-radius: 99px; cursor: pointer; text-decoration: none;
  font-size: 13px; font-weight: 500; color: #5a4430; background: rgb(255 255 255 / .3); box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), 0 1px 2px rgb(60 35 15 / .2); transition: background .3s; }
.pill:hover { background: rgb(255 255 255 / .55); color: var(--ink); }

/* ---------- The shelf wall ---------- */
.wall { position: relative; min-height: 0; overflow: auto; margin: 10px clamp(8px, .8vw, 13px) 12px; border-radius: 6px;
  --row: clamp(230px, 34vh, 330px); --board: 14px;
  background: radial-gradient(120% 60% at 50% 0%, rgb(255 216 160 / .12), transparent 60%), linear-gradient(180deg, #1f1c1a, var(--wall) 30%, #34302b);
  box-shadow: inset 0 18px 26px -10px rgb(0 0 0 / .55), inset 12px 0 18px -14px rgb(0 0 0 / .6), inset -12px 0 18px -14px rgb(0 0 0 / .6); }
.wall__head { padding: clamp(18px, 2.2vw, 30px) clamp(20px, 2.4vw, 40px) 0; }
.wall__head h1 { margin: 0; font: 600 clamp(24px, 1.2vw + 14px, 36px)/1.1 var(--serif); color: var(--cream); }
.wall__head p { margin: 8px 0 0; color: var(--muted); max-width: 70ch; }
.wall__head p span { color: var(--gold); margin-left: 6px; font-size: 12.5px; letter-spacing: .04em; }
.wall__head a { color: var(--gold); }
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--row) * .62 + 30px), 1fr)); grid-auto-rows: var(--row); row-gap: var(--board);
  align-items: end; justify-items: center; padding: 18px clamp(16px, 2vw, 32px) var(--board);
  /* A shelf board under every row, and a strip light above each. */
  background:
    repeating-linear-gradient(180deg, transparent 0 calc(var(--row) - 4px), rgb(0 0 0 / .35) calc(var(--row) - 4px) var(--row), var(--oak-edge) var(--row) calc(var(--row) + 3px), var(--oak-1) calc(var(--row) + 3px) calc(var(--row) + 8px), var(--oak-3) calc(var(--row) + 8px) calc(var(--row) + var(--board))) 0 18px / 100% calc(var(--row) + var(--board)),
    repeating-linear-gradient(180deg, rgb(255 216 160 / .1) 0, transparent 90px, transparent calc(var(--row) + var(--board))) 0 18px / 100% calc(var(--row) + var(--board)); }

/* A book, face out: a cover with a binding edge, a small design, its number and title. */
.cover { --w: calc(var(--row) * .62 * var(--tall)); position: relative; display: block; width: var(--w); height: calc(var(--w) / .72); margin-bottom: 0; text-decoration: none; perspective: 900px; }
.cover__face { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 14% 12% 11% 16%; border-radius: 2px 5px 5px 2px; overflow: hidden; color: var(--ink);
  background-color: var(--c); transform-origin: 50% 100%; transition: transform .55s var(--spring), box-shadow .4s;
  box-shadow: inset 7px 0 0 rgb(0 0 0 / .16), inset 8px 0 0 rgb(255 255 255 / .12), 6px 8px 16px -6px rgb(0 0 0 / .65), 1px 0 0 rgb(255 255 255 / .2); }
.cover__face::after { /* the page block, peeking out on the right */ content: ''; position: absolute; top: 3px; bottom: 3px; right: 0; width: 3px; background: repeating-linear-gradient(180deg, #f3ead8 0 1px, #d8ccb4 1px 2px); }
.m0 .cover__face { background-image: radial-gradient(circle at 76% 24%, var(--a) 0 19%, transparent 19.5%); }
.m1 .cover__face { background-image: linear-gradient(180deg, transparent 31%, var(--a) 31% 33.5%, transparent 33.5% 36%, var(--a) 36% 38.5%, transparent 38.5%); }
.m2 .cover__face { background-image: radial-gradient(circle at 100% 0%, var(--a) 0 38%, transparent 38.5%); }
.m3 .cover__face { background-image: linear-gradient(225deg, var(--a) 0 24%, transparent 24.5%); }
.m4 .cover__face { background-image: linear-gradient(var(--a), var(--a)); background-size: 30% 30%; background-position: 84% 16%; background-repeat: no-repeat; }
.about .cover__face { background-image: linear-gradient(180deg, transparent 0 calc(100% - 10px), var(--a) calc(100% - 10px)); }
.cover__no { font: 600 clamp(26px, calc(var(--row) * .14), 46px)/1 var(--serif); color: var(--ink); opacity: .75; }
.cover__title { margin-top: auto; font: 650 clamp(13px, calc(var(--row) * .058), 17px)/1.2 var(--sans); color: var(--ink); letter-spacing: -.01em; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
/* Long titles set smaller, so they stay clear of the cover's design. */
.cover__title--long { font-size: clamp(11.5px, calc(var(--row) * .047), 14px); line-height: 1.22; }
.cover__meta { margin-top: 6px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); opacity: .7; }
.cover__peek { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; padding: 16% 12% 11% 16%; font-size: 12px; line-height: 1.4; color: #f7efe1;
  background: linear-gradient(180deg, rgb(20 16 12 / .2), rgb(20 16 12 / .92) 45%); opacity: 0; transform: translateY(8px); transition: opacity .35s, transform .45s var(--ease); }
.cover__peek em { font-style: normal; font-weight: 600; color: var(--gold); }
.cover:hover .cover__face, .cover:focus-visible .cover__face { transform: translateY(-8px) rotateX(6deg); box-shadow: inset 7px 0 0 rgb(0 0 0 / .16), inset 8px 0 0 rgb(255 255 255 / .12), 10px 18px 26px -8px rgb(0 0 0 / .7); }
.cover:hover .cover__peek, .cover:focus-visible .cover__peek { opacity: 1; transform: none; }
.cover:focus-visible { outline: 3px solid var(--gold); outline-offset: 6px; border-radius: 4px; }
.motion .cover { opacity: 0; transform: translateY(30px); }
.motion.in .cover { opacity: 1; transform: none; transition: opacity .6s ease, transform .9s var(--spring); transition-delay: calc(var(--i) * 45ms + 120ms); }

/* ---------- The reading desk ---------- */
.desk { position: relative; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); background: radial-gradient(90% 70% at 50% 40%, #3a332c, #24201c 70%, #1c1916); }
.toc { position: absolute; z-index: 6; top: 0; bottom: 0; left: 0; width: min(var(--toc-w, 340px), 86vw); overflow: auto; padding: 22px 18px 40px; color: #e8dcc6;
  background: linear-gradient(180deg, #2b2621, #221e1a); box-shadow: 12px 0 30px -12px rgb(0 0 0 / .7); transform: translateX(-102%); transition: transform .45s var(--ease); }
.toc.open { transform: none; }
.toc__book { margin: 0 0 14px; font: 600 17px/1.25 var(--serif); color: var(--cream); }
.toc__book span { display: block; font: 600 11px/1 var(--sans); letter-spacing: .18em; color: var(--gold); margin-bottom: 6px; }
.toc ol { list-style: none; margin: 0; padding: 0 0 0 10px; }
.toc > ol { padding-left: 0; }
.toc li { margin: 1px 0; }
.toc a { display: block; padding: 5px 8px; border-radius: 6px; color: #d9cbb3; text-decoration: none; font-size: 13px; line-height: 1.3; }
.toc a:hover { background: rgb(255 255 255 / .06); color: #fff; }
.toc a[aria-current] { background: rgb(231 189 98 / .16); color: var(--gold); font-weight: 600; }
.toc summary { cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; color: #efe3cc; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before { content: '▸'; display: inline-block; width: 14px; color: #a99a86; transition: transform .2s; }
.toc details[open] > summary::before { transform: rotate(90deg); }
.toc summary:hover { background: rgb(255 255 255 / .05); }
.toc__no { color: var(--gold); margin-right: 6px; font-variant-numeric: tabular-nums; }
@media (min-width: 1500px) {
  .desk { grid-template-columns: var(--toc-w, 300px) minmax(0, 1fr); }
  .toc { position: relative; transform: none; width: auto; box-shadow: inset -1px 0 0 rgb(255 255 255 / .05); }
  .toc-toggle { display: none; }
}

.reader { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 18px 12px 14px; }

/* Without the script, a file reads as one long page. */
.book { position: relative; width: min(760px, 100%); max-height: 100%; overflow: auto; border-radius: 4px; background: var(--paper); color: var(--text); box-shadow: 0 30px 60px -30px rgb(0 0 0 / .8); }
.flow { padding: 40px 48px; }
.titlepage { margin-bottom: 26px; }
.titlepage__book { margin: 0 0 18px; font: 600 10.5px/1.3 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--link); }
.titlepage h1 { margin: 0; font: 600 clamp(26px, 2.2vw, 36px)/1.12 var(--serif); color: var(--text); letter-spacing: -.01em; }
.titlepage__where { margin: 14px 0 0; font-size: 12.5px; color: var(--text-2); }
.titlepage__meta { margin: 6px 0 0; font-size: 12px; color: #9a8a74; }
.titlepage__mark { display: block; width: 46px; height: 3px; margin-top: 22px; background: var(--link); border-radius: 2px; }
.endpage { margin-top: 30px; padding-top: 18px; border-top: 1px solid #e3d7c1; font-size: 13px; color: var(--text-2); }
.endpage a { display: inline-block; margin-top: 6px; color: var(--link); font-weight: 600; text-decoration: none; }

/* ---------- Paged: two pages side by side, columns flowing across them ---------- */
.paged .book { --pw: 460px; --ph: 640px; --pad: 38px; overflow: visible; width: calc(var(--pw) * var(--per, 2)); height: var(--ph); max-height: none; perspective: 2800px; background: none; box-shadow: none; }
.paged .book::before { /* the paper of the open book, with the shadow of the spine */ content: ''; position: absolute; inset: 0; border-radius: 3px;
  background: linear-gradient(90deg, #e9e0cd 0, var(--paper) 3%, var(--paper) 44%, #efe6d4 49%, #d8ccb4 50%, #efe6d4 51%, var(--paper) 56%, var(--paper) 97%, #e9e0cd 100%);
  box-shadow: 0 2px 0 #e2d6bf, 0 4px 0 #d6c8ae, 0 6px 0 #cbbc9f, 0 36px 60px -24px rgb(0 0 0 / .85); }
.paged .book[data-per="1"]::before { background: linear-gradient(90deg, #efe6d4 0, var(--paper) 4%, var(--paper) 96%, #e9e0cd 100%); }
.paged .spread { position: absolute; inset: 0; overflow: hidden; }
.paged .flow { position: absolute; top: var(--pad); left: var(--pad); padding: 0; width: calc(var(--pw) * var(--per, 2) - 2 * var(--pad)); height: calc(var(--ph) - 2 * var(--pad));
  column-width: calc(var(--pw) - 2 * var(--pad)); column-gap: calc(2 * var(--pad)); column-fill: auto; transition: transform .5s var(--ease); will-change: transform; }
.paged .titlepage { break-after: column; height: 100%; display: flex; flex-direction: column; justify-content: center; margin: 0; }
.paged .endpage { break-before: column; margin: 0; border: 0; padding-top: 40%; text-align: center; }
.folio { display: none; }
.paged .folio { display: block; position: absolute; bottom: 12px; z-index: 3; font: 11px/1 var(--serif); color: #a99a86; pointer-events: none; }
.paged .folio--l { left: calc(var(--pad)); } .paged .folio--r { right: calc(var(--pad)); }
.paged .book[data-per="1"] .folio--l { display: none; }
.edge { display: none; }
.paged .edge { display: block; position: absolute; z-index: 4; top: 0; bottom: 0; width: 13%; border: 0; background: none; cursor: pointer; }
.paged .edge--prev { left: -4%; } .paged .edge--next { right: -4%; }
.paged .edge:hover { background: linear-gradient(90deg, rgb(255 255 255 / .06), transparent); }
.paged .edge--next:hover { background: linear-gradient(270deg, rgb(255 255 255 / .06), transparent); }
.paged .edge[disabled] { cursor: default; background: none; }
.no-paging .edge { display: none; }

/* The turning leaf: a page with both its faces, rotating round the spine. */
.leaf { position: absolute; top: 0; z-index: 5; width: var(--pw); height: var(--ph); transform-style: preserve-3d; transition: transform .8s cubic-bezier(.45, .05, .3, 1); pointer-events: none; }
.leaf--fwd { left: var(--pw); transform-origin: 0 50%; }
.leaf--back { left: 0; transform-origin: 100% 50%; }
.face, .cover-page { position: absolute; inset: 0; overflow: hidden; background: var(--paper); }
.face { backface-visibility: hidden; }
.face--back { transform: rotateY(180deg); }
.face::after { content: ''; position: absolute; inset: 0; pointer-events: none; transition: opacity .8s; }
.leaf--fwd .face--front::after { background: linear-gradient(90deg, rgb(0 0 0 / .14), transparent 12%); }
.leaf--fwd .face--back::after { background: linear-gradient(270deg, rgb(0 0 0 / .14), transparent 12%); }
.leaf--back .face--front::after { background: linear-gradient(270deg, rgb(0 0 0 / .14), transparent 12%); }
.leaf--back .face--back::after { background: linear-gradient(90deg, rgb(0 0 0 / .14), transparent 12%); }
.cover-page { z-index: 4; width: var(--pw); height: var(--ph); }
.face .flow, .cover-page .flow { transition: none; }

/* ---------- What is on the pages ---------- */
.prose, .ProseMirror { font: 400 var(--read-size, 15px)/1.62 var(--serif); color: var(--text); overflow-wrap: break-word; }
.ProseMirror { outline: none; white-space: pre-wrap; }
.prose > :first-child, .ProseMirror > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--sans); color: var(--text); letter-spacing: -.01em; line-height: 1.25; break-after: avoid; }
.prose h1 { font-size: 22px; } .prose h2 { font-size: 18px; margin: 1.4em 0 .5em; } .prose h3 { font-size: 15.5px; margin: 1.3em 0 .4em; } .prose h4 { font-size: 14px; margin: 1.2em 0 .3em; }
.prose p { margin: 0 0 .85em; }
.prose a { color: var(--link); text-decoration-color: rgb(165 85 47 / .4); text-underline-offset: 2px; }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.3em; }
.prose li { margin: .2em 0; }
.prose li p { margin: 0; }
.prose ul[data-type="taskList"] { list-style: none; padding-left: .2em; }
.prose ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: baseline; }
.prose blockquote { margin: 1em 0; padding: .2em 0 .2em 1em; border-left: 3px solid #d9b98f; color: var(--text-2); font-style: italic; }
.prose code { font: 12.5px/1.5 var(--mono); background: #efe6d4; padding: .1em .35em; border-radius: 4px; }
.prose pre { margin: 0 0 1em; padding: 12px 14px; background: #f1e9d8; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 var(--mono); }
.prose pre code { background: none; padding: 0; font: inherit; }
.prose hr { border: 0; border-top: 1px solid #e3d7c1; margin: 1.4em 0; }
.prose img { max-width: 100%; height: auto; border-radius: 4px; cursor: zoom-in; break-inside: avoid; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font: 12px/1.4 var(--sans); }
.prose th, .prose td { padding: 5px 6px; border-bottom: 1px solid #e6dbc6; text-align: left; vertical-align: top; overflow-wrap: break-word; hyphens: auto; }
.prose th { word-break: break-word; }
.prose th { color: var(--text); font-weight: 650; border-bottom: 2px solid #d9c9ac; }
.prose tr { break-inside: avoid; }
.prose .tableWrapper { overflow: hidden; }

.code { margin: 0; }
.code pre { margin: 0; padding: 12px 14px; background: #f1e9d8; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 var(--mono); color: var(--text); max-height: 70vh; overflow: auto; }
.paged .code { height: 100%; break-inside: avoid; border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px #e6dbc6; }
.paged .code pre { max-height: none; height: 100%; }
.plate { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.paged .plate { height: 100%; break-inside: avoid; }
.plate img { max-width: 100%; max-height: calc(100% - 30px); object-fit: contain; border-radius: 4px; cursor: zoom-in; box-shadow: 0 10px 24px -14px rgb(0 0 0 / .5); }
.plate figcaption { font-size: 12px; color: var(--text-2); }
.plate audio { width: 100%; }
.plate__disc { width: 46%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #f1e9d8 0 9%, #2b2117 9.5% 11%, #3a2f25 11.5% 60%, #2b2117 60.5% 62%, #3a2f25 62.5%); box-shadow: 0 14px 30px -14px rgb(0 0 0 / .6); }

/* ---------- Under the book: chapter links and where you are ---------- */
.turn { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; width: min(100%, 980px); font-size: 12.5px; color: #cbbfae; }
.turn__chapter { display: inline-flex; gap: 6px; align-items: center; max-width: 100%; color: #d9cbb3; text-decoration: none; }
.turn__chapter span:not([aria-hidden]) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn__chapter[rel="next"] { justify-self: end; }
.turn__chapter:hover { color: var(--gold); }
.turn__folio { font-variant-numeric: tabular-nums; color: #a99a86; }

/* ---------- The notebook: a writing pad beside the book, only for the signed-in owner (notes.js) ---------- */
.board__tools { flex: none; display: flex; align-items: center; gap: 8px; }
.notes-toggle[aria-expanded="true"] { background: rgb(255 255 255 / .62); color: var(--ink); }
.notes-toggle.has-note::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--link); }
.toc a.has-note::after { content: '✎'; float: right; margin-left: 8px; color: var(--gold); font-size: 11px; opacity: .85; }
.notes { position: absolute; z-index: 6; top: 0; bottom: 0; right: 0; width: min(var(--notes-w, 420px), 92vw); display: flex; flex-direction: column; gap: 12px; padding: 18px 16px 14px;
  color: #e8dcc6; background: linear-gradient(180deg, #2b2621, #221e1a); box-shadow: -12px 0 30px -12px rgb(0 0 0 / .7);
  transform: translateX(102%); visibility: hidden; transition: transform .45s var(--ease), visibility 0s .45s; }
.notes.open { transform: none; visibility: visible; transition: transform .45s var(--ease); }
.notes__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.notes__title { margin: 0; font: 600 17px/1.25 var(--serif); color: var(--cream); }
.notes__status { min-width: 0; font-size: 12px; color: #a99a86; text-align: right; }
.notes__status[data-state="error"] { color: #f2a37f; }
.notes__status a, .notes__status button, .notes__foot a, .notes__foot button { padding: 0; border: 0; background: none; color: #e8dcc6; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.notes__status a:hover, .notes__status button:hover, .notes__foot a:hover, .notes__foot button:hover { color: var(--gold); }
.notes__pad { position: relative; flex: 1; min-height: 0; display: flex; border-radius: 4px; background: var(--paper);
  box-shadow: 0 2px 0 #e2d6bf, 0 4px 0 #d6c8ae, 0 26px 44px -26px rgb(0 0 0 / .85); }
.notes__pad::before { /* the margin rule of a notepad */ content: ''; position: absolute; top: 0; bottom: 0; left: 36px; width: 1px; background: rgb(198 95 61 / .3); pointer-events: none; }
.notes__pad:focus-within { box-shadow: 0 2px 0 #e2d6bf, 0 4px 0 #d6c8ae, 0 26px 44px -26px rgb(0 0 0 / .85), 0 0 0 2px rgb(231 189 98 / .55); }
.notes__pad textarea { flex: 1; width: 100%; min-height: 0; margin: 0; padding: 16px 18px 16px 48px; border: 0; border-radius: 4px; outline: none; resize: none;
  font: 400 15px/26px var(--serif); color: var(--text); background-color: transparent;
  background-image: linear-gradient(transparent 25px, #e8ddc9 25px); background-size: 100% 26px; background-position: 0 16px; background-attachment: local; }
.notes__pad textarea::placeholder { color: #a99a86; font-style: italic; }
.notes__foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #a99a86; }
@media (min-width: 1200px) {
  /* Room enough to read and write side by side: the pad takes a column and the book makes room. */
  .desk.notes-open { grid-template-columns: minmax(0, 1fr) var(--notes-w, 400px); }
  .desk.notes-open .notes { position: relative; width: auto; transform: none; box-shadow: inset 1px 0 0 rgb(255 255 255 / .05); transition: none; }
}
@media (min-width: 1500px) {
  .desk.notes-open { grid-template-columns: var(--toc-w, 300px) minmax(0, 1fr) var(--notes-w, 400px); }
}

/* ---------- Adding a book by upload, only for the signed-in owner (upload.js) ---------- */
.cover.is-uploaded::after { content: 'Uploaded'; position: absolute; z-index: 3; top: 8px; right: 8px; padding: 4px 7px; border-radius: 99px; pointer-events: none;
  font: 600 9.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: #fff; background: rgb(30 22 14 / .55); }
.upload { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 6px; background: var(--paper); color: var(--text);
  box-shadow: 0 2px 0 #e2d6bf, 0 4px 0 #d6c8ae, 0 30px 60px -20px rgb(0 0 0 / .8); }
.upload::backdrop { background: rgb(20 16 12 / .6); }
.upload__card { display: flex; flex-direction: column; gap: 14px; padding: 26px 26px 22px; }
.upload__card h2 { margin: 0; font: 600 22px/1.2 var(--serif); }
.upload__hint, .upload__picked { margin: 0; font-size: 13.5px; color: var(--text-2); }
.upload__picked { color: var(--text); font-weight: 600; }
.upload__drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 2px dashed #d9c9ac; border-radius: 8px; background: #f6efe2; text-align: center; color: var(--text-2); font-size: 13px; transition: background .2s, border-color .2s; }
.upload__drop strong { font: 600 15px/1.3 var(--serif); color: var(--text); }
.upload__drop.is-over { border-color: var(--link); background: #f3e4d3; }
.upload__choose, .upload__close, .upload__mine button { padding: 7px 14px; border: 1px solid #d9c9ac; border-radius: 99px; background: #fff; color: var(--text); font-size: 13px; cursor: pointer; }
.upload__go { padding: 9px 20px; border: 0; border-radius: 99px; background: var(--link); color: #fff; font-weight: 600; cursor: pointer; }
.upload__go:disabled { opacity: .5; cursor: default; }
.upload__actions { display: flex; gap: 10px; align-items: center; }
.upload__status { margin: 0; font-size: 13px; color: var(--text-2); min-height: 1.2em; }
.upload__status:empty { display: none; }
.upload__status[data-state="error"] { color: #a5352f; }
.upload__status[data-state="ok"] { color: #2f5d50; }
.upload__mine { padding-top: 14px; border-top: 1px solid #e3d7c1; }
.upload__mine[hidden] { display: none; }
.upload__mine h3 { margin: 0 0 8px; font: 600 12px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.upload__mine ul { list-style: none; margin: 0; padding: 0; }
.upload__mine li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.upload__mine li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload__mine button { padding: 4px 11px; font-size: 12px; }
.upload__quota { margin: 8px 0 0; font-size: 12px; color: #9a8a74; }

/* ---------- Sign-in for the notebook ---------- */
.signin { min-height: 0; overflow: auto; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(90% 70% at 50% 40%, #3a332c, #24201c 70%, #1c1916); }
.signin__card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px 26px; border-radius: 6px; background: var(--paper); color: var(--text);
  box-shadow: 0 2px 0 #e2d6bf, 0 4px 0 #d6c8ae, 0 30px 60px -30px rgb(0 0 0 / .8); }
.signin__card h1 { margin: 0; font: 600 24px/1.2 var(--serif); }
.signin__card p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.signin__card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.signin__card input { padding: 10px 12px; border: 1px solid #d9c9ac; border-radius: 6px; background: #fff; color: var(--text); font: 400 15px/1.4 var(--sans); }
.signin__card input:focus { outline: 2px solid rgb(231 189 98 / .75); outline-offset: 1px; }
.signin__go { align-self: flex-start; padding: 9px 20px; border: 0; border-radius: 99px; background: var(--link); color: #fff; font-weight: 600; cursor: pointer; }
.signin__go:disabled { opacity: .6; cursor: progress; }
.signin__card .signin__error { color: #a5352f; }

@media (max-width: 760px) {
  :root { --board-h: 52px; }
  .crumbs > a:not(:first-child), .crumbs > span[aria-hidden]:not(:last-of-type) { display: none; }
  .flow { padding: 28px 22px; }
  .turn { grid-template-columns: 1fr 1fr; }
  .turn__folio { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* =====================================================================================================
   The library as an app on a phone (iPhone first). Content takes the screen; controls sit at the bottom,
   within reach of a thumb, and hide while reading. Safe areas keep clear of the Dynamic Island and the
   home bar. Nothing here applies on a computer.
   ===================================================================================================== */
.board__back, .board__title, .runhead, .dock, .typeset, .notes__grip, .cover__row { display: none; }
.offline body::after { content: 'Offline'; position: fixed; z-index: 30; top: calc(env(safe-area-inset-top) + 6px); left: 50%; transform: translateX(-50%);
  padding: 3px 10px; border-radius: 99px; background: #2c2926; color: #f7efe1; font: 600 11px/1.4 var(--sans); letter-spacing: .04em; pointer-events: none; }
.signin__keep { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }

/* The library's home: continue reading, then every shelf. */
.home .shelf-list { list-style: none; margin: 0; padding: 16px clamp(14px, 2.4vw, 40px) 24px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.shelf-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px; border-radius: 12px; color: var(--cream); text-decoration: none;
  background: rgb(255 255 255 / .05); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .07); transition: background .2s; -webkit-tap-highlight-color: transparent; }
.shelf-card:hover, .shelf-card:active { background: rgb(255 255 255 / .1); }
.shelf-card__title { font: 600 19px/1.25 var(--serif); }
.shelf-card__blurb { font-size: 13.5px; line-height: 1.45; color: #d9cbb3; }
.shelf-card__meta { margin-top: auto; padding-top: 6px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.continue { display: grid; gap: 4px; margin: 16px clamp(14px, 2.4vw, 40px) 0; padding: 16px 18px; border-radius: 14px; background: var(--paper); color: var(--text); text-decoration: none;
  box-shadow: 0 2px 0 #e2d6bf, 0 18px 30px -18px rgb(0 0 0 / .8); -webkit-tap-highlight-color: transparent; }
.continue[hidden] { display: none; }
.continue__label { font: 600 10.5px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--link); }
.continue__title { font: 600 19px/1.25 var(--serif); }
.continue__where { font-size: 12.5px; color: var(--text-2); }
.continue__bar { height: 4px; margin-top: 8px; border-radius: 2px; background: #e8ddc9; overflow: hidden; }
.continue__bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--link); }
.home__foot { margin: 0; padding: 0 clamp(14px, 2.4vw, 40px) calc(24px + env(safe-area-inset-bottom)); font-size: 12.5px; }
.home__foot a { color: var(--muted); }

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  :root { --board-h: 48px; }
  html, body { -webkit-text-size-adjust: 100%; }
  .lib { grid-template-rows: calc(var(--board-h) + env(safe-area-inset-top)) minmax(0, 1fr); }

  /* The top bar: back, and where you are. Nothing else competes for the top of a tall phone. */
  .board { height: calc(var(--board-h) + env(safe-area-inset-top)); gap: 4px; padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left)); }
  .board .crumbs { display: none; }
  .board__back { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; color: var(--ink); text-decoration: none; font: 300 34px/1 var(--sans); -webkit-tap-highlight-color: transparent; }
  .board__back:active { background: rgb(255 255 255 / .35); }
  .board__title { display: block; flex: 1; min-width: 0; font: 600 16px/1.2 var(--sans); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .is-home .board__title { padding-left: 12px; }
  .is-home .board__tools, .is-shelf .board__tools { display: none; }

  /* Shelves and the home scroll as plain lists. */
  .wall { margin: 0; border-radius: 0; box-shadow: none; padding-bottom: env(safe-area-inset-bottom); -webkit-overflow-scrolling: touch; }
  .wall__head { padding: 18px 18px 2px; }
  .wall__head h1 { font-size: 27px; }
  .wall__head p { font-size: 13.5px; }
  .home .shelf-list { grid-template-columns: 1fr; padding: 14px; gap: 10px; }
  .continue { margin: 14px 14px 0; }

  .shelves { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 14px 28px; background: none; }
  .cover { display: flex; gap: 14px; align-items: flex-start; width: auto; height: auto; padding: 12px; border-radius: 12px; perspective: none;
    background: rgb(255 255 255 / .05); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06); -webkit-tap-highlight-color: transparent; }
  .cover:active { background: rgb(255 255 255 / .1); }
  .cover__face { position: relative; inset: auto; flex: none; width: 52px; height: 72px; padding: 8px 6px 6px 10px; }
  .cover__face .cover__title, .cover__face .cover__meta, .cover__peek { display: none; }
  .cover__no { font-size: 21px; }
  .cover:hover .cover__face, .cover:focus-visible .cover__face { transform: none; }
  .cover__row { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 2px 0 0; }
  .cover__rtitle { font: 650 15.5px/1.3 var(--sans); color: var(--cream); overflow-wrap: anywhere; }
  .cover__rmeta { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .cover__rsum { font-size: 13px; line-height: 1.45; color: #d9cbb3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .cover__progress { font-size: 12px; color: var(--gold); }
  .cover__progress[hidden] { display: none; }
  .cover.is-uploaded::after { top: 10px; right: 10px; }
  .motion .cover { transform: translateY(12px); }

  /* ---------- Reading: the page is the screen ---------- */
  body.is-reader { background: var(--paper); overscroll-behavior: none; }
  .is-reader .lib { display: block; background: var(--paper); }
  .is-reader .board, .is-reader .dock { position: fixed; z-index: 8; left: 0; right: 0;
    background: color-mix(in srgb, var(--paper) 86%, transparent); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
    transition: transform .32s var(--ease); }
  .is-reader .board { top: 0; box-shadow: 0 1px 0 rgb(58 42 27 / .1); }
  .is-reader .board__back, .is-reader .board__title { color: var(--text); }
  .is-reader .board__tools { display: none; }
  .is-reader .desk { position: fixed; inset: 0; display: block; background: var(--paper); }
  .is-reader .reader { position: absolute; inset: 0; display: block; padding: 0; }
  .is-reader .turn, .is-reader .paged .edge { display: none; }
  .is-reader .paged .book { touch-action: pinch-zoom; -webkit-tap-highlight-color: transparent; }
  .is-reader .paged .book::before { background: var(--paper); box-shadow: none; border-radius: 0; }
  .is-reader .paged .book[data-per="2"]::before { background: linear-gradient(90deg, var(--paper) 49.7%, rgb(58 42 27 / .1) 50%, var(--paper) 50.3%); }
  .is-reader .paged .flow { top: calc(env(safe-area-inset-top) + 30px); height: calc(var(--ph) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 56px); }
  .is-reader .paged .titlepage { break-after: auto; height: auto; display: block; margin: 2px 0 22px; }
  .is-reader .titlepage h1 { font-size: 25px; }
  .is-reader .titlepage__book { margin-bottom: 10px; }
  .is-reader .titlepage__mark { margin-top: 14px; }
  .is-reader .paged .endpage { padding-top: 30%; }
  .is-reader .code pre { white-space: pre-wrap; font-size: 12.5px; }
  .is-reader .runhead { display: block; position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + 9px); left: var(--pad); right: var(--pad);
    text-align: center; font: 500 11px/1.2 var(--sans); letter-spacing: .04em; color: var(--text-2); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
  .is-reader .paged .folio { bottom: calc(env(safe-area-inset-bottom) + 6px); font: 500 11px/1 var(--sans); letter-spacing: .04em; color: var(--text-2); opacity: .75; }
  .is-reader .paged .folio--l { display: none; }
  .is-reader .paged .folio--r { left: 0; right: 0; text-align: center; }

  /* The dock: contents, where you are in the page, notes, text. One row, within reach of a thumb. */
  .is-reader .dock { display: flex; align-items: center; gap: 4px; bottom: 0;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 4px) max(8px, env(safe-area-inset-left)); box-shadow: 0 -1px 0 rgb(58 42 27 / .1); }
  .dock__btn { position: relative; flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
    background: none; color: var(--text); font: 600 18px/1 var(--serif); -webkit-tap-highlight-color: transparent; }
  .dock__btn:active, .dock__btn[aria-expanded="true"] { background: rgb(58 42 27 / .1); }
  .dock__btn.has-note::after { content: ''; position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--link); }
  .dock__scrub { flex: 1; min-width: 0; height: 32px; margin: 0 6px; accent-color: var(--link); }
  .dock__folio { flex: none; min-width: 44px; text-align: center; font: 500 12px/1 var(--sans); color: var(--text-2); font-variant-numeric: tabular-nums; }
  .chrome-hidden .is-reader .board { transform: translateY(-100%); }
  .chrome-hidden .is-reader .dock { transform: translateY(100%); }

  .is-reader .typeset { position: fixed; z-index: 9; right: max(10px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + 66px); display: grid; gap: 10px;
    width: min(300px, calc(100vw - 20px)); padding: 12px; border-radius: 16px; background: var(--paper); box-shadow: 0 12px 30px rgb(0 0 0 / .25), 0 0 0 1px rgb(58 42 27 / .1); }
  .is-reader .typeset[hidden] { display: none; }
  .typeset__row { display: flex; align-items: center; gap: 6px; }
  .typeset__row button { flex: 1; height: 42px; border: 0; border-radius: 10px; background: var(--paper-2); color: var(--text); font: 600 15px/1 var(--sans); -webkit-tap-highlight-color: transparent; }
  .typeset__row button[aria-pressed="true"] { background: var(--text); color: var(--paper); }
  .typeset__size { flex: 1.2; text-align: center; font: 500 13px/1 var(--sans); color: var(--text-2); }

  /* Contents and notes come up from the bottom, as sheets. */
  .is-reader .toc { z-index: 9; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: min(78dvh, 680px); border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(env(safe-area-inset-bottom) + 24px); transform: translateY(104%); box-shadow: 0 -12px 30px -10px rgb(0 0 0 / .5); }
  .is-reader .toc.open { transform: none; }
  .is-reader .toc a { padding: 9px 8px; font-size: 14.5px; }
  .is-reader .toc summary { padding: 9px 8px; font-size: 14px; }

  .is-reader .notes { z-index: 9; position: fixed; top: auto; left: 0; right: 0; bottom: var(--kb, 0px); width: auto; height: var(--sheet, 50dvh); gap: 8px; border-radius: 16px 16px 0 0;
    padding: 0 max(14px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 8px) max(14px, env(safe-area-inset-left)); transform: translateY(104%); box-shadow: 0 -12px 30px -10px rgb(0 0 0 / .55); }
  .kb-open .is-reader .notes { padding-bottom: 8px; }
  .kb-open .is-reader .notes__foot { display: none; }
  .is-reader .notes.open { transform: none; }
  .notes__grip { display: block; flex: none; height: 24px; margin: 0 -14px; touch-action: none; cursor: grab; }
  .notes__grip::before { content: ''; display: block; width: 40px; height: 5px; margin: 9px auto 0; border-radius: 3px; background: rgb(255 255 255 / .3); }
  .is-reader .notes__pad textarea { font-size: 16px; line-height: 26px; padding: 14px 14px 14px 46px; }
  .is-reader .desk.notes-open[data-sheet="half"] .reader { bottom: calc(var(--sheet, 50dvh) + var(--kb, 0px)); }
  /* The page above a half-open notes sheet scrolls, so the question stays within reach while you write. */
  .is-reader .reader.scrolling .book { position: absolute; inset: 0; width: 100%; height: auto; max-height: none; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 0; box-shadow: none; background: var(--paper); -webkit-overflow-scrolling: touch; }
  .is-reader .reader.scrolling .flow { padding: calc(env(safe-area-inset-top) + var(--board-h) + 14px) 20px 28px; }
  .is-reader .reader.scrolling .titlepage { margin-bottom: 16px; }
  .is-reader .reader.scrolling .runhead, .is-reader .reader.scrolling .folio, .is-reader .reader.scrolling .endpage { display: none; }

  /* Night: the page colour for reading in the dark, chosen in Aa or following the phone. */
  :root[data-theme="night"] { --paper: #1d1a17; --paper-2: #2b2723; --text: #e6dccb; --text-2: #ab9e88; --link: #e3a57c; }
  :root[data-theme="night"] .prose code { background: #2e2924; }
  :root[data-theme="night"] .prose pre, :root[data-theme="night"] .code pre { background: #262220; color: var(--text); }
  :root[data-theme="night"] .prose th, :root[data-theme="night"] .prose td, :root[data-theme="night"] .endpage { border-color: #3a342e; }
  :root[data-theme="night"] .prose blockquote { border-color: #6b5a48; }
  :root[data-theme="night"] .titlepage__meta { color: var(--text-2); }
  :root[data-theme="night"] .notes__pad textarea { background-image: linear-gradient(transparent 25px, #34302b 25px); }
  :root[data-theme="night"] .continue__bar { background: #34302b; }
}
@media (prefers-color-scheme: dark) and (max-width: 760px), (prefers-color-scheme: dark) and (max-height: 500px) and (pointer: coarse) {
  :root[data-theme="auto"] { --paper: #1d1a17; --paper-2: #2b2723; --text: #e6dccb; --text-2: #ab9e88; --link: #e3a57c; }
  :root[data-theme="auto"] .prose code { background: #2e2924; }
  :root[data-theme="auto"] .prose pre, :root[data-theme="auto"] .code pre { background: #262220; color: var(--text); }
  :root[data-theme="auto"] .prose th, :root[data-theme="auto"] .prose td, :root[data-theme="auto"] .endpage { border-color: #3a342e; }
  :root[data-theme="auto"] .prose blockquote { border-color: #6b5a48; }
  :root[data-theme="auto"] .titlepage__meta { color: var(--text-2); }
  :root[data-theme="auto"] .notes__pad textarea { background-image: linear-gradient(transparent 25px, #34302b 25px); }
  :root[data-theme="auto"] .notes__doc { --rule-c: #3d3731; }
  :root[data-theme="auto"] .continue__bar { background: #34302b; }
}

/* =====================================================================================================
   Learning: resizable panels, smooth page turns, formatted notes, highlights, words and review.
   ===================================================================================================== */

/* Panels: drag an edge to make them wider or narrower. */
.resizer { position: absolute; z-index: 7; top: 0; bottom: 0; width: 10px; cursor: col-resize; touch-action: none; }
.resizer--right-edge { right: 0; } /* inside the contents, which scroll and would clip anything outside */
.resizer--left-edge { left: -5px; }
.resizer::after { content: ''; position: absolute; top: 50%; left: 4px; width: 2px; height: 38px; margin-top: -19px; border-radius: 2px; background: rgb(255 255 255 / .14); transition: background .2s, height .2s; }
.resizer:hover::after, .resizer:focus-visible::after, .is-resizing .resizer::after { height: 64px; margin-top: -32px; background: var(--gold); }
.resizer:focus-visible { outline: none; }
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none !important; }
.toc, .notes { overflow: visible; }
.toc { overflow-y: auto; }

/* Page turns: the copies wait out of sight, ready, and are never laid out again during a turn. */
.is-idle { visibility: hidden; }
.face, .cover-page { contain: strict; }
.face .flow, .cover-page .flow { will-change: auto; }

/* ---------- The notes panel: tabs, a formatting toolbar and the page you write on ---------- */
.notes__tabs { display: flex; gap: 4px; }
.notes__tab { padding: 6px 12px; border: 0; border-radius: 99px; background: none; color: #b8aa94; font: 600 13px/1 var(--sans); cursor: pointer; }
.notes__tab[aria-selected="true"] { background: rgb(255 255 255 / .1); color: var(--cream); }
.notes__tab:hover { color: var(--cream); }
.notes__write, .notes__words { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.notes__write[hidden], .notes__words[hidden], .notes__status[hidden] { display: none; }
.notes__tools { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-radius: 8px; background: rgb(255 255 255 / .05); }
.notes__tools[hidden] { display: none; }
.tool { min-width: 30px; height: 30px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: #e8dcc6; font: 600 13px/1 var(--sans); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tool:hover { background: rgb(255 255 255 / .1); }
.tool[aria-pressed="true"] { background: var(--cream); color: var(--ink); }
.tool--b { font-weight: 800; } .tool--i { font-style: italic; font-family: var(--serif); } .tool--u { text-decoration: underline; } .tool--s { text-decoration: line-through; }
.tool--mark { background: linear-gradient(transparent 58%, rgb(255 210 80 / .85) 58%); }
.tool--mark[aria-pressed="true"] { background: rgb(255 210 80); color: var(--ink); }

.notes__pad.is-rich { display: block; overflow-y: auto; }
.notes__pad.is-rich::before { display: none; }
/* Ruled like a notepad: a dashed line under every line of writing. Everything in the note keeps to rows of --row,
   so the writing stays on the lines however it is formatted. A rule is the bottom-left quarter of a conic gradient:
   --dash wide in every tile of twice that, 1px tall at the bottom of each row, lifted to sit just under the letters. */
.notes__doc { --row: 26px; --dash: 4px; --rule-c: #dccdb2; --rule-lift: 5px;
  min-height: 100%; padding: 18px 20px 40px; outline: none; color: var(--text); font: 400 15.5px/var(--row) var(--serif); overflow-wrap: break-word; white-space: pre-wrap;
  background-image: conic-gradient(from 90deg at var(--dash) calc(100% - 1px), transparent 0 25%, var(--rule-c) 0 50%, transparent 0);
  background-size: calc(var(--dash) * 2) var(--row); background-origin: content-box; background-position: 0 calc(var(--rule-lift) * -1); }
.notes__doc > :first-child { margin-top: 0; }
.notes__doc p { margin: 0; }
.notes__doc h2 { margin: var(--row) 0 0; font: 650 19px/var(--row) var(--sans); color: var(--text); letter-spacing: -.01em; }
.notes__doc h3 { margin: var(--row) 0 0; font: 650 15.5px/var(--row) var(--sans); color: var(--link); }
.notes__doc h2 + h3 { margin-top: 0; }
.notes__doc mark { background: linear-gradient(transparent 12%, rgb(255 214 77 / .65) 12%); color: inherit; padding: 0 .1em; border-radius: 2px; }
.notes__doc strong { color: var(--text); }
.notes__doc a { color: var(--link); }
.notes__doc ul, .notes__doc ol { margin: 0; padding-left: 1.4em; }
.notes__doc li > p { margin: 0; }
.notes__doc ul[data-type="taskList"] { list-style: none; padding-left: .1em; }
.notes__doc ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; }
.notes__doc ul[data-type="taskList"] li > label { flex: none; display: flex; align-items: center; height: var(--row); }
.notes__doc ul[data-type="taskList"] li > label input { width: 15px; height: 15px; accent-color: var(--link); }
.notes__doc ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.notes__doc ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--text-2); text-decoration: line-through; text-decoration-color: rgb(165 85 47 / .5); }
.notes__doc blockquote { margin: 0; padding: 0 .9em; border-left: 3px solid var(--link); border-radius: 0 6px 6px 0; background: rgb(165 85 47 / .07); color: var(--text); font-style: italic; }
.notes__doc blockquote p { margin: 0; }
.notes__doc code { padding: .1em .35em; border-radius: 4px; background: #efe6d4; font: 13px/1.5 var(--mono); }
.notes__doc pre { margin: 0; padding: calc(var(--row) / 2) 12px; border-radius: 6px; background: #f1e9d8; white-space: pre-wrap; }
.notes__doc pre code { padding: 0; background: none; }
/* A divider takes a whole row, a solid line through its middle, so it stands out from the dashed rules. */
.notes__doc hr { height: var(--row); margin: 0; border: 0; background: linear-gradient(rgb(165 85 47 / .45), rgb(165 85 47 / .45)) 0 50% / 100% 1px no-repeat; }
.notes__doc p.is-editor-empty:first-child::before { content: attr(data-placeholder); float: left; height: 0; color: #a99a86; font-style: italic; pointer-events: none; }

/* ---------- Highlights on the page ---------- */
::highlight(mk-yellow) { background-color: rgb(255 208 64 / .5); }
::highlight(mk-green) { background-color: rgb(120 200 140 / .42); }
::highlight(mk-blue) { background-color: rgb(110 170 235 / .4); }
::highlight(mk-pink) { background-color: rgb(240 140 170 / .42); }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }
/* Doubled class names: a swatch is also a toolbar button, whose plain background must not win. */
.dot--yellow, .swatch.swatch--yellow { background: #f2c94c; } .dot--green, .swatch.swatch--green { background: #6fbf86; }
.dot--blue, .swatch.swatch--blue { background: #6ea8e8; } .dot--pink, .swatch.swatch--pink { background: #ee8fae; }

/* The toolbar on a selection, and a highlight's card. */
.selbar, .markpop { position: fixed; z-index: 40; box-shadow: 0 12px 32px rgb(0 0 0 / .32), 0 0 0 1px rgb(255 255 255 / .06); }
.selbar[hidden], .markpop[hidden], .toast[hidden] { display: none; }
.selbar { display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 12px; background: #2b2621; color: var(--cream); }
.selbar button, .markpop__row button { height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: inherit; font: 600 12.5px/1 var(--sans); cursor: pointer; white-space: nowrap; }
.selbar button:hover, .markpop__row button:hover { background: rgb(255 255 255 / .1); }
.selbar__swatches { display: inline-flex; gap: 4px; padding: 0 6px 0 2px; margin-right: 2px; border-right: 1px solid rgb(255 255 255 / .12); }
.selbar .swatch, .markpop .swatch { width: 22px; min-width: 0; height: 22px; padding: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgb(0 0 0 / .15); }
.selbar .swatch:hover, .markpop .swatch:hover { transform: scale(1.12); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #2b2621, 0 0 0 4px var(--cream); }
.selbar.is-long .selbar__swatches { display: none; }

.markpop { width: min(340px, calc(100vw - 20px)); display: grid; gap: 8px; padding: 14px; border-radius: 14px; background: var(--paper); color: var(--text); }
.markpop__kind { margin: 0; font: 600 10.5px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }
.markpop__quote { margin: 0; font: 600 19px/1.3 var(--serif); }
.markpop__note { width: 100%; min-height: 54px; padding: 8px 10px; border: 1px solid #e0d3bb; border-radius: 8px; background: #fff; color: var(--text); font: 400 15px/1.45 var(--sans); resize: vertical; }
.markpop__note:focus { outline: 2px solid rgb(231 189 98 / .7); outline-offset: 0; }
.markpop__row { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; color: var(--text); }
.markpop__row .selbar__swatches { border-right-color: #e0d3bb; }
.markpop__row button:hover { background: var(--paper-2); }
.markpop__row .is-danger { margin-left: auto; color: #a5352f; }
.markpop .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--text); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); padding: 9px 14px; border-radius: 10px; background: #2b2621; color: var(--cream); font: 500 13px/1.3 var(--sans); box-shadow: 0 10px 24px rgb(0 0 0 / .3); }

/* ---------- The Words tab ---------- */
.notes__words { overflow-y: auto; padding-right: 2px; color: #e8dcc6; }
.words__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.words__head p { margin: 0; font-size: 13px; color: #cbbfae; }
.words__review { flex: none; padding: 8px 14px; border: 0; border-radius: 99px; background: var(--gold); color: #2b2117; font: 700 13px/1 var(--sans); cursor: pointer; }
.words__review:disabled { opacity: .4; cursor: default; }
.words__legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 11.5px; color: #a99a86; }
.words__legend span { display: inline-flex; align-items: center; gap: 5px; }
.words__hint { margin: 0; font-size: 12.5px; line-height: 1.45; color: #a99a86; }
.words__page h4 { margin: 6px 0 6px; font: 600 11px/1.3 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.words__page ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.words__page li { display: flex; align-items: stretch; gap: 4px; }
.words__item { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .05); color: inherit; text-align: left; cursor: pointer; font: inherit; }
.words__item:hover { background: rgb(255 255 255 / .1); }
.words__item .dot { margin-top: 5px; }
.words__text { display: grid; gap: 2px; min-width: 0; }
.words__text b { font: 600 15px/1.3 var(--serif); color: var(--cream); overflow-wrap: anywhere; }
.words__text span { font-size: 13px; line-height: 1.4; color: #d9cbb3; }
.words__text .is-empty { color: #8f826f; font-style: italic; }
.words__listen { flex: none; width: 38px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .05); color: inherit; cursor: pointer; }
.words__listen:hover { background: rgb(255 255 255 / .1); }

/* ---------- Review: one card at a time ---------- */
.review { width: min(520px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 18px; background: var(--paper); color: var(--text); box-shadow: 0 30px 70px -20px rgb(0 0 0 / .7); }
.review::backdrop { background: rgb(20 16 12 / .65); }
.review__card { position: relative; display: grid; gap: 14px; justify-items: center; padding: 30px 26px 26px; text-align: center; }
.review__label { margin: 0; font: 600 11px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--link); }
.review__word { margin: 4px 0 0; font: 600 clamp(26px, 6vw, 34px)/1.15 var(--serif); }
.review__context { margin: 0; max-width: 42ch; font: italic 400 15px/1.55 var(--serif); color: var(--text-2); }
.review__context mark { background: rgb(255 208 64 / .45); color: var(--text); font-style: normal; padding: 0 .15em; border-radius: 3px; }
.review__meaning { margin: 0; font: 500 18px/1.45 var(--sans); }
.review__meaning.is-empty { font-size: 14px; color: var(--text-2); font-style: italic; }
.review__answer { padding: 14px 16px; width: 100%; border-radius: 12px; background: var(--paper-2); }
.review__answer[hidden], .review__grades[hidden], .review__primary[hidden] { display: none; }
.review__primary, .review__good, .review__again, .review__ghost { padding: 11px 20px; border: 0; border-radius: 99px; font: 700 14px/1 var(--sans); cursor: pointer; }
.review__primary, .review__good { background: var(--link); color: #fff; }
.review__again { background: var(--paper-2); color: var(--text); box-shadow: inset 0 0 0 1px #d9c9ac; }
.review__ghost { padding: 8px 14px; background: none; color: var(--text-2); font-weight: 600; }
.review__grades { display: flex; gap: 10px; }
.review__meta { margin: 0; color: var(--text-2); }
.review__quit { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--text-2); font: 300 26px/1 var(--sans); cursor: pointer; }

.home__session { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
a.home__session { color: var(--gold); }

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  .resizer { display: none; }
  .is-reader .notes { padding-top: 0; }
  .notes__tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: none; }
  .notes__tools::-webkit-scrollbar { display: none; }
  .tool { min-width: 38px; height: 38px; font-size: 14px; }
  .notes__doc { font-size: 16px; padding: 14px 14px 30px; }
  .kb-open .is-reader .notes__words { display: none; }
  .selbar { padding: 6px; border-radius: 14px; }
  .selbar button { height: 38px; }
  .selbar .swatch { width: 28px; height: 28px; }
  .markpop.is-sheet { left: 8px !important; right: 8px; top: auto !important; bottom: calc(env(safe-area-inset-bottom) + 8px); width: auto; padding: 16px; border-radius: 18px; }
  .markpop__note { font-size: 16px; }
  .review { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .review__card { min-height: 100%; align-content: center; padding: calc(env(safe-area-inset-top) + 40px) 22px calc(env(safe-area-inset-bottom) + 24px); }
  .review__quit { top: calc(env(safe-area-inset-top) + 8px); }
  .review__grades button, .review__primary { min-width: 130px; padding: 14px 22px; font-size: 16px; }
  :root[data-theme="night"] ::highlight(mk-yellow) { background-color: rgb(255 208 64 / .35); }
  :root[data-theme="night"] .notes__doc code, :root[data-theme="night"] .notes__doc pre { background: #2e2924; }
  :root[data-theme="night"] .notes__doc { --rule-c: #3d3731; }
  :root[data-theme="night"] .markpop__note { background: #2b2723; border-color: #3a342e; }
}
