:root {
  color-scheme: light;
  --paper: #f4eee7;
  --paper-deep: #ebe2d8;
  --ink: #5f4639;
  --ink-strong: #4d382d;
  --muted: #78675f;
  --surface: #fffaf3;
  --line: #d9c9bc;
  --sage: #5f745f;
  --sage-dark: #304437;
  --gold: #c49752;
  --danger: #9f3d33;
  --shadow: 0 24px 70px rgba(78, 55, 43, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(72, 48, 37, 0.7), rgba(48, 68, 55, 0.58)),
    url("/images/leperthuis-hero.png") center / cover;
}

.auth-panel {
  width: min(100%, 440px);
  padding: 34px;
  border: 1px solid rgba(255, 250, 243, 0.72);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.93);
  box-shadow: var(--shadow);
}

.auth-panel h1,
.album-copy h1,
.gallery-heading h2,
.admin-hero h1 {
  margin: 0;
  color: var(--ink-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.auth-panel h1 {
  margin-top: 8px;
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  line-height: 0.96;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.small {
  font-size: 0.9rem;
}

.stack {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-strong);
  padding: 0 12px;
}

input:focus {
  border-color: var(--sage);
  outline: 3px solid rgba(95, 116, 95, 0.18);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 15px;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--ink-strong);
  color: var(--surface);
}

.button.secondary {
  border-color: var(--sage-dark);
  background: var(--sage-dark);
  color: #fff;
}

.button.ghost {
  border-color: rgba(95, 70, 57, 0.28);
  color: var(--ink-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.button[hidden] {
  display: none;
}

.quiet-link {
  display: inline-block;
  margin-top: 22px;
  color: var(--sage-dark);
  font-weight: 700;
}

.form-error,
.dialog-message.error {
  color: var(--danger);
  font-weight: 800;
}

.gallery-shell,
.admin-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(20px, 4vw, 52px);
  background: rgba(244, 238, 231, 0.92);
  color: var(--ink-strong);
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar form {
  margin: 0;
}

.album-entry {
  display: grid;
  grid-template-columns: minmax(280px, 0.62fr) minmax(340px, 1fr);
  align-items: end;
  gap: clamp(26px, 5vw, 74px);
  padding: clamp(30px, 6vw, 76px) clamp(20px, 4vw, 52px) clamp(40px, 7vw, 88px);
}

.album-entry-compact {
  padding-bottom: clamp(22px, 4vw, 38px);
}

.album-copy h1 {
  max-width: 680px;
  font-size: clamp(4rem, 13vw, 9.4rem);
  line-height: 0.88;
}

.album-copy p:not(.eyebrow) {
  max-width: 520px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.8;
}

.album-cover {
  position: relative;
  overflow: hidden;
  min-height: clamp(330px, 53vw, 650px);
  border: 0;
  border-radius: 38px;
  background: var(--paper-deep);
  box-shadow: var(--shadow);
  padding: 0;
  text-align: left;
}

.album-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 500ms ease;
}

.album-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(30, 20, 15, 0.03), rgba(30, 20, 15, 0.56));
}

.album-cover span {
  position: absolute;
  right: 22px;
  bottom: 22px;
  left: 22px;
  z-index: 1;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  color: #fffaf3;
}

.album-cover strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 500;
}

.album-cover small {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.album-cover:hover img,
.album-cover:focus-visible img {
  transform: scale(1.035);
}

.album-cover:focus-visible {
  outline: 4px solid rgba(95, 116, 95, 0.35);
  outline-offset: 4px;
}

.gallery-view[hidden] {
  display: none;
}

.gallery-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(20px, 4vw, 42px) clamp(20px, 4vw, 52px) 0;
}

.gallery-heading h2 {
  font-size: clamp(4.3rem, 11vw, 8.6rem);
  line-height: 0.86;
}

.selection-status {
  margin: 14px clamp(20px, 4vw, 52px) 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

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

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: clamp(72px, 7.1vw, 102px);
  grid-auto-flow: dense;
  gap: clamp(14px, 2vw, 24px);
  padding: clamp(32px, 5vw, 74px) clamp(20px, 4vw, 52px) clamp(54px, 8vw, 92px);
}

.photo-card {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  border-radius: 34px;
  background: var(--paper-deep);
  box-shadow: 0 16px 42px rgba(78, 55, 43, 0.1);
}

.tile-1,
.tile-4,
.tile-7 {
  grid-column: span 4;
  grid-row: span 3;
}

.tile-2 {
  grid-column: span 4;
  grid-row: span 5;
}

.tile-3,
.tile-5,
.tile-6,
.tile-8,
.tile-9 {
  grid-column: span 4;
  grid-row: span 3;
}

.photo-button {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: var(--paper-deep);
  padding: 0;
}

.photo-button img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  border-radius: 34px;
  display: block;
  object-fit: cover;
  transition: transform 420ms ease, filter 420ms ease;
}

.select-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  min-height: 34px;
  border: 1px solid rgba(255, 250, 243, 0.64);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.82);
  color: var(--ink-strong);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(48, 31, 23, 0.14);
}

.select-button.selected {
  border-color: var(--sage-dark);
  background: var(--sage-dark);
  color: #fffaf3;
}

.photo-card:hover img,
.photo-button:focus-visible img {
  filter: saturate(1.04) contrast(1.02);
  transform: scale(1.035);
}

.photo-button:focus-visible {
  outline: 4px solid rgba(95, 116, 95, 0.35);
  outline-offset: -4px;
}

.photo-meta {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.86);
  color: var(--ink-strong);
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.photo-card:hover .photo-meta,
.photo-card:focus-within .photo-meta {
  opacity: 1;
  transform: translateY(0);
}

.photo-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-meta a {
  color: var(--sage-dark);
  font-weight: 900;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.58);
  padding: 34px;
  text-align: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  background: rgba(29, 21, 17, 0.93);
  padding: 18px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox figure {
  min-width: 0;
  margin: 0;
}

.lightbox img {
  width: 100%;
  max-height: calc(100vh - 130px);
  display: block;
  object-fit: contain;
}

.lightbox figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  color: #fffaf3;
}

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

.lightbox-select.selected {
  border-color: rgba(255, 250, 243, 0.68);
  background: #fffaf3;
  color: var(--ink-strong);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 250, 243, 0.35);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.08);
  color: #fffaf3;
  font-size: 2rem;
  line-height: 1;
}

.icon-button.close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.download-dialog {
  width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.download-dialog::backdrop {
  background: rgba(29, 21, 17, 0.64);
}

.dialog-close {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.dialog-close .icon-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-strong);
}

.download-step {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-top: 16px;
}

.download-summary {
  margin: 14px 0 0;
  color: var(--ink-strong);
  font-size: 0.95rem;
  font-weight: 900;
}

.dialog-message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--sage-dark);
  font-weight: 800;
}

.admin-help,
.admin-list,
.admin-photo-sort,
.admin-downloads {
  margin: 0 clamp(20px, 4vw, 52px) 20px;
}

.admin-help,
.admin-photo-sort,
.admin-downloads {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}

.admin-help h2,
.admin-photo-sort h2,
.admin-downloads h2 {
  margin: 0 0 14px;
  color: var(--ink-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 500;
}

.admin-help p {
  margin: 10px 0 0;
  max-width: 920px;
  color: var(--muted);
  line-height: 1.75;
}

.admin-sort-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.admin-sort-header .button {
  flex: 0 0 auto;
}

.admin-sort-form {
  margin-top: 18px;
}

.sort-message {
  min-height: 22px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.sort-message.changed {
  color: var(--sage-dark);
}

.sort-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sort-photo {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 238, 231, 0.6);
  padding: 8px;
  cursor: grab;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
  user-select: none;
}

.sort-photo:focus-visible {
  border-color: var(--sage);
  outline: 3px solid rgba(95, 116, 95, 0.2);
}

.sort-photo.is-dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.sort-photo:hover {
  box-shadow: 0 14px 32px rgba(78, 55, 43, 0.12);
}

.sort-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  object-fit: cover;
}

.sort-photo strong,
.sort-photo span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort-photo span {
  color: var(--muted);
  font-size: 0.86rem;
}

.sort-position,
.sort-drag-handle {
  position: absolute;
  top: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--surface);
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(30, 20, 15, 0.2);
}

.sort-position {
  left: 12px;
  background: rgba(77, 56, 45, 0.9);
}

.sort-drag-handle {
  right: 12px;
  border: 1px solid rgba(255, 250, 243, 0.62);
  background: rgba(48, 68, 55, 0.9);
}

.sort-drag-handle:hover {
  background: var(--sage-dark);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
}

th {
  color: var(--ink-strong);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.admin-list {
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}

.admin-hero {
  padding: clamp(34px, 7vw, 74px) clamp(20px, 4vw, 52px);
}

.admin-hero h1 {
  max-width: 760px;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.96;
}

.admin-hero p:not(.eyebrow) {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.14rem);
  line-height: 1.75;
}

.admin-edit,
.admin-upload {
  display: grid;
  gap: 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.admin-edit {
  grid-template-columns: minmax(140px, 0.7fr) minmax(220px, 1.4fr) 90px auto;
  align-items: end;
}

.admin-upload {
  align-content: start;
}

.error-page {
  padding: 40px;
}

@media (max-width: 940px) {
  .album-entry,
  .admin-row,
  .admin-edit {
    grid-template-columns: 1fr;
  }

  .album-cover {
    min-height: 430px;
  }

  .gallery-heading {
    align-items: start;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .gallery-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-auto-rows: clamp(72px, 12vw, 100px);
  }

  .photo-card {
    grid-column: span 4;
    grid-row: span 3;
  }

  .tile-2,
  .tile-7 {
    grid-column: span 4;
    grid-row: span 4;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .button {
    width: 100%;
  }

  .album-entry {
    padding-top: 18px;
  }

  .album-copy h1,
  .gallery-heading h2 {
    font-size: clamp(3.4rem, 21vw, 5.8rem);
  }

  .album-cover {
    min-height: 360px;
    border-radius: 28px;
  }

  .album-cover span {
    align-items: start;
    flex-direction: column;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .photo-card,
  .tile-1,
  .tile-2,
  .tile-3,
  .tile-4,
  .tile-5,
  .tile-6,
  .tile-7,
  .tile-8,
  .tile-9 {
    grid-column: auto;
    grid-row: auto;
    min-height: 0;
    border-radius: 28px;
  }

  .photo-button img {
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 28px 28px 0 0;
  }

  .photo-meta {
    position: static;
    opacity: 1;
    transform: none;
    border-radius: 0;
  }

  .select-button {
    top: 12px;
    right: 12px;
  }

  .download-step {
    grid-template-columns: 1fr;
  }

  .admin-sort-header {
    flex-direction: column;
  }

  .admin-sort-header .button {
    width: 100%;
  }

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

  .lightbox {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    padding: 10px;
  }

  .lightbox figcaption {
    align-items: stretch;
    flex-direction: column;
  }

  .lightbox-actions {
    flex-direction: column;
  }

  .auth-panel {
    padding: 24px;
  }
}
