:root {
  --bg: #0e1013;
  --panel: #161a20;
  --panel-2: #1c212a;
  --text: #e8ebf0;
  --muted: #8a93a3;
  --accent: #f5c542;
  --border: #262c37;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(14, 16, 19, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #15171b;
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  align-self: center;
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.brand .accent { color: var(--accent); }
.brand .tagline { color: var(--muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 560px) { .brand .tagline { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #232a35; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }

/* ---------- Source filter chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 14px 20px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: #39414f; }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #15171b;
  font-weight: 600;
}
.chip .n { opacity: 0.7; font-weight: 400; margin-left: 4px; }

/* ---------- Status line ---------- */
.status {
  padding: 10px 20px 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
}
.status.error { color: #ff8585; }
.status.ok { color: #7fd7a4; }

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  padding: 16px 20px;
  align-items: start;
}

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, border-color 0.12s;
}
.card:hover { transform: translateY(-2px); border-color: #3a4353; }
.card:hover .thumb img { transform: scale(1.03); }

.thumb {
  position: relative;
  background: #0a0c0f;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.card.broken .thumb img { display: none; }
.card.broken .thumb::after {
  content: "link only";
  color: var(--muted);
  font-size: 13px;
}
.thumb .ext {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(10, 12, 15, 0.7);
  border-radius: 6px;
  padding: 2px 6px;
}

.meta { padding: 10px 12px 12px; }
.meta .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}
.badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(245, 197, 66, 0.12);
  border: 1px solid rgba(245, 197, 66, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}
.title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta .row2 {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.meta .row2 .author { margin-left: auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Load more ---------- */
.load-more-wrap { display: flex; justify-content: center; padding: 6px 0 26px; }
.load-more-wrap.hidden { visibility: hidden; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px 28px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 900px;
  margin: 0 auto;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .muted { opacity: 0.7; }

/* ---------- Static pages (privacy) ---------- */
.page {
  max-width: 720px;
  margin: 40px auto 60px;
  padding: 0 20px;
  line-height: 1.65;
  font-size: 14.5px;
}
.page h2 { margin-top: 0; }
.page a { color: var(--accent); text-decoration: none; }
.page a:hover { text-decoration: underline; }
.page .muted { color: var(--muted); font-size: 13px; }

/* ---------- Empty state ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}
.empty .big { font-size: 42px; display: block; margin-bottom: 12px; }
