:root {
  --reader-width: 47rem;
  --reader-gutter: clamp(1rem, 5.4vw, 2.75rem);
  --reader-dock-height: calc(5.9rem + env(safe-area-inset-bottom, 0px));
  background: #e6e6ee;
  color: #25283c;
  scroll-behavior: auto;
  scroll-padding-block: 1rem var(--reader-dock-height);
}

:root:has(.reader-shell[data-paper="white"]) { background: #e9e9e6; }
:root:has(.reader-shell[data-paper="dim"]) { background: #171926; }
:root:has(.reader-shell[data-reader-mode="knights"][data-paper="paper"]) { background: #ede4ec; }
:root:has(.reader-shell[data-reader-mode="vespers"][data-paper="paper"]) { background: #e7e3ef; }

body { margin: 0; }

.reader-shell {
  --reader-text-size: 1.5rem;
  --paper: #fdfaf5;
  --panel: #f2f2f8;
  --ink: #25283c;
  --muted: #54556c;
  --accent: #30477d;
  --rubric: #793b54;
  --rule: #c9c3c4;
  --control: #6b728d;
  --button-paper: #fffdf9;
  --selected-ink: #fffdf9;
  --cover: #f4f6fd;
  --cover-note: #4c5178;
  --season: #dee7fa;
  --season-ink: #2b3f70;
  --azure: #e0eafa;
  --blue: #e5e4f5;
  --gold: #f7e6c8;
  --rose: #f3dfeb;
  --violet: #eee2f6;
  --azure-ink: #415e9b;
  --blue-ink: #585b91;
  --gold-ink: #866021;
  --rose-ink: #884360;
  --violet-ink: #745284;
  --tint-rule: #78718b;
  --ui-font: system-ui, sans-serif;
  --reading-font: Georgia, "Noto Serif", "Times New Roman", serif;
  box-sizing: border-box;
  max-inline-size: var(--reader-width);
  min-block-size: 100vh;
  min-block-size: 100dvh;
  margin-inline: auto;
  background: var(--paper);
  color: var(--ink);
  font: var(--reader-text-size)/1.58 var(--reading-font);
  overflow-wrap: anywhere;
}

.reader-shell[data-reader-mode="mass"][data-paper="paper"]:is([data-liturgical-color="white"], [data-liturgical-color="gold"]) {
  --cover: #fff8eb;
  --season: #f3dfb5;
  --season-ink: #67491e;
}

.reader-shell[data-reader-mode="mass"][data-paper="paper"][data-liturgical-color="red"] {
  --cover: #fcf0f1;
  --season: #f3dce4;
  --season-ink: #743b53;
}

.reader-shell[data-reader-mode="mass"][data-paper="paper"]:is([data-liturgical-color="violet"], [data-liturgical-color="purple"]) {
  --cover: #f6f0fa;
  --season: #eadcf3;
  --season-ink: #614275;
}

.reader-shell[data-reader-mode="mass"][data-paper="paper"]:is([data-liturgical-color="rose"], [data-liturgical-color="pink"]) {
  --cover: #fff0f5;
  --season: #f6dce9;
  --season-ink: #773f60;
}

.reader-shell[data-reader-mode="mass"][data-paper="paper"][data-liturgical-color="black"] {
  --cover: #f2f1f7;
  --season: #e4e1eb;
  --season-ink: #414052;
}

.reader-shell[data-reader-mode="knights"][data-paper="paper"] {
  --panel: #f4eef5;
  --accent: #594269;
  --rubric: #743d56;
  --cover: #f9f1f8;
  --cover-note: #5f486c;
  --season: #f4e2c8;
  --season-ink: #624721;
}

.reader-shell[data-reader-mode="vespers"][data-paper="paper"] {
  --panel: #f0edf7;
  --accent: #414579;
  --rubric: #734360;
  --cover: #f3eff9;
  --cover-note: #53486e;
  --season: #e9dff4;
  --season-ink: #48376b;
}

.reader-shell[data-paper="white"] {
  --paper: #fff;
  --panel: #f0f0ee;
  --ink: #111;
  --muted: #414141;
  --accent: #292929;
  --rubric: #353535;
  --rule: #898983;
  --control: #464641;
  --button-paper: #fff;
  --selected-ink: #fff;
  --cover: #fff;
  --cover-note: #454545;
  --season: #dedede;
  --season-ink: #202020;
  --azure: #ededed;
  --blue: #e3e3e3;
  --gold: #ebebeb;
  --rose: #dfdfdf;
  --violet: #e9e9e9;
  --azure-ink: #4b4b4b;
  --blue-ink: #4f4f4f;
  --gold-ink: #555;
  --rose-ink: #454545;
  --violet-ink: #4d4d4d;
  --tint-rule: #727272;
}

.reader-shell[data-paper="dim"] {
  --paper: #222334;
  --panel: #2c2d42;
  --ink: #faf2e7;
  --muted: #d0cadd;
  --accent: #b7c9fc;
  --rubric: #f0b9d1;
  --rule: #777184;
  --control: #a39bb0;
  --button-paper: #27283c;
  --selected-ink: #202137;
  --cover: #282b44;
  --cover-note: #ddd3ef;
  --season: #3d486c;
  --season-ink: #edf1ff;
  --azure: #343f60;
  --blue: #3f3c5e;
  --gold: #51402e;
  --rose: #523546;
  --violet: #49395b;
  --azure-ink: #c6d4ff;
  --blue-ink: #c8c6f5;
  --gold-ink: #f3d6a4;
  --rose-ink: #f1bcd5;
  --violet-ink: #ddc6f6;
  --tint-rule: #a69bb5;
  color-scheme: dark;
}

.reader-shell[data-reader-mode="knights"][data-paper="dim"] {
  --cover: #30263d;
  --season: #52402d;
  --season-ink: #f6debe;
}

.reader-shell *,
.reader-shell *::before,
.reader-shell *::after { box-sizing: inherit; }

.reader-shell [hidden],
.reader-shell [role="status"]:empty { display: none !important; }

.reader-shell:has(.reader-turn-controls:not([hidden])) {
  padding-block-end: var(--reader-dock-height);
}

.reader-shell a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.reader-shell :focus-visible {
  outline: 3px solid var(--rubric);
  outline-offset: 3px;
}

.reader-shell .skip {
  position: absolute;
  z-index: 2;
  inset-block-start: 0.5rem;
  padding: 0.6rem;
  background: var(--paper);
  color: var(--ink);
  font: 700 1rem/1.3 var(--ui-font);
}

.reader-shell .skip:not(:focus) {
  inline-size: 1px;
  block-size: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}

.reader-masthead {
  display: grid;
  align-items: center;
  gap: 0.18rem 1rem;
  padding: 0.15rem var(--reader-gutter) 0.65rem;
  border-block-end: 1px solid var(--rule);
  background: var(--paper);
}

.reader-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 44px;
  justify-self: start;
  color: var(--accent);
  font: 700 1.4rem/1.15 var(--reading-font);
  text-decoration: none;
}

.reader-brand::before {
  flex: none;
  inline-size: 0.72rem;
  block-size: 0.72rem;
  background: var(--gold-ink);
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 61%, 50% 100%, 38% 61%, 0 50%, 38% 38%);
  content: "";
}

.reader-modes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 0.45rem;
}

.reader-modes a {
  display: grid;
  min-block-size: 44px;
  place-items: center;
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
  background: var(--button-paper);
  color: var(--ink);
  text-align: center;
  font: 650 1rem/1.2 var(--ui-font);
  text-decoration: none;
}

.reader-modes a[aria-current="page"] {
  border-block-end: 3px solid var(--season-ink);
  background: var(--season);
  color: var(--season-ink);
  font-weight: 780;
}

@media (min-width: 39rem) {
  .reader-masthead { grid-template-columns: minmax(0, 1fr) minmax(17rem, 3fr); }
}

.reader-settings {
  padding-inline: var(--reader-gutter);
  border-block-end: 1px solid var(--rule);
  background: var(--paper);
  font: 1rem/1.5 var(--ui-font);
}

.reader-settings summary {
  min-block-size: 44px;
  padding-block: 0.65rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.reader-settings-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem 0.85rem;
  padding-block: 0.25rem 1rem;
}

.reader-settings-panel label,
.reader-text-controls { min-inline-size: 0; }

.reader-settings-panel label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 44px;
  font-weight: 600;
}

.reader-text-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.reader-shell button,
.reader-shell select,
.reader-shell .action,
.reader-shell .reader-action,
.reader-turn-controls a {
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--control);
  border-radius: 0.25rem;
  background: var(--button-paper);
  color: var(--ink);
  font: 700 1rem/1.25 var(--ui-font);
}

.reader-shell button,
.reader-shell select { cursor: pointer; }

.reader-shell .action,
.reader-shell .reader-action,
.reader-turn-controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.reader-shell .reader-resume {
  margin: 0.8rem var(--reader-gutter) 0;
}

.reader-shell button:disabled {
  border-color: var(--rule);
  background: var(--panel);
  color: var(--muted);
  cursor: default;
}

.reader-shell input[type="checkbox"] {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
}

.reader-shell textarea {
  inline-size: 100%;
  min-block-size: 8rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--control);
  border-radius: 0.25rem;
  background: var(--button-paper);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.reader-help,
.reader-settings-panel > p,
.reader-shell [data-reader-wake-status] {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font: 0.98rem/1.55 var(--ui-font);
}

.reader-shell .masthead {
  padding: clamp(1rem, 2.7vw, 1.6rem) var(--reader-gutter) 1.25rem;
  border-block-end: 1px solid var(--rule);
  background: var(--cover);
  color: var(--ink);
}

.reader-shell .masthead h1 {
  max-inline-size: 24ch;
  margin: 0.12em 0 0.24em;
  font-size: clamp(1.92rem, 6.15vw, 3.3rem);
  line-height: 1.08;
  text-wrap: balance;
}

.reader-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

.reader-cover-copy {
  grid-row: 2;
  min-inline-size: 0;
}

.reader-cover-actions {
  grid-row: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 0.45rem;
}

.reader-hero-art {
  grid-row: 1;
  display: grid;
  place-items: center;
  inline-size: 100%;
  min-inline-size: 0;
  block-size: clamp(5.5rem, 23vw, 9.25rem);
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--gold-ink);
  border-radius: 0.25rem;
  background: var(--season);
}

.reader-cover-image {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  object-fit: cover;
}

.reader-shell[data-paper="white"] .reader-cover-image { filter: grayscale(1); }
.reader-shell[data-paper="dim"] .reader-cover-image { filter: brightness(0.67) saturate(0.64); }

.reader-hero-art:has(.reader-art-frame) {
  padding: 0.4rem;
}

.reader-art-frame {
  position: relative;
  display: grid;
  grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr));
  gap: 3px;
  inline-size: 3.8rem;
  block-size: 100%;
  overflow: hidden;
  border: 2px solid var(--gold-ink);
  border-radius: 50% 50% 0.12rem 0.12rem / 28% 28% 0.12rem 0.12rem;
}

.reader-art-frame i:nth-child(1) { background: var(--gold); }
.reader-art-frame i:nth-child(2) { background: var(--blue); }
.reader-art-frame i:nth-child(3) { background: var(--rose); }
.reader-art-frame i:nth-child(4) { background: var(--azure); }

.reader-art-frame::after {
  position: absolute;
  inset: 14% 14% 12%;
  background: var(--accent);
  clip-path: polygon(41% 0, 59% 0, 59% 30%, 100% 30%, 100% 44%, 59% 44%, 59% 100%, 41% 100%, 41% 44%, 0 44%, 0 30%, 41% 30%);
  content: "";
}

[data-reader-mode="knights"] .reader-art-frame {
  border: 0;
  border-radius: 0;
  clip-path: polygon(0 0, 100% 0, 100% 62%, 87% 77%, 50% 100%, 13% 77%, 0 62%);
}

[data-reader-mode="knights"] .reader-art-frame i:nth-child(2) { background: var(--violet); }
[data-reader-mode="knights"] .reader-art-frame i:nth-child(3) { background: var(--blue); }
[data-reader-mode="knights"] .reader-art-frame i:nth-child(4) { background: var(--gold); }
[data-reader-mode="knights"] .reader-art-frame::after { inset: 13% 15% 22%; }

@media (max-width: 23rem) {
  .reader-shell .masthead h1 { font-size: 1.7rem; }
}

.reader-shell .eyebrow,
.reader-shell .posture,
.reader-shell .subgroup,
.reader-shell .role-label,
.reader-shell .section-number {
  margin: 0 0 0.32rem;
  color: var(--rubric);
  font: 750 0.925rem/1.3 var(--ui-font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reader-shell .date {
  margin-block: 0.2rem 0.25rem;
  color: var(--muted);
  font: 650 1rem/1.4 var(--ui-font);
}

.reader-shell .masthead .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.44rem;
  color: var(--accent);
}

.reader-shell .masthead .eyebrow::after {
  flex: none;
  inline-size: 1.75rem;
  block-size: 1px;
  background: var(--gold-ink);
  content: "";
}

.reader-shell .facts {
  margin-block: 0.32rem 0;
  color: var(--cover-note);
  font: 1rem/1.5 var(--ui-font);
}

.reader-liturgical-color {
  display: inline-block;
  margin-inline-end: 0.25rem;
  padding: 0.12em 0.48em;
  border: 1px solid var(--rule);
  border-radius: 0.2em;
  background: var(--season);
  color: var(--season-ink);
  font-weight: 750;
}

.reader-shell .reader-save,
.reader-shell #offline-status {
  margin: 0;
  color: var(--cover-note);
  font: 650 1rem/1.5 var(--ui-font);
}

.reader-cover-actions .reader-save:has(> button[hidden]) { display: none; }

.reader-cover-actions .reader-save #offline-status { margin-block-start: 0.35rem; }

.reader-shell .masthead .action {
  border-color: var(--control);
  background: var(--button-paper);
  color: var(--accent);
}

.reader-shell .masthead .reader-start {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--selected-ink);
}

.reader-shell .masthead button:disabled {
  border-color: var(--cover-note);
  color: var(--cover-note);
}

.reader-shell .masthead :focus-visible { outline-color: var(--cover-note); }
.reader-shell .masthead p:has(.action) { margin-block: 0.85rem 0; }
.reader-shell .masthead p:has(.action[hidden]) { display: none; }

.vespers-intro {
  margin: 1rem var(--reader-gutter);
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--rule);
  border-inline-start: 3px solid var(--gold-ink);
  border-radius: 0.25rem;
  background: var(--panel);
  font: 1.125rem/1.5 var(--ui-font);
}

.vespers-intro p { margin: 0; }
.vespers-intro p + p { margin-block-start: 0.45rem; }
.vespers-intro p:has(a) { line-height: 1.35; }

.vespers-intro a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  font-weight: 650;
}

.reader-shell .navigation {
  padding: 0.95rem var(--reader-gutter) 1.25rem;
  border-block-end: 1px solid var(--rule);
  background: var(--paper);
}

.reader-shell .navigation p {
  margin: 0 0 0.62rem;
  color: var(--accent);
  font-size: 1.36rem;
  line-height: 1.35;
}

.reader-shell .navigation ol,
.reader-shell .navigation ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reader-shell .navigation li { min-inline-size: 0; }

.reader-shell :is([data-reader-tint="azure"], [data-reader-tint="sage"]) {
  --section-tint: var(--azure);
  --section-ink: var(--azure-ink);
}

.reader-shell [data-reader-tint="slate"] {
  --section-tint: var(--blue);
  --section-ink: var(--blue-ink);
}

.reader-shell [data-reader-tint="ochre"] {
  --section-tint: var(--gold);
  --section-ink: var(--gold-ink);
}

.reader-shell [data-reader-tint="berry"] {
  --section-tint: var(--rose);
  --section-ink: var(--rose-ink);
}

.reader-shell [data-reader-tint="plum"] {
  --section-tint: var(--violet);
  --section-ink: var(--violet-ink);
}

.reader-shell .navigation a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.44rem;
  min-block-size: 49px;
  block-size: 100%;
  padding: 0.5rem 0.72rem;
  border: 1px solid var(--rule);
  border-block-start: 3px solid var(--section-ink, var(--accent));
  border-radius: 0.3rem;
  background: var(--section-tint, var(--panel));
  color: var(--ink);
  font: 730 1rem/1.3 var(--ui-font);
  text-decoration: none;
}

.reader-shell .navigation a::after {
  flex: none;
  inline-size: 0.44rem;
  block-size: 0.44rem;
  border-block-start: 2px solid currentColor;
  border-inline-end: 2px solid currentColor;
  transform: rotate(45deg);
  content: "";
}

@media (min-width: 36rem) {
  .reader-shell .navigation ol,
  .reader-shell .navigation ul { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .reader-shell:is([data-reader-mode="knights"], [data-reader-mode="vespers"]) .navigation ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.reader-shell .mass-section,
.reader-shell .reader-section {
  padding: 1.4rem var(--reader-gutter) 1.35rem;
  border-block-end: 1px solid var(--rule);
}

.reader-shell .section-number {
  display: inline-block;
  min-inline-size: 1.85rem;
  margin: 0 0 0.25rem;
  padding: 0.16rem 0.42rem;
  border: 1px solid var(--section-ink, var(--accent));
  border-radius: 50%;
  color: var(--section-ink, var(--accent));
  text-align: center;
}

.reader-shell .mass-section h2,
.reader-shell .reader-section h2 {
  position: relative;
  margin: 0.12em 0 0.55em;
  padding-block-end: 0.35em;
  border-block-end: 1px solid var(--rule);
  color: var(--ink);
  font-size: clamp(1.65rem, 5.7vw, 2.4rem);
  line-height: 1.22;
}

.reader-shell .mass-section h2::after,
.reader-shell .reader-section h2::after {
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: -1px;
  inline-size: 3.25rem;
  block-size: 2px;
  background: var(--section-ink, var(--gold-ink));
  content: "";
}

.mass-section-art {
  inline-size: 100%;
  max-inline-size: 40rem;
  margin: 0 auto 0.75rem;
  padding: 0.22rem;
  border: 1px solid var(--section-ink, var(--gold-ink));
  border-radius: 0.25rem;
}

.mass-section-art img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 8 / 3;
  border-radius: 0.1rem;
}

.reader-shell[data-paper="white"] .mass-section-art img { filter: grayscale(1); }
.reader-shell[data-paper="dim"] .mass-section-art img { filter: brightness(0.67) saturate(0.64); }

@media (orientation: landscape) and (max-height: 540px) {
  .mass-section-art { max-inline-size: 19rem; }
}

.reader-shell .order-item,
.reader-shell .reading { padding-block: 1.05rem; }

.reader-shell .order-item + .order-item,
.reader-shell .reading + .reading { border-block-start: 1px solid var(--rule); }

.reader-shell .order-item h3,
.reader-shell .reading h5,
.reader-shell .reader-section h3 {
  margin: 0 0 0.48em;
  font-size: 1.18em;
  line-height: 1.27;
}

.reader-shell .posture {
  display: inline-block;
  padding: 0.22rem 0.38rem;
  border: 1px solid var(--gold-ink);
  border-radius: 0.16rem;
  color: var(--gold-ink);
  letter-spacing: 0.07em;
}

.reader-shell .subgroup { color: var(--muted); }

.reader-shell .line {
  padding: 0.56rem 0.68rem;
  border-inline-start: 2px solid var(--rule);
}

.reader-shell .line + .line { margin-block-start: 0.28rem; }
.reader-shell .line p:last-child { margin: 0; }
.reader-shell .line .role-label { color: var(--muted); }

.reader-shell .role-people,
.reader-shell .role-all {
  border-inline-start: 3px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.reader-shell .role-people .role-label,
.reader-shell .role-all .role-label { color: var(--accent); }

.reader-shell .role-rubric {
  border-inline-start-color: var(--rubric);
  background: transparent;
  color: var(--ink);
  font-style: italic;
}

.reader-shell .role-rubric .role-label {
  color: var(--rubric);
  font-style: normal;
}

.reader-shell .citation,
.reader-shell .segment-reference {
  margin-block: 0 0.75rem;
  color: var(--accent);
  font: 700 1rem/1.45 var(--ui-font);
}

.reader-shell .reading-text,
.reader-shell .prayer-text { margin-block: 0.8rem; }

.reader-shell .reading .citation {
  display: inline-block;
  padding-block-end: 0.18em;
  border-block-end: 1px solid var(--azure-ink);
  color: var(--accent);
}

.reader-shell .reading-gospel .citation {
  border-block-end-color: var(--rubric);
  color: var(--rubric);
}

.reader-shell .reading-gospel .reading-text {
  padding-inline-start: 0.65rem;
  border-inline-start: 2px solid var(--gold-ink);
}

.reader-shell blockquote.reading-text {
  margin-inline: 0;
  padding: 0.62rem 0.75rem;
  border-inline-start: 2px solid var(--gold-ink);
  color: var(--ink);
}

.reader-shell .reading-text p,
.reader-shell .prayer-text p { margin-block: 0.65em; }

.reader-shell .cue {
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid var(--rubric);
  color: var(--rubric);
  font-style: italic;
}

.reader-shell[data-reader-mode="vespers"] details.order-item summary {
  min-block-size: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  font: 700 1.05rem/1.4 var(--ui-font);
}

.reader-shell[data-reader-mode="vespers"] details.order-item[open] summary { margin-block-end: 0.65rem; }

#knights-intentions-hint,
.reader-shell [data-reader-notes-status] {
  color: var(--muted);
  font: 1rem/1.5 var(--ui-font);
}

.reader-shell .back {
  margin-block: 1rem 0;
  font: 650 1rem/1.5 var(--ui-font);
}

.reader-shell .back a,
.reader-shell .finale a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

.reader-shell .finale {
  padding: 1rem var(--reader-gutter) 1.4rem;
  border-block-start: 3px double var(--tint-rule);
  background: var(--paper);
  color: var(--accent);
}

.reader-shell .finale p { margin-block: 0.35rem; }
.reader-shell .finale a { font: 680 1rem/1.4 var(--ui-font); }

.reader-turn-controls {
  position: fixed;
  z-index: 1;
  inset-inline: 0;
  inset-block-end: 0;
  max-inline-size: var(--reader-width);
  margin-inline: auto;
  padding: 0.35rem var(--reader-gutter) calc(0.55rem + env(safe-area-inset-bottom, 0px));
  border-block-start: 2px solid var(--section-ink, var(--gold-ink));
  background: var(--paper);
}

.eink-follow-mount {
  margin-block-end: 0.35rem;
  font: 650 0.9rem/1.35 var(--ui-font);
}

.eink-follow-mount button {
  min-block-size: 44px;
  padding: 0.3rem 0.6rem;
  font-size: 0.9rem;
}

.eink-follow-mount [data-eink-follow-load],
.eink-follow-mount .eink-follow-start,
.eink-follow-mount .eink-follow-primary {
  border-color: var(--accent);
  color: var(--accent);
}

.eink-follow-row,
.eink-follow-actions,
.eink-follow-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
}

.eink-follow-row { justify-content: space-between; }
.eink-follow-status { min-inline-size: 0; }
.eink-follow-status > strong,
.eink-follow-status > span { display: block; }
.eink-follow-status > span { color: var(--muted); font-size: 0.82rem; }
.eink-follow-load-status { margin: 0.15rem 0; }
.eink-follow-load-status { color: var(--muted); }

.eink-follow-dialog {
  box-sizing: border-box;
  inline-size: min(30rem, calc(100% - 1.5rem));
  max-block-size: calc(100dvh - 2rem);
  padding: clamp(0.9rem, 4vw, 1.4rem);
  border: 2px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--ui-font);
}

.eink-follow-dialog::backdrop { background: #171c2b99; }

.eink-follow-dialog h2 {
  margin: 0 0 0.45rem;
  font: 700 1.45rem/1.2 var(--reading-font);
}

.eink-follow-dialog-actions { justify-content: end; }

.eink-follow-dialog .eink-follow-primary {
  background: var(--accent);
  color: var(--selected-ink);
}

.eink-follow-target-active {
  text-decoration: underline;
  text-decoration-color: var(--section-ink, var(--accent));
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
}

.reader-folio {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.42rem;
  margin-block-end: 0.2rem;
}

.reader-running-section {
  min-inline-size: 0;
  margin: 0;
  overflow: hidden;
  color: var(--section-ink, var(--accent));
  font: 750 0.86rem/1.35 var(--ui-font);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-page-number {
  margin: 0 0 0.22rem;
  color: var(--muted);
  font: 650 0.89rem/1.28 var(--ui-font);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.reader-folio .reader-page-number {
  flex: none;
  margin: 0;
}

.reader-turn-inner {
  display: grid;
  grid-template-areas: "previous contents next";
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.25rem, 1.3vw, 0.5rem);
}

.reader-shell[data-hand="left"] .reader-turn-inner {
  grid-template-areas: "next contents previous";
}

.reader-turn-inner [data-reader-action="prev"] { grid-area: previous; }
.reader-turn-inner [data-reader-action="next"] { grid-area: next; }
.reader-turn-inner a { grid-area: contents; }

.reader-turn-controls [data-reader-action="next"]:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--selected-ink);
}

.reader-turn-controls button,
.reader-turn-controls a {
  min-inline-size: 0;
  min-block-size: 48px;
  padding-inline: 0.32rem;
  text-align: center;
}

@media (orientation: landscape) and (max-height: 540px) {
  :root { --reader-dock-height: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  .reader-masthead { grid-template-columns: minmax(0, 1fr) minmax(15rem, 2.5fr); padding-block: 0.24rem; }
  .reader-shell .masthead { padding-block: 1rem; }
  .reader-cover { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .reader-cover-copy { grid-column: 1; grid-row: 1; }
  .reader-cover-actions { grid-column: 1; grid-row: 2; }
  .reader-hero-art { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .reader-turn-controls { padding-block-start: 0.22rem; }
}
