:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --ink: #181716;
  --muted: #68615a;
  --paper: #fffdf8;
  --line: #ded6c8;
  --red: #c51424;
  --red-dark: #8d101d;
  --shadow: 0 18px 48px rgba(28, 22, 16, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(24, 23, 22, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 23, 22, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 38px 38px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
img,
input,
textarea {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.editor-shell {
  width: min(1280px, calc(100% - 32px));
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
}

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

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  font-weight: 500;
  line-height: 0.9;
}

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

.button-link,
.save-button {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.save-button {
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.save-message {
  margin: 0 0 18px;
  border-left: 5px solid var(--red);
  padding: 10px 12px;
  background: var(--paper);
  color: var(--red-dark);
  font-weight: 900;
}

.presentation-grid,
.editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.category-row {
  min-width: 0;
}

.category-title,
.category-input {
  display: grid;
  width: 100%;
  min-height: 54px;
  place-items: center;
  margin: 0 0 12px;
  border: 0;
  border-top: 4px solid var(--red);
  border-bottom: 1px solid var(--red);
  color: var(--red);
  background: transparent;
  font-size: clamp(1.35rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.category-input {
  padding: 8px 10px;
  outline: 0;
}

.category-input:focus {
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(197, 20, 36, 0.2);
}

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

.presentation-grid {
  gap: 42px;
}

.presentation-grid .category-pieces {
  align-items: stretch;
  gap: 28px;
}

.art-card {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(28, 22, 16, 0.08);
}

.presentation-card {
  border: 12px solid #332821;
  border-radius: 6px;
  background: #fffaf0;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.55) inset,
    0 18px 46px rgba(28, 22, 16, 0.18);
}

.frame-image {
  display: grid;
  min-height: clamp(320px, 38vw, 560px);
  place-items: center;
  padding: clamp(12px, 2vw, 24px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(245, 236, 220, 0.88)),
    #f8efe2;
}

.image-button,
.drop-zone {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #e8e0d3;
}

.image-button {
  cursor: zoom-in;
}

.drop-zone {
  cursor: pointer;
}

.frame-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: clamp(280px, 34vw, 500px);
  object-fit: contain;
}

.image-button img,
.drop-zone img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  transition: transform 180ms ease, filter 180ms ease;
}

.image-button:hover img,
.image-button:focus-visible img,
.drop-zone:hover img,
.drop-zone.is-dragging img {
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.018);
}

.image-button:focus-visible,
.lightbox button:focus-visible,
.button-link:focus-visible,
.save-button:focus-visible,
.caption-input:focus {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.caption {
  margin: 0;
  min-height: 48px;
  padding: 11px 12px 12px;
  color: var(--muted);
  font-size: clamp(0.94rem, 1.4vw, 1.08rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.presentation-card .caption {
  border-top: 1px solid rgba(51, 40, 33, 0.16);
  background: #fffaf0;
}

.editor-card {
  display: grid;
}

.upload-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(24, 23, 22, 0.82);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.caption-input {
  width: 100%;
  min-height: 58px;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 11px 12px;
  color: var(--muted);
  background: var(--paper);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.lightbox {
  width: min(94vw, 1100px);
  max-width: 1100px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: white;
}

.lightbox::backdrop {
  background: rgba(12, 10, 9, 0.88);
}

.lightbox[open] {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: center;
  gap: 14px;
}

.lightbox-frame {
  margin: 0;
}

.lightbox-frame img {
  display: block;
  width: 100%;
  max-height: 82vh;
  border-radius: 8px;
  object-fit: contain;
  background: #1b1815;
  box-shadow: var(--shadow);
}

.lightbox-frame figcaption {
  padding-top: 12px;
  color: #fff8ea;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  color: white;
  cursor: pointer;
}

.lightbox-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 42px;
  height: 42px;
  font-size: 2rem;
  line-height: 1;
}

.lightbox-nav {
  width: 56px;
  height: 56px;
  font-size: 3rem;
  line-height: 0.8;
}

@media (max-width: 760px) {
  .gallery-shell,
  .editor-shell {
    width: min(100% - 22px, 560px);
    padding-top: 22px;
  }

  .page-header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .button-link,
  .save-button {
    flex: 1;
  }

  .presentation-grid,
  .editor-grid {
    gap: 22px;
  }

  .category-pieces {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .category-title,
  .category-input {
    min-height: 46px;
    font-size: clamp(1.1rem, 7vw, 2rem);
  }

  .image-button img,
  .drop-zone img {
    aspect-ratio: 4 / 5;
  }

  .frame-image {
    min-height: 330px;
  }

  .frame-image img {
    max-height: 300px;
  }

  .caption,
  .caption-input {
    font-size: 0.88rem;
  }

  .lightbox[open] {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .lightbox-nav {
    position: fixed;
    top: 50%;
    width: 44px;
    height: 44px;
    font-size: 2.3rem;
  }

  .lightbox-prev {
    left: 10px;
  }

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