:root {
  --grad-start: #4B3FC0;
  --grad-end: #8B93E8;
  --navy: #1B2140;
  --ink: #141416;
  --muted: #8A8A8E;
  --line: #E7E6E2;
  --bg: #F5F5F3;
  --green: #1DBF73;
  --radius: 3px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
}

/* ---------- Ad slots ---------- */

.ad-slot { display: none; }
.ad-slot.has-ad { display: block; }
.ad-slot iframe { border: 0; width: 100%; display: block; margin: 0 auto; }

.ad-slot--top { background: #fff; border-bottom: 1px solid var(--line); }
.ad-slot--inline { margin: 18px 24px 0; }
.ad-slot--bottom { max-width: 1520px; margin: 28px auto 0; padding: 0 24px; }

/* ---------- Top nav ---------- */

.topnav {
  background: linear-gradient(90deg, var(--grad-start) 0%, var(--grad-end) 100%);
  padding: 20px 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.nav-pill {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 1 auto;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.nav-pill:hover { opacity: 0.9; }
.nav-pill.dark { background: var(--navy); color: #fff; }
.nav-pill.active { background: #fff; color: var(--ink); }

@media (max-width: 420px) {
  .topnav { padding: 14px 8px; gap: 6px; }
  .nav-pill { font-size: 12px; padding: 9px 12px; gap: 5px; }
}

/* ---------- Search controls ---------- */

main { max-width: 1520px; margin: 0 auto; padding: 0 24px; }

.control-card {
  background: #fff;
  border-bottom: 1px solid var(--line);
  margin: 0 -24px;
  padding: 20px 24px 22px;
}

.control-block { margin-bottom: 4px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row--wrap { margin-top: 8px; }

.chip {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #fff;
  color: #444;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.chip:hover { border-color: #bbb; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.active.is-com { background: var(--grad-start); border-color: var(--grad-start); }

.text-toggle {
  margin-top: 10px;
  background: none;
  border: none;
  padding: 0;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--grad-start);
  cursor: pointer;
}

.control-block--form {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: flex-end;
  margin-top: 20px;
}
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-group--action { margin-left: auto; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.length-row { display: flex; gap: 6px; }
.length-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.length-btn:hover { border-color: #bbb; }
.length-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }

#base-string {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  letter-spacing: 0.03em;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 140px;
}
#base-string:focus { outline: 2px solid var(--grad-start); outline-offset: 1px; }

.position-row { display: flex; gap: 6px; }
.pill-checkbox {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
}
.pill-checkbox:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill-checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 16px;
}

.btn-primary, .btn-secondary {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  border-radius: 8px;
  padding: 11px 22px;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--grad-start); color: #fff; }
.btn-primary:hover { background: #3E33A8; }
.btn-primary:disabled { background: #bcbcbc; cursor: not-allowed; }
.btn-secondary { background: var(--navy); color: #fff; padding: 13px 28px; }
.btn-secondary:hover { opacity: 0.9; }
.btn-secondary:disabled { background: #bcbcbc; cursor: not-allowed; }

.form-error {
  color: #C0392B;
  font-size: 13px;
  margin: 10px 0 0;
  min-height: 0;
}

/* ---------- Results ---------- */

.results-wrap { padding: 22px 0 10px; }

.status-line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.status-line.error { color: #C0392B; border-color: #C0392B; }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
@media (max-width: 1180px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.card { display: flex; flex-direction: column; }

.card-canvas-wrap {
  position: relative;
  aspect-ratio: 1 / 0.92;
}
.card-canvas-wrap canvas { width: 100%; height: 100%; display: block; }

.badge {
  position: absolute;
  top: 12px; right: 12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.heart {
  position: absolute;
  bottom: 0; right: 0;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  color: inherit;
  opacity: 0.8;
}
.heart:hover { opacity: 1; }
.heart.saved { color: #FF4D6D !important; opacity: 1; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}
.card-foot .dl-btn {
  background: none;
  border: none;
  color: var(--grad-start);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  padding: 0;
}

.ext-tooltip {
  position: absolute;
  inset: 0;
  background: rgba(20,20,22,0.92);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  padding: 12px;
  text-align: center;
}
.card-canvas-wrap:hover .ext-tooltip { opacity: 1; }
.ext-tooltip-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #B8B8BE;
}
.ext-tooltip-list {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ext-price { font-weight: 400; color: #B8B8BE; font-size: 12px; }

/* Saved filter: when active, hide cards that aren't hearted */
.grid.filter-saved .card:not(.is-saved) { display: none; }

.more-wrap { display: flex; justify-content: center; margin: 34px 0 44px; }

/* ---------- Footer ---------- */

.foot {
  max-width: 1520px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  border-top: 1px solid var(--line);
}
.foot p { font-size: 12.5px; color: var(--muted); max-width: 760px; margin: 0 0 20px; }
