:root {
  --bg: #0b0f19;
  --card-bg: #111827;
  --card-hover-bg: #162032;
  --card-header-bg: #141d2e;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-glow: rgba(56, 189, 248, 0.2);
  --border: #1f293d;
  --border-light: #334155;
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.2);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 2rem 1rem 6rem 1rem;
  min-height: 100vh;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
  color: var(--text);
}

h1 span {
  color: var(--accent);
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 650px;
  margin: 0 auto;
}

/* Navigation */
.nav-links {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
}

.nav-link.active {
  color: #0b0f19;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* Controls & Filter Panel */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.search-bar {
  width: 100%;
}

.search-bar input {
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-size: 1.05rem;
  background: #090d16;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  background: #090d16;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  color: #0b0f19;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.metrics {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Grid & Cards (Modern CSS Auto-fit Grid - Zero Overlapping) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
  margin-bottom: 3rem;
}

.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-sizing: border-box;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  border-color: #3b82f6;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  line-height: 1.35;
  flex: 1;
}

.card-title a,
.card-title span {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.card-title span:hover {
  color: var(--accent);
}

.card-badges {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Ecosystem & Version Badges */
.badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.badge-eco-npm {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

.badge-eco-pypi {
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
}

.badge-eco-github {
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
  background: rgba(168, 85, 247, 0.1);
}

.badge-eco-golang {
  border-color: rgba(20, 184, 166, 0.4);
  color: #2dd4bf;
  background: rgba(20, 184, 166, 0.1);
}

.badge-eco-generic {
  border-color: rgba(148, 163, 184, 0.3);
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
}

.badge-version {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-version-select {
  background: #090d16;
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.badge-version-select:hover,
.badge-version-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.card-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tools Section & Tags */
.tools-section {
  margin: 0.5rem 0 1rem 0;
  position: relative;
}

.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}

.tools-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-toggle-tools {
  background: transparent;
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-toggle-tools:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 80px;
  overflow-y: auto;
  padding-right: 2px;
}

.tool-tags::-webkit-scrollbar {
  width: 4px;
}

.tool-tags::-webkit-scrollbar-thumb {
  background: #1f293d;
  border-radius: 4px;
}

.tool-tag {
  font-size: 0.73rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #090d16;
  border: 1px solid var(--border-light);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tool-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.tool-tag-more {
  font-size: 0.73rem;
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.tool-tag-more:hover {
  background: rgba(56, 189, 248, 0.2);
}

/* Inline Expandable Tool Drawer */
.inline-tool-drawer {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #080c14;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: drawerSlide 0.18s ease-out;
}

@keyframes drawerSlide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.drawer-search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.drawer-search-input {
  flex: 1;
  background: #111827;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
  outline: none;
}

.drawer-search-input:focus {
  border-color: var(--accent);
}

.drawer-count-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.drawer-tools-container {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 4px;
}

.drawer-tools-container::-webkit-scrollbar {
  width: 5px;
}

.drawer-tools-container::-webkit-scrollbar-thumb {
  background: #1f293d;
  border-radius: 4px;
}

.drawer-tool-row {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: all 0.15s;
}

.drawer-tool-row:hover {
  border-color: var(--accent);
  background: #152238;
}

.drawer-tool-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.drawer-tool-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
  word-break: break-all;
}

.drawer-tool-params-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: #090d16;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #1f293d;
  white-space: nowrap;
}

.drawer-tool-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card Actions */
.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  align-items: center;
}

.btn-copy,
.btn-inspect {
  flex: 1;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #090d16;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.btn-copy:hover {
  background: var(--accent);
  color: #0b0f19;
  border-color: var(--accent);
  font-weight: 700;
}

.btn-inspect {
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent);
}

.btn-inspect:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
}

.copied {
  background: var(--success) !important;
  color: #0b0f19 !important;
  border-color: var(--success) !important;
  font-weight: 700 !important;
}

/* Checkbox container for multi-server selection */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-container input {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

/* Floating Bottom Drawer */
#bottomDrawer {
  position: fixed;
  bottom: -100px;
  left: 0;
  width: 100%;
  background: var(--card-bg);
  border-top: 2px solid var(--accent);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  transition: bottom 0.25s ease-in-out;
  z-index: 100;
}

#bottomDrawer.show {
  bottom: 0;
}

.drawer-info {
  font-size: 1.05rem;
  font-weight: 700;
}

.btn-build {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-build:hover {
  background: var(--success);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #0f172a;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 92%;
  max-width: 900px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  animation: modalPop 0.18s ease-out;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn-modal {
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--success);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  gap: 0.5rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Code area */
.code-area {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: #e2e8f0;
  white-space: pre-wrap;
  overflow-x: auto;
  min-height: 200px;
}

/* Inspector Modal Detailed Styles */
.inspector-header-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.inspector-meta-item {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.inspector-meta-item strong {
  color: var(--text);
}

.inspector-meta-item a {
  color: var(--accent);
  text-decoration: none;
}

.inspector-meta-item a:hover {
  text-decoration: underline;
}

.tool-detail-card {
  background: #090d16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.15rem;
  margin-bottom: 1rem;
}

.tool-detail-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tool-detail-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}

.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.schema-table th,
.schema-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: left;
}

.schema-table th {
  background: #141d2e;
  color: var(--text);
  font-weight: 600;
}

.schema-table td {
  color: var(--text-muted);
}

.schema-table td.param-name {
  color: var(--text);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.copy-buttons-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success);
  color: #0b0f19;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 300;
}

#toast.show {
  opacity: 1;
}

/* Updates Page Badges */
.update-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.update-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.badge-new-server {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.badge-new-version {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.badge-tools-added {
  color: #a855f7;
  background: rgba(168, 85, 247, 0.1);
}

.badge-params-updated {
  color: #eab308;
  background: rgba(234, 179, 8, 0.1);
}

/* Sentinel for infinite scroll */
#scrollSentinel {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* No Tools Badge */
.no-tools-badge {
  font-size: 0.8rem;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  margin-top: 0.25rem;
  display: inline-block;
}
