/* The site's one look (docs/SPEC-local-site.md §3), for the library and the review pages alike: the owner, 10-02: a library
   as simple as the app's Library, plain and generous. The system font, ReadStair's green for actions (#248A3D, #30D158 in dark
   mode), big covers on a plain page, rem units, 16 px gutters and 44 px targets. The review pages sit on the grouped grey, in
   cards. */

:root {
  color-scheme: light dark;
  --bg: #fff;
  --grouped: #f2f2f7;
  --card: #fff;
  --field: #fff;
  --fill: rgba(120, 120, 128, 0.12);
  --ink: #1c1c1e;
  --ink2: #6e6e73;
  --line: #e3e3e8;
  /* A field's edge: Apple's system grey, 3:1 and more on white and on the dark card */
  --edge: #8e8e93;
  --green: #248a3d;
  --on-green: #fff;
  --lift: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.1);
  /* A menu over the page: Apple's card, opaque, so no picture shows through the names */
  --menu: #fff;
  --menu-lift: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.18);
  /* A book's spine, the shadow at its right page's inner edge */
  --spine: rgba(0, 0, 0, 0.07);
  /* A heart given: Apple's system pink */
  --heart: #ff2d55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --grouped: #000;
    --card: #1c1c1e;
    --field: #2c2c2e;
    --fill: rgba(120, 120, 128, 0.32);
    --ink: #f2f2f7;
    --ink2: #a1a1a6;
    --line: #38383a;
    --green: #30d158;
    /* White on #30D158 is too faint to read; black isn't */
    --on-green: #000;
    --lift: 0 0 0 1px rgba(255, 255, 255, 0.08);
    --menu: #2c2c2e;
    --menu-lift: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 12px 32px rgba(0, 0, 0, 0.5);
    --heart: #ff375f;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.47 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  /* A long word or address wraps instead of scrolling the page sideways */
  overflow-wrap: anywhere;
}

body.work { background: var(--grouped); }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

/* --- The bar: ReadStair on the left, Apple's App Store badge beside it (the owner, 11-18), Open Your Book on the right
   (Library and Sign Out on the owner's page). The badge keeps Apple's clear space, a quarter of its height (10 px), in
   the gaps and in the bar's padding and its row's room above and below it. */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand:hover { text-decoration: none; }

.brand img {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
}

/* Open Your Book, the way to a reader's own book, and Written by Readers beside it while there is a reader's book:
   green as the site's actions. Under 600 px they have the bar's second row, their words starting under ReadStair's
   logo (the owner, 11-18: "保留名字，Open Your Book 换到第二行"), so a phone keeps ReadStair's name with the badge
   beside it, 320 px too. */
.open-link, .readers-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}

.open-link { margin-left: auto; }

.app-store { display: block; flex: none; }
.app-store img { display: block; width: auto; height: 2.5rem; }

@media (max-width: 37.4375rem) {
  .bar { justify-content: flex-start; row-gap: 0; }
  .bar::after { content: ""; flex-basis: 100%; order: 1; }
  .bar .open-link { order: 2; margin-left: -0.25rem; }
  .bar .readers-link { order: 3; }
}

/* The owner's page: the way back to the library, then out (the owner, 10-02) */
.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 0.75rem;
  margin: 0;
  color: var(--ink2);
  font-size: 0.9375rem;
}
.who a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--ink2); }

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

h1 {
  margin: 0.75rem 0 0.25rem;
  font-size: 2.125rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.375rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h3 { margin: 0; font-size: 1.0625rem; line-height: 1.3; }
p { margin: 0 0 1rem; }

.lede {
  margin: 0 0 2.25rem;
  color: var(--ink2);
}

.sub { margin: 0; color: var(--ink2); }
.notice { margin: 0.75rem 0 0; }
/* A photo on a cover: a person checks it */
.item .notice.photo { margin: 0.75rem 0; font-weight: 600; }

/* --- The library: covers in a grid, the title and pen name under each */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 2.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.grid a { display: block; color: inherit; }
.grid a:hover { text-decoration: none; }
.grid a:hover img { transform: translateY(-2px); }

.grid img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.375rem;
  background: var(--fill);
  box-shadow: var(--lift);
  transition: transform 0.15s ease-out;
}

.grid .title {
  display: -webkit-box;
  margin-top: 0.75rem;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.grid .by {
  display: block;
  margin-top: 0.125rem;
  color: var(--ink2);
  font-size: 0.9375rem;
}

/* The Recommended ladder, all of it, easiest first, in rows down the page (the owner, 11-18), each book's place on the
   ladder on its cover: two across a phone, 320 px too, each as wide as a cover's hearts and views at their longest
   ("999 · 9.9K views"); from 640 px as many as fit at 11.5rem or more, the row always as wide as the page: three
   across an iPad held upright, five on a computer, as large as two rows still show whole under the title on a
   1280 x 800 screen (the owner, 11-18: "电脑上或者ipad的网站的书是否可以放2排就好，稍微大一点", "每行 5 本，排满"). A
   book the page opens at (public/ladder.js) shows the foot of the row above. */
.ladder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .ladder { grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 1.75rem 1.25rem; }
}

.ladder li { min-width: 0; scroll-margin-top: 4.5rem; }
.ladder a { position: relative; display: block; color: inherit; }
.ladder a:hover { text-decoration: none; }

.ladder img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0.375rem;
  background: var(--fill);
  box-shadow: var(--lift);
}

.ladder .n {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.625rem;
  height: 1.625rem;
  padding: 0 0.375rem;
  border-radius: 0.8125rem;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}

/* A book's marks after its age: very small icons, as in the app's Library */
.marks { white-space: nowrap; }
.mark svg { width: 0.8125rem; height: 0.8125rem; margin-left: 0.25rem; vertical-align: -0.0625rem; }

.empty {
  padding: 3rem 0;
  color: var(--ink2);
}

/* The library's title, its ages small at the right (the owner, 10-04: a phone shows two rows of books below) */
.library-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
}

.library-head h1 { margin: 0; }
.library-head + .ladder, .library-head + .grid { margin-top: 1.5rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* 36 px tall, past WCAG's 24 px for a target */
.library-head .segmented a {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  font-size: 0.875rem;
}

/* Small and quiet (the owner, 10-03: the two Hide items as short as can be, the type a little smaller); 36 px tall,
   past WCAG's 24 px for a target. Hide AI-helped is off for now (pages.ts HIDE_AI_HELPED); kept for when it's back. */
.filter {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 1.125rem;
  background: var(--fill);
  color: var(--ink);
  font-size: 0.8125rem;
}

.filter:hover { text-decoration: none; }
.filter svg { width: 0.75rem; height: 0.75rem; }
.filter.on { background: var(--green); color: var(--on-green); }

/* --- One book: its cover beside the title, then the story in a reading column */

.back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.back::before { content: "‹"; margin-right: 0.375rem; font-size: 1.375rem; line-height: 1; }

.hero {
  display: flex;
  align-items: flex-end;
  gap: 1.75rem;
  margin: 1rem 0 2.75rem;
}

.hero img {
  flex: none;
  width: 11rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.5rem;
  background: var(--fill);
  box-shadow: var(--lift);
}

.hero h1 { margin-top: 0; }
.hero p { margin: 0; }
.hero .stats { margin-top: 0.5rem; }

/* A book's heart and views, and on a reading page who is reading it now (src/counts.ts, public/count.js): small and
   grey, never broken, its numbers all as wide */
.stats {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  color: var(--ink2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ladder .stats, .grid .stats { margin-top: 0.375rem; font-size: 0.8125rem; }
/* A dot between any two counts shown, whichever they are (a count of none is hidden), not read out where the browser
   can say so */
.stats > :not([hidden]) ~ :not([hidden])::before { content: "·"; content: "·" / ""; margin-right: 0.25rem; }

/* One heart everywhere, outlined; filled pink only once this reader gave it. Its hidden words for VoiceOver placed in
   it (on the shelves, outside its cover's link, they would sit past the row's end and widen the page). */
.heart { position: relative; display: inline-flex; align-items: center; gap: 0.25rem; }
.heart-mark { flex: none; width: 1.125em; height: 1.125em; fill: none; stroke: currentColor; stroke-width: 2; }
.heart[aria-pressed="true"] .heart-mark { fill: var(--heart); stroke: var(--heart); }

/* The heart a reader taps: in a line of words, only as tall as they are, its finger's room around it reaching down
   (under a cover, not up into it), so the dots either side of its count are as far from it as the others */
button.heart {
  min-height: 0;
  margin: -0.25rem -0.5rem -0.875rem;
  padding: 0.25rem 0.5rem 0.875rem;
  border-radius: 1.375rem;
  background: none;
  color: inherit;
  font-weight: inherit;
}

/* A finger's width too, with no count beside it: its room reaching right, over words no one taps */
button.heart::after { content: ""; position: absolute; inset: 0 auto 0 0; width: max(100%, 2.75rem); }

.age {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.125rem 0.625rem;
  border-radius: 1rem;
  background: var(--fill);
  font-size: 0.875rem;
  font-weight: 600;
}

.story {
  max-width: 36rem;
  font: 1.25rem/1.6 ui-serif, "New York", Georgia, serif;
}

.story h2, .story h3 {
  margin: 2rem 0 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

.story p { margin: 0 0 1.1em; }

.story img { max-width: 100%; height: auto; }
.story pre { white-space: pre-wrap; }
.story table { display: block; max-width: 100%; overflow-x: auto; }

/* --- Reading a Recommended book (src/reading.ts): a picture book read aloud, a classic on one page */

/* A picture book is a reader's view the screen's height, as Apple Books' (never overflow: hidden, so a page zoomed in
   still scrolls): the way back and the language menu, the book, and the recording between the page turns */
main.reader {
  display: grid;
  grid-template: "top" auto "book" minmax(0, 1fr) "bar" auto / minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  padding: 0;
}

/* The top row as Apple's navigation bars: the way back, the book's title in the middle of the screen, cut short with an
   ellipsis when long, and the language menu (the owner, 10-14: the title there, so the book below has the room) */
.reader-top {
  grid-area: top;
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  gap: 0 0.75rem;
  padding: 0.25rem 1rem 0;
}

/* Never broken into lines: the title gives way, not the way back or the language */
.reader-top .back { grid-row: 1; grid-column: 1; justify-self: start; white-space: nowrap; }
.reader-top .menu { grid-row: 1; grid-column: -2 / -1; justify-self: end; margin: 0; white-space: nowrap; }

/* The title in the middle, its heart small after it (the owner, 10-14: "放到首栏书名后面,不要太大"): the title gives way,
   never the heart, which has the row's height to be tapped in */
.reader-top .title {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-width: 0;
}

.reader-top button.heart {
  flex: none;
  min-height: 2.75rem;
  margin-block: 0;
  padding-block: 0;
  color: var(--ink2);
  font-size: 0.875rem;
}

/* Who is reading it now and its views ("怎么还是在下面"): on a phone held upright, as Apple's navigation bars'
   subtitle, under the title on the row's whole width (beside it, the title had room for one letter), tucked up close,
   never in the way of a tap; on a wider screen, right of the heart in the same row, a dot between ("就放在爱心右边,
   给下面省点空间"), the title and its heart and counts kept together in the middle */
.reader-top > .stats {
  grid-row: 2;
  grid-column: 1 / -1;
  justify-self: center;
  /* A line's height with nothing on it yet, so the book's room never changes when a count comes */
  min-height: 0.9375rem;
  margin-top: -0.5rem;
  font-size: 0.75rem;
  line-height: 1.25;
  pointer-events: none;
}

@media (min-width: 44rem) {
  .reader-top { grid-template-columns: 1fr minmax(0, auto) auto 1fr; }
  .reader-top > .stats { grid-row: 1; grid-column: 3; justify-self: start; margin: 0 0 0 -0.5rem; font-size: 0.875rem; }
  /* The dot after the heart, while a count is shown; not read out where the browser can say so */
  .reader-top > .stats:has(> :not([hidden]))::before { content: "·"; content: "·" / ""; }
}

.reader-top h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The turns and the recording kept together under the book, not at a wide screen's far ends */
.reader-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 48rem;
  justify-self: center;
  padding: 0.5rem 1rem 0.75rem;
}

.reader-bar .player { flex: 1; min-width: 0; }
/* A phone has its volume keys, and its narrow player keeps the room for its timeline rather than its times */
@media (pointer: coarse) {
  .player::-webkit-media-controls-mute-button { display: none; }
}

@media (pointer: coarse) and (max-width: 500px) {
  .player::-webkit-media-controls-current-time-display,
  .player::-webkit-media-controls-time-remaining-display { display: none; }
}

/* The way back drawn as the turns are */
.reader-top .back::before { content: none; }
.reader-top .back svg { width: 0.625rem; height: 1.0625rem; margin-right: 0.375rem; }

/* The pages side by side, a page a screen, turned sideways (the owner, 10-13: "左右翻页的感觉,像是在翻书"): by
   swiping, scrolling or the arrow keys without read.js too; never past the first page into the browser's Back. read.js
   turns them with the recording and the turns, and hides the scroll bar. */
.leaves {
  grid-area: book;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}

.leaves.paged { scrollbar-width: none; }
.leaves.paged::-webkit-scrollbar { display: none; }
.leaves:focus-visible { outline-offset: -3px; }

/* A page: its picture, and its words under it on a phone upright; read.js gives the picture the height they leave */
.leaf {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.5rem 1rem;
  overflow-y: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.art {
  flex: none;
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  box-shadow: var(--lift);
}

.art img { display: block; width: 100%; height: auto; }
/* Without read.js, each picture as tall as the screen lets it */
.leaves:not(.paged) .art { width: fit-content; max-width: 100%; }
.leaves:not(.paged) .art img { width: auto; max-width: 100%; max-height: calc(100dvh - 9rem); }

/* A word read.js places on the picture, over the word printed there; only its light shows */
.art .w { position: absolute; color: transparent; }

/* The page's own words, start-aligned as a book's (right to left in Arabic), smaller only when the screen can't hold
   them at their size (read.js), and then scrolling within */
.line {
  width: 100%;
  max-width: 34rem;
  min-height: 0;
  margin: 0;
  /* A word whole, the page widened for it (read.js), not broken as the site's other text may be */
  overflow-wrap: normal;
  overflow-y: auto;
  font-size: 1.375rem;
  line-height: 1.5;
  text-align: start;
}

.line.long { font-size: 1.125rem; }
/* Under a picture wider than tall, as wide as it (read.js) */
.leaf.wide .line { max-width: none; }

/* On a screen wider than tall, an open book: the picture the left page, its words the right one beside it (the
   owner: "翻译的文字最好放在右边"), as tall, at least as wide (read.js), on white paper as the picture's, in dark mode
   too, so the two are one book, with the spine's shadow at its inner edge, centred upright in it. A picture wider
   than tall (.wide) is a spread of its own: its words stay under it. */
@media (min-aspect-ratio: 5/4) and (min-width: 700px) {
  .leaf:not(.wide) { flex-direction: row; gap: 0; }
  .leaf:not(.wide):has(.line) .art { border-radius: 0.5rem 0 0 0.5rem; }

  .leaf:not(.wide) .line {
    max-width: none;
    align-content: safe center;
    padding: 2rem 2.25rem;
    border-radius: 0 0.5rem 0.5rem 0;
    background: linear-gradient(to right, var(--spine), transparent 1.75rem) #fff;
    color: #1d1d1f;
    box-shadow: var(--lift);
  }
}

/* A phone on its side: less paper round the words */
@media (min-aspect-ratio: 5/4) and (min-width: 700px) and (max-height: 480px) {
  .leaf:not(.wide) .line { padding: 1rem 1.25rem; }
}

.w { border-radius: 0.2em; cursor: pointer; }
/* The app's light for the word being said (rsl's EPUB style) */
.w.on { background: rgba(0, 122, 255, 0.28); }

/* A page turn either side of the recording: round, 44 px, as Apple's; faint at the book's either end */
.turn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 50%;
}

.turn[hidden] { display: none; }
.turn svg { width: 0.75rem; height: 1.25rem; }
.turn[aria-disabled="true"] { opacity: 0.35; cursor: default; }

/* --- A classic's pages turned as a book's (public/pages.js; the owner, 10-14: "50 本经典文字书,也给文字书做成翻页"),
   on screens only, so printing gives the long page. Without the script, the book is the long page it was. */
@media screen {
  main.book.paged {
    display: grid;
    grid-template: "top" auto "book" minmax(0, 1fr) "bar" auto / minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    max-width: none;
    padding: 0;
  }

  /* A page a screen, snapped to by the browser's own scrolling, to the snap points pages.js lays beside the text */
  .paged .pages {
    grid-area: book;
    display: grid;
    grid-template-rows: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .paged .pages::-webkit-scrollbar { display: none; }
  .paged .pages:focus-visible { outline-offset: -3px; }

  /* The text in columns the box's height, its margins a column gap (pages.js), so each page is the box's width */
  .paged .flow {
    grid-area: 1 / 1;
    justify-self: start;
    height: 100%;
    margin: 0 1.5rem;
    padding: 1rem 0;
    column-count: 1;
    column-fill: auto;
  }

  .paged .snaps { grid-area: 1 / 1; justify-self: start; align-self: start; display: flex; height: 1px; pointer-events: none; }
  .paged .snaps > i { flex: none; width: var(--step); scroll-snap-align: start; scroll-snap-stop: always; }

  /* A page's lines no longer than reads well, in the middle of their column; a picture no taller than a page and
     never cut by one; a table going on over the page, as a box that scrolls can't */
  .paged .story { margin: 0 auto; }
  /* A picture holds its size (tools/reading.py writes it) before it comes, so nothing moves when it does; shrunk to
     a page's height inside that box */
  .paged .story img { max-height: calc(var(--page) - 3rem); object-fit: contain; break-inside: avoid; }
  /* A picture's own words under it (a caption, a way back) a line more room, so they stay on its page (I-133) */
  .paged .story .picture img { max-height: calc(var(--page) - 5rem); }
  /* On a screen as short as a phone on its side, the picture's line under it takes more of the page */
  @media (max-height: 30rem) {
    .paged .story .picture img { max-height: calc(var(--page) - 7rem); }
  }
  /* A classic's empty blocks after its last words, hidden by public/pages.js (I-133), whatever display their tag gets */
  .paged .story [hidden] { display: none !important; }
  .paged .story .picture { break-inside: avoid; }
  .paged .story table { display: table; }

  /* The contents a pop-up menu in the top row, the chapter shown ticked */
  .toc.menu { margin: 0; }
  .toc.menu > summary { padding: 0 0.875rem; color: var(--ink); }
  .toc.menu a[aria-current="location"]::before { content: "\2713\FE0E"; flex: none; width: 1rem; margin: 0 0.5rem 0 -1.5rem; }

  /* Listen between the turns */
  .paged .listen { position: static; margin: 0 auto; transform: none; box-shadow: none; }
}
/* A narrow screen (a phone at 200% zoom): Listen its mark alone, round as the turns are, so its name never stands a
   letter a line and the bar keeps to one row; the name still read out */
@media (max-width: 19.5rem) {
  .paged .listen { width: 2.75rem; padding: 0; }
  .paged .listen .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* On a screen wider than tall, an open book: two pages a screen */
@media screen and (min-aspect-ratio: 5/4) and (min-width: 900px) {
  .paged .flow { column-count: 2; }
}

/* A pop-up menu as on Apple's (public/menu.js): a button naming what is chosen, with an up-and-down chevron; open, a
   list over the page on a lifted card, the one chosen ticked. A picture book's languages (src/reading.ts
   languageMenu), a classic's chapters (public/pages.js). */
.menu { position: relative; z-index: 2; margin: 0 0 0 auto; }

.menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: 0.75rem;
  background: var(--fill);
  color: var(--ink);
  list-style: none;
  user-select: none;
}

.menu > summary::-webkit-details-marker { display: none; }
.menu .chevron { width: 0.5625rem; height: 0.875rem; color: var(--ink2); }

.menu > ul,
.menu > ol {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 13rem;
  max-height: min(32rem, 70vh);
  overflow-y: auto;
  margin: 0;
  padding: 0.375rem;
  list-style: none;
  border-radius: 0.875rem;
  background: var(--menu);
  box-shadow: var(--menu-lift);
}

/* Each a row 44 px tall, its name past the tick's column, so every name lines up */
.menu a {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem 0 2.25rem;
  border-radius: 0.5rem;
  color: var(--ink);
  font-size: 1.0625rem;
}

.menu a:hover { background: var(--fill); text-decoration: none; }
.menu .tick { flex: none; width: 1rem; height: 1rem; margin: 0 0.5rem 0 -1.5rem; }

@media (prefers-reduced-motion: no-preference) {
  .menu[open] > :is(ul, ol) { transform-origin: top right; animation: menu-open 0.16s ease-out; }
}

@keyframes menu-open { from { opacity: 0; transform: scale(0.96); } }

/* Words for a screen reader alone */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A classic heard in the device's own voice (public/listen.js): one button, always at hand at the bottom; the
   sentence said lit as a picture book's word is */
.listen {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  min-height: 2.75rem;
  padding: 0 1.375rem;
  border-radius: 1.375rem;
  background: var(--green);
  color: var(--on-green);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--lift);
}

.listen[hidden] { display: none; }
::highlight(said) { background-color: rgba(0, 122, 255, 0.28); }
.said { background: rgba(0, 122, 255, 0.12); border-radius: 0.25rem; }
/* Room below the text, so its last lines can rise clear of the button */

/* A classic's chapters, above its text, closed until opened (the owner, 10-04: "应该有个下拉框…不然太占地方了"):
   each a jump within the page */
.toc { margin: 1rem 0 1.5rem; }
/* The browser's own triangle says it opens */
.toc > summary { padding: 0.625rem 0; color: var(--green); font-weight: 600; cursor: pointer; }
.chapters { columns: 6rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.chapters a { display: inline-flex; align-items: center; min-height: 2.75rem; }

/* Report This Book: there for whoever needs it, quiet for everyone else */
.report { margin-top: 3rem; }

.report button {
  padding: 0 0.25rem;
  background: none;
  color: var(--ink2);
  font-size: 0.9375rem;
  font-weight: 400;
}

/* --- Pages of words: the terms, the privacy policy, a library's link */

.prose { max-width: 42rem; }
.prose h2 { margin-top: 2rem; font-size: 1.25rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin: 0.25rem 0; }

table { width: 100%; margin: 0 0 1rem; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem 0.5rem 0; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; }

/* --- The footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--ink2);
  font-size: 0.875rem;
}

.foot a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--ink2); }

/* --- The review pages: the work only, in cards */

.work main { max-width: 48rem; }

.count {
  margin-left: 0.5rem;
  color: var(--ink2);
  font-weight: 400;
}

.meta { margin: 0 0 1.25rem; }

/* What the owner declines: closed under To Do, as the chapters and Report This Book are */
.rules { margin: 0 0 1.25rem; }
.rules ol { margin: 0.25rem 0 0; padding-left: 1.25rem; }

/* Sections that aren't the work, closed until opened */
.more { margin: 2rem 0 0; }
.more > summary { padding: 0.5rem 0; color: var(--ink); }
.more > summary h2 { display: inline; margin: 0; }

/* Choices side by side, those ticked green: the library's ages */
.segmented {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.875rem;
  background: var(--fill);
}

.segmented form { margin: 0; }

.segmented button {
  border-radius: 0.625rem;
  background: none;
  color: var(--ink);
}

.segmented button[aria-pressed="true"] { background: var(--green); color: var(--on-green); }

/* The library's ages: links, each a switch, as the buttons look */
.segmented a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: 0.625rem;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
}

.segmented a:hover { text-decoration: none; }
.segmented a[aria-checked="true"] { background: var(--green); color: var(--on-green); }

.item {
  margin: 0 0 0.875rem;
  padding: 1rem 1.125rem;
  border-radius: 0.875rem;
  background: var(--card);
}

.head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.head > div { min-width: 0; }
.head p { margin: 0; }

.cover {
  flex: none;
  width: 6.5rem;
  height: auto;
  border-radius: 0.25rem;
  box-shadow: 0 0 0 1px var(--line);
}

.cover.small { width: 3.5rem; }

.text {
  margin: 1rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
  white-space: pre-wrap;
}

details { margin: 0.5rem 0 0; }
details p { margin: 0 0 0.5rem; }

summary {
  padding: 0.625rem 0;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
}

form, .actions, fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

form { min-width: 0; margin: 0.75rem 0 0; }
.actions { column-gap: 1.5rem; }

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  column-gap: 1rem;
}

legend { float: left; padding: 0; }

fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  cursor: pointer;
}

input[type=radio], input[type=checkbox] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--green);
}

label.score, label.check { display: inline-flex; align-items: center; gap: 0.5rem; }
label.check { min-height: 2.75rem; cursor: pointer; }
/* The upload's note under its choices; what became of each file */
form > .sub { flex-basis: 100%; }
.meta ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

/* Where Readers Are (src/admin.ts): a place a row, its count beside it, opening to its last opens */
.places { margin: 0; padding: 0; list-style: none; }
.places li { border-top: 1px solid var(--line); }
.places summary { padding: 0.625rem 0; cursor: pointer; }
/* Every place's table in the same columns */
.places table { table-layout: fixed; font-size: 0.875rem; }
.places th:first-child { width: 7.5rem; }
.places th:last-child { width: 4.5rem; }

.recent { margin: 0; padding: 0; list-style: none; }
.recent li { padding: 0.5rem 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }

input:not([type]), input[type=email], input[type=password] {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid var(--edge);
  border-radius: 0.75rem;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

/* The upload's EPUBs: the field 44 px tall, its button as the page's are */
input[type=file] {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  color: var(--ink2);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 400;
}

input[type=file]::file-selector-button {
  min-height: 2.75rem;
  margin-right: 0.75rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button, select {
  min-height: 2.75rem;
  border-radius: 0.75rem;
  color: var(--ink);
  font: inherit;
}

button {
  padding: 0.625rem 1.375rem;
  border: 0;
  background: var(--fill);
  font-weight: 600;
  cursor: pointer;
}

button.primary { background: var(--green); color: var(--on-green); }

select {
  max-width: 100%;
  padding: 0 0.5rem;
  border: 1px solid var(--edge);
  background: var(--field);
}

/* A reason and its button on one row: Decline and Remove read apart from Publish */
form:has(> select[name=reason]) { flex-wrap: nowrap; margin-top: 1.25rem; }
select[name=reason] { flex: 1; min-width: 0; }

@media (max-width: 30rem) {
  h1 { font-size: 1.875rem; }
  .grid { grid-template-columns: 1fr 1fr; gap: 1.75rem 1rem; }
  .hero { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .hero img { width: 10rem; }
  .story { font-size: 1.1875rem; }
  .cover { width: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .grid img { transition: none; }
  .grid a:hover img { transform: none; }
}

/* --- /open, a reader's own book (src/open.ts, public/open.js; docs/OPEN-DESIGN.md 6.4, 6.5): the start, the book turned
   as a classic's, My Words; the word card and the settings card over them */

/* One view at a time, and anything hidden on /open or in a classic hidden, whatever display its look gives it (I-024) */
main[hidden], main.start [hidden], main.book [hidden], main.words [hidden], .sheet [hidden], .foot[hidden] {
  display: none !important;
}

/* The start: one column, one green button; the privacy words and credits quiet under it */
.start .opening { max-width: 36rem; margin: 0 auto; }
.start .lede { margin-bottom: 1.5rem; }
.start .status:empty { display: none; }
.start .my-words { display: inline-flex; align-items: center; min-height: 2.75rem; }
.start .home-screen { color: var(--ink2); }
/* The privacy words a sentence a line, the folds under them */
.start .about { margin-top: 3rem; color: var(--ink2); font-size: 0.9375rem; }
.start .about p { margin: 0 0 0.375rem; }
.start .about details { margin: 0.75rem 0 0; }
.start .about summary { padding: 0.6875rem 0; color: var(--ink); cursor: pointer; }
.start .about details p { margin: 0 0 0.5rem; }
main.start > .reader-top, main.words > .reader-top, main.test > .reader-top { padding: 0.25rem 0 0; }

/* The book, as a classic's (main.book.paged): at the top row's end the reader's level and the book's ⋯, a round button
   of three dots (the owner, 10-22). The level a pill as tall, the logo's gold star and "3K", its room kept while a
   classic's words are worked out (public/open.js), so nothing beside it moves. A classic's contents an item in the ⋯
   (public/pages.js): no button of its own, its list opening where the ⋯'s does. */
.book-menu > summary { width: 2.75rem; padding: 0; justify-content: center; border-radius: 50%; }
.reader-top .menus { grid-row: 1; grid-column: -2 / -1; justify-self: end; position: relative; display: flex; align-items: center;
  gap: 0.375rem; }
.level-button { display: inline-flex; align-items: center; gap: 0.3125rem; min-height: 2.75rem; padding: 0 0.875rem 0 0.75rem;
  border-radius: 1.375rem; white-space: nowrap; }
.level-button .star { flex: none; width: 1.0625rem; height: 1.0625rem; color: var(--gold); }
.level-button.waiting { visibility: hidden; }
.menus .toc.in-more { position: absolute; top: 0; right: 0; width: 0; height: 2.75rem; margin: 0; }
.menus .toc.in-more > summary { display: none; }
.book-menu .dots { width: 1.125rem; height: 0.25rem; color: var(--ink); }
.menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 2.75rem;
  padding: 0 1rem 0 2.25rem;
  border-radius: 0.5rem;
  background: none;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 400;
  text-align: left;
}
.menu button:hover { background: var(--fill); }
.book-menu a, .book-menu button { padding-left: 1rem; }
/* The book's note over its turns, never in their row: a message never makes the bar taller, so the pages never lay out
   again under the reader's finger */
main.book .reader-bar { position: relative; }
.own .reader-bar { justify-content: space-between; }
.reader-bar .note {
  position: absolute;
  bottom: calc(100% - 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.375rem 0.875rem;
  border-radius: 1rem;
  background: var(--menu);
  box-shadow: var(--menu-lift);
  color: var(--ink);
  font-size: 0.9375rem;
  text-align: center;
}

/* A tap on the pages is a word's: iOS doesn't grey the whole box for it */
main.book .pages { -webkit-tap-highlight-color: transparent; }
/* One letter at the book's size, out of sight at the page's corner (where the text ends it would make the page itself
   scroll): its size changing says the iPhone's text size has (public/open.js) */
.em-probe { position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none; }

/* New words underlined in the app's red, the text as it is (no padding, so nothing moves); the word tapped lit lightly */
.own .flow .w { cursor: pointer; }
.own .flow .w.new { text-decoration: underline 0.1em #d70015; text-underline-offset: 0.18em; text-decoration-skip-ink: none; }
.own .flow .w.tapped { background: var(--fill); border-radius: 0.2em; }
/* A paragraph the browser has translated isn't the book's words any more (view-txt.js): nothing underlined, nothing to tap */
.own .flow p.translated .w.new { text-decoration: none; }
.own .flow p.translated .w { cursor: auto; }
/* A classic's the same, drawn as highlights over its text (public/view-html.js); the line unbroken by a letter's tail,
   which Safari takes from the text rather than the highlight */
::highlight(readstair-new) { text-decoration: underline 0.1em #d70015; text-underline-offset: 0.18em; text-decoration-skip-ink: none; }
::highlight(readstair-tapped) { background-color: var(--fill); }
main.book:not(.own) .story { text-decoration-skip-ink: none; }
/* A card over the page: on a phone from the bottom, or from the top when the room under the word is short, as tall as
   the room on its side (public/card.js); on a wide screen at the side, away from the word (--side tells card.js which).
   Its button in a foot that stays in sight while the rest scrolls. */
.sheet {
  --side: 0;
  position: fixed;
  z-index: 3;
  inset: auto 0 0 0;
  max-width: 40rem;
  max-height: 45vh;
  max-height: 45dvh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 0.75rem 1rem 0;
  border-radius: 1rem 1rem 0 0;
  background: var(--menu);
  box-shadow: var(--menu-lift);
  font-size: 1.0625rem;
}
/* A hairline over it, so a line cut by it reads as more below */
.card-foot {
  position: sticky;
  bottom: 0;
  margin: 0 -1rem;
  padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--menu);
}
.sheet.top .card-foot { padding-bottom: 1rem; }
/* The card's line for the reader: always there for a screen reader to hear, taking no room while empty */
.sheet .card-note { margin-bottom: 0.5rem; color: var(--ink2); }
.sheet .card-note:empty { margin: 0; }
/* The first card a reader sees fits a small phone whole: Done and every language on screen */
.settings.sheet { max-height: 75vh; max-height: 75dvh; }
.sheet[hidden] { display: none; }
.sheet.top { inset: 0 0 auto 0; padding-top: calc(0.75rem + env(safe-area-inset-top)); border-radius: 0 0 1rem 1rem; }
@media (min-width: 700px) and (min-aspect-ratio: 1/1) {
  .sheet, .settings.sheet {
    --side: 1;
    inset: 4rem 1rem auto auto;
    width: 22rem;
    max-height: calc(100dvh - 8rem);
    margin: 0;
    border-radius: 1rem;
  }
  .sheet .card-foot { padding-bottom: 1rem; }
  .sheet.left { inset: 4rem auto auto 1rem; }
  .sheet.top { inset: 4rem 1rem auto auto; padding-top: 0.75rem; border-radius: 1rem; }
}
/* A phone on its side: the settings card as tall as the screen, over the book's top row and turns (it is all there is to
   do then; kept clear of them, its languages were cut off) */
@media (max-height: 30rem) {
  .settings.sheet { max-height: 100vh; max-height: 100dvh; }
}
@media (max-height: 30rem) and (min-width: 700px) and (min-aspect-ratio: 1/1) {
  .settings.sheet { inset: 0.5rem 1rem auto auto; max-height: calc(100dvh - 1rem); }
}
.sheet p { margin: 0 0 0.75rem; }
/* A word too long for the row has its own line, broken only where it can be (waistcoat-pocket), the buttons under it */
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin-bottom: 0.25rem; }
.card-head h2 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 1.41em; overflow-wrap: break-word; }
.card-head h2:focus { outline: none; }
.card-head button {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  padding: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink2);
}
.card-head button svg { width: 1.125rem; height: 1.125rem; }
.card-head .say { color: var(--green); }
.card-head .say svg { width: 1.375rem; height: 1.375rem; }
.card-sentence { color: var(--ink2); }
.card-sentence strong { color: var(--ink); }
.card-meaning { font-size: 1.12em; }
.card-meaning.trouble { color: var(--ink2); font-size: 1em; }
.card-meaning.trouble .ai { display: none; }
.card-whole { color: var(--ink2); }
.card-part { color: var(--ink2); font-size: 0.82em; }
/* Inline, so the space before it holds it to the meaning's last word */
.ai {
  padding: 0 0.375rem;
  border-radius: 0.375rem;
  background: var(--fill);
  color: var(--ink);
  font-size: 0.7em;
  font-weight: 600;
  vertical-align: 0.15em;
}
/* A line to come, as a grey bar its height */
.card-meaning.waiting .meaning-text::before, .card-whole.waiting::before {
  content: "";
  display: inline-block;
  width: 60%;
  height: 0.75em;
  border-radius: 0.375rem;
  background: var(--fill);
}
.card-meaning.waiting .ai { display: none; }

/* The settings card: the reading level on its stairs, how many that underlines here, the meanings' language */
.settings .card-head h2 { font-size: 1.12em; }
.settings h3 { margin: 0.5rem 0; font-size: 0.94em; color: var(--ink2); font-weight: 600; }
.sheet .buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.settings .underlined, .settings .estimate, .settings .level-note, .settings .translate p { color: var(--ink2); }
/* The app's line under Reading Level (LevelSheet), but for the test's answer, which says enough, and on a screen as narrow
   as a small phone's text made larger, or as short as a phone on its side, where the languages and Done must fit
   unscrolled (section 13) */
.settings .estimate:not([hidden]) + .level-note { display: none; }
@media (max-width: 19.5rem) {
  .settings .level-note { display: none; }
}
/* How to have the browser translate the book, folded as the start page's folds: the summary in the text's colour */
.settings .translate { margin: 0.25rem 0 0.75rem; }
.settings .translate summary { padding: 0.6875rem 0; color: var(--ink); cursor: pointer; }
/* Done, and across from it the vocabulary test, taken from here only (the owner, 10-22): in the foot, so the card is
   no taller */
.settings .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
/* The meanings' language chosen green; three on one row at 320 px */
.settings [data-lang] { padding-inline: 0.875rem; }
.settings [data-lang][aria-pressed="true"] { background: var(--green); color: var(--on-green); }

/* The stairs (the logo's steps and gold star, the owner, 10-21: "就这这个logo拓展"): three steps rising, the reader's in
   the middle with the star, the one below and the one above to tap; a step's shade is its level's, each darker than the
   one under it (the logo's navy at the top), its label dark or white for 4.5:1 and more; on a dark card each lighter
   step is the lower one too, all at 4.5:1 and more against the card. The ground (no step) under 1K, nothing over 15K. */
:root {
  --stair-0: #d5dcea; --stair-1: #c0c8d9; --stair-2: #acb5c8; --stair-3: #98a2b8; --stair-4: #8490a7; --stair-5: #717e97;
  --stair-6: #5f6c87; --stair-7: #4d5b77; --stair-8: #3b4a68; --stair-9: #2b3a59; --stair-10: #1b2a4a;
  /* The app's gold (WordCard.swift GoldMark), the word card's star */
  --gold: #f5b800;
}
@media (prefers-color-scheme: dark) {
  :root {
    --stair-0: #eef1f7; --stair-1: #e3e8f2; --stair-2: #d8dfed; --stair-3: #cdd5e7; --stair-4: #c2cce2; --stair-5: #b7c3dd;
    --stair-6: #adbad8; --stair-7: #a2b1d2; --stair-8: #98a9cd; --stair-9: #8da0c7; --stair-10: #8397c2;
    --gold: #ffd60a;
  }
}
.stairs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  width: min(100%, 18rem);
  height: 5.25em;
  margin: 0.25rem 0 0.75rem;
}
.stair {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
}
.stair .block {
  width: 100%;
  padding-top: 0.2em;
  border-radius: 0.375em 0.375em 0 0;
  background: var(--shade);
  color: var(--shade-ink, #1b2a4a);
  font-size: 0.94em;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}
.stair:nth-child(1) .block { height: 1.6em; }
.stair:nth-child(2) .block { height: 3.2em; }
.stair:nth-child(3) .block { height: 4.8em; }
.stair .star { position: absolute; bottom: 3.3em; left: 50%; width: 1.75em; height: 1.75em; transform: translateX(-50%); color: var(--gold); }
.stair.none { visibility: hidden; }
button.stair:not(:disabled):hover .block { filter: brightness(1.1); }
button.stair:not(:disabled):active .block { filter: brightness(0.9); }
.stair[data-shade="0"] { --shade: var(--stair-0); }
.stair[data-shade="1"] { --shade: var(--stair-1); }
.stair[data-shade="2"] { --shade: var(--stair-2); }
.stair[data-shade="3"] { --shade: var(--stair-3); }
.stair[data-shade="4"] { --shade: var(--stair-4); --shade-ink: #000; }
.stair[data-shade="5"] { --shade: var(--stair-5); --shade-ink: #000; }
.stair[data-shade="6"] { --shade: var(--stair-6); --shade-ink: #fff; }
.stair[data-shade="7"] { --shade: var(--stair-7); --shade-ink: #fff; }
.stair[data-shade="8"] { --shade: var(--stair-8); --shade-ink: #fff; }
.stair[data-shade="9"] { --shade: var(--stair-9); --shade-ink: #fff; }
.stair[data-shade="10"] { --shade: var(--stair-10); --shade-ink: #fff; }
@media (prefers-color-scheme: dark) {
  .stair[data-shade] { --shade-ink: #1b2a4a; }
}
/* A phone on its side: the stairs three quarters the size, so the languages and Done still fit the card unscrolled */
@media (max-height: 30rem) {
  .stairs { margin: 0 0 0.5rem; font-size: 0.75em; }
  .settings .level-note { display: none; }
}

/* The book's text at the size the iPhone or iPad is set to read at (the owner reads at xxLarge), a classic's size at the
   standard one; the cards too, help no smaller than the text it helps with. After the cards' own sizes, so it wins. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  .own .pages { font: -apple-system-body; }
  .own .story { font-family: ui-serif, "New York", Georgia, serif; font-size: 1.12em; }
  /* The size the system's, the lines spaced as the site's (the shorthand would make them tight) */
  .sheet { font: -apple-system-body; line-height: 1.47; }
}

/* A PDF (public/view-pdf.js): each page of the file a page of the pager, two a screen where a TXT book has two
   columns, drawn on white as the file draws it, in the largest box its shape fits; its new words underlined over it
   in the app's red, inside the word's own box (from its type's descent to its ascent: the line sits just under the
   letters, never on the line below); a scan's text layer is drawn invisible over the picture of its print, its box's
   foot on the print's baseline or below (a font with no descent), so its line goes just under the box; the word
   tapped lit lightly, both placed as shares of the page */
main.book.pdf .paged .flow, main.book.pdf .flow { columns: auto; }
.story.pdf { display: flex; height: 100%; max-width: none; margin: 0; column-gap: inherit; }
.story.pdf > .pdf-page { flex: none; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
@media screen and (min-aspect-ratio: 5/4) and (min-width: 900px) {
  .story.pdf > .pdf-page { width: calc((100% - var(--gap, 3rem)) / 2); }
}
.pdf-sheet { position: relative; flex: none; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.pdf-sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pdf-ink, .pdf-tap { position: absolute; inset: 0; pointer-events: none; }
.pdf-ink i, .pdf-tap i { position: absolute; }
.pdf-ink i::after {
  content: "";
  position: absolute;
  top: 86%;
  left: 0;
  right: 0;
  height: 8%;
  min-height: 1px;
  border-radius: 1px;
  background: #d70015;
}
.pdf-ink i.scan::after { top: 104%; }
.pdf-tap.tapped i { background: rgba(120, 120, 128, 0.25); border-radius: 0.15em; }
/* The page number between the turns, a box to type a page in when tapped */
.reader-bar .page-number { min-height: 2.75rem; padding: 0 0.75rem; background: none; color: var(--ink2); font-weight: 400; }
.reader-bar .page-input { width: 5rem; min-height: 2.75rem; padding: 0 0.5rem; border: 1px solid var(--line); border-radius: 0.5rem;
  background: var(--bg); color: var(--ink); font: inherit; text-align: center; }

/* My Words: a word over its meaning, never beside it, each the card's button */
.words .list { max-width: 36rem; margin: 0 auto; }
.words .keep { margin: 1rem 0 2rem; }
.words .keep p { margin: 0 0 0.75rem; }
.words .nudge:empty { display: none; }
.words .back-status:empty { display: none; }
.words .save-hint, .words .back-status, .words .empty p:not(:first-child) { color: var(--ink2); }
.words .empty .empty-title { color: var(--ink); font-size: 1.25rem; font-weight: 600; }
.words .empty p { margin: 0 0 0.5rem; }
.words ul { margin: 0; padding: 0; list-style: none; }
.words li button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 0.625rem 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-weight: 400;
  text-align: left;
}
.words li strong { font-size: 1.125rem; }
.words li span { color: var(--ink2); }
.words .known summary { padding: 0.5625rem 0; color: var(--ink); cursor: pointer; }
.words .known summary h2 { display: inline; margin: 0; }
.words h2 { margin: 1.5rem 0 0.5rem; font-size: 1.25rem; }
.words .reader-top .back { background: none; padding: 0 0.5rem 0 0; font-weight: 400; color: var(--green); }
button.link { min-height: 2.75rem; padding: 0; background: none; color: var(--green); font-weight: 400; }
button.stair:disabled { cursor: default; }
/* My Words' Flashcards at the top right, as the app's Word List has it */
.words .reader-top .to-cards { grid-row: 1; grid-column: -2 / -1; justify-self: end; padding: 0 0 0 0.5rem; background: none;
  color: var(--green); font-weight: 400; }

/* Flashcards (the app's FlashcardsView): the card as big as the screen gives between the top row and the turns, at most
   a book page's width, its word in the book's serif type; turned over with a half turn, the side facing away hidden so
   no text is ever seen mirrored; at once where the reader asks for less motion */
main.cards:not([hidden]) { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding-bottom: 0; }
main.cards > .reader-top { padding: 0.25rem 0 0; }
.cards .cards-close { grid-row: 1; grid-column: -2 / -1; justify-self: end; display: inline-grid; place-items: center; width: 2.75rem;
  padding: 0; border-radius: 50%; color: var(--ink2); }
.cards .cards-close svg { width: 1.125rem; height: 1.125rem; }
.flashcard {
  position: relative;
  flex: 1;
  width: min(100%, 32rem);
  min-height: 16rem;
  max-height: 26rem;
  margin: 1rem auto;
  padding: 0;
  border-radius: 1.5rem;
  background: none;
  font-weight: 400;
  perspective: 75rem;
}
.flashcard .face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  overflow: auto;
  padding: 1.75rem;
  border-radius: 1.5rem;
  background: var(--card);
  box-shadow: var(--lift);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.35s ease-in-out;
}
.flashcard .back { transform: rotateY(180deg); }
.flashcard.turned .front { transform: rotateY(-180deg); }
.flashcard.turned .back { transform: rotateY(0deg); }
.fc-word { font: 600 2.5rem/1.2 ui-serif, "New York", Georgia, serif; text-align: center; overflow-wrap: anywhere; }
.fc-meaning { font-size: 1.5rem; font-weight: 600; text-align: center; }
.fc-meaning:empty { display: none; }
.fc-sentence { color: var(--ink2); text-align: center; }
.fc-sentence strong { color: var(--ink); }
.cards .reader-bar { align-self: center; justify-content: space-between; max-width: 32rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) {
  .flashcard .face { transition: none; }
}

/* The first book's vocabulary test (the app's LevelTestView): Skip at the top right, the words in columns at least
   150 px wide, each a capsule that turns green with a tick when tapped (the tick in room kept for it, so the word never
   moves) and always on one line, Continue as wide as the words in a bar that stays at the bottom */
.test .list, .test .test-foot, main.test > .reader-top { max-width: 36rem; margin: 0 auto; }
.test h1 { font-size: 1.75rem; }
.test h1:focus { outline: none; }
.test .hint { margin: 0 0 1rem; color: var(--ink2); }
.test .reader-top .skip { grid-row: 1; grid-column: -2 / -1; justify-self: end; padding: 0 0 0 0.5rem; background: none;
  color: var(--green); font-weight: 400; }
.test-words { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.375rem, 1fr)); gap: 0.5rem; }
.test-words button {
  position: relative;
  overflow: hidden;
  padding: 0.5rem 1.5rem;
  border-radius: 1.375rem;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.test-words button[aria-pressed="true"] { background: var(--green); color: var(--on-green); }
.test-words button[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.75rem;
  width: 0.3em;
  height: 0.6em;
  border: solid currentColor;
  border-width: 0 0.14em 0.14em 0;
  transform: translate(0, -60%) rotate(45deg);
}
@media (max-width: 22.4375rem) {
  .test-words button { padding-inline: 1.25rem; font-size: 0.94em; }
  .test-words button[aria-pressed="true"]::before { left: 0.5rem; }
}
.test .test-foot { position: sticky; bottom: 0; padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom)); background: var(--bg); }
.test .test-foot .go { width: 100%; }
