:root {
  color-scheme: light;
  --navy: #0d1d32;
  --navy-2: #142b48;
  --blue: #2878ff;
  --cyan: #26b6c9;
  --ink: #172335;
  --muted: #69768a;
  --line: #dce3ea;
  --paper: #f5f7f9;
  --panel: #ffffff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: var(--paper); }
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
kbd, code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.course-app { height: 100dvh; display: flex; flex-direction: column; }
.course-header {
  height: 68px;
  flex: 0 0 68px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 310px 1fr auto;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
  color: #fff;
  background: var(--navy);
  position: relative;
  z-index: 30;
}
.course-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.course-brand img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.2); }
.course-brand span, .course-brand b, .course-brand small { display: block; min-width: 0; }
.course-brand b { font-size: 15px; letter-spacing: .02em; }
.course-brand small { margin-top: 3px; color: #8fa4bb; font-size: 10px; }
.course-runtime { justify-self: center; display: flex; align-items: center; gap: 8px; color: #cbd8e7; font-size: 11px; }
.course-runtime i { width: 8px; height: 8px; border-radius: 50%; background: #30d9a0; box-shadow: 0 0 0 5px rgba(48,217,160,.12); }
.course-header-actions { display: flex; align-items: center; gap: 8px; }
.course-header-actions button, .course-header-actions a {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  color: #e9f0f7;
  background: rgba(255,255,255,.06);
  cursor: pointer;
}
.course-header-actions button:hover, .course-header-actions a:hover { background: rgba(255,255,255,.13); }
.mobile-only, .mobile-label { display: none !important; }

.course-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 270px minmax(500px,1fr) 340px;
  transition: grid-template-columns .22s ease;
}
.explanation-hidden .course-layout { grid-template-columns: 270px minmax(500px,1fr) 0; }

.lesson-sidebar {
  min-height: 0;
  overflow-y: auto;
  color: #dce8f5;
  background: #10243c;
  border-right: 1px solid rgba(255,255,255,.08);
  scrollbar-width: thin;
}
.sidebar-heading { padding: 25px 22px 18px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-heading > span { color: #58c7d5; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.sidebar-heading h1 { margin: 11px 0 20px; font: 600 22px/1.35 "Songti SC", Georgia, serif; color: #fff; }
.course-progress { height: 5px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.1); }
.course-progress i { width: 0; height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg,#26b6c9,#3b8cff); transition: width .3s ease; }
.sidebar-heading p { margin: 8px 0 0; color: #8fa5bd; font-size: 10px; }
.sidebar-heading p b { color: #fff; }
#lessonList { padding: 10px; display: grid; gap: 3px; }
.lesson-link {
  width: 100%; min-height: 61px; padding: 9px 11px;
  display: grid; grid-template-columns: 30px 1fr 18px; align-items: center; gap: 8px;
  border: 0; border-radius: 9px; text-align: left; color: #b7c7d7; background: transparent; cursor: pointer;
}
.lesson-link:hover { background: rgba(255,255,255,.06); }
.lesson-link.active { color: #fff; background: #1a3859; box-shadow: inset 3px 0 #39bfd0; }
.lesson-link > span:first-child { color: #5e7996; font-size: 10px; font-weight: 800; }
.lesson-link.active > span:first-child { color: #67d2df; }
.lesson-link span, .lesson-link b, .lesson-link small { display: block; min-width: 0; }
.lesson-link b { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.lesson-link small { margin-top: 5px; color: #7890a9; font-size: 8px; }
.lesson-link i { color: #69829d; font-size: 17px; font-style: normal; text-align: center; }
.lesson-link.completed i { color: #38d19b; }
.sidebar-license { margin: 8px 14px 18px; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: 10px; color: #8fa5bd; font-size: 8px; line-height: 1.7; }
.sidebar-license b { color: #dce8f5; font-size: 9px; }.sidebar-license p { margin: 7px 0; }.sidebar-license a { color: #5fcbd8; }

.lab-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #eef2f5; }
.lesson-toolbar {
  min-height: 74px;
  padding: 11px 16px 11px 20px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(190px,1fr) auto auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.lesson-toolbar > div:first-child { min-width: 0; }
.lesson-toolbar span { color: #458296; font-size: 8px; font-weight: 850; letter-spacing: .12em; }
.lesson-toolbar h2 { margin: 4px 0 0; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.lab-tips { display: flex; align-items: center; gap: 6px; }
.lab-tips > span { padding: 6px 8px; border-radius: 6px; color: #6c7788; background: #f4f6f8; font-size: 8px; font-weight: 600; letter-spacing: 0; white-space: nowrap; }
.lab-tips kbd { padding: 1px 3px; border: 1px solid #ced6de; border-bottom-width: 2px; border-radius: 3px; color: #344357; background: #fff; }
.lab-tips code { color: #1c6580; }
.complete-button { height: 34px; padding: 0 12px; border: 1px solid #cad5df; border-radius: 8px; color: #405267; background: #fff; font-size: 10px; font-weight: 700; cursor: pointer; }
.complete-button:hover { border-color: #43aebe; color: #14798b; }
.complete-button.done { border-color: #bde9d7; color: #188761; background: #ecfbf5; }

.lab-frame-wrap { min-height: 0; flex: 1; position: relative; background: #fff; }
#labFrame { width: 100%; height: 100%; display: block; border: 0; background: #fff; }
.lab-loading {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  color: #435469; background: #f7f9fb;
}
.lab-loading[hidden] { display: none; }
.lab-loading strong { margin-top: 5px; font-size: 14px; }.lab-loading span { color: #8793a1; font-size: 9px; }
.python-orbit { width: 58px; height: 58px; display: grid; place-items: center; border: 2px solid #d4e5ee; border-top-color: #28a8bf; border-radius: 50%; animation: orbit 1.1s linear infinite; }
.python-orbit b { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; background: linear-gradient(145deg,#298bd8,#1ba6a0); animation: orbitReverse 1.1s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } } @keyframes orbitReverse { to { transform: rotate(-360deg); } }
.lab-statusbar { min-height: 31px; padding: 0 14px; flex: 0 0 auto; display: flex; align-items: center; gap: 15px; border-top: 1px solid var(--line); color: #798797; background: #f8fafb; font-size: 8px; }
.lab-statusbar span::before { content: "✓"; margin-right: 5px; color: #24a879; }.lab-statusbar button { margin-left: auto; border: 0; color: #3a7e98; background: transparent; font-size: 8px; cursor: pointer; }

.explanation-panel {
  min-width: 0; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: #fff;
  transition: opacity .16s ease, transform .2s ease;
}
.explanation-hidden .explanation-panel { opacity: 0; pointer-events: none; transform: translateX(18px); }
.explanation-head { min-height: 74px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.explanation-head span { color: #b2693b; font-size: 8px; font-weight: 850; letter-spacing: .13em; }
.explanation-head h2 { margin: 5px 0 0; font-size: 18px; }
.explanation-head button { width: 30px; height: 30px; border: 1px solid #d9e0e7; border-radius: 50%; color: #6f7b89; background: #fff; cursor: pointer; }
.explanation-tabs { padding: 10px 14px; display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; border-bottom: 1px solid #e8edf1; }
.explanation-tabs button { height: 32px; border: 0; border-radius: 7px; color: #7b8795; background: transparent; font-size: 9px; font-weight: 700; cursor: pointer; }
.explanation-tabs button.active { color: #183a50; background: #eaf5f7; }
.explanation-content { padding: 24px 21px; flex: 1; }
.note-index { color: #dce3e9; font: 700 54px/1 Georgia, serif; }
.explanation-content h3 { margin: 10px 0 13px; font: 600 23px/1.35 "Songti SC", Georgia, serif; }
.explanation-content > p { color: #687586; font-size: 11px; line-height: 1.75; }
.explanation-content ul { margin: 22px 0 0; padding: 0; display: grid; gap: 9px; list-style: none; }
.explanation-content li { padding: 12px 13px 12px 34px; position: relative; border: 1px solid #e2e8ed; border-radius: 9px; color: #415064; background: #fafbfc; font-size: 10px; }
.explanation-content li::before { content: "✓"; position: absolute; left: 12px; color: #20a67b; font-weight: 900; }
.note-label { display: inline-block; padding: 5px 8px; border-radius: 5px; color: #176579; background: #e7f6f8; font-size: 8px; font-weight: 800; }.note-label.answer { color: #9a5c2a; background: #fff0e4; }
.hint-card { margin-top: 21px; padding: 15px; border-left: 3px solid #3cb3c4; color: #526174; background: #eef8fa; font-size: 10px; line-height: 1.7; }.hint-card b { color: #1e6372; }.hint-card p { margin: 5px 0 0; }
.note-secondary { margin-top: 18px; color: #8994a0 !important; font-size: 9px !important; }.note-secondary code { color: #136b7b; }
.reveal-answer, .copy-answer { width: 100%; min-height: 42px; margin-top: 16px; border: 0; border-radius: 8px; color: #fff; background: var(--navy-2); font-size: 10px; font-weight: 750; cursor: pointer; }
.explanation-content pre { max-height: 360px; margin: 18px 0 0; padding: 15px; overflow: auto; border-radius: 9px; color: #dcecff; background: #10243b; font-size: 9px; line-height: 1.65; white-space: pre-wrap; }
.copy-answer { min-height: 36px; margin-top: 8px; color: #365063; background: #edf2f5; }
.explanation-foot { margin: 0 16px 16px; padding: 14px; border: 1px solid #e3e8ed; border-radius: 10px; color: #738091; background: #fafbfc; font-size: 8px; line-height: 1.65; }
.explanation-foot b { display: block; margin-bottom: 8px; color: #37475a; font-size: 9px; }.explanation-foot code { display: inline-block; margin: 0 4px 5px 0; padding: 4px 6px; border-radius: 4px; color: #1a6577; background: #e8f4f6; }.explanation-foot p { margin: 2px 0 0; }
.explanation-fab { display: none; }
.course-backdrop { display: none; }

@media (max-width: 1180px) {
  .course-layout { grid-template-columns: 245px minmax(460px,1fr) 300px; }
  .explanation-hidden .course-layout { grid-template-columns: 245px minmax(460px,1fr) 0; }
  .course-header { grid-template-columns: 280px 1fr auto; }
  .lab-tips span:nth-child(3) { display: none; }
}

@media (max-width: 900px) {
  body { overflow: hidden; }
  .course-header { height: 60px; flex-basis: 60px; grid-template-columns: 1fr auto; padding: 0 11px; }
  .course-brand img { width: 34px; height: 34px; }.course-brand b { font-size: 13px; }.course-brand small { font-size: 8px; }
  .course-runtime { display: none; }.course-header-actions { gap: 5px; }.course-header-actions button, .course-header-actions a { height: 33px; padding: 0 10px; font-size: 10px; }
  .mobile-only, .mobile-label { display: inline-flex !important; }.wide-label { display: none; }
  .course-layout, .explanation-hidden .course-layout { grid-template-columns: minmax(0,1fr); position: relative; }
  .lesson-sidebar { width: min(330px,88vw); position: fixed; top: 60px; bottom: 0; left: 0; z-index: 25; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.23); }
  .lessons-open .lesson-sidebar { transform: translateX(0); }
  .course-backdrop { position: fixed; inset: 60px 0 0; z-index: 24; background: rgba(8,18,31,.48); }
  .lessons-open .course-backdrop { display: block; }
  .lesson-toolbar { min-height: 69px; grid-template-columns: 1fr auto; padding: 9px 11px; gap: 8px; }.lesson-toolbar h2 { font-size: 16px; }.lab-tips { display: none; }
  .complete-button { height: 32px; padding: 0 9px; font-size: 9px; }
  .lab-statusbar { padding: 0 9px; }.lab-statusbar span:nth-child(2) { display: none; }
  .explanation-panel { width: min(390px,94vw); max-height: 72vh; position: fixed; right: 3vw; bottom: 10px; z-index: 28; border: 1px solid #d7dfe6; border-radius: 17px; box-shadow: 0 24px 70px rgba(9,25,42,.3); transform: translateY(0); }
  .explanation-hidden .explanation-panel { transform: translateY(calc(100% + 30px)); }
  .explanation-head { min-height: 62px; }.explanation-content { padding: 18px; overflow-y: auto; }.explanation-content h3 { font-size: 20px; }
  .explanation-foot { display: none; }
  .explanation-fab { display: block; position: fixed; right: 13px; bottom: 45px; z-index: 27; min-height: 38px; padding: 0 15px; border: 0; border-radius: 99px; color: #fff; background: var(--navy-2); box-shadow: 0 10px 25px rgba(10,37,60,.25); font-size: 10px; }
  .course-app:not(.explanation-hidden) .explanation-fab { display: none; }
}

@media (max-width: 520px) {
  .course-brand small { display: none; }
  .course-header-actions a { display: none; }
  .lesson-toolbar { min-height: 66px; }.lesson-toolbar span { font-size: 7px; }.lesson-toolbar h2 { font-size: 14px; }
  .lab-statusbar span { display: none; }.lab-statusbar button { margin-left: 0; }
  .lab-loading { padding: 20px; text-align: center; }.lab-loading span { line-height: 1.5; }
  .explanation-panel { right: 2vw; width: 96vw; bottom: 7px; max-height: 78vh; }
}
