:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #6a6d72;
  --line: #dedbd2;
  --accent: #276a74;
  --accent-strong: #174b53;
  --focus: #d28b2a;
  --shadow: 0 18px 50px rgba(32, 33, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

body:has(.lightbox[open]) {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 56px);
  background: rgba(246, 245, 241, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

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

.search input,
.password-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search input:focus,
.password-row input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(210, 139, 42, 0.22);
}

.search {
  width: min(34vw, 320px);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 56px) 56px;
}

.gallery-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.download-all {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.photo-tile {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #e7e3d9;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 180ms ease;
}

.photo-tile:hover img,
.photo-tile:focus-visible img {
  transform: scale(1.04);
}

.photo-tile:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.photo-title {
  position: absolute;
  inset: auto 0 0;
  min-height: 34px;
  padding: 16px 10px 9px;
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
}

.empty-state {
  max-width: 620px;
  margin: 64px auto;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.lightbox {
  width: min(96vw, 1280px);
  height: min(94vh, 920px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #111;
  color: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.lightbox figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
}

.lightbox img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #111;
}

.lightbox figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 12px 64px;
  background: #181818;
  color: #f6f6f6;
}

.caption-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 10px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: white;
  color: #111;
  padding: 0 14px;
  border: 0;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.download-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.download-button:hover {
  background: #f0ece3;
}

.download-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.share-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #276a74;
  color: white;
}

.share-button:hover {
  background: #174b53;
}

.download-toast {
  position: absolute;
  left: 50%;
  bottom: 74px;
  z-index: 4;
  max-width: min(420px, calc(100vw - 32px));
  margin: 0;
  transform: translateX(-50%);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #111;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.close-button,
.nav-button {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.9);
}

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

.nav-button {
  top: 50%;
  transform: translateY(-50%);
}

.nav-button.previous {
  left: 12px;
}

.nav-button.next {
  right: 12px;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(39, 106, 116, 0.18), rgba(210, 139, 42, 0.16)),
    var(--bg);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 28px;
}

.login-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.form-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: #9b2d20;
  font-weight: 700;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .toolbar {
    width: 100%;
  }

  .search {
    width: 100%;
  }

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

  .lightbox {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }

  .lightbox figure {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .lightbox figcaption {
    position: sticky;
    bottom: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    min-height: 112px;
    padding: 12px 14px max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .caption-title {
    font-size: 0.9rem;
    text-align: center;
  }

  .download-button {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }

  .lightbox-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .lightbox-actions .download-button:only-child {
    grid-column: 1 / -1;
  }

  .share-button[hidden] + .download-button {
    grid-column: 1 / -1;
  }

  .nav-button {
    top: auto;
    bottom: calc(124px + env(safe-area-inset-bottom));
    transform: none;
  }

  .close-button {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
  }

  .download-toast {
    bottom: calc(126px + env(safe-area-inset-bottom));
  }

  .password-row {
    grid-template-columns: 1fr;
  }
}
