* {
  box-sizing: border-box;
}

/* cyrillic-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* cyrillic */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* greek-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}

/* greek */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* vietnamese */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* latin-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: "Reader Serif";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* cyrillic-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* cyrillic */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* greek-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}

/* greek */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* vietnamese */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* latin-ext */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: "Reader Serif";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/eb-garamond-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* vietnamese */
@font-face {
  font-family: "Reader Mono";
  font-style: normal;
  font-weight: 200 900;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/inconsolata-normal-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* latin-ext */
@font-face {
  font-family: "Reader Mono";
  font-style: normal;
  font-weight: 200 900;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/inconsolata-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: "Reader Mono";
  font-style: normal;
  font-weight: 200 900;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/inconsolata-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* cyrillic-ext */
@font-face {
  font-family: "Reader Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-italic-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* cyrillic */
@font-face {
  font-family: "Reader Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-italic-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* vietnamese */
@font-face {
  font-family: "Reader Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-italic-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* latin-ext */
@font-face {
  font-family: "Reader Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: "Reader Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* cyrillic-ext */
@font-face {
  font-family: "Reader Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-normal-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* cyrillic */
@font-face {
  font-family: "Reader Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-normal-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* vietnamese */
@font-face {
  font-family: "Reader Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-normal-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* latin-ext */
@font-face {
  font-family: "Reader Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: "Reader Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/libre-franklin-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

body {
  margin: 0;
  padding: 14px;
  background-color: #c9c9c9;
  color: #000;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-library {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.page-reader {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.page-centred {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
}

.page-upload {
  align-items: flex-start;
}

.header {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px;
  border: 2px outset #f4f4f4;
  background: linear-gradient(180deg, #fff, #dcdcdc);
}

.header h1,
.panel h1 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.header h1 {
  margin: 0;
}

.header-actions,
.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.button {
  display: inline-block;
  padding: 4px 12px;
  border: 2px outset #efefef;
  border-radius: 0;
  background: linear-gradient(180deg, #fff, #d7d7d7);
  color: #000;
  cursor: pointer;
  font: inherit;
  text-align: center;
  text-decoration: none !important;
}

.button:hover {
  background: linear-gradient(180deg, #fff, #cfcfcf);
}

.button:focus,
.button:focus-visible {
  outline: 0;
}

.button:active {
  border-style: inset;
}

.button:disabled {
  color: #707070;
  cursor: default;
}

.button.full-width {
  display: block;
  width: 100%;
}

.button.secondary {
  margin-top: 8px;
}

.panel {
  width: 100%;
  padding: 8px;
  border: 2px outset #f4f4f4;
  background: #dcdcdc;
}

.login-panel {
  max-width: 360px;
}

.upload-panel {
  max-width: 760px;
}

.page-upload .upload-panel {
  max-height: calc(100svh - 28px);
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 12px;
  padding: 5px 7px;
  border: 1px solid #808080;
  background: linear-gradient(180deg, #fff, #bdbdbd);
}

.form-group {
  margin-bottom: 10px;
}

.upload-panel .form-group {
  padding: 10px;
  border: 2px inset #efefef;
  background-color: #f2f2f2;
}

label {
  display: block;
  margin-bottom: 3px;
  color: #000;
}

.upload-panel label {
  margin-bottom: 8px;
}

.upload-workflow {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.upload-workflow[hidden] {
  display: none;
}

.upload-workflow h2 {
  margin: 6px 0 0;
  font-size: 12px;
}

input {
  width: 100%;
  padding: 4px;
  border: 2px inset #efefef;
  border-radius: 0;
  background: #fff;
  font: inherit;
}

input[type="file"] {
  max-width: 100%;
  color: #000;
}

.error {
  margin: 0 0 1rem;
  padding: 5px;
  border: 2px inset #efefef;
  background: #fff;
  color: #900;
}

.library-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding: 6px;
  overflow: hidden;
  border: 2px inset #efefef;
  background: #f2f2f2;
}

#bookshelf-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid #808080;
  background:
    url("/assets/study-background.webp") center / cover no-repeat,
    #fff;
  cursor: default;
  touch-action: manipulation;
}

.library-view-list #bookshelf-canvas {
  display: none;
}

.library-view-shelf .book-list {
  display: none;
}

.empty-library {
  max-width: 40rem;
  margin: 4rem auto;
  color: #000;
}

.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overflow-y: auto;
  list-style: none;
}

.book-list-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: start;
  min-height: 72px;
  padding: 6px;
  border: 2px outset #efefef;
  background: #dcdcdc;
  color: #000;
  text-decoration: none;
}

.book-list-item:hover,
.book-list-item:focus {
  border-style: inset;
  background: #000080;
  color: #fff;
  outline: 0;
  text-decoration: none;
}

.book-list-item img {
  display: block;
  width: 48px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border: 1px solid #808080;
  background: #fff;
}

.book-list-details {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.book-list-title,
.book-list-author,
.book-list-series {
  overflow-wrap: anywhere;
}

.book-list-title {
  font-weight: 700;
}

.book-list-series {
  color: inherit;
}

.book-spotlight {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: block;
  overflow: hidden;
  background: transparent;
}

.book-spotlight[hidden] {
  display: none;
}

.book-spotlight-actions {
  position: fixed;
  left: 50%;
  z-index: 2;
  display: flex;
  gap: 12px;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.book-spotlight-active .book-spotlight-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition-delay: 420ms;
}

.book-spotlight-actions .button {
  min-width: 110px;
  padding: 6px 16px;
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .book-spotlight-actions {
    transition: none;
  }
}

.reader-header {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px;
  border: 2px outset #f4f4f4;
  background: linear-gradient(180deg, #fff, #dcdcdc);
}

.reader-title,
.reader-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.reader-title h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.reader-title p {
  margin: 1px 0 0;
  overflow-wrap: anywhere;
}

.reader-progress {
  min-width: 94px;
  padding: 4px 7px;
  border: 2px inset #efefef;
  background: #fff;
  text-align: center;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}

.reader-nav,
.reader-document,
.reader-empty {
  border: 2px inset #efefef;
  background: #f2f2f2;
}

.reader-nav {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.reader-nav ol {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 18px;
}

.reader-nav a {
  display: block;
  padding: 2px 4px;
  overflow-wrap: anywhere;
}

.reader-nav a.current {
  background: #000080;
  color: #fff;
  text-decoration: none;
}

.reader-document {
  position: relative;
  display: flex;
  justify-content: center;
  justify-self: center;
  width: min(100%, 720px);
  min-height: 0;
  overflow: hidden;
  padding: clamp(20px, 4vw, 38px) clamp(38px, 7vw, 58px);
  background: #fffdf7;
  color: #15120e;
  font-family: "Reader Serif", Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-variant-ligatures: common-ligatures contextual;
  line-height: 1.38;
  outline: none;
}

.reader-page-viewport {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.reader-loading .reader-flow {
  visibility: hidden;
}

.reader-flow {
  --reader-page-gap: 96px;
  --reader-page-offset: 0px;
  --reader-page-width: 1px;
  column-fill: auto;
  column-gap: var(--reader-page-gap);
  column-width: var(--reader-page-width);
  height: 100%;
  transform: translateX(calc(-1 * var(--reader-page-offset)));
  width: var(--reader-page-width);
  will-change: transform;
}

.reader-section {
  margin: 0;
  max-width: none;
  overflow-wrap: break-word;
  -webkit-locale: "en";
}

.reader-section h2 {
  break-after: avoid;
  color: #15120e;
  font-family: "Reader Sans", Tahoma, Verdana, Arial, sans-serif;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
  margin: 0 0 1.2em;
  overflow-wrap: anywhere;
  text-align: left;
}

.reader-section p {
  hyphenate-limit-chars: 8 4 4;
  hyphenate-limit-last: always;
  hyphenate-limit-lines: 2;
  hyphenate-limit-zone: 8%;
  hyphenate-character: "\2010";
  hyphens: auto;
  margin: 0;
  orphans: 2;
  overflow-wrap: break-word;
  text-align: justify;
  text-align-last: left;
  text-indent: 1.25em;
  text-wrap: pretty;
  widows: 2;
  word-break: normal;
  -webkit-hyphens: auto;
  -webkit-hyphenate-limit-after: 4;
  -webkit-hyphenate-limit-before: 4;
  -webkit-hyphenate-limit-lines: 2;
}

.reader-section p + p {
  margin-top: 0.72em;
}

.reader-section code,
.reader-section kbd,
.reader-section pre,
.reader-section samp {
  font-family: "Reader Mono", "Courier New", monospace;
}

.reader-section em,
.reader-section i {
  font-style: italic;
}

.reader-empty {
  flex: 1 1 auto;
  padding: 16px;
}

.reader-loading-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.28);
}

.reader-loading-modal[hidden] {
  display: none;
}

.reader-loading-panel {
  width: min(320px, 100%);
  padding: 12px;
  border: 2px outset #efefef;
  background: #dcdcdc;
  color: #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.reader-loading-panel h2 {
  margin: 0 0 10px;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.reader-ui-reveal {
  display: none;
}

.reader-inverted {
  background-color: #111;
  color: #e6e0d5;
}

.reader-inverted .reader-header,
.reader-inverted .reader-nav,
.reader-inverted .reader-empty,
.reader-inverted .reader-loading-panel {
  background: #202020;
  color: #e6e0d5;
}

.reader-inverted .reader-document {
  background: #111;
  color: #e6e0d5;
}

.reader-inverted .reader-section h2 {
  color: #e6e0d5;
}

.reader-inverted .reader-progress {
  background: #050505;
  color: #e6e0d5;
}

.reader-fullscreen {
  padding: 0;
}

.reader-fullscreen .reader-header,
.reader-fullscreen .reader-nav {
  display: none;
}

.reader-fullscreen .reader-shell {
  grid-template-columns: 1fr;
  gap: 0;
  height: 100vh;
  height: 100svh;
}

.reader-fullscreen .reader-document {
  width: min(100%, 820px);
  border: 0;
  padding-top: clamp(28px, 6vh, 56px);
  padding-bottom: clamp(28px, 6vh, 56px);
}

.reader-fullscreen .reader-ui-reveal {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 70;
  display: block;
  height: 58px;
  border: 0;
  background: transparent;
  cursor: default;
}

.book-context-menu {
  position: fixed;
  z-index: 20;
  min-width: 150px;
  padding: 2px;
  border: 2px outset #efefef;
  background: #dcdcdc;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
}

.book-context-menu[hidden] {
  display: none;
}

.book-context-menu button {
  display: block;
  width: 100%;
  padding: 4px 18px;
  border: 0;
  background: transparent;
  color: #000;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.book-context-menu button:hover,
.book-context-menu button:focus {
  background: #000080;
  color: #fff;
  outline: 0;
}

.cover-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.44);
}

.cover-modal[hidden] {
  display: none;
}

.cover-modal-panel {
  width: min(760px, 100%);
  padding: 12px;
  border: 2px outset #efefef;
  background: #dcdcdc;
  color: #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.cover-modal-panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
}

.cover-candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 70vh;
  overflow: auto;
  padding: 2px;
}

.metadata-candidate-grid {
  display: grid;
  gap: 8px;
  max-height: 70vh;
  overflow: auto;
  padding: 2px;
}

.upload-workflow .metadata-candidate-grid {
  max-height: min(34vh, 320px);
}

.upload-workflow .cover-candidate-grid {
  max-height: min(40vh, 420px);
}

.cover-candidate {
  appearance: none;
  display: grid;
  gap: 6px;
  align-content: start;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 6px;
  border: 2px outset #efefef;
  background: #cfcfcf;
  color: #000;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.metadata-candidate {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 10px;
  align-items: start;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  padding: 8px;
  border: 2px outset #efefef;
  background: #cfcfcf;
  color: #000;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.metadata-candidate-with-cover {
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 100px;
}

.cover-candidate.selected,
.cover-candidate:focus,
.metadata-candidate.selected,
.metadata-candidate:focus {
  border-style: inset;
  background: #000080;
  color: #fff;
  outline: 0;
}

.cover-candidate img {
  display: block;
  width: 100%;
  height: 192px;
  min-height: 192px;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  border: 1px solid #808080;
  background: #fff;
}

.metadata-candidate img {
  display: block;
  grid-row: span 3;
  width: 56px;
  height: 84px;
  min-width: 56px;
  min-height: 84px;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  border: 1px solid #808080;
  background: #fff;
}

.cover-candidate.cover-candidate-missing img {
  opacity: 0.35;
}

.cover-candidate-label,
.cover-candidate-dimensions,
.cover-candidate-meta,
.metadata-candidate-title,
.metadata-candidate-author,
.metadata-candidate-meta {
  display: block;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cover-candidate-label,
.metadata-candidate-title {
  font-weight: 700;
}

.cover-candidate-dimensions {
  color: inherit;
}

.cover-candidate-meta {
  color: inherit;
}

.metadata-candidate-author,
.metadata-candidate-meta {
  color: inherit;
}

.cover-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.cover-modal-actions button {
  padding: 4px 12px;
  border: 2px outset #efefef;
  background: linear-gradient(180deg, #fff, #d7d7d7);
  color: #000;
  cursor: pointer;
  font: inherit;
}

.cover-modal-actions button:active {
  border-style: inset;
}

.progress-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.32);
}

.progress-modal[hidden] {
  display: none;
}

.progress-modal-panel {
  width: min(360px, 100%);
  padding: 12px;
  border: 2px outset #efefef;
  background: #dcdcdc;
  color: #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.progress-modal-panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.progress-modal-message {
  margin: 0 0 10px;
}

.progress-bar {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 2px inset #efefef;
  background: #fff;
}

.progress-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  background: #000080;
  animation: progress-indeterminate 1.1s linear infinite;
}

@keyframes progress-indeterminate {
  from {
    transform: translateX(-110%);
  }

  to {
    transform: translateX(250%);
  }
}

@media (max-width: 760px) {
  body {
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .page-upload .upload-panel {
    max-height: calc(100svh - 16px);
  }

  .upload-workflow .metadata-candidate-grid {
    max-height: min(32vh, 280px);
  }

  .upload-workflow .cover-candidate-grid {
    max-height: min(36vh, 360px);
  }

  .header {
    display: grid;
    gap: 1rem;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .page-library {
    height: 100svh;
  }

  .page-reader {
    height: 100svh;
  }

  .library-stage {
    padding: 4px;
  }

  .book-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .book-list-item {
    grid-template-columns: 44px 1fr;
    min-height: 66px;
    padding: 5px;
  }

  .book-list-item img {
    width: 44px;
  }

  .book-spotlight-actions {
    width: calc(100vw - 32px);
    gap: 8px;
  }

  .book-spotlight-actions .button {
    flex: 1 1 0;
    min-width: 0;
    max-width: 160px;
  }

  .reader-header {
    display: grid;
    align-items: start;
    gap: 8px;
    margin-bottom: 8px;
  }

  .reader-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

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

  .reader-nav {
    max-height: 140px;
  }

  .reader-document {
    width: min(100%, 620px);
    padding: 16px 18px 24px;
    font-size: 17px;
    line-height: 1.45;
  }

  .reader-flow {
    --reader-page-gap: 48px;
  }

  .reader-section p {
    overflow-wrap: anywhere;
    text-align: left;
    text-indent: 1em;
    text-wrap: wrap;
  }

  .reader-fullscreen .reader-document {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .reader-document {
    padding-right: 14px;
    padding-left: 14px;
    font-size: 16px;
  }
}
