:root {
  --bg: #BCBFB9;
  --panel: #24262c;
  --accent: #e8a33d;
  --text: #f2f2f2;
  --text-dim: #9a9da5;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
}

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

/* ---------- Loading screen ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.4s ease;
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-box {
  width: min(360px, 80vw);
  text-align: center;
}
.loading-title {
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--text-dim);
}
.progress-track {
  width: 100%;
  height: 6px;
  background: #34363d;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}
.loading-pct {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Topbar ---------- */
#topbar {
  height: 48px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid #000;
  z-index: 10;
}
#doc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; gap: 8px; }
#topbar button, #bottombar button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#topbar button:hover, #bottombar button:hover {
  background: rgba(255,255,255,0.08);
}

/* ---------- Viewer ---------- */
#viewer-wrap {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

#book {
  filter: drop-shadow(0 10px 30px var(--shadow));
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  border: none;
  color: #fff;
  font-size: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 5;
  line-height: 1;
}
.nav-arrow:hover { background: rgba(0,0,0,0.6); }
.nav-prev { left: 12px; }
.nav-next { right: 12px; }

/* StPageFlip generated pages */
.page {
  position: relative;
  background-color: #fff;
  background-size: cover;
  background-position: center;
}
.page img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #fff;
  display: block;
  pointer-events: none;
}

/* Clickable areas over links found in the PDF */
.pdf-link {
  position: absolute;
  display: block;
  cursor: pointer;
  background: rgba(255, 200, 0, 0.35);
  outline: 2px solid rgba(255, 170, 0, 0.9);
  outline-offset: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.pdf-link:hover {
  background: rgba(255, 200, 0, 0.55);
  outline: 2px solid rgba(255, 140, 0, 1);
}

/* ---------- Bottombar ---------- */
#bottombar {
  flex: 0 0 auto;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--panel);
  border-top: 1px solid #000;
  padding: 0 16px;
  z-index: 10;
}
.page-indicator {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
#page-input {
  width: 46px;
  text-align: center;
  background: #34363d;
  border: 1px solid #45474e;
  color: var(--text);
  border-radius: 4px;
  padding: 3px 2px;
  font-size: 13px;
}
#page-slider {
  width: min(320px, 40vw);
  accent-color: var(--accent);
}

@media (max-width: 640px) {
  #doc-title { font-size: 12px; }
  #page-slider { display: none; }
  .nav-arrow { width: 38px; height: 38px; font-size: 24px; }
}
