@font-face {
  font-family: Oswald;
  src: url("/assets/fonts/oswald-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  unicode-range: U+0400-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: Oswald;
  src: url("/assets/fonts/oswald-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("/assets/fonts/garamond-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0400-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: "EB Garamond";
  src: url("/assets/fonts/garamond-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: Literata;
  src: url("/assets/fonts/literata-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0400-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: Literata;
  src: url("/assets/fonts/literata-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: Literata;
  src: url("/assets/fonts/literata-italic-cyrillic.woff2") format("woff2");
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0400-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: Literata;
  src: url("/assets/fonts/literata-italic-latin.woff2") format("woff2");
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: Inter;
  src: url("/assets/fonts/inter-cyrillic.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0400-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: Inter;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
:root {
  color-scheme: light;
  --paper: #f4efe6;
  --ink: #3d382f;
  --muted: #797267;
  --line: #d7cfc1;
  --accent: #293e65;
  --accent-soft: #e7e7e6;
  --font-serif: Literata, Georgia, "Times New Roman", serif;
  --font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-pad: clamp(24px, 3.3vw, 54px);
  --book-h: clamp(300px, 54vh, 500px);
  --shelf-peek: 44px;
  --reader-alpha: 0;
  --library-alpha: 1;
  --header-alpha: 0;
  --preview-h: 0px;
  --duration: 320ms;
}
* {
  box-sizing: border-box;
}
html {
  min-height: 100%;
  background: var(--paper);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper) url("/assets/materials/paper.webp") repeat;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-reading {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100svh;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button {
  border: 0;
  background: none;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}
button[hidden],
[hidden] {
  display: none !important;
}
button img {
  pointer-events: none;
}
.icon {
  width: 24px;
  height: 24px;
  display: block;
  flex: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2 {
  font-weight: 400;
}
h1,
h2,
.serif-subtitle {
  font-family: var(--font-serif);
}
.muted,
.form-helper {
  color: var(--muted);
}
.eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.13em;
  font-weight: 500;
  text-transform: uppercase;
}
.book-author {
  font-family: var(--font-ui);
  font-size: 21px;
  line-height: 1.45;
  color: #57524a;
}
.plain-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 0;
  font-size: 18px;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  flex: none;
  border-radius: 50%;
}
.icon-button:hover {
  background: #e9e2d6;
}
.quiet-button {
  min-height: 44px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 14px;
}
.text-link {
  display: inline-block;
  min-height: 44px;
  padding: 6px 0;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 22px;
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 1px;
  text-align: left;
}
.text-link:hover {
  color: #142845;
}
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 24px;
  border-radius: 9px;
  font-size: 16px;
  line-height: 1.4;
}
.primary-button {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.primary-button:hover {
  background: #213456;
}
.secondary-button {
  border: 1px solid #bdb3a2;
  background: transparent;
}
.secondary-button:hover {
  background: #ece5d9;
}
.danger-link {
  display: inline-block;
  min-height: 44px;
  padding: 7px 0;
  color: #944e40;
  font-size: 14px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.app-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 34px var(--page-pad) 20px;
  opacity: var(--library-alpha);
}
.app-header h1 {
  font-size: clamp(30px, 3.3vw, 43px);
  line-height: 1.35;
  letter-spacing: -0.035em;
}
.library-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; min-width: 0; }
.library-count { font-size: 13px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.header-actions .account-button {
  font-size: 13px;
}
.language-button {
  font-size: 11px;
  letter-spacing: 0.08em;
}
.library-tools {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 12px;
  margin: 6px var(--page-pad) 0;
  max-width: 850px;
  opacity: var(--library-alpha);
}
.search-field {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.search-field input {
  border: 0;
  background: transparent;
  width: 100%;
  height: 48px;
  outline-offset: 0;
}
.library-tools select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  max-width: 175px;
  padding: 8px;
}
.library-view {
  position: relative;
  display: grid;
  grid-template-columns: minmax(250px, 27%) minmax(0, 1fr);
  align-items: center;
  min-height: calc(100svh - 160px - var(--preview-h));
  padding: 24px 0 76px var(--page-pad);
  isolation: isolate;
}
.library-aside {
  position: relative;
  z-index: 2;
  align-self: stretch;
  padding: 6px 24px 18px 0;
  opacity: var(--library-alpha);
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  padding-right: 32px;
}
.library-aside > .eyebrow {
  color: var(--muted);
  margin-bottom: 30px;
}
.library-aside h2 {
  font-size: clamp(34px, 3.7vw, 55px);
  line-height: 1.18;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
  margin-bottom: 14px;
}
.library-aside .book-author {
  font-size: 20px;
}
.selection-note {
  margin-top: 64px;
}
.selection-note h3 {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 24px;
}
.note-preview {
  border: 0;
  background: none;
  color: inherit;
  padding: 0;
  text-align: inherit;
  min-height: 44px;
  width: 100%;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.note-preview:hover { color: var(--accent); }
.selection-note .note-preview {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.selection-note .note-preview.is-empty {
  font-size: 21px;
  color: var(--muted);
}
.library-aside > .note-action {
  margin-top: 52px;
}
.shelf-area {
  position: relative;
  min-width: 0;
  align-self: center;
  will-change: transform;
}
.shelf-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 40px 0 48px;
  overscroll-behavior-x: contain;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}
.shelf-viewport::-webkit-scrollbar {
  display: none;
}
.shelf-viewport.is-dragging,
.shelf-viewport.is-dragging .book-hit { cursor: grabbing; }
.shelf-viewport { user-select: none; }
.shelf-track {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  padding: 0 max(28px, calc((100vw - 32vw) / 2 - 110px));
  height: calc(var(--book-h) + 24px);
}
.book-slot {
  position: relative;
  flex: 0 0 auto;
  width: var(--slot-w);
  height: var(--item-h);
  transition: width var(--duration) cubic-bezier(0.2, 0.7, 0.2, 1);
  isolation: isolate;
}
.book-anchor {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 240px;
  height: 360px;
  transform: translateX(-50%) scale(var(--book-k));
  transform-origin: 50% 100%;
  pointer-events: none;
  transition: transform var(--duration) cubic-bezier(0.2, 0.7, 0.2, 1);
}
.book-scene {
  width: 240px;
  height: 360px;
  position: relative;
  perspective: 1400px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
}
.book-lift {
  width: 240px;
  height: 360px;
  transform-origin: 50% 100%;
}
.book-lift .book-object { transition: none; }
.physical-book-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}
.has-physical-books .book-scene:not(.physical-fallback) .book-face {
  visibility: hidden;
}
.book-object {
  width: 240px;
  height: 360px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(var(--book-rx, 0deg)) rotateY(var(--book-ry, 88deg));
  transition: transform var(--duration) cubic-bezier(0.2, 0.7, 0.2, 1);
  --book-color: #d8c5a3;
  --book-ink: #38413d;
  --depth: 46px;
  --front-light: 1;
  --spine-light: 1;
}
.book-face {
  position: absolute;
  background-color: var(--book-color);
  background-image: url("/assets/materials/book-cloth.webp");
  background-size: 240px 240px;
  background-blend-mode: multiply;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
}
.book-front,
.book-back {
  inset: 0;
  border: 1px solid #00000014;
}
.is-lifted .book-front {
  box-shadow:
    inset 0 0 0 1px #ffffff24,
    -4px 12px 18px rgb(49 43 37 / var(--lift-shadow-alpha, 0));
}
.book-front {
  transform: translateZ(calc(var(--depth) / 2));
  filter: brightness(var(--front-light));
  box-shadow: inset 0 0 0 1px #ffffff24;
}
.book-back {
  transform: rotateY(180deg) translateZ(calc(var(--depth) / 2));
  filter: brightness(0.89);
}
.book-spine {
  width: var(--depth);
  height: 360px;
  left: calc(120px - var(--depth) / 2);
  top: 0;
  transform: rotateY(-90deg) translateZ(120px);
  filter: brightness(var(--spine-light));
  border: 1px solid #00000015;
  box-shadow:
    inset 2px 0 2px #ffffff17,
    inset -2px 0 3px #00000018;
}
.book-pages {
  width: calc(var(--depth) - 7px);
  height: 350px;
  left: calc(120px - (var(--depth) - 7px) / 2);
  top: 5px;
  transform: rotateY(90deg) translateZ(117px);
  background: #e3d7b8 url("/assets/materials/page-edges.webp") center/100% 100%;
  filter: brightness(0.93);
  border-radius: 1px;
}
.book-top,
.book-bottom {
  width: 234px;
  height: calc(var(--depth) - 5px);
  left: 3px;
  top: calc(180px - (var(--depth) - 5px) / 2);
  background: #e9dfc7 url("/assets/materials/page-edges.webp") center/100% 100%;
  border-radius: 1px;
}
.book-top {
  transform: rotateX(90deg) translateZ(177px);
}
.book-bottom {
  transform: rotateX(-90deg) translateZ(177px);
  filter: brightness(0.8);
}
.book-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.book-art.is-external {
  object-fit: cover;
}
.book-cover-type {
  position: absolute;
  inset: 25px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 15px;
  color: var(--book-ink);
  font-family: var(--font-serif);
  text-shadow: 0 0.5px #ffffff14;
}
.book-cover-author {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.book-cover-title {
  font-family: "EB Garamond", Literata, serif;
  font-size: 44px;
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.035em;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.book-cover-type.is-long .book-cover-title {
  font-size: 23px;
}
.book-cover-type.is-very-long .book-cover-title {
  font-size: 18px;
}
.book-cover-type.is-external {
  display: none;
}
.book-spine-type {
  position: absolute;
  inset: 67px 6px auto;
  color: var(--book-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  font-family: var(--font-serif);
  text-align: center;
}
.book-spine-title {
  font-size: 19px;
  line-height: 1.12;
  letter-spacing: -0.035em;
  text-transform: none;
  max-height: 220px;
  overflow: hidden;
  display: block;
  flex: none;
  width: 172.5%;
  transform: scaleX(0.58);
  font-weight: 500;
  overflow-wrap: normal;
  word-break: normal;
}
.book-spine-author {
  font-family: var(--font-ui);
  font-size: 8px;
  letter-spacing: 0.11em;
  max-height: 250px;
  overflow: hidden;
  opacity: 0.8;
  display: none;
}
.book-spine-art {
  position: absolute;
  inset: 0;
  opacity: 0.9;
  background-position: center bottom;
  background-size: auto 100%;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.book-hit {
  position: absolute;
  inset: auto auto 0 50%;
  translate: -50% 0;
  z-index: 4;
  width: var(--hit-w, 44px);
  height: var(--hit-h, var(--item-h));
  border-radius: 3px;
  background: none;
  transform-origin: 50% 100%;
}
.book-hit:focus-visible {
  outline-offset: 8px;
}
.book-hit:hover {
  background: #ffffff06;
}
.book-slot.is-active .book-object {
  --book-ry: -14deg;
  --book-rx: -2deg;
}
.book-ground-shadow {
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: var(--hit-w, calc(var(--slot-w) + 30px));
  height: 13px;
  transform: translateX(calc(-50% + var(--flow-x, 0px)));
  background: #51473445;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
  opacity: calc(1 - var(--hover-lift, 0) * 0.014);
}
.shelf-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 16px;
  opacity: var(--library-alpha);
}
.shelf-navigation .icon-button {
  color: var(--accent);
}
.shelf-navigation .icon {
  width: 22px;
  height: 22px;
}
.mobile-selection {
  display: none;
}
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  padding: 32px;
}
.empty-state h2 {
  font-size: clamp(32px, 4.5vw, 54px);
  line-height: 1.25;
  max-width: 650px;
  letter-spacing: -0.04em;
}
.empty-state p {
  max-width: 400px;
  color: var(--muted);
  font-size: 17px;
}
.empty-state .text-link {
  margin-top: 10px;
}
.library-view.is-empty .library-aside,
.library-view.is-empty .shelf-area,
.library-view.is-empty .mobile-selection {
  visibility: hidden;
}
.library-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  position: relative;
  padding: 12px var(--page-pad) 26px;
  font-size: 11px;
  letter-spacing: 0.015em;
  color: var(--muted);
  opacity: var(--library-alpha);
}
.reader-view {
  position: fixed;
  inset: var(--preview-h) 0 var(--shelf-peek);
  z-index: 20;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 36px;
  scrollbar-width: thin;
}
.reader-view:has(.reader-book-slot > .book-scene) {
  background: var(--paper) url("/assets/materials/paper.webp") repeat;
}
.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px var(--page-pad) 12px;
  gap: 20px;
  position: relative;
  z-index: 4;
  opacity: var(--header-alpha);
}
.reader-header .plain-button,
.reader-header > .text-link {
  font-family: var(--font-serif);
  font-size: 23px;
  color: var(--ink);
}
.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: 40px;
  max-width: 1260px;
  margin: 40px auto 0;
  padding: 0 clamp(40px, 7vw, 120px);
}
.reader-cover-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  column-gap: 14px;
  align-items: center;
  align-content: start;
  min-width: 0;
}
.reader-book-slot {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  width: min(100%, 34vw, 415px, calc((100svh - var(--preview-h) - 232px) * 0.666667));
  aspect-ratio: 2/3;
  flex: none;
}
.reader-book-slot > .book-scene {
  transform-origin: 0 0;
}
.cover-entry {
  font-size: 19px;
  margin-top: 17px;
  opacity: var(--reader-alpha);
}
.cover-source-choices {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  font-family: var(--font-ui);
  font-size: 13px;
  max-width: 100%;
}
.cover-source-choices button {
  min-height: 44px;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.cover-source-choices button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--paper);
}
.cover-generation-status {
  grid-column: 1 / -1;
  justify-self: center;
  font-size: 12px;
  color: var(--muted);
  max-width: 320px;
  text-align: center;
  opacity: var(--reader-alpha);
}
.reader-info {
  padding-top: 24px;
  opacity: var(--reader-alpha);
  min-width: 0;
}
.reader-info > h2 {
  font-size: clamp(43px, 6.7vw, 88px);
  line-height: 1.13;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}
.reader-info > .book-author {
  font-size: 24px;
  margin-top: 16px;
}
.reader-divider {
  height: 1px;
  background: var(--line);
  margin: 36px 0 33px;
}
.reader-note-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.reader-note-heading > .eyebrow {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.26em;
  color: var(--ink);
  margin: 0;
}
.reader-notes {
  display: grid;
  gap: 26px;
}
.reader-note {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  width: 100%;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(22px, 2.8vw, 35px);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.reader-note:hover {
  color: var(--accent);
}
.reader-note + .reader-note {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 22px;
}
.reader-note-page {
  display: block;
  margin-top: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.05em;
  font-style: normal;
  color: var(--muted);
}
.reader-empty-note {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 25px;
  line-height: 1.6;
  color: var(--muted);
}
.reader-metadata {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
  opacity: var(--reader-alpha);
}
.flight-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
.flight-layer > .book-scene {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.flight-layer .book-object {
  transition: none;
}
.is-reading .library-view {
  pointer-events: none;
}
.is-reading .book-anchor,
.is-reading .book-slot {
  /* The spring moves the whole row; resizing must not leave its geometry in transition. */
  transition: none;
}
.is-reading .library-footer,
.is-reading .app-header {
  pointer-events: none;
}
.sheet {
  color: var(--ink);
  background: var(--paper) url("/assets/materials/paper.webp") repeat;
  border: 1px solid #cfc6b5;
  border-radius: 16px;
  padding: 0;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  box-shadow: 0 24px 80px #312b252b;
  margin: auto;
  overflow: auto;
  scrollbar-width: thin;
}
.sheet::backdrop {
  background: #2f2a2342;
  backdrop-filter: blur(3px);
}
.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 28px 18px;
}
.sheet-header h2 {
  font-size: 31px;
  line-height: 1.3;
  letter-spacing: -0.025em;
}
.sheet-header > .icon-button {
  margin: -4px -9px 0 0;
}
.sheet-subtitle {
  font-family: var(--font-serif);
  font-size: 16px;
  margin-top: 7px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.sheet-body {
  padding: 0 28px 22px;
}
.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 28px 24px;
  position: sticky;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.sheet-footer .primary-button {
  min-width: 140px;
}
.form-fields {
  display: grid;
  gap: 19px;
}
.form-fields label,
.note-page {
  display: grid;
  gap: 7px;
  font-size: 13px;
}
.form-fields input,
.form-fields select,
.note-page input {
  width: 100%;
  height: 46px;
  background: #ffffff20;
  border: 1px solid #c8bcaa;
  border-radius: 7px;
  padding: 8px 12px;
  min-width: 0;
  font-size: 16px;
}
.form-fields select {
  padding-right: 24px;
}
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.rating-field {
  border: 0;
  margin: 0;
  padding: 0;
}
.rating-field legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 13px;
}
.rating-buttons {
  display: flex;
  gap: 8px;
}
.rating-buttons button {
  width: 40px;
  height: 40px;
  padding: 7px;
  opacity: 0.38;
}
.rating-buttons button.is-on {
  opacity: 1;
}
.rating-buttons .icon {
  width: 26px;
  height: 26px;
}
.note-editor textarea {
  width: 100%;
  min-height: 240px;
  border: 0;
  outline-offset: 4px;
  background: transparent;
  padding: 8px 0;
  resize: vertical;
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.6;
}
.note-page {
  max-width: 130px;
  margin-top: 18px;
}
.note-editor .danger-link {
  margin-top: 18px;
}
.cover-editor {
  width: min(600px, calc(100vw - 32px));
}
.cover-tabs {
  display: flex;
  gap: 18px;
  margin: 0 28px 26px;
  border-bottom: 1px solid var(--line);
}
.cover-tabs button {
  position: relative;
  min-height: 48px;
  flex: 1;
  padding: 9px;
  font-family: var(--font-serif);
  font-size: 21px;
}
.cover-tabs button[aria-selected="true"] {
  color: var(--accent);
}
.cover-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  height: 3px;
  border-radius: 3px;
  left: 0;
  right: 0;
  bottom: -1px;
  background: var(--accent);
}
.cover-draft-preview {
  float: left;
  width: 100px;
  aspect-ratio: 2/3;
  margin: 0 22px 14px 0;
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: 0 5px 12px #312b251a;
}
.cover-draft-preview .book-front {
  position: absolute;
  inset: 0;
  transform: none;
}
.cover-draft-preview .book-cover-type {
  inset: 10px 8px;
  gap: 7px;
}
.cover-draft-preview .book-cover-author {
  font-size: 5px;
}
.cover-draft-preview .book-cover-title {
  font-size: 14px;
}
.serif-subtitle {
  font-size: 26px;
  font-weight: 400;
  line-height: 1.35;
  margin-bottom: 12px;
}
.cover-body .muted {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 22px;
}
.cover-body .form-fields {
  clear: both;
  padding-top: 8px;
  gap: 16px;
}
.form-helper {
  font-size: 12px;
  line-height: 1.6;
  margin: 14px 0 24px;
}
.regenerate-button {
  max-width: 100%;
  font-size: 15px;
}
.cover-status {
  clear: both;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 18px;
  min-height: 20px;
}
.cover-status.is-error {
  color: #944e40;
}
.cover-status:empty {
  display: none;
}
.cover-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}
.cover-result {
  position: relative;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  min-width: 0;
}
.cover-result[aria-checked="true"] {
  border-color: var(--accent);
  background: #ffffff50;
}
.cover-result img {
  display: block;
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: contain;
  background: #e8e0d1;
}
.cover-result small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: 7px;
}
.file-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 120px;
  border: 1px dashed #bcb09b;
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  clear: both;
  padding: 15px;
  text-align: center;
}
.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.file-picker:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.preview-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px var(--page-pad);
  background: #e9dfcc;
  color: #685e4f;
  font-size: 11px;
}
.preview-notice strong {
  font-weight: 500;
  margin-right: 14px;
}
.preview-notice .quiet-button {
  font-size: 11px;
  min-height: 28px;
}
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  padding: 12px 22px;
  border-radius: 8px;
  background: #3d382f;
  color: #f4efe6;
  box-shadow: 0 8px 30px #30261c16;
  font-size: 14px;
  text-align: center;
  z-index: 100;
}
.mobile-more {
  display: none;
}
.mobile-menu {
  inset: calc(var(--preview-h) + 84px) var(--page-pad) auto auto;
  margin: 0;
  padding: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 35px #3d382f20;
  width: min(270px, calc(100vw - 32px));
  color: var(--ink);
}
.mobile-menu button,
.mobile-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 15px;
  text-decoration: none;
}
.mobile-menu button:hover,
.mobile-menu a:hover {
  background: #e9e2d6;
}
.mobile-menu .icon { width: 22px; height: 22px; }
.mobile-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 8px; }
.menu-user { font-size: 13px; color: var(--muted); padding: 8px 16px; overflow-wrap: anywhere; }
.rating-none {
  font-family: var(--font-serif);
  font-size: 23px;
}
.rating-buttons button.rating-none[aria-checked="true"] {
  opacity: 1;
}
.is-reading.is-closing .library-view {
  pointer-events: auto;
}
/* On iPad and desktop the editor replaces the notes pane; the same large book previews drafts. */
.cover-editor.is-inline {
  position: static;
  inset: auto;
  width: auto;
  max-height: none;
  margin: -64px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  opacity: var(--reader-alpha);
}
.cover-editor.is-inline .sheet-header {
  padding: 0 0 18px;
  gap: 12px;
}
.cover-editor.is-inline .sheet-header h2 {
  font-size: clamp(32px, 3.8vw, 50px);
}
.cover-editor.is-inline .sheet-subtitle {
  font-size: 21px;
  color: var(--ink);
  margin-top: 8px;
}
.cover-editor.is-inline .sheet-header > .icon-button {
  margin: 0 -9px 0 0;
}
.cover-editor.is-inline .cover-tabs {
  margin: 0 0 22px;
  gap: 20px;
}
.cover-editor.is-inline .cover-tabs button {
  font-family: var(--font-ui);
  font-size: clamp(13px, 1.35vw, 17px);
  padding-inline: 2px;
}
.cover-editor.is-inline .sheet-body {
  padding: 0;
}
.cover-editor.is-inline .cover-draft-preview {
  display: none;
}
.cover-editor.is-inline .serif-subtitle {
  font-size: 32px;
}
.cover-editor.is-inline .muted {
  font-family: var(--font-serif);
  font-size: 17px;
  margin-bottom: 18px;
}
.cover-editor.is-inline .form-fields {
  padding-top: 0;
  gap: 17px;
}
.cover-editor.is-inline .form-fields label {
  font-family: var(--font-serif);
  font-size: 17px;
}
.cover-editor.is-inline .form-fields input {
  font-family: var(--font-serif);
  font-size: 22px;
  height: 44px;
  background: transparent;
}
.cover-editor.is-inline .form-helper {
  font-size: 14px;
  margin: 12px 0 20px;
}
.cover-editor.is-inline .regenerate-button {
  font-family: var(--font-serif);
  font-size: 19px;
}
.cover-editor.is-inline .sheet-footer {
  position: static;
  justify-content: flex-start;
  padding: 22px 0 0;
  border: 0;
  background: none;
  gap: 18px;
}
.cover-editor.is-inline .sheet-footer button {
  font-family: var(--font-serif);
  font-size: 20px;
  min-width: 140px;
}

@media (min-width: 1500px) {
  .library-view {
    grid-template-columns: minmax(320px, 28%) minmax(0, 1fr);
  }
  .reader-layout {
    gap: 100px;
  }
  .library-aside {
    max-width: 400px;
  }
  .shelf-track {
    padding-inline: calc((100vw - 33vw) / 2 - 120px);
  }
}
@media (min-width: 768px) and (max-width: 1000px) {
  :root {
    --page-pad: 28px;
    --book-h: clamp(320px, 43vh, 440px);
  }
  .header-actions {
    gap: 7px;
  }
  .app-header h1 {
    font-size: 34px;
  }
  .library-view {
    grid-template-columns: 250px minmax(0, 1fr);
  }
  .library-aside h2 {
    font-size: 38px;
  }
  .library-aside .book-author {
    font-size: 17px;
  }
  .selection-note {
    margin-top: 45px;
  }
  .selection-note p {
    font-size: 22px;
  }
  .selection-note h3 {
    font-size: 15px;
  }
  .library-aside > .note-action {
    margin-top: 35px;
    font-size: 20px;
  }
  .reader-layout {
    padding-inline: 36px;
    gap: 34px;
    margin-top: 24px;
  }
  .reader-info > h2 {
    font-size: 46px;
  }
  .reader-info > .book-author {
    font-size: 20px;
  }
  .reader-note {
    font-size: 24px;
  }
  .shelf-track {
    padding-inline: calc((100vw - 278px) / 2 - 100px);
  }
}
@media (max-width: 767px) {
  :root {
    --page-pad: 22px;
    --book-h: clamp(220px, 28svh, 280px);
    --shelf-peek: 28px;
  }
  .app-header {
    padding: 30px var(--page-pad) 14px;
    gap: 12px;
    padding-top: calc(30px + env(safe-area-inset-top, 0px));
  }
  .library-heading { flex-direction: column; align-items: flex-start; gap: 2px; }
  input, select, textarea { font-size: max(16px, 1em); }
  .app-header h1 {
    font-size: clamp(24px, 6.5vw, 32px);
    white-space: nowrap;
    letter-spacing: -0.045em;
  }
  .header-actions {
    gap: 8px;
  }
  .header-actions > #add-open,
  .header-actions > #language-button {
    display: none;
  }
  .header-actions > .mobile-more {
    display: inline-flex;
  }
  .header-actions .search-toggle {
    width: 40px;
    min-width: 40px;
  }
  .search-toggle > span,
  .header-actions > .account-button {
    display: none;
  }
  .header-actions .icon-button {
    width: 38px;
    height: 44px;
    padding: 7px;
  }
  .header-actions .plain-button {
    padding: 7px;
  }
  .header-actions .language-button {
    width: 30px;
    font-size: 10px;
    padding: 4px;
  }
  .header-actions .icon {
    width: 22px;
    height: 22px;
  }
  .library-tools {
    flex-wrap: wrap;
    margin-top: 12px;
    gap: 10px;
  }
  .search-field {
    flex-basis: 100%;
  }
  .library-tools select {
    flex: 1;
    max-width: none;
    min-width: 0;
  }
  .library-view {
    display: block;
    min-height: calc(100svh - 145px - var(--preview-h));
    padding: 42px 0 30px;
    padding-top: 20px;
  }
  .library-aside {
    display: none;
  }
  .shelf-area {
    width: 100%;
  }
  .shelf-viewport {
    padding: 20px 0 26px;
  }
  .shelf-track {
    gap: 5px;
    padding-inline: calc(50vw - 85px);
    height: calc(var(--book-h) + 14px);
  }
  .shelf-navigation {
    display: none;
  }
  .mobile-selection {
    display: flex;
    align-items: center;
    flex-direction: column;
    text-align: center;
    padding: 26px var(--page-pad) 15px;
    opacity: var(--library-alpha);
  }
  .mobile-selection h2 {
    font-size: clamp(32px, 10.2vw, 42px);
    line-height: 1.2;
    letter-spacing: -0.045em;
    overflow-wrap: anywhere;
    max-width: 100%;
  }
  .mobile-selection .book-author {
    font-size: 15px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-top: 11px;
  }
  .mobile-note {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 21px;
    line-height: 1.6;
    margin: 25px auto 0;
    max-width: 330px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .mobile-note.is-empty {
    font-size: 18px;
    color: var(--muted);
  }
  .mobile-selection .primary-button {
    width: 100%;
    margin-top: 34px;
    min-height: 50px;
    background: #62594b;
    border-color: #62594b;
    font-family: var(--font-serif);
    font-size: 22px;
  }
  .library-footer {
    display: block;
    text-align: center;
    padding: 14px 20px 25px;
    font-size: 10px;
  }
  .library-footer > #account-hint {
    display: block;
    margin-top: 7px;
  }
  .empty-state {
    padding: 28px;
  }
  .empty-state h2 {
    font-size: 34px;
  }
  .empty-state p {
    font-size: 15px;
  }
  .empty-state .text-link {
    font-size: 20px;
  }
  .reader-header {
    padding: 18px var(--page-pad) 10px;
    gap: 12px;
  }
  .reader-header .plain-button,
  .reader-header > .text-link {
    font-size: 17px;
  }
  .reader-header .plain-button {
    gap: 10px;
  }
  .reader-header .icon {
    width: 21px;
    height: 21px;
  }
  .reader-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 var(--page-pad) 30px;
    margin-top: 19px;
  }
  .reader-cover-column {
    width: 100%;
    position: relative;
    grid-template-columns: minmax(0, 1fr) 72px;
    column-gap: 12px;
  }
  .reader-book-slot {
    width: min(100%, 58vw, 25svh);
    aspect-ratio: 2/3;
  }
  .cover-entry {
    font-size: 16px;
    margin-top: 2px;
    min-height: 36px;
    position: absolute;
    top: 100%;
  }
  .cover-source-choices {
    position: static;
    margin-top: 12px;
    font-size: 12px;
  }
  .reader-info {
    padding-top: 20px;
    width: 100%;
  }
  .reader-info > h2 {
    font-size: clamp(35px, 11.3vw, 46px);
    text-align: center;
    line-height: 1.18;
  }
  .reader-info > .book-author {
    font-size: 18px;
    text-align: center;
    margin-top: 8px;
  }
  .reader-divider {
    margin: 20px 0;
  }
  .reader-note-heading > .eyebrow {
    font-size: 10px;
    letter-spacing: 0.24em;
    margin: 0;
  }
  .reader-note {
    font-size: 20px;
    line-height: 1.65;
  }
  .reader-note + .reader-note {
    font-size: 19px;
  }
  .reader-empty-note {
    font-size: 21px;
  }
  .reader-metadata {
    font-size: 12px;
    gap: 10px;
  }
  .sheet {
    border-radius: 14px;
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 28px);
  }
  .sheet-header {
    padding: 20px 20px 16px;
  }
  .sheet-header h2 {
    font-size: 28px;
  }
  .sheet-body {
    padding: 0 20px 18px;
  }
  .sheet-footer {
    padding: 15px 20px 20px;
    gap: 10px;
  }
  .sheet-footer > .primary-button,
  .sheet-footer > .secondary-button {
    flex: 1;
    min-width: 0;
    padding-inline: 14px;
  }
  .field-pair {
    gap: 12px;
  }
  .form-fields label {
    font-size: 12px;
  }
  .cover-tabs {
    margin: 0 20px 23px;
    gap: 12px;
  }
  .cover-tabs button {
    font-family: var(--font-ui);
    font-size: 13px;
    padding-inline: 2px;
  }
  .cover-draft-preview {
    width: 80px;
    margin-right: 17px;
  }
  .serif-subtitle {
    font-size: 24px;
  }
  .cover-body .muted {
    font-size: 14px;
  }
  .note-editor textarea {
    font-size: 20px;
    min-height: 220px;
  }
  .preview-notice {
    font-size: 9px;
    padding: 6px 12px;
  }
  .preview-explanation {
    display: none;
  }
  .preview-notice .quiet-button {
    font-size: 9px;
  }
  .toast {
    font-size: 13px;
  }
}
@media (max-height: 620px) and (min-width: 768px) {
  :root {
    --book-h: 280px;
  }
  .app-header {
    padding-top: 16px;
  }
  .library-view {
    min-height: 420px;
    padding-top: 0;
  }
  .selection-note {
    margin-top: 26px;
  }
  .library-aside > .note-action {
    margin-top: 24px;
  }
  .reader-layout {
    margin-top: 0;
  }
  .reader-book-slot {
    width: 35svh;
  }
  .reader-info {
    padding-top: 3px;
  }
  .reader-info > h2 {
    font-size: 44px;
  }
  .reader-divider {
    margin: 20px 0;
  }
  .reader-note {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
  .shelf-area,
  .book-object,
  .flight-layer > .book-scene {
    will-change: auto;
  }
}
