/* ============================
   COMPONENTS
   ============================ */

/* ─────────────────────────────
   LEFT SIDEBAR — Profile
   ───────────────────────────── */

.profile-photo-wrap {
  width: 150px;
  height: 150px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #c9a84c;
  flex-shrink: 0;
}

.profile-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.historian-name {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.15;
  margin-bottom: 6px;
}

.historian-title {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #a0b0c0;
  text-align: center;
  margin-bottom: 14px;
}

.frase-destacada {
  color: #ffffff !important;
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-style: italic;
  line-height: 1.8;
  text-align: center;
  padding: 16px 8px;
  border-top: 1px solid rgba(201, 168, 76, 0.3);
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
  margin: 12px 0;
}

.divider-gold {
  height: 1px;
  background: linear-gradient(to right, transparent, #c9a84c, transparent);
  margin: 0 0 14px;
}

.bio-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  color: #c9a84c;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.font-controls {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
}

.font-controls button {
  background: rgba(255,255,255,0.08);
  color: #b0c4d4;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.2s;
}

.font-controls button:hover {
  background: rgba(255,255,255,0.18);
}

.bio-text {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 14px;
  line-height: 1.8;
  color: #b0c4d4;
  flex: 1;
  transition: font-size 0.2s;
}

.bio-text p { margin-bottom: 10px; }
.bio-text p:last-child { margin-bottom: 0; }
.bio-text em { color: #c9a84c; font-style: italic; }

/* ─────────────────────────────
   CENTER — Section titles
   ───────────────────────────── */

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 700;
  color: #1a2a3a;
  margin-bottom: 24px;
}

/* ─────────────────────────────
   FILTERS
   ───────────────────────────── */

.filters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-select {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid #d4c5a9;
  border-radius: 4px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  outline: none;
}

.filter-select:focus { border-color: #2c5f8a; }

.filter-clear-btn {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border: 1px solid #d4c5a9;
  border-radius: 4px;
  background: transparent;
  color: #6a5a4a;
  cursor: pointer;
  transition: background 0.2s;
}

.filter-clear-btn:hover { background: #d4c5a9; }

/* ─────────────────────────────
   CAROUSEL
   ───────────────────────────── */

.carousel-wrapper {
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
}

.carousel-track {
  display: flex;
  gap: 14px;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 4px 2px;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(26,42,58,0.85);
  color: #d4c5a9;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
  line-height: 1;
}

.carousel-btn:hover { background: #c9a84c; color: #1a2a3a; }
.carousel-btn.prev { left: 2px; }
.carousel-btn.next { right: 2px; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4c5a9;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.carousel-dot.active { background: #2c5f8a; }

/* ─────────────────────────────
   BOOK CARDS
   ───────────────────────────── */

.book-card {
  min-width: 185px;
  max-width: 185px;
  background: #fff;
  border: 1px solid #d4c5a9;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.22s, box-shadow 0.22s, opacity 0.28s;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

.book-card.filtered-out {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.book-cover-placeholder {
  width: 100%;
  height: 220px;
  border-radius: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
}

.book-cover-placeholder span {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  line-height: 1.4;
}

.book-card h4 {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 600;
  color: #1a2a3a;
  margin-bottom: 4px;
  line-height: 1.3;
}

.book-meta {
  font-size: 12px;
  color: #8a7a6a;
  margin-bottom: 5px;
}

.book-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9px;
}

/* ─ Ver PDF button ─ */
.btn-ver-pdf {
  display: inline-block;
  margin-top: 8px;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #2c5f8a;
  background: #e8f0fd;
  border: 1px solid #b8d0f0;
  border-radius: 4px;
  padding: 4px 10px;
  text-decoration: none;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.btn-ver-pdf:hover {
  background: #2c5f8a;
  color: #fff;
  border-color: #2c5f8a;
}
.btn-proximamente {
  color: #aaa;
  background: #f0f0f0;
  border-color: #ddd;
  cursor: not-allowed;
}
.btn-proximamente:hover {
  background: #f0f0f0;
  color: #aaa;
  border-color: #ddd;
}

/* ─ Escuchar / Version buttons ─ */
.btn-escuchar,
.btn-version {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: #2c5f8a;
  border: 1px solid #2c5f8a;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Source Sans Pro', sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
  line-height: 1.4;
}
.btn-escuchar:hover,
.btn-version:hover {
  background: #2c5f8a;
  color: #fff;
}
.btn-escuchar::before,
.btn-version::before {
  content: "🎙️";
  font-size: 11px;
}

.tag-conflictos    { background: #fde8e8; color: #8a2a2a; }
.tag-epica         { background: #e8f0fd; color: #2a4a8a; }
.tag-sanmartiniana { background: #e8fde8; color: #2a6a2a; }
.tag-biografia     { background: #fdf5e8; color: #6a4a1a; }
.tag-nacional      { background: #f0e8fd; color: #4a2a6a; }
.tag-identidad     { background: #fde8f5; color: #6a1a4a; }
.tag-regional      { background: #e8fdfd; color: #1a5a5a; }
.tag-militar       { background: #e8ecf5; color: #1a2a5a; }

/* ─────────────────────────────
   MODAL
   ───────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.abierto {
  display: flex;
}

.modal-content {
  background: #faf7f2;
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 36px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #888;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover { background: #eee; }

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  color: #1a2a3a;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
  font-style: italic;
}

.modal-divider {
  height: 2px;
  background: linear-gradient(to right, #c9a84c, transparent);
  margin-bottom: 20px;
}

.modal-body p {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 15px;
  line-height: 1.9;
  color: #333;
  margin-bottom: 16px;
}

.modal-firma {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #d4c5a9;
  text-align: right;
}

.modal-firma p {
  margin-bottom: 4px !important;
  font-size: 14px !important;
  color: #555 !important;
}

/* ─────────────────────────────
   ACTION BUTTONS
   ───────────────────────────── */

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.btn-primary {
  background: #1a2a3a;
  color: #fff;
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 28px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: #c9a84c; }

.btn-secondary {
  background: transparent;
  color: #1a2a3a;
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 28px;
  border: 2px solid #1a2a3a;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover { background: #1a2a3a; color: #c9a84c; }

/* ─────────────────────────────
   BIO EXTENDED (central scroll)
   ───────────────────────────── */

.bio-extended { padding-top: 20px; }

.bio-extended-body {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 15px;
  line-height: 1.78;
  color: #2a2a2a;
  max-width: 640px;
}

.bio-extended-body p { margin-bottom: 12px; }

.bio-extended-body h3 {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: #1a2a3a;
  margin: 22px 0 8px;
}

.bio-extended-body ul { margin-left: 18px; margin-bottom: 12px; }
.bio-extended-body li { margin-bottom: 3px; }

.bio-quote {
  border-left: 3px solid #c9a84c;
  margin: 16px 0;
  padding: 10px 16px;
  background: rgba(201,168,76,0.07);
  border-radius: 0 4px 4px 0;
}
.bio-quote p {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 13px;
  color: #3a2a1a;
  margin-bottom: 6px !important;
}
.bio-quote footer {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  color: #8a7a6a;
}

/* ─────────────────────────────
   CONTACT
   ───────────────────────────── */

.contact-section { padding-top: 20px; }

.contact-body p {
  font-size: 14px;
  color: #4a4a4a;
  margin-bottom: 14px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  margin-bottom: 8px;
}

/* ─────────────────────────────
   RIGHT PANEL HEADER
   ───────────────────────────── */

.archivo-juan-saa-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: #1a2a3a;
  color: #c9a84c;
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
  border-bottom: 2px solid #c9a84c;
  letter-spacing: 0.5px;
  transition: background 0.2s;
  cursor: pointer;
  box-sizing: border-box;
}

.archivo-juan-saa-btn:hover {
  background: #c9a84c;
  color: #1a2a3a;
}

.right-panel-header {
  background: #1a2a3a;
  color: #fff;
  padding: 14px 18px;
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.historian-mini-photo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #c9a84c;
}

/* ─────────────────────────────
   DOCUMENT VIEWER
   ───────────────────────────── */

.document-viewer {
  position: relative;
  height: 320px;
  background: #1e1e1e;
  overflow: hidden;
  cursor: grab;
  flex-shrink: 0;
}

.document-viewer:active { cursor: grabbing; }

.doc-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  /* transition handled in JS for smooth pan */
}

.viewer-controls {
  position: absolute;
  bottom: 7px;
  right: 7px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.viewer-btn {
  background: rgba(0,0,0,0.65);
  color: #d4c5a9;
  border: 1px solid rgba(255,255,255,0.2);
  width: 26px;
  height: 26px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
}

.viewer-btn:hover { background: #c9a84c; color: #1a2a3a; border-color: #c9a84c; }

/* ─────────────────────────────
   THUMBNAILS + TABS ROW
   ───────────────────────────── */

.viewer-thumbs-tabs {
  display: flex;
  border-bottom: 1px solid #d4c5a9;
  flex-shrink: 0;
}

.viewer-thumbnails {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px;
  background: #f0ece4;
  border-right: 1px solid #d4c5a9;
}

.thumb {
  background: none;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  display: block;
  transition: border-color 0.18s;
}

.thumb svg { display: block; }
.thumb:hover,
.thumb.active { border-color: #c9a84c; }

.viewer-meta-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #d4c5a9;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 10px 4px;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border: none;
  background: #f5f0e8;
  cursor: pointer;
  color: #6a5a4a;
  transition: background 0.18s, color 0.18s;
}

.tab-btn.active { background: #1a2a3a; color: #d4c5a9; }
.tab-btn:hover:not(.active) { background: #e8e0d0; }

.tab-content {
  display: none;
  padding: 10px 10px;
  overflow-y: auto;
  flex: 1;
}

.tab-content.active { display: block; }

.tab-desc {
  font-size: 12px;
  line-height: 1.55;
  color: #5a5a5a;
}

.metadata-table {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: #1a1a1a;
  color: #7ec8a0;
  padding: 10px;
  border-radius: 4px;
  line-height: 2.2;
  white-space: pre;
}

.metadata-table .key { color: #7ec8e3; }

/* ─────────────────────────────
   TRANSCRIPTION ACCORDION
   ───────────────────────────── */

.transcription-accordion {
  border-top: 1px solid #d4c5a9;
  flex-shrink: 0;
}

.accordion-header {
  width: 100%;
  padding: 9px 14px;
  background: #f5f0e8;
  border: none;
  text-align: left;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #1a2a3a;
  cursor: pointer;
  transition: background 0.18s;
}

.accordion-header:hover { background: #ece7dc; }

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.38s ease;
}

.accordion-body.open { max-height: 320px; overflow-y: auto; }

.transcription-text {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 15px;
  line-height: 2;
  color: #3a3a3a;
  font-style: italic;
  background: #faf7f2;
  padding: 16px;
  transition: font-size 0.2s;
}

.transcription-text p { margin-bottom: 10px; }
.transcription-text p:last-child { margin-bottom: 0; }

/* ─────────────────────────────
   CONTEXT MOSAIC
   ───────────────────────────── */

.context-section {
  padding: 12px 12px 14px;
  flex: 1;
}

.context-title {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 700;
  color: #c9a84c;
  margin-bottom: 10px;
  padding: 0 2px;
}

/* ─── Separador ─── */
.context-divider {
  text-align: center;
  color: #c9a84c;
  font-size: 10px;
  padding: 10px 0 8px;
  opacity: 0.45;
}

/* ─── GALERÍA FOTOGRÁFICA ─── */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 4px;
}

.photo-cell {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #d4c5a9;
  cursor: pointer;
  height: 110px;
  transition: transform 0.2s;
}

.photo-cell:hover { transform: scale(1.03); }

.photo-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(26,42,58,0.75);
  color: #d4c5a9;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 8px;
  padding: 3px 5px;
  text-align: center;
}

/* ─── LISTA DE DOCUMENTOS ─── */
.doc-list {
  border: 1px solid #e8e0d0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #e8e0d0;
  cursor: pointer;
  transition: background 0.18s;
  text-decoration: none;
  background: #fff;
}

.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: #f5f0e8; }

.doc-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.doc-item-title {
  flex: 1;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 12px;
  color: #1a2a3a;
  line-height: 1.3;
}

.doc-item-year {
  font-size: 11px;
  color: #888;
  font-family: 'Source Sans Pro', sans-serif;
  flex-shrink: 0;
}

/* ─── LISTA DE GRABACIONES ─── */
.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.recording-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f5f0e8;
  border: 1px solid #d4c5a9;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}

.recording-item:hover,
.recording-item.active {
  background: #1a2a3a;
  border-color: #c9a84c;
}

.recording-item.active .rec-title,
.recording-item:hover .rec-title  { color: #d4c5a9; }
.recording-item.active .rec-duration,
.recording-item:hover .rec-duration { color: #8a9aaa; }

.rec-wave { flex-shrink: 0; }

.rec-title {
  flex: 1;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #1a2a3a;
  transition: color 0.18s;
}

.rec-duration {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 10px;
  color: #8a7a6a;
  flex-shrink: 0;
  transition: color 0.18s;
}

.rec-play-btn {
  background: #c9a84c;
  color: #1a2a3a;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.rec-play-btn:hover { background: #e0c060; }

/* ─────────────────────────────
   AUDIO PLAYER
   ───────────────────────────── */

.audio-player {
  background: #1a2a3a;
  border-radius: 5px;
  padding: 10px 12px;
}

.audio-title {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #c9a84c;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-nav-btn {
  background: rgba(255,255,255,0.12);
  color: #c9a84c;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.audio-nav-btn:hover { background: rgba(201,168,76,0.25); }

.audio-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.play-btn {
  background: #c9a84c;
  color: #1a2a3a;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
}

.play-btn:hover { background: #e0c060; }

.progress-bar-wrapper {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: #c9a84c;
  border-radius: 2px;
  width: 0;
  transition: width 0.1s linear;
}

.time-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #8a9aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

.waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  margin-top: 8px;
}

.wave-bar {
  width: 3px;
  background: #c9a84c;
  border-radius: 2px;
  opacity: 0.5;
}

.waveform.playing .wave-bar {
  animation: waveAnim 0.8s ease-in-out infinite alternate;
  opacity: 1;
}

.waveform.playing .wave-bar:nth-child(1) { animation-delay: 0s; }
.waveform.playing .wave-bar:nth-child(2) { animation-delay: 0.10s; }
.waveform.playing .wave-bar:nth-child(3) { animation-delay: 0.20s; }
.waveform.playing .wave-bar:nth-child(4) { animation-delay: 0.05s; }
.waveform.playing .wave-bar:nth-child(5) { animation-delay: 0.15s; }
.waveform.playing .wave-bar:nth-child(6) { animation-delay: 0.25s; }
.waveform.playing .wave-bar:nth-child(7) { animation-delay: 0.08s; }
.waveform.playing .wave-bar:nth-child(8) { animation-delay: 0.18s; }

@keyframes waveAnim {
  0%   { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* ─────────────────────────────
   FULLSCREEN VIEWER
   ───────────────────────────── */

.document-viewer.fullscreen {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  border-radius: 0;
}

.document-viewer.fullscreen .viewer-controls {
  bottom: 18px;
  right: 18px;
}

/* ─────────────────────────────
   LIGHTBOX
   ───────────────────────────── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: lbFadeIn 0.2s ease;
}

@keyframes lbFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  display: block;
}

.lightbox-caption {
  color: #d4c5a9;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  font-style: italic;
}

.lightbox-close {
  position: absolute;
  top: -36px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.lightbox-close:hover { opacity: 1; }

/* ─────────────────────────────
   BIBLIOTECA / ARCHIVO — Tabla
   ───────────────────────────── */

.biblioteca-header {
  text-align: center;
  padding: 40px 20px 30px;
  border-bottom: 1px solid #d4c5a9;
  margin-bottom: 24px;
}

.biblioteca-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  color: #1a2a3a;
  margin-bottom: 8px;
}

.biblioteca-header h1 span { color: #c9a84c; }

.biblioteca-header p {
  font-size: 15px;
  color: #666;
  font-style: italic;
}

.biblio-search-input {
  width: 100%;
  padding: 12px 20px;
  border: 1px solid #d4c5a9;
  border-radius: 6px;
  font-size: 15px;
  margin-bottom: 16px;
  background: #fff;
  color: #1a2a3a;
  font-family: 'Source Sans Pro', sans-serif;
  box-sizing: border-box;
}

.biblio-filtros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filtro-btn {
  padding: 6px 16px;
  border: 1px solid #d4c5a9;
  border-radius: 20px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: #1a2a3a;
  font-family: 'Source Sans Pro', sans-serif;
}

.filtro-btn.active,
.filtro-btn:hover {
  background: #1a2a3a;
  color: #fff;
  border-color: #1a2a3a;
}

.biblio-table {
  width: 100%;
  border-collapse: collapse;
}

.biblio-table th {
  text-align: left;
  padding: 12px 16px;
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  color: #1a2a3a;
  border-bottom: 2px solid #1a2a3a;
  background: #f5f0e8;
}

.biblio-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e8e0d0;
  font-size: 14px;
  color: #333;
  vertical-align: middle;
}

.biblio-table tr:hover td { background: #faf7f2; }

.categoria-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tag-libro     { background: #fee2e2; color: #dc2626; }
.tag-articulo  { background: #e0f2fe; color: #0369a1; }
.tag-ensayo    { background: #fef3c7; color: #d97706; }
.tag-archivo   { background: #f0fdf4; color: #16a34a; }
.tag-historico { background: #ede9fe; color: #7c3aed; }

.btn-tabla-pdf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1a2a3a;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
  margin-right: 6px;
  transition: background 0.2s;
  border: none;
  cursor: pointer;
  font-family: 'Source Sans Pro', sans-serif;
}

.btn-tabla-pdf:hover { background: #2c5f8a; }

.btn-tabla-descargar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #c9a84c;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-tabla-descargar:hover { background: #a8883c; }

.btn-tabla-pronto {
  font-size: 12px;
  color: #aaa;
  font-style: italic;
}

.biblio-paginacion {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e8e0d0;
}

.pag-btn {
  padding: 6px 14px;
  border: 1px solid #d4c5a9;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: #1a2a3a;
  font-family: 'Source Sans Pro', sans-serif;
}

.pag-btn:hover,
.pag-btn.active {
  background: #1a2a3a;
  color: #fff;
}

.pag-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.biblio-soporte {
  margin-top: 24px;
  font-size: 13px;
  color: #888;
}

.biblio-soporte a { color: #2c5f8a; }

/* ─── Galería Juan Saá ─── */
.juan-saa-galeria {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.juan-saa-cell {
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: #f0ebe0;
  border: 1px solid #d4c5a9;
  transition: transform 0.2s, box-shadow 0.2s;
}

.juan-saa-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.juan-saa-cell img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.juan-saa-caption {
  display: block;
  font-size: 11px;
  color: #555;
  padding: 6px 8px;
  font-family: 'Source Sans Pro', sans-serif;
  line-height: 1.3;
}

/* ─── RESPONSIVE tabla ─── */
@media (max-width: 768px) {
  .biblio-table thead { display: none; }

  .biblio-table tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid #d4c5a9;
    border-radius: 6px;
    padding: 12px;
    background: #fff;
  }

  .biblio-table td {
    display: block;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }

  .biblio-table td:first-child {
    font-weight: 700;
    font-size: 14px;
    color: #1a2a3a;
    margin-bottom: 6px;
  }

  .btn-tabla-pdf,
  .btn-tabla-descargar {
    padding: 8px 14px;
    font-size: 13px;
    margin-top: 6px;
  }

  .biblioteca-header h1 { font-size: 22px; }
  .biblio-filtros { gap: 6px; }
  .filtro-btn { font-size: 12px; padding: 5px 12px; }

  .juan-saa-galeria {
    grid-template-columns: 1fr 1fr;
  }
}
