:root {
  --bg: #0f1117;
  --bg-sidebar: #161822;
  --bg-card: #1c1e2e;
  --bg-input: #252838;
  --bg-hover: #2a2d3f;
  --bg-overlay: rgba(0,0,0,0.7);
  --text: #e0e0e0;
  --text-muted: #888;
  --text-bright: #ffffff;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #2e3148;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  --topbar-height: 48px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-bright);
}

#sidebar-nav {
  padding: 12px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.sidebar-link:hover,
.sidebar-link:focus {
  background: var(--bg-hover);
  color: var(--text-bright);
  outline: none;
}

.sidebar-link .icon {
  font-size: 1.2rem;
}

/* Menu toggle */
#menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Main content */
#content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 32px 64px;
  max-width: 960px;
}

.category-section {
  margin-bottom: 40px;
  scroll-margin-top: 20px;
}

.category-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Accordion */
.subcategory-accordion {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.accordion-header:hover {
  background: var(--bg-hover);
}

.accordion-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
}

.accordion-header .arrow {
  font-size: 0.8rem;
  transition: transform var(--transition);
}

.subcategory-accordion.open .accordion-header .arrow {
  transform: rotate(90deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.subcategory-accordion.open .accordion-body {
  max-height: 5000px;
}

.resources-list {
  padding: 8px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Resource card */
.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color var(--transition);
}

.resource-card:hover {
  border-color: var(--accent);
}

.resource-card .resource-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

.resource-card .resource-title:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.resource-card .resource-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* YouTube click-to-load */
.yt-placeholder {
  margin-top: 10px;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16/9;
  background: #000;
}

.yt-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.yt-placeholder .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  transition: background var(--transition);
}

.yt-placeholder:hover .play-overlay {
  background: rgba(0,0,0,0.5);
}

.yt-placeholder .play-btn {
  width: 48px;
  height: 48px;
  background: rgba(255,0,0,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.yt-placeholder:hover .play-btn {
  transform: scale(1.1);
}

.yt-placeholder .play-btn::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 16px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 2px;
}

.yt-placeholder iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Modal overlay (shared) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

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

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }

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

  #menu-toggle {
    display: flex;
  }

  #content {
    margin-left: 0;
    padding: 56px 16px 32px;
  }

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

  .modal-content {
    min-width: auto;
    width: 95vw;
  }
}
