:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page: #09090b;
  --surface: #18181b;
  --text: #f2f2f3;
  --muted: #a1a1a6;
  --line: #3f3f46;
  --hover: #27272a;
  --pressed: #34343b;
  --backdrop: #09090bbd;
  background: var(--page);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
html, .stage, .qr-dialog { touch-action: manipulation; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.gallery {
  position: relative;
  isolation: isolate;
  height: 100vh;
  height: 100dvh;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
}

.overlay-control, .close-qr {
  display: grid;
  place-items: center;
  position: absolute;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.overlay-control::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: #09090b94;
}

.overlay-control:focus-visible { box-shadow: 0 0 0 6px var(--page); }
.overlay-control:active::before { background: #09090bd9; }

.overlay-control svg, .close-qr svg {
  position: relative;
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arrow {
  top: 50%;
  transform: translateY(-50%);
}

.arrow-previous { left: max(6px, env(safe-area-inset-left)); }
.arrow-next { right: max(6px, env(safe-area-inset-right)); }

.qr-trigger {
  top: max(6px, env(safe-area-inset-top));
  right: max(6px, env(safe-area-inset-right));
}

.qr-trigger svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.35;
}

.placeholder-detail {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.placeholder-detail svg {
  width: 30px;
  height: 30px;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  place-items: center;
  padding: 24px;
  background: var(--backdrop);
  backdrop-filter: blur(7px);
  z-index: 1;
}

.rotate-card, .qr-dialog {
  width: min(100%, 324px);
  padding: 23px 24px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 70px #0008;
  text-align: center;
}

.rotate-card h2, .qr-dialog h2 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -.035em;
}

.rotate-card p, .qr-dialog p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.rotate-icon { display: block; width: 90px; height: 90px; margin: 0 auto 9px; }
.rotate-icon g { stroke-linecap: round; stroke-linejoin: round; }
.rotate-guide { stroke: var(--muted); stroke-width: 2; }

.rotate-phone {
  stroke: var(--text);
  stroke-width: 2.4;
  transform-origin: 44.5px 47px;
}

.qr-dialog {
  position: fixed;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 24px);
  color: inherit;
}

.qr-dialog::backdrop { background: var(--backdrop, #09090bbd); backdrop-filter: blur(4px); }
.qr-dialog h2 { padding-inline: 24px; }

.close-qr {
  top: 8px;
  right: 8px;
  color: var(--muted);
}

.close-qr:active { background: var(--pressed); }

.qr-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 15px auto 4px;
  border-radius: 6px;
  background: white;
}

.qr-download {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  color: var(--text);
  font-size: 13px;
  text-underline-offset: 4px;
}

@media (hover: hover) {
  .overlay-control:hover::before { background: #09090bc9; }
  .close-qr:hover { background: var(--hover); }
}

@media (orientation: portrait) and (max-width: 767px),
  (orientation: portrait) and (any-pointer: coarse) {
  .rotate-overlay { display: grid; }
  .rotate-phone { animation: turn-phone 2.8s ease-in-out infinite; }
}

@keyframes turn-phone {
  0%, 13% { transform: rotate(0); }
  42%, 78% { transform: rotate(90deg); }
  100% { transform: rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; transform: rotate(42deg); }
}
