/* ============================================================
   style.css — MCP Platform Marketplace
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #0891b2;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.15);

  --transition: 0.2s ease;
  --max-width: 1280px;
  --nav-height: 56px;

  /* Typography Scale */
  --text-4xl: 2.5rem;
  --text-3xl: 2rem;
  --text-2xl: 1.5rem;
  --text-xl: 1.25rem;
  --text-lg: 1.1rem;
  --text-base: 1rem;
  --text-sm: 0.875rem;
  --text-xs: 0.75rem;

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
}

/* Dark theme (default) */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #263548;
  --bg-elevated: #334155;
  --border: #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --input-bg: #1e293b;
  --input-border: #475569;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.3);
  --nav-bg: rgba(15,23,42,0.95);
}

/* Light theme */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --nav-bg: rgba(248,250,252,0.95);
}

/* ── Auth Flash Prevention ─────────────────────────────────── */
/* Hide login button and user menu until auth resolves to prevent FOUC */
#login-btn, #user-menu { visibility: hidden; }
html.auth-ready #login-btn, html.auth-ready #user-menu { visibility: visible; }

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Navigation ────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 16px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-logo:hover { text-decoration: none; }

.nav-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.nav-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}

.nav-search input:focus { border-color: var(--color-primary); }

.nav-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--color-primary);
  font-weight: 600;
}

#user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

#user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

#user-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}

.hamburger-btn svg {
  width: 24px;
  height: 24px;
}

.mobile-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  backdrop-filter: blur(4px);
}

.mobile-menu-overlay.open { display: block; }

.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 151;
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.mobile-menu.open { transform: translateX(0); }

.mobile-menu-close {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.mobile-menu-close button {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}

.mobile-menu-close button svg {
  width: 24px;
  height: 24px;
}

.mobile-menu-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-menu-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
}

.mobile-menu-links a:hover,
.mobile-menu-links a.active {
  background: var(--bg-surface-hover);
  color: var(--color-primary);
  text-decoration: none;
}

.mobile-menu-links a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-surface-hover); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-success {
  background: var(--color-success);
  color: #fff;
}
.btn-success:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 6px 8px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}

.badge-green { background: rgba(22,163,74,0.15); color: #22c55e; }
.badge-blue { background: rgba(37,99,235,0.15); color: #60a5fa; }
.badge-amber { background: rgba(217,119,6,0.15); color: #fbbf24; }
.badge-yellow { background: rgba(234,179,8,0.15); color: #facc15; }
.badge-orange { background: rgba(234,88,12,0.15); color: #fb923c; }
.badge-red { background: rgba(220,38,38,0.15); color: #f87171; }
.badge-gray { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-gold { background: rgba(245,158,11,0.15); color: #f59e0b; }

[data-theme="light"] .badge-green { background: rgba(22,163,74,0.1); color: #16a34a; }
[data-theme="light"] .badge-blue { background: rgba(37,99,235,0.1); color: #2563eb; }
[data-theme="light"] .badge-amber { background: rgba(217,119,6,0.1); color: #d97706; }
[data-theme="light"] .badge-yellow { background: rgba(234,179,8,0.1); color: #ca8a04; }
[data-theme="light"] .badge-orange { background: rgba(234,88,12,0.1); color: #ea580c; }
[data-theme="light"] .badge-red { background: rgba(220,38,38,0.1); color: #dc2626; }
[data-theme="light"] .badge-gray { background: rgba(100,116,139,0.1); color: #64748b; }
[data-theme="light"] .badge-gold { background: rgba(245,158,11,0.1); color: #d97706; }

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge-official {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
}

/* Badge Hover Effect */
.badge {
  transition: filter 0.15s ease;
  cursor: default;
  position: relative;
}

.badge:hover {
  filter: brightness(1.2);
  z-index: 5;
}

/* Badge Rich Tooltip (CSS-only) */
.badge-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: normal;
  width: max-content;
  max-width: 260px;
  line-height: 1.6;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  text-align: left;
}

.badge-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border-light);
}

.badge-tip::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--bg-elevated);
  z-index: 1;
}

.badge:hover .badge-tip {
  display: block;
  animation: badgeTipFade 0.15s ease forwards;
}

@keyframes badgeTipFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Ensure tooltip doesn't overflow viewport on edges */
.badge-group .badge:first-child .badge-tip { left: 0; transform: none; }
.badge-group .badge:first-child .badge-tip::after,
.badge-group .badge:first-child .badge-tip::before { left: 20px; transform: none; }

.badge-group .badge:last-child .badge-tip { left: auto; right: 0; transform: none; }
.badge-group .badge:last-child .badge-tip::after,
.badge-group .badge:last-child .badge-tip::before { left: auto; right: 20px; transform: none; }

/* Card Badge Area (visual zone separator) */
.card-badges {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px dashed var(--border);
}

/* Badge Summary (compact single-line for cards) */
.badge-summary {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}

.badge-summary .summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.summary-dot.dot-a { background: #16a34a; }
.summary-dot.dot-b { background: #2563eb; }
.summary-dot.dot-c { background: #d97706; }
.summary-dot.dot-d { background: #dc2626; }

.badge-summary .sep { color: var(--text-muted); }

/* Grade Legend */
.grade-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.grade-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.grade-legend-item .trust-grade {
  width: 24px;
  height: 24px;
  font-size: 0.65rem;
}

/* Grade tip in card: right-align to avoid overflow */
.card .trust-grade .grade-tip {
  left: auto;
  right: 0;
  transform: none;
}

.card .trust-grade .grade-tip::after {
  left: auto;
  right: 10px;
  transform: none;
}

/* ── SVG Icons ─────────────────────────────────────────────── */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transform: translateY(0);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 8px 25px rgba(37,99,235,0.12);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title a {
  color: inherit;
}
.card-title a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tag {
  padding: 2px 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* ── Trust Grade ──────────────────────────────────────────── */
.trust-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  cursor: help;
}

.trust-grade-a { background: #16a34a; }
.trust-grade-b { background: #2563eb; }
.trust-grade-c { background: #d97706; }
.trust-grade-d { background: #dc2626; }

.trust-grade .grade-tip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  z-index: 50;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.trust-grade .grade-tip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--bg-elevated);
}

.trust-grade:hover .grade-tip {
  display: block;
  animation: badgeTipFade 0.15s ease forwards;
}

/* ── Server Card Grid ──────────────────────────────────────── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.page-content {
  padding: 24px 0;
}

.layout-sidebar {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

/* ── Hero Section ──────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 60px 16px 40px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(124,58,237,0.1) 0%, transparent 50%),
    linear-gradient(135deg, var(--bg-surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.3;
  pointer-events: none;
}

.hero h1 {
  font-size: var(--text-4xl);
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.hero p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  max-width: 600px;
  margin: 0 auto 32px;
  position: relative;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.hero-stat {
  text-align: center;
}

.hero-stat .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.hero-stat .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Sidebar Filters ───────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 24px);
  align-self: start;
}

.filter-section {
  margin-bottom: 20px;
}

.filter-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-option:hover { color: var(--text-primary); }

.filter-option input[type="checkbox"] {
  accent-color: var(--color-primary);
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumb .breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.breadcrumb .breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Sort Bar ──────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.sort-bar .result-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.sort-options {
  display: flex;
  gap: 4px;
}

.sort-options button {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.sort-options button:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.sort-options button.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ── Category Tabs ─────────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.category-tabs button {
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.category-tabs button:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.category-tabs button.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ── Onboard Steps ─────────────────────────────────────────── */
.onboard-steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.onboard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  max-width: 180px;
}

.onboard-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  margin-bottom: 8px;
}

.onboard-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.onboard-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.onboard-desc a {
  color: var(--color-primary);
  text-decoration: underline;
}

.onboard-arrow {
  color: var(--text-muted);
  margin-top: 12px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .onboard-steps { flex-direction: column; align-items: center; gap: 4px; }
  .onboard-step { max-width: 100%; flex-direction: row; gap: 12px; text-align: left; }
  .onboard-icon { width: 36px; height: 36px; flex-shrink: 0; margin-bottom: 0; }
  .onboard-icon svg { width: 18px; height: 18px; }
  .onboard-arrow { transform: rotate(90deg); margin-top: 0; }
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.form-group .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.label-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: var(--bg-elevated);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--bg-surface-hover); }

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 32px;
}

.pagination button {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.pagination button.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Wizard ────────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wizard-step .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.wizard-step.active { color: var(--color-primary); }
.wizard-step.active .step-num {
  background: var(--color-primary);
  color: #fff;
}

.wizard-step.done { color: var(--color-success); }
.wizard-step.done .step-num {
  background: var(--color-success);
  color: #fff;
}

.wizard-connector {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}

.wizard-connector.done { background: var(--color-success); }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

.wizard-progress {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.wizard-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.wizard-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Server Detail ─────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.detail-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-header .version {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.detail-section {
  margin-bottom: 32px;
}

.detail-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.badge-explain {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.badge-explain-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.badge-explain-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
}

.badge-explain-item.explain-source { border-left: 3px solid #60a5fa; }
.badge-explain-item.explain-data { border-left: 3px solid #22c55e; }
.badge-explain-item.explain-permission { border-left: 3px solid #fbbf24; }
.badge-explain-item.explain-community { border-left: 3px solid #f59e0b; }
.badge-explain-item.explain-external { border-left: 3px solid #a78bfa; }

.badge-explain-item .badge-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ── Timeline ──────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
}

.timeline-item.success::before { background: var(--color-success); border-color: var(--color-success); }
.timeline-item.warning::before { background: var(--color-warning); border-color: var(--color-warning); }
.timeline-item.danger::before { background: var(--color-danger); border-color: var(--color-danger); }

.timeline-item .time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Code Block ────────────────────────────────────────────── */
.code-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  position: relative;
  white-space: pre;
  line-height: 1.5;
}

.code-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}
.code-block .copy-btn:hover { color: var(--text-primary); }

/* ── Scan Results Grid ─────────────────────────────────────── */
.scan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.scan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color var(--transition);
}

.scan-item:hover {
  border-color: var(--color-primary);
}

.scan-item .scan-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Stats Card ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transform: translateY(0);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Composition Card ──────────────────────────────────────── */
.comp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  transform: translateY(0);
  transition: transform var(--transition), box-shadow var(--transition);
}

.comp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}

.comp-card .comp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comp-card .comp-name {
  font-size: 1.05rem;
  font-weight: 600;
}

.comp-endpoint {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 8px 0;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.comp-endpoint code { flex: 1; }

.comp-servers {
  margin-top: 12px;
}

.comp-server-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.comp-server-item:hover { background: var(--bg-surface-hover); }

.comp-server-item .prefix {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--color-primary);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ── Template Cards ───────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.template-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transform: translateY(0);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.template-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37,99,235,0.12);
}

.template-card .template-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.template-card .template-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.template-card .template-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.template-card .template-servers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.template-card .template-servers .tag {
  font-size: 0.7rem;
}

/* ── Status Indicator ──────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.status-dot.active { background: var(--color-success); }
.status-dot.inactive { background: var(--text-muted); }
.status-dot.pending { background: var(--color-warning); }
.status-dot.error { background: var(--color-danger); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ── Loading ───────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton Loading ─────────────────────────────────────── */
.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
}

.skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}

.skeleton-line.skeleton-title {
  height: 20px;
  width: 70%;
  margin-bottom: 16px;
}

.skeleton-line.skeleton-desc {
  width: 100%;
}

.skeleton-line.skeleton-desc-short {
  width: 60%;
}

.skeleton-line.skeleton-badge {
  display: inline-block;
  width: 72px;
  height: 22px;
  border-radius: 9999px;
  margin-right: 6px;
  margin-bottom: 8px;
}

.skeleton-line.skeleton-meta {
  width: 50%;
  height: 12px;
  margin-top: 16px;
  margin-bottom: 0;
}

.skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--bg-surface-hover), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Featured Section ─────────────────────────────────────── */
.featured-section {
  margin-bottom: 32px;
}

.featured-section h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.featured-card {
  background: var(--bg-surface);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  transform: translateY(0);
  transition: transform var(--transition), box-shadow var(--transition);
}

.featured-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(37,99,235,0.05) 0%, transparent 100%);
  pointer-events: none;
}

.featured-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37,99,235,0.15);
}

.featured-label {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 9999px;
}

/* ── Badge Education ──────────────────────────────────────── */
.badge-education {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}

.badge-education-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition);
}

.badge-education-header:hover {
  background: var(--bg-surface-hover);
}

.badge-education-header h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-education-header .toggle-icon {
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.badge-education-header .toggle-icon.open {
  transform: rotate(180deg);
}

.badge-education-body {
  display: none;
  padding: 0 20px 20px;
}

.badge-education-body.open {
  display: block;
  overflow: visible;
}

.badge-education-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.badge-education-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px 14px 14px 16px;
  border-left: 3px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}

.badge-education-item:hover {
  background: var(--bg-surface-hover);
}

.badge-education-item.edu-source { border-left-color: #60a5fa; }
.badge-education-item.edu-data { border-left-color: #22c55e; }
.badge-education-item.edu-permission { border-left-color: #fbbf24; }
.badge-education-item.edu-community { border-left-color: #f59e0b; }

.badge-education-item .edu-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.badge-education-item h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.badge-education-item p {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Grade Bar (compact grade legend) ─────────────────────── */
.grade-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.grade-bar-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}

.grade-bar-item:hover {
  background: var(--bg-surface-hover);
}

.grade-bar-a { border-left: 3px solid #16a34a; }
.grade-bar-b { border-left: 3px solid #2563eb; }
.grade-bar-c { border-left: 3px solid #d97706; }
.grade-bar-d { border-left: 3px solid #dc2626; }

.grade-bar-item .trust-grade {
  width: 26px;
  height: 26px;
  font-size: 0.7rem;
}

.grade-bar-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.grade-bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.grade-bar-score {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Grade Dimensions formula row */
.grade-dimensions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.grade-dim {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 0.7rem;
  color: var(--text-secondary);
  cursor: help;
  transition: background var(--transition);
}

.grade-dim:hover {
  background: var(--bg-surface-hover);
}

.grade-dim-icon {
  display: inline-flex;
  color: var(--text-muted);
}

.grade-dim-result {
  background: rgba(37,99,235,0.1);
  color: var(--color-primary);
  font-weight: 600;
}

.grade-dim-result .grade-dim-icon {
  color: var(--color-primary);
}

.grade-dim-plus,
.grade-dim-eq {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.grade-dim-eq {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .grade-bar {
    flex-wrap: wrap;
  }
  .grade-bar-item {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }
  .grade-dimensions {
    gap: 4px;
  }
  .grade-dim span:not(.grade-dim-icon) {
    display: none;
  }
  .grade-dim {
    padding: 6px;
  }
}

/* ── Onboarding Band (Quick Start) ────────────────────────── */
.onboarding-band {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 48px 16px;
  position: relative;
  overflow: hidden;
}

.onboarding-band::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.15;
  pointer-events: none;
}

.onboarding-band.hidden { display: none; }

.onboarding-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  text-align: center;
}

.onboarding-dismiss {
  position: absolute;
  top: -8px;
  right: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  z-index: 2;
}

.onboarding-dismiss:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.onboarding-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  margin-bottom: 12px;
  position: relative;
}

.onboarding-headline {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
  position: relative;
}

.onboarding-highlight {
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.onboarding-subline {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 40px;
  position: relative;
}

.onboarding-steps {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 36px;
  position: relative;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 200px;
  position: relative;
}

.onboarding-step-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.onboarding-step:hover .onboarding-step-icon { transform: translateY(-4px); }

.onboarding-icon-blue {
  background: rgba(37, 99, 235, 0.12);
  color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}
.onboarding-step:hover .onboarding-icon-blue {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3), 0 8px 24px rgba(37, 99, 235, 0.15);
}

.onboarding-icon-purple {
  background: rgba(124, 58, 237, 0.12);
  color: #a78bfa;
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.15);
}
.onboarding-step:hover .onboarding-icon-purple {
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.3), 0 8px 24px rgba(124, 58, 237, 0.15);
}

.onboarding-icon-green {
  background: rgba(22, 163, 74, 0.12);
  color: #4ade80;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.15);
}
.onboarding-step:hover .onboarding-icon-green {
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.3), 0 8px 24px rgba(22, 163, 74, 0.15);
}

.onboarding-step-num {
  position: absolute;
  top: -4px;
  right: calc(50% - 38px);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-light, var(--border));
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.onboarding-step-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.onboarding-step-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 160px;
}

.onboarding-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 0 12px;
  margin-top: 20px;
  opacity: 0.5;
}

.onboarding-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.onboarding-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.onboarding-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.onboarding-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.onboarding-btn-secondary:hover {
  color: var(--text-primary);
  text-decoration: none;
}

/* Staggered entrance */
@keyframes onboarding-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.onboarding-label     { animation: onboarding-fade-up 0.5s ease both 0.1s; }
.onboarding-headline  { animation: onboarding-fade-up 0.5s ease both 0.15s; }
.onboarding-subline   { animation: onboarding-fade-up 0.5s ease both 0.2s; }
.onboarding-step[data-step="1"] { animation: onboarding-fade-up 0.5s ease both 0.3s; }
.onboarding-steps > .onboarding-connector:nth-child(2) { animation: onboarding-fade-up 0.5s ease both 0.4s; }
.onboarding-step[data-step="2"] { animation: onboarding-fade-up 0.5s ease both 0.45s; }
.onboarding-steps > .onboarding-connector:nth-child(4) { animation: onboarding-fade-up 0.5s ease both 0.55s; }
.onboarding-step[data-step="3"] { animation: onboarding-fade-up 0.5s ease both 0.6s; }
.onboarding-cta       { animation: onboarding-fade-up 0.5s ease both 0.7s; }

@media (prefers-reduced-motion: reduce) {
  .onboarding-label, .onboarding-headline, .onboarding-subline,
  .onboarding-step, .onboarding-connector, .onboarding-cta { animation: none; }
  .onboarding-step:hover .onboarding-step-icon { transform: none; }
  .onboarding-btn:hover { transform: none; }
}

@media (max-width: 768px) {
  .onboarding-band { padding: 36px 16px; }
  .onboarding-headline { font-size: var(--text-xl); }
  .onboarding-subline { margin-bottom: 32px; }
  .onboarding-step { width: 160px; }
  .onboarding-step-icon { width: 52px; height: 52px; }
  .onboarding-step-icon svg { width: 22px; height: 22px; }
  .onboarding-connector { padding: 0 6px; }
  .onboarding-connector svg { width: 18px; height: 18px; }
  .onboarding-step-num { right: calc(50% - 32px); width: 20px; height: 20px; font-size: 0.65rem; }
  .onboarding-cta { flex-direction: column; gap: 8px; }
}

@media (max-width: 480px) {
  .onboarding-band { padding: 28px 16px; }
  .onboarding-headline { font-size: var(--text-lg); }
  .onboarding-subline { font-size: var(--text-xs); margin-bottom: 24px; }
  .onboarding-steps { flex-direction: column; align-items: center; gap: 8px; }
  .onboarding-step {
    flex-direction: row; width: 100%; max-width: 320px; gap: 14px; text-align: left;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 14px 16px;
  }
  .onboarding-step-icon { width: 44px; height: 44px; margin-bottom: 0; flex-shrink: 0; }
  .onboarding-step-icon svg { width: 20px; height: 20px; }
  .onboarding-step-num { display: none; }
  .onboarding-step-title { font-size: var(--text-sm); }
  .onboarding-step-desc { max-width: none; }
  .onboarding-connector { transform: rotate(90deg); padding: 0; margin-top: 0; }
  .onboarding-connector svg { width: 16px; height: 16px; }
  .onboarding-btn { width: 100%; justify-content: center; padding: 12px 20px; }
  .onboarding-btn-secondary { width: 100%; justify-content: center; }
}

/* ── Alert ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert-info {
  background: rgba(8,145,178,0.1);
  border-color: rgba(8,145,178,0.3);
  color: var(--color-info);
}

.alert-warning {
  background: rgba(217,119,6,0.1);
  border-color: rgba(217,119,6,0.3);
  color: var(--color-warning);
}

.alert-danger {
  background: rgba(220,38,38,0.1);
  border-color: rgba(220,38,38,0.3);
  color: var(--color-danger);
}

.alert-success {
  background: rgba(22,163,74,0.1);
  border-color: rgba(22,163,74,0.3);
  color: var(--color-success);
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 11px;
  transition: var(--transition);
}

.toggle .slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .slider { background: var(--color-primary); }
.toggle input:checked + .slider::before { transform: translateX(18px); background: #fff; }

/* ── Tooltip ───────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 10;
}

.label-help[data-tooltip]::after {
  white-space: normal;
  width: 220px;
  text-align: left;
  left: 0;
  transform: none;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── Scroll to Top ────────────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top-btn:hover {
  background: var(--color-primary-hover);
}

.scroll-top-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Login Providers ───────────────────────────────────────── */
.login-providers {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.btn-login-github,
.btn-login-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
}

.btn-login-github {
  background: #24292e;
  color: #fff;
  border-color: #24292e;
}
.btn-login-github:hover { background: #1b1f23; }

.btn-login-google {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-login-google:hover { background: var(--bg-surface-hover); }

[data-theme="light"] .btn-login-google {
  background: #fff;
  border-color: #dadce0;
}
[data-theme="light"] .btn-login-google:hover {
  background: #f8f9fa;
}

/* ── Utility ───────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout-sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: none;
  }

  .sidebar.open { display: block; }

  .nav-search { max-width: none; }

  .nav-links a.hide-mobile { display: none; }

  .hamburger-btn { display: block; }

  .hero { padding: 40px 16px 32px; }

  .hero h1 { font-size: var(--text-3xl); }

  .hero-stats { gap: 16px; }

  .server-grid {
    grid-template-columns: 1fr;
  }

  .detail-header {
    flex-direction: column;
  }

  .detail-actions {
    width: 100%;
  }

  .detail-actions .btn { flex: 1; justify-content: center; }

  .badge-explain {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .wizard-step .step-label { display: none; }

  .modal { max-width: 100%; margin: 16px; }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .featured-grid {
    grid-template-columns: 1fr;
  }

  .badge-education-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .badge-explain {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    flex-direction: column;
    gap: 8px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Site Footer ───────────────────────────────────────────── */
.site-footer {
  margin-top: 64px;
  padding: 40px 0 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.site-footer .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.footer-col p {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.footer-col-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-col-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-xs);
  transition: color var(--transition);
}

.footer-col-links a:hover {
  color: var(--color-primary);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-bottom .footer-disclosure {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding-bottom: 12px;
}

.footer-social a {
  color: var(--text-muted);
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
}

.footer-social a:hover {
  color: var(--text-primary);
}

/* ── Privacy / Trust Pages ────────────────────────────────── */
.policy-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}
.policy-page h1 {
  margin-bottom: 8px;
}
.policy-page .policy-updated {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
}
.policy-page .policy-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 32px;
}
.policy-page .policy-summary h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}
.policy-page .policy-summary p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}
.policy-section {
  margin-bottom: 32px;
}
.policy-section h2 {
  font-size: 1.125rem;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.policy-section ul {
  padding-left: 20px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.policy-section li {
  margin-bottom: 4px;
}

/* Trust page feature grid */
.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.trust-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transform: translateY(0);
  transition: transform var(--transition), box-shadow var(--transition);
}
.trust-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}
.trust-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}
.trust-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}
.trust-card .trust-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}
.trust-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.trust-source-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── Card Enhancement (Phase B) ─────────────────────────── */
.card-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.source-agency {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-key-badge {
  font-size: var(--text-xs);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.api-key-badge.needs-key {
  background: rgba(217, 119, 6, 0.15);
  color: var(--color-warning);
}
.api-key-badge.free {
  background: rgba(22, 163, 74, 0.15);
  color: var(--color-success);
}
.card-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color, var(--border));
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.card-bottom a {
  color: var(--color-primary);
  text-decoration: none;
}
.card-bottom a:hover {
  text-decoration: underline;
}

/* Source Info Grid (detail page) */
.source-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.source-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.source-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.source-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.source-value a {
  color: var(--color-primary);
  text-decoration: none;
}
.source-value a:hover {
  text-decoration: underline;
}

/* Install Tabs */
.install-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.install-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-muted);
  transition: var(--transition);
}
.install-tab:hover {
  color: var(--text-primary);
}
.install-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Frequency Badge */
.freq-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(8, 145, 178, 0.1);
  color: var(--color-info);
}

/* Badge success for open source */
.badge-success {
  background: rgba(22, 163, 74, 0.15);
  color: var(--color-success);
}

