:root {
  color-scheme: dark;
  --bg-0: #05070d;
  --bg-1: #0b1120;
  --bg-2: #111b31;
  --panel: rgba(10, 14, 24, 0.72);
  --panel-strong: rgba(12, 18, 32, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.94);
  --text-soft: rgba(255, 255, 255, 0.72);
  --accent: #8ef0c2;
  --accent-2: #8dbbff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(141, 187, 255, 0.12), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(142, 240, 194, 0.08), transparent 35%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 50%, var(--bg-2));
  overflow: hidden;
}

html.is-fallback,
body.is-fallback {
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

button {
  font: inherit;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.viewer {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
}

.viewer.is-panning {
  cursor: grabbing;
}

.viewer::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.hud > * {
  pointer-events: auto;
}

.sheet {
  display: block;
  margin: 0 auto;
  transform-origin: top center;
  box-shadow: var(--shadow);
  background: #fff;
}

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

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 20;
  pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
}

.hud--top {
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.hud--bottom {
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.brand,
.hint,
.zoom-readout {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  color: var(--text);
}

.brand {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hint {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.control,
.zoom-readout {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}

.control {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  opacity: 0.92;
}

.control--primary {
  width: auto;
  min-width: 72px;
  padding: 0 12px;
}

.control__label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 13, 0.72);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 180ms ease;
}

.app.is-ready .loading {
  opacity: 0;
  pointer-events: none;
}

.app.is-fallback {
  position: relative;
  min-height: 100%;
  padding: 12px 0 24px;
}

.app.is-fallback .viewer {
  position: static;
  inset: auto;
  overflow: visible;
  touch-action: auto;
  cursor: default;
  display: flex;
  justify-content: center;
}

.app.is-fallback .sheet {
  width: min(76vw, 540px) !important;
  height: auto !important;
  box-shadow: none;
}

.app.is-fallback .sheet img {
  height: auto;
  pointer-events: auto;
}

.app.is-fallback .hud,
.app.is-fallback .loading {
  display: none;
}

@media (max-width: 640px) {
  .hud {
    padding-left: 8px;
    padding-right: 8px;
  }

  .control {
    width: 38px;
    height: 38px;
  }

  .control--primary {
    min-width: 68px;
  }
}
