:root {
  --bg: #1a1612;
  --panel: #2a231c;
  --text: #f5efe6;
  --muted: #b8a99a;
  --accent: #c9a227;
  --highlight: rgba(255, 235, 59, 0.38);
  --border: #4a3f34;
  --toolbar-compact-h: auto;
  --book-cover: #5c4a38;
  --book-spine: #6b5a48;
  --book-spine-highlight: #8a735c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.toolbar-compact {
  display: contents;
}

.toolbar-menu {
  display: contents;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.eyebrow {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.nav-bible {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  flex: 1;
}

.nav-bible label,
.nav-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.nav-field-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.search-bible {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  flex: 1 1 14rem;
  min-width: 12rem;
}

.search-bible label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
  flex: 1;
  min-width: 10rem;
}

#searchInput {
  width: 100%;
  min-width: 10rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(320px, 50vh);
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
}

.search-results button:last-child {
  border-bottom: none;
}

.search-results button:hover,
.search-results button:focus-visible {
  background: rgba(201, 162, 39, 0.12);
}

.search-result-label {
  display: block;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}

.search-result-snippet {
  display: block;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--muted);
}

.search-result-snippet .search-hit {
  background: rgba(0, 100, 255, 0.28);
  color: var(--text);
  padding: 0 0.1em;
  border-radius: 2px;
}

.search-results-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-results-warn {
  display: block;
  font-size: 0.72rem;
  color: #ffb4a8;
  margin-top: 0.2rem;
}

.book-appearance {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0;
  border-top: none;
}

.bible-pdf-source {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.bible-pdf-source-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.35;
}

.bible-pdf-source-status.is-warn {
  color: #ffb4a8;
}

.bible-pdf-source-actions .btn-account-sync {
  border-color: rgba(200, 160, 80, 0.55);
  color: #f0d9a0;
  font-weight: 600;
}

.google-drive-admin {
  margin-top: 0.35rem;
  padding: 0.35rem 0.45rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.google-drive-admin summary {
  cursor: pointer;
  color: var(--muted);
}

.google-drive-admin[hidden] {
  display: none !important;
}

.bible-pdf-source-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.bible-index-heading {
  margin-top: 0.35rem;
}

.settings-panel .book-appearance {
  padding-top: 0;
  border-top: none;
}

.book-appearance-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.book-color-preset {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--preset-cover, #5c4a38) 55%,
    var(--preset-spine, #6b5a48) 55%
  );
}

.book-color-field--pair {
  --pair-cover: #5c4a38;
  --pair-spine: #6b5a48;
}

.book-color-pair-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.book-color-pair-swatch {
  width: 2.5rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  background: linear-gradient(
    90deg,
    var(--pair-cover) 55%,
    var(--pair-spine) 55%
  );
}

.book-color-preset.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.book-color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text);
}

.book-color-field input[type="color"] {
  width: 2.5rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

select {
  min-width: 7rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.book-search-label input {
  min-width: 11rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

#bookSelect {
  min-width: 10rem;
}

#gotoBookBtn {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent);
}

select option.verse-no-pdf {
  color: var(--muted);
}

button {
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #1a1612;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.5rem;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.zoom-controls button {
  min-width: 2.5rem;
  min-height: 2.5rem;
  background: var(--bg);
  color: var(--text);
}

.page-indicator {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.5rem;
  white-space: nowrap;
}

.btn-goto-verse .goto-long {
  display: inline;
}

.btn-goto-verse .goto-short {
  display: none;
}

.viewer-main {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-main.mode-spread {
  overflow: hidden;
}

.viewer-main.mode-focus {
  overflow-x: hidden;
  overflow-y: auto;
}

.spread-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.5rem 0.75rem;
  touch-action: none;
}

.spread-viewport.is-zoomed {
  touch-action: pan-x pan-y;
}

.spread-viewport:not(.is-zoomed) {
  background: #2a231c;
}

.spread-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  background: #2a231c;
}

.spread-viewport.is-zoomed .spread-stage,
.spread-viewport.is-zoomed .spread-mount,
.spread-viewport.is-zoomed .book-spread,
.spread-viewport.is-zoomed .page-half {
  touch-action: pan-x pan-y;
}

.spread-stage:has(.is-page-turning),
.spread-stage:has(.is-flip-abort-settle) {
  overflow: visible;
}

.spread-mount {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spread-mount:has(.is-page-turning),
.spread-mount:has(.is-flip-abort-settle) {
  overflow: visible;
}

.spread-viewport:has(.is-page-turning),
.spread-viewport:has(.is-flip-abort-settle) {
  overflow: visible;
}

.page-turn-under {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.page-turn-under.is-preparing {
  visibility: hidden;
}

.page-turn-slot {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.page-flip > .page-turn-slot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  transform: none;
  transform-style: flat;
}

.spread-mount > .page-turn-slot.is-slot-past-spine {
  position: absolute;
  z-index: 4;
  transform: none;
  transform-style: flat;
  inset: auto;
}

.page-half > .page-turn-slot {
  inset: 0;
  width: 100%;
  height: 100%;
}

.page-turn-slot[hidden] {
  display: none !important;
}

.page-turn-slot--left {
  border-radius: 4px 0 0 4px;
}

.page-turn-slot--right {
  border-radius: 0 4px 4px 0;
}

.spread-mount:has(.is-turn-next) .page-turn-slot--right {
  box-shadow:
    0 4px 22px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.spread-mount:has(.is-turn-prev) .page-turn-slot--left {
  box-shadow:
    0 4px 22px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.spread-mount:has(.is-page-turning) .page-turn-slot {
  filter: none;
}

.spread-mount .page-flip-sheet.is-mount-layer {
  display: block;
  position: absolute;
  z-index: 10;
  pointer-events: none;
  transform-style: preserve-3d;
}

.spread-mount .page-flip-sheet.is-mount-layer.is-mount-next {
  transform-origin: left center;
}

.spread-mount .page-flip-sheet.is-mount-layer.is-mount-prev {
  transform-origin: right center;
}

.page-turn-slot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-spread.spread-prep-hidden {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
}

.book-spread.page-turn-current,
.book-spread.is-page-turning,
.book-spread.is-flip-abort-settle {
  position: relative;
  z-index: 2;
}

.book-spread.is-page-turning {
  overflow: visible;
}

.book-spread.is-page-turning .page-half:not(.is-flipping) {
  position: relative;
  z-index: 2;
  transition: box-shadow 180ms ease;
}

.book-spread.is-turn-next .page-half--left:not(.is-flipping) {
  filter: none;
}

/* Prev (swipe dreapta): pagina dreaptă rămâne ancoră vizuală */
.book-spread.is-turn-prev .page-half--right:not(.is-flipping) {
  filter: none;
  box-shadow: 3px 0 14px rgba(0, 0, 0, 0.18);
}

@keyframes pageSheetFlipNext {
  0% {
    transform: rotateY(0) translateZ(0);
  }
  35% {
    transform: rotateY(-63deg) translateZ(30px);
  }
  50% {
    transform: rotateY(-90deg) translateZ(34px);
  }
  65% {
    transform: rotateY(-117deg) translateZ(30px);
  }
  100% {
    transform: rotateY(-180deg) translateZ(0);
  }
}

@keyframes pageSheetFlipPrev {
  0% {
    transform: rotateY(0) translateZ(0);
  }
  35% {
    transform: rotateY(63deg) translateZ(30px);
  }
  50% {
    transform: rotateY(90deg) translateZ(34px);
  }
  65% {
    transform: rotateY(117deg) translateZ(30px);
  }
  100% {
    transform: rotateY(180deg) translateZ(0);
  }
}

@keyframes pageSheetCurlShade {
  0%,
  100% {
    opacity: 0.2;
  }
  35%,
  65% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes pageHalfShadowNext {
  0%,
  100% {
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.08);
  }
  50% {
    box-shadow:
      18px 14px 42px rgba(0, 0, 0, 0.52),
      8px 6px 18px rgba(0, 0, 0, 0.3),
      inset -1px 0 0 rgba(0, 0, 0, 0.08);
  }
}

@keyframes pageHalfShadowPrev {
  0%,
  100% {
    box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.08);
  }
  50% {
    box-shadow:
      -18px 14px 42px rgba(0, 0, 0, 0.52),
      -8px 6px 18px rgba(0, 0, 0, 0.3),
      inset 1px 0 0 rgba(0, 0, 0, 0.08);
  }
}

.book-spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
  grid-template-rows: 1fr;
  position: relative;
  background: transparent;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 8px 28px rgba(0, 0, 0, 0.32),
    0 18px 48px rgba(0, 0, 0, 0.18);
  max-width: 100%;
  overflow: visible;
  perspective: 2200px;
  transform-style: preserve-3d;
}

.book-spread:not(.book-spread--single)::before {
  content: "";
  position: absolute;
  inset: -3px -6px;
  z-index: -1;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    var(--book-cover) 0%,
    color-mix(in srgb, var(--book-cover) 88%, black) 48%,
    color-mix(in srgb, var(--book-cover) 75%, black) 100%
  );
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.page-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.page-flip-live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: block;
}

.page-half:not(.is-flipping) .page-flip-live {
  display: block;
  visibility: visible;
}

.page-flip-sheet {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  transform-style: preserve-3d;
}

.page-half.is-flipping .page-flip-live {
  display: none;
}

.page-half.is-flipping.is-flip-live-backing .page-flip-live {
  display: block;
  z-index: 0;
}

.page-half.is-flipping.is-flip-snap-cancel .page-flip-live {
  display: block;
  z-index: 0;
}

.page-half.is-flipping.is-flip-snap-cancel .page-flip-sheet {
  visibility: hidden !important;
  animation: none !important;
}

.page-half.is-flipping.is-flip-snap-cancel .page-turn-slot {
  display: none !important;
}

.page-half.is-flipping .page-flip-sheet {
  display: block;
  z-index: 12;
  will-change: transform;
}

.page-half.is-flipping.is-flip-next .page-flip-sheet {
  transform-origin: left center;
}

.page-half.is-flipping.is-flip-prev .page-flip-sheet {
  transform-origin: right center;
}

.page-flip-sheet.is-dragging {
  animation: none !important;
  transition: none;
}

.page-flip-sheet.is-snap-finishing {
  animation: none !important;
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.page-half.is-flipping:has(.page-flip-sheet.is-dragging),
.page-half.is-flipping:has(.page-flip-sheet.is-snap-finishing) {
  animation: none !important;
}

.page-half.is-flipping:has(.page-flip-sheet.is-dragging) {
  box-shadow:
    calc(var(--flip-progress, 0) * -8px) 0
    calc(12px + var(--flip-progress, 0) * 28px)
    rgba(0, 0, 0, calc(0.08 + var(--flip-progress, 0) * 0.22));
}

.page-flip-front,
.page-flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.page-flip-front {
  z-index: 1;
}

.page-flip-back {
  z-index: 0;
  transform: rotateY(180deg);
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, 0.22), transparent 34%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 18%),
    linear-gradient(135deg, #f4eddf 0%, #e9ddc8 48%, #d8c7ad 100%);
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.24),
    inset 24px 0 38px rgba(255, 255, 255, 0.14);
}

.page-flip-back-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 0;
}

.page-flip-back::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.22;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(64, 48, 34, 0.34) 0 1px,
      transparent 1px 8px
    ),
    linear-gradient(
      90deg,
      transparent 0 45%,
      rgba(64, 48, 34, 0.12) 45% 46%,
      transparent 46% 100%
    );
  filter: blur(0.35px);
}

.page-flip-back::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.32) 0%,
    rgba(0, 0, 0, 0.14) 10%,
    rgba(255, 255, 255, 0.08) 42%,
    transparent 72%
  );
}

.page-half.is-flipping.is-flip-prev .page-flip-back::after {
  background: linear-gradient(
    270deg,
    rgba(0, 0, 0, 0.32) 0%,
    rgba(0, 0, 0, 0.14) 10%,
    rgba(255, 255, 255, 0.08) 42%,
    transparent 72%
  );
}

.page-half.is-flipping .page-flip-back::before {
  opacity: 0.12;
}

.page-half.is-flipping .page-flip-back::after {
  opacity: 0.18;
}

.page-half.is-flipping {
  z-index: 10;
  overflow: visible;
  background: #fff;
  height: 100%;
  min-height: 100%;
}

.page-half.is-flipping .page-flip {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 100%;
}

.page-half.is-flipping .page-clip,
.page-half.is-flipping .page-flip-front {
  background: transparent;
}

.page-flip-front img,
.page-flip-back img,
.page-flip-face-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-half.is-flipping .page-flip-front {
  filter: none;
}

.page-half.is-flipping .page-flip-back img {
  filter: none;
}

.page-half.is-flipping .page-flip-front::after {
  display: none;
}

.page-half.is-flipping.is-flip-next .page-flip-sheet {
  animation: pageSheetFlipNext 480ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-half.is-flipping.is-flip-prev .page-flip-sheet {
  animation: pageSheetFlipPrev 480ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-half.is-flipping.is-flip-next {
  animation: pageHalfShadowNext 480ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-half.is-flipping.is-flip-prev {
  animation: pageHalfShadowPrev 480ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
  .page-flip-sheet {
    animation: none !important;
  }

  .page-half.is-flipping {
    animation: none !important;
    box-shadow: none !important;
  }

  .book-spread.is-turn-next .page-half--left:not(.is-flipping),
  .book-spread.is-turn-prev .page-half--right:not(.is-flipping) {
    filter: none;
    box-shadow: none;
    transition: none;
  }

  .page-half.is-flipping .page-flip-front {
    filter: none;
  }

  .page-half.is-flipping .page-flip-front::after {
    display: none;
  }
}

.spread-spine {
  width: 12px;
  align-self: stretch;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 18%,
      transparent 82%,
      rgba(0, 0, 0, 0.12) 100%
    ),
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.28) 0%,
      var(--book-spine) 22%,
      var(--book-spine-highlight) 48%,
      var(--book-spine) 78%,
      rgba(0, 0, 0, 0.28) 100%
    );
  box-shadow:
    inset 0 0 6px rgba(0, 0, 0, 0.35),
    inset 1px 0 0 rgba(255, 255, 255, 0.12),
    inset -1px 0 0 rgba(0, 0, 0, 0.2);
}

.page-half--left {
  border-radius: 3px 0 0 3px;
  box-shadow:
    -2px 0 6px rgba(0, 0, 0, 0.12),
    -1px 0 0 rgba(255, 255, 255, 0.5);
}

.page-half--right {
  border-radius: 0 3px 3px 0;
  box-shadow:
    2px 0 6px rgba(0, 0, 0, 0.12),
    1px 0 0 rgba(255, 255, 255, 0.5);
}

.page-half--left:not(.is-flipping) .page-flip-live .page-clip::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    270deg,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.08) 8px,
    transparent 28px
  );
}

.page-half--right:not(.is-flipping) .page-flip-live .page-clip::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.08) 8px,
    transparent 28px
  );
}

.page-half.is-flipping .page-clip::after {
  display: none;
}

.book-spread--single {
  grid-template-columns: 1fr;
}

.book-spread--single .spread-spine,
.book-spread--single .page-half--right {
  display: none;
}

.book-spread--single .page-half--full {
  max-width: 100%;
  border-radius: 4px;
  cursor: default;
}

.page-half {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: #fff;
  cursor: pointer;
  position: relative;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transform-style: preserve-3d;
}

.page-half:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}

.page-clip {
  overflow: hidden;
  width: 100%;
  height: 100%;
  position: relative;
  background: #fff;
}

.page-surface {
  position: relative;
  background: #fff;
}

.page-surface canvas {
  display: block;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.book-spread.loading .page-half {
  min-height: 400px;
  background: #eee;
}

.viewer-main.mode-focus .book-spread:not(.is-focused) {
  display: none;
}

.viewer-main.mode-focus .book-spread.is-focused {
  grid-template-columns: 1fr;
  max-width: calc(100vw - 2rem);
  margin: 0 auto;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

.viewer-main.mode-focus .book-spread.is-focused .spread-spine {
  display: none;
}

.viewer-main.mode-focus .book-spread.is-focused .page-half:not(.is-active) {
  display: none;
}

.viewer-main.mode-focus .book-spread.is-focused .page-half.is-active {
  grid-column: 1;
  border-radius: 4px;
  cursor: default;
}

.spread-nav-btn {
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.spread-nav-btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-spread {
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-spread:hover {
  background: rgba(201, 162, 39, 0.12);
}

.textLayer {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
  pointer-events: none;
  user-select: text;
  -webkit-user-select: text;
}

.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}

.textLayer span.markedContent {
  top: 0;
  height: 0;
}

.textLayer ::selection {
  background: rgba(0, 100, 255, 0.35);
}

.textLayer br::selection {
  background: transparent;
}


.highlight-layer {
  position: absolute;
  pointer-events: none;
  background: var(--highlight);
  border-radius: 2px;
  z-index: 10;
  transition: top 0.15s ease, left 0.15s ease;
}

.status-msg {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: var(--muted);
  padding: 0.5rem 1rem;
  pointer-events: none;
  z-index: 15;
  max-width: calc(100% - 2rem);
}

.status-msg.error {
  color: #ffb4a8;
  font-weight: 600;
}

/* Nu afișa status peste paginile cărții în citire / fullscreen */
body.reading-mode .status-msg,
body.is-fullscreen .status-msg {
  display: none !important;
}

.btn-reading,
.btn-fullscreen,
.btn-settings,
.btn-search-toggle {
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
  min-height: 2.5rem;
  cursor: pointer;
}

.btn-reading:hover,
.btn-fullscreen:hover,
.btn-settings:hover,
.btn-search-toggle:hover,
.btn-reading.is-active,
.btn-settings.is-open,
.btn-search-toggle.is-open {
  border-color: var(--accent);
  color: var(--accent);
}

.search-panel {
  position: fixed;
  z-index: 65;
  min-width: 18rem;
  max-width: min(24rem, calc(100vw - 1rem));
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.search-panel[hidden] {
  display: none !important;
}

.search-panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-panel .search-bible {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.search-panel-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.search-panel #searchInput {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.search-panel .search-results {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  max-height: min(280px, 40vh);
  margin-top: 0.15rem;
}

.settings-wrap {
  position: relative;
  display: inline-flex;
}

.settings-panel {
  position: fixed;
  z-index: 60;
  min-width: 16rem;
  max-width: calc(100vw - 1rem);
  max-height: min(90dvh, calc(100dvh - 1rem));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 0.75rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
}

.settings-panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 -0.75rem 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.settings-panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.settings-close-btn {
  flex-shrink: 0;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg, #1a1612);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.settings-close-btn:hover,
.settings-close-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .settings-panel {
    width: calc(100vw - 1rem);
    max-width: none;
    max-height: calc(100dvh - 1rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}

.reading-chrome {
  /* Bandă stângă sus: buton sus, meniu vertical în jos */
  --chrome-y: 8%;
  position: absolute;
  left: max(0.35rem, env(safe-area-inset-left, 0px));
  right: auto;
  top: var(--chrome-y);
  bottom: auto;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  z-index: 25;
  opacity: 1;
  transition: opacity 0.2s ease;
  pointer-events: auto;
  max-height: calc(100% - 1rem);
}

.reading-chrome-toggle {
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(26, 22, 18, 0.5);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  opacity: 0.55;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.reading-chrome.is-collapsed .reading-chrome-toggle {
  opacity: 0.55;
}

.reading-chrome.is-open {
  /* Poza 2: butoanele (B) ~1 cm sub ✕; poza 1 (pliat) rămâne neschimbată */
  gap: 1cm;
}

.reading-chrome.is-open .reading-chrome-toggle,
.reading-chrome-toggle:hover,
.reading-chrome-toggle:focus-visible {
  opacity: 0.95;
  background: rgba(26, 22, 18, 0.9);
  border-color: var(--border);
}

.reading-chrome-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 2.75rem;
  max-width: 2.75rem;
  padding: 0.4rem 0.2rem;
  background: rgba(26, 22, 18, 0.92);
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  max-height: min(82vh, 40rem);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.reading-chrome-goto {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  width: 100%;
  min-width: 0;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 0.2rem;
}

.reading-chrome-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  min-width: 0;
}

.reading-chrome-field-label {
  font-size: 0.52rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
  text-align: center;
  padding: 0;
}

.reading-chrome-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.2rem 0;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.68rem;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.reading-chrome-goto-btn {
  width: 100%;
  min-height: 2.75rem;
  margin-top: 0.15rem;
  padding: 0.25rem 0;
  border-radius: 0.65rem;
  border: 1px solid var(--accent);
  background: rgba(212, 168, 75, 0.22);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.1;
}

.reading-chrome-goto-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.reading-chrome-goto-btn:not(:disabled):hover {
  background: rgba(212, 168, 75, 0.35);
}

.reading-chrome-panel[hidden] {
  display: none !important;
}

.reading-chrome.is-dragging {
  transition: none;
}

.reading-chrome.is-dragging .reading-chrome-panel {
  opacity: 0.95;
}

.reading-chrome-drag {
  min-width: 2.4rem;
  min-height: 1.75rem;
  padding: 0.15rem 0.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
}

.reading-chrome-drag:hover {
  color: var(--accent);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.reading-chrome.is-dragging .reading-chrome-drag {
  cursor: grabbing;
}

.reading-chrome-btn {
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.reading-chrome-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

body.reading-mode .toolbar {
  display: none;
}

body.is-fullscreen .toolbar {
  display: none !important;
}

html:has(body.is-fullscreen),
body.is-fullscreen,
body.is-fullscreen .viewer-main {
  overscroll-behavior: none;
}

body.reading-mode .viewer-main {
  overscroll-behavior: none;
}

body.is-fullscreen .viewer-main {
  flex: 1;
  min-height: 100dvh;
  height: 100dvh;
}

body.is-fullscreen .spread-viewport {
  padding: max(0.25rem, env(safe-area-inset-top, 0px))
    max(0.25rem, env(safe-area-inset-right, 0px))
    max(0.25rem, env(safe-area-inset-bottom, 0px))
    max(0.25rem, env(safe-area-inset-left, 0px));
  height: 100%;
}

body.is-fullscreen .spread-viewport:not(.is-zoomed) {
  overflow: hidden;
  overscroll-behavior: none;
}

body.is-fullscreen .spread-viewport.is-zoomed {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

body.is-fullscreen .spread-viewport.is-pinching {
  touch-action: none;
}

body.is-fullscreen .spread-viewport.is-pinching .spread-stage,
body.is-fullscreen .spread-viewport.is-pinching .spread-mount,
body.is-fullscreen .spread-viewport.is-pinching .book-spread,
body.is-fullscreen .spread-viewport.is-pinching .page-half {
  touch-action: none;
}

body.is-fullscreen .spread-viewport.is-zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

body.is-fullscreen .spread-viewport.is-zoomed .book-spread {
  max-width: none;
}

body.is-fullscreen .spread-viewport.is-zoomed .page-half--full {
  max-width: none;
}

body.is-fullscreen .spread-viewport.is-zoomed .spread-stage {
  width: auto;
  height: auto;
  min-width: 100%;
  min-height: 100%;
}

body.is-fullscreen .reading-chrome {
  display: flex;
  /* Fullscreen: coboară banda stângă ~1 cm față de modul cu toolbar */
  top: calc(var(--chrome-y, 8%) + 1.1cm);
}

body.is-fullscreen .reading-chrome.is-open {
  /* Spațiu mai mare între ✕ și butoanele de sub (B) */
  gap: 1.5cm;
}

body.reading-mode .viewer-main {
  flex: 1;
  min-height: 100dvh;
  height: 100dvh;
}

body.reading-mode .spread-viewport {
  padding: max(0.25rem, env(safe-area-inset-top, 0px))
    max(0.25rem, env(safe-area-inset-right, 0px))
    max(0.25rem, env(safe-area-inset-bottom, 0px))
    max(0.25rem, env(safe-area-inset-left, 0px));
  height: 100%;
}

body.reading-mode .spread-viewport:not(.is-zoomed) {
  overflow: hidden;
  overscroll-behavior: none;
}

body.reading-mode .spread-viewport.is-zoomed {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

body.reading-mode .spread-viewport.is-pinching {
  touch-action: none;
}

body.reading-mode .spread-viewport.is-pinching .spread-stage,
body.reading-mode .spread-viewport.is-pinching .spread-mount,
body.reading-mode .spread-viewport.is-pinching .book-spread,
body.reading-mode .spread-viewport.is-pinching .page-half {
  touch-action: none;
}

body.reading-mode .spread-viewport.is-zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

body.reading-mode .spread-viewport.is-zoomed .book-spread {
  max-width: none;
}

body.reading-mode .spread-viewport.is-zoomed .page-half--full {
  max-width: none;
}

body.reading-mode .spread-viewport.is-zoomed .spread-stage {
  width: auto;
  height: auto;
  min-width: 100%;
  min-height: 100%;
}

body.reading-mode .status-msg {
  bottom: max(4.5rem, calc(env(safe-area-inset-bottom, 0px) + 3.5rem));
}

body.reading-mode .reading-chrome {
  display: flex;
}

/* —— Tabletă —— */
@media (max-width: 1024px) and (min-width: 769px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .toolbar-compact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .toolbar-menu {
    display: block;
    width: 100%;
  }

  .toolbar-menu-summary {
    display: none;
  }

  .toolbar-menu-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: flex-end;
    width: 100%;
  }

  .nav-bible--compact {
    flex: 1;
    flex-wrap: nowrap;
  }

  .nav-bible--compact .nav-field {
    flex: 1;
    min-width: 0;
  }

  .nav-bible--compact select {
    width: 100%;
    min-width: 0;
  }

  .zoom-controls--compact {
    justify-content: flex-end;
    width: 100%;
  }

  .brand {
    flex: 1 1 100%;
  }

  .brand h1 {
    font-size: 0.95rem;
  }

  .nav-bible--menu {
    flex: 1 1 auto;
  }

  .search-bible {
    flex: 1 1 100%;
    min-width: 0;
  }

  .spread-viewport {
    padding: 0.35rem 0.5rem;
  }
}

/* —— Telefon —— */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .toolbar-compact {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.35rem 0.5rem;
    padding: 0.4rem 0.5rem;
    width: 100%;
    align-items: center;
  }

  .nav-bible--compact {
    grid-column: 1;
    grid-row: 1 / 3;
    display: grid;
    grid-template-columns: 1fr 0.65fr 0.65fr auto;
    gap: 0.3rem;
    align-items: end;
    flex: none;
    width: 100%;
  }

  .nav-bible--compact .nav-field {
    min-width: 0;
  }

  .nav-bible--compact .nav-field-label {
    font-size: 0.65rem;
    line-height: 1;
  }

  .nav-bible--compact select {
    width: 100%;
    min-width: 0;
    padding: 0.4rem 0.25rem;
    font-size: 0.82rem;
    min-height: 2.5rem;
  }

  .btn-goto-verse {
    align-self: end;
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .btn-goto-verse .goto-short {
    display: inline;
  }

  .btn-goto-verse .goto-long {
    display: none;
  }

  .zoom-controls--compact {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    margin-left: 0;
    gap: 0.25rem;
  }

  .zoom-controls--compact .btn-fit-width {
    display: none;
  }

  .page-indicator {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: 0.7rem;
    text-align: right;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .toolbar-menu {
    display: block;
    width: 100%;
    border-top: 1px solid var(--border);
  }

  .toolbar-menu-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
    user-select: none;
    min-height: 2.5rem;
  }

  .toolbar-menu-summary::-webkit-details-marker {
    display: none;
  }

  .toolbar-menu-summary::after {
    content: "▾";
    font-size: 0.75rem;
    transition: transform 0.15s ease;
  }

  .toolbar-menu[open] .toolbar-menu-summary::after {
    transform: rotate(180deg);
  }

  .toolbar-menu-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 0.65rem;
    max-height: min(45vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
  }

  .brand h1 {
    font-size: 0.9rem;
  }

  .nav-bible--menu {
    flex-direction: column;
    align-items: stretch;
  }

  .book-search-label input,
  .search-bible label,
  #searchInput {
    width: 100%;
    min-width: 0;
  }

  .search-bible {
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .search-results {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    max-height: min(200px, 35vh);
  }

  .spread-viewport {
    padding: 0.25rem 0.35rem;
  }

  .spread-nav-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  .book-spread {
    max-width: 100%;
  }

  .btn-spread {
    font-size: 0.72rem;
    padding: 0.3rem 0.45rem;
  }
}

/* —— Desktop: layout clasic pe un rând —— */
@media (min-width: 1025px) {
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: flex-end;
    padding: 0.75rem 1rem;
  }

  .toolbar-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    flex: 1 1 auto;
  }

  .nav-bible--compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: flex-end;
    flex: 1;
  }

  .nav-bible--compact .nav-field-label {
    display: block;
  }

  .nav-bible--compact .nav-field-label:first-child::after {
    content: none;
  }

  .nav-field-label:empty {
    display: none;
  }

  .btn-goto-verse .goto-short {
    display: none;
  }

  .btn-goto-verse .goto-long {
    display: inline;
  }

  .zoom-controls--compact .btn-fit-width {
    display: inline-block;
  }

  .toolbar-menu {
    display: contents;
  }

  .toolbar-menu-summary {
    display: none;
  }

  .toolbar-menu-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    flex: 1 1 auto;
  }

  .brand {
    flex: 0 0 auto;
  }

  .nav-bible--menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: flex-end;
  }

  .search-bible {
    flex: 1 1 14rem;
    min-width: 12rem;
  }
}

/* --- Cont / autentificare --- */
.btn-account,
.btn-study,
.btn-annotate,
.btn-local-pdf-return {
  font-size: 0.82rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
}

.btn-local-pdf-return {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.18);
  font-weight: 600;
}

.btn-local-pdf-return[hidden] {
  display: none !important;
}

.btn-annotate.is-active {
  background: rgba(255, 229, 102, 0.25);
  border-color: #ffe566;
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 1rem;
}

.auth-panel-inner {
  position: relative;
  width: min(100%, 22rem);
  background: #2a231c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.auth-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: #d8c9b0;
  font-size: 1.4rem;
  cursor: pointer;
}

.auth-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: #d8c9b0;
}

.auth-panel input {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1a1612;
  color: #f5efe3;
}

.auth-terms-check {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.55rem !important;
  font-size: 0.78rem !important;
  line-height: 1.35;
  margin: 0.75rem 0 0.35rem !important;
}

.auth-terms-check input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: #c4a574;
}

.auth-terms-check a {
  color: #e8d4b0;
  text-decoration: underline;
}

.auth-terms-hint {
  margin: 0.15rem 0 0.5rem !important;
  font-size: 0.75rem;
  opacity: 0.85;
}

.auth-terms-hint a {
  color: #e8d4b0;
}

.terms-gate {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.terms-gate[hidden] {
  display: none !important;
}

.terms-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 8, 0.72);
}

.terms-gate-card {
  position: relative;
  z-index: 1;
  width: min(28rem, 100%);
  max-height: min(90vh, 36rem);
  overflow: auto;
  background: #2a241c;
  color: #f5efe3;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.terms-gate-card h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.terms-gate-card p {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  color: #d8c9b0;
}

.terms-gate-card a {
  color: #e8d4b0;
}

.terms-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

a.btn-annotate-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-auth-primary,
.btn-auth-secondary {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-auth-primary {
  background: #c9a227;
  color: #1a1612;
}

.btn-auth-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-auth-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #f2e8d8;
}

.auth-links {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.auth-links button {
  background: none;
  border: none;
  color: #c9a227;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: 0.85rem;
}

.auth-message {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: rgba(125, 255, 179, 0.12);
  color: #b8f5d0;
  font-size: 0.85rem;
}

.auth-message.is-error {
  background: rgba(255, 120, 100, 0.15);
  color: #ffb8a8;
}

.account-summary {
  margin: 0 0 1rem;
  color: #d8c9b0;
  font-size: 0.9rem;
}

/* --- Sublinieri utilizator --- */
.annotate-settings {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.annotate-settings.is-active {
  border-top-color: var(--accent);
}

.annotate-settings-title {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  color: var(--text);
}

.annotate-toggle,
.annotate-color-field,
.annotate-note-field,
.annotate-tool-field,
.annotate-width-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.annotate-tool-field,
.annotate-width-field {
  border: none;
  padding: 0;
  margin-inline: 0;
}

.annotate-tool-field legend,
.annotate-width-field legend,
.annotate-field-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.annotate-tool-row,
.annotate-width-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.annotate-tool-option,
.annotate-width-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.76rem;
}

.annotate-tool-option:has(input:checked),
.annotate-width-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.12);
}

.annotate-swatch-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.annotate-swatch {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.annotate-swatch.is-active {
  border-color: #f2e8d8;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.annotate-color-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.annotate-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
}

.annotate-note-field input,
.annotate-color-field input[type="color"] {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.btn-annotate-save {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #1a1612;
  font-weight: 600;
  cursor: pointer;
}

.annotate-clear-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.btn-annotate-clear {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.76rem;
  cursor: pointer;
}

.btn-annotate-clear--danger {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffb8a8;
}

.user-bibles-settings {
  margin-bottom: 0.65rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.annotate-bible-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.annotate-bible-field select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.annotate-bible-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.markup-bible-label {
  font-size: 0.72rem;
  color: #4a4035;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.25rem;
}

.annotate-hint {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.annotate-feedback {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: #ffb8a8;
}

.annotate-feedback.is-ok {
  color: #b8f5d0;
}

.annotate-settings[hidden] {
  display: none !important;
}

.annotate-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 130;
  margin: 0;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  background: rgba(42, 35, 28, 0.95);
  border: 1px solid rgba(201, 162, 39, 0.45);
  color: #f2e8d8;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.pen-ink-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.pen-ink-canvas {
  mix-blend-mode: multiply;
  pointer-events: none;
}

body.annotate-mode-active #spreadViewport {
  touch-action: none;
}

body.annotate-mode-active .spread-stage {
  cursor: crosshair;
}

body.annotate-tool-eraser.annotate-mode-active .spread-stage,
body.annotate-tool-eraser.annotate-mode-active #spreadViewport {
  cursor: cell;
}

.markup-toolbar {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
}

.markup-toolbar[hidden] {
  display: none !important;
}

.markup-btn {
  width: 2.1rem;
  height: 2.1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #2a231c;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.markup-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.markup-btn:not(:disabled):hover,
.markup-tool-btn.is-active {
  background: rgba(42, 35, 28, 0.08);
}

.markup-tool-btn.is-active {
  box-shadow: inset 0 0 0 1px rgba(42, 35, 28, 0.15);
}

.markup-sep {
  width: 1px;
  height: 1.4rem;
  background: rgba(0, 0, 0, 0.12);
  margin: 0 0.15rem;
}

.markup-color-btn {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 0;
  background: #ffe566;
}

.user-annotations-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.user-highlight {
  position: absolute;
  border-radius: 3px;
  opacity: 0.42;
  mix-blend-mode: multiply;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* --- Studiul meu --- */
.study-panel[hidden] {
  display: none !important;
}

.auth-panel[hidden] {
  display: none !important;
}

.study-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 110;
  width: min(100vw, 22rem);
  height: 100%;
  background: #2a231c;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.study-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.study-panel-head h2 {
  margin: 0;
  font-size: 1rem;
  color: #f2e8d8;
}

.study-panel-head button {
  border: none;
  background: transparent;
  color: #d8c9b0;
  font-size: 1.35rem;
  cursor: pointer;
}

.study-panel-actions {
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.study-panel-actions button {
  touch-action: manipulation;
}

.app-version-label {
  display: block;
  font-size: 0.72rem;
  color: #8a7a68;
  margin-top: 0.15rem;
}

.app-version-label--settings {
  margin: 0 0 0.65rem;
}

.study-notebook-error {
  margin: 0 0 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: rgba(255, 100, 80, 0.15);
  border: 1px solid rgba(255, 100, 80, 0.35);
  color: #ffb8a8;
  font-size: 0.82rem;
}

.study-notebook-error[hidden] {
  display: none !important;
}

.study-panel-actions button,
.study-reader-actions button,
.study-editor-actions button {
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  margin-right: 0.35rem;
}

.btn-danger {
  border-color: rgba(255, 100, 80, 0.35) !important;
  color: #ffb8a8 !important;
}

.study-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem;
  overflow: auto;
  flex: 0 0 auto;
  max-height: 28vh;
}

.study-list-item {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.25rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: #e8dcc8;
  cursor: pointer;
}

.study-list-item.is-active {
  border-color: #c9a227;
  background: rgba(201, 162, 39, 0.12);
}

.study-reader,
.study-editor {
  flex: 1;
  overflow: auto;
  padding: 0.75rem 1rem 1rem;
}

.study-notebook-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.study-notebook-modal[hidden] {
  display: none !important;
}

.study-notebook-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.study-notebook-modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 22rem);
  max-height: 90vh;
  overflow: auto;
  background: #2a231c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 1rem 1rem 0.85rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.study-notebook-creator-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  color: #f2e8d8;
}

.study-notebook-modal-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: #c8b8a0;
}

.study-notebook-modal-card select,
.study-notebook-modal-card input {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #1a1612;
  color: #f5efe3;
  font-family: inherit;
  font-size: 1rem;
}

.study-notebook-modal-card button {
  touch-action: manipulation;
}

body.study-notebook-modal-open {
  overflow: hidden;
}

.study-reader-body {
  line-height: 1.55;
  color: #e8dcc8;
  font-size: 0.92rem;
  max-height: 50vh;
  overflow: auto;
  padding: 0.5rem 0;
}

.study-reader-body .bible-ref {
  color: #c9a227;
  text-decoration: underline;
  cursor: pointer;
}

.study-editor label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: #d8c9b0;
}

.study-editor input,
.study-editor textarea,
.study-editor select {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1a1612;
  color: #f5efe3;
  font-family: inherit;
}

.study-empty,
.study-loading {
  padding: 0.75rem 1rem;
  color: #a89880;
  font-size: 0.85rem;
}

/* Caiet Studiul meu */
body.notebook-mode-active #spreadViewport {
  pointer-events: none;
  visibility: hidden;
}

body.notebook-mode-active .notebook-overlay,
body.notebook-mode-active .notebook-overlay * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.notebook-overlay {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #1a1612;
  color: #f2e8d8;
  overflow: hidden;
}

body.notebook-header-hidden .notebook-header {
  display: none;
}

.notebook-overlay[hidden] {
  display: none !important;
}

.notebook-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  touch-action: none;
}

.notebook-header-titles {
  min-width: 0;
  touch-action: none;
}

.notebook-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.notebook-paper-label {
  font-size: 0.78rem;
  color: #a89880;
}

.notebook-header-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.notebook-close-btn,
.notebook-delete-btn {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
}

.notebook-page-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 0.5rem 0.5rem 4.5rem;
  touch-action: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.notebook-page-stage {
  position: relative;
  flex-shrink: 0;
  transform-origin: center center;
}

.notebook-paper-canvas,
.notebook-ink-canvas,
.notebook-live-canvas {
  position: absolute;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
}

.notebook-ink-canvas {
  z-index: 1;
  mix-blend-mode: multiply;
  touch-action: none;
  pointer-events: auto;
  cursor: crosshair;
}

.notebook-live-canvas {
  z-index: 2;
  box-shadow: none;
  mix-blend-mode: multiply;
  touch-action: none;
  pointer-events: none;
}

.notebook-chrome {
  --chrome-x: 50%;
  --chrome-y: 94%;
  position: absolute;
  left: var(--chrome-x);
  top: var(--chrome-y);
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(26, 22, 18, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  z-index: 95;
  backdrop-filter: blur(4px);
  opacity: 0.28;
  transition: opacity 0.25s ease, background 0.25s ease, border-color 0.25s ease;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.notebook-chrome.is-faded {
  opacity: 0.28;
}

.notebook-chrome.is-active,
.notebook-chrome:hover,
.notebook-chrome:focus-within {
  opacity: 0.92;
  background: rgba(26, 22, 18, 0.82);
  border-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.notebook-chrome.is-dragging {
  opacity: 0.95;
  transition: none;
}

.notebook-chrome-drag {
  min-width: 1.75rem;
  min-height: 2.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #a89880;
  font-size: 0.85rem;
  cursor: grab;
  touch-action: none;
}

.notebook-chrome-btn {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

.notebook-chrome-btn:hover,
.notebook-chrome-btn.is-active,
.notebook-chrome-btn.is-open {
  border-color: #c9a227;
  color: #f2e8d8;
  background: rgba(201, 162, 39, 0.2);
}

.notebook-chrome-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.notebook-markup-arc {
  --markup-arc-height: 72px;
  position: fixed;
  width: min(92vw, 380px);
  height: calc(var(--markup-arc-height) + 2.5rem);
  transform: translate(-50%, -100%);
  z-index: 96;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.notebook-markup-arc[hidden] {
  display: none !important;
}

.notebook-markup-arc-track {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  height: calc(100% - 0.35rem);
  transform: translateX(-50%);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-bottom: none;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: rgba(248, 248, 250, 0.9);
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.notebook-markup-arc-items {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.notebook-arc-btn,
.notebook-arc-width {
  position: absolute;
  margin: 0;
}

.notebook-arc-btn {
  width: 2.35rem;
  height: 2.35rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #2a231c;
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.notebook-arc-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.notebook-arc-btn:not(:disabled):hover,
.notebook-markup-tool.is-active {
  background: rgba(42, 35, 28, 0.1);
}

.notebook-arc-color-btn {
  --arc-ink-color: #1a1a1a;
  background: var(--arc-ink-color);
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.notebook-arc-color-btn[aria-expanded="true"] {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px #c9a227,
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.notebook-arc-width {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  padding: 0.15rem 0.25rem;
  border-radius: 999px;
  background: rgba(42, 35, 28, 0.06);
}

.notebook-arc-width[hidden] {
  display: none !important;
}

.notebook-arc-width-btn {
  width: 1.55rem;
  height: 1.55rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  color: #2a231c;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.notebook-arc-width-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.notebook-arc-width-label {
  min-width: 1.35rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #2a231c;
}

.notebook-color-palette-arc {
  position: fixed;
  width: min(52vw, 200px);
  height: 7.5rem;
  transform: translate(-50%, -100%);
  z-index: 97;
  pointer-events: none;
}

.notebook-color-palette-arc[hidden] {
  display: none !important;
}

.notebook-color-palette-track {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 115%;
  height: calc(100% - 0.2rem);
  transform: translateX(-50%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: none;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: rgba(248, 248, 250, 0.94);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.notebook-color-palette-items {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.notebook-palette-item {
  position: absolute;
  width: 2.15rem;
  height: 2.15rem;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.notebook-palette-swatch {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.notebook-palette-swatch.is-active {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px rgba(0, 0, 0, 0.55);
}

.notebook-palette-wheel {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: conic-gradient(
    #ff6b6b,
    #ffb347,
    #ffe566,
    #7dffb3,
    #7ec8ff,
    #c084fc,
    #ff6b6b
  );
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.notebook-palette-wheel input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 480px) {
  .notebook-markup-arc {
    width: min(96vw, 340px);
    --markup-arc-height: 64px;
  }

  .notebook-arc-btn {
    width: 2.1rem;
    height: 2.1rem;
    font-size: 0.95rem;
  }

  .notebook-color-palette-arc {
    width: min(68vw, 180px);
    height: 6.75rem;
  }

  .notebook-palette-item {
    width: 1.95rem;
    height: 1.95rem;
  }
}

body.notebook-mode-active.is-fullscreen #notebookOverlay {
  background: #000;
}

body.notebook-mode-active.is-fullscreen.notebook-header-hidden .notebook-header,
body.notebook-mode-active.is-fullscreen #notebookOverlay .notebook-header {
  opacity: 0;
  pointer-events: none;
}

body.notebook-mode-active.is-fullscreen .notebook-page-wrap {
  padding-bottom: 0.5rem;
}

.notebook-width-control {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.15rem;
}

.notebook-width-control[hidden] {
  display: none !important;
}

.notebook-width-btn {
  width: 1.65rem;
  height: 1.65rem;
  border: none;
  border-radius: 6px;
  background: rgba(42, 35, 28, 0.08);
  color: #2a231c;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.notebook-width-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.notebook-width-label {
  min-width: 1.75rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #2a231c;
}

body.notebook-eraser-active .notebook-page-wrap {
  cursor: cell;
}

.notebook-settings-panel {
  position: fixed;
  z-index: 200;
  min-width: 16rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(26, 22, 18, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  color: #f2e8d8;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.notebook-settings-panel[hidden] {
  display: none !important;
}

.notebook-settings-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}

.notebook-settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-size: 0.82rem;
  color: #a89880;
}

.notebook-settings-field select {
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
}

.notebook-page-color-presets {
  display: flex;
  gap: 0.4rem;
}

.notebook-page-color-preset {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}

.notebook-page-color-preset.is-active {
  border-color: #c9a227;
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.35);
}

.notebook-settings-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.notebook-settings-btn {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.85rem;
}

.notebook-settings-btn--danger {
  border-color: rgba(220, 80, 80, 0.4);
  color: #f0a0a0;
}

.google-drive-client-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
}

.google-drive-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

.google-drive-modal[hidden] {
  display: none !important;
}

.google-drive-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.google-drive-modal-panel {
  position: relative;
  z-index: 1;
  width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(80vh, 36rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.google-drive-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.google-drive-modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.google-drive-modal-close {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.google-drive-modal-status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.google-drive-modal-folder,
.google-drive-modal-tools {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

.google-drive-modal-folder input,
.google-drive-modal-tools input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
}

.google-drive-modal-folder button,
.google-drive-modal-tools button,
.google-drive-modal-folder-actions button {
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.78rem;
}

.google-drive-modal-folder-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.google-drive-folder-label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.google-drive-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.google-drive-file-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

.google-drive-file-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.google-drive-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.google-drive-modal-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.study-local-pdf-note {
  margin: 0 0 0.65rem;
  padding: 0 0.15rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #a89880;
}

.study-section-title {
  margin: 0.75rem 0 0.35rem;
  padding: 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.study-panel-actions .btn-study-primary {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.study-panel-actions .btn-study-secondary {
  opacity: 0.9;
  font-size: 0.78rem;
}

.study-local-pdf-list .study-local-pdf-row {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

.study-local-pdf-list .study-local-pdf-row .study-list-item {
  flex: 1;
}

.study-local-pdf-remove {
  flex: 0 0 2.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: #ffb4a8;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.study-panel-actions {
  flex-wrap: wrap;
}

.local-pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  flex-direction: column;
  background: #12100e;
}

.local-pdf-overlay[hidden] {
  display: none !important;
}

body.local-pdf-open {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.local-pdf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.65rem, env(safe-area-inset-top, 0px)) 1rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(20, 18, 16, 0.96);
  flex-wrap: wrap;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 10;
}

.study-pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  justify-content: center;
  flex-wrap: wrap;
  min-width: 0;
}

.study-pdf-toolbar[hidden] {
  display: none !important;
}

.study-pdf-layout-wrap {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
}

.study-pdf-layout-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.38rem 1.55rem 0.38rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23d8ccb8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
      right 0.55rem center / 0.65rem no-repeat,
    rgba(201, 162, 39, 0.18);
  color: #f2e8d8;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  max-width: 8.5rem;
}

.study-pdf-layout-select:focus-visible {
  outline: 2px solid rgba(201, 162, 39, 0.65);
  outline-offset: 2px;
}

.study-pdf-manual-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

.study-pdf-manual-tools[hidden] {
  display: none !important;
}

.study-pdf-tool {
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #d8ccb8;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.study-pdf-tool.is-active {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.2);
  color: #f2e8d8;
}

.study-pdf-ink-settings {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.16rem 0.24rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.study-pdf-ink-settings[hidden] {
  display: none !important;
}

.study-pdf-ink-tool {
  min-width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #d8ccb8;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.study-pdf-ink-tool.is-active {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.22);
  color: #f2e8d8;
}

.study-pdf-ink-tool:disabled {
  opacity: 0.35;
  cursor: default;
}

.study-pdf-ink-tool--label {
  min-width: auto;
  padding: 0 0.45rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.study-pdf-ink-tool--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.study-pdf-eraser-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.study-pdf-eraser-modes {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.study-pdf-eraser-modes[hidden] {
  display: none !important;
}

.study-pdf-color-chip {
  --study-pdf-ink-color: #1a1a1a;
  width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: var(--study-pdf-ink-color);
  cursor: pointer;
  overflow: hidden;
}

.study-pdf-color-chip.is-disabled {
  opacity: 0.38;
  cursor: default;
}

.study-pdf-color-chip input {
  width: 140%;
  height: 140%;
  border: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.study-pdf-color-chip.is-disabled input {
  cursor: default;
}

.study-pdf-width-btn {
  min-width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.study-pdf-width-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.study-pdf-width-label {
  min-width: 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: #d8ccb8;
  font-variant-numeric: tabular-nums;
}

.study-pdf-page-info {
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: #a89880;
  white-space: nowrap;
}

.study-pdf-toc-panel {
  flex: 0 0 auto;
  max-height: min(42vh, 360px);
  overflow: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 10, 8, 0.96);
  padding: 0.65rem 0.85rem 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.study-pdf-toc-panel[hidden] {
  display: none !important;
}

body.study-pdf-toc-open .study-pdf-toc-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  right: 0;
  top: var(--study-pdf-toc-top, 7.5rem);
  bottom: 0;
  z-index: 225;
  max-height: none;
  border-bottom: 0;
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
}

body.study-pdf-toc-open .local-pdf-viewport.study-pdf-viewport--toc-covered {
  pointer-events: none;
}

.study-pdf-toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.study-pdf-toc-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f2e8d8;
}

.study-pdf-toc-close {
  border: 0;
  background: transparent;
  color: #c9a227;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
}

.study-pdf-toc-hint {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  color: #a89880;
  line-height: 1.35;
}

.study-pdf-toc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.study-pdf-toc-scan-btn,
.study-pdf-toc-accept-all-btn {
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.16);
  color: #f2e8d8;
  font-size: 0.8rem;
  cursor: pointer;
}

.study-pdf-toc-scan-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.study-pdf-toc-accept-all-btn {
  border-color: rgba(120, 200, 120, 0.45);
  background: rgba(80, 160, 80, 0.18);
}

.study-pdf-toc-edit-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: #d8ccb8;
  cursor: pointer;
  user-select: none;
}

.study-pdf-toc-edit-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #c9a227;
  cursor: pointer;
}

.study-pdf-toc-edit-tools {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.study-pdf-toc-move-up,
.study-pdf-toc-move-down,
.study-pdf-toc-edit-confirmed {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0;
}

.study-pdf-toc-move-up:disabled,
.study-pdf-toc-move-down:disabled {
  opacity: 0.35;
  cursor: default;
}

.study-pdf-toc-item--editing .study-pdf-toc-jump {
  flex: 1 1 auto;
  min-width: 0;
}

.study-pdf-toc-item--editing .study-pdf-toc-remove {
  width: 1.85rem;
  height: 1.85rem;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}

.study-pdf-toc-section {
  margin-bottom: 0.65rem;
}

.study-pdf-toc-section[hidden] {
  display: none !important;
}

.study-pdf-toc-section-title {
  margin: 0 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: #c9a227;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.study-pdf-toc-item--proposal {
  border-radius: 8px;
  border: 1px dashed rgba(201, 162, 39, 0.35);
  background: rgba(201, 162, 39, 0.06);
  padding: 0.35rem 0.45rem;
}

.study-pdf-toc-proposal-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.study-pdf-toc-proposal-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.study-pdf-toc-accept,
.study-pdf-toc-edit,
.study-pdf-toc-ignore {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.study-pdf-toc-accept {
  border-color: rgba(120, 200, 120, 0.45);
  color: #9fd49f;
}

.study-pdf-toc-ignore {
  color: #c9a227;
}

.study-pdf-toc-list {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.study-pdf-toc-item {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

.study-pdf-toc-jump {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.84rem;
}

.study-pdf-toc-jump:hover {
  border-color: rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.12);
}

.study-pdf-toc-jump-label {
  flex: 1 1 auto;
  min-width: 0;
}

.study-pdf-toc-jump-page {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: #a89880;
  font-variant-numeric: tabular-nums;
}

.study-pdf-toc-remove {
  flex: 0 0 auto;
  width: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c9a227;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.study-pdf-toc-mark {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.study-pdf-toc-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: #a89880;
}

.study-pdf-toc-field--grow {
  flex: 1 1 10rem;
  min-width: 8rem;
}

.study-pdf-toc-field input {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: #f2e8d8;
  font-size: 0.84rem;
}

.study-pdf-toc-field input[type="number"] {
  width: 4.5rem;
}

.study-pdf-toc-mark-btn {
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.18);
  color: #f2e8d8;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

body.study-pdf-toc-open .local-pdf-overlay {
  display: flex;
  flex-direction: column;
}

body.study-pdf-toc-open .local-pdf-header {
  flex: 0 0 auto;
}

body.study-pdf-toc-open .study-pdf-toc-panel {
  flex: 0 0 auto;
}

body.study-pdf-toc-open .local-pdf-viewport {
  flex: 1 1 auto;
  min-height: 0;
}

.study-pdf-page--placeholder .study-pdf-page-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: inherit;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
}

body.study-pdf-mode-read .study-pdf-pen-layer {
  pointer-events: none;
  cursor: default;
}

body.study-pdf-mode-select .study-pdf-pen-layer {
  pointer-events: none;
  cursor: text;
}

body.study-pdf-mode-refs .study-pdf-pen-layer {
  pointer-events: none;
  cursor: pointer;
}

body.study-pdf-mode-fill .study-pdf-pen-layer {
  cursor: text;
}

body.study-pdf-mode-dynamic .study-pdf-pen-layer {
  /*
   * pointer-events: none — degetul „trece prin” la pagină și derulează nativ.
   * Pencil e prins în capture pe viewport (pointerType=pen) și doar scrie.
   */
  pointer-events: none;
  touch-action: none;
  cursor: crosshair;
  z-index: 5;
}

body.study-pdf-mode-dynamic.study-pdf-ink-erase .study-pdf-pen-layer {
  cursor: cell;
}

body.study-pdf-mode-dynamic .local-pdf-page-inner {
  -webkit-user-select: none;
  user-select: none;
}

body.study-pdf-mode-dynamic .local-pdf-viewport {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

body.study-pdf-mode-dynamic .local-pdf-canvas {
  touch-action: pan-y;
}

body.study-pdf-mode-dynamic .study-pdf-select-layer {
  pointer-events: none !important;
}

body.study-pdf-mode-dynamic .study-pdf-ink-layer,
body.study-pdf-mode-dynamic .study-pdf-live-layer {
  z-index: 2;
  pointer-events: none;
}

/* Specificitate peste .study-pdf-cloud-mode .local-pdf-ref-layer (z-index:4) —
   altfel vezi referințele prin stilou transparent, dar tap-ul nu le lovește. */
body.study-pdf-cloud-mode.study-pdf-mode-dynamic .local-pdf-ref-layer {
  z-index: 10;
  pointer-events: none;
}

body.study-pdf-cloud-mode.study-pdf-mode-dynamic .local-pdf-bible-ref {
  pointer-events: auto;
  display: block;
  z-index: 11;
  background: rgba(201, 162, 39, 0.22);
  box-shadow: inset 0 -2.5px 0 rgba(201, 162, 39, 0.9);
}

body.study-pdf-mode-dynamic .local-pdf-ref-layer {
  z-index: 10;
  pointer-events: none;
}

body.study-pdf-mode-dynamic .local-pdf-bible-ref {
  pointer-events: auto;
  display: block;
  z-index: 11;
  background: rgba(201, 162, 39, 0.22);
  box-shadow: inset 0 -2.5px 0 rgba(201, 162, 39, 0.9);
}

/* Cât timp Pencil e pe pagină: zero scroll. */
body.study-pdf-mode-dynamic.study-pdf-inking .local-pdf-viewport {
  touch-action: none !important;
  overscroll-behavior: none !important;
  overflow: hidden !important;
  -webkit-overflow-scrolling: auto !important;
}

body.study-pdf-mode-dynamic.study-pdf-inking .study-pdf-pen-layer,
body.study-pdf-mode-dynamic.study-pdf-inking .local-pdf-page-inner,
body.study-pdf-mode-dynamic.study-pdf-inking .local-pdf-canvas,
body.study-pdf-mode-dynamic.study-pdf-inking .local-pdf-overlay {
  touch-action: none !important;
  overscroll-behavior: none !important;
}

body.study-pdf-mode-pen .study-pdf-pen-layer {
  cursor: crosshair;
  touch-action: none;
}

body.study-pdf-mode-pen .local-pdf-page-inner,
body.study-pdf-mode-eraser .local-pdf-page-inner {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.study-pdf-mode-pen .local-pdf-viewport,
body.study-pdf-mode-eraser .local-pdf-viewport {
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body.study-pdf-mode-pen .study-pdf-select-layer,
body.study-pdf-mode-eraser .study-pdf-select-layer {
  pointer-events: none !important;
}

body.study-pdf-mode-eraser .study-pdf-pen-layer {
  cursor: cell;
}

.local-pdf-header-text h2 {
  margin: 0;
  font-size: 1rem;
  color: #f2e8d8;
  max-width: min(34rem, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-pdf-status {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: #a89880;
}

.local-pdf-close {
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f2e8d8;
  cursor: pointer;
  flex: 0 0 auto;
}

.local-pdf-viewport {
  flex: 1;
  overflow: auto;
  padding: 1rem 0.75rem 1.5rem;
}

.local-pdf-page {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.local-pdf-page-inner {
  position: relative;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
  background: #fff;
}

.local-pdf-canvas {
  display: block;
  vertical-align: top;
}

.local-pdf-ref-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.local-pdf-bible-ref {
  position: absolute;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(201, 162, 39, 0.12);
  box-shadow: inset 0 -2px 0 rgba(201, 162, 39, 0.75);
  cursor: pointer;
  pointer-events: auto;
  border-radius: 2px;
}

.local-pdf-bible-ref:hover,
.local-pdf-bible-ref:focus-visible {
  background: rgba(201, 162, 39, 0.28);
}

.local-pdf-loading {
  margin: 2rem;
  color: #666;
  font-size: 0.9rem;
}

.study-pdf-ink-layer,
.study-pdf-live-layer,
.study-pdf-pen-layer {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.study-pdf-live-layer {
  z-index: 3;
  pointer-events: none;
}

.study-pdf-pen-layer {
  z-index: 4;
  cursor: crosshair;
}

.study-pdf-ink-layer {
  z-index: 2;
  pointer-events: none;
}

.study-pdf-select-layer {
  z-index: 1;
}

body.study-pdf-mode-select .study-pdf-select-layer {
  pointer-events: auto;
}

body.study-pdf-mode-select .study-pdf-select-layer span {
  pointer-events: auto;
}

.study-pdf-text-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.study-pdf-text-note {
  position: absolute;
  max-width: 88%;
  min-width: 4rem;
  min-height: 1.2rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
  background: rgba(255, 248, 220, 0.92);
  border-left: 3px solid rgba(201, 162, 39, 0.75);
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-0.15rem);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.study-pdf-text-note-content {
  min-height: 1.2rem;
  outline: none;
}

.study-pdf-text-note-controls {
  position: absolute;
  top: -1.45rem;
  right: 0;
  display: none;
  gap: 0.2rem;
  align-items: center;
}

.study-pdf-text-note-move,
.study-pdf-text-note-delete {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(40, 32, 22, 0.25);
  background: rgba(255, 248, 220, 0.96);
  color: #2a2118;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}

.study-pdf-text-note-move {
  cursor: grab;
}

.study-pdf-text-note-delete {
  color: #8a2b24;
}

.study-pdf-text-note--fill {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(201, 162, 39, 0.65);
  border-left-width: 3px;
}

.study-pdf-text-note:focus {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.55), 0 4px 14px rgba(0, 0, 0, 0.18);
}

body.study-pdf-mode-fill .study-pdf-text-layer,
body.study-pdf-place-text .study-pdf-text-layer {
  z-index: 5;
}

body.study-pdf-mode-fill .study-pdf-text-note,
body.study-pdf-place-text .study-pdf-text-note {
  pointer-events: auto;
}

body.study-pdf-mode-fill .study-pdf-text-note-controls,
body.study-pdf-place-text .study-pdf-text-note-controls {
  display: flex;
}

body.study-pdf-cloud-mode .local-pdf-ref-layer {
  z-index: 4;
  pointer-events: none;
}

body.study-pdf-cloud-mode .local-pdf-bible-ref {
  pointer-events: auto;
}

body.study-pdf-cloud-mode:not(.study-pdf-mode-refs):not(.study-pdf-mode-dynamic) .local-pdf-bible-ref {
  display: none;
}

body.study-pdf-mode-select .local-pdf-bible-ref {
  pointer-events: none;
  background: transparent;
  box-shadow: none;
}

body.study-pdf-place-text .study-pdf-pen-layer {
  cursor: copy;
}

@media (max-width: 900px) {
  .local-pdf-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 0.35rem 0.5rem;
    padding: max(0.45rem, env(safe-area-inset-top, 0px)) 0.45rem 0.45rem;
  }

  .local-pdf-header-text {
    min-width: 0;
  }

  .local-pdf-header-text h2 {
    max-width: none;
    font-size: 0.88rem;
  }

  .local-pdf-status {
    margin-top: 0.1rem;
    font-size: 0.68rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .study-pdf-toolbar {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 0.1rem 0.05rem 0.25rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .study-pdf-layout-select {
    flex: 0 0 auto;
    padding: 0.36rem 1.4rem 0.36rem 0.55rem;
    font-size: 0.76rem;
  }

  .study-pdf-manual-tools {
    flex: 0 0 auto;
    flex-wrap: nowrap;
  }

  .study-pdf-tool {
    flex: 0 0 auto;
    padding: 0.36rem 0.55rem;
    font-size: 0.76rem;
  }

  .study-pdf-ink-settings {
    flex: 0 0 auto;
  }

  .study-pdf-page-info {
    flex: 0 0 auto;
    margin-left: 0.15rem;
    padding-right: 0.35rem;
    font-size: 0.72rem;
  }

  .local-pdf-close {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    padding: 0.34rem 0.5rem;
    font-size: 0.76rem;
  }

  .local-pdf-viewport {
    padding-top: 0.55rem;
  }
}

.verse-popup-add-pdf {
  margin-top: 0.55rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
}

.verse-popup-add-pdf:hover {
  background: rgba(255, 255, 255, 0.14);
}

.verse-popup-add-pdf[hidden] {
  display: none !important;
}

.verse-popup {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.verse-popup[hidden] {
  display: none !important;
}

.verse-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.verse-popup-card {
  position: relative;
  width: min(28rem, 100%);
  max-height: min(70vh, 32rem);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: rgba(26, 22, 18, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.verse-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.verse-popup-title {
  margin: 0;
  font-size: 1rem;
  color: #f2e8d8;
}

.verse-popup-close {
  border: none;
  background: transparent;
  color: #a89880;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.verse-popup-text {
  margin: 0;
  flex: 1;
  overflow: auto;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #f5efe3;
}

.verse-popup-error {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #f0a0a0;
}

.verse-popup-ref-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 12rem;
  overflow: auto;
}

.verse-popup-ref-list[hidden] {
  display: none !important;
}

.verse-popup-ref-item {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.35);
  background: rgba(201, 162, 39, 0.12);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.88rem;
}

.verse-popup-ref-item:hover {
  background: rgba(201, 162, 39, 0.24);
}

.verse-popup-read-more {
  margin-top: 0.85rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.15);
  color: #f2e8d8;
  cursor: pointer;
  font-size: 0.9rem;
}

.verse-popup-read-more:hover {
  background: rgba(201, 162, 39, 0.28);
}

.pencil-scribble-hint {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(36rem, calc(100vw - 1.5rem));
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(26, 22, 18, 0.94);
  color: #f2e8d8;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.pencil-scribble-hint[hidden] {
  display: none !important;
}

.pencil-scribble-hint__text {
  margin: 0;
  flex: 1 1 16rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.pencil-scribble-hint__btn {
  flex: 0 0 auto;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.5);
  background: rgba(201, 162, 39, 0.2);
  color: #f2e8d8;
  font-size: 0.85rem;
  cursor: pointer;
}

.pencil-scribble-hint__btn:hover {
  background: rgba(201, 162, 39, 0.35);
}

body.notebook-mode-active .pencil-scribble-hint {
  bottom: max(4.75rem, calc(4.5rem + env(safe-area-inset-bottom)));
}

body.study-pdf-cloud-mode .local-pdf-open .pencil-scribble-hint,
body.local-pdf-open .pencil-scribble-hint {
  bottom: max(1rem, env(safe-area-inset-bottom));
}
