:root {
  --control-height: 48px;
  --control-gap: 8px;
  --mat: 12px;
  --caption-height: 28px;
  --mat-color: rgba(26, 21, 18, 0.84);
  --mat-ink: #e9dcc6;
  --backdrop-fade: 0.45s;
  --meta-width: 230px;
  --meta-space: calc(var(--meta-width) + var(--mat));
  --bg-tiny: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 24 19' preserveAspectRatio='xMidYMid slice'%3E%3Cfilter id='b' x='-10%' y='-10%' width='120%' height='120%'%3E%3CfeGaussianBlur stdDeviation='1.1'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='1 1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Cimage filter='url(%23b)' x='0' y='0' width='24' height='19' preserveAspectRatio='none' xlink:href='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABIMDRANCxIQDhAUExIVGywdGxgYGzYnKSAsQDlEQz85Pj1HUGZXR0thTT0+WXlaYWltcnNyRVV9hnxvhWZwcm7/2wBDARMUFBsXGzQdHTRuST5Jbm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm7/wAARCAATABgDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAQDAQb/xAAiEAACAgIBAwUAAAAAAAAAAAABAgADERIxBDJBFCE0UYH/xAAUAQEAAAAAAAAAAAAAAAAAAAAD/8QAGBEBAQEBAQAAAAAAAAAAAAAAAAECEUH/2gAMAwEAAhEDEQA/APMp0te+Dqx+icTcUNWfjgDwwAk7Vsx5H7L2sb0yL3OowSPMG6p85iGzp1Fp0QhmHbn2icUubU2JY8AZiJOhvOtAZo7stK6kjjiIhH8SuAYiIkHX/9k='/%3E%3C/svg%3E");
}

html, body {
  height: 100%;
  margin: 0;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-layer.fade {
  opacity: 0;
  transition: opacity 1.4s ease-in-out;
}

.bg-layer.fade.visible {
  opacity: 1;
}

.bg-tiny {
  background-image: var(--bg-tiny);
}

.floater {
  position: fixed;
  top: 0;
  left: 0;
  cursor: pointer;
  will-change: transform;
  transition: opacity 0.6s ease, filter 0.6s ease;
}

.floater::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.floater-body {
  width: 100%;
  height: 100%;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.floater.ghost .floater-body {
  opacity: 0.22;
  filter: brightness(0) invert(1);
}

.floater.ghost .floater-play {
  opacity: 0;
}

.flyer {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.flyer.fading {
  opacity: 0;
}

.flyer-icon,
.flyer-photo {
  position: absolute;
}

.flyer-icon {
  object-fit: contain;
}

.flyer-photo {
  object-fit: cover;
  opacity: 0;
}

.floater-play {
  position: absolute;
  right: -14%;
  bottom: -14%;
  display: grid;
  place-items: center;
  width: max(14px, 40%);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9));
  pointer-events: none;
}

.floater-play::before {
  content: '';
  width: 75%;
  height: 85%;
  background: #fff;
  clip-path: polygon(8% 0, 100% 50%, 8% 100%);
}

.floater-image {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.floater-emoji {
  display: grid;
  place-items: center;
  line-height: 1;
  user-select: none;
}

.floater.fading {
  pointer-events: none;
  opacity: 0;
}

.reveal-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background-color 0.25s ease, backdrop-filter 0.25s ease, -webkit-backdrop-filter 0.25s ease;
  z-index: 10;
}

.reveal-layer.open {
  background-color: rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: background-color var(--backdrop-fade) ease-in-out, backdrop-filter var(--backdrop-fade) ease-in-out, -webkit-backdrop-filter var(--backdrop-fade) ease-in-out;
}

.reveal-layer.pinned {
  pointer-events: auto;
  background-color: rgba(0, 0, 0, 0.35);
}

.reveal {
  --chrome-height: calc(2 * var(--mat) + var(--caption-height) + var(--control-height) + var(--control-gap));
  --max-w: calc(92vw - 2 * var(--mat));
  --max-h: calc(85vh - var(--chrome-height));
  position: relative;
  display: flex;
  gap: var(--mat);
  margin: 0;
  padding: var(--mat);
  line-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--mat-color);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.reveal-layer.open .reveal {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.4s ease-out var(--backdrop-fade);
}

.reveal-layer.open.flying .reveal {
  opacity: 0;
  transition: none;
}

.reveal-layer.open.landed .reveal {
  transition: opacity 0.3s ease-out;
}

.reveal-main {
  min-width: 0;
}

.reveal-layer.has-meta .reveal {
  --max-w: calc(92vw - 2 * var(--mat) - var(--meta-space));
}

@supports (height: 1dvh) {
  .reveal {
    --max-h: calc(85dvh - var(--chrome-height));
  }
}

.reveal-media {
  position: relative;
  width: min(var(--max-w), calc(var(--max-h) * var(--ratio, 0.75)));
  aspect-ratio: var(--ratio, 0.75);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.reveal-placeholder,
.reveal-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reveal-placeholder {
  background-position: center;
  background-size: cover;
  filter: blur(14px);
  transform: scale(1.15);
}

.reveal-media:not(.loaded) .reveal-placeholder {
  animation: reveal-pulse 1.4s ease-in-out infinite;
}

.reveal-image {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.reveal-media:not(.loaded) .reveal-image {
  transition: none;
}

.reveal-media.loaded .reveal-image {
  opacity: 1;
}

@keyframes reveal-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.reveal-meta {
  display: none;
  position: relative;
  flex: none;
  width: var(--meta-width);
  line-height: normal;
}

.reveal-layer.has-meta .reveal-meta {
  display: block;
}

.reveal-meta-list {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  color: var(--mat-ink);
  font: 11px/1.4 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  scrollbar-width: thin;
}

.reveal-meta-group + .reveal-meta-group {
  margin-top: 12px;
}

.reveal-meta-group h4 {
  margin: 0 0 4px;
  font: 600 10px/1.4 system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.reveal-meta-group dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
  margin: 0;
}

.reveal-meta-group dt {
  opacity: 0.6;
}

.reveal-meta-group dd {
  margin: 0;
  word-break: break-all;
}

.reveal-caption {
  display: none;
  padding-top: var(--control-gap);
  color: var(--mat-ink);
  font: 14px/var(--caption-height) Georgia, 'Times New Roman', serif;
  letter-spacing: 0.03em;
  text-align: center;
}

.reveal-layer.has-caption .reveal-caption {
  display: block;
}

.reveal-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.reveal-layer.playing .reveal-video {
  opacity: 1;
}

.reveal-controls {
  display: none;
  align-items: center;
  gap: var(--control-gap);
  padding-top: var(--control-gap);
}

.reveal-layer.has-controls .reveal-controls {
  display: flex;
}

.reveal-thumbs {
  display: flex;
  gap: var(--control-gap);
  min-width: 0;
  overflow-x: auto;
}

.reveal-thumb {
  flex: none;
  box-sizing: border-box;
  height: var(--control-height);
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: none;
  overflow: hidden;
  cursor: pointer;
}

.reveal-thumb img {
  display: block;
  width: auto;
  height: 100%;
}

.reveal-thumb.selected {
  border-color: #fff;
}

.reveal-play {
  display: none;
  flex: none;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.reveal-play:hover {
  opacity: 1;
}

.reveal-layer.has-video .reveal-play {
  display: grid;
}

.reveal-play::before {
  content: '';
  width: 22px;
  height: 26px;
  background: #fff;
  clip-path: polygon(8% 0, 100% 50%, 8% 100%);
}

.reveal-layer.playing .reveal-play::before {
  width: 20px;
  height: 20px;
  clip-path: none;
}

.counter {
  position: fixed;
  right: max(6px, calc(env(safe-area-inset-right) - 8px));
  bottom: max(6px, calc(env(safe-area-inset-bottom) - 8px));
  z-index: 0;
  display: flex;
  padding: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  color: var(--mat-ink);
  font: 14px/1 Georgia, 'Times New Roman', serif;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.counter:hover .counter-label,
.counter:focus-visible .counter-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.counter:focus-visible {
  outline: 2px solid var(--mat-ink);
  border-radius: 8px;
}

.counter[aria-pressed='true'] .counter-outline {
  stroke: #ffc478;
}

body.shelf .floater,
body.unshelving .floater {
  transition: opacity 0.6s ease, filter 0.6s ease, width 0.4s ease, height 0.4s ease;
}

body.shelf .floater:not(.seen) {
  opacity: 0.4;
  filter: grayscale(0.6);
}

body.shelf .floater:not(.seen):hover {
  opacity: 0.9;
  filter: none;
}

.counter-icon {
  width: 40px;
  height: 40px;
  overflow: visible;
}

.counter-glass {
  fill: rgba(42, 29, 21, 0.55);
}

.counter-outline {
  fill: none;
  stroke: var(--mat-ink);
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.counter-shine {
  fill: none;
  stroke: var(--mat-ink);
  stroke-opacity: 0.35;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.counter-bean-body {
  fill: #5a3e31;
  stroke: var(--mat-ink);
  stroke-width: 1;
}

.counter-bean-slit {
  fill: none;
  stroke: #8d6a55;
  stroke-width: 1;
  stroke-linecap: round;
}

.counter-bean {
  animation: counter-bean-drop 0.55s cubic-bezier(0.3, 0.7, 0.4, 1.25) both;
}

.counter-seen {
  display: inline-block;
}

.counter-seen.bump {
  animation: counter-bump 0.35s ease-out;
}

@keyframes counter-bean-drop {
  from { transform: translateY(-34px); opacity: 0; }
  40% { opacity: 1; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes counter-bump {
  40% { transform: scale(1.4); }
}

@media (max-width: 700px) {
  :root {
    --meta-width: 0px;
    --meta-space: 0px;
  }

  .reveal-layer.has-meta .reveal-meta {
    display: none;
  }

  .reveal {
    gap: 0;
  }
}
