:root {
  --bg: #061117;
  --surface: #0c222c;
  --surface-raised: #122d38;
  --surface-card: rgba(8, 22, 30, 0.58);
  --line: rgba(205, 225, 222, 0.16);
  --line-strong: rgba(205, 225, 222, 0.28);
  --text: #f4f8f6;
  --text-muted: #8fa6a8;
  --teal: #75d3c0;
  --orange: #f0b36c;
  --yellow: #ebd57b;
  --red: #f38b82;
  --navy: #153b49;
  --font-serif: Georgia, "Times New Roman", "Baskerville", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Consolas", monospace;
  --deck-left: clamp(24px, 4vw, 56px);
  --deck-width: min(64vw, 1240px);
  --deck-gap: clamp(14px, 2vh, 24px);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Título de la diapositiva en la esquina superior izquierda */
.slide-corner-title {
  position: fixed;
  top: clamp(20px, 3vh, 32px);
  left: clamp(24px, 3.5vw, 48px);
  z-index: 20;
  margin: 0;
  color: #f1f6f4;
  font-family: var(--font-serif);
  font-size: clamp(20px, 2.1vw, 28px);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

/* La apertura funciona como una cortina: deja solo al expositor y los controles. */
.app-shell.is-opening .slide-corner-title,
.app-shell.is-opening .stage-panel,
.app-shell.is-opening .biblio-toggle-btn,
.app-shell.is-opening .dialogue-overlay {
  visibility: hidden;
  opacity: 0;
}

/* Workspace */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Stage Area (Left) */
.stage-panel {
  position: relative;
  z-index: 3;
  width: min(64vw, 1260px);
  height: 100%;
  pointer-events: none;
}

/* Presenter Panel (Right Side 3D Avatar) */
.presenter-panel {
  position: static;
  display: block;
  overflow: visible;
  background: none;
  pointer-events: none;
}

.avatar-stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  background: transparent;
  pointer-events: none;
}

#avatar-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* El diálogo vive fuera del canvas para permanecer sobre cards y gráfico. */
.dialogue-overlay {
  position: fixed;
  right: clamp(24px, 3vw, 56px);
  bottom: clamp(108px, 14vh, 160px);
  z-index: 32;
  width: min(34vw, 640px);
  min-height: 1.4em;
  color: #f3f4ed;
  font-size: clamp(15px, 1.45vw, 27px);
  font-weight: 500;
  line-height: 1.25;
  text-shadow: 0 0 18px rgba(240, 179, 108, 0.9), 0 3px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  user-select: none;
  transition: opacity 180ms ease;
}

.avatar-fallback {
  position: absolute;
  top: 50%;
  right: 15%;
  transform: translateY(-50%);
  color: rgba(230, 244, 239, 0.7);
  font-size: 64px;
  font-weight: 800;
}

/* Bottom Controls (Centrado abajo, botones rectangulares) */
.stage-controls {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(205, 225, 222, 0.16);
  background: rgba(8, 22, 30, 0.88);
  backdrop-filter: blur(20px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

.presentation-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 5px;
  border: 1px solid rgba(205, 225, 222, 0.15);
  background: rgba(14, 38, 48, 0.7);
  color: #dbe8e3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.presentation-button svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.presentation-button.graph-button svg.icon-paper-pencil {
  width: 15px;
  height: 15px;
  fill: none;
}

.presentation-button:hover:not(:disabled) {
  border-color: rgba(117, 211, 192, 0.55);
  background: rgba(22, 54, 66, 0.9);
  color: #fff;
  transform: translateY(-1px);
}

.presentation-button:active:not(:disabled) {
  transform: translateY(0);
}

.presentation-button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.presentation-button.start-button {
  border-color: var(--orange);
  background: var(--orange);
  color: #122128;
}

.presentation-button.start-button:hover:not(:disabled) {
  background: #ffd08b;
  color: #081419;
  box-shadow: 0 0 18px rgba(240, 179, 108, 0.5);
}

.presentation-button.graph-button {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(12, 34, 46, 0.85);
  color: #38bdf8;
}

.presentation-button.graph-button:hover:not(:disabled),
.presentation-button.graph-button.is-active {
  border-color: #38bdf8;
  background: rgba(20, 52, 70, 0.95);
  color: #e0f2fe;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

/* Botón de Cálculos manuales (Esquina inferior derecha) */
.biblio-toggle-btn {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(205, 225, 222, 0.18);
  background: rgba(8, 22, 30, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #dbe8e3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  transition: all 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.biblio-toggle-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.biblio-toggle-btn:hover {
  border-color: rgba(117, 211, 192, 0.6);
  background: rgba(18, 48, 60, 0.92);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65), 0 0 20px rgba(117, 211, 192, 0.3);
}

.biblio-toggle-btn:active {
  transform: translateY(0);
}

@media (max-width: 900px) {
  .dialogue-overlay {
    right: 4vw;
    bottom: 104px;
    width: 92vw;
    font-size: clamp(14px, 3.4vw, 20px);
    text-align: center;
  }
}

/* Modal de Cálculos manuales */
.biblio-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 12, 17, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 24px;
}

.biblio-modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.biblio-modal-container {
  position: relative;
  width: min(94vw, 1080px);
  height: min(90vh, 820px);
  background: rgba(10, 26, 36, 0.96);
  border: 1px solid rgba(117, 211, 192, 0.24);
  border-radius: 16px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.8), 0 0 40px rgba(117, 211, 192, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(12px);
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.biblio-modal-backdrop.is-open .biblio-modal-container {
  transform: scale(1) translateY(0);
}

.biblio-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(205, 225, 222, 0.12);
  background: rgba(6, 17, 23, 0.6);
}

.biblio-modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: #f4f8f6;
  display: flex;
  align-items: center;
  gap: 10px;
}

.biblio-modal-title svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.biblio-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(205, 225, 222, 0.15);
  background: rgba(14, 38, 48, 0.7);
  color: #8fa6a8;
  cursor: pointer;
  transition: all 160ms ease;
}

.biblio-modal-close svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.biblio-modal-close:hover {
  background: rgba(243, 139, 130, 0.2);
  border-color: var(--red);
  color: #fff;
}

.manual-calcs-intro {
  margin: 0;
  padding: 18px 24px 0;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.manual-calcs-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 14px 24px 24px;
}

.manual-calcs-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 980px);
  min-height: 0;
  padding: 12px;
  border: 1px solid rgba(117, 211, 192, 0.25);
  border-radius: 10px;
  background: rgba(244, 248, 246, 0.96);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  color: #17313a;
  text-decoration: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.manual-calcs-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(68vh, 720px);
  object-fit: contain;
}

.manual-calcs-preview span {
  position: absolute;
  right: 18px;
  bottom: 16px;
  padding: 6px 9px;
  border-radius: 4px;
  background: rgba(6, 17, 23, 0.84);
  color: #f4f8f6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.manual-calcs-preview:hover,
.manual-calcs-preview:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48), 0 0 20px rgba(117, 211, 192, 0.18);
  transform: translateY(-2px);
}

.biblio-tabs-nav {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(8, 22, 30, 0.4);
  border-bottom: 1px solid rgba(205, 225, 222, 0.08);
}

.biblio-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #8fa6a8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.biblio-tab-btn:hover {
  color: #e0f2fe;
  background: rgba(205, 225, 222, 0.06);
}

.biblio-tab-btn.is-active {
  color: var(--teal);
  background: rgba(117, 211, 192, 0.12);
  border-color: rgba(117, 211, 192, 0.3);
}

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

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

/* Tab 1: PDF Viewer */
.biblio-pdf-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}

.biblio-pdf-frame {
  width: 100%;
  flex: 1;
  min-height: 480px;
  border: 1px solid rgba(205, 225, 222, 0.12);
  border-radius: 8px;
  background: #15222e;
}

.biblio-pdf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.biblio-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  background: rgba(117, 211, 192, 0.15);
  border: 1px solid rgba(117, 211, 192, 0.4);
  color: var(--teal);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all 180ms ease;
}

.biblio-link-btn:hover {
  background: var(--teal);
  color: #061117;
}

.biblio-link-btn.google-deck {
  background: rgba(240, 179, 108, 0.15);
  border-color: rgba(240, 179, 108, 0.4);
  color: var(--orange);
}

.biblio-link-btn.google-deck:hover {
  background: var(--orange);
  color: #061117;
}

/* Tab 2 & 3: Documentation & Audit Report Styling */
.biblio-report-section {
  color: #dbe8e3;
  line-height: 1.7;
  font-size: 14px;
  max-width: 960px;
}

.biblio-report-section h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  color: #fff;
  margin-top: 0;
  margin-bottom: 8px;
}

.biblio-report-section h3 {
  font-size: 16px;
  color: var(--orange);
  margin-top: 22px;
  margin-bottom: 8px;
}

.biblio-card-box {
  background: rgba(14, 38, 48, 0.6);
  border: 1px solid rgba(205, 225, 222, 0.12);
  border-radius: 8px;
  padding: 18px;
  margin: 14px 0;
}

.biblio-card-box strong {
  color: var(--yellow);
}

.biblio-audit-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.biblio-audit-table th,
.biblio-audit-table td {
  padding: 10px 14px;
  text-align: left;
  border: 1px solid rgba(205, 225, 222, 0.12);
}

.biblio-audit-table th {
  background: rgba(8, 22, 30, 0.7);
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.biblio-audit-table td {
  background: rgba(14, 38, 48, 0.35);
}
