.gallery-section {
  padding-bottom: 56px;
}

.gallery-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin-top: 48px;
}

.gallery-toolbar-summary,
.gallery-toolbar-controls,
.gallery-mode-toggle,
.gallery-view-toggle {
  display: flex;
  align-items: center;
}

.gallery-toolbar-summary {
  min-width: 0;
  gap: 16px;
}

.gallery-toolbar-controls {
  flex: 0 0 auto;
  gap: 12px;
}

.gallery-mode-toggle {
  gap: 17px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.gallery-mode-button {
  display: inline-flex;
  height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  transition: color 150ms cubic-bezier(.4, 0, .2, 1), background-color 150ms cubic-bezier(.4, 0, .2, 1), box-shadow 150ms cubic-bezier(.4, 0, .2, 1);
}

.gallery-mode-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.gallery-mode-button:hover {
  color: var(--heading);
  background: var(--muted);
}

.gallery-mode-button.is-active {
  color: #fff;
  background: #0f172a;
  box-shadow: var(--shadow-sm);
}

.gallery-result-count {
  display: inline-flex;
  height: 40px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.gallery-result-count strong {
  color: var(--primary);
  font-weight: 600;
}

.gallery-view-toggle {
  gap: 4px;
}

.gallery-view-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  transition: color 150ms cubic-bezier(.4, 0, .2, 1), background-color 150ms cubic-bezier(.4, 0, .2, 1), border-color 150ms cubic-bezier(.4, 0, .2, 1);
}

.gallery-view-button:hover,
.gallery-view-button.is-active {
  background: var(--muted);
  border-color: var(--border);
}

.gallery-view-button:hover { color: var(--heading); }
.gallery-view-button.is-active { color: var(--primary); }

.gallery-view-button svg {
  width: 16px;
  height: 16px;
}

.gallery-select-field {
  position: relative;
  display: block;
  width: 140px;
  height: 40px;
}

.gallery-select-field select {
  width: 100%;
  height: 100%;
  padding: 0 34px 0 12px;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: var(--card);
  color: var(--foreground);
  font-size: 14px;
  line-height: 20px;
  transition: border-color 150ms cubic-bezier(.4, 0, .2, 1), box-shadow 150ms cubic-bezier(.4, 0, .2, 1);
}

.gallery-select-field > svg {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted-foreground);
  pointer-events: none;
  transform: translateY(-50%);
}

.gallery-mode-button:focus-visible,
.gallery-view-button:focus-visible,
.gallery-select-field select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 25%, transparent);
}

.gallery-select-field select:focus-visible {
  border-color: var(--primary);
}

.gallery-grid {
  display: flex;
  min-height: 400px;
  align-items: flex-start;
  gap: 16px;
  margin-top: 32px;
}

.gallery-column {
  display: flex;
  min-width: 0;
  flex: 1 1 0;
  flex-direction: column;
  gap: 16px;
}

.prompt-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transform: translateY(0);
  transition: transform 300ms cubic-bezier(.4, 0, .2, 1), box-shadow 300ms cubic-bezier(.4, 0, .2, 1);
}

.prompt-card-media {
  position: relative;
  overflow: hidden;
  background: var(--muted);
}

.prompt-card-image {
  width: 100%;
  height: auto;
  object-fit: cover;
  transform: scale(1);
  transition: transform 500ms cubic-bezier(.4, 0, .2, 1);
}

.prompt-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, .8), rgba(0, 0, 0, .28) 42%, transparent 72%);
  opacity: 0;
  transition: opacity 300ms cubic-bezier(.4, 0, .2, 1);
}

.prompt-card-title {
  display: -webkit-box;
  margin: 0 0 4px;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-card-author {
  margin: 0;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 16px;
}

.prompt-card-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 10px;
  backdrop-filter: blur(6px);
}

.prompt-card-badge svg {
  width: 11px;
  height: 11px;
}

@media (hover: hover) and (pointer: fine) {
  .prompt-card:hover {
    z-index: 1;
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
  }

  .prompt-card:hover .prompt-card-image {
    transform: scale(1.1);
  }

  .prompt-card:hover .prompt-card-overlay {
    opacity: 1;
  }
}

@media (hover: none), (pointer: coarse) {
  .prompt-card-overlay {
    opacity: 1;
  }
}

.gallery-grid.is-list-view {
  display: block;
}

.gallery-grid.is-list-view .gallery-column {
  gap: 12px;
}

.gallery-grid.is-list-view .prompt-card {
  display: flex;
  width: 100%;
  height: 164px;
}

.gallery-grid.is-list-view .prompt-card-media {
  width: 240px;
  flex: 0 0 240px;
}

.gallery-grid.is-list-view .prompt-card-image {
  height: 100%;
}

.gallery-grid.is-list-view .prompt-card-overlay {
  position: relative;
  flex: 1 1 auto;
  justify-content: center;
  background: var(--card);
  opacity: 1;
}

.gallery-grid.is-list-view .prompt-card-title {
  color: var(--heading);
  font-size: 16px;
  line-height: 24px;
}

.gallery-grid.is-list-view .prompt-card-author {
  color: var(--muted-foreground);
}

.gallery-grid.is-list-view .prompt-card-badge {
  top: 12px;
  bottom: auto;
}

.gallery-message {
  display: flex;
  min-height: 400px;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
}

.gallery-sentinel {
  width: 100%;
  height: 1px;
}

@media (max-width: 767px) {
  .gallery-section {
    padding-bottom: 40px;
  }

  .gallery-toolbar {
    align-items: stretch;
    flex-direction: column;
    margin-top: 32px;
  }

  .gallery-toolbar-summary {
    justify-content: space-between;
  }

  .gallery-toolbar-controls {
    width: 100%;
    flex-wrap: wrap;
    gap: 17px 12px;
    padding-top: 5px;
  }

  .gallery-view-toggle {
    width: 100%;
    justify-content: flex-end;
  }

  .gallery-select-field {
    min-width: 0;
    flex: 1 1 0;
  }

  .gallery-grid,
  .gallery-column {
    gap: 8px;
  }

  .prompt-card-overlay {
    padding: 12px;
  }

  .prompt-card-badge {
    right: 8px;
    bottom: 8px;
    padding: 4px 6px;
  }

  .gallery-grid.is-list-view .prompt-card {
    height: 128px;
  }

  .gallery-grid.is-list-view .prompt-card-media {
    width: 128px;
    flex-basis: 128px;
  }
}

@media (min-width: 768px) {
  .gallery-result-count {
    position: absolute;
    top: 3px;
    right: 396px;
  }
}

@media (max-width: 439px) {
  .gallery-view-toggle {
    flex: 0 0 auto;
  }

  .gallery-select-field select {
    padding-left: 9px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .prompt-card,
  .prompt-card-image,
  .prompt-card-overlay {
    transition-duration: .01ms;
  }
}
