:root{--blue:#0b3d91;--blue2:#062a66;--gold:#d4a017;--bg:#e8eef6}
*{box-sizing:border-box}
html,body{height:100%;margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:#14213d;overflow:hidden}
body{display:grid;grid-template-rows:64px 1fr 96px}
.site-footer{min-height:0;display:flex;flex-direction:column}
.educa-footer{height:52px;display:flex;align-items:center;justify-content:center;background:#fff;border-top:1px solid rgba(16,42,82,.14);overflow:hidden;padding:4px 12px}
.educa-footer img{display:block;max-width:100%;max-height:44px;width:auto;height:auto;object-fit:contain}

button{font:inherit;cursor:pointer;border:0}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;background:linear-gradient(90deg,var(--blue2),var(--blue));color:#fff;box-shadow:0 2px 10px rgba(0,0,0,.25);z-index:20}
.brand{display:flex;align-items:center;gap:10px;min-width:0}.brand-mark{display:grid;place-items:center;width:42px;height:42px;border:2px solid var(--gold);border-radius:50%;font-weight:800;color:var(--gold)}
.brand div{display:flex;flex-direction:column;min-width:0}.brand strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.brand small{opacity:.82}
.toolbar{display:flex;gap:6px}.toolbar button{background:rgba(255,255,255,.14);color:#fff;border:1px solid rgba(255,255,255,.22);border-radius:8px;min-width:40px;height:38px;font-size:25px;font-weight:700}.toolbar button:hover{background:rgba(255,255,255,.26)}.toolbar button:disabled{opacity:.35;cursor:not-allowed}
.viewer-shell{min-height:0;display:flex;position:relative}.viewer{position:relative;flex:1;min-width:0;display:flex;align-items:center;justify-content:center;padding:20px 66px;background:radial-gradient(circle at center,#f8fbff 0,#dfe8f4 65%,#cbd8e8 100%);touch-action:none;user-select:none}
.book-stage{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}
canvas{display:block;max-width:100%;max-height:100%;filter:drop-shadow(0 16px 20px rgba(0,0,0,.25));transform:translateZ(0);backface-visibility:hidden}
.side-nav{position:absolute;top:50%;transform:translateY(-50%);z-index:30;width:48px;height:76px;border-radius:12px;background:rgba(11,61,145,.88);color:#fff;font-size:44px;line-height:1;box-shadow:0 7px 20px rgba(0,0,0,.22)}.side-nav:hover{background:var(--blue2);transform:translateY(-50%) scale(1.04)}.side-nav:disabled{opacity:.3;cursor:not-allowed}.prev-side{left:12px}.next-side{right:12px}
.statusbar{display:flex;align-items:center;justify-content:center;gap:18px;background:#102a52;color:#fff}.statusbar span{font-weight:700;min-width:130px;text-align:center}.statusbar small{opacity:.78}
@media(max-width:800px){body{grid-template-rows:58px 1fr 88px}.brand small{display:none}.toolbar button{min-width:34px;height:34px}.viewer{padding:10px 44px}.side-nav{width:38px;height:62px;font-size:36px}.prev-side{left:4px}.next-side{right:4px}.statusbar small{display:none}.educa-footer{height:46px;padding:3px 10px}.educa-footer img{max-height:40px}}
@media(max-width:480px){.brand-mark{display:none}.viewer{padding-left:38px;padding-right:38px}.educa-footer{height:42px}.educa-footer img{max-height:36px}}

/* === Identidad institucional + descarga PDF === */
.institution-logo{
  display:block;
  height:100px;
  object-fit:contain;
  object-position:center;
  flex:0 0 auto;
}
.brand-divider{
  width:1px;
  height:38px;
  background:rgba(255,255,255,.72);
  margin:0 2px 0 1px;
  flex:0 0 auto;
}
.brand-text{display:flex;flex-direction:column;min-width:0}
.toolbar{align-items:center}
.download-pdf{
  height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:0 14px;
  margin-right:3px;
  color:#fff;
  text-decoration:none;
  font-size:14px;
  font-weight:700;
  white-space:nowrap;
  border:1px solid rgba(255,255,255,.42);
  border-radius:8px;
  background:rgba(255,255,255,.08);
  transition:background .18s ease,border-color .18s ease,transform .18s ease;
}
.download-pdf:hover{
  background:rgba(255,255,255,.18);
  border-color:rgba(255,255,255,.7);
  transform:translateY(-1px);
}
.download-pdf:active{transform:translateY(0)}
.download-pdf svg{
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.9;
  stroke-linecap:round;
  stroke-linejoin:round;
  flex:0 0 auto;
}
.toolbar-divider{
  width:1px;
  height:30px;
  background:rgba(255,255,255,.28);
  margin:0 5px 0 3px;
}
@media(max-width:800px){
  .institution-logo{width:42px;height:39px}
  .brand-divider{height:32px}
  .download-pdf{height:34px;padding:0 10px}
  .download-pdf span{display:none}
  .download-pdf svg{width:19px;height:19px}
  .toolbar-divider{height:26px;margin-left:1px;margin-right:2px}
}
@media(max-width:560px){
  .institution-logo{width:36px;height:34px}
  .brand-divider{display:none}
  .brand{gap:7px}
}
@media(max-width:430px){
  .institution-logo{display:none}
}


/* === Navegación directa por número de página === */
.page-jump{display:inline-flex;align-items:center;gap:6px;margin-left:2px}
.page-jump label{font-size:13px;font-weight:700;opacity:.9}
.page-jump input{width:64px;height:30px;border:1px solid rgba(255,255,255,.35);border-radius:6px;background:#fff;color:#102a52;text-align:center;font-weight:700;outline:none}
.page-jump input:focus{box-shadow:0 0 0 2px rgba(255,255,255,.25)}
.page-jump button{height:30px;padding:0 10px;border-radius:6px;background:#fff;color:#0b3d91;font-size:13px;font-weight:800}
.page-jump button:hover{background:#edf4ff}
@media(max-width:560px){.statusbar{gap:8px}.page-jump label{display:none}.page-jump input{width:54px}.page-jump button{padding:0 8px}}


/* === Zoom táctil / móvil === */
.book-stage{position:relative}
canvas{will-change:transform;transition:transform .12s ease-out}
.viewer.is-zoomed canvas{transition:none;cursor:grab}
.viewer.is-zoomed canvas:active{cursor:grabbing}
.zoom-btn{font-size:22px!important}
@media(max-width:800px){
  .viewer{touch-action:none;overscroll-behavior:contain}
  canvas{transform-origin:center center}
}


/* === Botón Inicio en barra inferior, antes de Ir a === */
.home-page-btn{
  width:34px;height:30px;display:inline-flex;align-items:center;justify-content:center;
  flex:0 0 auto;border:1px solid rgba(255,255,255,.35);border-radius:6px;
  background:rgba(255,255,255,.12);color:#fff;padding:0;transition:background .16s ease,transform .16s ease
}
.home-page-btn:hover{background:rgba(255,255,255,.24);transform:translateY(-1px)}
.home-page-btn:active{transform:none}
.home-page-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
@media(max-width:560px){.home-page-btn{width:32px;height:30px}.home-page-btn svg{width:17px;height:17px}}

/* === Corrección responsive de barra superior en móviles verticales === */
@media (max-width: 700px) and (orientation: portrait){
  body{grid-template-rows:104px 1fr 88px}
  .topbar{
    height:104px;
    padding:6px 8px 7px;
    display:grid;
    grid-template-columns:1fr;
    grid-template-rows:46px 43px;
    gap:2px;
    overflow:visible;
  }
  .brand{
    width:100%;
    min-width:0;
    justify-content:flex-start;
    gap:7px;
    overflow:hidden;
  }
  .institution-logo{
    display:block;
    width:35px;
    height:34px;
    flex:0 0 35px;
  }
  .brand-divider{display:block;height:29px;margin:0 1px}
  .brand-mark{
    display:grid;
    width:34px;
    height:34px;
    min-width:34px;
    font-size:13px;
    border-width:1.5px;
  }
  .brand-text{min-width:0;flex:1}
  .brand strong{font-size:14px;line-height:17px;max-width:100%}
  .brand small{display:block;font-size:10px;line-height:13px}
  .toolbar{
    width:100%;
    min-width:0;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:5px;
    overflow:visible;
  }
  .toolbar button{
    width:34px;
    min-width:34px;
    height:34px;
    padding:0;
    font-size:21px;
    border-radius:7px;
    flex:0 0 34px;
  }
  .download-pdf{
    width:34px;
    min-width:34px;
    height:34px;
    padding:0;
    margin:0;
    flex:0 0 34px;
  }
  .download-pdf span{display:none}
  .download-pdf svg{width:18px;height:18px}
  .toolbar-divider{height:25px;margin:0 1px;flex:0 0 1px}
}

@media (max-width: 390px) and (orientation: portrait){
  .topbar{padding-left:5px;padding-right:5px}
  .toolbar{gap:4px}
  .toolbar button{width:32px;min-width:32px;height:32px;flex-basis:32px;font-size:20px}
  .download-pdf{width:32px;min-width:32px;height:32px;flex-basis:32px}
  .institution-logo{width:31px;height:31px;flex-basis:31px}
  .brand-mark{width:31px;height:31px;min-width:31px}
}
