:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #667085;
  --line: #d6d9df;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --soft-strong: #e7edf6;
  --accent: #116b5c;
  --accent-dark: #0b4d43;
  --focus: #0b74de;
  --shadow: 0 14px 34px rgba(31, 35, 40, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.eyebrow,
.image-card__category {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  line-height: 1.1;
}

.topbar__meta {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 78px);
}

.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  overflow: auto;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

#category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.category-button span {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--soft-strong);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.category-button:hover,
.category-button.active {
  border-color: #b5cdc8;
  background: #eaf5f2;
  color: var(--accent-dark);
}

.gallery-panel {
  min-width: 0;
  padding: 20px clamp(16px, 3vw, 34px) 44px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.search {
  display: grid;
  gap: 6px;
  width: min(520px, 100%);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 12px;
  color: var(--ink);
}

.search input:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

.ghost-button,
.image-card__actions button,
.image-card__actions a {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
  cursor: pointer;
}

.ghost-button:hover,
.image-card__actions button:hover,
.image-card__actions a:hover {
  border-color: #9bbab4;
  color: var(--accent-dark);
}

.notice {
  margin: 0 0 18px;
  border-left: 4px solid var(--accent);
  background: #ecf7f5;
  padding: 10px 12px;
  color: #32524d;
  font-weight: 700;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.image-link {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f6 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f6 75%);
  background-color: #f9fafb;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.image-card img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-card__body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.image-card h2 {
  margin: 3px 0 0;
  font-size: 1rem;
  line-height: 1.25;
}

.image-card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.image-card__actions button,
.image-card__actions a {
  display: grid;
  place-items: center;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.download-link {
  grid-column: 1 / -1;
}

.empty-state {
  margin: 40px auto;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  transform: translateY(20px);
  opacity: 0;
  border: 1px solid #9bbab4;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: var(--accent-dark);
  font-weight: 800;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #category-list {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .category-button {
    margin-bottom: 0;
  }
}

@media (max-width: 560px) {
  .controls,
  .image-card__actions {
    grid-template-columns: 1fr;
  }

  .controls {
    display: grid;
  }

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