:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-2: #191923;
  --border: #23232e;
  --border-strong: #333340;
  --text: #ececf1;
  --text-2: #a3a3b2;
  --text-3: #6b6b7c;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --accent-dim: rgba(124, 92, 255, 0.14);
  --badge: #fbbf24;
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 272px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-2);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(124, 92, 255, 0.5);
}

.topbar-count {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}

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

/* ---------- Search ---------- */

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
}

.search input {
  width: 100%;
  height: 36px;
  padding: 0 42px 0 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-family: inherit;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--surface-2);
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(420px, 60vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  z-index: 60;
}

.sres {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 9px 10px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.sres:hover,
.sres.active {
  background: var(--surface);
}

.sres-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sres-name {
  font-size: 14px;
  font-weight: 600;
}

.sres-name mark {
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
}

.sres-badge {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--badge);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 1px 6px;
  border-radius: 999px;
}

.sres-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.sres-desc {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sres-empty {
  padding: 16px 12px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

/* ---------- Layout ---------- */

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px 12px 48px;
  z-index: 60;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 45;
}

.view {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 32px) clamp(16px, 4vw, 48px) 96px;
  max-width: 1200px;
}

/* ---------- Sidebar nav ---------- */

.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 16px 10px 6px;
}

.nav-section:first-child {
  padding-top: 4px;
}

.nav-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-cat.nested {
  padding-left: 20px;
}

.nav-cat:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-cat.active {
  background: var(--accent-dim);
  color: #fff;
}

.nav-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 17px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nav-cat.active .nav-count {
  color: var(--accent-2);
  border-color: rgba(124, 92, 255, 0.4);
  background: transparent;
}

/* ---------- Page header ---------- */

.page-header {
  margin-bottom: 24px;
}

.crumb {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.page-title {
  font-size: 30px;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}

.page-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- Cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

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

.badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--badge);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

.pill {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.pill:hover {
  color: var(--accent-2);
  border-color: rgba(124, 92, 255, 0.5);
  background: rgba(124, 92, 255, 0.08);
}

.card.flash {
  animation: flash 1.4s ease;
}

@keyframes flash {
  0% {
    background: rgba(124, 92, 255, 0.22);
    border-color: var(--accent);
  }
  60% {
    background: rgba(124, 92, 255, 0.1);
  }
  100% {
    background: var(--surface);
    border-color: var(--border);
  }
}

/* ---------- Skeleton ---------- */

.sk-card {
  height: 128px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.sk-nav-line {
  height: 20px;
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}

.sk-nav-section {
  height: 12px;
  width: 45%;
  border-radius: 4px;
  background: var(--surface);
  margin: 16px 10px 10px;
  position: relative;
  overflow: hidden;
}

.sk-card::after,
.sk-nav-line::after,
.sk-nav-section::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* ---------- Error ---------- */

.error {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-2);
}

.error h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 20px;
}

.error p {
  margin: 0 0 20px;
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ---------- Scrollbars ---------- */

.sidebar::-webkit-scrollbar,
.search-dropdown::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.search-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.5);
  }

  .view {
    margin-left: 0;
  }

  .menu-btn {
    display: inline-flex;
  }

  .topbar-count {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand-name {
    display: none;
  }

  .search-kbd {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 24px;
  }
}
