:root {
  --bg: #f4f5f7;
  --bg-soft: #e9ebef;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --border: #e1e4e8;
  --border-soft: #ebedf0;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #5753d8;
  --accent-2: #7c6cf0;
  --star: #e0a000;
  --green: #2da44e;
  --radius: 12px;
  --maxw: 1320px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 22px 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 34px; line-height: 1;
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.kicker { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 1px; }
.header-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.guide-link { background: var(--panel-2); border-color: var(--border); }
.guide-link:hover { border-color: var(--accent); color: var(--accent); }

/* Reserve height so JS-filled stats don't shove the header when they pop in (CLS). */
.stats { display: flex; gap: 14px; flex-wrap: wrap; align-content: flex-start; min-height: 62px; }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 14px; min-width: 92px; text-align: center;
}
.stat .num { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Toolbar */
.toolbar { position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border-soft);
}
.toolbar-inner { display: flex; gap: 14px; align-items: center; padding: 12px 20px; flex-wrap: wrap; }
#search {
  flex: 1 1 320px; min-width: 220px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(87, 83, 216, 0.18); }
.controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.select { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.select select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px; font-size: 13px;
}
.check { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* Chips */
.chips { border-bottom: 1px solid var(--border-soft); }
/* Reserve the chip row so category chips don't push the board down when filled (CLS). */
.chips-inner { display: flex; gap: 8px; padding: 12px 20px; flex-wrap: wrap; align-content: flex-start; min-height: 55px; }
.chip {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  display: inline-flex; gap: 7px; align-items: center; transition: all 0.12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Fixed-width count so a daily count change (25→9→125) can't re-wrap the row (CLS). */
.chip .c { opacity: 0.7; font-variant-numeric: tabular-nums; display: inline-block; min-width: 2.4ch; text-align: right; }
.chip.active .c { opacity: 0.9; }

/* Board */
main.wrap { padding-top: 24px; padding-bottom: 60px; }
/* Reserve the board's vertical space up front so the "Loading…" → full-grid swap
   (the dominant CLS source, 0.888) doesn't reflow the page. */
#board { min-height: 100vh; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

.category { margin-bottom: 26px; scroll-margin-top: 120px; }
.cat-head {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.cat-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.cat-head .count {
  font-size: 12px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px;
}
.cat-head .desc { color: var(--muted); font-size: 12.5px; }
.cat-head { margin-bottom: 8px; }
.cat-when {
  margin: 0 0 14px; color: #57606a; font-size: 13.5px; line-height: 1.5; max-width: 96ch;
}
.cat-when .tag {
  display: inline-block; margin-right: 9px; color: #5753d8;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  border: 1px solid rgba(87, 83, 216, 0.4); background: rgba(87, 83, 216, 0.1);
  border-radius: 5px; padding: 2px 7px; vertical-align: middle;
}
/* HackerNews signal badge */
.hn {
  color: #ff8c42; font-variant-numeric: tabular-nums; font-weight: 600;
}
.card .meta .hn::before, .detail-grid .hn::before { content: ""; }
.site-footer .hn { font-weight: 700; }
/* Hugging Face model cards */
.card .avatar.hf-avatar { display: grid; place-items: center; font-size: 20px; background: var(--bg-soft); }
.badge-tier.hf-badge { background: rgba(255, 170, 0, 0.14); color: #b07000; border: 1px solid rgba(255, 170, 0, 0.42); }
.card .meta .dl { color: var(--muted); font-variant-numeric: tabular-nums; }

.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; position: relative;
  display: flex; gap: 11px; align-items: flex-start;
  transition: transform 0.1s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(22, 28, 38, 0.07);
}
.card .avatar {
  width: 38px; height: 38px; border-radius: 9px; flex: 0 0 auto;
  background: var(--bg-soft); border: 1px solid var(--border); object-fit: cover;
}
.card .body { min-width: 0; flex: 1; }
.card .name {
  font-weight: 650; font-size: 14px; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .owner { color: var(--muted); font-size: 11.5px; }
.card .desc {
  color: var(--muted); font-size: 12px; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta {
  display: flex; gap: 10px; margin-top: 9px; align-items: center;
  font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.card .meta .star { color: var(--star); font-variant-numeric: tabular-nums; }
.card .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }
.badge-curated {
  position: absolute; top: 9px; right: 9px;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em;
  background: rgba(124, 108, 240, 0.16); color: #5753d8;
  border: 1px solid rgba(124, 108, 240, 0.4); border-radius: 5px; padding: 1px 5px;
}

/* Detail modal */
.detail-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 32, 0.42);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(4px);
}
.detail-backdrop[hidden] { display: none; }
.detail-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  max-width: 520px; width: 100%; padding: 22px; position: relative;
  box-shadow: 0 24px 60px rgba(20, 24, 32, 0.16);
}
.detail-card .close {
  position: absolute; top: 14px; right: 16px; cursor: pointer; color: var(--muted);
  font-size: 20px; background: none; border: none;
}
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-head img { width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--border); }
.detail-head h3 { margin: 0; font-size: 18px; }
.detail-head .sub { color: var(--muted); font-size: 13px; }
.detail-desc { margin: 14px 0; color: var(--text); font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.detail-grid .kv { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.detail-grid .kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-grid .kv .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.detail-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border); color: var(--text);
  background: var(--panel-2);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }

.no-results { color: var(--muted); padding: 50px 0; text-align: center; }

/* Footer */
.site-footer { border-top: 1px solid var(--border-soft); padding: 28px 0 44px; color: var(--muted); font-size: 13px; }
.site-footer .muted { color: var(--muted); opacity: 0.85; margin-top: 6px; font-size: 12.5px; }

@media (max-width: 640px) {
  .stats { width: 100%; }
  /* One column on phones — content-rich cards need the full width; two
     columns crushed them and a featured card spanning two tracks overflowed
     the container and clipped the right column. */
  .grid { grid-template-columns: 1fr; }
  .card.featured { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ── CNCF-style tiers ───────────────────────── */
.grid { grid-auto-flow: row dense; }
.badge-tier {
  position: absolute; top: 9px; right: 9px; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.05em; border-radius: 5px; padding: 1px 6px; font-weight: 600;
}
.badge-tier.featured { background: rgba(87, 83, 216, 0.16); color: #5753d8; border: 1px solid rgba(87, 83, 216, 0.4); }
.badge-tier.prop { background: rgba(139, 149, 167, 0.14); color: #6b7280; border: 1px solid rgba(139, 149, 167, 0.32); }
/* Reserve room so the name never slides under the absolutely-positioned badge.
   Sized per badge: "FEATURED" / "no OSS license" / "🤗 HF". */
.card.featured .name { padding-right: 88px; }
.card.proprietary .name { padding-right: 104px; }
.card.hf .name { padding-right: 48px; }
/* Featured = large highlighted box (spans two columns) */
.card.featured {
  grid-column: span 2;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  border-color: rgba(87, 83, 216, 0.45);
  box-shadow: inset 0 0 0 1px rgba(87, 83, 216, 0.12);
}
.card.featured .avatar { width: 46px; height: 46px; }
.card.featured .name { font-size: 15.5px; }
.card.featured:hover { border-color: var(--accent); }
/* Proprietary = muted gray box */
.card.proprietary {
  background: #f1f3f5;
  border-color: #e1e4e8;
}
.card.proprietary .name, .card.proprietary .avatar { filter: saturate(0.55); opacity: 0.92; }
.card.proprietary:hover { border-color: #d4d8de; }
@media (max-width: 520px) { .card.featured { grid-column: span 1; } }

/* Legend (landscape + guide) */
.legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.legend .lg b { color: var(--text); font-weight: 600; }
.legend .lg-box { width: 22px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }
.legend .lg-box.featured { background: linear-gradient(180deg, rgba(87,83,216,0.18), var(--panel-2)); border-color: rgba(87,83,216,0.5); }
.legend .lg-box.oss { background: var(--panel); }
.legend .lg-box.prop { background: #f1f3f5; border-color: #e1e4e8; }
.toolbar-legend { border-bottom: 1px solid var(--border-soft); }
.toolbar-legend .wrap { padding: 10px 20px; }

/* ── Pantry Guide page ───────────────────────── */
.guide-wrap { display: grid; grid-template-columns: 232px 1fr; gap: 44px; align-items: start; padding-top: 30px; padding-bottom: 80px; }
.guide-index { position: sticky; top: 18px; }
.guide-index nav { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--border-soft); }
.gi-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; font-size: 13px; color: var(--muted); border-left: 2px solid transparent; margin-left: -1px;
}
.gi-link .gi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat, var(--muted)); flex: 0 0 auto; opacity: 0.85; }
.gi-link .gi-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gi-link:hover { color: var(--text); text-decoration: none; }
.gi-link.active { color: var(--text); border-left-color: var(--cat, var(--accent)); background: linear-gradient(90deg, rgba(22,28,38,0.05), transparent); }
.gi-link.gi-intro { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.gi-count { font-size: 11px; color: var(--muted); opacity: 0.7; font-variant-numeric: tabular-nums; }

.guide-main { max-width: 760px; }
.guide-intro { padding-bottom: 26px; margin-bottom: 12px; border-bottom: 1px solid var(--border-soft); scroll-margin-top: 20px; }
.guide-intro h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 14px; }
.guide-intro p { color: #57606a; font-size: 15px; line-height: 1.6; }
.guide-intro .legend { margin: 18px 0 0; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.guide-intro .legend .lg { flex-direction: row; }
/* CNCF attribution callout */
.g-attribution {
  display: flex; gap: 12px; align-items: flex-start; margin: 20px 0;
  padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(87,83,216,0.10), rgba(124,108,240,0.06));
  border: 1px solid rgba(87,83,216,0.3); color: #424a53; font-size: 13.5px; line-height: 1.55;
}
.g-attribution .g-attr-icon { font-size: 20px; line-height: 1.3; }
.g-attribution em { color: #2c2417; font-style: normal; font-weight: 600; }

/* Chapters as colorful cards */
.guide-chapter {
  padding: 22px 22px 24px; margin-bottom: 22px; scroll-margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--border); border-left: 4px solid var(--cat); border-radius: 14px;
}
.g-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.g-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 23px; flex: 0 0 auto;
  background: color-mix(in srgb, var(--cat) 18%, transparent); border: 1px solid color-mix(in srgb, var(--cat) 35%, var(--border));
}
.g-head-text { display: flex; flex-direction: column; gap: 1px; }
.g-head-text h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.g-head-text .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-explore { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--cat); white-space: nowrap; }
.g-explore:hover { color: var(--cat); filter: brightness(1.2); }
.guide-chapter .cat-when { margin: 0 0 16px; }

.g-facets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g-facet {
  background: rgba(22,28,38,0.04); border: 1px solid var(--border-soft); border-radius: 11px; padding: 13px 15px;
}
.g-facet.tech { grid-column: 1 / -1; background: rgba(22,28,38,0.05); }
.g-facet-head {
  display: flex; align-items: center; gap: 7px; margin-bottom: 7px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--cat);
}
.g-facet-icon { font-size: 14px; }
.g-facet p { margin: 0; color: #57606a; font-size: 14px; line-height: 1.6; }

.g-examples { margin-top: 16px; }
.g-ex-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: block; margin-bottom: 9px; }
.g-ex-list { display: flex; flex-wrap: wrap; gap: 8px; }
.g-ex {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 5px;
}
.g-ex img { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-soft); border: 1px solid var(--border); }
.g-ex .g-ex-name { font-weight: 600; }
.g-ex .g-ex-star { color: var(--star); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.g-ex:hover { border-color: var(--cat); text-decoration: none; }

@media (max-width: 820px) {
  .guide-wrap { grid-template-columns: 1fr; gap: 16px; }
  .guide-index { position: static; }
  .guide-index nav { flex-direction: row; flex-wrap: wrap; border-left: none; gap: 6px; }
  .gi-link { border: 1px solid var(--border); border-radius: 999px; margin-left: 0; }
  .gi-link.active { border-color: var(--cat, var(--accent)); }
  .g-facets { grid-template-columns: 1fr; }
}

/* "Use in your agent" button + modal */
.use-agent { background: var(--accent); border-color: var(--accent); color: #fff; }
.use-agent:hover { color: #fff; filter: brightness(1.06); }
.use-row { display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.use-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 3px; }
.use-url { font-size: 12px; color: var(--text); word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.use-tip { margin-top: 14px; font-size: 13px; color: var(--muted); background: rgba(87, 83, 216, 0.06);
  border: 1px solid rgba(87, 83, 216, 0.22); border-radius: 10px; padding: 11px 12px; }
.use-tip code { display: block; margin: 7px 0; font-size: 12px; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.5; }
.btn.copy { padding: 6px 13px; font-size: 12.5px; white-space: nowrap; }
.btn.copy.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Legend emoji icon + Hot (spicy) indicator */
.legend .lg-ico { font-size: 15px; line-height: 1; }
.card .meta .hot { font-size: 13px; line-height: 1; filter: saturate(1.1); }
