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

/* ── Theme tokens (unicorn gradient) ── */
:root {
  --background: 270 30% 98%;
  --foreground: 260 20% 10%;
  --card: 0 0% 100%;
  --card-foreground: 260 20% 10%;
  --primary: 270 60% 55%;
  --primary-foreground: 0 0% 100%;
  --muted: 270 20% 94%;
  --muted-foreground: 260 10% 50%;
  --accent: 270 30% 92%;
  --accent-foreground: 260 20% 10%;
  --border: 270 15% 88%;
  --input: 270 15% 88%;
  --ring: 270 60% 55%;
  --radius: 0.75rem;
  --sidebar-bg: linear-gradient(180deg, #f5f0ff 0%, #fef0f7 50%, #fff8f0 100%);
  --sidebar-bg-flat: #f5f0ff;
  --sidebar-width: 270px;
  --gradient-1: #8b5cf6;
  --gradient-2: #ec4899;
  --gradient-3: #f59e0b;
  --gradient-4: #06b6d4;
}

.dark {
  --background: 260 30% 6%;
  --foreground: 270 20% 92%;
  --card: 260 30% 9%;
  --card-foreground: 270 20% 92%;
  --primary: 270 60% 65%;
  --primary-foreground: 260 30% 6%;
  --muted: 260 20% 14%;
  --muted-foreground: 260 15% 55%;
  --accent: 260 20% 16%;
  --accent-foreground: 270 20% 92%;
  --border: 260 20% 16%;
  --input: 260 20% 16%;
  --ring: 270 60% 65%;
  --sidebar-bg: linear-gradient(180deg, #1a1028 0%, #1e0f20 50%, #1a1510 100%);
  --sidebar-bg-flat: #1a1028;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ── */
.page {
  background: hsl(var(--background));
  min-height: 100vh;
  transition: background-color 0.2s;
}

.layout {
  display: grid;
  width: 100%;
  max-width: 97rem;
  margin: 0 auto;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  position: relative;
  display: flex;
  justify-content: flex-end;
  border-right: 1px solid hsl(var(--border));
  background: var(--sidebar-bg);
  min-height: 100vh;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -100vw;
  background: var(--sidebar-bg-flat);
  z-index: -1;
}

.sidebar-inner {
  width: var(--sidebar-width);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-github {
  color: hsl(var(--muted-foreground));
  transition: color 0.15s;
}

.sidebar-github:hover {
  color: hsl(var(--foreground));
}

/* ── Search ── */
.sidebar-search {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

#search,
#search-mobile {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-size: 0.875rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

#search:focus,
#search-mobile:focus {
  border-color: var(--gradient-1);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* ── Nav ── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  padding: 0 0.75rem;
  margin-bottom: 0.25rem;
}

.nav-items {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.1s;
  text-align: left;
  font-family: inherit;
  width: 100%;
}

.nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(236, 72, 153, 0.08));
  color: var(--gradient-1);
  font-weight: 500;
}

.dark .nav-item.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.12));
  color: hsl(270 60% 75%);
}

.nav-item .count {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.icon-moon {
  display: none;
}

.dark .icon-sun {
  display: none;
}

.dark .icon-moon {
  display: block;
}

/* ── Drawer (mobile) ── */
.drawer-trigger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 40;
  padding: 0.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}

.drawer-close:hover {
  color: hsl(var(--foreground));
}

/* ── Main header ── */
.main-header {
  grid-area: header;
  display: flex;
  justify-content: flex-start;
}

.header-content {
  max-width: 900px;
  padding: 2.5rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2), var(--gradient-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.result-count {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.result-count strong {
  font-weight: 500;
  color: hsl(var(--foreground));
}

/* ── Main content ── */
.main-content {
  grid-area: main;
  display: flex;
  justify-content: flex-start;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 900px;
  width: 100%;
  align-content: start;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1280px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Cards ── */
.card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2), var(--gradient-3));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.95);
  transition: all 0.25s ease;
  position: relative;
}

.card:hover {
  box-shadow:
    0 8px 30px rgba(139, 92, 246, 0.25),
    0 4px 12px rgba(236, 72, 153, 0.15);
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.3);
}

.card-header {
  padding: 0.75rem 1rem 0.35rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.card:hover .card-title {
  color: #fff;
}

.card-body {
  padding: 0 1rem;
}

.card-description {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 1rem 0;
  flex: 1;
  align-content: start;
}

.tag {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  margin-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.card-footer-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-footer-item svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* Level badges */
.level-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.level-beginner {
  background: hsl(160 60% 90%);
  color: hsl(160 60% 35%);
}

.level-intermediate {
  background: hsl(40 80% 90%);
  color: hsl(40 80% 35%);
}

.level-advanced {
  background: hsl(0 70% 90%);
  color: hsl(0 70% 40%);
}

.dark .level-beginner {
  background: hsl(160 60% 15%);
  color: hsl(160 60% 65%);
}

.dark .level-intermediate {
  background: hsl(40 60% 15%);
  color: hsl(40 70% 65%);
}

.dark .level-advanced {
  background: hsl(0 50% 15%);
  color: hsl(0 70% 65%);
}

/* ── Empty state ── */
.empty {
  padding: 4rem 1.5rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.95rem;
  width: 100%;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .sidebar {
    display: none;
  }

  .drawer-trigger {
    display: flex;
  }

  .header-content {
    padding: 2.5rem 1.5rem 0;
    padding-top: 4rem;
  }
}

@media (min-width: 1024px) {
  .header-content {
    padding: 2.5rem 3rem 0;
  }

  .card-grid {
    padding: 1.5rem 3rem 3rem;
  }
}
