:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --text: #171916;
  --muted: #7e8279;
  --line: #e4e7df;
  --accent: #8da82c;
  --shadow: 0 8px 24px rgba(23, 29, 13, .07);
  --max: 1600px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Arial, Helvetica, sans-serif; }
body.viewer-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.gallery-page, .image-page { width: min(var(--max), calc(100% - 64px)); margin: 0 auto; }
.gallery-page { padding: 28px 0 64px; }
.image-page { padding: 28px 0 84px; }
.site-name { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 64px; margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--text); font-size: 21px; font-weight: 800; letter-spacing: -.06em; }
.site-logo { display: block; flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; object-fit: contain; }
.brand-text { display: block; }
.site-name:hover { color: var(--accent); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; align-items: start; }
.photo-card { display: block; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; content-visibility: auto; contain-intrinsic-size: 260px; }
.photo-card:hover { border-color: #d4d9ca; box-shadow: var(--shadow); transform: translateY(-3px); }
.photo-card:focus-visible, .back-link:focus-visible, .full-gallery-link:focus-visible, .site-name:focus-visible, .sequence-nav a:focus-visible { outline: 3px solid rgba(141, 168, 44, .35); outline-offset: 3px; }
.photo-image { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; background: #ecefe9; }
.photo-image img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-card:hover .photo-image img { transform: none; }
.photo-card-info { display: block; min-height: 49px; padding: 11px 12px 12px; }
.photo-card-info h2 { margin: 0; color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.38; }
.load-sentinel { height: 1px; }
.empty { padding: 100px 0; color: var(--muted); text-align: center; }
.empty-page { width: min(var(--max), calc(100% - 64px)); margin: 0 auto; padding: 28px 0 84px; }

.image-page .site-name { margin-bottom: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 30px; color: var(--muted); font-size: 12px; }
.back-link:hover, .full-gallery-link:hover { color: var(--accent); }
.photo-details { width: min(100%, 1100px); margin: 0 auto; }
.image-button { display: flex; align-items: center; justify-content: center; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.detail-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 78vh; margin: 0 auto; object-fit: contain; background: #eef0eb; }
.detail-image:hover { opacity: .95; }
.detail-title { margin: 18px 0 0; color: var(--text); font-size: clamp(25px, 3vw, 42px); font-weight: 600; line-height: 1.08; letter-spacing: -.045em; text-align: center; }
.sequence-nav { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 18px; width: min(100%, 1100px); margin: 28px auto 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sequence-link { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); }
.sequence-link > span:not(.sequence-arrow) { min-width: 0; max-width: 100%; overflow: hidden; }
.sequence-link:hover, .sequence-home:hover { color: var(--accent); }
.sequence-next { justify-content: flex-end; text-align: right; }
.sequence-arrow { flex: 0 0 auto; font-size: 22px; line-height: 1; }
.sequence-link small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sequence-link strong { display: block; width: min(260px, 100%); max-width: 100%; overflow: hidden; font-size: 12px; font-weight: 600; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.sequence-home { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.related-section { padding-top: 82px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-heading h2 { margin: 0; color: var(--text); font-size: 21px; font-weight: 600; letter-spacing: -.035em; }
.related-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.related-grid .photo-card-info { min-height: 44px; padding: 9px 10px 10px; }
.related-grid .photo-card-info h2 { font-size: 11px; }
.full-gallery-link { display: inline-flex; align-items: center; gap: 10px; margin-top: 30px; color: var(--text); font-size: 12px; font-weight: 600; }
.full-gallery-link span { font-size: 18px; line-height: 1; }

.viewer { position: fixed; z-index: 20; inset: 0; display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; place-items: center; padding: 28px; background: rgba(11, 12, 10, .98); opacity: 0; transition: opacity .18s ease; }
.viewer[hidden] { display: none; }
.viewer.is-open { opacity: 1; }
.viewer-figure { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; margin: 0; }
.viewer-figure img { width: auto; max-width: min(100%, 1120px); height: auto; max-height: calc(100vh - 105px); object-fit: contain; }
.viewer-figure figcaption { max-width: min(90vw, 900px); padding-top: 13px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-figure figcaption a { color: rgba(255,255,255,.8); border-bottom: 1px solid rgba(255,255,255,.35); }
.viewer-figure figcaption a:hover { color: var(--accent); border-color: var(--accent); }
.viewer-close, .viewer-arrow { display: grid; place-items: center; border: 1px solid rgba(255,255,255,.24); color: #fff; background: rgba(0,0,0,.18); transition: color .18s ease, border-color .18s ease, background .18s ease; }
.viewer-close { position: absolute; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%; font-size: 27px; line-height: 1; }
.viewer-close:hover, .viewer-arrow:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,255,255,.06); }
.viewer-arrow { width: 46px; height: 46px; border-radius: 50%; font-size: 37px; line-height: .7; }
.viewer-arrow:disabled { cursor: not-allowed; opacity: .28; }
.viewer-arrow:disabled:hover { color: #fff; border-color: rgba(255,255,255,.24); background: rgba(0,0,0,.18); }
.viewer-prev { grid-column: 1; grid-row: 1; }
.viewer-next { grid-column: 3; grid-row: 1; }

@media (min-width: 561px) and (max-width: 1100px) {
  .sequence-nav { gap: 12px; }
  .sequence-link { gap: 8px; }
  .sequence-link strong { width: min(220px, 100%); }
}

@media (max-width: 900px) {
  .gallery-page, .image-page, .empty-page { width: min(100% - 36px, 720px); }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 11px; }
  .related-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
}
@media (max-width: 560px) {
  .gallery-page, .image-page, .empty-page { width: calc(100% - 24px); padding-top: 16px; }
  .site-name { margin-bottom: 20px; padding-bottom: 14px; font-size: 19px; }
  .gallery, .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .photo-card-info { min-height: 46px; padding: 9px 10px 10px; }
  .photo-card-info h2 { font-size: 11px; }
  .detail-title { font-size: 27px; }
  .sequence-nav { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; margin-top: 22px; }
  .sequence-link { gap: 7px; }
  .sequence-link strong { max-width: 110px; font-size: 10px; }
  .sequence-link small { font-size: 9px; }
  .sequence-arrow { font-size: 18px; }
  .sequence-home { font-size: 9px; }
  .related-section { padding-top: 58px; }
  .viewer { grid-template-columns: 42px minmax(0, 1fr) 42px; padding: 18px 8px; }
  .viewer-arrow { width: 34px; height: 34px; font-size: 28px; }
  .viewer-close { top: 12px; right: 13px; }
}
