:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #16130f;
  --muted: #6d665c;
  --line: #e6e1d8;
  --accent: #7a4bd0;
  --accent-soft: #f1ebfd;
  --shadow: 0 1px 2px rgba(22, 19, 15, 0.05), 0 8px 24px rgba(22, 19, 15, 0.05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131215;
    --surface: #1c1b20;
    --ink: #f2efea;
    --muted: #a29b91;
    --line: #302e36;
    --accent: #b193f5;
    --accent-soft: #2a2337;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

/* ── hero ─────────────────────────────────────────────────────────── */
.hero {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--accent-soft), transparent);
}
.hero-inner,
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.hero-inner { padding-top: 2.6rem; padding-bottom: 2rem; }
h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  letter-spacing: -0.02em;
}
.tagline { margin: 0 0 0.75rem; max-width: 62ch; color: var(--muted); }
.tagline strong { color: var(--ink); }
.links { margin: 0; font-size: 0.9rem; color: var(--muted); display: flex; gap: 0.55rem; flex-wrap: wrap; }

/* ── boot screen ──────────────────────────────────────────────────── */
.boot { max-width: 620px; margin: 4rem auto; padding: 0 1.5rem; }
.boot-row { display: flex; align-items: center; gap: 0.7rem; font-weight: 550; }
.boot-note { color: var(--muted); font-size: 0.86rem; }
.bar {
  height: 6px;
  margin: 1rem 0 0.6rem;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: #d1435b; font-weight: 550; }

/* ── tabs ─────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel.is-active { display: block; }
.panel-help { color: var(--muted); max-width: 78ch; margin: 0 0 1.1rem; }
.count { color: var(--ink); font-weight: 600; }

/* ── search controls ──────────────────────────────────────────────── */
.searchbar { display: flex; gap: 0.6rem; margin-bottom: 0.85rem; }
input[type="search"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
input[type="search"] { flex: 1; min-width: 0; }
input[type="search"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { width: 100%; resize: vertical; }

.primary {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.15rem;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  border-radius: 99px;
  padding: 0.32rem 0.75rem;
  cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip-img { padding: 0; overflow: hidden; border-radius: 10px; width: 52px; height: 52px; }
.chip-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.filters { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.9rem; }
.filters label,
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.field { margin-bottom: 0.8rem; }

.status { color: var(--muted); font-size: 0.88rem; min-height: 1.4em; margin: 0.5rem 0 1rem; }

/* ── results grid ─────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 1rem;
}
.grid-tight { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 0.7rem; }

.card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.thumb { position: relative; aspect-ratio: 3 / 4; background: var(--accent-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.score {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(20, 16, 12, 0.72);
  padding: 0.14rem 0.4rem;
  border-radius: 6px;
  backdrop-filter: blur(3px);
}
figcaption { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.55rem 0.65rem 0.7rem; }
.title {
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sub { font-size: 0.72rem; color: var(--muted); }

/* ── two-column panels ────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 1.75rem; }
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
}

.dropzone {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  overflow: hidden;
  margin-bottom: 0.8rem;
  position: relative;
}
.dropzone:hover,
.dropzone.is-hot { border-color: var(--accent); color: var(--ink); }
.dropzone img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dropzone.has-image .dropzone-hint { display: none; }
.dropzone-hint { padding: 1rem; text-align: center; }

/* ── label bars ───────────────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 0.55rem; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 26%) 1fr auto; gap: 0.7rem; align-items: center; }
.bar-label { font-size: 0.88rem; overflow-wrap: anywhere; }
.bar-track { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar-value {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── footer ───────────────────────────────────────────────────────── */
.foot {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  max-width: 90ch;
}
