:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #222;
  background: #fff;
  --subtle: #666;
  --border: #ececef;
  --accent: #ae443d;
  --accent-wash: #faf0ee;
  --rail-width: 264px;
  --header-height: 72px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
body:has(dialog[open]) { overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 488px) 1fr;
  align-items: center;
  gap: 24px;
  height: var(--header-height);
  padding: 0 32px;
  background: #fff;
}
.wordmark {
  width: max-content;
  font-size: 23px;
  font-weight: 740;
  letter-spacing: -.04em;
  text-decoration: none;
  white-space: nowrap;
}
.gallery-search {
  display: flex;
  min-width: 0;
  height: 44px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 24px;
  background: #f6f6f7;
}
.gallery-search:focus-within { border-color: #ccc; }
.gallery-search input { flex: 1; min-width: 0; height: 100%; padding: 0 0 0 18px; border: 0; outline: 0; background: transparent; font-size: 14px; }
.gallery-search button { display: grid; place-items: center; flex: 0 0 44px; height: 42px; border: 0; border-radius: 22px; background: transparent; }
.gallery-search button:hover { background: #eaeaec; }
.gallery-search button img { width: 18px; height: 18px; }

.sidebar { position: fixed; inset: var(--header-height) auto 0 0; width: var(--rail-width); padding: 14px 16px 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; background: #fff; }
.main-nav { display: grid; gap: 8px; }
.main-nav button, .about-trigger { display: flex; align-items: center; gap: 13px; width: 100%; padding: 0 16px; min-height: 48px; border: 0; border-radius: 28px; background: none; font-size: 15px; white-space: nowrap; text-align: start; }
.main-nav button img, .about-trigger img { width: 20px; height: 20px; }
.main-nav button[aria-pressed="true"], .main-nav button:hover, .about-trigger:hover { background: #f5f5f6; font-weight: 650; }

.gallery { margin-left: var(--rail-width); padding: 0 30px 26px; min-height: calc(100vh - var(--header-height) - 72px); }
.gallery-heading { position: sticky; top: var(--header-height); z-index: 2; display: flex; justify-content: space-between; align-items: center; min-height: 62px; gap: 10px; padding-block: 8px; background: #fff; }
.categories { display: flex; flex-wrap: wrap; gap: 6px; }
.categories button, .button {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  font-size: 14px;
}
.categories button { border-color: transparent; color: var(--subtle); }
.categories button:hover, .categories button[aria-pressed="true"] { background: #f5f5f6; color: #222; }
.categories button[aria-pressed="true"] { font-weight: 650; }
.button:hover { background: var(--accent-wash); color: var(--accent); }
.button:disabled { cursor: wait; opacity: .65; }

.photo-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: 8px; column-gap: 26px; align-items: start; list-style: none; margin: 0; padding: 0; }
.photo-link { display: block; border-radius: 16px; text-decoration: none; }
.photo-image { display: block; width: 100%; height: auto; max-height: 100%; border-radius: 16px; object-fit: cover; background: #f3f3f4; }
.photo-image[hidden] { display: none; }
.photo-link:has(.photo-image[hidden])::before { content: ""; display: block; aspect-ratio: 1; border-radius: 16px; background: #f3f3f4; }
.photo-caption { padding: 10px 9px 0; }
.photo-title { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 620; overflow-wrap: anywhere; }
.photo-link:hover .photo-title { color: var(--accent); }
.photo-author { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--subtle); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.author-avatar { display: block; width: 18px; height: 18px; flex: none; border-radius: 50%; object-fit: cover; }
.author-avatar[hidden] { display: none; }
.gallery-status { margin: 12px 0 20px; color: var(--subtle); }
.pagination { text-align: center; margin-top: 12px; }
.site-footer { margin-left: var(--rail-width); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 24px; min-height: 72px; padding: 20px; border-top: 1px solid var(--border); color: var(--subtle); font-size: 13px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

dialog { width: min(880px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: inherit; }
dialog::backdrop { background: rgb(26 33 43 / .53); }
.viewer-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 18px; color: var(--subtle); font-size: 14px; }
.close-button { border: none; border-radius: 6px; background: transparent; width: 44px; height: 44px; font-size: 27px; line-height: 1; }
.close-button:hover { background: var(--accent-wash); }
.photo-stage { display: grid; place-items: center; min-height: 160px; background: #edf0f3; text-align: center; color: var(--subtle); }
.photo-stage img { display: block; width: 100%; height: min(62dvh, 640px); object-fit: contain; }
.photo-info { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 17px 20px; }
.photo-info h2, .about h2 { margin: 0; font-size: 19px; line-height: 1.5; }
.photo-info p, .about > p { margin: 8px 0 0; color: var(--subtle); font-size: 14px; line-height: 1.6; }
.photo-info .button { flex: none; }
.share-status { margin: 0 20px 15px; color: var(--accent); font-size: 14px; }
#manual-link { width: calc(100% - 40px); margin: 0 20px 16px; padding: 8px; border: 1px solid var(--border); }
.about { width: min(480px, calc(100% - 32px)); }
.about > p { margin: 0; padding: 0 18px 22px; }

@media (max-width: 1430px) {
  :root { --rail-width: 216px; }
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 22px; }
}
@media (max-width: 1100px) {
  :root { --rail-width: 166px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 18px; }
  .gallery { padding-inline: 20px; }
}
@media (max-width: 760px) {
  :root { --rail-width: 0px; --header-height: 60px; }
  .site-header { display: flex; gap: 12px; padding: 0 14px; }
  .wordmark { font-size: 19px; }
  .gallery-search { flex: 1; height: 40px; }
  .gallery-search button { height: 38px; }
  .sidebar { position: sticky; inset: var(--header-height) 0 auto; z-index: 3; width: auto; height: 44px; padding: 0 14px; flex-direction: row; align-items: center; }
  .main-nav { display: flex; gap: 4px; }
  .main-nav button, .about-trigger { min-height: 38px; width: auto; gap: 5px; padding: 0 9px; font-size: 13px; }
  .main-nav button img, .about-trigger img { width: 16px; height: 16px; }
  .gallery { padding-inline: 12px; }
  .gallery-heading { top: calc(var(--header-height) + 44px); min-height: 54px; padding-block: 5px; }
  .categories button { min-height: 38px; padding-inline: 10px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .photo-link, .photo-image, .photo-link:has(.photo-image[hidden])::before { border-radius: 12px; }
  .photo-caption { padding: 8px 3px 0; }
  .photo-title { font-size: 14px; }
  .photo-info { flex-wrap: wrap; }
}
