.courses-dialog { width: min(980px, 94vw); height: min(640px, 88vh); padding: 0; border: 1px solid #454545; border-radius: 12px; background: #1e1e1e; color: #ddd; box-shadow: 0 24px 80px #000b; overflow: hidden; }
.courses-dialog[open] { display: flex; flex-direction: column; }
.courses-dialog::backdrop { background: #0009; }
.cd-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #303031; background: #181818; }
.cd-total { margin-left: auto; color: #89d185; font-size: 13px; }
.cd-x { border: 0; background: transparent; color: #ccc; font-size: 22px; cursor: pointer; }
.cd-body { display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0; }
.cd-nav { overflow: auto; border-right: 1px solid #303031; background: #181818; padding: 8px; }
.cd-course { padding: 12px 8px 4px; } .cd-course b { display: block; } .cd-course small { color: #858585; }
.cd-lesson { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: #ccc; text-align: left; cursor: pointer; font: inherit; }
.cd-lesson:hover { background: #2a2d2e; } .cd-lesson.active { background: #264f78; color: #fff; }
.cd-main { overflow: auto; padding: 20px 24px; line-height: 1.65; }
.cd-main h2 { margin: 0 0 12px; font-size: 20px; }
.cd-main pre, .cd-main code { font-family: Consolas, "Courier New", monospace; }
.cd-main pre { padding: 12px 14px; border: 1px solid #303b48; border-radius: 8px; background: #111820; color: #dce5ef; direction: ltr; text-align: left; line-height: 1.7; overflow: auto; tab-size: 4; }
.cd-main code { padding: 1px 5px; border-radius: 4px; background: #2d2d2d; color: #f3c969; }
.cd-main pre code { padding: 0; background: none; }
.cd-task { margin: 16px 0; padding: 12px 14px; border-left: 3px solid #007acc; background: #252526; border-radius: 4px; }
.cd-primary { padding: 10px 18px; border: 0; border-radius: 8px; background: #007acc; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.lesson-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid #293544; background: #171e27; font-size: 13px; }
.lesson-bar[hidden] { display: none; }
.lb-title { min-width: 0; color: #e6edf5; font-weight: 650; }
.lb-msg { flex: 1 1 180px; min-width: 140px; color: #9baabd; } .lb-msg.good { color: #7ee0ad; } .lb-msg.bad { color: #ff9292; } .lb-msg.warn { color: #ffd27a; }
.lb-controls { display: flex; align-items: center; gap: 7px; margin-inline-start: auto; }
.lb-group { display: flex; align-items: center; gap: 5px; padding-inline-end: 8px; border-inline-end: 1px solid #344151; }
.lesson-bar button { min-height: 32px; padding: 5px 11px; border: 1px solid #354355; border-radius: 7px; background: #202a36; color: #dce5ef; font: inherit; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.lesson-bar button:hover { background: #2b3949; border-color: #50647a; color: #fff; }
.lesson-bar button:focus-visible { outline: 2px solid #70d4e5; outline-offset: 2px; }
.lesson-bar .lb-task.on { background: #17434d; border-color: #287887; color: #a9edf5; }
.lesson-bar .lb-next { background: #253c58; border-color: #385a80; color: #d8e9ff; }
.lesson-bar .lb-close { width: 32px; padding: 0; color: #aab6c5; font-size: 18px; }
@media (max-width: 720px) { .cd-body { grid-template-columns: 1fr; grid-template-rows: 180px 1fr; } .cd-nav { border-right: 0; border-bottom: 1px solid #303031; } }
.cd-simple { margin: 0 0 14px; padding: 12px 14px; border-radius: 8px; background: #1f3a2a; border: 1px solid #2f5a42; }
.cd-simple b, .cd-walk > b, .cd-mistakes > b, .cd-task > b { display: block; margin-bottom: 4px; }
.cd-simple p { margin: 0; color: #d6f0de; font-size: 15px; }
.cd-example { margin: 14px 0; padding: 14px; border: 1px solid #354355; border-radius: 10px; background: linear-gradient(145deg, #202a36, #1b242f); box-shadow: 0 8px 24px #0002; }
.cd-example-title { display: block; margin-bottom: 12px; color: #dcecff; font-size: 15px; }
.cd-io-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 12px; direction: ltr; }
.cd-io-card { min-width: 0; overflow: hidden; border: 1px solid #344252; border-radius: 8px; background: #111820; }
.cd-io-card > b { display: flex; align-items: center; gap: 7px; margin: 0; padding: 8px 11px; border-bottom: 1px solid #303b48; color: #dce5ef; font-size: 12px; letter-spacing: .02em; }
.cd-io-card > b::before { width: 7px; height: 7px; border-radius: 50%; background: #68c7d5; content: ""; }
.cd-example-code .CodeMirror, .cd-inline-code .CodeMirror { height: auto; min-height: 56px; padding: 8px 0; background: #111820; color: #dce5ef; font: 13px/1.7 Consolas, "Courier New", monospace; direction: ltr; text-align: left; }
.cd-example-code .CodeMirror-scroll, .cd-inline-code .CodeMirror-scroll { min-height: 0; overflow-x: auto !important; overflow-y: hidden !important; }
.cd-example-code .CodeMirror-gutters, .cd-inline-code .CodeMirror-gutters { border-right: 1px solid #293542; background: #151e28; }
.cd-example-code .CodeMirror-linenumber, .cd-inline-code .CodeMirror-linenumber { color: #637387; padding: 0 8px 0 5px; }
.cd-example-code .CodeMirror-lines, .cd-inline-code .CodeMirror-lines { padding: 0 8px; }
.cd-example-code .CodeMirror-cursor, .cd-inline-code .CodeMirror-cursor { display: none !important; }
.cd-inline-code { margin: 10px 0 14px; overflow: hidden; border: 1px solid #303b48; border-radius: 8px; background: #111820; }
.cd-io-input { border-color: #315c70; }
.cd-io-input > b { background: #142b37; color: #a9edf5; }
.cd-io-output { border-color: #315d48; }
.cd-io-output > b { background: #172c22; color: #a9e6bb; }
.cd-io-output > b::before { background: #72d69a; }
.cd-main .cd-io-card pre.cd-example-output { min-height: 56px; margin: 0; padding: 12px; border: 0; border-radius: 0; background: #101b15; color: #b9f0c8; font: 13px/1.7 Consolas, "Courier New", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.cd-example .cd-walk { margin: 14px 0 0; }
.cd-example .cd-walk > b { color: #a9edf5; }
.cd-main pre code { color: inherit; }
.cd-walk { margin: 14px 0; } .cd-walk-row { display: grid; grid-template-columns: minmax(150px, 40%) 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid #303031; align-items: start; }
.cd-walk-row code { direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-word; }
.cd-mistakes { margin: 14px 0; padding: 10px 14px; border-radius: 8px; background: #3a2a1f; border: 1px solid #5a432f; } .cd-mistakes ul { margin: 4px 0 0; padding-inline-start: 20px; }
.cd-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cd-secondary { padding: 10px 18px; border: 1px solid #454545; border-radius: 8px; background: #252526; color: #ddd; font: inherit; cursor: pointer; }
@media (max-width: 720px) { .cd-walk-row { grid-template-columns: 1fr; gap: 2px; } }
@media (max-width: 720px) { .cd-io-grid { grid-template-columns: 1fr; } }
.file-row.lesson-file .file-type, .python-file-icon.lesson-icon { width: auto; min-width: 34px; color: #89d185; font-weight: 700; }
.activity-button .courses-icon { display: block; width: 20px; height: 20px; }
.file-row.lesson-file .file-name { color: #d6f0de; }
.task-panel { flex: 0 0 auto; max-height: 40%; overflow: auto; padding: 10px 14px 12px; border-bottom: 1px solid #293544; background: #1c2530; color: #dce5ef; font-size: 13px; line-height: 1.6; }
.task-panel[hidden] { display: none; }
.task-panel.right { border-bottom: 1px solid #293544; border-left: 1px solid #293544; border-top: 1px solid #293544; flex: 0 0 320px; max-height: 100%; border-bottom: 0; }
.task-panel.left { border-bottom: 1px solid #293544; border-right: 1px solid #293544; border-top: 1px solid #293544; flex: 0 0 320px; max-height: 100%; border-bottom: 0; }
.tp-head { display: flex; justify-content: flex-end; padding-bottom: 6px; }
.tp-menu { border: 0; background: transparent; color: #78d5e4; font-size: 18px; cursor: pointer; padding: 0 4px; border-radius: 4px; }
.tp-menu:hover { background: #293946; }
.tp-section { margin-bottom: 8px; } .tp-section > b { display: block; margin-bottom: 3px; color: #78d5e4; font-size: 11px; letter-spacing: .04em; }
.tp-task code { padding: 1px 5px; border-radius: 4px; background: #293946; color: #e2edf6; font-family: Consolas, "Courier New", monospace; direction: ltr; unicode-bidi: isolate; }
.tp-expected { margin: 0; padding: 8px 10px; border: 1px solid #293846; border-radius: 6px; background: #111820; color: #dce5ef; font: 12px/1.5 Consolas, "Courier New", monospace; direction: ltr; text-align: left; overflow: auto; }
.tp-reqs ul { margin: 0; padding: 0; list-style: none; } .tp-reqs li { color: #aab6c5; } .tp-reqs li.ok { color: #7ee0ad; }
.tp-compare { margin-top: 6px; padding-top: 8px; border-top: 1px dashed #36495d; }
.tp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; direction: ltr; }
.tp-col > b { display: block; margin-bottom: 3px; color: #78d5e4; font-size: 11px; }
.tp-col pre { margin: 0; padding: 6px 0; border-radius: 6px; background: #111820; font: 12px/1.5 Consolas, "Courier New", monospace; overflow: auto; text-align: left; }
.tp-col .ln { padding: 0 10px; white-space: pre; } .tp-col .ln.bad { background: #5b282b; color: #ffc0b8; }
.lesson-bar button.on { background: #264f78; border-color: #264f78; color: #fff; }
.tp-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 10px; border-top: 1px solid #303b48; justify-content: center; }
.tp-nav-btn { padding: 6px 14px; border: 1px solid #454545; border-radius: 6px; background: #252526; color: #ddd; font: inherit; cursor: pointer; font-size: 12px; }
.tp-nav-btn:hover { background: #333; color: #fff; border-color: #666; }
.tp-nav-btn:disabled { opacity: .5; cursor: not-allowed; }
.tp-nav-btn.solution { border-color: #2f5a42; background: #1f3a2a; color: #7ee0ad; }
.tp-nav-btn.solution:hover { background: #2a4a37; color: #aaf0c4; border-color: #3d7a55; }
.tp-nav-btn.solution.on { background: #2f5a42; border-color: #2f5a42; color: #fff; }
.tp-solution { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #36495d; }
.tp-solution > b { display: block; margin-bottom: 6px; color: #7ee0ad; font-size: 12px; letter-spacing: .04em; }
.tp-solution pre { margin: 0; padding: 0; overflow: hidden; }
.tp-solution .CodeMirror { height: auto; min-height: 42px; padding: 8px 0; background: #111820; color: #dce5ef; font: 12px/1.5 Consolas, "Courier New", monospace; direction: ltr; text-align: left; }
.tp-solution .CodeMirror-scroll { min-height: 0; overflow-x: auto !important; overflow-y: hidden !important; }
.tp-solution .CodeMirror-gutters { border-right: 1px solid #293542; background: #151e28; }
.tp-solution .CodeMirror-linenumber { color: #637387; padding: 0 8px 0 5px; }
.tp-solution .CodeMirror-lines { padding: 0 8px; }
.tp-title { margin: 0 0 12px; padding: 8px 10px; border-radius: 6px; background: #1a2332; color: #e6edf5; font-size: 13px; font-weight: 600; }
.tp-title b { color: #78d5e4; }
.tp-open { width: 100%; padding: 6px 12px; border: 1px solid #454545; border-radius: 6px; background: #252526; color: #ddd; font: inherit; cursor: pointer; font-size: 12px; margin-bottom: 14px; }
.tp-open:hover { background: #333; color: #fff; border-color: #666; }
@media (max-width: 720px) { .tp-cols { grid-template-columns: 1fr; } }

/* The course reader is styled like an open, illustrated study book. */
.courses-dialog { width: min(1120px, 96vw); height: min(780px, 92vh); border-color: #765b37; background: #332819; box-shadow: 0 28px 100px #000c; }
.courses-dialog::backdrop { background: #100c08c9; backdrop-filter: blur(4px); }
.cd-head { min-height: 52px; padding-inline: 20px; color: #f7e8c8; border-bottom-color: #624b2e; background: linear-gradient(110deg, #49351f, #2f2419); }
.cd-head strong::before { content: "✦  "; color: #efc46c; }
.cd-total { color: #d7b46c; }
.cd-body { grid-template-columns: 275px minmax(0, 1fr); gap: 0; background: #eee3c9; }
.cd-nav { padding: 18px 12px; border-color: #c2ae88; background: linear-gradient(90deg, #e4d5b5, #efe5ce); color: #493722; }
.cd-course { margin: 0 4px 8px; padding: 14px 10px 7px; border-bottom: 1px solid #cdbb98; }
.cd-course b { color: #594126; font-size: 14px; line-height: 1.5; }
.cd-course small { color: #826a48; }
.cd-lesson { margin: 3px 0; padding: 9px 10px; color: #594b36; text-align: start; line-height: 1.45; transition: transform .18s, background .18s, box-shadow .18s; }
.cd-lesson:hover { transform: translateX(-3px); background: #f8f0dd; }
.cd-lesson.active { color: #fff9e9; background: #7f5b2d; box-shadow: 0 3px 10px #68461e3b; }
.cd-main { position: relative; padding: clamp(20px, 4vw, 44px) clamp(20px, 5vw, 58px); color: #3e3325; background-color: #f5eddc; background-image: linear-gradient(90deg, #bca77a12 1px, transparent 1px), linear-gradient(#bca77a0b 1px, transparent 1px); background-size: 100% 30px; box-shadow: inset 10px 0 24px #61481b12; line-height: 1.9; }
.cd-main::before { position: absolute; top: 0; bottom: 0; inset-inline-start: 18px; width: 1px; background: #be936844; content: ""; pointer-events: none; }
.cd-main h2 { padding-bottom: 12px; margin-bottom: 20px; color: #49371f; border-bottom: 2px solid #d3bd91; font-size: clamp(20px, 2.4vw, 27px); line-height: 1.45; }
.cd-main .cd-text { font-size: 16px; line-height: 2; }
.cd-main .cd-text b { color: #765321; }
.cd-main .cd-simple { background: #e5eedf; border-color: #b3cba4; box-shadow: 0 3px 9px #5745230b; }
.cd-simple p { color: #344a31; line-height: 1.85; }
.cd-example { border-color: #c7b58f; background: linear-gradient(145deg, #eee2c7, #e8dcc1); box-shadow: 0 8px 20px #563d1a12; }
.cd-example-title { color: #67491f; }
.cd-main .cd-task { color: #44351f; border-inline-start: 0; border-inline-end: 4px solid #bd8a3a; background: #f1dfb9; line-height: 1.9; }
.cd-main .cd-task > b { color: #73501d; }
.cd-main .cd-mistakes { color: #5d3a2b; border-color: #dec2aa; background: #f2e0d2; }
.cd-main .cd-mistakes > b { color: #834b30; }
.cd-main .cd-mistakes li { margin-block: 5px; line-height: 1.75; }
.cd-main .cd-secondary { border-color: #b9a47b; background: #f1e7d2; color: #59472a; }
.cd-main .cd-secondary:hover { background: #e8d8b9; }
.cd-main .cd-primary { background: #725126; }
.cd-page-turn { animation: bookPageTurn .48s cubic-bezier(.2,.72,.25,1) both; transform-origin: center right; }
.cd-main[dir="rtl"].cd-page-turn { transform-origin: center left; }
@keyframes bookPageTurn { from { opacity: .35; transform: perspective(1200px) rotateY(-5deg) translateX(10px); } to { opacity: 1; transform: perspective(1200px) rotateY(0) translateX(0); } }
.cd-page-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 26px; padding: 16px 0 4px; border-top: 1px solid #cbb891; }
.cd-page-button { min-height: 42px; padding: 8px 15px; border: 1px solid #a78b5e; border-radius: 8px; background: #e9dcc1; color: #594322; font: inherit; cursor: pointer; transition: transform .18s, background .18s; }
.cd-page-button:first-child { justify-self: start; }
.cd-page-button:last-child { justify-self: end; }
.cd-page-button:hover:not(:disabled) { transform: translateY(-2px); background: #dfcda8; }
.cd-page-button:disabled { opacity: .45; cursor: default; }
.cd-page-mark { color: #826b48; font-size: 13px; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .cd-page-turn { animation: none; } .cd-page-button, .cd-lesson { transition: none; } }
@media (max-width: 720px) {
  .cd-body { grid-template-columns: 1fr; grid-template-rows: 156px minmax(0, 1fr); }
  .cd-nav { border-right: 0; border-bottom: 1px solid #c2ae88; }
  .cd-main { padding: 24px 24px 32px; }
  .cd-main::before { inset-inline-start: 9px; }
}
@media (max-width: 760px) {
  .lesson-bar { gap: 6px 10px; padding: 8px 10px; }
  .lb-title { flex: 1 1 auto; }
  .lb-msg { order: 2; flex-basis: 100%; }
  .lb-controls { order: 3; flex: 1 1 100%; margin-inline-start: 0; flex-wrap: wrap; }
  .lb-group { padding-inline-end: 6px; }
}
