:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #687076;
  --line: #d9dee2;
  --paper: #f6f8f8;
  --panel: #ffffff;
  --teal: #007f73;
  --teal-dark: #005c54;
  --coral: #c13c45;
  --amber: #f2b84b;
  --shadow: 0 18px 46px rgba(30, 36, 40, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

button,
.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button:hover {
  border-color: #aeb8bd;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.primary {
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
}

.primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.danger {
  color: #ffffff;
  border-color: var(--coral);
  background: var(--coral);
}

.ghost {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(0, 0, 0, 0.42);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--teal);
}

label span,
dt,
.eyebrow,
.muted {
  color: var(--muted);
}

label span b {
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 2.8vw, 2.8rem);
}

h2 {
  font-size: 1.24rem;
}

.topbar,
.upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(18px, 4vw, 48px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 76px;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  color: #2f3336;
  background: #e6eaed;
  font-size: 0.82rem;
  font-weight: 900;
}

.status-pill[data-tone="ok"] {
  color: #053d37;
  background: #bce9df;
}

.status-pill[data-tone="error"] {
  color: #5f1118;
  background: #ffd8dc;
}

.admin-layout {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto 56px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.create-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 22px;
}

.admin-home {
  display: grid;
  gap: 0;
}

.open-event-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1.4fr) auto;
  gap: 16px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding: 22px;
}

.open-event-form h2 {
  grid-column: 1 / -1;
}

.create-form label,
.open-event-form label,
.links-panel label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.event-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.key-grid div {
  min-width: 0;
  border-left: 4px solid var(--amber);
  padding-left: 10px;
}

dt {
  font-size: 0.76rem;
  font-weight: 800;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.switch span {
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: #aeb8bd;
  position: relative;
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(26px);
}

.admin-columns {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 18px;
}

.qr-panel,
.links-panel,
.images-panel {
  padding: 22px;
}

.qr-box {
  width: min(100%, 296px);
  margin: 0 auto;
}

.qr-box svg {
  width: 100%;
  display: block;
}

.links-panel {
  display: grid;
  gap: 14px;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.image-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.image-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #d9dee2;
}

.image-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.upload-page {
  min-height: 100svh;
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(0, 127, 115, 0.94), rgba(32, 33, 36, 0.96)),
    #202124;
}

.upload-header {
  position: relative;
  z-index: 2;
}

.upload-main {
  min-height: calc(100svh - 116px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 190px));
  gap: 18px;
}

.pick-button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

.pick-button input {
  display: none;
}

.pick-icon {
  color: #ffffff;
  font-size: 3rem;
  line-height: 1;
}

.preview {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  place-items: center;
  padding: max(90px, env(safe-area-inset-top)) 18px max(92px, env(safe-area-inset-bottom));
  background: #080807;
  touch-action: none;
}

.preview[hidden] {
  display: none;
}

.preview img {
  max-width: 100%;
  max-height: calc(100% - 74px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58);
  transform-origin: 50% 18%;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  will-change: transform, opacity;
}

.preview.is-sending img {
  animation: throw-photo-up 560ms cubic-bezier(0.18, 0.72, 0.2, 1) forwards;
}

.swipe-hint {
  align-self: start;
  margin-top: -4px;
  padding: 10px 14px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.13);
  font-size: 0.98rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.preview.is-sending .swipe-hint,
.preview.is-sending .preview-actions {
  opacity: 0;
  transition: opacity 140ms ease;
}

.preview-actions {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.preview-actions button {
  pointer-events: auto;
}

.send-button {
  width: 64px;
  height: 64px;
  min-height: 64px;
  border-radius: 50%;
  color: #053d37;
  border-color: #ffffff;
  background: #ffffff;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
}

.screen-page {
  overflow: hidden;
  background: #080807;
}

.screen-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #080807;
}

.photo-grid {
  position: absolute;
  inset: 0;
  opacity: 0.68;
  filter: saturate(1.08) contrast(1.02);
  z-index: 1;
}

.tile {
  position: absolute;
  left: var(--tile-x);
  top: var(--tile-y);
  width: clamp(112px, var(--tile-width), 245px);
  aspect-ratio: var(--tile-aspect);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 7px;
  background: #151514;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.78) rotate(var(--tile-rotate));
  animation:
    tile-arrive 760ms ease forwards,
    tile-float var(--float-duration) ease-in-out var(--float-delay) infinite alternate;
  will-change: transform, opacity;
  z-index: 1;
}

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

.screen-label {
  position: fixed;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #ffffff;
  font-size: clamp(1rem, 1.6vw, 1.55rem);
  font-weight: 900;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.72);
}

.screen-label .status-pill[data-tone="ok"] {
  color: #ffffff;
  background: rgba(10, 12, 14, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.screen-label .status-pill[data-tone="ok"]::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f43f3f;
  box-shadow: 0 0 0 0 rgba(244, 63, 63, 0.78);
  animation: live-pulse 1.15s ease-out infinite;
}

.hero-photo {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 7vh 7vw;
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity 420ms ease,
    transform 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.hero-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
}

.hero-photo.is-visible {
  opacity: 1;
  transform: scale(1);
}

.hero-photo img {
  position: relative;
  max-width: min(88vw, 150vh);
  max-height: 82vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.66);
}

@keyframes throw-photo-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-68vh) scale(0.72);
  }
}

@keyframes tile-arrive {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes tile-float {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) rotate(var(--tile-rotate));
  }

  100% {
    transform: translate(-50%, -50%) translate(var(--float-x), var(--float-y))
      rotate(calc(var(--tile-rotate) + var(--float-rotate)));
  }
}

@keyframes live-pulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(244, 63, 63, 0.78);
  }

  70% {
    opacity: 0.78;
    box-shadow: 0 0 0 9px rgba(244, 63, 63, 0);
  }

  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(244, 63, 63, 0);
  }
}

@media (max-width: 760px) {
  .topbar,
  .upload-header {
    align-items: flex-start;
    padding: 22px 16px;
  }

  .admin-layout {
    width: calc(100vw - 24px);
  }

  .create-form,
  .open-event-form,
  .admin-columns,
  .key-grid {
    grid-template-columns: 1fr;
  }

  .event-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .copy-row {
    grid-template-columns: 1fr;
  }

  .picker {
    width: min(100%, 360px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile {
    width: clamp(86px, calc(var(--tile-width) * 1.45), 176px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview img,
  .hero-photo,
  .switch span,
  .switch span::after {
    transition-duration: 1ms;
  }

  .preview.is-sending img {
    animation-duration: 80ms;
  }

  .tile {
    animation: tile-arrive 120ms ease forwards;
  }

  .screen-label .status-pill[data-tone="ok"]::before {
    animation: none;
  }
}
