/* ── variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #07080b;
  --surface:   #0d0f14;
  --surface2:  #13151c;
  --border:    #1c1f2a;
  --border2:   #252836;
  --accent:    #f59e0b;
  --accent-lo: rgba(245,158,11,0.12);
  --accent-md: rgba(245,158,11,0.25);
  --blue:      #60a5fa;
  --blue-lo:   rgba(96,165,250,0.12);
  --green:     #34d399;
  --green-lo:  rgba(52,211,153,0.12);
  --red:       #f87171;
  --red-lo:    rgba(248,113,113,0.12);
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #475569;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Plus Jakarta Sans', sans-serif;
  --serif:     'Fraunces', serif;
}

/* ── light theme override (Feature 1) ──────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f8f9fc;
  --surface:   #ffffff;
  --surface2:  #f1f3f7;
  --border:    #e2e5ef;
  --border2:   #d0d5e3;
  --accent:    #d97706;
  --accent-lo: rgba(217,119,6,0.10);
  --accent-md: rgba(217,119,6,0.22);
  --blue:      #2563eb;
  --blue-lo:   rgba(37,99,235,0.10);
  --green:     #059669;
  --green-lo:  rgba(5,150,105,0.10);
  --red:       #dc2626;
  --red-lo:    rgba(220,38,38,0.10);
  --text:      #111827;
  --text2:     #374151;
  --text3:     #9ca3af;
}

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

/* ── base ───────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* noise texture overlay — z-index kept below modals (300) and dropdowns (200) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 50;
  opacity: 0.4;
}

/* ── header ─────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,8,11,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
}

/* ── wordmark ───────────────────────────────────────────────────────────────── */
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

.wordmark-cite {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.wordmark-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.wordmark-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-left: 2px;
}

/* ── nav tabs ───────────────────────────────────────────────────────────────── */
nav.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text2); background: var(--surface2); }

.tab-btn.active {
  color: var(--accent);
  background: var(--accent-lo);
}

.tab-btn i { font-size: 12px; }

/* ── status dot ─────────────────────────────────────────────────────────────── */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.3s;
}

.status-dot.ok    { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-green 2s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ── main layout ────────────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── section typography ─────────────────────────────────────────────────────── */
.section-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.section-sub {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 28px;
}

/* ── cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* ── search ─────────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder { color: var(--text3); }

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

.search-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ── saved searches dropdown (Feature 19) ─────────────────────────────────── */
.saved-searches-wrap {
  position: relative;
}

.saved-searches-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  overflow: hidden;
}

.saved-searches-dropdown.open { display: block; }

.saved-search-empty {
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}

.saved-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.saved-search-item:last-child { border-bottom: none; }
.saved-search-item:hover { background: var(--surface2); }

.saved-search-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-search-meta {
  font-size: 10px;
  color: var(--text3);
  flex-shrink: 0;
}

.saved-search-del {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.12s;
}

.saved-search-del:hover { color: var(--red); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text2);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--accent);
  color: var(--text);
}

/* ── buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  border: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #fbbf24; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}

.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── result cards ───────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}

.result-card:hover { border-color: var(--border2); background: var(--surface2); }

.result-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.result-authors {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
}

.result-meta { display: flex; gap: 12px; flex-wrap: wrap; }

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 400;
}

.chip-type   { background: var(--blue-lo);   color: var(--blue);   }
.chip-year   { background: var(--surface2);  color: var(--text3);  }
.chip-doi    { background: var(--accent-lo); color: var(--accent); }
.chip-score  { background: var(--green-lo);  color: var(--green);  }
.chip-signed { background: var(--green-lo);  color: var(--green);  }
.chip-repo   { background: var(--surface2);  color: var(--text3);  }

/* ── stat cards ─────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  font-family: var(--mono);
}

.stat-value {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-value.accent { color: var(--accent); }
.stat-value.blue   { color: var(--blue); }
.stat-value.green  { color: var(--green); }

/* ── repo cards ─────────────────────────────────────────────────────────────── */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.repo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: border-color 0.15s;
}

.repo-card:hover { border-color: var(--border2); }

.repo-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.repo-desc {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 14px;
  line-height: 1.5;
  min-height: 18px;
}

.repo-stats { display: flex; gap: 16px; }

.repo-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
}

.repo-stat i { font-size: 10px; }

.vis-badge {
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vis-public   { background: var(--green-lo); color: var(--green); }
.vis-private  { background: var(--red-lo);   color: var(--red);   }
.vis-internal { background: var(--blue-lo);  color: var(--blue);  }

/* ── activity feed ──────────────────────────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 0; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  animation: slide-in 0.3s ease both;
}

.activity-item:last-child { border-bottom: none; }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.icon-push    { background: var(--accent-lo); color: var(--accent); }
.icon-pull    { background: var(--blue-lo);   color: var(--blue);   }
.icon-create  { background: var(--green-lo);  color: var(--green);  }
.icon-delete  { background: var(--red-lo);    color: var(--red);    }
.icon-default { background: var(--surface2);  color: var(--text3);  }

.activity-body { flex: 1; min-width: 0; }

.activity-main {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}

.activity-main strong { color: var(--accent); font-weight: 500; }
.activity-main code   { font-family: var(--mono); font-size: 12px; color: var(--blue); }

.activity-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
}

/* ── identity ───────────────────────────────────────────────────────────────── */
.field-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
  font-family: var(--mono);
}

.verify-result {
  border-radius: 8px;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 13px;
  display: none;
  margin-top: 12px;
}

.verify-result.valid   { background: var(--green-lo); border: 1px solid var(--green); color: var(--green); }
.verify-result.invalid { background: var(--red-lo);   border: 1px solid var(--red);   color: var(--red);   }

/* ── data table ─────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}

.data-table td:first-child { color: var(--text); }
.data-table tr:hover td    { background: var(--surface2); }

.data-table .mono-cell {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
}

/* ── layout helpers ─────────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

/* ── empty / loading states ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}

.empty-state i {
  font-size: 28px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}

.empty-state p { font-size: 13px; }

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── bar chart ──────────────────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }

.bar-row { display: flex; align-items: center; gap: 10px; }

.bar-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  width: 70px;
  flex-shrink: 0;
  text-align: right;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.bar-fill.blue { background: var(--blue); }

.bar-val {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  width: 36px;
  text-align: right;
}

/* ── mode tabs ──────────────────────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
}

.mode-tab {
  padding: 5px 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.mode-tab.active { background: var(--accent); color: #000; }
.mode-tab:hover:not(.active) { color: var(--text2); background: var(--surface2); }

/* ── scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
