:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f3a5f;

  --cat-documentation: #1f6feb;
  --cat-documentation-bg: #0d2137;
  --cat-code-quality: #d29922;
  --cat-code-quality-bg: #2a1f00;
  --cat-productivity: #3fb950;
  --cat-productivity-bg: #0d2a14;
  --cat-automation: #bc8cff;
  --cat-automation-bg: #1e1040;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.header-left h1 span { color: var(--accent); }

.header-left p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-gh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-gh:hover { background: var(--surface-hover); border-color: var(--accent); }

/* ── Controls ── */
.controls {
  padding: 20px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

#search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-muted); }

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text); border-color: var(--text-muted); }
.filter-btn.active { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

.view-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}

.view-btn {
  padding: 4px 12px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.view-btn.active { background: var(--accent-dim); color: var(--accent); }

/* ── Main ── */
main { padding: 24px 32px; }

.count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Skill Cards ── */
#skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.skill-card:hover { border-color: var(--accent); background: var(--surface-hover); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
  text-decoration: none;
}
.card-name:hover { text-decoration: underline; }

.card-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-readonly {
  background: #21262d;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-cat { border: none; }
.badge-marketplace { background: #1a2332; color: #58a6ff; border: 1px solid #1f6feb; font-family: monospace; }
.badge-documentation { background: var(--cat-documentation-bg); color: var(--cat-documentation); }
.badge-code-quality   { background: var(--cat-code-quality-bg);   color: var(--cat-code-quality); }
.badge-productivity   { background: var(--cat-productivity-bg);   color: var(--cat-productivity); }
.badge-automation     { background: var(--cat-automation-bg);     color: var(--cat-automation); }

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}
.card-desc.expanded {
  display: block;
  overflow: visible;
}

.card-install {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}

.card-install code {
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.copy-btn:hover { color: var(--accent); background: var(--accent-dim); }
.copy-btn.copied { color: var(--cat-productivity); }

/* ── Bundle Cards ── */
#bundles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.bundle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bundle-name {
  font-size: 1rem;
  font-weight: 600;
}

.bundle-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bundle-skills {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bundle-skill-item {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.bundle-skill-item::before { content: '▸'; color: var(--accent); font-size: 0.65rem; }

.bundle-install {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  position: relative;
}

.bundle-install pre {
  font-size: 0.72rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.6;
}

.bundle-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 2px 8px;
  transition: color 0.15s, border-color 0.15s;
}
.bundle-copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.bundle-copy-btn.copied { color: var(--cat-productivity); border-color: var(--cat-productivity); }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty p:first-child { font-size: 1.5rem; margin-bottom: 8px; }

/* ── Footer ── */
footer {
  margin-top: 48px;
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 600px) {
  header, .controls, main, footer { padding-left: 16px; padding-right: 16px; }
  .view-toggle { margin-left: 0; }
  #skills-grid, #bundles-grid { grid-template-columns: 1fr; }
}
