:root {
  --footer-side-size: 36px;
  --footer-gap: 8px;
  --footer-pad-x: 20px;
  --footer-pad-y: 4px;
}

@media (max-width: 768px) {
  :root {
    --footer-side-size: 34px;
    --footer-gap: 7px;
    --footer-pad-x: 16px;
    --footer-pad-y: 4px;
  }
}

@media (max-width: 420px) {
  :root {
    --footer-side-size: 32px;
    --footer-gap: 6px;
    --footer-pad-x: 12px;
  }
}

.reader-footer {
  position: relative;
  width: 100%;
  height: var(--reader-footer-h);
  z-index: 10020;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: var(--footer-side-size) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--footer-gap);
  padding: var(--footer-pad-y) var(--footer-pad-x);
  padding-bottom: calc(var(--footer-pad-y) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(90deg, rgba(79, 124, 255, 0.09), rgba(147, 98, 232, 0.1));
  border-top: 1px solid rgba(112, 110, 180, 0.14);
  isolation: isolate;
  flex-shrink: 0;
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.reader-footer.is-book-end {
  background: linear-gradient(90deg, rgba(23, 22, 49, 0.96) 0%, rgba(33, 30, 66, 0.97) 45%, rgba(42, 30, 73, 0.97) 100%);
  border-top: 1px solid rgba(138, 128, 210, 0.16);
  box-shadow: none;
}

.reader-footer,
.reader-footer * {
  pointer-events: auto;
}

.footer-nav-left,
.footer-nav-right {
  height: var(--footer-side-size);
  display: flex;
  align-items: center;
}

.footer-nav-left {
  width: var(--footer-side-size);
  min-width: var(--footer-side-size);
  justify-content: flex-start;
  justify-self: start;
}

.footer-nav-right {
  width: auto;
  min-width: var(--footer-side-size);
  justify-content: flex-end;
  justify-self: end;
  gap: 10px;
}

.footer-nav-right > * + * { margin-left: 10px; }

@supports (gap: 1px) {
  .footer-nav-right > * + * { margin-left: 0; }
}

.footer-center {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.footer-btn {
  width: var(--footer-side-size);
  height: var(--footer-side-size);
  padding: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(215, 211, 255, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(79, 124, 255, 0.06);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease, background 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .footer-btn:hover {
    border-color: rgba(155, 149, 255, 0.55);
    box-shadow: 0 12px 26px rgba(79, 124, 255, 0.1);
  }
}

.footer-btn:active {
  transform: scale(0.98);
}

.footer-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
  border-color: rgba(215, 211, 255, 0.55);
}

.footer-btn .nav-icon {
  width: 28px;
  height: 28px;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.footer-btn .nav-prev {
  transform: rotate(180deg);
}

.footer-btn:disabled .nav-icon {
  opacity: 0.55;
}

.footer-nav-left .footer-btn.hidden,
.footer-nav-right .footer-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}

.reader-footer.is-book-end .footer-nav-left .footer-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(198, 192, 255, 0.22);
  box-shadow: 0 6px 16px rgba(8, 8, 24, 0.16);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.reader-footer.is-book-end .footer-nav-left .footer-btn .nav-icon {
  opacity: 0.96;
  filter: brightness(0) saturate(100%) invert(87%) sepia(18%) saturate(830%) hue-rotate(204deg) brightness(104%) contrast(101%);
}

.reader-footer .reader-progress {
  width: 100%;
  max-width: 620px;
  min-width: 0;
  margin: 0 auto;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.reader-footer .reader-progress > * + * { margin-top: 2px; }

@supports (gap: 1px) {
  .reader-footer .reader-progress > * + * { margin-top: 0; }
}

.reader-footer .reader-progress.hidden {
  visibility: hidden;
  pointer-events: none;
}

.reader-footer .reader-progress-text {
  min-width: 60px;
  height: 20px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  color: rgba(31, 42, 68, 0.78);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(215, 211, 255, 0.95);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(79, 124, 255, 0.08);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.reader-footer .reader-progress-track {
  position: relative;
  width: 92%;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(243, 239, 248, 0.92), rgba(237, 232, 245, 0.88));
  border: 1px solid rgba(226, 220, 242, 0.95);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.96) inset, 0 0 0 1px rgba(255, 255, 255, 0.45), 0 3px 10px rgba(35, 34, 84, 0.06);
}

.reader-footer .reader-progress-fill {
  position: relative;
  z-index: 1;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(128, 205, 255, 0.95) 0%, rgba(155, 149, 255, 0.96) 28%, rgba(126, 114, 245, 0.98) 58%, rgba(111, 95, 244, 0.98) 76%, rgba(246, 175, 212, 0.96) 100%);
  box-shadow: 0 8px 18px rgba(122, 114, 242, 0.14), 0 0 12px rgba(122, 114, 242, 0.08);
  transition: width 180ms ease;
}

.footer-finish {
  position: relative;
  min-width: 122px;
  width: auto;
  height: calc(var(--footer-side-size) + 2px);
  padding: 0 16px 0 13px;
  white-space: nowrap;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(122, 114, 242, 0.95), rgba(79, 124, 255, 0.95));
  color: rgba(255, 255, 255, 0.98);
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
  overflow: hidden;
}

.footer-finish > * + * { margin-left: 8px; }

@supports (gap: 1px) {
  .footer-finish > * + * { margin-left: 0; }
}

.footer-finish::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.03));
  pointer-events: none;
}

.footer-finish .footer-finish-ico,
.footer-finish .footer-finish-text {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.footer-finish .footer-finish-ico {
  filter: drop-shadow(0 1px 4px rgba(255, 255, 255, 0.2));
}

.footer-finish.visible {
  display: inline-flex;
}

.footer-finish:active {
  transform: scale(0.98);
}

@media (hover: hover) and (pointer: fine) {
  .footer-finish:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.46), 0 0 0 8px rgba(255, 84, 214, 0.1);
  }
}

.footer-finish:disabled {
  opacity: 0.45;
  box-shadow: none;
}

/* Pulse hint on Next button (cover page, desktop) */
.footer-btn.footer-next-hint {
  animation: footerNextHintPulse 1.5s ease-in-out infinite;
  border-color: rgba(155, 149, 255, 0.75);
  box-shadow: 0 10px 24px rgba(79, 124, 255, 0.14), 0 0 0 0 rgba(122, 114, 242, 0.22);
}

.footer-btn.footer-next-hint .nav-icon {
  animation: footerNextHintArrow 1.5s ease-in-out infinite;
}

@keyframes footerNextHintPulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 10px 24px rgba(79, 124, 255, 0.12), 0 0 0 0 rgba(122, 114, 242, 0.2);
  }
  50% {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 14px 30px rgba(79, 124, 255, 0.18), 0 0 0 8px rgba(122, 114, 242, 0.1);
  }
}

@keyframes footerNextHintArrow {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50%      { transform: translateX(2px); opacity: 0.96; }
}

@media (prefers-reduced-motion: reduce) {
  .footer-btn.footer-next-hint,
  .footer-btn.footer-next-hint .nav-icon {
    animation: none;
  }
}

@media (max-width: 768px) {
  .reader-footer .reader-progress {
    max-width: 100%;
  }
  .reader-footer .reader-progress-text {
    min-width: 58px;
    height: 18px;
    padding: 0 8px;
  }
  .reader-footer .reader-progress-track {
    height: 14px;
  }
  .footer-btn .nav-icon {
    width: 26px;
    height: 26px;
  }
  .footer-finish {
    min-width: 108px;
    height: var(--footer-side-size);
    padding: 0 14px 0 11px;
    gap: 7px;
    font-size: 15px;
  }
  .footer-finish > * + * { margin-left: 7px; }
  @supports (gap: 1px) {
    .footer-finish > * + * { margin-left: 0; }
  }
  .footer-finish .footer-finish-ico {
    font-size: 15px;
  }
}

@media (max-width: 420px) {
  .reader-footer .reader-progress-text {
    min-width: 54px;
    padding: 0 7px;
  }
  .reader-footer .reader-progress-track {
    height: 14px;
  }
  .footer-btn .nav-icon {
    width: 24px;
    height: 24px;
  }
  .footer-finish {
    min-width: 96px;
    font-size: 14px;
    padding: 0 12px 0 10px;
    gap: 6px;
  }
  .footer-finish > * + * { margin-left: 6px; }
  @supports (gap: 1px) {
    .footer-finish > * + * { margin-left: 0; }
  }
}
