:root {
  color-scheme: dark;
  --viewer-ink: #f7f5f0;
  --viewer-muted: rgba(247, 245, 240, 0.68);
  --viewer-glass: rgba(17, 17, 16, 0.7);
  --viewer-line: rgba(255, 255, 255, 0.2);
  --viewer-accent: #d7ff45;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 100%;
  min-height: 100%;
  background: #080808;
}

body {
  color: var(--viewer-ink);
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.viewer-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: auto;
  background: #080808;
}

.viewer-stage {
  position: relative;
  width: min(1920px, 100vw);
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: 1080px;
  overflow: hidden;
  isolation: isolate;
  cursor: grab;
  outline: none;
  user-select: none;
  touch-action: none;
  background: radial-gradient(circle at 50% 40%, #34342f, #10100f 70%);
}

.viewer-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: auto;
}

.viewer-stage.is-dragging {
  cursor: grabbing;
}

.viewer-stage:focus-visible::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: 8px;
  border: 1px solid rgba(215, 255, 69, 0.72);
  border-radius: 16px;
  pointer-events: none;
}

.viewer-image {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  -webkit-user-drag: none;
  will-change: contents;
}

.viewer-shade {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, transparent 23%, transparent 68%, rgba(0, 0, 0, 0.52) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.12));
}

.viewer-header {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 28px 32px;
  pointer-events: none;
}

.viewer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.5);
}

.viewer-brand-mark {
  width: 11px;
  height: 11px;
  border: 2px solid var(--viewer-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(215, 255, 69, 0.14);
}

.viewer-brand p,
.viewer-brand strong {
  margin: 0;
}

.viewer-brand p {
  margin-bottom: 3px;
  color: var(--viewer-muted);
  font-size: 9px;
  font-weight: 600;
}

.viewer-brand strong {
  font-size: 14px;
  font-weight: 600;
}

.viewer-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.viewer-frame {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.viewer-frame i {
  display: block;
  width: 24px;
  height: 1px;
  background: rgba(255, 255, 255, 0.42);
}

.viewer-frame span:first-child {
  color: #fff;
  font-weight: 700;
}

.viewer-display-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 0;
  border-radius: 13px;
  background: rgba(16, 16, 15, 0.3);
  box-shadow: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  pointer-events: auto;
}

.viewer-display-actions button {
  display: flex;
  align-items: center;
  height: 36px;
  gap: 8px;
  padding: 0 11px;
  color: rgba(255, 255, 255, 0.82);
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: color 160ms ease, background 160ms ease;
}

.viewer-display-actions button:hover,
.viewer-display-actions button:focus-visible,
.viewer-display-actions button.is-active {
  color: #fff;
  outline: none;
  background: rgba(255, 255, 255, 0.13);
}

.viewer-fullscreen-icon {
  width: 14px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) left top / 5px 1px no-repeat,
    linear-gradient(currentColor, currentColor) left top / 1px 5px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 5px 1px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 1px 5px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 5px 1px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 1px 5px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 5px 1px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 1px 5px no-repeat;
}

.viewer-instruction {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 140px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.045em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.viewer-stage.is-dragging .viewer-instruction {
  opacity: 0;
  transform: translate(-50%, 6px);
}

.viewer-drag-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  font-size: 17px;
}

.viewer-controls {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 28px;
  display: flex;
  align-items: stretch;
  height: 58px;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.viewer-scene-picker {
  position: relative;
}

.viewer-scene-trigger,
.viewer-scene-menu button {
  color: var(--viewer-ink);
  border: 0;
  cursor: pointer;
}

.viewer-scene-trigger {
  display: flex;
  align-items: center;
  min-width: 240px;
  height: 100%;
  gap: 12px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(158, 130, 94, 0.3);
  box-shadow: none;
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  opacity: 0.7;
  transition: background 160ms ease, opacity 160ms ease;
}

.viewer-scene-trigger:hover,
.viewer-scene-trigger:focus-visible {
  outline: none;
  background: rgba(177, 149, 112, 0.45);
  opacity: 0.86;
}

.viewer-scene-swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.38);
}

.viewer-scene-current {
  display: grid;
  flex: 1;
  gap: 3px;
  text-align: left;
  line-height: 1;
}

.viewer-scene-current small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.viewer-scene-current strong {
  font-size: 12px;
  font-weight: 650;
}

.viewer-chevron {
  width: 7px;
  height: 7px;
  margin: 0 3px 4px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.82);
  border-left: 1px solid rgba(255, 255, 255, 0.82);
  transform: rotate(45deg);
  transition: transform 160ms ease, margin 160ms ease;
}

.viewer-chevron.is-open {
  margin-top: 5px;
  margin-bottom: 0;
  transform: rotate(225deg);
}

.viewer-scene-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: 280px;
  padding: 8px;
  border: 0;
  border-radius: 22px;
  background: rgba(158, 130, 94, 0.3);
  box-shadow: none;
  backdrop-filter: blur(24px) saturate(135%);
  -webkit-backdrop-filter: blur(24px) saturate(135%);
  animation: viewer-menu-in 160ms ease-out;
}

@keyframes viewer-menu-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.viewer-scene-menu-title {
  margin: 8px 10px 7px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.viewer-scene-menu button {
  display: grid;
  grid-template-columns: 18px 1fr 13px;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.viewer-scene-menu button:hover,
.viewer-scene-menu button:focus-visible,
.viewer-scene-menu button.is-active {
  outline: none;
  background: rgba(255, 255, 255, 0.16);
}

.viewer-scene-menu strong {
  font-size: 12px;
  font-weight: 600;
}

.viewer-scene-menu button i {
  width: 6px;
  height: 6px;
  justify-self: end;
  border-radius: 50%;
  background: transparent;
}

.viewer-scene-menu button.is-active i {
  background: var(--viewer-accent);
  box-shadow: 0 0 0 4px rgba(215, 255, 69, 0.12);
}

.viewer-loading,
.viewer-error {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #151514;
}

.viewer-loading span {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--viewer-accent);
  border-radius: 50%;
  animation: viewer-spin 850ms linear infinite;
}

.viewer-loading p {
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  letter-spacing: 0.1em;
}

@keyframes viewer-spin {
  to { transform: rotate(360deg); }
}

.viewer-error {
  gap: 8px;
  padding: 24px;
  color: #fff;
  text-align: center;
  background: rgba(14, 14, 13, 0.92);
}

.viewer-error strong {
  font-size: 15px;
}

.viewer-error span {
  max-width: 80vw;
  color: rgba(255, 255, 255, 0.5);
  font-family: monospace;
  font-size: 10px;
  overflow-wrap: anywhere;
}

@media (max-width: 760px), (pointer: coarse) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .viewer-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .viewer-stage,
  .viewer-stage:fullscreen {
    --mobile-image-height: min(100dvh, 56.25vw);
    --mobile-image-width: min(100vw, 177.7778dvh);
    width: 100vw;
    height: 100dvh;
    max-height: none;
    aspect-ratio: auto;
    overscroll-behavior: none;
  }

  .viewer-image {
    object-fit: contain;
  }

  .viewer-header {
    padding:
      max(9px, env(safe-area-inset-top))
      max(9px, env(safe-area-inset-right))
      9px
      max(9px, env(safe-area-inset-left));
  }

  .viewer-brand p,
  .viewer-frame,
  .viewer-display-actions button > span:last-child {
    display: none;
  }

  .viewer-display-actions button {
    width: 30px;
    height: 30px;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
  }

  .viewer-display-actions {
    padding: 3px;
    border-radius: 10px;
  }

  .viewer-fullscreen-icon {
    width: 12px;
    height: 12px;
  }

  .viewer-instruction {
    top: auto;
    bottom: calc(
      (100dvh - var(--mobile-image-height)) / 2
      + max(18px, env(safe-area-inset-bottom))
    );
    gap: 0;
    transform: translateX(-50%);
  }

  .viewer-instruction > span:last-child {
    display: none;
  }

  .viewer-stage.is-dragging .viewer-instruction {
    transform: translate(-50%, 4px);
  }

  .viewer-drag-icon {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .viewer-controls {
    right: calc(
      (100vw - var(--mobile-image-width)) / 2
      + max(10px, env(safe-area-inset-right))
    );
    bottom: calc(
      (100dvh - var(--mobile-image-height)) / 2
      + max(10px, env(safe-area-inset-bottom))
    );
    left: auto;
    width: auto;
    height: 42px;
    transform: none;
  }

  .viewer-scene-trigger {
    min-width: 142px;
    gap: 8px;
    padding: 0 12px;
  }

  .viewer-scene-menu {
    right: 0;
    bottom: calc(100% + 8px);
    width: 176px;
    padding: 5px;
    border-radius: 16px;
  }

  .viewer-scene-swatch {
    width: 10px;
    height: 10px;
  }

  .viewer-scene-current {
    gap: 2px;
  }

  .viewer-scene-current small {
    font-size: 6px;
  }

  .viewer-scene-current strong,
  .viewer-scene-menu strong {
    font-size: 10px;
  }

  .viewer-chevron {
    width: 6px;
    height: 6px;
    margin-right: 1px;
    margin-left: 5px;
  }

  .viewer-scene-menu-title {
    margin: 5px 7px;
    font-size: 7px;
  }

  .viewer-scene-menu button {
    grid-template-columns: 13px 1fr 9px;
    gap: 7px;
    padding: 8px 7px;
    border-radius: 8px;
  }

  .viewer-scene-menu button i {
    width: 5px;
    height: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-scene-menu,
  .viewer-loading span {
    animation-duration: 1ms;
  }

  .viewer-chevron,
  .viewer-scene-trigger,
  .viewer-display-actions button {
    transition: none;
  }
}
