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

:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #27272a;
  --border: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --beginner: #22c55e;
  --intermediate: #f59e0b;
  --advanced: #ef4444;
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.15);
  --radius: 12px;
  --transition: 0.18s ease;
}

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

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 14, 16, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.1rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}

#search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 36px 8px 12px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}

#search:focus {
  border-color: var(--accent);
}

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

/* ── Hero ── */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 24px 32px;
  text-align: center;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 32px;
}

.level-filter {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Cards ── */
.cards-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.8;
}

.card[data-level="beginner"]::before { background: var(--beginner); }
.card[data-level="intermediate"]::before { background: var(--intermediate); }
.card[data-level="advanced"]::before { background: var(--advanced); }

.card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-order {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.level-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.level-badge.beginner { background: rgba(34,197,94,0.15); color: var(--beginner); }
.level-badge.intermediate { background: rgba(245,158,11,0.15); color: var(--intermediate); }
.level-badge.advanced { background: rgba(239,68,68,0.15); color: var(--advanced); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.card-summary {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.card-duration {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 64px 0;
  font-size: 1rem;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 780px;
  padding: 40px 48px;
  position: relative;
  margin: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ── Markdown styles ── */
.modal-content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.modal-content h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--accent);
}

.modal-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.7;
}

.modal-content strong { color: var(--text); }

.modal-content code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', 'SF Mono', monospace;
  font-size: 0.85em;
  color: #e2e8f0;
}

.modal-content pre {
  background: #0d0d0f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
}

.modal-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.modal-content ul, .modal-content ol {
  padding-left: 20px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-content li { margin-bottom: 4px; }

.modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.875rem;
}

.modal-content th {
  background: var(--surface-2);
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

.modal-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.modal-content td:first-child { color: var(--text); }

.modal-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.modal-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  background: var(--accent-glow);
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  color: var(--text-muted);
}

.modal-content a { color: var(--accent); text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.6rem; }
  .modal { padding: 28px 20px; }
  .card-grid { grid-template-columns: 1fr; }
}
