.pdf-reader {
  --pdf-ink: #263740;
  --pdf-warm: #8b3e26;
  --pdf-border: #d9d2c5;
  min-width: 0;
  color: var(--pdf-ink);
}

.pdf-reader button {
  min-height: 42px;
  min-width: 42px;
  padding: 6px 10px;
  border: 1px solid var(--pdf-border);
  border-radius: 6px;
  color: var(--pdf-ink);
  background: #fffbf3;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.pdf-reader button:disabled { opacity: .48; cursor: default; }
.pdf-reader button:focus-visible { outline: 2px solid #476b88; outline-offset: 2px; }
.pdf-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 2px 0 10px;
}
.pdf-header h1 {
  margin: 0;
  min-width: 0;
  font-size: clamp(1rem, 2.8vw, 1.4rem);
  line-height: 1.35;
}
.pdf-header button { flex: none; }
.pdf-toolbar,
.pdf-control-group,
.pdf-selection-bar,
.pdf-translation > div,
.pdf-bottom {
  display: flex;
  align-items: center;
  gap: 5px;
}
.pdf-toolbar {
  flex-wrap: wrap;
  justify-content: space-between;
  row-gap: 7px;
  padding: 5px 0 8px;
}
.pdf-control-group { flex: none; }
.pdf-page-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pdf-toolbar [data-download] {
  background: #e8edf0;
  color: #264661;
  border-color: #c2ccd3;
  white-space: nowrap;
}
.pdf-selection-bar {
  flex-wrap: wrap;
  margin-bottom: 8px;
  color: #455b66;
  font-size: .875rem;
}
.pdf-selection-bar span { flex: 1 1 auto; }
.pdf-selection-bar [data-highlight]:not(:disabled) { background: #f9e5a0; border-color: #cfad54; }
.pdf-translation {
  margin: 0 0 8px;
  padding: 7px 12px;
  color: var(--pdf-ink);
  border: 1px solid #c4d0d7;
  border-radius: 6px;
  background: #f0f4f6;
}
.pdf-translation > div { justify-content: space-between; }
.pdf-translation p { margin: 3px 0 7px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pdf-status {
  margin: 0 0 8px;
  color: var(--pdf-warm);
  font-size: .875rem;
  overflow-wrap: anywhere;
}
.pdf-stage {
  min-height: 140px;
  max-height: min(78vh, 960px);
  max-height: min(78dvh, 960px);
  overflow: auto;
  padding: 8px;
  background: #e5dfd4;
  border-radius: 6px;
  overscroll-behavior-inline: contain;
}
.pdf-sheet {
  position: relative;
  isolation: isolate;
  margin-inline: auto;
  background: white;
  box-shadow: 0 1px 4px #342f2633;
}
.pdf-sheet canvas { display: block; width: 100%; height: 100%; max-width: none; }
.pdf-highlight-layer { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; z-index: 1; }
.pdf-highlight { position: absolute; border-radius: 1px; background: #fac93694; }
.pdf-sheet .textLayer {
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-user-select: text;
  user-select: text;
  transform-origin: 0 0;
  caret-color: CanvasText;
}
.pdf-sheet .textLayer :is(span, br) {
  position: absolute;
  color: transparent;
  cursor: text;
  white-space: pre;
  transform-origin: 0 0;
}
.pdf-sheet .textLayer > :not(.markedContent),
.pdf-sheet .textLayer .markedContent span:not(.markedContent) {
  --font-height: 0;
  --scale-x: 1;
  --rotate: 0deg;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.pdf-sheet .textLayer .markedContent { display: contents; }
.pdf-sheet .textLayer ::selection { background: #619ac675; }
.pdf-sheet .textLayer br::selection { background: transparent; }
.pdf-bottom { justify-content: space-between; padding: 8px 0; }
.pdf-reader [hidden] { display: none !important; }

@media (max-width: 520px) {
  .pdf-reader button { padding-inline: 7px; }
  .pdf-toolbar { font-size: .86rem; }
  .pdf-toolbar, .pdf-toolbar .pdf-control-group, .pdf-selection-bar { gap: 4px; }
  .pdf-selection-bar [data-undo] { white-space: nowrap; }
}
