* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0906;
  color: #f1e9df;
  font-family: "Jost", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
}

.topbar__back {
  flex: 0 0 auto;
  color: #f1e9df;
  opacity: 0.75;
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.topbar__back:hover {
  opacity: 1;
  text-decoration: underline;
}

.topbar__brand {
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.1rem;
}

.topbar__hint {
  opacity: 0.6;
  font-size: 0.85rem;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0.5rem 1rem;
  overflow: auto;
}

.book {
  width: 100%;
  height: 100%;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease;
  transform-origin: center top;
  flex: 0 0 auto;
}

.stage--zoomed {
  justify-content: flex-start;
  align-items: flex-start;
}

.book img {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.empty-msg {
  max-width: 32rem;
  text-align: center;
  opacity: 0.7;
  line-height: 1.6;
}

.empty-msg code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
}

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.6rem 1.25rem;
  padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.controls__group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.controls__group--nav {
  flex: 1 1 auto;
  min-width: 12rem;
}

.controls__group--zoom {
  flex: 0 0 auto;
}

.controls__link {
  flex: 0 0 auto;
  color: #f1e9df;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 1.25rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.controls__link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.controls__btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1e9df;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.controls__btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.controls__btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.controls__btn--small {
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
}

.controls__btn--active {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.4);
}

.controls__indicator--zoom {
  min-width: 2.75rem;
}

.controls__slider {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

.controls__slider::-webkit-slider-thumb {
  appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #f1e9df;
  cursor: pointer;
}

.controls__slider::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: none;
  border-radius: 50%;
  background: #f1e9df;
  cursor: pointer;
}

.controls__slider:disabled {
  opacity: 0.3;
  cursor: default;
}

.controls__indicator {
  flex: 0 0 auto;
  min-width: 3.5rem;
  text-align: center;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .topbar__hint {
    display: none;
  }

  .topbar__back {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
  }

  .controls {
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    justify-content: center;
  }

  .controls__group--nav {
    order: 1;
    min-width: 100%;
  }

  .controls__group--zoom {
    order: 2;
  }

  .controls__link {
    order: 3;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }

  .controls__indicator {
    min-width: 2.75rem;
    font-size: 0.8rem;
  }
}
