:root {
  color-scheme: light;
  --text: #171717;
  --muted: #717171;
  --line: #dedede;
  --surface: #f7f7f7;
  --danger: #a33232;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { background: #fff; color: var(--text); }
body { margin: 0; }
button, input { font: inherit; }
a { color: inherit; }

.gallery-shell {
  width: min(1280px, calc(100% - 64px));
  margin: 0 auto;
  padding: 76px 0 100px;
}

.profile {
  display: grid;
  justify-items: center;
  gap: 26px;
  margin-bottom: 64px;
  text-align: center;
}

.site-logo {
  display: block;
  width: min(var(--logo-size, 280px), 68vw);
  height: min(var(--logo-size, 280px), 68vw);
  object-fit: contain;
}

.site-logo-placeholder {
  display: grid;
  place-items: center;
  width: 260px;
  height: 100px;
  border: 1px solid #aaa;
  color: #777;
  font-size: .8rem;
  letter-spacing: .28em;
}

.profile-line {
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-line p {
  margin: 0;
  font-size: .88rem;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  border: 1px solid #aaa;
  background: #f1f1f1;
}

.social-links {
  display: flex;
  gap: 28px;
  font-size: .82rem;
}

.social-links a {
  position: relative;
  text-decoration: none;
}

.social-links a + a::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -15px;
  width: 1px;
  height: 13px;
  background: #bbb;
  transform: translateY(-50%);
}

.social-links a:hover { text-decoration: underline; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #d7d7d7;
  background: #f3f3f3;
  cursor: zoom-in;
  overflow: hidden;
}

.photo-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .7s ease, transform .7s ease;
}

.photo-item.in-view img.loaded {
  opacity: 1;
  transform: translateY(0);
}

.photo-credit {
  position: absolute;
  right: 9px;
  bottom: 8px;
  z-index: 1;
  max-width: calc(100% - 18px);
  padding: 4px 7px;
  overflow: hidden;
  color: #fff;
  background: #0009;
  font-size: clamp(.58rem, .85vw, .74rem);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .45s ease .25s;
  pointer-events: none;
}

.photo-item.in-view .photo-credit { opacity: 1; }

.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 54px 96px;
  border: 0;
  background: #fffffff7;
}

.lightbox[open] {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  place-items: center;
}

.lightbox::backdrop { background: #0008; }

.lightbox img {
  grid-column: 2;
  max-width: 100%;
  max-height: calc(100vh - 108px);
  object-fit: contain;
}

.lightbox-nav,
.lightbox-close {
  border: 0;
  color: #222;
  background: transparent;
  cursor: pointer;
}

.lightbox-nav { font-size: 3rem; }
.lightbox-prev { grid-column: 1; }
.lightbox-next { grid-column: 3; }

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 24px;
  font-size: 2rem;
}

.admin-page { min-height: 100vh; background: #f2f2f2; }

.admin-header {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  font-size: .82rem;
}

.admin-header form { margin: 0; }
.text-button { padding: 0; border: 0; background: transparent; text-decoration: underline; cursor: pointer; }
.admin-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 14px;
  border: 1px solid #1f2937;
  border-radius: 999px;
  color: #fff;
  background: #111827;
  font-weight: 700;
  text-decoration: none;
}
.admin-header-button:hover { background: #374151; }
.seatguard-button::before {
  content: "📷";
  margin-right: 6px;
}

.admin-shell {
  width: min(1060px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.admin-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
}

.admin-title h1, .auth-card h1 { margin: 0; }
.admin-title span { color: var(--muted); }
.admin-kicker { margin: 0 0 8px; color: var(--muted); font-size: .7rem; letter-spacing: .16em; }

.admin-card, .auth-card {
  margin-bottom: 20px;
  padding: 26px;
  border: 1px solid var(--line);
  background: #fff;
}

.admin-card h2 { margin-top: 0; font-size: 1.1rem; }
.admin-card > p, .auth-card > p { color: var(--muted); font-size: .85rem; }
.auth-card { width: min(480px, 100%); margin: 70px auto; }

.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.logo-size-setting { grid-column: 1 / -1; }
.range-row { display: flex; align-items: center; gap: 16px; }
.range-row input { width: min(520px, 100%); }
.range-row output { min-width: 56px; color: var(--text); font-weight: 700; }

.stack-form { display: grid; gap: 16px; }
.settings-form label, .stack-form label, .upload-setting > label {
  display: grid;
  gap: 7px;
  color: #555;
  font-size: .8rem;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid #bbb;
  background: #fff;
}

input[type="file"] { max-width: 100%; }
.check-label { display: flex !important; align-items: center; margin-top: 9px; }

.primary-button {
  justify-self: start;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #111;
  color: #fff;
  background: #111;
  cursor: pointer;
}

.upload-form { display: flex; align-items: center; gap: 20px; }

.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.admin-photo { border: 1px solid var(--line); background: var(--surface); }
.admin-photo[draggable="true"] { cursor: grab; }
.admin-photo.dragging { opacity: .35; }
.admin-photo.drag-target { outline: 2px solid #111; outline-offset: 2px; }
.admin-photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-credit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.photo-credit-form label {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
}
.photo-credit-form input {
  min-width: 0;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #bbb;
}
.photo-credit-form button {
  min-height: 30px;
  border: 1px solid #bbb;
  background: #fff;
  cursor: pointer;
}
.credit-save-status {
  align-self: center;
  color: var(--muted);
  font-size: .7rem;
}
.credit-save-status.saved { color: #29663b; }
.credit-save-status.error { color: var(--danger); }
.photo-actions { display: flex; justify-content: center; gap: 5px; padding: 8px; }
.photo-actions form { margin: 0; }
.photo-actions button { min-width: 32px; min-height: 30px; border: 1px solid #bbb; background: #fff; cursor: pointer; }
.photo-actions .danger-button { color: var(--danger); }
.drag-handle {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  color: var(--muted);
  user-select: none;
}

.reorder-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}

.reorder-heading h2 { margin-bottom: 6px; }
.reorder-heading p { margin: 0; color: var(--muted); font-size: .85rem; }
.reorder-controls { display: flex; align-items: center; gap: 14px; }
.reorder-status { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.reorder-status.changed { color: #805d14; }
.reorder-status.saved { color: #29663b; }
.reorder-status.error { color: var(--danger); }
.primary-button:disabled { opacity: .4; cursor: not-allowed; }

.flash { margin-bottom: 18px; padding: 12px 14px; border: 1px solid; background: #fff; }
.flash.error { color: var(--danger); border-color: #d6a0a0; }
.flash.success { color: #29663b; border-color: #a4cbae; }

@media (max-width: 900px) {
  .gallery-shell { width: min(100% - 32px, 720px); padding-top: 50px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .admin-photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-form { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .gallery-shell { width: calc(100% - 24px); padding-top: 36px; }
  .profile { margin-bottom: 42px; gap: 20px; }
  .profile-line { flex-direction: column; gap: 10px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lightbox { padding: 60px 8px; }
  .lightbox[open] { grid-template-columns: 36px minmax(0, 1fr) 36px; }
  .lightbox-nav { font-size: 2rem; }
  .admin-photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-form { align-items: flex-start; flex-direction: column; }
  .reorder-heading { flex-direction: column; }
  .reorder-controls { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-item img { transition: none; transform: none; }
}
