:root {
  --ink: #111820;
  --muted: #5b6874;
  --line: #c9dbea;
  --paper: #ffffff;
  --wash: #eef9ff;
  --sky: #bdeff4;
  --blue: #1477b6;
  --blue-dark: #07538b;
  --cyan: #00a7e8;
  --shadow: 0 16px 45px rgba(7, 83, 139, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--sky) 0, #f8fcff 360px);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: #9ee6ef;
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 26px rgba(7, 83, 139, 0.12);
}

.brand {
  display: grid;
  place-items: center;
  width: 162px;
  height: 48px;
  padding: 7px 14px;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.brand img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.topnav {
  display: flex;
  gap: 8px;
}

.nav-button,
.ghost-button,
.link-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--paper);
  color: var(--blue-dark);
  font-weight: 700;
  cursor: pointer;
}

.topbar .nav-button {
  border-color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.72);
}

.nav-button.is-active,
.link-button {
  border-color: var(--cyan);
  background: #e7f7ff;
  box-shadow: inset 0 0 0 1px var(--cyan);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 28px;
  align-items: center;
  min-height: 520px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 670px;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 0.98;
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  width: min(100%, 640px);
  min-height: 58px;
  overflow: hidden;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.search input {
  min-width: 0;
  border: 0;
  padding: 0 18px;
  outline: 0;
  font-size: 18px;
}

.search button,
.download-button {
  border: 0;
  padding: 0 24px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 150px;
  gap: 10px;
}

.hero-grid img,
.photo-card img,
.category-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-grid button,
.photo-card,
.category-card {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #dcebf4;
  cursor: pointer;
}

.hero-grid button:first-child {
  grid-row: span 2;
}

.section {
  padding-top: 42px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#categories.is-searching .section-title {
  display: none;
}

.section-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.category-card {
  height: 132px;
  color: #fff;
  text-align: left;
}

.category-card.is-empty {
  background: linear-gradient(135deg, #0e73ad, #aeeaf2);
}

.category-card::after,
.photo-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.52));
}

.category-card span {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  font-weight: 900;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
}

.photo-grid {
  columns: 4 220px;
  column-gap: 16px;
}

.folder-view {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.folder-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.folder-head h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.photo-card {
  display: inline-grid;
  width: 100%;
  margin: 0 0 16px;
  aspect-ratio: 4 / 3;
  padding: 0;
  color: #fff;
  text-align: left;
  box-shadow: 0 1px 0 rgba(17, 24, 32, 0.08);
  break-inside: avoid;
  page-break-inside: avoid;
}

.photo-card.is-vertical {
  aspect-ratio: 3 / 4;
}

.photo-card strong {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 13px;
  z-index: 1;
  font-size: 16px;
  line-height: 1.2;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.5);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.pagination button {
  min-width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue-dark);
  font-weight: 800;
  cursor: pointer;
}

.pagination button.is-current {
  border-color: var(--cyan);
  background: #dff6ff;
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.photo-dialog {
  width: min(1180px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.3);
}

.photo-dialog::backdrop {
  background: rgba(2, 21, 36, 0.55);
}

.close-button {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.dialog-layout > img {
  width: 100%;
  height: min(78vh, 760px);
  object-fit: contain;
  background: #eef4f7;
}

.download-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: #fff;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--wash);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
}

.size-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.size-list legend {
  padding: 0 4px;
  color: var(--muted);
  font-weight: 700;
}

.size-list label {
  display: grid;
  grid-template-columns: auto 36px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.size-list label:first-of-type {
  border-top: 0;
}

.size-list span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.size-list small {
  color: var(--muted);
}

.download-button {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 8px;
  text-decoration: none;
}

.related-panel {
  padding: 18px 24px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.related-panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: 0;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.related-card {
  position: relative;
  min-height: 96px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #dcebf4;
  color: #fff;
  cursor: pointer;
}

.related-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.58));
}

.related-card img {
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
  display: block;
}

.related-card span {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  z-index: 1;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.55);
}

@media (max-width: 860px) {
  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    width: 132px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .hero-grid {
    grid-auto-rows: 116px;
  }

  .search {
    grid-template-columns: 1fr;
  }

  .search button {
    min-height: 48px;
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }

  .download-panel {
    padding: 20px;
  }

  .related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 861px) and (max-height: 820px) {
  .topbar {
    padding-block: 10px;
  }

  main {
    padding-top: 18px;
    padding-bottom: 36px;
  }

  .hero {
    min-height: 390px;
    gap: 22px;
  }

  .hero-copy {
    gap: 14px;
  }

  h1 {
    font-size: clamp(34px, 5vw, 54px);
  }

  .search {
    min-height: 52px;
  }

  .hero-grid {
    grid-auto-rows: 118px;
  }

  .section {
    padding-top: 28px;
  }

  .category-card {
    height: 116px;
  }
}

@media (min-width: 861px) and (max-height: 700px) {
  .hero {
    min-height: 330px;
  }

  .hero-grid {
    grid-auto-rows: 98px;
  }

  .eyebrow {
    font-size: 12px;
  }

  h1 {
    font-size: clamp(32px, 4.5vw, 46px);
  }

  .link-button,
  .nav-button,
  .ghost-button {
    min-height: 38px;
  }
}
