:root {
  --ink: #182430;
  --muted: #5c6b7a;
  --faint: #9aa4b2;
  --bg: #f7f9fa;
  --surface: #ffffff;
  --line: #e3e8ed;
  --accent: #0d7a6c;
  --accent-hover: #0a5f55;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 16.5px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.brand-sub {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  border-left: 1px solid var(--line); padding-left: 8px; margin-left: 2px;
}

.topnav { display: flex; gap: 18px; font-size: 14px; font-weight: 600; }
.topnav a { color: var(--muted); transition: color .15s ease; }
.topnav a:hover { color: var(--accent); text-decoration: none; }

/* ---------- ads ---------- */
.ad-wrap { display: flex; justify-content: center; padding: 8px 14px; background: #eef2f4; }
.ad-slot { max-width: 970px; width: 100%; text-align: center; min-height: 40px; }

.ad-placeholder {
  border: 1px dashed #ccd5dc; border-radius: var(--radius); min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 12px; letter-spacing: .06em;
}

/* ---------- hero / search ---------- */
.hero { max-width: 970px; margin: 0 auto; padding: 34px 20px 6px; }

.hero h1 { font-size: 26px; line-height: 1.3; letter-spacing: -0.02em; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 15.5px; margin: 0 0 18px; line-height: 1.6; max-width: 62ch; }

.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid #d4dde3; border-radius: 12px;
  padding: 13px 16px; transition: border-color .15s ease, box-shadow .15s ease;
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,122,108,.12); }

.searchbar input {
  flex: 1; border: none; outline: none; font: inherit; font-size: 15.5px; background: transparent; color: var(--ink); min-width: 0;
}

.controls { display: flex; align-items: center; gap: 18px; margin-top: 14px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.controls label { display: flex; align-items: center; gap: 7px; font-weight: 600; }

select {
  padding: 6px 10px; border-radius: 8px; border: 1px solid #d4dde3; background: var(--surface); font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
}

.stats { margin-left: auto; color: var(--faint); font-size: 13.5px; }

/* ---------- results ---------- */
.results { max-width: 970px; margin: 0 auto; padding: 16px 20px 8px; display: grid; gap: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: #c3cedb; }

.card-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.repo-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.repo-name a { color: inherit; }
.repo-name a:hover { color: var(--accent); text-decoration: none; }

.badge {
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #eef4f3; color: #3d5a55; white-space: nowrap;
}
.badge.lang::before { content: "● "; }

.stars { font-size: 13.5px; color: var(--faint); white-space: nowrap; }

.desc { margin: 8px 0 10px; color: var(--muted); font-size: 14.5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.release-meta { font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.release-meta b { color: #1d6b4f; font-weight: 700; }

.assets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.dl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff !important; border-radius: 8px; padding: 8px 13px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; max-width: 100%;
  transition: background .15s ease, transform .1s ease;
}
.dl-btn:hover { background: var(--accent-hover); text-decoration: none !important; }
.dl-btn:active { transform: scale(.98); }
.dl-btn .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

.gh-link { font-size: 13px; color: var(--faint); margin-left: auto; white-space: nowrap; }
.gh-link:hover { color: var(--accent); }

.empty, .loading { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; font-size: 15px; line-height: 1.6; }
.loading { color: var(--faint); }

.live-hint { max-width: 970px; margin: 6px auto 0; padding: 0 20px; font-size: 14px; color: var(--muted); }
.muted { color: var(--faint); font-size: 13px; }

.btn-ghost {
  background: none; border: 1.5px solid #cdd6e4; color: var(--accent); border-radius: 8px;
  padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn-ghost:hover { background: #eef4f3; border-color: var(--accent); }

/* ---------- content / footer ---------- */
.content-section { max-width: 970px; margin: 26px auto 0; padding: 24px 20px; color: #3c4658; line-height: 1.65; font-size: 15px; }
.content-section h2 { font-size: 19px; letter-spacing: -0.01em; margin-top: 22px; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 30px; padding-bottom: 18px; }
.foot-note, .foot-copy { text-align: center; font-size: 13px; color: var(--muted); margin: 10px auto; max-width: 970px; padding: 0 16px; }

/* ---------- interstitial overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 32, .72); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

/* the interstitial is toggled via the `hidden` attribute — make sure that truly
   hides it (author `.overlay{display:flex}` would otherwise override [hidden]) */
.overlay[hidden] { display: none; }

.overlay-card {
  position: relative; background: var(--surface); border-radius: 14px; max-width: 560px; width: 100%;
  padding: 28px 24px 26px; text-align: center; box-shadow: 0 24px 64px rgba(10, 20, 30, .35);
}

.close-x {
  position: absolute; top: 10px; right: 14px; background: none; border: none;
  font-size: 26px; color: var(--faint); cursor: pointer; line-height: 1; padding: 4px;
  z-index: 2147483647; /* stay above any full-viewport layer an ad script injects */
}
.close-x:hover { color: var(--ink); }

/* sandbox the ad slot: transform makes this box the containing block for
   position:fixed descendants, so a network's full-screen interstitial layer
   is clipped to the slot instead of covering our close button and backdrop */
.il-ad { min-height: 250px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; position: relative; overflow: hidden; transform: translateZ(0); }
.il-ad .ad-placeholder { width: 100%; min-height: 250px; }

.il-text { color: var(--muted); font-size: 15px; margin: 0 0 14px; }

.btn-primary {
  background: #1d6b4f; color: #fff; border: none; border-radius: 10px;
  padding: 13px 34px; font: inherit; font-size: 15.5px; font-weight: 700; cursor: pointer; min-width: 240px;
  transition: background .15s ease, transform .1s ease;
}
.btn-primary:hover:not(:disabled) { background: #16543f; }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { background: #b9c2d0; cursor: not-allowed; }

@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  .stats { margin-left: 0; width: 100%; }
  .gh-link { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- Full-width layout toggle (ui.js adds body.fullwidth) ---- */
.fw-toggle { display:inline-flex; align-items:center; gap:6px; font:inherit; font-size:13px; font-weight:700; color:#5c6b7a; background:#f2f5f7; border:1px solid #e3e8ed; border-radius:8px; padding:5px 11px; cursor:pointer; white-space:nowrap; transition:color .15s ease,background .15s ease,border-color .15s ease; }
.fw-toggle:hover { color:#0d7a6c; border-color:#0d7a6c; background:#eef4f3; text-decoration:none; }
.fw-toggle[aria-pressed="true"] { color:#fff; background:#0d7a6c; border-color:#0d7a6c; }
body.fullwidth .hero, body.fullwidth .results, body.fullwidth .content-section, body.fullwidth .live-hint, body.fullwidth .foot-note, body.fullwidth .foot-copy { max-width:none; padding-left:clamp(20px,4vw,72px); padding-right:clamp(20px,4vw,72px); }
@media (max-width:560px){ .fw-toggle .fw-lbl{display:none;} .fw-toggle{padding:5px 8px;} }
