:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --ink: #27221d;
  --muted: #746b62;
  --line: #ddd4ca;
  --panel: #fffdf9;
  --accent: #35685b;
  --accent-strong: #244d43;
  --danger: #9d3328;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.viewer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
}

.event-state {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.panel {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-only,
.manager-only,
.home-only {
  display: none;
}

.dropzone {
  display: grid;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #f0ebe3;
  cursor: pointer;
}

.dropzone-title {
  font-size: 1.15rem;
  font-weight: 750;
}

.dropzone-copy {
  color: var(--muted);
}

.dropzone input {
  margin-top: 8px;
}

.native-file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-grid;
  min-height: 42px;
  width: fit-content;
  place-items: center;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

.file-selection {
  color: var(--muted);
  font-weight: 650;
}

.upload-progress {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.upload-progress::before {
  content: "";
}

.upload-progress-bar {
  width: 0%;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  transition: width 160ms ease;
}

.upload-progress {
  padding: 8px;
  border-radius: 8px;
  background: #ebe4da;
}

.event-form,
.login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.55fr) minmax(180px, 0.55fr) auto;
  gap: 12px;
  align-items: end;
}

.login-form {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.event-form,
.admin-actions,
.events-list {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.home-only p {
  max-width: 720px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.home-only a {
  color: var(--accent-strong);
  font-weight: 750;
}

.primary,
.secondary,
.danger {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 720;
}

.primary {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
}

.primary.compact {
  width: auto;
  margin-top: 0;
}

.primary:hover,
.primary:focus-visible {
  background: var(--accent-strong);
}

.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.secondary.compact {
  width: auto;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.admin-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.status-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.status {
  padding: 10px 12px;
  border-radius: 8px;
  background: #ece5db;
  color: var(--ink);
  opacity: 1;
  transition: opacity 240ms ease, transform 240ms ease;
}

.status.success {
  background: #dcebe3;
}

.status.error {
  background: #f5d7d3;
}

.status.is-fading {
  opacity: 0;
  transform: translateY(-4px);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.scroll-sentinel {
  height: 1px;
}

.events-list {
  display: grid;
  gap: 12px;
}

.event-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.event-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.event-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.event-card small {
  color: var(--muted);
}

.event-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  padding: 10px;
  border-radius: 8px;
  background: #f0ebe3;
}

.stat strong {
  display: block;
  font-size: 1.2rem;
}

.event-links {
  display: grid;
  gap: 8px;
}

.event-links a {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-weight: 700;
}

.qr-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.qr-card canvas {
  width: 132px;
  height: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #e9e1d7;
  cursor: zoom-in;
}

.photo-meta {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.photo-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-actions button,
.photo-actions a {
  display: inline-grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(44px, 0.12fr) minmax(0, 1fr) minmax(44px, 0.12fr);
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  background: rgba(22, 18, 15, 0.92);
}

.viewer[hidden] {
  display: none;
}

.viewer img {
  grid-column: 2;
  max-width: 100%;
  max-height: calc(100vh - 112px);
  object-fit: contain;
  border-radius: 8px;
  background: #111;
  touch-action: pan-y;
}

.viewer-close,
.viewer-nav {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 2rem;
  line-height: 1;
}

.viewer-nav {
  width: 48px;
  height: 64px;
  font-size: 2.4rem;
}

.viewer-prev {
  grid-column: 1;
}

.viewer-next {
  grid-column: 3;
}

.viewer-caption {
  grid-column: 1 / -1;
  max-width: min(92vw, 720px);
  color: rgba(255, 255, 255, 0.82);
  overflow-wrap: anywhere;
  text-align: center;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .topbar {
    align-items: flex-start;
  }

  .secondary {
    padding: 0 12px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewer {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .viewer img {
    grid-column: 1;
    max-height: calc(100vh - 104px);
  }

  .viewer-nav {
    display: none;
  }

  .event-form,
  .login-form,
  .event-stats {
    grid-template-columns: 1fr;
  }

  .event-card-header {
    display: grid;
  }

  .qr-card {
    grid-template-columns: 1fr;
  }
}
