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

:root {
  --bg: #07070f;
  --surface: #0d0d1c;
  --card: #111121;
  --card-hover: #161628;
  --border: #1e1e38;
  --border-bright: #2a2a50;
  --accent: #b2ff59;
  --accent-dim: rgba(178,255,89,0.12);
  --accent-dim2: rgba(178,255,89,0.06);
  --blue: #5b8fff;
  --blue-dim: rgba(91,143,255,0.12);
  --pink: #ff6eb4;
  --text: #ddddf5;
  --text-muted: #7777a0;
  --text-faint: #44445a;
  --mono: 'Space Mono', monospace;
  --sans: 'Syne', sans-serif;
  --radius: 10px;
  --radius-lg: 16px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise overlay */
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='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* Grid background */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,7,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-logo {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.nav-logo svg { width: 22px; height: 22px; }

.nav-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.nav-breadcrumb .crumb {
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
}
.nav-breadcrumb .crumb:hover { color: var(--text); }
.nav-breadcrumb .sep { color: var(--text-faint); }
.nav-breadcrumb .current { color: var(--text); }

/* ── MAIN WRAPPER ── */
main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

/* ── PAGES ── */
.page { display: none; animation: fadeUp 0.3s ease both; }
.page.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HERO ── */
.hero {
  padding: 4rem 0 3rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim2);
  border: 1px solid rgba(178,255,89,0.2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 1rem;
}

.hero h1 span { color: var(--accent); }

.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
  font-family: var(--mono);
  font-size: 0.82rem;
}

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.7rem;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-dim2);
  border: 1px solid rgba(178,255,89,0.15);
  padding: 2px 10px;
  border-radius: 100px;
}

/* ── REPO GRID ── */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.repo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.repo-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.repo-card:hover {
  border-color: var(--border-bright);
  background: var(--card-hover);
  transform: translateY(-2px);
}
.repo-card:hover::before { opacity: 1; }

.repo-card-icon {
  width: 44px; height: 44px;
  background: var(--accent-dim);
  border: 1px solid rgba(178,255,89,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.repo-card-author {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.repo-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.repo-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.repo-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.repo-arrow {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 1.2rem;
  transition: transform 0.2s, color 0.2s;
}
.repo-card:hover .repo-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

/* ── SEARCH BAR ── */
.search-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input::placeholder { color: var(--text-faint); }
#search-input:focus {
  border-color: var(--border-bright);
  box-shadow: 0 0 0 3px rgba(178,255,89,0.08);
}

/* ── APP GRID ── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-card:hover {
  border-color: var(--border-bright);
  background: var(--card-hover);
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.app-icon {
  width: 38px; height: 38px;
  flex-shrink: 0;
  background: var(--blue-dim);
  border: 1px solid rgba(91,143,255,0.2);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.app-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.3;
}

.app-version {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  background: var(--accent-dim2);
  border: 1px solid rgba(178,255,89,0.12);
  padding: 2px 7px;
  border-radius: 5px;
  display: inline-block;
  margin-top: 3px;
}

.app-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.app-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.app-detail-label {
  color: var(--text-faint);
  flex-shrink: 0;
  width: 60px;
  padding-top: 1px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-detail-value {
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.4;
}

.app-detail-value.pkg { color: var(--blue); }

.app-divider {
  height: 1px;
  background: var(--border);
}

.app-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 6px 12px;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }

.btn-obtainium {
  background: var(--accent);
  color: #07070f;
}
.btn-obtainium:hover { opacity: 0.88; }

.btn-copy {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
}
.btn-copy:hover { background: var(--card-hover); color: var(--text); }
.btn-copy.copied {
  background: rgba(91,143,255,0.12);
  color: var(--blue);
  border-color: rgba(91,143,255,0.25);
}

.btn-store {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
}
.btn-store:hover { background: var(--card-hover); color: var(--text); }

.btn-github {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
  margin-left: auto;
}
.btn-github:hover { background: var(--card-hover); color: var(--text); }

/* ── LOADING ── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem;
  flex-direction: column;
  gap: 1rem;
}

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

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

.loader-text {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

/* ── REPO PAGE HEADER ── */
.repo-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.repo-header-author {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.repo-header-name {
  font-weight: 800;
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.repo-header-stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-pill strong { color: var(--text); }

/* ── FILTER CHIPS ── */
.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.chip {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
}

.chip:hover, .chip.active {
  background: var(--accent-dim);
  border-color: rgba(178,255,89,0.3);
  color: var(--accent);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-icon { color: var(--accent); }

/* ── ERROR ── */
.error-msg {
  background: rgba(255,80,80,0.08);
  border: 1px solid rgba(255,80,80,0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #ff8080;
  margin: 1rem 0;
}

/* ── MISC ── */
.hidden { display: none !important; }

@media (max-width: 600px) {
  nav { padding: 0 1rem; }
  main { padding: 0 1rem 4rem; }
  .repo-grid { grid-template-columns: 1fr; }
  .app-grid { grid-template-columns: 1fr; }
}