.piv-shell {
  --piv-accent: #b62634;
  --piv-accent-dark: #941a25;
  --piv-bg: transparent;
  --piv-paper: #eee7d7;
  --piv-surface: #fffdf9;
  --piv-surface-alt: #f7f2e9;
  --piv-border: #d8ccb8;
  --piv-rule: #e8ddcd;
  --piv-copy: #27211d;
  --piv-copy-soft: #92877b;
  --piv-hit: rgba(255, 224, 90, 0.68);
  font-family: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.piv-shell,
.piv-shell * {
  box-sizing: border-box;
}

.piv-shell button,
.piv-shell input {
  font: inherit;
}

.piv-header {
  padding: 0 0 0.7rem;
  background: transparent;
  border-bottom: 0;
}

.piv-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
}

.piv-eyebrow {
  color: var(--piv-accent);
  font-size: clamp(0.8rem, 1.1vw, 0.92rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: none;
}

.piv-title {
  max-width: 980px;
  color: inherit;
  font-size: clamp(1.3rem, 2.2vw, 1.75rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
}

.piv-panel-title {
  margin-bottom: 0.85rem;
  color: #82786f;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.45;
  text-transform: none;
}

.piv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem 0 1.25rem;
  background: transparent;
}

/* La búsqueda vive en un panel lateral que se abre desde la barra (.piv-search-toggle). */
.piv-sidebar {
  display: none;
  gap: 1rem;
  align-content: start;
  padding: 0;
  background: transparent;
  border-right: 0;
}

.piv-shell.is-search-open .piv-sidebar {
  display: grid;
}

@media (min-width: 861px) {
  .piv-shell.is-search-open .piv-body {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  }

  .piv-shell.is-search-open .piv-sidebar {
    max-height: var(--piv-panel-h, none);
    overflow: auto;
  }
}

.piv-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.piv-shell .piv-search-close {
  appearance: none;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin: -0.3rem -0.3rem 0 0;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--piv-copy-soft);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.piv-shell .piv-search-close:hover,
.piv-shell .piv-search-close:focus-visible {
  background: var(--piv-surface-alt);
  color: var(--piv-accent);
}

.piv-shell .piv-search-toggle[aria-expanded="true"] {
  background: var(--piv-accent);
  border-color: var(--piv-accent);
  color: #fff;
}


.piv-search-panel,
.piv-results-panel,
.piv-meta-section {
  background: var(--piv-surface);
  border: 1px solid var(--piv-border);
  border-radius: 6px;
  padding: 1rem;
}

.piv-controls,
.piv-nav,
.piv-zoom-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.piv-controls {
  margin-top: 0.75rem;
}

.piv-query,
.piv-page-info input {
  width: 100%;
  min-width: 0;
  padding: 0.68rem 0.82rem;
  border: 1px solid var(--piv-border);
  border-radius: 5px;
  background: #fffdfa;
  color: var(--piv-copy);
}

.piv-query {
  font-size: 1.08rem;
  line-height: 1.25;
}

.piv-page-info {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #8d8378;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.piv-page-info input {
  width: 54px;
  height: 38px;
  padding: 0.3rem;
  border-width: 2px;
  border-radius: 6px;
  color: var(--piv-copy);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.piv-sidebar-note,
.piv-results-empty {
  margin: 0;
  color: #9a9084;
  font-size: 0.96rem;
  line-height: 1.55;
}

.piv-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.45rem 0.8rem;
  background: #fffdfa;
  border: 2px solid var(--piv-border);
  border-radius: 5px;
  color: #3d352f;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.piv-btn:hover {
  background: #fff;
  border-color: #bfb19f;
  color: var(--piv-accent);
  transform: none;
}

/* Botones de solo icono: el nombre de la acción va en aria-label y title. */
.piv-btn--icon {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.piv-icon {
  display: block;
  flex: 0 0 auto;
}

.piv-fit .piv-icon--fit-page,
.piv-fit[aria-pressed="true"] .piv-icon--fit-width,
.piv-fullscreen .piv-icon--collapse,
.piv-fullscreen[aria-pressed="true"] .piv-icon--expand {
  display: none;
}

.piv-fit[aria-pressed="true"] .piv-icon--fit-page,
.piv-fullscreen[aria-pressed="true"] .piv-icon--collapse {
  display: block;
}

.piv-copy {
  color: #6f655b;
}

.piv-search {
  background: var(--piv-accent);
  border-color: var(--piv-accent);
  color: #fff;
}

.piv-search:hover {
  background: var(--piv-accent-dark);
  border-color: var(--piv-accent-dark);
  color: #fff;
}

.piv-results-count {
  color: var(--piv-copy-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: right;
}

.piv-main {
  display: block;
  min-width: 0;
}

/* Tres grupos: búsqueda | navegación (centrada) | vista. */
.piv-main-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border: 2px solid var(--piv-border);
  border-radius: 6px;
  background: var(--piv-surface);
  box-shadow: none;
}

.piv-toolbar-start {
  display: flex;
  align-items: center;
}

.piv-zoom-controls {
  justify-content: flex-end;
}

.piv-zoom-value {
  min-width: 3.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6f655b;
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.piv-toolbar-divider {
  width: 1px;
  height: 26px;
  background: var(--piv-rule);
}



.piv-shell:fullscreen,
.piv-shell.is-fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 1rem;
  background: #f7f2e9;
  overflow: auto;
}

.piv-shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
}

.piv-shell:fullscreen .piv-header,
.piv-shell.is-fullscreen .piv-header,
.piv-shell:fullscreen .piv-meta-section,
.piv-shell.is-fullscreen .piv-meta-section {
  display: none;
}

.piv-shell:fullscreen .piv-main-toolbar,
.piv-shell.is-fullscreen .piv-main-toolbar {
  margin-bottom: 1rem;
}

.piv-shell:fullscreen .piv-body,
.piv-shell.is-fullscreen .piv-body {
  min-height: 0;
  height: calc(100vh - 6.5rem);
  padding: 0;
}

.piv-shell:fullscreen .piv-viewer-panel,
.piv-shell.is-fullscreen .piv-viewer-panel {
  min-height: 0;
  height: 100%;
}

/* --piv-panel-h lo calcula viewer.js: el alto que queda visible de la ventana. */
.piv-viewer-panel {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  height: var(--piv-panel-h, 680px);
  min-height: 0;
  padding: 1rem;
  background: var(--piv-paper);
  border: 2px solid var(--piv-border);
  border-radius: 6px;
  scroll-behavior: smooth;
}

.piv-stage {
  position: relative;
}

.piv-shell:fullscreen .piv-main,
.piv-shell.is-fullscreen .piv-main,
.piv-shell:fullscreen .piv-stage,
.piv-shell.is-fullscreen .piv-stage {
  height: 100%;
}

.piv-shell .piv-side-nav,
.piv-shell .piv-side-nav:hover,
.piv-shell .piv-side-nav:focus,
.piv-shell .piv-side-nav:active {
  appearance: none;
  position: absolute;
  top: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 0 3px;
  border: 1px solid var(--piv-border);
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 4px 12px rgba(26, 17, 11, 0.16);
  color: var(--piv-accent);
  cursor: pointer;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.6;
  transform: translateY(-50%);
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}

.piv-shell .piv-side-nav--prev {
  left: 0.75rem;
}

.piv-shell .piv-side-nav--next {
  right: 0.75rem;
}

.piv-shell .piv-stage:hover .piv-side-nav {
  opacity: 0.85;
}

.piv-shell .piv-stage .piv-side-nav:hover,
.piv-shell .piv-stage .piv-side-nav:focus-visible {
  background: var(--piv-accent);
  border-color: var(--piv-accent);
  color: #fff;
  opacity: 1;
}

.piv-shell .piv-stage .piv-side-nav:disabled,
.piv-shell .piv-btn:disabled {
  cursor: default;
  opacity: 0.25;
  pointer-events: none;
}

.piv-status {
  position: absolute;
  top: 3rem;
  left: 50%;
  z-index: 6;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 0.75rem;
  max-width: calc(100% - 2rem);
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--piv-border);
  border-radius: 6px;
  background: var(--piv-surface);
  box-shadow: 0 8px 22px rgba(26, 17, 11, 0.16);
  color: var(--piv-copy);
  font-size: 0.95rem;
  font-weight: 700;
  transform: translateX(-50%);
}

.piv-stage.is-loading .piv-status,
.piv-stage.has-error .piv-status {
  display: flex;
}

.piv-status-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--piv-rule);
  border-top-color: var(--piv-accent);
  border-radius: 50%;
  animation: piv-spin 800ms linear infinite;
}

.piv-stage.has-error .piv-status-spinner {
  display: none;
}

.piv-stage.has-error .piv-status {
  border-color: var(--piv-accent);
  color: var(--piv-accent-dark);
}

.piv-status-bar {
  flex: 0 0 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--piv-rule);
  overflow: hidden;
}

.piv-status-bar[hidden],
.piv-status-retry[hidden] {
  display: none;
}

.piv-status-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--piv-accent);
  transition: width 160ms linear;
}

@keyframes piv-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .piv-status-spinner {
    animation-duration: 2400ms;
  }
}

@media (hover: none) {
  .piv-shell .piv-side-nav {
    opacity: 0.85;
  }
}

/* margin:auto centra la página y, a diferencia de justify-content, no recorta lo que desborda con zoom. */
.piv-page-wrap {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  margin: auto;
  min-width: 120px;
  min-height: 160px;
  background: #fff;
  box-shadow: 9px 9px 0 rgba(26, 17, 11, 0.15);
}

.piv-canvas {
  display: block;
  max-width: none;
  height: auto;
}

.piv-page-image {
  display: none;
  max-width: none;
  height: auto;
}

.piv-text-layer,
.piv-ocr-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.piv-text-layer {
  z-index: 2;
}

.piv-ocr-layer {
  z-index: 3;
}

.piv-text-layer span.piv-hit {
  background: rgba(255, 214, 10, 0.72) !important;
  box-shadow: 0 0 0 1px rgba(156, 109, 0, 0.25);
  border-radius: 2px;
}

.piv-text-layer span.piv-hit.piv-hit-active {
  background: rgba(255, 166, 0, 0.92) !important;
  box-shadow: 0 0 0 2px rgba(143, 23, 36, 0.3);
}

.piv-ocr-hit {
  position: absolute;
  background: rgba(255, 214, 10, 0.42);
  border: 1px solid rgba(177, 132, 0, 0.54);
  border-radius: 2px;
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.piv-ocr-hit.is-active {
  background: rgba(255, 140, 0, 0.55);
  border-color: rgba(143, 23, 36, 0.82);
  box-shadow: 0 0 0 2px rgba(143, 23, 36, 0.22);
}

.piv-text-hit {
  background: rgba(255, 214, 10, 0.34);
  border-color: rgba(177, 132, 0, 0.42);
}

.piv-meta-section {
  margin-top: 0;
  border: 2px solid var(--piv-border);
  border-radius: 6px;
  padding: 1.45rem 1.75rem;
  background: var(--piv-surface);
}

.piv-meta-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 0;
  margin: 0;
}

.piv-meta-item {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  grid-column: 1 / -1;
  align-items: start;
  padding: 0.78rem 0;
  border-top: 1px solid var(--piv-rule);
}

.piv-meta-item:first-child {
  border-top: 0;
}

.piv-meta-label {
  margin: 0;
  color: #958b80;
  font-size: 0.9rem;
  line-height: 1.35;
  letter-spacing: 0.08em;
  text-transform: none;
}

.piv-meta-value {
  margin: 0;
  color: #211b17;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-color: #8b8176;
  text-underline-offset: 0.12em;
}

.piv-term-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.piv-term-link a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #211b17;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: underline;
  text-decoration-color: #8b8176;
  text-underline-offset: 0.12em;
}

.piv-error .piv-results-list {
  color: #b00020;
}

@media (max-width: 860px) {
  .piv-body {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .piv-sidebar {
    border-right: 0;
    border-bottom: 0;
  }

  .piv-results-list {
    max-height: 40vh;
  }
}

@media (max-width: 680px) {
  .piv-shell {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .piv-header {
    order: 1;
  }

  .piv-body {
    display: contents;
  }

  .piv-sidebar {
    order: 2;
  }

  .piv-main-toolbar {
    order: 3;
  }

  .piv-main {
    order: 4;
  }

  .piv-meta-section {
    order: 5;
  }

  .piv-header,
  .piv-sidebar,
  .piv-meta-section {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .piv-header {
    padding-bottom: 0.9rem;
  }

  .piv-eyebrow {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    line-height: 1.25;
  }

  .piv-title {
    font-size: clamp(1.15rem, 5.5vw, 1.4rem);
    line-height: 1.1;
  }

  .piv-main-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.4rem;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding: 0.45rem;
  }

  .piv-main-toolbar > .piv-nav,
  .piv-main-toolbar > .piv-zoom-controls {
    width: auto;
  }

  .piv-nav {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.3rem;
    width: auto;
  }

  .piv-nav .piv-page-info {
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    letter-spacing: 0;
    order: 0;
  }

  .piv-page-info input {
    width: 38px;
    height: 34px;
    font-size: 0.95rem;
  }

  .piv-zoom-controls {
    display: flex;
    gap: 0.3rem;
    width: auto;
    align-items: center;
    justify-self: end;
  }

  .piv-zoom-value,
  .piv-toolbar-divider {
    display: none;
  }

  .piv-fullscreen,
  .piv-fit {
    display: none;
  }

  .piv-btn {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 0.95rem;
    flex: 0 0 auto;
  }

  .piv-search-panel,
  .piv-meta-section {
    padding: 0.95rem;
  }

  .piv-panel-title {
    margin-bottom: 0.55rem;
    font-size: 0.84rem;
    letter-spacing: 0.06em;
  }

  .piv-query {
    font-size: 0.95rem;
  }

  .piv-sidebar-note,
  .piv-results-empty {
    font-size: 0.9rem;
  }

  .piv-viewer-panel {
    margin-top: 0;
    padding: 0.75rem 0.5rem;
  }

  .piv-page-wrap {
    box-shadow: 5px 5px 0 rgba(26, 17, 11, 0.12);
  }

  .piv-shell .piv-side-nav {
    width: 34px;
    height: 34px;
    font-size: 1.4rem;
  }

  .piv-shell .piv-side-nav--prev {
    left: 0.3rem;
  }

  .piv-shell .piv-side-nav--next {
    right: 0.3rem;
  }

  .piv-meta-grid,
  .piv-meta-item {
    display: grid;
    grid-template-columns: 1fr;
  }

  .piv-meta-value {
    margin-top: 0.35rem;
    font-size: 0.98rem;
  }
}

/* Teléfonos angostos: el zoom se hace con los dedos; sin − y + la barra cabe en una línea. */
@media (max-width: 400px) {
  .piv-zoom-controls .piv-zoom-out,
  .piv-zoom-controls .piv-zoom-in {
    display: none;
  }
}
