/* Shared lesson design system — light/dark themes, layout, content blocks, animations */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e7eaf2;
  --border: #dde1ea;
  --text: #1c2130;
  --text-2: #4a5468;
  --text-3: #6f7a90;
  --accent: #4c5fe0;
  --accent-2: #eef0ff;
  --accent-text: #3343c4;
  --green: #17925a;  --green-bg: #e6f6ee;
  --orange: #c56a12; --orange-bg: #fff3e4;
  --red: #c4383a;    --red-bg: #fdeaea;
  --purple: #8a3fd1; --purple-bg: #f4ebfd;
  --blue: #2f6fe0;   --blue-bg: #e8f0fe;
  --gray: #6b7280;   --gray-bg: #f1f2f5;
  --code-bg: #f4f5f9;
  --code-text: #23293a;
  --shadow: 0 1px 2px rgba(20, 25, 40, .05), 0 4px 16px rgba(20, 25, 40, .06);
  --radius: 12px;
  --sidebar-w: 290px;
  --toc-w: 230px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #161a23; --surface-2: #1c212c; --surface-3: #252b38;
    --border: #2a3140; --text: #e6e9f0; --text-2: #b3bbcb; --text-3: #8791a5;
    --accent: #7d8cff; --accent-2: #232a4d; --accent-text: #a9b3ff;
    --green: #3fcf8e; --green-bg: #12291f; --orange: #f0a04b; --orange-bg: #2d2114;
    --red: #f07177; --red-bg: #2e1719; --purple: #c08bff; --purple-bg: #251a35;
    --blue: #6aa3ff; --blue-bg: #14223a; --gray: #9aa3b2; --gray-bg: #1f242e;
    --code-bg: #12161e; --code-text: #d7dceb;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #161a23; --surface-2: #1c212c; --surface-3: #252b38;
  --border: #2a3140; --text: #e6e9f0; --text-2: #b3bbcb; --text-3: #8791a5;
  --accent: #7d8cff; --accent-2: #232a4d; --accent-text: #a9b3ff;
  --green: #3fcf8e; --green-bg: #12291f; --orange: #f0a04b; --orange-bg: #2d2114;
  --red: #f07177; --red-bg: #2e1719; --purple: #c08bff; --purple-bg: #251a35;
  --blue: #6aa3ff; --blue-bg: #14223a; --gray: #9aa3b2; --gray-bg: #1f242e;
  --code-bg: #12161e; --code-text: #d7dceb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.7 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-2); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--purple)); color: #fff; font-size: 15px;
}
.crumbs { flex: 1; min-width: 0; font-size: 14px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { margin: 0 6px; opacity: .6; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  cursor: pointer; font-size: 17px; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-btn { display: none; }
#theme-btn { margin-left: auto; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); min-height: calc(100vh - 60px); }
.layout.no-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--surface); padding: 14px 10px 40px;
}
.main { min-width: 0; padding: 32px clamp(16px, 4vw, 56px) 80px; }
.content { max-width: 860px; margin: 0 auto; }
.toc { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 28px 16px 40px 8px; font-size: 13px; }

/* ---------- sidebar ---------- */
.search {
  width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238791a5' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 11px 50%;
  color: var(--text); font: inherit; font-size: 14px; margin-bottom: 12px; outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.nav-cat { margin-bottom: 2px; }
.nav-cat > button, .nav-group > button {
  width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; border-radius: 8px;
}
.nav-cat > button { padding: 7px 10px; font-weight: 650; font-size: 14px; }
.nav-cat > button:hover, .nav-group > button:hover { background: var(--surface-2); }
.nav-cat .cat-icon { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; flex: none; color: #fff; }
.nav-cat .count { margin-left: auto; font-size: 11px; color: var(--text-3); font-weight: 500; }
.chev { transition: transform .2s; font-size: 10px; color: var(--text-3); width: 10px; flex: none; }
.open > button > .chev { transform: rotate(90deg); }
.nav-cat > .kids, .nav-group > .kids { display: none; }
.nav-cat.open > .kids, .nav-group.open > .kids { display: block; }
.nav-group > button { padding: 5px 10px 5px 22px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.nav-topic {
  display: flex; gap: 8px; padding: 4px 10px 4px 40px; font-size: 13px; color: var(--text-2);
  border-radius: 8px; line-height: 1.45; position: relative;
}
.nav-topic .num { color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
.nav-topic:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-topic.current { background: var(--accent-2); color: var(--accent-text); font-weight: 600; }
.nav-topic.current::before { content: ""; position: absolute; left: 30px; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav-topic.soon { opacity: .45; pointer-events: none; }
.nav-empty { padding: 10px; font-size: 13px; color: var(--text-3); }

/* ---------- toc ---------- */
.toc h4 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.toc a { display: block; padding: 4px 10px; color: var(--text-3); border-left: 2px solid var(--border); line-height: 1.4; }
.toc a.sub { padding-left: 22px; font-size: 12px; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); font-weight: 600; }

/* ---------- hero ---------- */
.hero {
  border-radius: 18px; padding: 30px 32px; margin-bottom: 30px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-2), var(--purple-bg)); border: 1px solid var(--border);
}
.hero .kicker { font-size: 13px; font-weight: 650; color: var(--accent-text); text-transform: uppercase; letter-spacing: .08em; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.15; margin: 8px 0 12px; letter-spacing: -.02em; }
.hero p.lead { font-size: 17px; color: var(--text-2); margin: 0 0 18px; max-width: 680px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
}
.chip.easy { color: var(--green); } .chip.medium { color: var(--orange); } .chip.hard { color: var(--red); }
.hero-art { position: absolute; right: -20px; top: -20px; width: 220px; opacity: .18; pointer-events: none; }

.learn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 34px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.content .panel h3, .panel h3 { margin: 0 0 8px; font-size: 15px; }
.panel ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 14.5px; }
.panel li { margin: 3px 0; }

/* ---------- content typography ---------- */
.content h2 {
  font-size: 26px; line-height: 1.25; margin: 56px 0 16px; letter-spacing: -.015em;
  display: flex; align-items: baseline; gap: 12px;
}
.content h2 .sec-num {
  flex: none; font-size: 13px; font-weight: 700; color: var(--accent-text); background: var(--accent-2);
  border-radius: 8px; padding: 2px 9px; transform: translateY(-3px);
}
.content h3 { font-size: 19px; margin: 32px 0 10px; }
.content h4 { font-size: 16px; margin: 24px 0 8px; }
.content p, .content li { color: var(--text-2); }
.content strong { color: var(--text); }
.content ul, .content ol { padding-left: 22px; }
.content li { margin: 5px 0; }
.part-title {
  margin: 64px 0 8px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border); font-weight: 700; font-size: 15px; color: var(--text);
}
.part-title span { color: var(--accent-text); margin-right: 8px; }
code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: var(--code-text); }
a code { color: var(--accent-text); }
.codeblock { position: relative; margin: 18px 0; border-radius: var(--radius); border: 1px solid var(--border); background: var(--code-bg); overflow: hidden; }
.codeblock .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); font-family: var(--mono); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13.5px/1.6 var(--mono); color: var(--code-text); }
.codeblock pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.copy-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 6px; padding: 2px 8px; font: 12px var(--font); cursor: pointer; }
.copy-btn:hover { color: var(--text); }
.tok-k { color: var(--purple); } .tok-s { color: var(--green); } .tok-c { color: var(--text-3); font-style: italic; } .tok-n { color: var(--orange); }
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th { background: var(--surface-2); text-align: left; font-weight: 650; color: var(--text); }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }
blockquote { margin: 18px 0; padding: 4px 18px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }

figure.diagram { margin: 24px 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
figure.diagram img { display: block; width: 100%; height: auto; cursor: zoom-in; }
figure.diagram figcaption { color: #4a5468; font-size: 13px; padding: 8px 6px 2px; line-height: 1.5; }
.zoom { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 15, .78); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.zoom img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 12px; padding: 10px; }

/* ---------- callouts ---------- */
.callout { display: flex; gap: 14px; margin: 22px 0; padding: 16px 18px; border-radius: var(--radius); border: 1px solid; }
.callout .ic { font-size: 18px; line-height: 1.5; flex: none; }
.callout .body > :first-child { margin-top: 0; } .callout .body > :last-child { margin-bottom: 0; }
.callout .title { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.callout.note { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.callout.tip { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.callout.warn { background: var(--orange-bg); border-color: color-mix(in srgb, var(--orange) 35%, transparent); }
.callout.danger { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.example {
  margin: 26px 0; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); overflow: hidden;
}
.example .ex-head { display: flex; align-items: center; gap: 10px; padding: 11px 18px; background: var(--green-bg); border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; color: var(--green); }
.example .ex-body { padding: 4px 20px 14px; }
.example .ex-body p, .example .ex-body li { font-size: 15px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.compare > div { border-radius: var(--radius); border: 1px solid var(--border); padding: 14px 16px; background: var(--surface); }
.compare .bad { border-top: 4px solid var(--red); } .compare .good { border-top: 4px solid var(--green); }
.compare h5 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.compare .bad h5 { color: var(--red); } .compare .good h5 { color: var(--green); }
.compare .codeblock { margin: 8px 0 0; }

/* special sections */
details.deep { margin: 56px 0 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
details.deep > summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; }
details.deep > summary::-webkit-details-marker { display: none; }
details.deep > summary .badge { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; background: var(--purple-bg); color: var(--purple); padding: 3px 9px; border-radius: 999px; }
details.deep > summary .tw { margin-left: auto; color: var(--text-3); font-size: 14px; transition: transform .2s; }
details.deep[open] > summary .tw { transform: rotate(180deg); }
details.deep > .deep-body { padding: 0 24px 18px; border-top: 1px solid var(--border); }
details.deep > .deep-body h2 { display: none; }
.pitfalls { display: grid; gap: 10px; margin: 16px 0; padding: 0; list-style: none; counter-reset: pf; }
.pitfalls li { counter-increment: pf; position: relative; padding: 14px 16px 14px 54px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin: 0; }
.pitfalls li::before { content: counter(pf); position: absolute; left: 16px; top: 14px; width: 26px; height: 26px; border-radius: 8px; background: var(--red-bg); color: var(--red); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.cheatsheet { border-radius: 16px; border: 1px dashed var(--accent); background: var(--accent-2); padding: 6px 18px 12px; margin: 16px 0; }
.cheatsheet .codeblock { background: var(--surface); }
.takeaways { border-radius: 16px; padding: 18px 22px; background: linear-gradient(135deg, var(--green-bg), var(--blue-bg)); border: 1px solid var(--border); margin: 40px 0 0; }
.takeaways h3 { margin: 0 0 8px; }
.takeaways ul { margin: 0; }

/* exercises */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 16px 0; }
.ex-card { display: block; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; color: var(--text); }
.ex-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.ex-card .ex-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-3); margin-bottom: 6px; font-family: var(--mono); }
.ex-card .ex-title { font-weight: 650; font-size: 15px; line-height: 1.4; }
.ex-card .ex-file { margin-top: 8px; font-size: 12px; color: var(--text-3); font-family: var(--mono); word-break: break-all; }

/* quiz */
.quiz { margin: 18px 0; display: grid; gap: 14px; }
.q { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.q .q-text { font-weight: 650; margin-bottom: 10px; color: var(--text); }
.q .opts { display: grid; gap: 8px; }
.q button.opt { text-align: left; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14.5px; cursor: pointer; }
.q button.opt:hover:not(:disabled) { border-color: var(--accent); }
.q button.opt.right { background: var(--green-bg); border-color: var(--green); }
.q button.opt.wrong { background: var(--red-bg); border-color: var(--red); }
.q button.opt:disabled { cursor: default; }
.q .why { display: none; margin-top: 10px; font-size: 14px; color: var(--text-2); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.q.answered .why { display: block; }
.quiz-score { font-weight: 650; color: var(--text-2); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 56px 0 0; }
.pager a { padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .lbl { font-size: 12px; color: var(--text-3); }
.pager .next { text-align: right; grid-column: 2; }
.footer-note { margin-top: 40px; font-size: 13px; color: var(--text-3); text-align: center; }

/* ---------- animation player ---------- */
.anim { margin: 28px 0; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.anim-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.anim-head .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); background: var(--accent-2); padding: 3px 8px; border-radius: 6px; }
.anim-head .ttl { font-weight: 650; font-size: 15px; }
.anim-variants { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.anim-variants button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font: 13px var(--font); cursor: pointer; }
.anim-variants button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.anim-stage { padding: 10px 12px 0; }
.anim-stage svg { display: block; width: 100%; height: auto; overflow: visible; }
.anim-caption { min-height: 52px; margin: 6px 16px 0; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; color: var(--text-2); display: flex; gap: 10px; align-items: flex-start; }
.anim-caption .stepno { flex: none; font: 600 12px var(--mono); color: var(--accent-text); background: var(--accent-2); padding: 2px 7px; border-radius: 6px; margin-top: 2px; }
.anim-controls { display: flex; align-items: center; gap: 8px; padding: 12px 16px 14px; flex-wrap: wrap; }
.anim-controls button { height: 34px; min-width: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.anim-controls button:hover:not(:disabled) { background: var(--surface-2); }
.anim-controls button:disabled { opacity: .4; cursor: default; }
.anim-controls button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.anim-controls .progress { flex: 1; min-width: 120px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.anim-controls .progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--purple)); transition: width .3s; }
.anim-controls label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.anim-controls input[type=range] { width: 80px; accent-color: var(--accent); }
.anim-extra { padding: 0 16px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.anim-extra button { border: 1px dashed var(--accent); background: var(--accent-2); color: var(--accent-text); border-radius: 9px; padding: 6px 12px; font: 600 13px var(--font); cursor: pointer; }

/* SVG scene styling (theme-aware) */
.sc-node rect, .sc-node circle, .sc-node path.shape { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; transition: fill .35s, stroke .35s; }
.sc-node text { fill: var(--text); font: 600 13px var(--font); text-anchor: middle; dominant-baseline: middle; transition: fill .35s; }
.sc-node text.sub { font: 500 11px var(--mono); fill: var(--text-3); }
.sc-node.c-blue rect, .sc-node.c-blue circle, .sc-node.c-blue path.shape { fill: var(--blue-bg); stroke: var(--blue); }
.sc-node.c-green rect, .sc-node.c-green circle, .sc-node.c-green path.shape { fill: var(--green-bg); stroke: var(--green); }
.sc-node.c-orange rect, .sc-node.c-orange circle, .sc-node.c-orange path.shape { fill: var(--orange-bg); stroke: var(--orange); }
.sc-node.c-red rect, .sc-node.c-red circle, .sc-node.c-red path.shape { fill: var(--red-bg); stroke: var(--red); }
.sc-node.c-purple rect, .sc-node.c-purple circle, .sc-node.c-purple path.shape { fill: var(--purple-bg); stroke: var(--purple); }
.sc-node.hl rect, .sc-node.hl circle, .sc-node.hl path.shape { stroke-width: 3; filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 55%, transparent)); }
.sc-node.s-ok rect, .sc-node.s-ok circle, .sc-node.s-ok path.shape { fill: var(--green-bg); stroke: var(--green); stroke-width: 2.5; }
.sc-node.s-err rect, .sc-node.s-err circle, .sc-node.s-err path.shape { fill: var(--red-bg); stroke: var(--red); stroke-width: 2.5; }
.sc-node.s-warn rect, .sc-node.s-warn circle, .sc-node.s-warn path.shape { fill: var(--orange-bg); stroke: var(--orange); stroke-width: 2.5; }
.sc-node.s-wait rect, .sc-node.s-wait circle { stroke-dasharray: 6 4; animation: dash 1s linear infinite; }
.sc-node.s-dead { opacity: .45; }
.sc-node.s-dead rect, .sc-node.s-dead circle { stroke-dasharray: 4 4; }
.sc-node.dim { opacity: .3; }
.sc-node .badge-g rect { stroke-width: 0; }
.sc-node .badge-g text { font: 700 11px var(--font); fill: #fff; }
.sc-edge { stroke: var(--border); stroke-width: 2; fill: none; transition: stroke .3s; }
.sc-edge.dashed { stroke-dasharray: 6 5; }
.sc-edge.hl { stroke: var(--accent); stroke-width: 2.5; }
.sc-edge-label { fill: var(--text-3); font: 500 11px var(--mono); text-anchor: middle; }
.sc-packet circle { stroke: var(--surface); stroke-width: 2; }
.sc-packet rect { stroke-width: 0; }
.sc-packet text { fill: #fff; font: 700 11px var(--mono); text-anchor: middle; dominant-baseline: middle; }
.sc-packet.p-blue rect, .sc-packet.p-blue circle { fill: var(--blue); }
.sc-packet.p-green rect, .sc-packet.p-green circle { fill: var(--green); }
.sc-packet.p-red rect, .sc-packet.p-red circle { fill: var(--red); }
.sc-packet.p-orange rect, .sc-packet.p-orange circle { fill: var(--orange); }
.sc-packet.p-purple rect, .sc-packet.p-purple circle { fill: var(--purple); }
.sc-note rect { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.sc-note text { fill: var(--accent-text); font: 600 12px var(--font); text-anchor: middle; dominant-baseline: middle; }
.sc-group rect { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 5 5; }
.sc-group text { fill: var(--text-3); font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .08em; }
.sc-crash { pointer-events: none; }
.sc-crash path { stroke: var(--red); stroke-width: 5; stroke-linecap: round; }
.seq-life { stroke: var(--border); stroke-width: 2; stroke-dasharray: 4 5; }
.seq-msg line { stroke: var(--text-3); stroke-width: 2; }
.seq-msg.m-blue line { stroke: var(--blue); } .seq-msg.m-green line { stroke: var(--green); }
.seq-msg.m-red line { stroke: var(--red); } .seq-msg.m-orange line { stroke: var(--orange); } .seq-msg.m-purple line { stroke: var(--purple); }
.seq-msg.dashed line { stroke-dasharray: 6 5; }
.seq-msg text { font: 600 12px var(--mono); fill: var(--text); text-anchor: middle; }
.seq-msg text.bg { stroke: var(--surface); stroke-width: 5; stroke-linejoin: round; }
.seq-mark text { font: 600 11px var(--font); text-anchor: start; dominant-baseline: middle; }
.seq-mark rect { stroke-width: 1.5; }
.seq-mark.k-ok rect { fill: var(--green-bg); stroke: var(--green); } .seq-mark.k-ok text { fill: var(--green); }
.seq-mark.k-err rect { fill: var(--red-bg); stroke: var(--red); } .seq-mark.k-err text { fill: var(--red); }
.seq-mark.k-warn rect { fill: var(--orange-bg); stroke: var(--orange); } .seq-mark.k-warn text { fill: var(--orange); }
.seq-mark.k-info rect { fill: var(--blue-bg); stroke: var(--blue); } .seq-mark.k-info text { fill: var(--blue); }
.seq-new { animation: fadein .45s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes dash { to { stroke-dashoffset: -20; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.pulse { animation: pulse 1.2s ease-in-out infinite; }

/* widgets */
.widget { padding: 14px 16px 16px; }
.widget .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.widget input[type=text], .widget input[type=number] { font: 15px var(--mono); padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); width: 220px; outline: none; }
.widget input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.widget .out { font: 600 22px var(--mono); color: var(--accent-text); letter-spacing: .04em; }
.steps-list { font: 13px/1.8 var(--mono); color: var(--text-2); background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; max-height: 260px; overflow: auto; }
.steps-list .hl { color: var(--accent-text); font-weight: 700; }
.digit-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.digit { min-width: 38px; padding: 6px 4px; border-radius: 9px; text-align: center; border: 1px solid var(--accent); background: var(--accent-2); animation: fadein .35s both; }
.digit b { display: block; font: 700 18px var(--mono); color: var(--accent-text); }
.digit small { font: 11px var(--mono); color: var(--text-3); }
.http-demo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.http-demo pre { margin: 0; font: 12.5px/1.6 var(--mono); background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: var(--code-text); white-space: pre-wrap; min-height: 150px; }
.http-demo .lbl { font-size: 12px; color: var(--text-3); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 7px 12px; font: 600 13px var(--font); cursor: pointer; }
.btn-row button:hover:not(:disabled) { border-color: var(--accent); }
.btn-row button:disabled { opacity: .4; cursor: not-allowed; }
.btn-row button.danger { color: var(--red); }

/* ---------- home / index pages ---------- */
.home-hero { text-align: center; padding: 40px 10px 20px; }
.home-hero h1 { font-size: clamp(32px, 5vw, 48px); margin: 0 0 10px; letter-spacing: -.02em; }
.home-hero p { color: var(--text-2); font-size: 18px; margin: 0 auto; max-width: 640px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 30px 0; }
.cat-card { display: block; padding: 20px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); color: var(--text); transition: transform .15s, border-color .15s; }
.cat-card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.cat-card .cat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: #fff; margin-bottom: 12px; }
.cat-card h3 { margin: 0 0 4px; font-size: 18px; }
.cat-card p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; }
.cat-card .bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.cat-card .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); }
.cat-card .small { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.topic-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin: 10px 0 30px; }
.topic-list > a, .topic-list > .soon { display: flex; gap: 10px; align-items: baseline; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14.5px; }
.topic-list > a { box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.topic-list > a:hover { border-color: var(--accent); text-decoration: none; }
.topic-list > .soon { opacity: .55; }
.topic-list > .soon::after { content: "soon"; margin-left: auto; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.topic-list .num { color: var(--text-3); font-family: var(--mono); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: grid; }
  .sidebar { position: fixed; left: 0; top: 60px; z-index: 40; width: min(320px, 86vw); transform: translateX(-102%); transition: transform .25s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 60px 0 0; background: rgba(0, 0, 0, .35); z-index: 35; }
  .learn-grid, .compare, .http-demo { grid-template-columns: 1fr; }
  .hero { padding: 24px 20px; }
  .crumbs { display: none; }
}
@media (max-width: 520px) {
  .main { padding: 20px 16px 60px; }
  .content h2 { font-size: 22px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .topbar, .sidebar, .toc, .anim-controls, .pager { display: none !important; }
  .layout { display: block; }
}

/* grid/flex children must be allowed to shrink so wide code blocks scroll instead of overflowing the page */
.compare > div, .learn-grid > *, .http-demo > *, .ex-grid > *, .example, .callout .body { min-width: 0; }
.codeblock { max-width: 100%; }
.toc a, .nav-topic, .content h2, .content h3, .content p, .content li { overflow-wrap: anywhere; }

/* code: never render ligatures (<=, ==, => must look like what you type) */
pre, code, .seq-msg text, .widget input { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* language tabs for code samples */
.codetabs { margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); }
.codetabs .tab-bar { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); background: var(--surface-2); overflow-x: auto; }
.codetabs .tab { border: 0; background: transparent; color: var(--text-2); font: 600 12.5px var(--font); padding: 7px 12px; border-radius: 8px 8px 0 0; cursor: pointer; white-space: nowrap; }
.codetabs .tab:hover { color: var(--text); }
.codetabs .tab.active { background: var(--code-bg); color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.codetabs .codeblock { margin: 0; border: 0; border-radius: 0; }
.ex-card .ex-langs { display: flex; gap: 8px; margin-top: 10px; }
.ex-card .ex-lang { font: 700 12px var(--mono); padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.ex-card .ex-lang:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.codetabs .code-head span { visibility: hidden; }
.codetabs .code-head { border-bottom: 0; padding-bottom: 0; }

/* ---------- interview Q&A ---------- */
.iqa-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.iqa-bar p { margin: 0; color: var(--text-2); flex: 1; min-width: 220px; }
.iqa-toggle { font: 600 13px var(--font); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.iqa-toggle:hover { border-color: var(--accent); }
.iqa { margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.iqa-item { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.iqa-item > summary { list-style: none; cursor: pointer; padding: 13px 16px; display: flex; align-items: baseline; gap: 10px; font-weight: 600; line-height: 1.45; }
.iqa-item > summary::-webkit-details-marker { display: none; }
.iqa-item > summary .iqa-q { flex: 1; }
.iqa-item > summary .iqa-n { font: 700 12px var(--mono); color: var(--accent-text); min-width: 28px; }
.iqa-item > summary .chip { font-size: 11px; }
.iqa-item > summary .chip.senior { background: var(--purple-bg); color: var(--purple); }
.iqa-item > summary .tw { color: var(--text-3); transition: transform .2s; }
.iqa-item[open] > summary .tw { transform: rotate(180deg); }
.iqa-a { padding: 0 16px 14px 54px; border-top: 1px dashed var(--border); padding-top: 12px; }
.iqa-a > :first-child { margin-top: 0; }
.iqa-f { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; }
.iqa-f .lbl { font: 700 11px var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 4px; }
.iqa-f ul { margin: 0; padding-left: 18px; }
.iqa-f li { margin: 4px 0; }
@media (max-width: 640px) { .iqa-a { padding-left: 16px; } }

/* ---------- mock interview script ---------- */
.mock { margin: 16px 0 0; border-left: 2px solid var(--border); padding-left: 0; }
.mock-phase { display: flex; gap: 16px; padding: 12px 0 12px 16px; position: relative; }
.mock-phase::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.mock-time { font: 700 12.5px var(--mono); color: var(--accent-text); min-width: 74px; padding-top: 2px; }
.mock-body { flex: 1; min-width: 0; }
.mock-title { font-weight: 700; margin-bottom: 4px; }
.mock-body ul { margin: 4px 0; padding-left: 20px; }
@media (max-width: 640px) { .mock-phase { flex-direction: column; gap: 4px; } }

/* ---------- accounts: gate, login, user menu ---------- */
html.auth-gate body > *:not(.auth-overlay) { visibility: hidden; }
.auth-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 10%, var(--accent-2), transparent), var(--bg); overflow-y: auto; }
.auth-overlay.modal-overlay { background: rgba(10, 12, 20, .55); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.auth-card h2 { margin: 0 0 16px; font-size: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.auth-brand .logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8a3fd1); color: #fff; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface-2); margin-bottom: 18px; }
.auth-tabs button { border: 0; background: transparent; padding: 8px; border-radius: 8px; font: 600 14px var(--font); color: var(--text-2); cursor: pointer; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.auth-field input, .auth-field select, .auth-field textarea, .goal-notes textarea, .inline-field select, .goal-controls > select {
  font: 15px var(--font); padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; }
.auth-field input:focus, .auth-field textarea:focus, .goal-notes textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.auth-error { color: var(--red); font-size: 14px; min-height: 1em; }
.auth-hint { color: var(--text-3); font-size: 13px; margin: 14px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px var(--font); padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.user-menu { position: relative; margin-left: auto; margin-right: 8px; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; font: 600 14px var(--font); }
.user-btn .avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.user-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 50; }
.user-menu.open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--text); font: 14px var(--font); cursor: pointer; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown .who { padding: 6px 10px 8px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.locked-link { opacity: .55; }
.locked-link::after { content: " 🔒"; font-size: .85em; }
.locked-box { text-align: center; padding: 80px 20px; }
.locked-box .locked-icon { font-size: 48px; }
@media (max-width: 640px) { .user-btn .uname { display: none; } .user-btn { padding: 4px; } }

/* ---------- goal banner on lessons ---------- */
.goal-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent-2); border: 1px solid var(--border); font-size: 14.5px; }
.goal-banner .goal-text { flex: 1; min-width: 200px; }
.goal-tick { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.goal-err { color: var(--red); }

/* ---------- goals page ---------- */
.goals-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 8px 0 18px; }
.goal-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.goal-stats .stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; min-width: 76px; }
.goal-stats .stat b { display: block; font-size: 22px; }
.goal-stats .stat span { font-size: 12.5px; color: var(--text-3); }
.goal-stats .stat.ok b { color: var(--green); } .goal-stats .stat.bad b { color: var(--red); } .goal-stats .stat.warn b { color: var(--orange); }
.goal-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.goal-controls > select { width: auto; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.inline-field select { width: auto; }
.goal-list { display: flex; flex-direction: column; gap: 14px; }
.goal-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.goal-card.status-done { border-left-color: var(--green); }
.goal-card.status-not_done { border-left-color: var(--red); }
.goal-card.flash { outline: 2px solid var(--accent); }
.goal-top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.goal-title h3 { margin: 0 0 6px; font-size: 18px; }
.goal-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.deadline.bad { color: var(--red); border-color: var(--red); }
.chip.deadline.warn { color: var(--orange); }
.goal-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.status-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.status-toggle .btn { border: 0; border-radius: 0; background: var(--surface); font-size: 13px; padding: 7px 10px; }
.status-toggle .btn + .btn { border-left: 1px solid var(--border); }
.status-toggle .btn.active { background: var(--accent-2); color: var(--accent-text); }
.goal-more { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.goal-progress { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; }
.goal-progress .bar { flex: 1; height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.goal-progress .bar i { display: block; height: 100%; background: var(--green); }
.goal-progress .small { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.goal-topics { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2px 24px; }
.goal-topics li { padding: 4px 0; font-size: 14.5px; }
.goal-topics label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.goal-topics .topic-cat { display: block; margin-left: 26px; font-size: 12px; color: var(--text-3); }
.goal-notes { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.goal-notes label { display: flex; flex-direction: column; gap: 5px; width: 100%; font-size: 13px; font-weight: 600; color: var(--text-2); }
.goal-empty { text-align: center; padding: 50px 20px; color: var(--text-3); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.goal-empty div { font-size: 40px; }
.confirm-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.goal-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.goal-editor h2 { margin: 0; font-size: 19px; }
.editor-row { display: flex; flex-wrap: wrap; gap: 12px; }
.editor-row .grow { flex: 1; min-width: 220px; }
.editor-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.editor-actions { display: flex; gap: 10px; }
.muted { color: var(--text-3); }

/* ---------- tree picker ---------- */
.tree-picker { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg); }
.tree-picker .search { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 14px var(--font); }
.tree-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.tree-summary { font-size: 13px; color: var(--text-3); margin-left: auto; }
.tree-list { max-height: 380px; overflow-y: auto; }
.tree-cat > summary, .tree-group > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: 600; font-size: 14px; }
.tree-group { margin-left: 20px; }
.tree-group > summary { font-weight: 500; }
.tree-count { margin-left: auto; font: 600 12px var(--mono); color: var(--text-3); }
.tree-topic { display: flex; align-items: center; gap: 8px; margin-left: 44px; padding: 3px 0; font-size: 14px; cursor: pointer; }
.tree-topic .num { font: 600 12px var(--mono); color: var(--text-3); }

/* ---------- admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: top; }
.admin-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); background: var(--surface-2); }
.admin-table tr.disabled td { opacity: .55; }
.admin-table .small:not(.btn) { font-size: 12.5px; color: var(--text-3); }
.row-actions .btn { margin: 0 6px 6px 0; }
.admin-users { overflow-x: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; transition: all .25s; z-index: 2000;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }
.until-select { margin-left: auto; font: 12.5px var(--font); padding: 3px 6px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 46%; }
.until-link { font-size: 12px; }
.toc a.beyond-goal { opacity: .4; }

/* ---------- goal globe ---------- */
.globe-wrap { position: relative; margin: 4px 0 14px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: radial-gradient(800px 400px at 50% 40%, var(--accent-2), transparent 70%), var(--surface); box-shadow: var(--shadow); }
.globe-canvas { display: block; width: 100%; cursor: grab; touch-action: none; outline: none; }
.globe-canvas.dragging { cursor: grabbing; }
.globe-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.globe-tip { display: none; position: absolute; pointer-events: none; max-width: 220px; padding: 8px 10px; border-radius: 9px; font-size: 13px; line-height: 1.45;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 2; }
.globe-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--text-3); font-size: 14.5px; max-width: 70%; pointer-events: none; }
.globe-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.globe-legend .hint { margin-left: auto; color: var(--text-3); }
.globe-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: var(--text-3); }
.globe-legend .dot.ok { background: var(--green); } .globe-legend .dot.bad { background: var(--red); }
.globe-legend .dot.big { width: 14px; height: 14px; } .globe-legend .dot.small { width: 7px; height: 7px; }
.all-lessons { margin-bottom: 6px; }
@media (max-width: 640px) { .globe-legend .hint { margin-left: 0; } }
.locked-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- locked lessons and access requests ---------- */
.nav-topic.locked { opacity: .62; cursor: pointer; }
.nav-topic.locked .lock-ic { margin-left: auto; font-size: 11px; padding-left: 6px; }
.nav-topic.locked:hover { opacity: .9; }
.nav-topic.selected { opacity: 1; background: var(--accent-2); color: var(--accent-text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-topic.selected .lock-ic::before { content: "✓ "; }
.nav-topic.requested { cursor: default; }
.select-locked { margin-left: auto; font-size: 11px; color: var(--accent-text); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; cursor: pointer; white-space: nowrap; }
.select-locked:hover { border-color: var(--accent); }
.request-bar { display: none; position: sticky; bottom: 0; margin: 10px -8px -8px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(0,0,0,.08); }
.request-bar.show { display: block; }
.request-bar .rb-info { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.request-bar .rb-actions { display: flex; gap: 8px; }
.req-list { margin: 8px 0 14px; padding-left: 20px; font-size: 14px; max-height: 220px; overflow-y: auto; }
.req-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font: 700 11px var(--font); margin-left: 6px; }
.user-btn .req-badge { position: absolute; top: -4px; right: -4px; margin: 0; }
.user-btn { position: relative; }
.admin-h2 { font-size: 20px; margin: 6px 0 12px; }
.admin-requests { margin-bottom: 26px; }
.req-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.req-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.req-msg { margin: 0; font-style: italic; color: var(--text-2); }
.req-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; font-size: 14px; max-height: 240px; overflow-y: auto; }
.req-topics label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.req-note { font: 14px var(--font); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.req-history summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
.req-history ul { font-size: 14px; padding-left: 20px; }
.req-status.approved { color: var(--green); font-weight: 600; } .req-status.denied { color: var(--red); font-weight: 600; } .req-status.cancelled { color: var(--text-3); }

/* ---------- sidebar sections (accounts) ---------- */
.nav-section { margin: 12px 6px 4px; font: 700 11.5px var(--font); text-transform: uppercase; letter-spacing: .07em; color: var(--green); }
.nav-section.locked { color: var(--text-3); }
.nav-divider { border: 0; border-top: 1px solid var(--border); margin: 14px 4px 6px; }
.nav-note { margin: 0 8px 8px; font-size: 12px; line-height: 1.45; color: var(--text-3); }
.nav-empty { margin: 4px 8px 6px; font-size: 13px; color: var(--text-3); }
.locked-tree .nav-cat > button { opacity: .7; }

/* ---------- panel toggles and reading mode ---------- */
.menu-btn { display: grid; }
.panel-btn { font-size: 16px; }
#theme-btn { margin-left: 0; }
.crumbs { margin-right: auto; }
.reading-exit { display: none; }
@media (min-width: 901px) {
  html.hide-left .sidebar { display: none; }
  html.hide-left .layout { grid-template-columns: minmax(0, 1fr) var(--toc-w); }
  html.hide-left .layout.no-toc { grid-template-columns: minmax(0, 1fr); }
  html.hide-right .toc { display: none; }
  html.hide-right .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  html.hide-left.hide-right .layout { grid-template-columns: minmax(0, 1fr); }
  html.hide-right #toc-btn, html.hide-left #menu-btn { color: var(--text-3); }
}
@media (min-width: 901px) and (max-width: 1240px) {
  html.hide-left .layout { grid-template-columns: minmax(0, 1fr); }
  #toc-btn { display: none; }
}
@media (max-width: 1240px) { #toc-btn { display: none; } }
html.reading .topbar, html.reading .sidebar, html.reading .toc { display: none !important; }
html.reading .layout { grid-template-columns: minmax(0, 1fr) !important; min-height: 100vh; }
html.reading .main { padding-top: 48px; }
html.reading .content { max-width: 900px; font-size: 1.04em; }
html.reading .reading-exit { display: block; position: fixed; top: 12px; right: 16px; z-index: 60; font: 600 13px var(--font); padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; opacity: .55; box-shadow: var(--shadow); }
html.reading .reading-exit:hover { opacity: 1; }
