:root {
  color-scheme: light;
  --bg: #10002b;
  --surface: #240046;
  --ink: #f7f1ff;
  --muted: #c77dff;
  --accent: #9d4edd;
  --accent-strong: #7b2cbf;
  --border: #3c096c;
  --shadow: 0 12px 30px rgba(16, 0, 43, 0.5);
  --font-display: "Space Grotesk", "Trebuchet MS", sans-serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local("Space Grotesk");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local("DM Sans");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: radial-gradient(circle at top left, #5a189a, var(--bg) 55%);
  color: var(--ink);
  overflow-y: auto;
}

.page-header {
  display: flex;
  position: sticky;
  top: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 2.5rem 1rem 2.5rem;
  z-index: 10;
  background: transparent;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.header-filters {
  display: flex;
  align-items: center;
  gap: 3rem;
  margin-left: auto;
}

.header-filters .search {
  min-width: 12rem;
}

.header-filters .search:last-child label {
  margin-left: -0.6rem;
}

.page-header .toolbar {
  margin-left: 2rem;
  padding: 0;
}

.page-header.scrolled {
  background: rgba(16, 0, 43, 0.92);
  box-shadow: 0 10px 24px rgba(16, 0, 43, 0.6);
}

.title h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);  
}

.title p {
  margin: 0;
  color: var(--muted);
  max-width: 32rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: min(18rem, 100%);
}

.search label {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.search input {
  flex: 0 0 auto;
  width: 294px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.25);
}

.search select {
  flex: 0 0 auto;
  width: 294px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.2rem) 55%, calc(100% - 0.9rem) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

.search select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.25);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 2.5rem 1rem 2.5rem;
}

.selection-info {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

#resultCount,
#selectedCount {
  display: inline-block;
  min-width: 6ch;
  text-align: right;
}

.divider {
  color: var(--border);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

button {
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(16, 0, 43, 0.6);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--accent);
  box-shadow: none;
}


main {
  padding: 1rem 2.5rem 1rem 2.5rem;
}

.page-footer {
  padding: 2rem 2.5rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.page-footer p {
  margin: 0;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

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

.icon-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.icon-card[hidden] {
  display: none;
}

.icon-card.selected {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.icon-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.icon-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.icon-download {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
}

.icon-download:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(16, 0, 43, 0.4);
}

.icon-download-mark {
  width: 16px;
  height: 16px;
  display: block;
  background: linear-gradient(var(--ink), var(--ink));
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 3a1 1 0 0 1 1 1v8.59l2.3-2.3a1 1 0 1 1 1.4 1.42l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.42l2.3 2.3V4a1 1 0 0 1 1-1z'/><path d='M4 14a1 1 0 0 1 1 1v3h14v-3a1 1 0 1 1 2 0v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1z'/></svg>");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.icon-select input {
  accent-color: var(--accent);
}

.icon-preview {
  height: 110px;
  border-radius: 14px;
  background: #2a064f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-preview img {
  width: 80px;
  height: 80px;
}

.icon-meta {
  display: grid;
  gap: 0.35rem;
}

.icon-name {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-word;
}

.icon-tags {
  font-size: 0.75rem;
  color: var(--muted);
}

.tag {
  display: inline-block;
  background: #3c096c;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

@media (max-width: 640px) {
  .page-header {
    padding: 2rem 1.25rem 1rem;
  }

  .toolbar {
    padding: 0 1.25rem 1.25rem;
  }

  main {
    padding: 0 1.25rem 2.5rem;
  }
}
