:root {
  color-scheme: dark;
  --page: #10111b;
  --nav: #151622;
  --surface: #1b1c2a;
  --raised: #24263a;
  --line: #34364c;
  --text: #f2f1ff;
  --muted: #a5a8c1;
  --accent: #d9fc8b;
  --accent-ink: #202918;
  --violet: #bfb3ff;
  --plot: #17182b;
  --plot-grid: #30334e;
  --plot-panel: #252744;
  --plot-label: #d6d8f0;
  --plot-muted: #747caa;
  --plot-route: #d9fc8b;
  --plot-packet: #f5ffc9;
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
:root[data-theme=light] {
  color-scheme: light;
  --page: #f5f5fb;
  --nav: #eeedf8;
  --surface: #fff;
  --raised: #ece9fc;
  --line: #d6d4e7;
  --text: #272139;
  --muted: #5e5873;
  --accent: #5f3bc8;
  --accent-ink: #fff;
  --violet: #5d3abc;
  --plot: #efedf9;
  --plot-grid: #d9d5ee;
  --plot-panel: #fff;
  --plot-label: #322b57;
  --plot-muted: #69628b;
  --plot-route: #693acb;
  --plot-packet: #5932ad;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.topbar { display: flex; align-items: center; gap: 18px; min-height: 65px; padding: 10px 26px; border-bottom: 1px solid var(--line); background: var(--nav); position: sticky; top: 0; z-index: 3; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 750; white-space: nowrap; letter-spacing: -.025em; }
.brand-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 9px; background: var(--violet); color: #211941; font-size: 23px; }
:root[data-theme=light] .brand-icon { color: white; }
.search-trigger, .icon-button, .button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; }
.search-trigger { display: flex; align-items: center; gap: 9px; margin-left: auto; padding: 6px 10px; min-width: 240px; color: var(--muted); text-align: left; font-size: .875rem; }
.search-trigger > span:first-child { font-size: 1.2rem; }
kbd { margin-left: auto; border-radius: 5px; background: var(--raised); border: 1px solid var(--line); padding: 1px 5px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; font-size: 1.2rem; line-height: 1; }
.icon-button:hover, .outline:hover, .search-trigger:hover { background: var(--raised); }
.menu { display: none; }
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 65px); }
.sidebar { display: flex; flex-direction: column; min-height: 0; position: sticky; top: 65px; height: calc(100dvh - 65px); background: var(--nav); border-right: 1px solid var(--line); padding: 22px 14px 14px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 15px; gap: 8px; }
.sidebar-head h2, .timeline h2 { font-size: .95rem; margin: 0; }
.sidebar-head span, .timeline-head span { color: var(--muted); font-size: .8rem; }
#course-nav { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 0 4px 12px; scrollbar-width: thin; }
.module-group { margin-bottom: 7px; }
.module-group summary { cursor: pointer; min-height: 38px; padding: 8px 4px; font-weight: 650; font-size: .85rem; }
.module-group summary::marker { color: var(--violet); }
.module-group summary small { float: right; color: var(--muted); font-size: .73rem; font-weight: 500; }
.lesson-link { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 9px 8px 16px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .85rem; line-height: 1.35; }
.lesson-link::before { content: '·'; color: var(--violet); font-size: 1.1rem; line-height: 1; }
.lesson-link:hover, .lesson-link[aria-current] { background: var(--raised); color: var(--text); }
.lesson-link[aria-current] { box-shadow: inset 2px 0 var(--violet); }
.lesson-link .check { margin-left: auto; color: var(--accent); }
.progress-card { margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.progress-head { display: flex; justify-content: space-between; font-size: .8rem; }
.progress-head span { color: var(--accent); }
progress { width: 100%; height: 7px; accent-color: var(--accent); }
.plain { background: none; border: 0; color: var(--muted); padding: 4px 0; font-size: .8rem; }
.plain:hover { text-decoration: underline; }
.main { min-width: 0; width: 100%; max-width: 1700px; margin: 0 auto; padding: 29px clamp(15px, 3vw, 46px) 38px; }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.module { color: var(--violet); font-size: .875rem; font-weight: 650; }
h1 { margin: 7px 0 7px; font-size: clamp(2rem, 4vw, 3.45rem); line-height: 1.08; letter-spacing: -.065em; }
.brief { margin: 0; max-width: 65ch; color: var(--muted); }
.lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(265px, 320px); gap: 15px; }
.visual, .guide, .timeline, .challenge { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); min-width: 0; }
.visual { overflow: hidden; }
.visual-head, .visual-foot { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eyebrow { color: var(--violet); font-size: .73rem; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.visual-head strong { font-size: 1rem; }
.scenario { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.scenario select { padding: 5px 7px; min-height: 35px; max-width: 155px; border: 1px solid var(--line); border-radius: 7px; background: var(--raised); color: var(--text); }
.stage { background: var(--plot); position: relative; border-block: 1px solid var(--line); }
canvas { display: block; width: 100%; height: clamp(285px, 38vh, 440px); }
.stage-legend, .transfer { position: absolute; bottom: 10px; font-size: .76rem; border-radius: 7px; }
.stage-legend { left: 13px; color: var(--plot-muted); display: flex; align-items: center; gap: 6px; }
.legend-line { width: 13px; height: 3px; background: var(--plot-route); border-radius: 3px; }
.transfer { right: 13px; padding: 3px 8px; color: var(--plot-label); background: var(--plot-panel); max-width: 54%; text-align: right; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.metric { padding: 8px 11px; min-width: 0; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: .69rem; }
.metric strong { display: block; font-size: .95rem; font-variant-numeric: tabular-nums; }
.metric.current strong { color: var(--accent); }
.route-label { color: var(--muted); font-size: .78rem; }
.playback, .guide-buttons { display: flex; align-items: center; gap: 7px; }
.button { padding: 8px 12px; font-weight: 650; font-size: .85rem; min-height: 38px; white-space: nowrap; }
.button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.completion[aria-pressed=true] { color: var(--accent); }
.guide { display: flex; flex-direction: column; justify-content: space-between; gap: 20px; padding: 22px; }
.guide h2 { margin: 12px 0 10px; font-size: clamp(1.35rem, 2.5vw, 1.8rem); line-height: 1.18; letter-spacing: -.035em; }
.guide p { color: var(--muted); margin: 0; line-height: 1.65; }
.observation { margin-top: 17px; padding: 12px; border-radius: 8px; background: var(--raised); border-left: 3px solid var(--violet); }
.observation p { margin-top: 4px; font-size: .9rem; }
.guide-buttons { justify-content: space-between; }
.timeline { margin-top: 15px; padding: 12px 14px; }
.timeline-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
#steps { display: flex; gap: 6px; overflow: auto; padding: 4px 4px 7px; margin: 0; list-style: none; scrollbar-width: thin; }
#steps li { flex: 1 0 100px; }
.step-button { padding: 8px; width: 100%; min-height: 58px; border: 1px solid var(--line); border-radius: 8px; text-align: left; background: var(--nav); color: var(--muted); line-height: 1.25; font-size: .78rem; }
.step-button span { display: block; color: var(--violet); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.step-button:hover, .step-button[aria-current] { background: var(--raised); color: var(--text); }
.step-button[aria-current] { border-color: var(--violet); }
.challenge { margin-top: 15px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.challenge p { margin: 4px 0 0; color: var(--muted); font-size: .93rem; }
dialog { width: min(560px, calc(100% - 28px)); max-height: min(620px, 90vh); padding: 19px; color: var(--text); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
dialog::backdrop { background: #0c0b17aa; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.dialog-head h2 { margin: 0; font-size: 1.23rem; }
#search { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: var(--nav); color: var(--text); }
.search-results { max-height: 415px; overflow: auto; padding: 8px 3px; }
.search-result { display: block; padding: 9px; border-radius: 7px; text-decoration: none; }
.search-result:hover, .search-result:focus-visible { background: var(--raised); }
.search-result small { display: block; color: var(--muted); }
@media (max-width: 1160px) { .lab { grid-template-columns: minmax(0, 1fr) 260px; } .layout { grid-template-columns: 212px minmax(0, 1fr); } .guide { padding: 15px; } }
@media (max-width: 960px) { .lab { grid-template-columns: 1fr; } .guide { padding: 18px; } }
@media (max-width: 700px) {
  .topbar { min-height: 58px; gap: 8px; padding: 8px 10px; }
  .brand { font-size: .85rem; gap: 5px; } .brand-icon { width: 26px; height: 26px; font-size: 19px; }
  .menu { display: grid; }
  .search-trigger { min-width: 0; font-size: .76rem; gap: 5px; } kbd { display: none; }
  .layout { display: block; }
  .sidebar { display: none; position: fixed; top: 58px; height: calc(100dvh - 58px); z-index: 2; width: min(285px, 88vw); box-shadow: 20px 0 40px #0005; }
  .sidebar.open { display: flex; }
  .main { padding-top: 22px; }
  .lesson-head { display: block; } .completion { margin-top: 12px; }
  .challenge { align-items: flex-start; flex-direction: column; }
  .metrics .metric { padding: 6px; } .metric span { font-size: .62rem; }
  .route-label { font-size: .72rem; }
}
@media (max-width: 365px) { .search-trigger span:nth-child(2) { display: none; } .visual-head { align-items: flex-start; } .scenario { display: block; } }
