*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0a0b;
  --bg2: #141416;
  --bg3: #1c1c1f;
  --border: #2a2a2e;
  --text: #f4f4f5;
  --text2: #a1a1aa;
  --text3: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,0.15);
  --green: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Nav */
nav {
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,11,0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.nav-links { display: flex; gap: 24px; }
.nav-links a {
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color .2s;
}
.nav-links a:hover { color: var(--text); }

/* Hero */
.hero {
  position: relative;
  text-align: center;
  padding: 80px 24px 64px;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 600px 400px at 50% 0%, var(--accent-glow), transparent);
  pointer-events: none;
}
.hero h1 {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -1.5px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text2);
  font-size: 18px;
  margin-bottom: 32px;
}
.hero-stats {
  margin-top: 20px;
  color: var(--text3);
  font-size: 14px;
}
.hero-stats span { color: var(--accent); font-weight: 600; }

/* Search */
.search-box {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text3);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 14px 16px 14px 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#searchInput::placeholder { color: var(--text3); }

/* Controls */
.controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.filter-group { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.filter-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: var(--accent); color: white; }
.sort-group { display: flex; align-items: center; gap: 8px; }
.sort-group label { color: var(--text3); font-size: 13px; }
#sortSelect {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

/* Grid */
.tools-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text3);
  font-size: 15px;
}

/* Tool Card */
.tool-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(0,0,0,.4);
  transform: translateY(-2px);
}
.tool-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.tool-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.star-count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
  white-space: nowrap;
}
.tool-card-author {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}
.tool-card-lang {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.lang-py { background: rgba(99,102,241,0.15); color: var(--accent); }
.lang-ts { background: rgba(34,197,94,0.15); color: var(--green); }
.lang-unknown { background: rgba(161,161,170,0.15); color: var(--text2); }
.tool-card-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.tool-card-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.meta-item {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}
.tool-card-version {
  font-size: 12px;
  color: var(--text3);
  font-family: monospace;
  flex-shrink: 0;
}
.tool-card-date {
  font-size: 12px;
  color: var(--text3);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* Modal content */
.modal-header { margin-bottom: 24px; }
.modal-name {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-author { font-size: 13px; color: var(--text3); margin-top: 4px; }
.modal-stats {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}
.modal-desc {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.modal-section { margin-bottom: 20px; }
.modal-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.param-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.param-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.param-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  font-family: monospace;
  margin-bottom: 4px;
}
.param-name .required { color: #ef4444; font-weight: 400; }
.param-desc { font-size: 13px; color: var(--text2); }
.param-type { font-size: 12px; color: var(--text3); font-family: monospace; margin-top: 2px; }
.version-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.version-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.version-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.version-date { font-size: 12px; color: var(--text3); }
.version-repo {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}
.version-repo a { color: var(--accent); text-decoration: none; }
.version-repo a:hover { text-decoration: underline; }
.modal-entry {
  font-family: monospace;
  font-size: 13px;
  color: var(--text2);
  background: var(--bg3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* Footer */
footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text3);
  font-size: 13px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Responsive */
@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 16px; }
  .hero { padding: 48px 24px 40px; }
  .tools-grid { grid-template-columns: 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
  .modal { padding: 24px; }
}
