:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --panel-2: #efede8;
  --text: #17181c;
  --muted: #5d6169;
  --line: #e2dfd8;
  --accent: #1f3b8f;
  --accent-soft: #e3e9fb;
  --beginner: #1d7a4f;
  --beginner-bg: #dff3e8;
  --intermediate: #9a5b00;
  --intermediate-bg: #fbecd2;
  --advanced: #7b2c8f;
  --advanced-bg: #f2e1f6;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 4px 16px rgba(20, 20, 30, .05);
  --radius: 12px;
  --sidebar: 256px;
  --top: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1014; --panel: #17191f; --panel-2: #20232b; --text: #eceef2; --muted: #a1a6b0; --line: #2a2e37;
    --accent: #8fb0ff; --accent-soft: #1d2747; --beginner: #6fd6a2; --beginner-bg: #143225;
    --intermediate: #f3bd6b; --intermediate-bg: #3a2a10; --advanced: #dd9cf0; --advanced-bg: #3a1d44;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1014; --panel: #17191f; --panel-2: #20232b; --text: #eceef2; --muted: #a1a6b0; --line: #2a2e37;
  --accent: #8fb0ff; --accent-soft: #1d2747; --beginner: #6fd6a2; --beginner-bg: #143225;
  --intermediate: #f3bd6b; --intermediate-bg: #3a2a10; --advanced: #dd9cf0; --advanced-bg: #3a1d44;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn svg, .search svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; flex: none; }
.brand:hover { color: inherit; }
.logo { width: 28px; height: 28px; fill: var(--accent); }
.brand-name { font-size: 17px; white-space: nowrap; }
.search { flex: 1; max-width: 620px; margin: 0 auto; display: flex; }
.search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-right: 0;
  border-radius: 20px 0 0 20px; background: var(--panel);
}
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  width: 60px; border: 1px solid var(--line); border-radius: 0 20px 20px 0; background: var(--panel-2); cursor: pointer;
  display: grid; place-items: center;
}

/* ---------- layout ---------- */
.layout { display: flex; }
.sidebar {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); width: var(--sidebar); flex: none;
  overflow-y: auto; padding: 12px 10px 40px; border-right: 1px solid var(--line);
}
.sidebar h4 { margin: 18px 12px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-link {
  display: flex; align-items: flex-start; gap: 10px; padding: 7px 12px; border-radius: 10px; font-size: 14px;
  line-height: 1.35;
}
.nav-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.nav-link .nav-dot { margin-top: 6px; }
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .count { flex: none; color: var(--muted); font-size: 12px; font-weight: 400; padding-top: 1px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .5; flex: none; }
main { flex: 1; min-width: 0; padding: 20px 28px 80px; }
.scrim { display: none; }

@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: var(--top); z-index: 30; background: var(--bg); transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0,0,0,.35); z-index: 25; }
  main { padding: 16px 14px 60px; }
  .brand-name { display: none; }
}
@media (min-width: 961px) {
  body.nav-collapsed .sidebar { display: none; }
}

/* ---------- chips & toolbar ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 8px; border: 0; background: var(--panel-2); cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip:hover { filter: brightness(.96); }
.chip.on { background: var(--text); color: var(--bg); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 18px; }
.toolbar select {
  height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
.toolbar .result-count { margin-left: auto; color: var(--muted); font-size: 13px; }
.clear-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0 4px; }

/* ---------- video grid ---------- */
.grid { display: grid; gap: 28px 18px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, var(--accent-soft), var(--panel-2));
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.card:hover .thumb img { transform: scale(1.03); }
.thumb.noimg img { display: none; }
.thumb .ph { position: absolute; inset: 0; display: none; place-items: center; padding: 14px; text-align: center; font-weight: 700; color: var(--accent); font-size: 15px; }
.thumb.noimg .ph { display: grid; }
.badge-dur {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.82); color: #fff; font-size: 12px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
}
.badge-course {
  position: absolute; inset: 0 0 0 auto; width: 38%; background: rgba(10,12,20,.78); color: #fff; display: grid;
  place-content: center; text-align: center; font-weight: 700; font-size: 13px; gap: 2px;
}
.badge-course b { font-size: 22px; }
.stack::before, .stack::after {
  content: ""; position: absolute; left: 6%; right: 6%; height: 6px; border-radius: 8px 8px 0 0; background: var(--line);
}
.stack { position: relative; margin-top: 8px; }
.stack::before { top: -8px; left: 10%; right: 10%; opacity: .6; }
.stack::after { top: -4px; }
.meta { display: flex; gap: 12px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.meta-text { min-width: 0; }
.title {
  margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sub a:hover { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted);
  white-space: nowrap;
}
a.tag:hover { color: var(--text); }
.lv-beginner { background: var(--beginner-bg); color: var(--beginner); }
.lv-intermediate { background: var(--intermediate-bg); color: var(--intermediate); }
.lv-advanced { background: var(--advanced-bg); color: var(--advanced); }
.q {
  font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.sentinel { height: 1px; }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; }
.banner {
  background: var(--intermediate-bg); color: var(--intermediate); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px;
}

/* ---------- headings / hero ---------- */
.page-head { margin: 4px 0 18px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; line-height: 1.2; }
.page-head p { margin: 0; color: var(--muted); max-width: 760px; }
.section-title { font-size: 18px; margin: 32px 0 14px; letter-spacing: -.01em; }
.hero {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; padding: 22px; border-radius: 18px; margin-bottom: 22px;
  background: linear-gradient(120deg, var(--accent-soft), var(--panel)); border: 1px solid var(--line);
}
.hero h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; line-height: 1.15; }
.hero p { margin: 0 0 14px; color: var(--muted); }
.hero .stats { display: flex; gap: 22px; flex-wrap: wrap; }
.hero .stats div { font-size: 13px; color: var(--muted); }
.hero .stats b { display: block; font-size: 22px; color: var(--text); }
.hero-roads { display: grid; gap: 8px; }
.road-mini { display: block; padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.road-mini b { display: block; font-size: 14px; }
.road-mini span { font-size: 12.5px; color: var(--muted); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }

/* ---------- learning paths ---------- */
.topic-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.topic-card {
  display: block; padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.topic-card h3 { margin: 0 0 4px; font-size: 16px; }
.topic-card p { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.topic-card .sub { font-size: 12.5px; }
.roadmap { padding: 16px 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 14px; }
.roadmap h3 { margin: 0 0 2px; font-size: 16px; }
.roadmap p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.road { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.road a { padding: 6px 12px; border-radius: 999px; background: var(--panel-2); font-size: 13.5px; font-weight: 600; }
.road a:hover { background: var(--accent-soft); }
.road .arrow { color: var(--muted); font-size: 13px; }
.prereq { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.prereq a { color: var(--accent); font-weight: 600; }
.stage { position: relative; margin: 26px 0 8px; padding-left: 34px; }
.stage::before { content: ""; position: absolute; left: 8px; top: 30px; bottom: -14px; width: 2px; background: var(--line); }
.stage:last-of-type::before { display: none; }
.stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stage-head::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 4px solid currentColor;
}
.stage-head h2 { margin: 0; font-size: 19px; }
.stage-head .hint { color: var(--muted); font-size: 13px; }
.stage.beginner { color: var(--beginner); } .stage.intermediate { color: var(--intermediate); } .stage.advanced { color: var(--advanced); }
.stage-head h2, .stage .grid { color: var(--text); }
.step-num {
  position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.8); color: #fff; font-weight: 700; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; z-index: 2;
}

/* ---------- watch page ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; }
@media (max-width: 1200px) { .watch { grid-template-columns: 1fr; } }
.player { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; position: relative; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.player .play-cover { position: absolute; inset: 0; border: 0; padding: 0; cursor: pointer; background: #000; }
.player .play-cover img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.player .play-cover span {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 74px; height: 52px; border-radius: 14px;
  background: rgba(0,0,0,.75); display: grid; place-items: center;
}
.player .play-cover span::after { content: ""; border-left: 20px solid #fff; border-top: 12px solid transparent; border-bottom: 12px solid transparent; margin-left: 5px; }
.player .play-cover:hover span { background: var(--accent); }
.watch h1 { font-size: 20px; margin: 14px 0 6px; line-height: 1.3; letter-spacing: -.01em; }
.watch-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; color: var(--muted); font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--panel-2);
  font-weight: 600; font-size: 14px; border: 0; cursor: pointer;
}
.btn.primary { background: var(--text); color: var(--bg); }
.btn.primary:hover { color: var(--bg); opacity: .9; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; }
.box h3 { margin: 0 0 8px; font-size: 14px; }
.box p { margin: 6px 0; font-size: 14px; }
.why li { font-size: 13.5px; margin: 3px 0; }
.why ul { margin: 0; padding-left: 18px; }
.bars { display: grid; grid-template-columns: 110px 1fr 34px; gap: 6px 10px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.desc { white-space: pre-line; color: var(--muted); font-size: 14px; }
.side-list { display: grid; gap: 10px; }
.side-item { display: grid; grid-template-columns: 168px 1fr; gap: 10px; align-items: start; }
.side-item .thumb { border-radius: 8px; }
.side-item .title { font-size: 14px; }
.side-item.current { background: var(--accent-soft); border-radius: 10px; padding: 4px; margin: -4px; }
.next-step { border: 2px solid var(--accent); }
.course-list { counter-reset: lec; display: grid; gap: 12px; }
.course-row { display: grid; grid-template-columns: 34px 200px 1fr; gap: 14px; align-items: center; }
.course-row .n { color: var(--muted); font-weight: 700; text-align: right; }
@media (max-width: 640px) { .course-row { grid-template-columns: 26px 120px 1fr; gap: 10px; } .side-item { grid-template-columns: 140px 1fr; } }
.about { max-width: 820px; }
.about h2 { font-size: 18px; margin-top: 28px; }
.about table { border-collapse: collapse; width: 100%; font-size: 14px; }
.about td, .about th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
footer.site { color: var(--muted); font-size: 12.5px; margin-top: 48px; }
.player > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { overflow: hidden; }
.side-item .thumb .ph, .course-row .thumb .ph { font-size: 11.5px; padding: 8px; line-height: 1.3; }
.search { min-width: 0; }
.roadmap { scroll-margin-top: calc(var(--top) + 12px); }
@media (max-width: 600px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .search button { width: 44px; }
  .search input { padding: 0 12px; }
  .hero { padding: 16px; }
  .hero h1 { font-size: 22px; }
  .hero-roads .road-mini { display: none; }
  .grid { grid-template-columns: 1fr; }
}

/* ---------- watch history ---------- */
.prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.35); z-index: 2; }
.prog i { display: block; height: 100%; background: #e5372b; }
.thumb .badge-dur { z-index: 3; }
.prog ~ .badge-dur, .badge-dur:has(~ .prog) { bottom: 10px; }
.badge-watched {
  position: absolute; right: 8px; top: 8px; z-index: 3; background: rgba(0,0,0,.82); color: #fff; font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.card.watched .thumb img, .side-item.watched .thumb img, .course-row.watched .thumb img { opacity: .55; }
.course-row.watched .n { color: var(--beginner); }
.watch-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 2px; font-size: 14px; }
.ws { font-weight: 600; }
.ws.done { color: var(--beginner); }
.ws.muted { color: var(--muted); font-weight: 400; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.danger { background: #c62828; color: #fff; }
label.btn { cursor: pointer; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.path-progress { display: grid; grid-template-columns: auto minmax(120px, 320px); gap: 12px; align-items: center; margin-top: 12px; font-size: 14px; }
.path-progress .bar i { background: var(--beginner); }
.stage-done { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--beginner); }
.hist-stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 6px 0 4px; }
.hist-stats div { font-size: 13px; color: var(--muted); }
.hist-stats b { display: block; font-size: 24px; color: var(--text); }
.section-title .clear-btn { font-size: 13px; font-weight: 500; margin-left: 8px; }

/* ---------- resources & papers ---------- */
.tag.res { background: var(--accent-soft); color: var(--accent); }
.resources .res-group { margin-top: 8px; font-size: 14px; }
.resources ul { margin: 4px 0 0; padding-left: 20px; }
.resources li { margin: 3px 0; }
.resources li a { color: var(--accent); font-weight: 500; }
.paper { padding: 10px 0; border-top: 1px solid var(--line); }
.box .paper:first-of-type { border-top: 0; }
.paper-list .paper { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.paper-title { font-weight: 700; font-size: 15px; color: var(--text); }
.paper-title:hover { color: var(--accent); }
.paper-tl { margin: 6px 0; font-size: 14px; color: var(--muted); }
.paper-links { display: flex; gap: 14px; font-size: 13px; margin: 4px 0; }
.paper-links a { color: var(--accent); font-weight: 600; }
.paper .sub a { color: var(--accent); }
.inline-link { color: var(--accent); font-weight: 600; }

/* ---------- core path ---------- */
.core-note { margin: 8px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 14px; max-width: 900px; }
.concepts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.concept { font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.concept i { font-style: normal; color: var(--muted); font-weight: 700; margin-left: 2px; }
.concept.learned { background: var(--beginner-bg); border-color: transparent; color: var(--beginner); }
.concept.gap { border-style: dashed; color: var(--muted); font-weight: 500; }
.concept.gap:hover { color: var(--accent); }
.covers { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
details.more { margin: 18px 0 4px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px; margin-bottom: 14px; }

/* ---------- topic multi-select & dynamic channels ---------- */
details.multi { position: relative; }
details.multi > summary {
  list-style: none; height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; font-weight: 600; max-width: 340px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
details.multi > summary::-webkit-details-marker { display: none; }
details.multi > summary::after { content: "▾"; color: var(--muted); font-size: 12px; }
details.multi[open] > summary { border-color: var(--accent); }
.multi-panel {
  position: absolute; z-index: 15; top: 40px; left: 0; width: 340px; max-height: 420px; overflow-y: auto; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.multi-actions { display: flex; justify-content: space-between; padding: 2px 6px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.multi-opt { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.multi-opt:hover { background: var(--panel-2); }
.multi-opt input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.multi-opt span:first-of-type { flex: 1; }
.multi-opt .count { color: var(--muted); font-size: 12px; }
.multi-foot { position: sticky; bottom: -8px; background: var(--panel); padding: 8px 6px 4px; border-top: 1px solid var(--line); margin-top: 4px; text-align: right; }
.nav-link.zero { opacity: .45; }
@media (max-width: 600px) { .multi-panel { width: calc(100vw - 40px); } }
