:root {
  color-scheme: dark;
  --gallery-bg: #080808;
  --gallery-text: #f5f3ef;
  --gallery-muted: #aaa7a1;
  --gallery-page-padding: clamp(24px, 6vw, 100px);
  font-family: Arial, Helvetica, sans-serif;
  background: var(--gallery-bg);
  color: var(--gallery-text);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--gallery-bg);
  color: var(--gallery-text);
}

button,
input,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

:focus-visible {
  outline: 2px solid #f5f3ef;
  outline-offset: 4px;
}

.gallery-back-link {
  color: var(--gallery-muted);
  font-size: 0.78rem;
  transition: color 180ms ease;
}

.gallery-back-link:hover {
  color: var(--gallery-text);
}

.gallery-landing,
.gallery-error-page {
  display: grid;
  min-height: 100svh;
  padding: 40px 24px 80px;
  place-items: center;
  text-align: center;
}

.gallery-landing {
  padding-bottom: 28px;
}

.gallery-entry-card,
.gallery-message-card {
  width: min(100%, 520px);
}

.gallery-eyebrow {
  margin: 0 0 18px;
  color: #bcb8b1;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.gallery-admin-entry {
  display: inline-block;
  margin-top: 16px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: color 180ms ease;
}

.gallery-admin-entry:hover {
  color: var(--gallery-text);
}

.gallery-landing h1,
.gallery-message-card h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 5rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.gallery-intro {
  max-width: 430px;
  margin: 24px auto 34px;
  color: #c5c1bb;
  font-size: 0.98rem;
  line-height: 1.8;
}

.gallery-entry-form {
  display: grid;
  gap: 12px;
  width: min(100%, 380px);
  margin-inline: auto;
}

.gallery-entry-input,
.gallery-admin-input,
.gallery-admin-select {
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid rgba(245, 243, 239, 0.24);
  border-radius: 2px;
  background: rgba(245, 243, 239, 0.04);
  color: var(--gallery-text);
}

.gallery-entry-input {
  border-radius: 9px;
}

.gallery-entry-input::placeholder,
.gallery-admin-input::placeholder {
  color: #85817b;
}

.gallery-primary-button,
.gallery-secondary-button,
.gallery-quiet-button {
  border: 0;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    opacity 180ms ease;
}

.gallery-primary-button {
  flex: 0 0 auto;
  padding: 14px 20px;
  background: var(--gallery-text);
  color: #080808;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-entry-form .gallery-primary-button {
  width: 100%;
  border-radius: 9px;
}

.gallery-primary-button:hover {
  background: #d8d5cf;
}

.gallery-primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.gallery-form-message {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: #e6aaa2;
  font-size: 0.82rem;
  line-height: 1.5;
}

.gallery-form-message[data-kind="success"] {
  color: #c6d6c1;
}

.gallery-demo-note {
  margin: 26px 0 0;
  color: #8d8982;
  font-size: 0.76rem;
  line-height: 1.6;
}

.gallery-demo-note code {
  color: var(--gallery-text);
  font-family: inherit;
  letter-spacing: 0.08em;
}

.gallery-page {
  padding-bottom: 170px;
}

.gallery-page-header {
  padding: 130px var(--gallery-page-padding) 45px;
}

.gallery-page-header h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4.8rem);
  font-weight: 400;
  letter-spacing: -0.055em;
}

.gallery-page-header p {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--gallery-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.gallery-demo-banner,
.gallery-service-warning {
  margin: 0 var(--gallery-page-padding) 32px;
  padding: 14px 16px;
  border-left: 2px solid #c5b88a;
  background: rgba(197, 184, 138, 0.08);
  color: #e0d7b8;
  font-size: 0.78rem;
  line-height: 1.6;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 28px);
  padding: 0 var(--gallery-page-padding);
}

.gallery-photo {
  position: relative;
  min-width: 0;
  aspect-ratio: 4 / 5;
  background: #151515;
}

.gallery-photo-open {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: grid;
  width: 100%;
  padding: 0;
  overflow: hidden;
  place-items: center;
  border: 0;
  background: #151515;
  cursor: zoom-in;
}

.gallery-photo-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 450ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.gallery-photo-open:hover img {
  transform: scale(1.025);
}

.gallery-photo-number {
  position: absolute;
  z-index: 2;
  bottom: 12px;
  left: 12px;
  color: var(--gallery-text);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 5px #000;
  pointer-events: none;
}

.gallery-preview-watermark {
  position: absolute;
  z-index: 1;
  display: grid;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.55rem, 1vw, 0.8rem);
  letter-spacing: 0.22em;
  text-shadow: 0 1px 5px #000;
  transform: rotate(-24deg);
  pointer-events: none;
}

.gallery-photo-download {
  position: absolute;
  z-index: 4;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 9px 12px;
  border: 1px solid rgba(245, 243, 239, 0.72);
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.76);
  color: #f5f3ef;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.gallery-photo-download:disabled {
  cursor: wait;
  opacity: 0.7;
}

.gallery-select-button {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(245, 243, 239, 0.9);
  border-radius: 50%;
  background: rgba(8, 8, 8, 0.08);
  color: #f5f3ef;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition:
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.gallery-select-button:hover {
  transform: scale(1.08);
}

.gallery-select-button[aria-pressed="true"] {
  background: #080808;
  color: #f5f3ef;
}

.gallery-select-button svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.gallery-select-button[aria-pressed="true"] svg {
  opacity: 1;
}

.gallery-order-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 62px var(--gallery-page-padding) max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.48) 52%,
    rgba(0, 0, 0, 0) 100%
  );
}

.gallery-order-inner {
  width: min(100%, 1200px);
  margin-inline: auto;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
}

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

.gallery-order-summary,
.gallery-order-total {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gallery-order-summary strong,
.gallery-order-total strong {
  font-size: 0.85rem;
  font-weight: 400;
}

.gallery-order-summary span,
.gallery-order-total span {
  color: #d0cdc7;
  font-size: 0.7rem;
}

.gallery-order-total {
  align-items: flex-end;
}

.gallery-order-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.gallery-quiet-button {
  padding: 8px 0;
  background: transparent;
  color: var(--gallery-text);
}

.gallery-download-list {
  display: grid;
  gap: 10px;
  width: min(100%, 360px);
  margin: 0 auto 24px;
  font-size: 0.72rem;
  text-decoration: underline;
  text-decoration-color: rgba(245, 243, 239, 0.45);
  text-underline-offset: 4px;
}

.gallery-quiet-button:hover {
  opacity: 0.74;
}

.gallery-order-details {
  max-height: min(62dvh, 590px);
  overflow: auto;
  padding: 0 4px 12px;
}

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

.gallery-order-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 18px;
}

.gallery-order-details h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
}

.gallery-order-items {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-order-items li,
.gallery-order-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #d7d4ce;
  font-size: 0.78rem;
}

.gallery-order-totals {
  display: grid;
  gap: 10px;
  max-width: 360px;
  margin: 20px 0 0 auto;
  padding-top: 16px;
  border-top: 1px solid rgba(245, 243, 239, 0.18);
}

.gallery-order-line.is-final {
  color: var(--gallery-text);
  font-size: 0.9rem;
}

.gallery-checkout-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  max-width: 520px;
  margin: 20px 0 0 auto;
}

.gallery-checkout-form .gallery-primary-button {
  width: 100%;
  border-radius: 9px;
}

.gallery-checkout-form .gallery-form-message {
  grid-column: 1 / -1;
}

.gallery-checkout-note {
  max-width: 520px;
  margin: 12px 0 0 auto;
  color: #aaa7a1;
  font-size: 0.7rem;
  line-height: 1.5;
}

.gallery-viewer {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: clamp(14px, 3vw, 44px);
  place-items: center;
  background: rgba(0, 0, 0, 0.94);
}

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

.gallery-viewer-content {
  position: relative;
  display: grid;
  width: min(100%, 1500px);
  height: min(calc(100dvh - 2 * clamp(14px, 3vw, 44px)), 920px);
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.gallery-viewer-image-wrap {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  touch-action: pan-y;
}

.gallery-viewer-image {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-viewer-watermark {
  position: absolute;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.75);
  font-size: clamp(0.65rem, 2vw, 1rem);
  letter-spacing: 0.25em;
  text-shadow: 0 1px 5px #000;
  transform: rotate(-24deg);
  pointer-events: none;
}

.gallery-viewer-close,
.gallery-viewer-arrow {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(245, 243, 239, 0.35);
  border-radius: 50%;
  background: rgba(8, 8, 8, 0.6);
  color: var(--gallery-text);
  font-size: 1.4rem;
  cursor: pointer;
}

.gallery-viewer-close {
  top: 0;
  right: 0;
}

.gallery-viewer-arrow {
  top: 50%;
  transform: translateY(-50%);
}

.gallery-viewer-prev {
  left: 0;
}

.gallery-viewer-next {
  right: 0;
}

.gallery-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  color: #d0cdc7;
  font-size: 0.78rem;
}

.gallery-error {
  margin: 24px 0;
  color: #e6aaa2;
  font-size: 0.85rem;
}

.gallery-admin {
  width: min(calc(100% - 2 * var(--gallery-page-padding)), 1200px);
  margin: 140px auto 100px;
}

.gallery-admin h1 {
  margin: 0 0 30px;
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.05em;
}

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

.gallery-admin-panel {
  padding: 24px;
  border: 1px solid rgba(245, 243, 239, 0.13);
  border-radius: 14px;
  background: rgba(245, 243, 239, 0.025);
}

.gallery-admin .gallery-admin-input,
.gallery-admin .gallery-admin-select {
  border-radius: 9px;
}

.gallery-admin .gallery-primary-button {
  border-radius: 9px;
}

.gallery-admin-panel h2 {
  margin: 0 0 20px;
  font-size: 1rem;
  font-weight: 400;
}

.gallery-admin-form {
  display: grid;
  gap: 12px;
}

.gallery-admin-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gallery-admin-label {
  display: grid;
  gap: 7px;
  color: #d0cdc7;
  font-size: 0.75rem;
}

.gallery-admin-note {
  color: #aaa7a1;
  font-size: 0.75rem;
  line-height: 1.6;
}

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

.gallery-admin-record {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(245, 243, 239, 0.13);
  font-size: 0.8rem;
}

.gallery-admin-record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gallery-admin-record small {
  color: #aaa7a1;
}

.gallery-admin-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-admin-inline .gallery-admin-input {
  flex: 1 1 120px;
}

.gallery-admin-inline .gallery-primary-button {
  padding: 10px 12px;
  font-size: 0.68rem;
}

.gallery-page-status {
  color: #c6d6c1;
}

.gallery-page-status.is-closed {
  color: #e6aaa2;
}

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .gallery-landing {
    padding: 24px 22px 56px;
  }

  .gallery-primary-button {
    width: 100%;
  }

  .gallery-page {
    padding-bottom: 202px;
  }

  .gallery-page-header {
    padding: 112px var(--gallery-page-padding) 28px;
  }

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

  .gallery-select-button {
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
  }

  .gallery-order-bar {
    padding: 54px 12px max(10px, env(safe-area-inset-bottom));
  }

  .gallery-order-inner {
    padding: 12px;
  }

  .gallery-order-compact {
    align-items: flex-end;
    gap: 8px;
  }

  .gallery-order-summary strong,
  .gallery-order-total strong {
    font-size: 0.75rem;
  }

  .gallery-order-summary span,
  .gallery-order-total span {
    font-size: 0.64rem;
  }

  .gallery-order-actions {
    gap: 10px;
  }

  .gallery-order-actions .gallery-quiet-button {
    font-size: 0.66rem;
  }

  .gallery-order-details {
    max-height: 48dvh;
  }

  .gallery-order-details-header {
    padding-bottom: 12px;
  }

  .gallery-viewer {
    padding: 10px;
  }

  .gallery-viewer-content {
    height: calc(100dvh - 20px);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .gallery-viewer-close,
  .gallery-viewer-arrow {
    width: 40px;
    height: 40px;
  }

  .gallery-viewer-prev {
    left: 6px;
  }

  .gallery-viewer-next {
    right: 6px;
  }

  .gallery-viewer-footer {
    flex-wrap: wrap;
    font-size: 0.7rem;
  }

  .gallery-admin {
    margin-top: 112px;
  }

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

  .gallery-admin-panel {
    padding: 18px;
  }
}

@media (max-width: 360px) {
  .gallery-admin h1 {
    font-size: clamp(2rem, 10vw, 2.4rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
