:root {
  --accent: #b76e79;
  --ink: #251f23;
  --muted: #70646a;
  --paper: #fffaf6;
  --band: #f6ece5;
  --line: rgba(37, 31, 35, 0.13);
  --danger: #a33a3a;
  --ok: #3f7f5f;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  min-height: 100vh;
}

.hero {
  background: linear-gradient(rgba(37, 31, 35, 0.2), rgba(37, 31, 35, 0.28)),
    url("https://images.unsplash.com/photo-1511285560929-80b456fea0bc?auto=format&fit=crop&w=1600&q=80");
  background-position: center;
  background-size: cover;
  color: white;
  padding: 28px 18px 46px;
}

.hero-inner {
  margin: 0 auto;
  max-width: 1080px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 8px;
}

.ghost {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: white;
  padding: 9px 12px;
}

.hero h1 {
  font-size: clamp(2.2rem, 8vw, 5.6rem);
  letter-spacing: 0;
  line-height: 0.95;
  margin: 82px 0 16px;
  max-width: 820px;
}

.hero p {
  font-size: 1.1rem;
  line-height: 1.55;
  margin: 0 0 26px;
  max-width: 600px;
}

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

.primary,
.secondary,
.danger,
.plain {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 11px 15px;
}

.primary {
  background: var(--accent);
  color: white;
}

.button-spinner {
  animation: spin 0.75s linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: white;
  border-radius: 999px;
  display: none;
  height: 16px;
  width: 16px;
}

.is-loading .button-spinner {
  display: inline-block;
}

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

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

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

.plain {
  background: transparent;
  color: var(--ink);
}

.content {
  margin: 0 auto;
  max-width: 1080px;
  padding: 22px 18px 56px;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin: 0 0 18px;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

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

.tile {
  aspect-ratio: 1;
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.lazy-thumb {
  background: var(--band);
}

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

.video-placeholder {
  align-items: center;
  background: linear-gradient(135deg, #251f23, #5c4c55);
  color: white;
  display: flex;
  font-size: 2.1rem;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.media-fallback {
  align-items: center;
  background: var(--band);
  color: var(--muted);
  display: flex;
  font-size: 2rem;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.tile-meta {
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.68));
  bottom: 0;
  color: white;
  font-size: 0.78rem;
  left: 0;
  padding: 28px 9px 9px;
  position: absolute;
  right: 0;
}

.empty {
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
}

.modal {
  align-items: center;
  background: rgba(37, 31, 35, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.panel {
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(37, 31, 35, 0.22);
  max-height: min(860px, 92vh);
  max-width: 620px;
  overflow: auto;
  padding: 20px;
  width: 100%;
}

.panel h2,
.admin h2 {
  margin: 0 0 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

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

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

.drop {
  background: white;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 18px;
}

.notice {
  border-radius: 8px;
  margin: 12px 0;
  padding: 11px 12px;
}

.notice.ok {
  background: rgba(63, 127, 95, 0.12);
  color: var(--ok);
}

.notice.error {
  background: rgba(163, 58, 58, 0.12);
  color: var(--danger);
}

.admin {
  margin: 0 auto;
  max-width: 1080px;
  padding: 28px 18px;
}

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

.box {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.settings {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

.media-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  padding: 10px 0;
}

.thumb {
  aspect-ratio: 1;
  background: var(--band);
  border-radius: 8px;
  overflow: hidden;
}

.thumb img,
.thumb video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

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

.lightbox {
  background: rgba(0, 0, 0, 0.9);
}

.viewer {
  align-items: center;
  display: grid;
  gap: 12px;
  max-height: 92vh;
  max-width: min(94vw, 1080px);
  position: relative;
  width: 100%;
}

.viewer-media {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 0;
  position: relative;
  touch-action: pan-y;
}

.viewer img,
.viewer video {
  border-radius: 8px;
  max-height: 76vh;
  max-width: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.viewer img.is-loaded,
.viewer video.is-loaded {
  opacity: 1;
}

.viewer-loader {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  left: 50%;
  padding: 12px 14px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.viewer-loader[hidden] {
  display: none;
}

.viewer-caption {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.45;
  margin: 0 auto;
  max-width: 760px;
  padding: 12px 14px;
  width: min(100%, 760px);
}

.viewer-caption p {
  margin: 5px 0 0;
}

.lightbox-close,
.lightbox-nav {
  align-items: center;
  background: rgba(0, 0, 0, 0.34);
  border-radius: 999px;
  color: white;
  display: flex;
  font-weight: 800;
  justify-content: center;
  opacity: 0.42;
  position: absolute;
  transition: opacity 0.16s ease, background 0.16s ease;
  z-index: 25;
}

.lightbox-close:hover,
.lightbox-close:focus-visible,
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(0, 0, 0, 0.58);
  opacity: 1;
}

.lightbox-close {
  font-size: 1rem;
  height: 32px;
  right: 10px;
  top: 10px;
  width: 32px;
}

.lightbox-nav {
  font-size: 1.35rem;
  height: 34px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
}

.lightbox-nav.prev {
  left: 10px;
}

.lightbox-nav.next {
  right: 10px;
}

.slideshow {
  align-items: center;
  background: #090708;
  color: white;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.slideshow-controls {
  display: flex;
  gap: 8px;
  left: 14px;
  opacity: 0.24;
  position: fixed;
  top: 14px;
  transition: opacity 0.18s ease;
  z-index: 5;
}

.slideshow-controls:focus-within,
.slideshow-controls:hover {
  opacity: 1;
}

.slide-media {
  max-height: 100vh;
  max-width: 100vw;
  object-fit: contain;
}

@media (max-width: 760px) {
  .hero h1 {
    margin-top: 58px;
  }

  .admin-grid,
  .settings {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .actions,
  .toolbar .primary,
  .toolbar .secondary {
    width: 100%;
  }

  .lightbox {
    padding: 54px 12px 18px;
  }

  .viewer img,
  .viewer video {
    max-height: 64vh;
  }

  .lightbox-nav {
    height: 32px;
    width: 32px;
  }
}
