*{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  height:100%;
  font-family:Arial, Helvetica, sans-serif;
  background:#111;
  color:#fff;
}

body{
  display:flex;
  flex-direction:column;
}

.topbar,
.footerbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 18px;
  background:#1b1b1b;
  border-bottom:1px solid rgba(255,255,255,0.08);
}

.footerbar{
  border-top:1px solid rgba(255,255,255,0.08);
  border-bottom:none;
  justify-content:center;
}

.brand{
  font-weight:700;
  letter-spacing:.08em;
  white-space:nowrap;
}

.controls{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.btn{
  border:none;
  background:#2b2b2b;
  color:#fff;
  padding:10px 14px;
  border-radius:8px;
  cursor:pointer;
  text-decoration:none;
  font-size:14px;
  transition:transform .15s ease, background .15s ease;
}

.btn:hover{
  background:#3a3a3a;
  transform:translateY(-1px);
}

.link-btn{
  background:#0a3c78;
}

.link-btn:hover{
  background:#1457a5;
}

.viewer-wrap{
  flex:1;
  display:grid;
  grid-template-columns:64px 1fr 64px;
  align-items:center;
  min-height:0;
}

.book{
  width:100%;
  height:100%;
  overflow:auto;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  cursor:grab;
}

.book:active{
  cursor:grabbing;
}

.page-stage{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:min-content;
  min-height:min-content;
}

.page-image{
  max-width:min(90vw, 1100px);
  max-height:calc(100vh - 180px);
  width:auto;
  height:auto;
  display:block;
  box-shadow:0 12px 40px rgba(0,0,0,0.45);
  background:#fff;
  transform-origin:50% 50%;
  user-select:none;
  -webkit-user-drag:none;
}

.side-arrow{
  width:44px;
  height:72px;
  margin:auto;
  border:none;
  border-radius:10px;
  background:rgba(255,255,255,0.1);
  color:#fff;
  font-size:28px;
  cursor:pointer;
  transition:background .15s ease, transform .15s ease;
}

.side-arrow:hover{
  background:rgba(255,255,255,0.18);
  transform:scale(1.03);
}

.left-arrow{
  justify-self:center;
}

.right-arrow{
  justify-self:center;
}

#pageCounter{
  font-size:14px;
  opacity:.92;
}

@media (max-width: 900px){
  .viewer-wrap{
    grid-template-columns:48px 1fr 48px;
  }

  .topbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .controls{
    width:100%;
    justify-content:flex-start;
  }

  .page-image{
    max-width:min(92vw, 1100px);
    max-height:calc(100vh - 220px);
  }

  .side-arrow{
    width:38px;
    height:62px;
    font-size:24px;
  }
}

@media (max-width: 560px){
  .book{
    padding:12px;
  }

  .btn{
    padding:9px 11px;
    font-size:13px;
  }

  .brand{
    font-size:14px;
  }
}
