:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1b2740;
  --line: #243049;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-ink: #08233a;
  --ok: #34d399;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0e1729, var(--bg));
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand h1 { margin: 0; font-size: 1.25rem; color: var(--accent); }
.brand p { margin: 0.15rem 0 0; font-size: 0.85rem; }

.folder { display: flex; align-items: center; gap: 0.6rem; }
.folder-status { font-size: 0.82rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-status.set { color: var(--ok); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: default; }

.banner {
  margin: 0;
  padding: 0.7rem 1.5rem;
  background: #3b2a12;
  color: #fde68a;
  font-size: 0.85rem;
  border-bottom: 1px solid #5a4318;
}

.toolbar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
}
#search {
  flex: 1 1 16rem;
  min-width: 12rem;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.result-count { padding: 0 1.5rem; margin: 0.2rem 0 0.6rem; font-size: 0.82rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-thumb {
  aspect-ratio: 16 / 10;
  background: #0a1322 center/contain no-repeat;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-thumb .ph { color: var(--muted); font-size: 0.75rem; }
.card-body { padding: 0.7rem 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.card-title { font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.card-title:hover { color: var(--accent); }
.badges { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.badge { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; padding: 0.12rem 0.4rem; border-radius: 5px; background: var(--panel-2); color: var(--muted); }
.card-meta { font-size: 0.78rem; color: var(--muted); margin-top: auto; }
.card-actions { display: flex; gap: 0.5rem; }
.card-actions .btn { flex: 1; text-align: center; text-decoration: none; }
.dl { line-height: 1.6; }

.more { display: grid; place-items: center; padding: 1rem 0 2.5rem; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 20;
  max-width: 90vw;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: #f87171; color: #fecaca; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.7);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 30;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 1.4rem;
  position: relative;
}
.modal-close { position: absolute; top: 0.6rem; right: 0.8rem; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.detail-thumb { width: 100%; max-height: 260px; object-fit: contain; background: #0a1322; border-radius: 10px; border: 1px solid var(--line); }
.detail-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.6rem 0; }
.versions { width: 100%; border-collapse: collapse; margin-top: 0.6rem; font-size: 0.82rem; }
.versions th, .versions td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--line); }
