:root {
  --bg: #ffffff;
  --bg-side: #f6f7f9;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e5e8;
  --accent: #2563eb;
  --active-bg: #e0eaff;
  --code-bg: #f3f4f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-side: #1d2026;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2c3038;
    --accent: #6ea0ff;
    --active-bg: #23304d;
    --code-bg: #232730;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 10;
}
header h1 { font-size: 18px; margin: 0; }
#menuBtn { display: none; background: none; border: none; font-size: 22px; color: var(--text); cursor: pointer; }

.layout { display: flex; height: calc(100vh - 52px); }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
}
#search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.tree-actions { display: flex; gap: 6px; margin: 8px 0; }
.tree-actions button {
  flex: 1;
  padding: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

#tree ul { list-style: none; margin: 0; padding-left: 14px; }
#tree > ul { padding-left: 0; }
#tree li.collapsed > ul { display: none; }
#tree li.hidden { display: none; }

.node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.node:hover { background: var(--active-bg); }
.node.active { background: var(--active-bg); color: var(--accent); font-weight: 600; }
.caret { width: 14px; display: inline-block; color: var(--muted); font-size: 10px; transition: transform .15s; }
li:not(.collapsed) > .node > .caret.has-children { transform: rotate(90deg); }
.empty-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); margin-left: auto; }

/* ---------- Content ---------- */
#content { flex: 1; overflow-y: auto; padding: 24px 40px; }
#breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
#breadcrumb a { color: var(--muted); text-decoration: none; cursor: pointer; }
#breadcrumb a:hover { color: var(--accent); }
#article { max-width: 860px; line-height: 1.6; }
#article h2 { margin-top: 0; }
#article pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
}
#article code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
#article :not(pre) > code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
#article table { border-collapse: collapse; }
#article th, #article td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.placeholder { color: var(--muted); font-style: italic; }
.child-list a { color: var(--accent); cursor: pointer; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  #menuBtn { display: block; }
  #sidebar {
    position: fixed; top: 52px; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .2s;
    z-index: 20;
  }
  #sidebar.open { transform: translateX(0); }
  #content { padding: 16px; }
}
.skill-desc { border-left: 3px solid var(--accent); background: var(--code-bg); padding: 8px 12px; border-radius: 4px; }

/* ---------- Ghi chú học ---------- */
#article h4 { margin: 22px 0 6px; }
.tip, .warn { padding: 8px 12px; border-radius: 6px; margin: 10px 0; border-left: 4px solid; }
.tip  { border-color: #16a34a; background: rgba(22,163,74,.08); }
.warn { border-color: #d97706; background: rgba(217,119,6,.10); }
.kw td:first-child { font-family: ui-monospace, Consolas, monospace; font-size: 13px; white-space: nowrap; }
#article table { margin: 8px 0; }
