:root {
  color-scheme: light;
  --blue: #0366d6;
  --blue-dark: #0456b1;
  --ink: #20252b;
  --muted: #657387;
  --line: #c7d8eb;
  --chrome: #e8f2ff;
  --text-scale: 1;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); background: #f3f6fa; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; min-height: 34px; padding: 7px 11px;
  color: var(--ink); background: #ffffffd9; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; font-weight: 550; line-height: 1.25;
  white-space: nowrap; cursor: pointer; touch-action: manipulation;
}
button:hover:not(:disabled) { color: var(--blue); border-color: #93b8e4; background: #fff; }
button:disabled { color: #96a3b3; border-color: #cfdbeb; background: #ffffff66; cursor: default; }
button.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
button.primary:hover:not(:disabled) { color: #fff; border-color: var(--blue-dark); background: var(--blue-dark); }
button.primary:disabled { color: #96a3b3; background: #dce7f3; border-color: var(--line); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
a { color: var(--blue); text-underline-offset: .14em; }
a:hover { text-decoration-thickness: 2px; }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reader-shell {
  width: 100%; max-width: 980px; height: 100vh; height: 100dvh;
  margin: 0 auto; display: flex; flex-direction: column;
  background: #fff; border-inline: 1px solid #d8e3ef;
}
.reader-header {
  flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand title" "commands tools";
  align-items: center; gap: 15px 12px;
  padding: max(14px, env(safe-area-inset-top, 0px)) 20px 14px;
  background: var(--chrome); border-bottom: 1px solid #d0e1f4;
}
.reader-home { grid-area: brand; display: flex; align-items: center; justify-self: start; border-radius: 3px; }
/* Cover trims only transparent padding from the PNG, not the lettering. */
.reader-home img { display: block; width: 220px; height: 40px; object-fit: cover; object-position: center; }
.reader-title { grid-area: title; margin: 0; font-size: 16px; line-height: 1.3; font-weight: 600; text-align: right; }
.top-controls { grid-area: commands; display: flex; align-items: center; gap: 7px; min-width: 0; }
.top-controls button { flex: 0 0 auto; }
.top-controls .control-group-start { margin-left: 8px; }
.top-controls .control-group-start::after { content: ""; position: absolute; left: -9px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.reading-actions { grid-area: tools; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.text-tools { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #ffffffd9; }
.text-tools button { gap: 2px; width: 36px; min-height: 32px; padding: 5px; border: 0; border-radius: 0; background: transparent; font-size: 15px; }
.text-tools button + button { border-left: 1px solid var(--line); }
.text-tools button:focus-visible { outline-offset: -3px; }
.help-button { width: 34px; min-width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 21px; font-weight: 500; }
.reading-pane { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; scroll-padding: 24px; background: #fff; }
.reading-pane:focus-visible { outline-offset: -3px; }
.crumb { padding: 52px 64px 45px; }
.crumb-number { margin: 0; color: #435166; font-size: 18px; font-weight: 550; text-align: center; line-height: 1.4; }
.crumb-title { margin: 18px 0 34px; color: #111820; font-size: calc(40px * var(--text-scale)); font-weight: 650; text-align: center; line-height: 1.2; letter-spacing: -.022em; overflow-wrap: anywhere; }
.crumb-title[hidden] + .crumb-body { margin-top: 28px; }
.crumb-body { font-size: calc(26px * var(--text-scale)); line-height: 1.55; letter-spacing: -.012em; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.crumb-body a { text-decoration-thickness: 1px; }
.reader-footer {
  flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 16px; padding: 12px 20px max(12px, env(safe-area-inset-bottom, 0px));
  background: var(--chrome); border-top: 1px solid #d0e1f4;
}
.reading-order { display: flex; align-items: center; min-width: 0; }
.toggle-control { border-color: transparent; background: transparent; padding: 5px 3px; color: #53647b; }
.toggle-control:hover:not(:disabled) { border-color: transparent; background: #dcecff; }
.toggle-control:disabled { border-color: transparent; background: transparent; }
.toggle-control[aria-pressed="true"], .toggle-control[aria-checked="true"] { color: var(--blue); }
.random-control { gap: 9px; font-size: 12px; }
.switch-track { display: inline-flex; align-items: center; width: 34px; height: 20px; padding: 2px; border-radius: 20px; background: #aebdce; transition: background .15s; }
.switch-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #26384a26; transition: transform .15s; }
.random-control[aria-checked="true"] .switch-track { background: var(--blue); }
.random-control[aria-checked="true"] .switch-thumb { transform: translateX(14px); }
.random-icon { display: none; }
.reading-progress { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line); font-size: 11px; color: #63758c; white-space: nowrap; }
.step-controls { display: flex; gap: 9px; }
.step-controls button { min-width: 105px; min-height: 36px; font-size: 13px; }
.phone-step { display: none; }
.favorite-control { justify-self: end; gap: 8px; }
.favorite-control .icon { width: 22px; height: 22px; }
.favorite-control[aria-pressed="true"] .icon { fill: var(--blue); }
.empty-state { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; gap: 15px; text-align: center; color: var(--muted); }
.empty-state h2, .empty-state p { margin: 0; max-width: 500px; }
.empty-state h2 { color: var(--ink); font-size: 24px; }
.empty-state a { margin-top: 8px; }
.loading-mark { height: 26px; width: 26px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: turn 1s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.noscript { padding: 25px; }
dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); padding: 26px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 80px #15202e38; overflow-y: auto; }
dialog::backdrop { background: #18253570; }
dialog h2 { margin: 0 0 16px; font-size: 25px; line-height: 1.2; letter-spacing: -.025em; }
dialog p { font-size: 15px; line-height: 1.55; }
dialog button { min-height: 40px; }
dialog .wide { width: 100%; margin-top: 10px; }
dialog input[type="text"], dialog input[type="number"] { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #aeb9c4; border-radius: 6px; font-size: 16px; color: var(--ink); background: #fff; }
.field-label { display: block; margin: 16px 0 8px; font-size: 14px; font-weight: 600; }
dialog .dialog-note { margin: 9px 0 0; font-size: 13px; color: var(--muted); }
.dialog-divider { height: 1px; margin-top: 22px; background: var(--line); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.field-error { color: #20252b; border-left: 3px solid var(--blue); padding-left: 10px; }
.favorites-dialog { width: min(600px, calc(100% - 32px)); }
.favorites-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow: auto; }
.favorites-list a { display: block; padding: 13px 10px; border-bottom: 1px solid var(--line); text-decoration: none; }
.favorites-list a:hover { background: #f1f7ff; }
.favorites-list span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.favorites-list strong { font-size: 16px; font-weight: 600; }
.favorites-list a[aria-current="page"] { background: #f1f7ff; }
.help-dialog { width: min(650px, calc(100% - 32px)); }
.help-content { max-height: 55vh; max-height: 55dvh; overflow: auto; overscroll-behavior: contain; padding: 3px 12px 3px 3px; }
.help-list { margin: 0; font-size: 14px; line-height: 1.55; }
.help-list dt { display: flex; align-items: center; gap: 9px; margin-top: 17px; font-weight: 650; color: var(--blue); }
.help-list dt:first-child { margin-top: 0; }
.help-icons { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; min-height: 24px; }
.help-icons .icon { width: 20px; height: 20px; }
.help-wordmark { display: block; width: 74px; height: 15px; object-fit: cover; object-position: center; }
.help-label { min-width: 0; overflow-wrap: anywhere; }
.help-key { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 3px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--chrome); font-size: 13px; font-weight: 550; line-height: 1; }
.help-question { min-width: 24px; padding: 0; border-radius: 50%; font-size: 18px; }
.help-list dd { margin: 5px 0 0; }
.control-hint { position: fixed; z-index: 1000; width: max-content; max-width: min(320px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; margin: 0; padding: 10px 13px; color: #fff; background: #27374b; border-radius: 6px; box-shadow: 0 4px 16px #0003; font-size: 13px; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); width: max-content; max-width: min(600px, calc(100% - 32px)); transform: translateX(-50%); padding: 12px 18px; color: #fff; background: #203d62; box-shadow: 0 3px 14px #0002; border-radius: 7px; font-size: 14px; line-height: 1.5; text-align: center; pointer-events: none; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 20; padding: 12px; background: #fff; }
@media (max-width: 900px) and (min-width: 801px) {
  .reader-header { padding-inline: 14px; column-gap: 9px; }
  .top-controls { gap: 5px; }
  .top-controls button { padding-inline: 8px; font-size: 12px; gap: 5px; }
  .reading-progress { margin-left: 8px; padding-left: 8px; font-size: 10px; }
  .reader-footer { padding-inline: 14px; gap: 10px; }
}
@media (max-width: 800px), (max-height: 500px) {
  body { background: #fff; }
  .reader-shell { border: 0; }
  .reader-header {
    grid-template-areas: "brand tools" "title tools" "commands commands";
    grid-template-columns: minmax(0, 1fr) auto; gap: 0 9px;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 4px max(12px, env(safe-area-inset-left, 0px));
  }
  .reader-home img { width: 150px; height: 28px; }
  .reader-title { font-size: 10.5px; font-weight: 550; line-height: 14px; text-align: left; white-space: nowrap; }
  .reading-actions { align-self: center; gap: 8px; }
  .text-tools button { width: 30px; min-height: 28px; font-size: 13px; }
  .help-button { width: 30px; min-width: 30px; height: 30px; min-height: 30px; font-size: 19px; }
  .top-controls { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 2px; }
  .top-controls button { min-width: 0; height: 42px; min-height: 42px; padding: 0; border: 0; border-radius: 5px; background: transparent; }
  /* The visible button is compact; its surrounding slot remains a touch target. */
  .top-controls button::before { content: ""; position: absolute; inset: 5px 2px; border: 1px solid var(--line); border-radius: 5px; background: #ffffffc7; }
  .top-controls button:disabled::before { background: #ffffff66; border-color: #cfdbeb; }
  .top-controls button:hover:not(:disabled)::before { background: #fff; border-color: #93b8e4; }
  .top-controls .control-group-start { margin-left: 0; }
  .top-controls .control-group-start::after { display: none; }
  .top-controls .icon { position: relative; width: 18px; height: 18px; }
  .top-controls .control-label, .reader-footer .control-label, .reading-progress { display: none; }
  .reading-pane { scrollbar-gutter: auto; }
  .crumb { padding: 26px max(22px, env(safe-area-inset-right, 0px)) 32px max(22px, env(safe-area-inset-left, 0px)); }
  .crumb-number { font-size: 15px; line-height: 1.4; }
  .crumb-title { font-size: calc(32px * var(--text-scale)); margin: 15px 0 25px; }
  .crumb-body { font-size: calc(22px * var(--text-scale)); line-height: 1.5; }
  /* The viewport fits within the safe area; keep the control band to one row. */
  .reader-footer { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: 42px; gap: 0; padding: 5px 12px; }
  .reading-order, .step-controls { display: contents; }
  .reader-footer button { justify-self: center; width: 40px; min-width: 40px; height: 42px; min-height: 42px; padding: 0; }
  .reader-footer .toggle-control { border: 0; border-radius: 6px; }
  .random-control .switch-track { display: none; }
  .random-icon, .phone-step { display: block; }
  .desktop-step { display: none; }
  .random-control .icon, .favorite-control .icon { width: 23px; height: 23px; }
  .step-controls button { height: 34px; min-height: 34px; align-self: center; border: 0; background: transparent; }
  .step-controls .icon { width: 22px; height: 22px; }
  .step-controls button.primary { background: var(--blue); }
  .step-controls button.primary:disabled { background: #dce7f3; }
  .random-control[aria-checked="true"], .favorite-control[aria-pressed="true"] { background: #d4e7ff; }
  .toast { bottom: 64px; padding: 10px 14px; font-size: 13px; }
  dialog { padding: 21px; }
  dialog button { min-height: 44px; }
}
@media (max-width: 350px) {
  .reader-home img { width: 140px; height: 26px; }
  .reader-title { font-size: 9.5px; }
  .reading-actions { gap: 6px; }
  .top-controls { gap: 3px; }
  .top-controls button::before { inset-inline: 1px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .reader-header { padding-top: max(4px, env(safe-area-inset-top, 0px)); }
  .reader-home img { width: 135px; height: 25px; }
  .reader-title { line-height: 12px; font-size: 9.5px; }
  .top-controls button { height: 36px; min-height: 36px; }
  .top-controls button::before { inset-block: 3px; }
  .reader-footer { grid-template-rows: 36px; padding-block: 3px; }
  .reader-footer button { height: 36px; min-height: 36px; }
  .crumb { padding-top: 18px; }
}
@media (prefers-reduced-motion: reduce) { .loading-mark { animation: none; } .switch-track, .switch-thumb { transition: none; } }
@media print {
  html, body { height: auto; background: #fff; }
  .reader-shell { height: auto; max-width: none; border: 0; }
  .reader-header, .reader-footer, dialog, .toast, .skip-link, .control-hint { display: none !important; }
  .reading-pane { overflow: visible; }
  .crumb { padding: 0; }
}
