:root {
  --text: #343633;
  --muted: #4a4e48;
  --brand: #424946;
  --line: rgb(52 54 51 / 24%);
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--text);
  background: #dedbd6;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
button,
input {
  font: inherit;
}
button,
#pdf-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  flex-shrink: 0;
  padding: 0 10px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition:
    color 150ms ease,
    background-color 150ms ease;
}
button:hover:not(:disabled),
#pdf-download:hover {
  color: #222621;
  background: rgb(52 54 51 / 7%);
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button svg,
#pdf-download svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  pointer-events: none;
}
button:focus-visible,
input:focus-visible,
#viewport:focus-visible,
a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
#reader {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #dedbd6;
}
#reader::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  /* A light sheen preserves the glass relief while keeping controls legible. */
  background: linear-gradient(
    to bottom,
    rgb(255 255 255 / 38%),
    rgb(255 255 255 / 12%) 20%,
    rgb(255 255 255 / 12%) 80%,
    rgb(255 255 255 / 38%)
  );
}
#backdrop {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  /* Refraction and diffusion are baked into the image, including offline. */
  background: url("./assets/chinchilla-background.png") center / cover no-repeat;
}
#search-panel {
  position: relative;
  z-index: 5;
  grid-row: 2;
  grid-column: 1;
  align-self: end;
  justify-self: start;
  width: min(280px, calc(100% - 40px));
  margin-inline: 20px;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
}
.search-input {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.search-input:focus-within {
  border-bottom-color: var(--text);
  box-shadow: 0 1px 0 var(--text);
}
.search-input button {
  width: 36px;
  min-height: 36px;
  padding: 6px;
}
.search-input button svg {
  width: 18px;
  height: 18px;
}
.search-input input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 4px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 16px;
}
.search-input input:focus-visible {
  outline: none;
}
.search-input input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.search-input input::-webkit-search-cancel-button {
  display: none;
}
#search-results-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: min(420px, calc(100vw - 40px));
  max-height: min(65dvh, 520px);
  overflow: auto;
  padding: 12px;
  background: rgb(249 248 245 / 95%);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(255 255 255 / 65%);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgb(35 45 38 / 12%);
  scrollbar-width: thin;
  scrollbar-color: #989b95 transparent;
}
#search-summary {
  margin: 0;
  padding: 4px 6px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
#search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}
#search-results li + li {
  border-top: 1px solid var(--line);
}
#search-results button {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 10px 6px;
  text-align: left;
  justify-content: normal;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.result-page {
  font-size: 12px;
  font-weight: 600;
}
#search-results button[aria-current="true"] .result-page::after {
  content: " · ausgewählt";
  font-weight: 400;
}
.result-excerpt mark {
  color: inherit;
  background: rgb(220 181 74 / 25%);
  border-radius: 2px;
}
#more-results {
  width: 100%;
  margin-top: 6px;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}
#stage {
  position: relative;
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  min-height: 0;
  padding: 4px 52px;
  overflow: hidden;
}
.page-turn {
  position: absolute;
  z-index: 3;
  top: 50%;
  width: 44px;
  height: 56px;
  padding: 8px;
  transform: translateY(-50%);
  opacity: 0.7;
}
.page-turn svg {
  width: 28px;
  height: 28px;
}
.page-turn.previous {
  left: 4px;
}
.page-turn.next {
  right: 4px;
}
.page-turn:disabled {
  opacity: 0.16;
}
#viewport {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
  scrollbar-width: thin;
  scrollbar-color: #a6aea7 transparent;
}
#mount {
  width: 100%;
  height: 100%;
  contain: paint;
  user-select: none;
  touch-action: pan-y pinch-zoom;
}
#mount.zoomed {
  cursor: grab;
  touch-action: pan-x pan-y pinch-zoom;
}
#mount.panning {
  cursor: grabbing;
}
#book {
  width: 100%;
  height: 100%;
  min-width: 0;
  touch-action: inherit;
}
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.loading-ring {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: loading-turn 900ms linear infinite;
}
@keyframes loading-turn {
  to {
    transform: rotate(360deg);
  }
}
#reader-options {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: clamp(12px, 2.5vw, 36px);
  padding: 4px 320px max(4px, env(safe-area-inset-bottom));
  font-size: 13px;
}
.option-group {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
}
#contents-panel {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 8px;
  overflow: auto;
  color: var(--text);
  background: rgb(249 248 245 / 95%);
  backdrop-filter: blur(20px);
  border: 1px solid rgb(255 255 255 / 65%);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgb(35 45 38 / 12%);
  scrollbar-width: thin;
  scrollbar-color: #a6aea7 transparent;
}
#contents-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#contents-list li + li {
  border-top: 1px solid var(--line);
}
#contents-list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
}
#contents-list a:hover {
  background: rgb(52 54 51 / 7%);
}
#contents-list a > span:first-child {
  overflow-wrap: anywhere;
  min-width: 0;
}
.view-options button,
#contents-toggle,
#pdf-download {
  width: 44px;
  padding: 10px;
}
.view-options button {
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.view-options button[aria-pressed="true"] {
  color: #222621;
  border-bottom-color: currentColor;
}
.page-selection {
  gap: 8px;
  white-space: nowrap;
}
#page-number {
  width: 3.4rem;
  height: 32px;
  padding: 4px;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  appearance: textfield;
}
#page-number::-webkit-inner-spin-button,
#page-number::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}
.zoom-options button[data-icon] {
  width: 40px;
}
#zoom-fit {
  min-width: 64px;
  font-variant-numeric: tabular-nums;
}
#zoom-fit:disabled {
  opacity: 1;
}
#error {
  grid-row: 4;
  margin: 0;
  padding: 8px 20px 16px;
  color: #81302a;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}
@media (max-width: 1100px) {
  #reader {
    grid-template-rows: minmax(0, 1fr) auto auto;
  }
  #search-panel {
    grid-row: 3;
  }
  #reader-options {
    padding-inline: 16px;
    padding-bottom: 4px;
  }
}
@media (max-width: 700px) {
  #search-panel {
    margin-inline: 12px;
    width: min(280px, calc(100% - 24px));
  }
  #search-results-panel {
    width: min(420px, calc(100vw - 24px));
  }
  #stage {
    padding-inline: 40px;
  }
  #reader-options {
    gap: 0 12px;
    padding-inline: 8px;
  }
  .page-selection {
    gap: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  #pdf-download {
    transition: none;
  }
  .loading-ring {
    animation: none;
  }
}
@media (forced-colors: active) {
  :root {
    --text: CanvasText;
    --muted: CanvasText;
    --brand: Highlight;
    --line: CanvasText;
  }
  .search-input:focus-within {
    border-bottom-width: 2px;
  }
  #backdrop,
  #reader::before {
    display: none;
  }
  #reader {
    background: Canvas;
  }
  #search-results-panel,
  #contents-panel {
    background: Canvas;
    border-color: CanvasText;
  }
  #search-results button[aria-current="true"] {
    outline: 1px solid Highlight;
  }
}
.pdf-page {
  position: relative;
  overflow: hidden;
  background: white;
}
.pdf-page-blank {
  background: transparent !important;
}
.page-content {
  position: absolute;
}
.page-content img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.pdf-links,
.pdf-matches {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdf-links {
  z-index: 2;
}
.pdf-links a {
  position: absolute;
  pointer-events: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.pdf-links a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
#mount.turning .pdf-links a {
  pointer-events: none;
}
.pdf-matches span {
  position: absolute;
  background: rgb(255 215 0 / 40%);
}
.pdf-matches .active {
  outline: 2px solid #bd7300;
  background: rgb(255 175 0 / 55%);
}
.page-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #64788b;
}
.text-measure {
  position: fixed;
  left: -100000px;
  top: 0;
  opacity: 0;
  pointer-events: none;
  text-align: initial;
  line-height: 1;
  letter-spacing: normal;
  word-spacing: normal;
  text-size-adjust: none;
  transform-origin: 0 0;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.text-measure :is(span, br) {
  position: absolute;
  white-space: pre;
  transform-origin: 0 0;
}
.text-measure > :not(.markedContent),
.text-measure .markedContent span:not(.markedContent) {
  --font-height: 0;
  --scale-x: 1;
  --rotate: 0deg;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x))
    scale(var(--min-font-size-inv));
}
.text-measure .markedContent {
  display: contents;
}
