
:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --accent: #f78166;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --code-bg: #1c2230;
  --tag-bg: #21262d;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --max-content: 920px;
}
[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --bg-elev-2: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --text-dim: #59636e;
  --link: #0969da;
  --link-hover: #0550ae;
  --accent: #cf222e;
  --good: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --code-bg: #f6f8fa;
  --tag-bg: #eaeef2;
  --shadow: 0 6px 24px rgba(0,0,0,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { color: var(--link); }
.search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  border-color: var(--link);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
.search::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .7;
}
.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  font: 12px ui-monospace, monospace;
  color: var(--text-dim);
}
.topbar .progress-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
}
.progress-pill .bar {
  width: 70px;
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-pill .bar > span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--good), var(--link));
  transition: width .3s;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-elev-2); }

/* layout */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  gap: 0;
  min-height: calc(100vh - 56px);
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
  overflow-y: auto;
  padding: 14px 8px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--bg-elev-2); border-radius: 4px; }

.sidebar .track {
  margin-bottom: 6px;
}
.sidebar .track-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.sidebar .track-header:hover { background: var(--bg-elev); }
.sidebar .track-header .chev {
  display: inline-block;
  transition: transform .15s;
  color: var(--text-dim);
  font-size: 10px;
}
.sidebar .track[data-open="true"] .chev { transform: rotate(90deg); }
.sidebar .track-progress {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.sidebar .track-body {
  display: none;
  padding: 4px 0 8px 6px;
}
.sidebar .track[data-open="true"] .track-body { display: block; }
.sidebar .group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  padding: 8px 12px 4px;
}
.sidebar a.item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.4;
  margin: 1px 0;
}
.sidebar a.item:hover { background: var(--bg-elev); color: var(--link); }
.sidebar a.item.active {
  background: var(--bg-elev-2);
  color: var(--link);
  font-weight: 600;
}
.sidebar a.item .check {
  font-size: 11px;
  color: var(--good);
  width: 14px;
  flex-shrink: 0;
}
.sidebar a.item .check:empty::before { content: "○"; color: var(--text-dim); opacity: .35; }
.sidebar a.item.done .check::before { content: "●"; }
.sidebar .empty-search {
  padding: 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* main */
.content {
  padding: 26px 32px 80px;
  max-width: var(--max-content);
  width: 100%;
  margin: 0 auto;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--link); }
.breadcrumb .sep { margin: 0 6px; opacity: .5; }

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--text-dim); }
.btn.primary {
  background: var(--link);
  border-color: var(--link);
  color: #0d1117;
  font-weight: 600;
}
.btn.primary:hover { background: var(--link-hover); }
.btn.done {
  background: var(--good);
  border-color: var(--good);
  color: #0d1117;
  font-weight: 600;
}
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* article */
.md h1 { font-size: 28px; margin-top: 0; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.md h2 { font-size: 22px; margin-top: 36px; padding-bottom: 6px; border-bottom: 1px solid var(--border); scroll-margin-top: 80px; }
.md h3 { font-size: 17px; margin-top: 26px; scroll-margin-top: 80px; }
.md h4 { font-size: 15px; margin-top: 20px; color: var(--text-dim); }
.md p { margin: 12px 0; }
.md a { color: var(--link); }
.md a:hover { color: var(--link-hover); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.md ul, .md ol { padding-left: 26px; }
.md li { margin: 4px 0; }
.md blockquote {
  border-left: 3px solid var(--accent);
  background: var(--bg-elev);
  padding: 8px 14px;
  margin: 14px 0;
  color: var(--text-dim);
  border-radius: 0 6px 6px 0;
}
.md table {
  border-collapse: collapse;
  margin: 16px 0;
  display: block;
  overflow-x: auto;
  width: 100%;
}
.md th, .md td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.md th { background: var(--bg-elev); }
.md tr:nth-child(even) td { background: var(--bg-elev); }
.md code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font: 13px ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--accent);
}
.md pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font: 13px ui-monospace, "SF Mono", Consolas, monospace;
  line-height: 1.5;
}
.md pre code { background: transparent; padding: 0; color: var(--text); }

/* codehilite tokens (Pygments) */
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kr { color: #ff7b72; }
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sd { color: #a5d6ff; }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: var(--text-dim); font-style: italic; }
.codehilite .nf, .codehilite .nx, .codehilite .nc { color: #d2a8ff; }
.codehilite .mi, .codehilite .mf, .codehilite .mb { color: #79c0ff; }
.codehilite .o, .codehilite .p { color: var(--text-dim); }
.codehilite .nb, .codehilite .bp { color: #ffa657; }

/* prev / next */
.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.prevnext a {
  display: block;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .15s;
}
.prevnext a:hover { border-color: var(--link); transform: translateY(-1px); }
.prevnext .label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); }
.prevnext .title { font-weight: 600; margin-top: 4px; }
.prevnext .next { text-align: right; }

/* TOC right rail */
.toc-rail {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 26px 14px 80px 4px;
  border-left: 1px solid var(--border);
  font-size: 12.5px;
}
.toc-rail h4 {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .8px;
  color: var(--text-dim);
  margin: 0 0 8px 8px;
}
.toc-rail a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-dim);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: 2px;
  line-height: 1.35;
}
.toc-rail a.l3 { padding-left: 18px; font-size: 12px; }
.toc-rail a:hover { color: var(--text); }
.toc-rail a.active {
  color: var(--link);
  border-left-color: var(--link);
  background: var(--bg-elev);
}

/* home dashboard */
.hero {
  background: linear-gradient(135deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 30px;
  margin-bottom: 22px;
}
.hero h1 { margin: 0 0 6px; font-size: 30px; }
.hero p { margin: 0; color: var(--text-dim); font-size: 16px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin: 14px 0;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0 0 14px; color: var(--text-dim); font-size: 13.5px; flex: 1; }
.card .progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.card .progress-line .bar {
  flex: 1;
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.card .progress-line .bar > span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--good), var(--link));
  transition: width .3s;
}
.card a.go {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
  text-decoration: none;
}
.card a.go:hover { color: var(--link-hover); }
.card.recent { border-color: var(--link); }

.shortcut-table {
  margin-top: 18px;
  font-size: 13px;
  border-collapse: collapse;
}
.shortcut-table td { padding: 4px 10px; }
.shortcut-table td:first-child { color: var(--text-dim); }

/* responsive */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px 1fr; }
  .toc-rail { display: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 56px;
    width: 280px;
    height: calc(100vh - 56px);
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform .2s;
    z-index: 40;
    box-shadow: var(--shadow);
  }
  body[data-sidebar="open"] .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex !important; }
  .topbar .progress-pill { display: none; }
  .content { padding: 18px 16px 60px; }
}
.sidebar-toggle { display: none; }

/* mini animations */
.fade-in { animation: fade .25s ease-out; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ------- v2 user-friendliness additions ------- */

/* skip link (accessibility) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--link);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 200;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { left: 16px; }

/* reading progress bar */
.reading-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 60;
  pointer-events: none;
}
.reading-progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--good), var(--link));
  transition: width .15s linear;
}

/* meta line under page title */
.page-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-dim);
  margin: -6px 0 14px;
}
.page-meta .dot { opacity: .4; }
.page-meta .read-time::before { content: "🕐 "; }
.page-meta .word-count::before { content: "📝 "; }

/* tag color variants by tier / kind */
.tag.tier-1 { background: rgba(63,185,80,.12);  color: var(--good); border-color: rgba(63,185,80,.35); }
.tag.tier-2 { background: rgba(88,166,255,.12); color: var(--link); border-color: rgba(88,166,255,.35); }
.tag.tier-3 { background: rgba(210,153,34,.15); color: var(--warn); border-color: rgba(210,153,34,.35); }
.tag.tier-4 { background: rgba(248,81,73,.12);  color: var(--bad);  border-color: rgba(248,81,73,.35); }
.tag.deep-dive  { background: rgba(247,129,102,.12); color: var(--accent); border-color: rgba(247,129,102,.35); }
.tag.curriculum { background: rgba(88,166,255,.12); color: var(--link);   border-color: rgba(88,166,255,.35); }
.tag.plan       { background: rgba(63,185,80,.12);  color: var(--good);   border-color: rgba(63,185,80,.35); }
.tag.reference  { background: rgba(139,148,158,.15); color: var(--text-dim); }
.tag.\35 -min   { background: rgba(247,129,102,.10); color: var(--accent); border-color: rgba(247,129,102,.30); }
.tag.overview, .tag.index { background: rgba(139,148,158,.18); color: var(--text); }

/* sidebar item meta (small text under title) */
.sidebar a.item .item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-left: 22px;
  display: block;
  margin-top: 1px;
}
.sidebar a.item.active .item-meta { color: var(--link); opacity: .9; }
.sidebar a.item .title-line {
  display: block;
  white-space: normal;
}

/* group progress bar */
.sidebar .group-bar {
  height: 2px;
  background: var(--bg-elev-2);
  border-radius: 2px;
  margin: 0 12px 6px;
  overflow: hidden;
}
.sidebar .group-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--good), var(--link));
  transition: width .3s;
}

/* loading spinner overlay */
.loading {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 14px;
  gap: 12px;
}
.loading.active { display: flex; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg-elev-2);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* back-to-top floating button */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 20px;
  cursor: pointer;
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s, background .15s;
  box-shadow: var(--shadow);
}
.back-to-top.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.back-to-top:hover { background: var(--bg-elev-2); }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 22px 22px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { transform: translateY(8px) scale(.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  padding: 16px 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-foot {
  font-size: 12px;
  color: var(--text-dim);
  margin: 14px 0 0;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { font-size: 14px; }
.setting-help { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.btn.danger {
  background: transparent;
  border-color: rgba(248,81,73,.4);
  color: var(--bad);
}
.btn.danger:hover { background: rgba(248,81,73,.10); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: background .15s;
}
.switch span::before {
  content: "";
  position: absolute;
  height: 16px; width: 16px;
  left: 2px; top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .15s, background .15s;
}
.switch input:checked + span { background: var(--link); border-color: var(--link); }
.switch input:checked + span::before { transform: translateX(16px); background: #fff; }

/* toast notifications */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 110;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--good);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toastIn .2s ease-out, toastOut .2s ease-in 2.6s forwards;
  min-width: 200px;
}
.toast.error { border-left-color: var(--bad); }
.toast.info  { border-left-color: var(--link); }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(20px); opacity: 0; }
}

/* sidebar mobile backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 39;
  display: none;
}
body[data-sidebar="open"] .sidebar-backdrop { display: block; }

/* improved focus styles for keyboard nav */
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible, .icon-btn:focus-visible {
  outline-offset: 1px;
}

/* hero CTA refinement (first-time user) */
.hero.welcome {
  background: linear-gradient(135deg, rgba(88,166,255,.18), rgba(63,185,80,.12));
  border-color: rgba(88,166,255,.4);
}
.hero .cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  background: var(--link);
  color: #0d1117;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}
.hero .cta:hover { background: var(--link-hover); }
.hero .lede {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

/* continue-learning card pinned at top of home */
.continue-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--link);
  border-radius: 12px;
  margin-bottom: 22px;
}
.continue-card .ico { font-size: 28px; flex-shrink: 0; }
.continue-card .body { flex: 1; }
.continue-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
}
.continue-card h3 { margin: 2px 0; font-size: 16px; }
.continue-card .desc { font-size: 13px; color: var(--text-dim); margin: 0; }
.continue-card .btn { flex-shrink: 0; }

/* completion celebration */
.complete-banner {
  background: linear-gradient(135deg, rgba(63,185,80,.18), rgba(88,166,255,.10));
  border: 1px solid rgba(63,185,80,.4);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 18px 0;
  font-size: 14px;
  color: var(--good);
}

/* responsive tweaks */
@media (max-width: 760px) {
  .sidebar-toggle { display: inline-flex !important; }
  .topbar .progress-pill { display: none; }
  #help-btn, #settings-btn { display: none; }
  .content { padding: 18px 14px 60px; }
  .modal-card { max-width: 100%; }
  .back-to-top { right: 14px; bottom: 14px; }
  .continue-card { flex-direction: column; align-items: flex-start; }
}

/* print-friendly */
@media print {
  .topbar, .sidebar, .toc-rail, .back-to-top, .reading-progress,
  .modal, .toast-stack, .page-actions, .prevnext, .sidebar-backdrop { display: none !important; }
  .layout { grid-template-columns: 1fr !important; }
  .content { max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
  .md a { color: #000; text-decoration: underline; }
  .md pre, .md code { background: #f4f4f4 !important; color: #000 !important; }
}

/* reduce-motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ------- Path A additions: difficulty, time, your-path, wizard ------- */

/* difficulty badges */
.diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  letter-spacing: .3px;
  text-transform: uppercase;
}
.diff-beginner    { background: rgba(63,185,80,.10);  color: var(--good); border-color: rgba(63,185,80,.35); }
.diff-intermediate{ background: rgba(88,166,255,.10); color: var(--link); border-color: rgba(88,166,255,.35); }
.diff-advanced    { background: rgba(210,153,34,.12); color: var(--warn); border-color: rgba(210,153,34,.35); }
.diff-expert      { background: rgba(248,81,73,.10);  color: var(--bad);  border-color: rgba(248,81,73,.35); }
.diff-all-levels  { background: rgba(139,148,158,.12); color: var(--text-dim); border-color: var(--border); }

/* small inline difficulty dot for sidebar items */
.sidebar a.item .diff-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  background: var(--text-dim);
}
.sidebar a.item .diff-dot.diff-beginner    { background: var(--good); }
.sidebar a.item .diff-dot.diff-intermediate{ background: var(--link); }
.sidebar a.item .diff-dot.diff-advanced    { background: var(--warn); }
.sidebar a.item .diff-dot.diff-expert      { background: var(--bad);  }

/* track card time line */
.track-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}
.track-time strong { color: var(--text); }
.diff-bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0 4px;
  background: var(--bg-elev-2);
}
.diff-bar > span { display: block; height: 100%; }
.diff-bar > .diff-beginner    { background: var(--good); }
.diff-bar > .diff-intermediate{ background: var(--link); }
.diff-bar > .diff-advanced    { background: var(--warn); }
.diff-bar > .diff-expert      { background: var(--bad);  }
.diff-bar > .diff-all-levels  { background: var(--text-dim); }
.diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.diff-legend .lg-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  vertical-align: middle; margin-right: 4px;
}

/* "Your path" card on home */
.your-path-card {
  background: linear-gradient(135deg, rgba(88,166,255,.14), rgba(63,185,80,.10));
  border: 1px solid rgba(88,166,255,.35);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
}
.your-path-card .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.your-path-card h2 {
  margin: 0;
  font-size: 20px;
}
.your-path-card .subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin: 2px 0 0;
}
.your-path-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.your-path-card ol {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.your-path-card ol li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  transition: border-color .15s, transform .1s;
}
.your-path-card ol li:hover { border-color: var(--link); transform: translateX(2px); }
.your-path-card ol li.done { opacity: .55; }
.your-path-card ol li .num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  width: 22px;
  flex-shrink: 0;
}
.your-path-card ol li.done .num::before { content: "✓ "; color: var(--good); }
.your-path-card ol li a {
  color: var(--text);
  text-decoration: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.your-path-card ol li a:hover { color: var(--link); }
.your-path-card ol li .it-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.your-path-card ol li .it-meta {
  font-size: 11px;
  color: var(--text-dim);
}
.your-path-card .summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}
.your-path-card .summary-row .pill {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
}

/* onboarding wizard */
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-progress {
  display: flex;
  gap: 6px;
  margin: 0 0 20px;
}
.wizard-progress .dot {
  flex: 1;
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 2px;
  transition: background .2s;
}
.wizard-progress .dot.active { background: var(--link); }
.wizard-progress .dot.done   { background: var(--good); }
.wizard-question {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
}
.wizard-help {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 16px;
}
.wizard-options {
  display: grid;
  gap: 10px;
}
.wizard-options button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color .15s, background .15s, transform .1s;
}
.wizard-options button:hover {
  border-color: var(--link);
  background: var(--bg-elev-2);
}
.wizard-options button.selected {
  border-color: var(--link);
  background: rgba(88,166,255,.10);
}
.wizard-options button strong { font-size: 14px; }
.wizard-options button span { font-size: 12px; color: var(--text-dim); }
.wizard-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 8px;
}
.wizard-foot .skip {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}
.wizard-foot .skip:hover { color: var(--text); }

/* welcome popup (first-time prompt) */
.welcome-prompt {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--link);
  border-radius: 10px;
  margin-bottom: 22px;
}
.welcome-prompt .ico { font-size: 24px; }
.welcome-prompt .body { flex: 1; }
.welcome-prompt h3 { margin: 0 0 2px; font-size: 15px; }
.welcome-prompt p { margin: 0; font-size: 13px; color: var(--text-dim); }
.welcome-prompt .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Search panel (floating Ask widget) ---- */
.ap-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; border: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  box-shadow: 0 10px 28px rgba(99,102,241,.35), 0 4px 10px rgba(0,0,0,.2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ap-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(99,102,241,.5), 0 4px 10px rgba(0,0,0,.25); }
.ap-fab:active { transform: translateY(0); }
.ap-fab-icon { font-size: 18px; }
.ap-fab-text { letter-spacing: 0.2px; }
body.ap-open .ap-fab { display: none; }
@media (max-width: 720px) {
  .ap-fab { right: 16px; bottom: 16px; padding: 12px 14px; }
  .ap-fab-text { display: none; }
}

.ap-scrim {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(8, 10, 18, 0.55);
  backdrop-filter: blur(2px);
  animation: ap-fade .15s ease;
}
.ap-scrim[hidden], .ap-panel[hidden] { display: none !important; }
@keyframes ap-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ap-pop { from { opacity: 0; transform: translate(-50%, -45%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.ap-panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 100;
  width: min(720px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 64px));
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 8px 20px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: ap-pop .18s ease;
}
.ap-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.ap-head-icon { font-size: 18px; opacity: .7; }
#ap-input {
  flex: 1; min-width: 0;
  padding: 8px 4px; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 16px;
}
#ap-input::placeholder { color: var(--text-dim); }
.ap-close {
  border: 0; background: transparent; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; font-size: 16px;
}
.ap-close:hover { background: var(--bg-elev-2); color: var(--text); }

.ap-results {
  flex: 1; overflow-y: auto;
  padding: 8px;
}
.ap-result {
  display: block; text-decoration: none; color: inherit;
  padding: 12px 14px; margin-bottom: 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.ap-result.ap-hover, .ap-result:hover {
  background: var(--bg-elev-2);
  border-color: var(--border);
}
.ap-row1 { display: flex; align-items: center; gap: 8px; }
.ap-title { font-weight: 600; font-size: 15px; color: var(--text); }
.ap-done { color: #10b981; font-weight: 700; font-size: 13px; }
.ap-row2 {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 4px; font-size: 12px; color: var(--text-dim);
}
.ap-track { font-weight: 500; }
.ap-diff-name { text-transform: capitalize; }
.ap-min { font-variant-numeric: tabular-nums; }
.ap-anchor {
  margin-top: 6px; font-size: 13px;
  color: var(--accent);
}
.ap-anchor strong { color: var(--accent); }
.ap-summary {
  margin-top: 6px; font-size: 13px; line-height: 1.5;
  color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.ap-empty {
  padding: 28px 18px; text-align: center; color: var(--text-dim);
}
.ap-empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.ap-empty-help { font-size: 13px; line-height: 2.2; }
.ap-chip {
  display: inline-block; margin: 2px 4px;
  padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text);
  font-size: 12px; cursor: pointer;
}
.ap-chip:hover { border-color: var(--accent); color: var(--accent); }

.ap-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-elev);
}
.ap-foot .kbd {
  font-size: 10px; padding: 1px 6px;
}
.ap-foot-right { margin-left: auto; opacity: .8; }
@media (max-width: 540px) {
  .ap-panel { width: calc(100vw - 16px); max-height: calc(100vh - 32px); }
  .ap-foot { flex-wrap: wrap; gap: 8px; }
  .ap-foot-right { margin-left: 0; width: 100%; text-align: right; }
}

/* hide ap-fab in print mode */
@media print {
  .ap-fab, .ap-scrim, .ap-panel { display: none !important; }
}
