/* ── Dracula Palette (dark, default) ─────────────────────── */
:root,
:root[data-theme="dark"] {
  --bg:       #282a36;
  --surface:  #21222c;
  --card:     #2d2f3f;
  --line:     #44475a;
  --fg:       #f8f8f2;
  --comment:  #6272a4;
  --cyan:     #8be9fd;
  --green:    #50fa7b;
  --orange:   #ffb86c;
  --pink:     #ff79c6;
  --purple:   #bd93f9;
  --red:      #ff5555;
  --yellow:   #f1fa8c;
}

/* ── Light Palette ───────────────────────────────────────── */
:root[data-theme="light"] {
  --bg:       #fafafa;
  --surface:  #ffffff;
  --card:     #ffffff;
  --line:     #e2e4ea;
  --fg:       #1f2230;
  --comment:  #6b7280;
  --cyan:     #0e7490;
  --green:    #15803d;
  --orange:   #b45309;
  --pink:     #be185d;
  --purple:   #6d28d9;
  --red:      #b91c1c;
  --yellow:   #a16207;
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--cyan); text-decoration: none; transition: color .2s; }
a:hover { color: var(--purple); }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }

/* ── Nav ─────────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
}
.nav-brand {
  color: var(--purple);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.nav-links {
  display: flex;
  gap: 1.6rem;
  list-style: none;
}
.nav-links a {
  color: var(--fg);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .3px;
}
.nav-links a:hover { color: var(--cyan); }

/* ── Layout ──────────────────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
section { padding: 72px 0; }
section + section { border-top: 1px solid var(--line); }

/* ── Section Headings ────────────────────────────────────── */
.section-title {
  font-size: 1.6rem;
  color: var(--purple);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Hero ────────────────────────────────────────────────── */
#hero { padding-top: 96px; padding-bottom: 96px; }
.course-hero { text-align: center; }
.course-title { font-size: 3rem; color: var(--fg); margin-bottom: .4rem; }
.course-title span { color: var(--purple); }
.course-subtitle {
  color: var(--orange);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .4px;
  margin-bottom: 1rem;
}
.course-desc {
  color: var(--comment);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto 1.8rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .9rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: all .2s;
  white-space: nowrap;
  cursor: pointer;
}
.btn-github { border-color: var(--cyan); color: var(--cyan); }
.btn-github:hover { background: var(--line); color: var(--fg); border-color: var(--fg); }
.btn-pdf { border-color: var(--cyan); color: var(--cyan); }
.btn-pdf:hover { background: var(--line); color: var(--fg); border-color: var(--fg); }
.btn-video {
  border-color: var(--line);
  color: var(--comment);
  background: transparent;
  cursor: not-allowed;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
}

/* ── Theme Toggle ────────────────────────────────────────── */
.theme-toggle {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  font-family: inherit;
}
.theme-toggle:hover { background: var(--line); border-color: var(--fg); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  padding: .15rem .55rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-lista  { background: rgba(255,184,108,.15); color: var(--orange); }
.badge-lab    { background: rgba(139,233,253,.15);  color: var(--cyan); }

/* ── Unit Headers ────────────────────────────────────────── */
.unit-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 2.5rem 0 .75rem;
}
.unit-header:first-child { margin-top: 0; }
.unit-num {
  color: var(--purple);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
.unit-name { color: var(--fg); font-size: .97rem; font-weight: 700; }
.unit-header::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Lecture Cards ───────────────────────────────────────── */
.lecture-list { display: flex; flex-direction: column; gap: .65rem; }
.lecture-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
  border-radius: 8px;
  padding: .85rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: border-left-color .2s, transform .2s;
}
.lecture-card:hover { border-left-color: var(--cyan); transform: translateX(3px); }
.lecture-info { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.lecture-num {
  color: var(--comment);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.lecture-title { font-size: .95rem; font-weight: 600; color: var(--fg); }
.lecture-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ── Inline Exercises ────────────────────────────────────── */
.lecture-exercises {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .55rem;
  padding-top: .7rem;
  margin-top: .1rem;
  border-top: 1px dashed var(--line);
}
.exercises-label {
  color: var(--comment);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin-right: .1rem;
}
.exercise-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(68,71,90,.25);
  color: var(--fg);
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.exercise-chip:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(80,250,123,.08);
  transform: translateY(-1px);
}
.chip-lista { border-left: 3px solid var(--orange); }
.chip-lab   { border-left: 3px solid var(--cyan); }
.chip-demo  { border-left: 3px solid var(--purple); }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 2px solid var(--line);
  text-align: center;
  padding: 2rem 1rem;
  font-size: .83rem;
  color: var(--comment);
}
footer span { color: var(--purple); }

/* ── Recommended Reading ─────────────────────────────────── */
.reading-details {
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: 6px;
  background: var(--card);
  margin: 0.4rem 0 1.5rem;
  overflow: hidden;
}
.reading-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--orange);
  list-style: none;
  user-select: none;
}
.reading-summary::-webkit-details-marker { display: none; }
.reading-summary::after {
  content: "▶";
  font-size: .7rem;
  color: var(--comment);
  transition: transform .2s;
}
.reading-details[open] > .reading-summary::after { transform: rotate(90deg); }
.reading-details[open] > .reading-summary { border-bottom: 1px solid var(--line); }
.reading-content {
  padding: .75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.reading-group-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--comment);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 .5rem;
}
.reading-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--fg);
}
.reading-ref { flex: 1; }
.reading-ref a { color: var(--cyan); text-decoration: none; }
.reading-ref a:hover { text-decoration: underline; }
.badge-paper   { background: rgba(189,147,249,.15); color: var(--purple); }
.badge-chapter { background: rgba(255,184,108,.15); color: var(--orange); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 620px) {
  .course-title { font-size: 2.2rem; }
  .nav-links { gap: 1rem; }
  .nav-brand { display: none; }
  .lecture-card { gap: .75rem; }
  .lecture-actions { justify-content: flex-end; width: 100%; }
}
