:root {
  color-scheme: dark;
  --bg: #111111;
  --text: #f5f3ee;
  --muted: rgba(245, 243, 238, 0.72);
  --line: rgba(245, 243, 238, 0.18);
  --panel: rgba(17, 17, 17, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overscroll-behavior: none;
  touch-action: none;
}

button {
  font: inherit;
}

.viewer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #111111;
  user-select: none;
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.stage img {
  width: 100vw;
  height: 100dvh;
  object-fit: contain;
  opacity: 1;
  transition: opacity 140ms ease;
  -webkit-user-drag: none;
}

.stage img.is-changing {
  opacity: 0.72;
}

.topbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.title,
.progress {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 1.2;
}

.title {
  font-weight: 700;
}

.progress {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-tap-highlight-color: transparent;
}

.nav:disabled {
  opacity: 0.24;
  cursor: default;
}

.nav-up {
  top: max(64px, calc(env(safe-area-inset-top) + 64px));
  left: 50%;
  transform: translateX(-50%);
}

.nav-down {
  bottom: max(44px, calc(env(safe-area-inset-bottom) + 44px));
  left: 50%;
  transform: translateX(-50%);
}

.nav-left {
  left: max(12px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
}

.nav-right {
  right: max(12px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
}

.dots {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(245, 243, 238, 0.36);
}

.dot.is-active {
  width: 22px;
  background: rgba(245, 243, 238, 0.92);
}

@media (min-width: 720px) {
  .topbar {
    left: 20px;
    right: 20px;
    max-width: 720px;
    margin: 0 auto;
  }

  .nav {
    width: 48px;
    height: 48px;
  }
}
