/* ==========================================================================
   Pirate Search — shadcn/ui-style design system (vanilla CSS)
   System theme: light/dark follows prefers-color-scheme
   Font: Manrope
   ========================================================================== */

:root {
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 0.5rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --font-display: "Archivo", sans-serif;

  /* shadcn/ui neutral tokens — light */
  --background: oklch(0.985 0.008 65);
  --foreground: oklch(0.145 0.008 65);
  --card: oklch(0.985 0.008 65);
  --card-foreground: oklch(0.145 0.008 65);
  --popover: oklch(0.985 0.008 65);
  --popover-foreground: oklch(0.145 0.008 65);
  --primary: oklch(0.49 0.16 38);
  --primary-foreground: oklch(0.985 0.008 65);
  --secondary: oklch(0.97 0.008 65);
  --secondary-foreground: oklch(0.205 0.008 65);
  --muted: oklch(0.97 0.008 65);
  --muted-foreground: oklch(0.47 0.015 65);
  --accent: oklch(0.97 0.008 65);
  --accent-foreground: oklch(0.205 0.008 65);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0.008 65);
  --input: oklch(0.922 0.008 65);
  --ring: oklch(0.708 0.008 65);

  /* semantic */
  --seed: oklch(0.627 0.194 149.214);
  --seed-contrast: #fff;
  --leech: oklch(0.577 0.245 27.325);
  --gold: oklch(0.681 0.162 75.834);

  --shadow-pop: 0 10px 30px rgb(0 0 0 / 0.14), 0 2px 8px rgb(0 0 0 / 0.08);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --background: oklch(0.145 0.008 65);
  --foreground: oklch(0.985 0.008 65);
  --card: oklch(0.205 0.008 65);
  --card-foreground: oklch(0.985 0.008 65);
  --popover: oklch(0.205 0.008 65);
  --popover-foreground: oklch(0.985 0.008 65);
  --primary: oklch(0.78 0.14 55);
  --primary-foreground: oklch(0.205 0.008 65);
  --secondary: oklch(0.269 0.008 65);
  --secondary-foreground: oklch(0.985 0.008 65);
  --muted: oklch(0.269 0.008 65);
  --muted-foreground: oklch(0.708 0.008 65);
  --accent: oklch(0.269 0.008 65);
  --accent-foreground: oklch(0.985 0.008 65);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 12%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0.008 65);

  --seed: oklch(0.723 0.219 149.579);
  --seed-contrast: oklch(0.204 0.05 155);
  --leech: oklch(0.704 0.191 22.216);
  --gold: oklch(0.795 0.184 86.047);

  --shadow-pop: 0 10px 30px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.35);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.145 0.008 65);
    --foreground: oklch(0.985 0.008 65);
    --card: oklch(0.205 0.008 65);
    --card-foreground: oklch(0.985 0.008 65);
    --popover: oklch(0.205 0.008 65);
    --popover-foreground: oklch(0.985 0.008 65);
    --primary: oklch(0.78 0.14 55);
    --primary-foreground: oklch(0.205 0.008 65);
    --secondary: oklch(0.269 0.008 65);
    --secondary-foreground: oklch(0.985 0.008 65);
    --muted: oklch(0.269 0.008 65);
    --muted-foreground: oklch(0.708 0.008 65);
    --accent: oklch(0.269 0.008 65);
    --accent-foreground: oklch(0.985 0.008 65);
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 12%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.556 0.008 65);

    --seed: oklch(0.723 0.219 149.579);
    --seed-contrast: oklch(0.204 0.05 155);
    --leech: oklch(0.704 0.191 22.216);
    --gold: oklch(0.795 0.184 86.047);

    --shadow-pop: 0 10px 30px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.35);

    color-scheme: dark;
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

/* the [hidden] attribute must always win over any display: flex/grid rules */
[hidden] { display: none !important; }

/* Google-style centered homepage (animates to top once a search starts) */
.shell.centered { min-height: 100dvh; }

.hero { transition: none; }

.shell.centered .hero {
  margin-top: clamp(48px, calc(50dvh - 215px), 45vh);
}

.shell.centered .footer { display: none; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.shell {
  position: relative;
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 20px 60px;
}

::selection { background: color-mix(in oklab, var(--primary) 20%, transparent); }

/* ==========================================================================
   shadcn/ui components
   ========================================================================== */

/* ---------- Button ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 45%, transparent);
}

.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 88%, var(--primary-foreground)); }

.btn-outline {
  background: var(--background);
  border-color: var(--border);
  color: var(--foreground);
}
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in oklab, var(--secondary) 80%, var(--foreground)); }

.btn-success { background: var(--seed); color: var(--seed-contrast); }
.btn-success:hover { background: color-mix(in oklab, var(--seed) 85%, #000); }

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-lg { height: 2.75rem; padding: 0 1.5rem; font-size: 0.9375rem; border-radius: calc(var(--radius) - 2px); }

.btn .icon { width: 0.9375rem; height: 0.9375rem; flex-shrink: 0; }
.btn .chevron { width: 0.875rem; height: 0.875rem; transition: transform 0.15s; }
.btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* button-busy spinner */
.btn .btn-spinner {
  width: 0.875rem;
  height: 0.875rem;
  border-width: 2px;
  border-color: color-mix(in oklab, currentColor 30%, transparent);
  border-top-color: currentColor;
  margin-right: 0;
  vertical-align: middle;
}

.copy-btn.copied {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

/* ---------- Input ---------- */

.input {
  height: 2.5rem;
  padding: 0 0.875rem;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder { color: var(--muted-foreground); }

.input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
}

.input-sm { height: 2rem; font-size: 0.8125rem; padding: 0 0.75rem; }
.input-hero { height: 2.75rem; font-size: 1rem; }

/* ---------- Select (dropdown) ---------- */

.select { position: relative; }

.select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 9.5rem;
  height: 2rem;
  padding: 0 0.625rem 0 0.75rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
}

.select-trigger .chevron {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--muted-foreground);
  transition: transform 0.15s;
}

.select-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.select-content {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  z-index: 50;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.25rem;
  box-shadow: var(--shadow-pop);
}

.select-item {
  display: flex;
  width: 100%;
  align-items: center;
  padding: 0.3125rem 0.5rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.select-item:hover,
.select-item:focus-visible {
  background: var(--accent);
  color: var(--accent-foreground);
  outline: none;
}

.select-item[aria-selected="true"] { font-weight: 600; }

/* ---------- Card ---------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(8px);
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--popover-foreground);
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   App layout
   ========================================================================== */

/* ---------- header ---------- */

.hero { text-align: center; margin-bottom: 30px; }

.hero h1 {
  margin: 0 0 6px;
  font-size: 2.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}


.searchbar {
  display: flex;
  gap: 0.625rem;
  max-width: 620px;
  margin: 28px auto 0;
}

.searchbar .input { flex: 1; }

/* ---------- status ---------- */

.status {
  text-align: center;
  padding: 28px 20px;
  color: var(--muted-foreground);
  font-size: 0.95rem;
}

.status.error { color: var(--destructive); }

.spinner {
  display: inline-block;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--border);
  border-top-color: var(--muted-foreground);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -4px;
  margin-right: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 16px;
}

.toolbar-field { display: flex; align-items: center; gap: 0.5rem; }
.toolbar-label { color: var(--muted-foreground); font-size: 0.8125rem; }

#name-filter { width: 11rem; }

/* ---------- results ---------- */

.results { display: flex; flex-direction: column; gap: 0.625rem; }

.result {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 0.875rem 1rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.result:hover {
  border-color: color-mix(in oklab, var(--foreground) 25%, var(--border));
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.06);
}

.result-main { min-width: 0; }

.result-name {
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.result-name .trusted { color: var(--gold); }

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 7px;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

.result-meta .seed { color: var(--seed); font-weight: 700; }
.result-meta .leech { color: var(--leech); font-weight: 700; }
.result-meta .trusted { color: var(--gold); }

/* ---------- result actions + download menu ---------- */

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.result-actions .btn { flex: 0 0 auto; }

.dl-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn.copied,
.copy-dl-btn.copied {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.dl-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: min(24rem, calc(100vw - 32px));
  max-height: 18rem;
  overflow-y: auto;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0;
  box-shadow: var(--shadow-pop);
}

.dl-menu-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--popover);
  border-bottom: 1px solid var(--border);
}

.dl-menu-count { font-size: 0.75rem; color: var(--muted-foreground); padding-left: 2px; }

.btn-xs { height: 1.625rem; padding: 0 0.625rem; font-size: 0.75rem; gap: 0.375rem; }
.btn-xs .icon { width: 0.75rem; height: 0.75rem; }

.dl-item-row {
  padding-inline: 4px;
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.dl-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.5rem;
  font-size: 0.8125rem;
  color: inherit;
  text-decoration: none;
  border-radius: calc(var(--radius) - 6px);
  transition: background 0.1s;
}

.dl-item-copy {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.dl-item-copy svg { width: 0.875rem; height: 0.875rem; }
.dl-item-copy:hover { background: var(--accent); color: var(--accent-foreground); }
.dl-item-copy.copied { color: var(--seed); }

.dl-item .icon { width: 0.875rem; height: 0.875rem; color: var(--seed); flex-shrink: 0; }

.dl-item:hover { background: var(--accent); color: var(--accent-foreground); }

.dl-item-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dl-more {
  padding: 0.3125rem 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.cat-badge {
  padding: 1px 9px;
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- pagination ---------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
  margin-top: 26px;
}

.pagination .select-trigger { min-width: 0; }

#page-indicator {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  min-width: 70px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- footer ---------- */

.footer {
  margin-top: 48px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  opacity: 0.75;
}

/* ---------- homepage ---------- */

.home {
  text-align: center;
  margin-top: 26px;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) 0.05s backwards;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.feature-pill {
  padding: 5px 14px;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.home-hint {
  margin: 26px 0 10px;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip-btn {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.chip-btn:hover {
  border-color: var(--ring);
  background: var(--accent);
  color: var(--accent-foreground);
  transform: translateY(-1px);
}

.chip-btn:active { transform: scale(0.96); }

/* ---------- theme toggle ---------- */

.theme-select {
  position: absolute;
  top: 28px;
  right: 20px;
  z-index: 70;
}

/* ---------- bookmarks ---------- */

.bm-toggle {
  position: absolute;
  top: 28px;
  left: 20px;
  z-index: 70;
}

.bm-toggle.active {
  border-color: color-mix(in oklab, var(--gold) 55%, transparent);
  color: var(--gold);
}

.bm-btn { padding: 0 0.7rem; flex: 0 0 auto !important; }
.bm-btn svg { width: 1rem; height: 1rem; }
.bm-btn.saved {
  color: var(--gold);
  border-color: color-mix(in oklab, var(--gold) 50%, transparent);
  background: color-mix(in oklab, var(--gold) 8%, transparent);
}
.bm-btn.saved svg { fill: var(--gold); stroke: var(--gold); }

.empty-note { text-align: center; color: var(--muted-foreground); padding: 34px 0; }

.bm-back { margin-bottom: 14px; }

.theme-trigger {
  width: 2.25rem;
  min-width: 0;
  padding: 0;
  justify-content: center;
}

#theme-icon, .theme-item-icon { display: inline-flex; }
#theme-icon svg, .theme-item-icon svg { width: 1rem; height: 1rem; }
.theme-item-icon { margin-right: 0.5rem; color: var(--muted-foreground); }

/* ---------- animations ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.hero { animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }

.toolbar, .pagination { animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) 0.08s backwards; }

/* staggered result entrance */
.result {
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.25s;
}

/* Hover highlights the row without moving it toward adjacent results. */

/* Keep an open download menu above neighboring rows. */
.result:has(.dl-menu:not([hidden])) {
  position: relative;
  z-index: 100;
}

.result:nth-child(1) { animation-delay: 0.02s; }
.result:nth-child(2) { animation-delay: 0.05s; }
.result:nth-child(3) { animation-delay: 0.08s; }
.result:nth-child(4) { animation-delay: 0.11s; }
.result:nth-child(5) { animation-delay: 0.14s; }
.result:nth-child(6) { animation-delay: 0.17s; }
.result:nth-child(7) { animation-delay: 0.20s; }
.result:nth-child(8) { animation-delay: 0.23s; }
.result:nth-child(9) { animation-delay: 0.26s; }
.result:nth-child(10) { animation-delay: 0.29s; }

/* dropdown + download menus pop in when opened */
.select-content, .dl-menu { animation: menu-in 0.16s ease; }

/* press feedback */
.btn:active, .chip-btn:active { transform: scale(0.96); }

/* smooth theme switch */
body { transition: background-color 0.25s ease, color 0.25s ease; }

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .shell {
    padding: max(28px, env(safe-area-inset-top)) 14px 40px;
  }

  .hero h1 { font-size: 1.7rem; }

  /* toolbar: one full-width row per control */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-field { width: 100%; }
  .toolbar-field .select, .toolbar-field .select-trigger { flex: 1; width: 100%; min-width: 0; }
  .toolbar-field .input { flex: 1; width: auto; }
  #name-filter { width: auto; }

  .pagination { flex-wrap: wrap; gap: 10px; }
  .theme-select { top: 18px; right: 14px; }
  .bm-toggle { top: 18px; left: 14px; padding: 0 0.7rem; }
  .bm-toggle #bm-count { display: none; }
}

/* Editorial search identity and shared finishing details. */
.shell { max-width: 1040px; padding: 112px 32px 48px; }
.shell.centered .hero { margin-top: clamp(48px, calc(36dvh - 112px), 240px); }
.hero { margin-bottom: var(--space-xl); }


.hero h1 { font-family: var(--font-display); font-size: clamp(2.5rem, 6.6vw, 4.75rem); line-height: 1.05; font-weight: 800; letter-spacing: -.065em; margin-bottom: 20px; }
.wordmark-dot { color: var(--primary); }

.searchbar { max-width: 720px; margin-top: 36px; gap: 8px; padding: 8px; border: 1px solid var(--input); border-radius: 12px; background: var(--card); }
.searchbar:focus-within { border-color: var(--primary); outline: 3px solid color-mix(in oklch, var(--primary) 15%, transparent); }
.searchbar .input { min-width: 0; height: 48px; border: 0; box-shadow: none; background: transparent; }
.searchbar .btn { height: 48px; padding-inline: 28px; font-weight: 700; }
.feature-row { gap: 12px 24px; }
.feature-pill { border: 0; background: transparent; padding: 0; font-size: .8125rem; }
.feature-pill > span { color: var(--primary); font-size: .6875rem; font-weight: 800; margin-right: 6px; }
.bm-toggle, .theme-select { top: 28px; }
.bm-toggle { left: 32px; border-color: transparent; background: transparent; }
.theme-select { right: 32px; }
#bm-count { background: var(--muted); min-width: 24px; padding: 2px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.theme-trigger { width: 44px; height: 44px; border-color: transparent; background: transparent; }
.theme-select .select-content { right: 0; left: auto; min-width: 160px; }
.select-item { min-height: 40px; }
.select-item[aria-checked="true"] { font-weight: 700; background: var(--accent); }
.btn, .select-trigger { min-height: 40px; }
.btn:focus-visible, .select-trigger:focus-visible, a:focus-visible, .select-item:focus-visible, .dl-item-copy:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.toolbar { padding-block: 16px; border-block: 1px solid var(--border); margin-top: 40px; margin-bottom: 0; }
.input-sm { height: 40px; }
.results { gap: 0; }
.result { padding: 24px 8px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; gap: 16px; animation: rise .35s cubic-bezier(.16, 1, .3, 1) backwards; }
.result:hover { box-shadow: none; border-color: var(--border); background: color-mix(in oklch, var(--muted) 35%, transparent); }
.result-name { font-size: 1rem; line-height: 1.6; }
.result-meta { gap: 8px 16px; font-size: .8125rem; }
.result-actions { border: 0; padding: 0; }
.cat-badge { border: 0; border-radius: 4px; font-size: .75rem; padding: 2px 8px; }
.dl-wrap { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.dl-menu { right: auto; left: 0; }
.toast { max-width: min(560px, calc(100vw - 32px)); width: max-content; text-align: center; }
.footer { opacity: 1; font-size: .8125rem; }
.shell.centered .footer { display: block; margin-top: 80px; }
.empty-note { padding: 48px 16px; line-height: 1.7; }
@media (max-width: 560px) {
  .shell { padding: 96px 20px 32px; }
  .shell.centered .hero { margin-top: clamp(48px, 10dvh, 100px); }
  .hero h1 { font-size: clamp(2.25rem, 10vw, 3.5rem); }

  .bm-toggle { left: 16px; }
  .theme-select { right: 16px; }
  .bm-toggle #bm-count { display: inline-block; }
  .searchbar { padding: 6px; gap: 4px; margin-top: 28px; }
  .searchbar .input { padding-inline: 10px; }
  .searchbar .btn { padding-inline: 16px; font-size: .875rem; }
  .feature-row { flex-direction: column; gap: 12px; align-items: center; }
  .feature-pill, .result-meta, .cat-badge, .toolbar-label, .input-sm, .select-trigger, .select-item, .btn-sm, #page-indicator, .footer { font-size: .875rem; }
  .btn, .select-trigger, .select-item, .dl-item, .dl-item-copy, .dl-item-play { min-height: 44px; }
  .bm-btn, .dl-item-copy, .dl-item-play { min-width: 44px; }
  .toolbar-field .toolbar-label { min-width: 44px; }
  .result { padding-inline: 0; }
  .result-actions { gap: 8px; }
  .dl-wrap { position: static; }
  .result { position: relative; }
  .dl-menu { left: 0; right: 0; width: 100%; }
  .pagination { gap: 12px; }
  #page-indicator { order: -1; width: 100%; }
}

/* Keep the original lively entrances without animating layout. */
.searchbar { transition: border-color .2s, outline-color .2s, box-shadow .2s; }
.feature-pill { animation: rise .45s cubic-bezier(.16, 1, .3, 1) backwards; }
.feature-pill:nth-child(1) { animation-delay: .12s; }
.feature-pill:nth-child(2) { animation-delay: .2s; }
.feature-pill:nth-child(3) { animation-delay: .28s; }
.result:nth-child(n+11) { animation-delay: .29s; }
@media (prefers-reduced-motion: reduce) {
  .btn:active, .chip-btn:active { transform: none; }
}

/* Autocomplete stays anchored to the search field without shifting results. */
.searchbar { position: relative; }
.hero:has(.suggestion-panel:not([hidden])) { position: relative; z-index: 110; }
.suggestion-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  z-index: 110;
  text-align: left;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: menu-in .16s ease-out;
}
#search-suggestions { list-style: none; margin: 0; padding: 6px; max-height: min(360px, 42dvh); overflow-y: auto; overscroll-behavior: contain; }
#search-suggestions [role="option"] { padding: 12px; min-height: 44px; border-radius: 5px; font-size: .9375rem; line-height: 1.5; cursor: pointer; overflow-wrap: anywhere; }
#search-suggestions [role="option"]:hover,
#search-suggestions [aria-selected="true"] { background: var(--accent); }
#search-suggestions strong { font-weight: 800; }

/* Mobile fields share a baseline and avoid focus zoom on iOS. */
@media (max-width: 560px) {
  .toolbar-field .input { min-height: 44px; font-size: 1rem; min-width: 0; }
  #search-suggestions [role="option"] { font-size: 1rem; }
  .shell { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .result-actions .dl-wrap { flex-basis: 100%; }
  .result-actions .dl-wrap > .btn { flex: 1 1 auto; }
}
@media (pointer: coarse) and (min-width: 561px) {
  .btn, .select-trigger, .select-item, .dl-item, .dl-item-copy, .dl-item-play { min-height: 44px; }
  .input { min-height: 44px; font-size: 1rem; }
}

/* Compact action groups retain distinct touch targets. */
.dl-item-row {
  display: grid;
  --file-action-size: 32px;
  grid-template-columns: minmax(0, 1fr) repeat(3, var(--file-action-size));
  align-items: center;
  gap: 0;
  padding: 2px 8px;
}
.dl-item-row + .dl-item-row { border-top: 1px solid var(--border); }
.dl-item { grid-column: 1; min-height: 32px; padding: 4px; }
.dl-item-download, .dl-item-play, .dl-item-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--foreground);
  text-decoration: none;
  cursor: pointer;
}
.dl-item-download { grid-column: 2; }
.dl-item-play { grid-column: 3; }
.dl-item-copy { grid-column: 4; }
.dl-item-download svg, .dl-item-play svg, .dl-item-copy svg { width: 16px !important; height: 16px !important; flex-shrink: 0; }
.dl-item-download:hover, .dl-item-play:hover, .dl-item-copy:hover { background: var(--accent); color: var(--accent-foreground); }
.dl-item-download:active, .dl-item-play:active, .dl-item-copy:active { background: var(--muted); }
.dl-menu-head .download-all-btn { min-height: 32px; }

/* Filenames are text; downloads require the explicit action on the right. */
.dl-item:hover { background: transparent; color: inherit; }
@media (max-width: 560px) {
  .dl-item-row { row-gap: 0; padding: 4px 8px; }
  .dl-item { grid-column: 1 / -1; min-height: 0; padding: 0 0 4px; }
  .dl-item-name { white-space: normal; overflow-wrap: anywhere; font-size: .875rem; }
  .dl-item-download, .dl-item-play, .dl-item-copy { grid-row: 2; }
}

@media (max-width: 560px), (pointer: coarse) {
  .dl-item-row { --file-action-size: 44px; }
  .dl-item-download, .dl-item-play, .dl-item-copy { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .dl-menu-head .download-all-btn { min-height: 44px; }
}

.dl-item-row:not(:has(.dl-item-play)) {
  grid-template-columns: minmax(0, 1fr) repeat(2, var(--file-action-size));
}
.dl-item-row:not(:has(.dl-item-play)) .dl-item-copy { grid-column: 3; }

.search-empty { padding: 48px 16px; text-align: center; border-top: 1px solid var(--border); }
.search-empty h2 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; letter-spacing: -.03em; }
.search-empty p { max-width: 44ch; margin: 12px auto 24px; color: var(--muted-foreground); overflow-wrap: anywhere; }

.empty-icon { display: block; width: 40px; height: 40px; margin: 0 auto 16px; color: var(--muted-foreground); }
