:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(17, 24, 39, 0.10);
  --shadow: 0 10px 25px rgba(17, 24, 39, 0.08);

  --primary: #2563eb;
  --primaryHover: #1d4ed8;

  --reading: #2563eb;
  --video: #7c3aed;
  --quiz: #059669;
  --doc: #4f46e5;

  --r: 14px;
  --max: 1100px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  background:var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height:1.55;
}

a{color:var(--primary); text-decoration:none}
a:hover{color:var(--primaryHover); text-decoration:underline}
a:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
}

code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: rgba(17, 24, 39, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
}

pre{
  background: rgba(17, 24, 39, 0.06);
  padding: 12px;
  border-radius: 12px;
  overflow:auto;
}

.container{
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 18px 56px;
}

.header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.hgroup h1{
  margin:0;
  font-size: 20px;
  letter-spacing: .2px;
}
.meta{
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.actions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.04);
  color: var(--text);
  text-decoration:none;
}
.btn:hover{
  background: rgba(17, 24, 39, 0.08);
  text-decoration:none;
}
.btn.primary{
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary);
}
.btn.primary:hover{
  background: rgba(37, 99, 235, 0.18);
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.04);
  color: var(--text);
}
.badge.reading{ border-color: rgba(37, 99, 235, 0.35); background: rgba(37, 99, 235, 0.10); color: #1d4ed8; }
.badge.video{ border-color: rgba(124, 58, 237, 0.35); background: rgba(124, 58, 237, 0.10); color: #6d28d9; }
.badge.quiz{ border-color: rgba(5, 150, 105, 0.35); background: rgba(5, 150, 105, 0.10); color: #047857; }
.badge.doc{ border-color: rgba(79, 70, 229, 0.35); background: rgba(79, 70, 229, 0.10); color: #4338ca; }
.badge.unknown{ opacity: .9; }

.grid{ display:grid; gap: 14px; }

/* Overview vertical flow */
.flow{
  position: relative;
  margin-top: 16px;
  padding-left: 22px;
}
.flow::before{
  content:"";
  position:absolute;
  left: 10px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: rgba(17, 24, 39, 0.12);
}

.chapterCard{
  position: relative;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px 16px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}
.chapterCard::before{
  content:"";
  position:absolute;
  left: -18px;
  top: 22px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid rgba(37, 99, 235, 0.75);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.10);
}
.chapterCard::after{
  content:"";
  position:absolute;
  left: -10px;
  top: 27px;
  width: 12px;
  height: 2px;
  background: rgba(17, 24, 39, 0.14);
}
.chapterCard h2{ margin: 0; font-size: 17px; }
.chapterCard .row{ display:flex; justify-content:space-between; gap: 10px; flex-wrap:wrap; align-items:flex-start; }
.chapterCard .summary{ display:flex; gap: 8px; flex-wrap:wrap; margin-top: 10px; }

/* Chapter layout */
.chapterLayout{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin-top: 16px;
}
.sidebar{
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  padding: 14px 14px;
  position: sticky;
  top: 18px;
  height: fit-content;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}
.sidebar h2{
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sidebar .chapterTitle{
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
}
.chapterJump{
  display:none;
  margin: 10px 0 10px;
}
.jumpLabel{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.chapterJump select{
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}
.sidebar .nav{
  list-style:none;
  padding:0;
  margin:0;
  display:grid;
  gap: 8px;
}
.sidebar .nav a{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  padding: 4px 6px;
  border-radius: 10px;
  color: var(--text);
}
.sidebar .nav a:hover{
  background: rgba(17, 24, 39, 0.04);
  text-decoration:none;
}
.sidebar .nav a.is-active{
  background: rgba(37, 99, 235, 0.10);
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.70);
  text-decoration:none;
}
.sidebar .nav a.is-active .label{
  font-weight: 600;
}
.sidebar .nav .label{
  font-size: 13px;
}
.sidebar .pager{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  margin-top: 12px;
}

.main{
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  padding: 18px 18px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}
.chapterHeader{
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: rgba(17, 24, 39, 0.02);
  border-radius: var(--r);
  padding: 14px 14px;
  margin: 0 0 14px;
}
.chapterHeaderRow{
  display:flex;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
  align-items:flex-start;
}
.chapterHeaderKicker{
  color: var(--muted);
  font-size: 13px;
}
.chapterHeaderTitle{
  margin: 6px 0 4px;
  font-size: 18px;
}
.chapterHeaderMeta{
  color: var(--muted);
  font-size: 13px;
}
.chapterHeaderActions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
}
.nodeBlock{
  padding: 14px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.02);
  margin: 0 0 14px;
  scroll-margin-top: 18px;
}
.nodeBlock h3{ margin: 0 0 8px; font-size: 16px; }
.nodeMeta{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  align-items:center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.ctaRow{ display:flex; gap: 10px; flex-wrap:wrap; margin-top: 10px; }
.muted{ color: var(--muted); }
.missing{ color: var(--muted); font-style: italic; }
.backTop{ display:inline-block; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* Markdown content */
.md h1, .md h2, .md h3{ line-height: 1.25; margin: 16px 0 8px; }
.md h1{ font-size: 22px; }
.md h2{ font-size: 18px; }
.md h3{ font-size: 16px; }
.md p{ margin: 0 0 12px; }
.md a{ text-decoration: underline; text-decoration-color: rgba(37, 99, 235, 0.45); text-underline-offset: 2px; }
.md a:hover{ text-decoration-color: rgba(37, 99, 235, 0.85); }
.md code{
  background: rgba(17, 24, 39, 0.06);
  border: 1px solid rgba(17, 24, 39, 0.08);
}
.md pre code{
  border: none;
  background: transparent;
  padding: 0;
}
.md ul, .md ol{ margin: 0 0 12px; padding-left: 20px; }
.md li{ margin: 4px 0; }
.md blockquote{
  margin: 12px 0;
  padding: 8px 12px;
  border-left: 3px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.06);
  border-radius: 12px;
  color: rgba(17, 24, 39, 0.78);
}
.md table{
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.md th, .md td{
  border: 1px solid rgba(17, 24, 39, 0.10);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
.md th{ background: rgba(17, 24, 39, 0.03); }
.md tr:nth-child(even) td{ background: rgba(17, 24, 39, 0.015); }
.md hr{
  border: none;
  border-top: 1px solid rgba(17, 24, 39, 0.10);
  margin: 16px 0;
}
.md img{
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(17, 24, 39, 0.10);
}

/* Wrapper page */
.wrapper{
  max-width: 820px;
  margin: 16px auto 0;
}
.crumbs{
  display:flex;
  gap: 8px;
  flex-wrap:wrap;
  align-items:center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.crumbs a{ color: var(--muted); }
.crumbs a:hover{ color: var(--primary); text-decoration:none; }
.crumbSep{ opacity: .7; }
.crumbCurrent{ color: var(--text); }

@media (max-width: 900px){
  .chapterLayout{ grid-template-columns: 1fr; }
  .sidebar{ position: relative; top: auto; }
  .chapterJump{ display:block; }
  .flow{ padding-left: 18px; }
  .flow::before{ left: 8px; }
  .chapterCard::before{ left: -16px; }
  .chapterCard::after{ left: -8px; width: 10px; }
}

/* Learning map */
.mapCard{
  margin-top: 18px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px 16px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}
.mapHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  flex-wrap:wrap;
}
.mapTitle{
  margin: 0;
  font-size: 16px;
  letter-spacing: .2px;
}
.mapWrap{
  margin-top: 12px;
  border-radius: 16px;
  border: 1px solid rgba(17, 24, 39, 0.10);
  background: rgba(17, 24, 39, 0.02);
  padding: 12px;
  overflow:auto;
}
.learningMapSvg{
  width: 100%;
  height: auto;
  min-width: 720px;
  color: rgba(17, 24, 39, 0.22);
}
.mapArrow{ fill: currentColor; opacity: .7; }
.mapEdge{ stroke: rgba(17, 24, 39, 0.14); }
.mapEdge.is-satisfied{ stroke: rgba(245, 158, 11, 0.65); }
.mapEdge.is-to-unlocked{ opacity: 1; }

.mapNode{ cursor:pointer; }
.mapNodeRect{
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(17, 24, 39, 0.16);
  stroke-width: 1.5;
}
.mapNodeTitle{
  font-size: 14px;
  font-weight: 700;
  fill: var(--text);
}
.mapNodeMeta{
  font-size: 12px;
  fill: rgba(17, 24, 39, 0.66);
}
.mapNodeType{ opacity: .9; }

.mapNode.is-locked .mapNodeRect{
  fill: rgba(17, 24, 39, 0.04);
  stroke: rgba(17, 24, 39, 0.12);
}
.mapNode.is-locked .mapNodeTitle,
.mapNode.is-locked .mapNodeMeta{ opacity: .55; }

.mapNode.is-available .mapNodeRect{
  fill: rgba(37, 99, 235, 0.08);
  stroke: rgba(37, 99, 235, 0.28);
}
.mapNode.is-inprogress .mapNodeRect{
  fill: rgba(124, 58, 237, 0.10);
  stroke: rgba(124, 58, 237, 0.32);
}
.mapNode.is-complete .mapNodeRect{
  fill: rgba(245, 158, 11, 0.20);
  stroke: rgba(245, 158, 11, 0.50);
}

.mapControls{ margin-top: 14px; }
.mapControlList{ display:grid; gap: 10px; }
.mapControlRow{
  display:flex;
  justify-content:space-between;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.10);
  background: rgba(17, 24, 39, 0.02);
}
.mapControlLeft{ min-width: 240px; }
.mapControlTitle{ font-weight: 700; }
.mapControlMeta{ margin-top: 4px; color: var(--muted); font-size: 12px; }
.mapControlRight{
  display:grid;
  gap: 10px;
  justify-items:end;
}
.mapControlPct{ font-size: 12px; color: var(--muted); }
.mapControlBtns{ display:flex; gap: 10px; flex-wrap:wrap; justify-content:flex-end; }
.mapControlRight input[type="range"]{ width: min(320px, 46vw); }

@media (max-width: 700px){
  .learningMapSvg{ min-width: 640px; }
  .mapControlRow{ flex-direction:column; }
  .mapControlRight{ justify-items:start; }
  .mapControlRight input[type="range"]{ width: 100%; }
}
