:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #0f766e;
}

* {
  box-sizing: border-box;
}

.app {
  min-height: 500px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0.75rem;
}

.viewerSection:fullscreen {
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at top, #d9e7f7, #bfd1e6 70%);
  padding: 0.5rem;
}

.viewerSection:fullscreen .viewerFrame {
  height: calc(100vh - 2.2rem);
  min-height: 0;
}

.viewerSection:fullscreen .pageFooter {
  display: none;
}

.searchInfo {
  color: var(--muted);
  font-size: 0.95rem;
  min-width: 64px;
  text-align: center;
}

.searchField {
  position: relative;
  flex: 0 1 220px;
  width: clamp(150px, 22vw, 220px);
  min-width: 140px;
}

#searchInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.55rem 2rem 0.55rem 0.7rem;
  background: #ffffff;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.45rem 0.7rem;
  background: #f8fafc;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

#nextBtn,
#searchBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.viewerFrame {
  position: relative;
  display: block;
  width: 100%;
  height: 700px;
 /** height: min(78dvh, calc(100dvh - 9.5rem)); **/
  min-height: 420px;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #dbe5f2;
  overflow: hidden;
  touch-action: none;
}

.pagesWrap {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 0rem;
  align-items: flex-start;
  justify-content: center;
  padding: 0.7rem 0.7rem 4.2rem;
  min-height: 100%;
  width: max-content;
}

.pageSlot {
  position: relative;
  flex: 0 0 auto;
}

#slotB[hidden] {
  display: none;
}

.pageSlot canvas {
  width: auto;
  height: auto;
  max-width: none;
  box-shadow: 0 8px 24px rgb(15 23 42 / 20%);
  background: #ffffff;
  display: block;
}

.highlightLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hitBox {
  position: absolute;
  background: rgb(250 204 21 / 45%);
  border: 1px solid rgb(250 204 21 / 80%);
  border-radius: 0.15rem;
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  color: var(--muted);
  font-weight: 600;
  background: rgb(255 255 255 / 80%);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
}

.navBtn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgb(255 255 255 / 38%);
  color: #0f172a;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  box-shadow: 0 8px 22px rgb(15 23 42 / 18%);
}

.navLeft {
  left: 0.45rem;
}

.navRight {
  right: 0.45rem;
}

.resultsPanel {
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 3.7rem;
  max-height: 38%;
  overflow: auto;
  z-index: 20;
  background: rgb(255 255 255 / 45%);
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 0.75rem;
  padding: 0.45rem;
  box-shadow: 0 8px 24px rgb(15 23 42 / 16%);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
}

.resultsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.25rem 0.5rem;
}

.resultsList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.resultBtn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 0.5rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.resultBtn.active {
  border-color: var(--accent);
  background: #ecfeff;
}

.searchDock {
  position: absolute;
  left: 50%;
  bottom: 0.6rem;
  transform: translateX(-50%);
 /* width: fit-content; */
	width: 90%;
  max-width: calc(100% - 1.4rem);
  display: flex;
  gap: 0.35rem;
  align-items: center;
  background: rgb(255 255 255 / 48%);
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 2rem;
  padding: 0.35rem;
  z-index: 30;
  box-shadow: 0 6px 18px rgb(15 23 42 / 14%);
  backdrop-filter: blur(12px) saturate(165%);
  -webkit-backdrop-filter: blur(12px) saturate(165%);
}

.zoomDock {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding-left: 0.15rem;
}

.zoomDock .btn {
  min-width: 2.05rem;
  padding-inline: 0.55rem;
  background: rgb(255 255 255 / 70%);
}

.clearInputBtn {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgb(148 163 184 / 65%);
  background: rgb(255 255 255 / 82%);
  color: #334155;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
}

.searchField.has-value .clearInputBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pageFooter {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  color: var(--muted);
  font-weight: 600;
}

.viewerFrame.can-pan canvas {
  cursor: grab;
}

.viewerFrame.is-dragging canvas {
  cursor: grabbing;
}

@media (max-width: 680px) {
  .app {
    padding: 0.35rem;
  }

  .btn {
    font-size: 0.95rem;
    padding: 0.5rem 0.65rem;
  }

  .viewerFrame {
    height: min(80dvh, calc(100dvh - 9.2rem));
    min-height: 360px;
  }

  .pagesWrap {
    padding: 0.55rem 0.55rem 4.15rem;
  }

  .navBtn {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  .searchDock {
    width: calc(100% - 10px);
    max-width: calc(100% - 10px);
    gap: 0.25rem;
    padding: 0.3rem;
    flex-wrap: nowrap;
  }

  #searchInput {
    min-width: 0;
  }

  .zoomDock {
    width: 100%;
    justify-content: flex-end;
  }

  .resultsPanel {
    left: 0.5rem;
    right: 0.5rem;
  }
}
