.templates-page {
  --gallery-panel: var(--brand-surface);
}

.gallery-intro {
  padding-block: clamp(38px, 5vw, 70px) clamp(22px, 3vw, 38px);
}

.gallery-intro h1 {
  max-width: 19ch;
  font-size: clamp(42px, 6vw, 84px);
  font-weight: 800;
  line-height: .98;
  letter-spacing: -.075em;
}
.gallery-intro .orange-point { color: var(--brand-accent-ink); }

@media (max-width: 360px) {
  .gallery-intro h1 { font-size: 2.25rem; overflow-wrap: anywhere; }
}

.gallery-intro p {
  margin-top: 18px;
  color: var(--muted);
  font-size: clamp(14px, 1.4vw, 17px);
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(18px, 2.5vw, 32px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gallery-filters button,
.gallery-demo select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--gallery-panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.gallery-filters button {
  padding-inline: 14px;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}

.gallery-filters button:hover {
  border-color: var(--brand-accent-ink);
}

.gallery-filters button[aria-pressed=true] {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  color: var(--brand-on-accent);
}

.gallery-filters button span {
  margin-left: 3px;
  font-size: 11px;
}

.gallery-demo {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.gallery-demo label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.gallery-demo select {
  min-width: 0;
  max-width: 100%;
  padding-inline: 12px 16px;
  cursor: pointer;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 40px) clamp(12px, 2vw, 24px);
}

.gallery-card {
  display: block;
  height: 100%;
  padding: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  transition: border-color 140ms ease-out, transform 140ms ease-out;
}

.gallery-art {
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
}

.gallery-card-caption {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 0;
}

.gallery-card-caption h2 {
  font-size: clamp(17px, 1.55vw, 23px);
  text-wrap: initial;
}

.gallery-card-caption p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.gallery-card-arrow {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.gallery-card:focus-visible .gallery-card-arrow {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  color: var(--brand-on-accent);
}

@media (hover: hover) {
  .gallery-card:hover {
    border-color: var(--brand-accent-ink);
    transform: translateY(-2px);
  }

  .gallery-card:hover .gallery-card-arrow {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
    color: var(--brand-on-accent);
  }
}

.gallery-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.gallery-about {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: clamp(30px, 5vw, 68px);
  padding-block: 28px;
  border-top: 1px solid var(--line);
}

.gallery-about h2 {
  font-size: 20px;
}

.gallery-about p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .gallery-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .gallery-demo {
    width: 100%;
  }

  .gallery-demo .mk-cmd-wrap {
    flex-basis: 100%;
  }

  .gallery-demo .mk-cmd-shell,
  .gallery-demo .mk-cmd-dropdown {
    max-width: 100%;
  }

  .gallery-demo select {
    flex: 1;
  }

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

  .gallery-filters button {
    padding-inline: 10px;
  }
}

@media (max-width: 440px) {
  .gallery-card {
    border-radius: 8px 8px 0 0;
  }

  .gallery-art {
    border-radius: 8px;
  }

  .gallery-card-caption {
    gap: 4px;
    padding: 10px 4px 6px;
  }

  .gallery-card-arrow {
    width: 22px;
    height: 22px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-card-arrow,
  .gallery-filters button {
    transition: none;
  }

  .gallery-card:hover {
    transform: none;
  }
}
