:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #eef2f5;
  color: #182331;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input { font: inherit; }

.viewer {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px),
    linear-gradient(#f5f7f9, #dce4eb);
  background-size: 28px 28px, auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #d7dde3;
  box-shadow: 0 2px 12px rgba(31,45,61,.08);
}

.title { display: grid; gap: 2px; }
.title strong { font-size: 18px; }
.title span { color: #627080; font-size: 13px; }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; flex-wrap: wrap; }
.controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.zoom-control { display: inline-flex; align-items: center; gap: 8px; color: #364656; font-size: 14px; font-weight: 700; white-space: nowrap; }
.zoom-control input { width: 130px; accent-color: #1f3c88; cursor: pointer; }
.zoom-control output { min-width: 40px; font-variant-numeric: tabular-nums; }

button {
  width: 42px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: #1f3c88;
  color: #fff;
  cursor: pointer;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.pdf-viewer-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 6px;
  background: #eef3fb;
  color: #1f3c88;
  border: 1px solid #1f3c88;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.pdf-viewer-button:hover,
.pdf-viewer-button:focus-visible { background: #dce7f8; }

#pageInfo { min-width: 80px; text-align: center; font-weight: 700; }
.sound-toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #364656; }

.book-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
}

.book { filter: drop-shadow(0 20px 28px rgba(20,30,40,.24)); transform-origin: center center; }
.book.is-zoomed { cursor: grab; touch-action: none; }
.book.is-dragging { cursor: grabbing; }
.page { position: relative; background: #fff; overflow: hidden; }
.page img { width: 100%; height: 100%; display: block; object-fit: contain; user-select: none; }

.pdf-link {
  position: absolute;
  display: block;
  z-index: 5;
  background: rgba(31, 60, 136, 0);
  border-radius: 4px;
}

.pdf-link:hover,
.pdf-link:focus-visible {
  background: rgba(31, 60, 136, .16);
  outline: 2px solid rgba(31, 60, 136, .55);
}

body.debug-links .pdf-link {
  background: rgba(255, 220, 0, .22);
  outline: 2px solid rgba(255, 120, 0, .9);
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; display: grid; }
  .toolbar-actions { justify-content: flex-start; gap: 10px; }
  .controls { justify-content: flex-start; }
  .book-wrap { padding: 12px; }
}
