* {
  box-sizing: border-box;
}

:root {
  --cerulean-void: #02090d;
  --cerulean-midnight: #04141b;
  --cerulean-deep: #062532;
  --cerulean-panel: rgba(4, 24, 33, 0.78);
  --cerulean-bright: #35d7ee;
  --cerulean-soft: #72eaff;
  --cerulean-ice: #eefcff;
  --cerulean-fog: rgba(238, 252, 255, 0.72);
  --cerulean-line: rgba(95, 233, 255, 0.2);
  --cerulean-line-strong: rgba(95, 233, 255, 0.44);
  --cerulean-coral: #ef795f;
}

html {
  color-scheme: dark;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--cerulean-void);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--cerulean-ice);
  background:
    radial-gradient(circle at 10% 8%, rgba(95, 233, 255, 0.09), transparent 27rem),
    radial-gradient(circle at 82% 14%, rgba(0, 143, 173, 0.14), transparent 34rem),
    linear-gradient(180deg, #010609 0%, #021015 48%, #010609 100%);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #c75635;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: 1rem;
  transform: translateY(-200%);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: #fff;
  background: #23312f;
}

.skip-link:focus {
  transform: none;
}

.library-view {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 5vw;
}

.site-header,
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.site-header {
  min-height: 96px;
  border-bottom: 1px solid rgba(35, 49, 47, 0.18);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.wordmark-mark,
.preparing-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.75rem;
  border-radius: 0.2rem 0.5rem 0.5rem 0.2rem;
  color: #f6eddc;
  background: #244b57;
  box-shadow: inset 4px 0 rgba(255, 255, 255, 0.16), 0 8px 20px rgba(35, 49, 47, 0.15);
  font-family: "Libre Baskerville", Georgia, serif;
}

.privacy-note,
.section-heading p,
.site-footer {
  color: #5c6965;
  font-size: 0.9rem;
}

.library-hero {
  display: grid;
  align-content: center;
  min-height: 56vh;
  padding: clamp(4rem, 9vw, 9rem) 0;
  border-bottom: 1px solid rgba(35, 49, 47, 0.18);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: #9a472f;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.library-hero h1 {
  max-width: 920px;
  margin-bottom: 1.5rem;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(3.2rem, 8.3vw, 8.5rem);
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 0.94;
}

.hero-copy {
  max-width: 670px;
  color: #4c5a56;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.05rem, 1.8vw, 1.45rem);
  line-height: 1.7;
}

.hero-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.8rem;
}

.hero-details span {
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(35, 49, 47, 0.18);
  border-radius: 99rem;
  color: #4c5a56;
  font-size: 0.82rem;
}

.discovery-invite {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.8fr) auto;
  align-items: end;
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(3rem, 6vw, 5.5rem) 0;
  border-bottom: 1px solid rgba(35, 49, 47, 0.18);
}

.discovery-invite h2 {
  max-width: 650px;
  margin: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1.04;
}

.discovery-invite > p {
  margin: 0;
  color: #53615d;
  line-height: 1.7;
}

.discovery-start,
.discovery-action {
  border: 0;
  border-radius: 99rem;
  font-weight: 700;
  cursor: pointer;
}

.discovery-start {
  padding: 1rem 1.35rem;
  color: #fff8e8;
  background: #244b57;
  box-shadow: 0 12px 24px rgba(36, 75, 87, 0.2);
}

.discovery-view {
  min-height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.86), transparent 28rem),
    linear-gradient(145deg, #eee7d6, #d9ceb5);
}

.discovery-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(1100px, 100%);
  margin: 0 auto;
}

.discovery-header > div {
  text-align: center;
}

.discovery-header h1 {
  margin: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 400;
}

.discovery-header .eyebrow {
  margin-bottom: 0.25rem;
}

.discovery-header > p {
  justify-self: end;
  margin: 0;
  color: #5c6965;
  font-variant-numeric: tabular-nums;
}

.discovery-main {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: calc(100dvh - 6rem);
  padding: 1rem 0;
}

.discovery-stack {
  position: relative;
  width: min(92vw, 400px);
  height: min(65dvh, 610px);
  perspective: 1400px;
}

.discovery-card {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid rgba(35, 49, 47, 0.15);
  border-radius: 1.5rem;
  background: #f8f2e5;
  box-shadow: 0 28px 65px rgba(35, 49, 47, 0.22);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  will-change: transform;
}

.discovery-card-back {
  transform: translateY(12px) scale(0.95);
  opacity: 0.62;
  pointer-events: none;
}

.discovery-cover {
  --cover: #244b57;
  --ink: #f4dba5;
  --accent: #d06d48;
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto auto;
  min-height: 0;
  padding: 10%;
  color: var(--ink);
  background: var(--cover);
  overflow: hidden;
}

.discovery-cover img,
.discovery-cover-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.discovery-cover img {
  object-fit: cover;
}

.discovery-cover-shade {
  background: linear-gradient(180deg, rgba(18, 25, 24, 0.03), rgba(18, 25, 24, 0.78));
}

.discovery-cover-title,
.discovery-cover-author,
.discovery-cover-mark {
  position: relative;
  z-index: 1;
}

.discovery-cover-title {
  grid-row: 2;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.8rem, 7vw, 3.1rem);
  line-height: 0.98;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.42);
}

.discovery-cover-author {
  grid-row: 3;
  margin-top: 0.75rem;
}

.discovery-cover-mark {
  position: absolute;
  top: 8%;
  right: 8%;
  color: var(--accent);
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 4rem;
  opacity: 0.9;
}

.discovery-copy {
  padding: 1.2rem 1.35rem 1.35rem;
}

.discovery-copy .book-kicker {
  margin-bottom: 0.35rem;
}

.discovery-copy h2 {
  margin: 0 0 0.45rem;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1.45rem;
}

.discovery-copy > p:not(.book-kicker) {
  display: -webkit-box;
  margin-bottom: 0.65rem;
  color: #53615d;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.discovery-copy > span {
  color: #69736f;
  font-size: 0.82rem;
}

.swipe-stamp {
  position: absolute;
  z-index: 3;
  top: 2rem;
  padding: 0.55rem 0.75rem;
  border: 3px solid currentColor;
  border-radius: 0.45rem;
  background: rgba(248, 242, 229, 0.9);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}

.swipe-stamp-skip {
  right: 1.5rem;
  color: #a64732;
  transform: rotate(8deg);
}

.swipe-stamp-read {
  left: 1.5rem;
  color: #28705a;
  transform: rotate(-8deg);
}

.discovery-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.3rem;
}

.discovery-action {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem;
}

.discovery-skip {
  color: #34423e;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(35, 49, 47, 0.18);
}

.discovery-open {
  color: #fff8e8;
  background: #244b57;
}

.discovery-help {
  margin: 0.75rem 0 0;
  color: #68746f;
  font-size: 0.8rem;
}

.library-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2rem);
  padding: clamp(3rem, 7vw, 6rem) 0;
  border-bottom: 1px solid var(--cerulean-line);
}

.library-tools article {
  padding: clamp(1.4rem, 4vw, 2.4rem);
  border: 1px solid var(--cerulean-line);
  border-radius: 1.25rem;
  background:
    linear-gradient(145deg, rgba(53, 215, 238, 0.06), transparent 52%),
    var(--cerulean-panel);
  box-shadow: inset 0 1px rgba(238, 252, 255, 0.06), 0 24px 60px rgba(0, 4, 9, 0.34);
}

.library-tools h2 {
  margin-bottom: 1rem;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.library-tools label:not(.import-button),
.library-tools article > p:not(.eyebrow),
#searchStatus,
#importStatus {
  color: var(--cerulean-fog);
  line-height: 1.6;
}

.library-tools label:not(.import-button) {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.search-field {
  display: flex;
  gap: 0.55rem;
}

.search-field input {
  min-width: 0;
  min-height: 50px;
  flex: 1;
  padding: 0 1rem;
  border: 1px solid var(--cerulean-line-strong);
  border-radius: 0.75rem;
  color: var(--cerulean-ice);
  background: rgba(1, 9, 13, 0.7);
}

.search-field input::placeholder {
  color: rgba(238, 252, 255, 0.46);
}

.search-field button,
.import-button,
.remove-import {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: 1px solid var(--cerulean-line-strong);
  border-radius: 0.7rem;
  color: var(--cerulean-ice);
  background: rgba(0, 143, 173, 0.16);
  font-weight: 750;
  cursor: pointer;
}

.search-field button:disabled {
  opacity: 0.42;
  cursor: default;
}

.import-button {
  margin-top: 0.3rem;
  background: linear-gradient(135deg, #007f9d, #005f78);
  box-shadow: 0 12px 28px rgba(0, 143, 173, 0.2);
}

#searchStatus,
#importStatus {
  min-height: 1.4em;
  margin: 0.8rem 0 0;
  font-size: 0.82rem;
}

.imported-section {
  padding: clamp(4rem, 8vw, 8rem) 0 0;
}

.imported-item {
  display: grid;
  align-content: start;
}

.remove-import {
  justify-self: center;
  margin-top: 1rem;
  color: var(--cerulean-fog);
  background: transparent;
  font-size: 0.78rem;
}

.pdf-page {
  display: grid;
  place-items: center;
  padding: 0.5rem;
  overflow: hidden;
}

.pdf-page canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  box-shadow: 0 8px 24px rgba(32, 28, 21, 0.18);
}

.shelf-section {
  padding: clamp(4rem, 8vw, 8rem) 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 2rem;
  margin-bottom: 3rem;
}

.section-heading h2,
.library-note h2 {
  margin-bottom: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.045em;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.4rem, 4vw, 4rem);
}

.book-card {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.book-object {
  position: relative;
  width: min(78%, 280px);
  margin: 0 auto 2.25rem;
  aspect-ratio: 0.68;
  perspective: 1200px;
  filter: drop-shadow(0 28px 24px rgba(36, 43, 41, 0.24));
  transition: transform 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.book-card:hover .book-object,
.book-card:focus-visible .book-object {
  transform: translateY(-12px) rotate(-1deg);
}

.book-cover {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12% 10%;
  border-radius: 0.35rem 0.9rem 0.9rem 0.35rem;
  color: #f4ead2;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 7%, transparent 94%, rgba(255, 255, 255, 0.12)),
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.14), transparent 35%),
    #244b57;
  box-shadow:
    inset 8px 0 rgba(255, 255, 255, 0.08),
    inset -3px 0 rgba(0, 0, 0, 0.14),
    10px 12px 0 -7px #c9bfa9,
    15px 17px 0 -9px #847a68;
  transform: rotateY(-6deg) rotateZ(1.5deg);
  transform-origin: left center;
  transition: transform 430ms cubic-bezier(0.2, 0.75, 0.2, 1);
  overflow: hidden;
}

.cover-art,
.cover-shade {
  position: absolute;
  inset: 0;
}

.cover-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.8) contrast(0.9);
}

.cover-shade {
  background: linear-gradient(180deg, rgba(20, 22, 18, 0.22), rgba(20, 22, 18, 0.7));
}

.book-cover > :not(.cover-art, .cover-shade) {
  position: relative;
  z-index: 1;
}

.book-card:hover .book-cover,
.book-card:focus-visible .book-cover {
  transform: rotateY(-18deg) rotateZ(0);
}

.cover-rule {
  width: 100%;
  height: 2px;
  background: #d06d48;
}

.cover-title {
  align-self: center;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.1rem, 2.3vw, 2.1rem);
  line-height: 1.15;
}

.cover-author {
  margin: 0;
  font-size: clamp(0.68rem, 1.1vw, 0.86rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cover-mark {
  position: absolute;
  right: 9%;
  bottom: 8%;
  color: #d06d48;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(3.8rem, 8vw, 7rem);
  font-style: italic;
  line-height: 0.75;
  opacity: 0.8;
}

.book-card-copy {
  border-top: 1px solid rgba(35, 49, 47, 0.2);
  padding-top: 1.2rem;
}

.book-kicker {
  margin-bottom: 0.5rem;
  color: #7a4c3d;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.book-card h3 {
  min-height: 2.5em;
  margin: 0 0 0.5rem;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1.25;
}

.book-meta {
  margin-bottom: 0.9rem;
  color: #63706c;
  font-size: 0.86rem;
}

.book-progress {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #45534f;
  font-size: 0.8rem;
}

.book-progress-track {
  flex: 1;
  height: 3px;
  overflow: hidden;
  background: rgba(35, 49, 47, 0.16);
}

.book-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #c75635;
}

.library-note {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 1fr;
  gap: 2rem;
  padding: clamp(3rem, 7vw, 7rem) 0;
  border-top: 1px solid rgba(35, 49, 47, 0.18);
}

.library-note p:last-child {
  color: #53615d;
  font-family: "Libre Baskerville", Georgia, serif;
  line-height: 1.75;
}

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid rgba(35, 49, 47, 0.18);
}

.site-footer p {
  margin: 0;
}

.reader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 100svh;
  overflow: hidden;
  color: var(--cerulean-ice);
  background-color: var(--cerulean-void);
  background-image:
    radial-gradient(circle at 50% 18%, rgba(53, 215, 238, 0.16), transparent 42rem),
    radial-gradient(circle at 8% 82%, rgba(0, 143, 173, 0.12), transparent 32rem),
    linear-gradient(180deg, var(--cerulean-midnight), var(--cerulean-void));
}

.reader-header {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) minmax(220px, 1fr);
  align-items: center;
  gap: 1rem;
  padding: max(0.8rem, env(safe-area-inset-top)) clamp(1rem, 3vw, 2.5rem) 0.65rem;
}

.icon-button,
.reader-footer button {
  min-height: 44px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.library-button {
  justify-self: start;
}

.reader-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 0.25rem;
  justify-self: end;
}

.settings-button span:last-child,
.fullscreen-glyph {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(38, 49, 47, 0.24);
  border-radius: 50%;
  font-family: "Libre Baskerville", Georgia, serif;
}

.fullscreen-glyph::before {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 2px;
  content: "";
}

.reader:fullscreen,
.reader:-webkit-full-screen {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.reader.focus-mode {
  grid-template-rows: auto 0 minmax(0, 1fr) 0;
}

.reader.focus-mode .progress-row,
.reader.focus-mode .reader-footer {
  height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  visibility: hidden;
}

.reader.focus-mode .book-stage,
.reader.focus-mode .book-stage[data-layout="spread"] {
  height: min(86svh, 900px);
  max-height: calc(100svh - 92px);
}

.fullscreen-notice {
  position: fixed;
  z-index: 80;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  width: fit-content;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  color: #fff8e8;
  background: rgba(35, 49, 47, 0.95);
  box-shadow: 0 14px 35px rgba(20, 28, 27, 0.3);
  font-size: 0.84rem;
  line-height: 1.45;
  text-align: center;
}

.reader-identity {
  min-width: 0;
  text-align: center;
}

.reader-identity p {
  margin-bottom: 0.2rem;
  color: var(--cerulean-fog);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reader-identity h1 {
  margin: 0;
  overflow: hidden;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  color: var(--cerulean-fog);
  font-size: 0.72rem;
}

.progress-track {
  flex: 1;
  height: 2px;
  overflow: hidden;
  background: rgba(95, 233, 255, 0.18);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cerulean-coral);
  transition: width 180ms ease;
}

.reader-main {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  min-height: 0;
  padding: 0 clamp(0.25rem, 2vw, 1.5rem);
}

.book-area {
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  min-height: 0;
}

.preparing-book,
.book-stage {
  grid-area: 1 / 1;
}

.page-control {
  z-index: 5;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--cerulean-line-strong);
  border-radius: 50%;
  color: var(--cerulean-ice);
  background: rgba(4, 24, 33, 0.72);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.page-control span {
  font-family: Georgia, serif;
  font-size: 2.2rem;
  line-height: 1;
  transform: translateY(-2px);
}

.page-control:hover:not(:disabled) {
  transform: scale(1.06);
  background: rgba(0, 143, 173, 0.4);
}

.page-control:disabled {
  cursor: default;
  opacity: 0.25;
}

.preparing-book {
  display: grid;
  justify-items: center;
  gap: 1rem;
  color: var(--cerulean-fog);
}

.preparing-book .preparing-mark {
  animation: breathe 1.5s ease-in-out infinite alternate;
}

@keyframes breathe {
  to {
    transform: translateY(-8px) rotate(2deg);
    box-shadow: inset 4px 0 rgba(255, 255, 255, 0.16), 0 18px 34px rgba(35, 49, 47, 0.22);
  }
}

.book-stage {
  position: relative;
  width: min(92vw, 760px);
  height: min(78svh, 900px);
  max-height: calc(100svh - 150px);
  perspective: 2400px;
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
}

.book-stage:active {
  cursor: grabbing;
}

.book-stage[data-layout="spread"] {
  width: min(90vw, 1700px);
  height: min(77svh, 820px);
}

.book-shadow {
  position: absolute;
  inset: 8% 4% -3%;
  border-radius: 50%;
  background: rgba(0, 5, 9, 0.68);
  filter: blur(25px);
  transform: translateY(10%);
}

.book-spread {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.paper-page {
  position: absolute;
  inset-block: 0;
  width: 50%;
  overflow: hidden;
  padding: clamp(2.6rem, 4.4vw, 4.8rem) clamp(2rem, 3.6vw, 4.4rem) clamp(2.3rem, 3.8vw, 4rem);
  color: #10242c;
  background-color: #f7fbfc;
  background-image:
    repeating-linear-gradient(93deg, rgba(0, 95, 120, 0.012) 0 1px, transparent 1px 6px),
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.96), transparent 34%);
  box-shadow: inset 0 0 40px rgba(0, 80, 105, 0.055);
  font-family: "Libre Baskerville", Georgia, serif;
}

.page-left {
  left: 0;
  border-radius: 0.55rem 0.08rem 0.08rem 0.55rem;
  box-shadow:
    inset -22px 0 30px -27px rgba(0, 24, 34, 0.42),
    inset 0 0 35px rgba(0, 80, 105, 0.05);
}

.page-right {
  right: 0;
  border-radius: 0.08rem 0.55rem 0.55rem 0.08rem;
  box-shadow:
    inset 22px 0 30px -27px rgba(0, 24, 34, 0.44),
    inset 0 0 35px rgba(0, 80, 105, 0.05);
}

.book-stage[data-layout="single"] .paper-page {
  width: 100%;
  border-radius: 0.45rem 0.8rem 0.8rem 0.45rem;
  box-shadow:
    inset 12px 0 24px -22px rgba(30, 26, 18, 0.48),
    inset -4px 0 rgba(255, 255, 255, 0.28),
    0 22px 48px rgba(43, 38, 29, 0.22);
}

.book-stage[data-layout="single"] .page-left {
  display: none;
}

.book-spine {
  position: absolute;
  z-index: 8;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(38, 31, 20, 0.16), rgba(255, 255, 255, 0.4), rgba(38, 31, 20, 0.16));
  box-shadow: 0 0 14px rgba(38, 31, 20, 0.24);
  transform: translateX(-1px);
}

.book-stage[data-layout="single"] .book-spine {
  left: 0;
  width: 6px;
  background: linear-gradient(90deg, rgba(38, 31, 20, 0.28), rgba(255, 255, 255, 0.25), transparent);
  box-shadow: none;
}

.turn-sheet {
  position: absolute;
  z-index: 7;
  inset-block: 0;
  left: 50%;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  visibility: hidden;
  will-change: transform;
}

.book-stage[data-layout="single"] .turn-sheet {
  left: 0;
  width: 100%;
}

.turn-sheet.active {
  visibility: visible;
}

.turn-sheet.animating {
  transition: transform 430ms cubic-bezier(0.2, 0.72, 0.2, 1);
}

.turn-face {
  inset: 0;
  width: 100%;
  backface-visibility: hidden;
}

.turn-front {
  transform: rotateY(0);
}

.turn-back {
  transform: rotateY(180deg);
  box-shadow:
    inset -20px 0 28px -25px rgba(30, 26, 18, 0.42),
    inset 0 0 35px rgba(89, 68, 38, 0.06);
}

.page-running,
.page-number {
  position: absolute;
  left: clamp(1.7rem, 4vw, 3.8rem);
  right: clamp(1.7rem, 4vw, 3.8rem);
  color: #52707a;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page-running {
  top: clamp(1rem, 2.2vw, 1.7rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-number {
  bottom: clamp(0.9rem, 2vw, 1.4rem);
  text-align: center;
}

.page-body {
  height: 100%;
  overflow: hidden;
  font-size: 2rem;
  line-height: 1.58;
}

.page-body p {
  margin: 0 0 0.85em;
  text-indent: 1.25em;
}

.page-body p:first-child,
.page-body p.continued {
  text-indent: 0;
}

.page-body h2 {
  margin: 0 0 1.5em;
  font-size: 1.25em;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-align: center;
  text-transform: uppercase;
}

.illustration-page {
  display: grid;
  place-items: center;
}

.illustration-page figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.55rem;
  width: 100%;
  height: 100%;
  margin: 0;
  min-height: 0;
}

.illustration-page img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  filter: drop-shadow(0 0.25rem 0.4rem rgba(45, 37, 27, 0.12));
}

.illustration-page figcaption {
  overflow: hidden;
  color: #6f6759;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.68rem;
  line-height: 1.35;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-theme="night"] .illustration-page img {
  filter: brightness(0.82) contrast(0.94);
}

.page-body .title-page {
  display: grid;
  align-content: center;
  height: 100%;
  text-align: center;
}

.title-page h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.45rem, 4vw, 2.4rem);
  letter-spacing: 0;
  text-transform: none;
}

.title-page p {
  text-indent: 0;
}

.source-page {
  display: grid;
  align-content: center;
  height: 100%;
  color: #36535d;
  font-size: 0.86em;
  line-height: 1.75;
}

.source-page p {
  text-indent: 0;
}

body[data-text-size="small"] .page-body {
  font-size: 1.5rem;
}

body[data-text-size="large"] .page-body {
  font-size: 2.4rem;
}

body[data-theme="sepia"] .paper-page {
  color: #33291f;
  background:
    repeating-linear-gradient(93deg, rgba(85, 66, 40, 0.02) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.42), transparent 32%),
    #ead8b7;
}

body[data-theme="night"] .reader {
  color: #d7d0bf;
  background:
    radial-gradient(circle at 50% 20%, rgba(72, 83, 80, 0.34), transparent 46%),
    #18201f;
}

body[data-theme="night"] .paper-page {
  color: #ddd5c5;
  background:
    repeating-linear-gradient(93deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.03), transparent 32%),
    #29302e;
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.18);
}

body[data-theme="night"] .page-running,
body[data-theme="night"] .page-number,
body[data-theme="night"] .reader-identity p,
body[data-theme="night"] .progress-row,
body[data-theme="night"] .source-page {
  color: #aaa897;
}

body[data-theme="night"] .page-control {
  color: #ddd5c5;
  border-color: rgba(221, 213, 197, 0.24);
  background: rgba(221, 213, 197, 0.06);
}

.gesture-hint {
  margin: 0.65rem 0 0;
  color: var(--cerulean-fog);
  font-size: 0.74rem;
  text-align: center;
  transition: opacity 300ms ease;
}

.gesture-hint.dismissed {
  opacity: 0;
}

.reader-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 52px;
  padding: 0 clamp(1rem, 3vw, 2.5rem) max(0.4rem, env(safe-area-inset-bottom));
  color: var(--cerulean-fog);
  font-size: 0.72rem;
}

.reader-footer button {
  justify-self: start;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.reader-footer p {
  margin: 0;
}

.reader-footer p:last-child {
  justify-self: end;
}

dialog {
  width: min(92vw, 560px);
  max-height: min(86vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 1rem;
  color: #26312f;
  background: #f4edde;
  box-shadow: 0 28px 80px rgba(16, 22, 20, 0.34);
}

dialog::backdrop {
  background: rgba(20, 26, 24, 0.54);
  backdrop-filter: blur(5px);
}

dialog form,
.info-dialog article {
  padding: clamp(1.5rem, 5vw, 2.5rem);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.dialog-heading h2 {
  margin: 0;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1.8rem;
  font-weight: 400;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(38, 49, 47, 0.2);
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

fieldset {
  padding: 0;
  margin: 0 0 1.8rem;
  border: 0;
}

legend {
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.choice-row label {
  position: relative;
}

.choice-row input {
  position: absolute;
  opacity: 0;
}

.choice-row span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid rgba(38, 49, 47, 0.2);
  border-radius: 0.6rem;
  cursor: pointer;
}

.choice-row input:checked + span {
  color: #fff;
  border-color: #244b57;
  background: #244b57;
}

.choice-row input:focus-visible + span {
  outline: 3px solid #c75635;
  outline-offset: 3px;
}

.text-size-control {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 0.7rem;
}

.text-size-control button {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(38, 49, 47, 0.2);
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.text-size-control button:last-child {
  font-size: 1.35rem;
}

.text-size-control output {
  text-align: center;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid rgba(38, 49, 47, 0.18);
}

.toggle-row span {
  display: grid;
  gap: 0.2rem;
}

.toggle-row small {
  color: #66716d;
}

.toggle-row input {
  width: 1.4rem;
  height: 1.4rem;
}

.done-button {
  width: 100%;
  min-height: 50px;
  margin-top: 1.5rem;
  border: 0;
  border-radius: 99rem;
  color: #fff;
  background: #244b57;
  cursor: pointer;
}

.info-dialog dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1.2rem;
  margin-bottom: 1.5rem;
}

.info-dialog dt {
  color: #66716d;
}

.info-dialog dd {
  margin: 0;
}

.info-dialog p {
  color: #52605c;
  line-height: 1.65;
}

.info-dialog a {
  color: #8c402c;
  font-weight: 700;
}

.pagination-probe {
  position: fixed;
  z-index: -10;
  left: -200vw;
  top: 0;
  width: 480px;
  height: 680px;
  visibility: hidden;
  pointer-events: none;
}

body.reduced-effects .turn-sheet {
  transition: opacity 90ms linear !important;
}

body.reduced-effects .turn-sheet.active {
  opacity: 0.15;
  transform: none !important;
}

body.reduced-effects .preparing-book .preparing-mark {
  animation: none;
}

@media (max-width: 820px) {
  .library-view {
    padding: 0 1.2rem;
  }

  .discovery-invite {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .library-tools {
    grid-template-columns: 1fr;
  }

  .discovery-start {
    justify-self: start;
  }

  .site-header {
    min-height: 78px;
  }

  .privacy-note {
    display: none;
  }

  .book-grid {
    grid-template-columns: 1fr;
    gap: 4rem;
  }

  .book-object {
    width: min(62vw, 270px);
  }

  .book-card h3 {
    min-height: auto;
  }

  .library-note {
    grid-template-columns: 1fr;
  }

  .reader-main {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    padding-inline: 0;
  }

  .book-stage[data-layout="spread"] {
    width: min(88vw, 970px);
    height: min(74svh, 820px);
  }

  .page-body {
    font-size: 1.6rem;
  }

  body[data-text-size="small"] .page-body {
    font-size: 1.25rem;
  }

  body[data-text-size="large"] .page-body {
    font-size: 1.9rem;
  }

  .page-control {
    width: 44px;
    height: 44px;
  }

  .reader-header {
    grid-template-columns: 80px minmax(0, 1fr) 80px;
    padding-inline: 0.65rem;
  }

  .reader-actions {
    gap: 0;
  }

  .icon-button > span:not(:last-child) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .library-button > span:first-child {
    position: static;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    overflow: visible;
    clip: auto;
    font-size: 1.35rem;
  }

  .gesture-hint {
    max-width: 68vw;
  }

  .reader-footer {
    grid-template-columns: 1fr auto;
  }

  .reader-footer p:last-child {
    display: none;
  }
}

@media (max-width: 560px) {
  .library-hero h1 {
    font-size: clamp(3rem, 16vw, 5rem);
  }

  .discovery-header {
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
  }

  .discovery-header .icon-button span:last-child,
  .discovery-header .eyebrow {
    display: none;
  }

  .discovery-header .icon-button > span:first-child {
    position: static;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    overflow: visible;
    clip: auto;
    font-size: 1.35rem;
  }

  .discovery-header h1 {
    font-size: 1.08rem;
  }

  .discovery-stack {
    width: min(92vw, 370px);
    height: min(67dvh, 570px);
  }

  .discovery-copy {
    padding: 0.9rem 1rem 1rem;
  }

  .discovery-copy > p:not(.book-kicker) {
    font-size: 0.9rem;
  }

  .site-footer {
    display: grid;
    gap: 0.5rem;
  }

  .reader-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-control {
    position: fixed;
    z-index: 8;
    top: 50%;
    width: 40px;
    height: 48px;
    border: 0;
    background: rgba(4, 24, 33, 0.7);
    transform: translateY(-50%);
  }

  .page-control:hover:not(:disabled) {
    transform: translateY(-50%);
  }

  .page-control-previous {
    left: 0.2rem;
  }

  .page-control-next {
    right: 0.2rem;
  }

  .book-stage {
    width: min(94vw, 500px);
    height: min(67svh, 650px);
    max-height: calc(100svh - 190px);
  }

  .paper-page {
    padding: 3rem 1.45rem 2.5rem;
  }

  .page-running {
    top: 1.1rem;
    left: 1.45rem;
    right: 1.45rem;
  }

  .page-number {
    bottom: 1rem;
    left: 1.45rem;
    right: 1.45rem;
  }

  .page-body {
    font-size: 1.45rem;
    line-height: 1.56;
  }

  body[data-text-size="small"] .page-body {
    font-size: 1.15rem;
  }

  body[data-text-size="large"] .page-body {
    font-size: 1.72rem;
  }

  .reader-footer {
    padding-inline: 0.8rem;
  }
}

@media (max-height: 720px) {
  .reader-header {
    padding-top: max(0.35rem, env(safe-area-inset-top));
    padding-bottom: 0.25rem;
  }

  .reader-footer {
    min-height: 42px;
  }

  .gesture-hint {
    display: none;
  }

  .book-stage,
  .book-stage[data-layout="spread"] {
    height: calc(100svh - 150px);
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* CeruleanKit shell theme with a cool-white default reading surface. */
.library-view {
  color: var(--cerulean-ice);
}

.site-header,
.library-hero,
.discovery-invite,
.library-note,
.site-footer {
  border-color: var(--cerulean-line);
}

.wordmark-mark,
.preparing-mark {
  color: var(--cerulean-ice);
  background: linear-gradient(135deg, #003348, #008fad 64%, #04141b);
  box-shadow: 0 0 0 4px rgba(95, 233, 255, 0.05), 0 0 22px rgba(95, 233, 255, 0.18);
}

.privacy-note,
.section-heading p,
.site-footer,
.hero-copy,
.discovery-invite > p,
.library-note p:last-child,
.book-meta,
.book-progress {
  color: var(--cerulean-fog);
}

.eyebrow,
.book-kicker {
  color: var(--cerulean-bright);
}

.hero-details span {
  border-color: var(--cerulean-line);
  color: var(--cerulean-fog);
  background: rgba(4, 24, 33, 0.52);
}

.discovery-start {
  color: #001116;
  background: linear-gradient(135deg, var(--cerulean-soft), var(--cerulean-bright));
  box-shadow: 0 12px 32px rgba(53, 215, 238, 0.2);
}

.book-card-copy {
  border-color: var(--cerulean-line);
}

.book-progress-track {
  background: rgba(95, 233, 255, 0.16);
}

.book-progress-track span {
  background: var(--cerulean-coral);
}

.book-object {
  filter: drop-shadow(0 28px 28px rgba(0, 4, 9, 0.5));
}

.discovery-view {
  color: var(--cerulean-ice);
  background:
    radial-gradient(circle at 50% 12%, rgba(53, 215, 238, 0.12), transparent 28rem),
    linear-gradient(180deg, var(--cerulean-midnight), var(--cerulean-void));
}

.discovery-header > p,
.discovery-help {
  color: var(--cerulean-fog);
}

.discovery-header .icon-button {
  color: var(--cerulean-ice);
}

.discovery-card {
  color: #23312f;
}
