:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --adopt: #3fb950;
  --trial: #d29922;
  --scout: #58a6ff;
  --hold: #8b949e;
  --q1: #f78166;
  --q2: #d2a8ff;
  --q3: #58a6ff;
  --q4: #3fb950;
}

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

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

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.legend {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ring-badge {
  padding: 0.2rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ring-badge.adopt { background: rgba(63,185,80,0.15); color: var(--adopt); border: 1px solid rgba(63,185,80,0.3); }
.ring-badge.trial { background: rgba(210,153,34,0.15); color: var(--trial); border: 1px solid rgba(210,153,34,0.3); }
.ring-badge.scout { background: rgba(88,166,255,0.15); color: var(--scout); border: 1px solid rgba(88,166,255,0.3); }
.ring-badge.hold  { background: rgba(139,148,158,0.15); color: var(--hold); border: 1px solid rgba(139,148,158,0.3); }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}

/* Radar */
.radar-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

#radar { width: 100%; height: auto; }

.tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 280px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.tooltip.visible { opacity: 1; }
.tooltip .tt-name { font-weight: 700; margin-bottom: 0.25rem; }
.tooltip .tt-desc { color: var(--text-muted); font-size: 0.8rem; }
.tooltip .tt-meta { margin-top: 0.5rem; font-size: 0.75rem; color: var(--text-muted); }

/* Filters */
.filters {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

/* Details Panel */
.details-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  position: relative;
  animation: slideIn 0.2s ease-out;
}

.details-panel.hidden { display: none; }

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

.close-btn {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.details-panel h3 { font-size: 1.2rem; margin-bottom: 0.75rem; }
.details-panel .detail-row { display: flex; gap: 1rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
.details-panel .detail-label { color: var(--text-muted); min-width: 100px; }
.details-panel .detail-value { color: var(--text); }
.details-panel .detail-section { margin-top: 1rem; }
.details-panel .detail-section h4 { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.details-panel .detail-section p { font-size: 0.9rem; }

/* Table */
.table-section { margin-top: 2rem; }
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.table-header h2 { font-size: 1.2rem; margin: 0; }
#search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 260px;
  outline: none;
  transition: border-color 0.2s;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
  white-space: nowrap;
}
th[data-sort]:hover { color: var(--text); }
th.sorted { color: var(--accent); }
.sort-arrow { font-size: 0.7rem; }

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr { cursor: pointer; transition: background 0.1s; }
tr:hover { background: rgba(88,166,255,0.05); }

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

.stars-cell { font-variant-numeric: tabular-nums; }

/* Stats */
.stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.stat-number { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Dot labels */
.dot-label { transition: opacity 0.15s; pointer-events: none; }

/* Ring filter */
.legend .ring-badge { cursor: pointer; transition: opacity 0.15s; }
.legend .ring-badge:hover { opacity: 0.8; }
.legend .ring-badge.ring-inactive { opacity: 0.3; }

/* Signal column */
.signal-cell { font-variant-numeric: tabular-nums; text-align: center; font-weight: 600; line-height: 1.2; }
.coverage-hint { display: block; font-size: 0.65rem; font-weight: 400; color: var(--text-muted); }
.signal-high { color: #e0e0e0; }
.signal-mid { color: #a0a0a0; }
.signal-low { color: #666; }
.signal-none { color: var(--text-muted); }
.signal-meta { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-left: 0.5rem; }

/* Signal bars in detail panel */
.signals-section { margin-top: 1rem; }
.signal-bars { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.75rem 0; }
.signal-bar-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.signal-bar-label { min-width: 110px; color: var(--text-muted); }
.signal-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.signal-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.bar-high { background: #e0e0e0; }
.bar-mid { background: #888; }
.bar-low { background: #555; }
.signal-bar-val { min-width: 24px; text-align: right; font-weight: 600; font-size: 0.75rem; }
.signal-details { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Methodology */
.methodology { margin: 1.5rem 0; }
.methodology summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem 0; }
.methodology summary:hover { color: var(--text); }
.methodology-content { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-top: 0.5rem; font-size: 0.85rem; line-height: 1.7; }
.methodology-content p { margin-bottom: 0.75rem; }
.methodology-content p:last-child { margin-bottom: 0; }
.method-table { width: 100%; margin: 0.75rem 0; font-size: 0.8rem; }
.method-table th { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 0.75rem; }
.method-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
.method-note { color: var(--text-muted); font-size: 0.8rem; font-style: italic; }
.risk-list { margin: 0.5rem 0 0 1.2rem; }
.risk-list li { margin-bottom: 0.5rem; }
.risk-list li:last-child { margin-bottom: 0; }

/* Notable Stargazers */
.notable-list { list-style: none; padding: 0; }
.notable-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.notable-list li:last-child { border-bottom: none; }
.notable-list a { color: var(--accent); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notable-list a:hover { text-decoration: underline; }
.follower-count { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.no-notables { color: var(--text-muted); font-style: italic; }

/* Score Trend Sparkline */
.trend-section { margin-top: 1rem; }
.sparkline-wrap { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }
.sparkline { width: 280px; height: 60px; }
.trend-delta { font-weight: 700; font-size: 0.95rem; }
.trend-up { color: var(--adopt); }
.trend-down { color: #f85149; }
.trend-flat { color: var(--text-muted); }
.trend-range { font-size: 0.75rem; color: var(--text-muted); }

/* Landscape */
.landscape-section { margin-top: 2.5rem; }
.landscape-section h2 { font-size: 1.2rem; margin-bottom: 0.25rem; }
.landscape-intro { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.reason-cell { color: var(--text-muted); font-size: 0.8rem; max-width: 300px; }

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

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

/* Tag filters */
.tag-filters {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.tag-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}
.tag-btn:hover { border-color: var(--accent); color: var(--text); }
.tag-btn.active { background: rgba(88,166,255,0.15); color: var(--accent); border-color: var(--accent); }
.tag-count { opacity: 0.5; font-size: 0.65rem; margin-left: 0.15rem; }

/* Detail tags + related */
.detail-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.25rem; }
.detail-tag {
  background: rgba(88,166,255,0.1);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}
.detail-tag:hover { background: rgba(88,166,255,0.25); }

.related-list { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.25rem; }
.related-entry {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
}
.related-entry:hover { text-decoration: underline; }
.ring-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.ring-dot.adopt { background: var(--adopt); }
.ring-dot.trial { background: var(--trial); }
.ring-dot.scout { background: var(--scout); }
.ring-dot.hold { background: var(--hold); }

/* Status badges */
.status-cell { text-align: center; }
.status-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-in-use { background: rgba(255,255,255,0.1); color: #e0e0e0; border: 1px solid rgba(255,255,255,0.2); }
.status-tested { background: rgba(255,255,255,0.05); color: #a0a0a0; border: 1px solid rgba(255,255,255,0.1); }
.status-evaluated { background: rgba(139,148,158,0.05); color: #666; border: 1px solid rgba(139,148,158,0.1); }

/* Convention badge (instead of score) */
.convention-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Stale warning badge (>90d since last commit) */
.stale-badge {
  font-size: 0.65rem;
  color: #d29922;
  background: rgba(210,153,34,0.1);
  border: 1px solid rgba(210,153,34,0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-left: 0.3rem;
  vertical-align: middle;
}

/* Crypto-Token warning badge */
.crypto-badge {
  font-size: 0.65rem;
  color: #f85149;
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-left: 0.3rem;
  vertical-align: middle;
}

/* Own Project badge */
.own-project-badge {
  font-size: 0.65rem;
  color: var(--trial);
  background: rgba(210,153,34,0.12);
  border: 1px solid rgba(210,153,34,0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-left: 0.3rem;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .stats-section { grid-template-columns: repeat(2, 1fr); }
  .detail-row { flex-direction: column; gap: 0.1rem; }
  .table-section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  #search-input { width: 100%; }
  .table-header { flex-direction: column; align-items: stretch; }
  .filters { gap: 0.3rem; }
  .filter-btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
}
