/* 仰望星空 · Course workspace. Shared brand marks live in brand.css. */

@font-face {
  font-family: "Xingkong Course Serif";
  src: url("/assets/course-title-serif.woff2") format("woff2");
  font-weight: 380;
  font-display: swap;
}

/* Foundations */
:root {
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  --green: var(--accent);
  --light: var(--accent-soft);
  --sidebar-width: 264px;
}
/* Reading surfaces stay quiet; gold is reserved for the brand mark. */
html[data-theme="day"] body.site-interior.course-learning-page {
  --page: #f3f5f7;
  --paper: #f3f5f7;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-raised: #eef1f4;
  --field: #f7f9fb;
  --ink: #283440;
  --muted: #586776;
  --line: #dce2e8;
  --line-strong: #b6c2cd;
  --accent: #425f76;
  --action: #425f76;
  --accent-soft: #e8eef3;
  --gold: #9c7a42;
  --gold-bright: #344d61;
  --gold-ink: #ffffff;
  --focus: #425f76;
  --danger: #a43f36;
  --success-ink: #30624e;
  --success-surface: #eaf3ee;
}
html[data-theme="night"] body.site-interior.course-learning-page {
  --page: #102137;
  --paper: #102137;
  --panel: #1a3048;
  --surface: #1a3048;
  --surface-raised: #223c56;
  --field: #13273c;
  --ink: #e7f0f8;
  --muted: #b6c9db;
  --line: #36516b;
  --line-strong: #647f99;
  --accent: #c4dcec;
  --action: #b8d3e6;
  --accent-soft: #294965;
  --gold: #d6c19d;
  --gold-bright: #d1e3ef;
  --gold-ink: #142b3f;
  --focus: #c4dcec;
  --danger: #f3b0a8;
  --success-ink: #b1d7c3;
  --success-surface: #22392f;
}
.course-learning-page > .night-sky { background: var(--page); opacity: .16; }
.course-learning-page .brand-mark { color: var(--gold); background: transparent; border-color: transparent; }
.course-learning-page .brand-mark::after { display: none; }
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
}
button,input,textarea {
  font: inherit;
}
button,input,textarea,select {
  font: inherit;
}
button,a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  transition: background .15s,border-color .15s,color .15s;
}
a {
  color: var(--accent);
}
button:disabled {
  cursor: default;
}
button:focus-visible,a:focus-visible,summary:focus-visible {
  outline: 3px solid #8ba7ff;
  outline-offset: 3px;
}
textarea:focus-visible,input:focus-visible {
  outline: 2px solid #848faa;
  outline-offset: 2px;
}
textarea:focus-visible,input:focus-visible,select:focus-visible {
  outline: 2px solid #577ce8;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  top: -80px;
  left: 20px;
  background: var(--action);
  color: #fff;
  padding: 10px;
  z-index: 10;
}
.skip:focus {
  top: 10px;
}
.hidden {
  display: none!important;
}
.app-shell {
  padding-bottom: 112px;
  display: flex;
  min-height: 100dvh;
}

/* Course navigation */
.sidebar {
  overflow-y: auto;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 3;
  overflow: hidden;
  color: var(--muted);
  gap: 0;
}
.space-label {
  font-size: 11px;
  color: var(--muted);
  margin: 18px 10px 8px;
  letter-spacing: 1px;
}
.nav-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px 10px;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.nav-current>span:first-child {
  font-size: 15px;
  color: var(--muted);
}
.tiny-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.nav-current .tiny-dot {
  margin-left: auto;
  background: var(--accent);
}
.chapter-label {
  margin: 16px 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  gap: 6px;
  line-height: 1.6;
}
.chapter-label>span:last-child {
  font-size: 11px;
  white-space: nowrap;
  color: var(--muted);
}
.lesson-nav-button {
  width: 100%;
  background: none;
  border: 0;
  padding: 10px 8px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: 8px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  margin: 3px 0;
  line-height: 1.6;
  min-height: 44px;
}
.lesson-nav-button .nav-num {
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 23px;
  height: 23px;
  flex-shrink: 0;
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--muted);
}
.lesson-nav-button.active {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
}
.lesson-nav-button.active .nav-num {
  background: var(--action);
  color: var(--gold-ink);
  border-color: var(--line);
}
.lesson-nav-button.done .nav-num {
  color: var(--muted);
  background: var(--surface-raised);
  border-color: var(--line);
}
.lesson-nav-button .nav-state {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
}
.lesson-nav-button:hover {
  background: var(--surface-raised);
  color: var(--ink);
}
.future-chapter {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  padding: 22px 10px;
  margin-top: 16px;
  border-color: var(--line);
}
.future-chapter small {
  display: block;
  font-size: 12px;
  margin-top: 7px;
  color: var(--muted);
}
.lock-icon {
  font-size: 17px;
}
.sidebar-progress {
  flex-shrink: 0;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
}
.learning-tools {
  padding: 14px;
  margin: 18px 0;
}
.progress-card {
  padding: 0;
}
.progress-card>div {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  gap: 7px;
}
.progress-card progress {
  width: 100%;
  height: 5px;
  display: block;
  margin: 12px 0;
  appearance: none;
  border: 0;
  background: var(--surface-raised);
  border-radius: 8px;
  overflow: hidden;
}
.progress-card progress::-webkit-progress-bar {
  background: var(--surface-raised);
}
.progress-card progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 8px;
}
.progress-card progress::-moz-progress-bar {
  background: var(--accent);
}
.progress-card p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  line-height: 1.8;
}
.resources-button {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  min-height: 44px;
}
.resources-button span:last-child {
  margin-left: auto;
}
.local-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 10px;
  color: var(--muted);
  padding: 0;
  line-height: 1.7;
}
.local-note .tiny-dot {
  width: 4px;
  height: 4px;
  background: var(--accent);
}

/* Workspace and lesson header */
.workspace {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-width: 0;
}
.topbar {
  height: 76px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
  background: var(--surface);
  border-color: var(--line);
  gap: 20px;
}
.breadcrumb {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  line-height: 1.6;
}
.breadcrumb span {
  color: var(--muted);
}
.breadcrumb strong {
  font-weight: 500;
  color: var(--muted);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.mode-badge {
  font-size: 11px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-raised);
  color: var(--muted);
  display: flex;
  gap: 7px;
  align-items: center;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 11px;
  display: grid;
  place-items: center;
}
main {
  max-width: 1450px;
  margin: auto;
  padding: 30px 38px 0;
}
.lesson-heading {
  padding: 30px 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.lesson-heading .eyebrow {
  gap: 10px 22px;
  margin-bottom: 18px;
  font-size: 14px;
}
.lesson-title-row {
  --lesson-title-size: clamp(30px, 2.7vw, 40px);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.course-learning-page .lesson-title-row h1 {
  min-width: 0;
  margin: 0;
  font-family: "Xingkong Course Serif", "Songti SC", "STSong", serif;
  font-size: var(--lesson-title-size);
  font-weight: 380;
  line-height: 1.5;
  letter-spacing: .045em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.course-learning-page .lesson-heading .chapter-chip {
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: .02em;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
  flex-wrap: wrap;
}
.chapter-chip {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0;
  background: var(--accent-soft);
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--accent);
}
h1 {
  font-size: 30px;
  letter-spacing: .3px;
  font-weight: 650;
  margin: 13px 0 8px;
  line-height: 1.45;
  color: var(--ink);
}
h1:focus {
  outline: none;
}
.lesson-heading>div>p {
  font-size: 15px;
  color: var(--muted);
  margin: 14px 0 0;
  line-height: 1.9;
}
.heading-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 2ch;
  height: calc(var(--lesson-title-size) * 1.5);
  font-family: "Xingkong Course Serif", "Songti SC", "STSong", serif;
  font-variant-numeric: tabular-nums;
  font-weight: 380;
  color: var(--muted);
  font-size: calc(var(--lesson-title-size) * .72);
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}
.stepper {
  display: flex;
  align-items: center;
  max-width: 740px;
  margin: 29px 0 28px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
  min-height: 44px;
}
.step-number {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  width: 30px;
  height: 30px;
  background: var(--surface-raised);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 12px;
  border-color: var(--line);
  color: var(--muted);
}
.step small {
  display: block;
  font-size: 10px;
  margin-top: 3px;
  color: var(--muted);
}
.step.active {
  color: var(--accent);
  font-weight: 600;
}
.step.active .step-number {
  background: var(--action);
  color: var(--gold-ink);
  border-color: var(--action);
  box-shadow: none;
}
.step.completed .step-number {
  background: var(--accent-soft);
  border-color: var(--line);
  color: var(--accent);
}
.step-line {
  height: 1px;
  background: var(--surface-raised);
  flex: 1;
  margin: 0 18px;
  min-width: 20px;
}

/* Lesson reading and practice */
.learning-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 292px;
  gap: 24px;
  align-items: start;
}
.main-column {
  min-width: 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.lesson-card {
  padding: 26px;
}
.card-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 18px;
}
.book-icon {
  font-size: 17px;
}
.small-tag {
  font-size: 10px;
  font-weight: 400;
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--muted);
  margin-left: auto;
  border-color: var(--line);
  background: var(--surface-raised);
}
h2 {
  font-size: 19px;
  line-height: 1.6;
  margin: 0 0 13px;
  font-weight: 600;
  color: var(--ink);
}
#lesson-content p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.95;
  margin: 10px 0;
}
code {
  font-family: var(--mono);
  font-size: 12px;
}
.example-code {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 16px 0 13px;
  border-color: var(--line);
}
.token-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 12px!important;
  color: var(--muted);
  padding-top: 2px;
}
.token-list>div {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.token-list code {
  color: var(--accent);
  min-width: 116px;
}
.quiz-box {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
  border-color: var(--line);
}
.quiz-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
}
.quiz-question {
  color: var(--muted)!important;
  font-size: 13px!important;
  margin: 8px 0 12px!important;
}
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.quiz-choice {
  border: 1px solid var(--line);
  background: var(--field);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px!important;
  text-align: left;
  line-height: 1.7;
  border-color: var(--line);
  min-height: 40px;
}
.quiz-choice:hover {
  border-color: var(--line);
  background: var(--surface-raised);
}
.quiz-choice.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.quiz-response {
  font-size: 12px!important;
  padding: 7px 0 0;
  color: var(--muted)!important;
}
.target-label {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 6px;
}
.target-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  background: var(--field);
  border: 1px dashed var(--line);
  padding: 13px 16px;
  border-radius: 9px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  margin: 0;
  border-color: var(--line);
}
.task-tip {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 11px 0 0;
  line-height: 1.8;
}

/* Code editor and output */
.code-card {
  margin-top: 18px;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
  border-color: var(--line);
}
.editor-toolbar>div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.code-icon {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 15px;
}
.editor-toolbar strong {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
}
.file-tab {
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-raised);
  border-color: var(--line);
}
#draft-status {
  font-size: 11px;
  color: var(--muted);
}
.icon-button {
  border: 0;
  background: transparent;
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.icon-button:hover {
  background: var(--surface-raised);
}
.editor-shell {
  background: var(--field);
  padding: 17px 0 15px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.85;
}
.frame-line {
  color: var(--muted);
  padding-left: 54px;
  font-size: 12px;
  line-height: 1.9;
  user-select: none;
}
.editor-body {
  display: flex;
  margin: 8px 0 8px;
  min-height: 66px;
}
#line-numbers {
  width: 44px;
  flex-shrink: 0;
  white-space: pre;
  text-align: right;
  padding-right: 11px;
  color: var(--muted);
  line-height: 1.85;
  font-size: 13px;
  overflow: hidden;
  max-height: 300px;
  user-select: none;
}
#code-editor {
  width: 100%;
  min-width: 0;
  display: block;
  resize: vertical;
  min-height: 86px;
  height: 86px;
  max-height: 380px;
  border: 0;
  background: var(--field);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.85;
  padding: 0 14px 0 10px;
  tab-size: 4;
  caret-color: var(--focus);
  border-radius: 3px 0 0 3px;
  white-space: pre;
  overflow: auto;
}
#code-editor:focus {
  outline: none;
  box-shadow: inset 2px 0 var(--focus);
}
#code-editor::placeholder {
  color: var(--muted);
}
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  gap: 10px;
}
.editor-footer>span {
  font-size: 11px;
  color: var(--muted);
}
.primary {
  background: var(--action);
  color: var(--gold-ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 16px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
  white-space: nowrap;
  border-color: var(--action);
  min-height: 44px;
  justify-content: center;
}
.primary:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}
.primary:disabled {
  opacity: .65;
  cursor: default;
}
.primary kbd {
  font-family: inherit;
  font-size: 10px;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 3px;
  margin-left: 6px;
  border-color: currentColor;
}
.scope-details {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  font-size: 11px;
  color: var(--muted);
  border-color: var(--line);
}
.scope-details summary {
  cursor: pointer;
}
.scope-details p {
  line-height: 1.9;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.inline-notice {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-raised);
}
.inline-notice button {
  font-size: 12px;
  background: none;
  border: 0;
  text-decoration: underline;
  color: var(--accent);
  margin-left: 8px;
}
.output-card {
  margin-top: 18px;
}
.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
  border-color: var(--line);
}
.output-toolbar h2 {
  font-size: 13px;
  margin: 0;
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-weight: 500;
}
.terminal-symbol {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}
.result-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-raised);
  padding: 4px 7px;
  border-radius: 4px;
  max-width: 65%;
  white-space: normal;
  text-align: right;
  line-height: 1.6;
}
.result-badge.success {
  color: #a7dfd0;
  background: #162e36;
}
.result-badge.error {
  color: #f0c79f;
  background: #30251f;
}
#output-area {
  min-height: 104px;
  padding: 18px 21px;
}
.output-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 3px;
}
.output-empty>span {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 27px;
}
.output-empty p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  margin: 0;
}
.output-empty small {
  font-size: 11px;
  display: block;
  color: var(--muted);
}
.actual-output {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-family: var(--mono);
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.feedback-line {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
  margin: 12px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  border-color: var(--line);
}
.error-heading {
  font-size: 12px;
  color: #f0c79f;
  margin: 0 0 7px;
}
.error-location {
  font-size: 12px;
  color: #f0c79f;
}
.error-message {
  font-size: 12px;
  color: #f0c79f;
  line-height: 1.9;
  margin: 7px 0;
}
.diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.diff>div {
  padding: 10px;
  border-radius: 6px;
  background: var(--surface-raised);
  min-width: 0;
}
.diff label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}
.diff pre {
  font-family: var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.8;
}
.completion-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #162e36;
  border-radius: 12px;
  padding: 20px;
  border-color: var(--line);
}
.completion-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #a7dfd0;
}
.completion-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
  margin: 4px 0 14px;
}
.completion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.secondary {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  min-height: 44px;
  border-color: var(--line);
}
.secondary:hover {
  background: var(--surface-raised);
}
.lesson-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 36px;
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  z-index: 5;
  min-height: 88px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 24px #152a4d08;
  backdrop-filter: none;
}
.lesson-bottom>span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
  flex: 1;
}
.text-button {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  min-height: 40px;
}

/* Course coach */
.mentor-toggle { width: 100%; min-height: 36px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--accent); font-size: 12px; }
#mentor-content[hidden] { display: none !important; }
@media (min-width:981px) {
  .course-learning-page .learning-grid:has(>.mentor-column.is-collapsed) { grid-template-columns: minmax(0,1fr) 44px; }
  .mentor-column.is-collapsed .mentor-toggle { writing-mode: vertical-rl; min-height: 112px; padding: 12px 8px; }
}
@media (min-width:981px) {
  .mentor-column {
    position: sticky;
    top: 24px;
    align-self: start;
    max-height: calc(100dvh - 136px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
}
.mentor-card {
  padding: 22px 19px;
}
.mentor-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
  border-color: var(--line);
}
.mentor-avatar {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  border-radius: 12px;
  color: var(--accent);
  font-size: 27px;
  border-color: var(--line);
}
.mentor-heading h2 {
  font-size: 14px;
  margin: 0 0 4px;
  color: var(--ink);
}
.mentor-heading p {
  font-size: 10px;
  color: var(--muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.8;
}
.mentor-heading .tiny-dot {
  width: 4px;
  height: 4px;
  background: var(--accent);
}
.mentor-sparkle {
  margin-left: auto;
  font-size: 22px;
  color: var(--muted);
}
.coach-messages {
  max-height: 390px;
  min-height: 150px;
  overflow: auto;
  padding: 19px 0 4px;
  scrollbar-width: thin;
  scrollbar-color: #d5dfef transparent;
  padding-top: 18px;
}
.coach-message {
  font-size: 14px;
  line-height: 1.95;
  color: var(--muted);
  margin: 0 0 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.coach-message .message-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 4px;
  letter-spacing: .5px;
}
.coach-message.user {
  background: var(--accent-soft);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
}
.coach-message.hint {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  border-color: var(--line);
}
.coach-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 15px;
  flex-wrap: wrap;
}
.coach-actions button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  padding: 11px;
  text-align: left;
  min-height: 44px;
  border-color: var(--line);
}
.coach-actions button:hover {
  border-color: var(--line);
  background: var(--surface-raised);
}
.coach-actions button>span:last-child {
  margin-left: auto;
  font-size: 11px;
}
.question-box {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  gap: 5px;
  border-color: var(--line);
}
.question-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 8px 6px;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  min-height: 34px;
}
.question-box input::placeholder {
  color: var(--muted);
}
.question-box button {
  background: var(--action);
  border: 0;
  color: #fff;
  border-radius: 7px;
  width: 34px;
  flex-shrink: 0;
  min-height: 34px;
}
.coach-disclosure {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.9;
  margin: 11px 0 0;
}
.gentle-card {
  margin-top: 19px;
  padding: 21px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 13px;
  border-color: var(--line);
}
.gentle-card>span {
  color: var(--muted);
  font-size: 22px;
  display: block;
  margin-bottom: 8px;
}
.gentle-card h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 9px;
}
.gentle-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
  margin: 0;
}
.chapter-footnote {
  font-size: 9px;
  letter-spacing: 1.3px;
  text-align: center;
  margin-top: 24px;
  color: var(--muted);
}
.page-footer {
  padding: 32px 0 22px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  border-top: 1px solid var(--line);
  margin-top: 27px;
  gap: 12px;
  border-color: var(--line);
  line-height: 1.8;
}

/* Dialogs and supporting lesson content */
dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 540px;
  width: calc(100% - 36px);
  padding: 26px;
  color: var(--muted);
  box-shadow: 0 24px 90px #0f224233;
  border-color: var(--line);
}
dialog::backdrop {
  background: rgb(3 7 20 / 78%);
  backdrop-filter: blur(3px);
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 16px;
}
.dialog-header h2 {
  font-size: 18px;
  margin: 0;
}
#dialog-body p,#dialog-body li {
  font-size: 14px;
  line-height: 1.95;
  color: var(--muted);
}
#dialog-body pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--field);
  padding: 14px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}
#dialog-body a {
  color: var(--accent);
}
#dialog-body ul {
  padding-left: 20px;
}
.dialog-meta {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 12px!important;
  border-color: var(--line);
}
#lesson-content p,.coach-message {
  font-size: 14px;
  line-height: 1.95;
}
.token-list,.quiz-choice,.quiz-question {
  font-size: 12px!important;
}
.example-code,.actual-output,.target-code,#code-editor {
  font-size: 13px;
}
.coach-disclosure,.scope-details,.scope-details p {
  font-size: 12px;
  color: var(--muted);
}
.task-tip,.feedback-line,.error-message {
  font-size: 12px;
}
.primary,.secondary,.coach-actions button {
  font-size: 12px;
}
.chapter-group-label {
  font-size: 12px;
  letter-spacing: .3px;
  color: var(--muted);
  padding: 17px 9px 6px;
}
#line-numbers span {
  display: block;
  line-height: 1.85;
}
.error-gutter {
  background: var(--surface-raised);
  color: var(--muted);
  border-radius: 3px;
}
.next-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.next-lesson-button {
  min-height: 52px;
  min-width: 218px;
  padding: 13px 18px;
  font-size: 15px!important;
  font-weight: 600;
  border-radius: 10px;
  justify-content: space-between;
  box-shadow: none;
}
.next-arrow {
  font-size: 27px;
  line-height: 1;
  margin-left: 15px;
}
.skip-lesson-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--muted);
  padding: 11px 14px;
  font-size: 12px;
}
.skip-lesson-button:hover {
  background: var(--surface-raised);
}
.completion-actions .next-lesson-button {
  min-width: 210px;
}
.diagnosis-card {
  margin: 13px 0 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 11px;
  background: #30251f;
  border-color: #70563b;
  border-left-color: #c39964;
}
.diagnosis-card h3 {
  font-size: 15px;
  color: #f0c79f;
  margin: 0 0 10px;
}
.diagnosis-card h4 {
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 10px;
}
.diagnosis-location {
  font-size: 12px;
  color: #f0c79f;
  margin: 5px 0 9px;
}
.diagnosis-source {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  padding: 12px;
  background: #30251f;
  color: #f0c79f;
  border-radius: 6px;
  margin: 9px 0;
}
.diagnosis-message,.diagnosis-suggestion,.diagnosis-card>p {
  font-size: 13px;
  line-height: 1.9;
  color: #f0c79f;
  margin: 8px 0;
  overflow-wrap: anywhere;
}
.diagnosis-card ol {
  padding-left: 22px;
  margin: 0;
}
.diagnosis-card li {
  padding: 7px 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.diagnosis-card li code {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.diagnosis-card li span {
  display: block;
  margin-top: 3px;
}
#lesson-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #536582 transparent;
  padding-right: 3px;
}
.catalog-controls {
  margin: 0 2px 10px;
}
.catalog-controls input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--field);
  font-size: 12px;
  color: var(--muted);
  min-height: 42px;
}
.catalog-toggle {
  display: none;
}
.stage-group>summary {
  font-size: 12px;
  line-height: 1.7;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 6px;
  cursor: pointer;
}
.chapter-group {
  margin: 0 0 4px 5px;
}
.chapter-group>summary {
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
  padding: 8px 4px;
  cursor: pointer;
}
.chapter-group .lesson-nav-button {
  font-size: 12px;
  gap: 8px;
  padding: 10px 7px;
}
.catalog-empty {
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.brand,.chapter-label,.catalog-controls {
  flex-shrink: 0;
}
.workshop-editor .frame-line {
  display: none;
}
.workshop-editor .editor-shell {
  padding-top: 12px;
}
.workshop-template {
  margin: 0 16px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-color: var(--line);
}
.workshop-editor #code-editor {
  min-height: 80px;
  font-size: 14px;
}
.workshop-editor #code-editor[readonly] {
  color: var(--muted);
  cursor: text;
}
.example-note {
  padding: 14px 17px;
  border-left: 3px solid var(--line);
  background: var(--surface-raised);
  margin: 20px 0;
  border-radius: 0 7px 7px 0;
  font-size: 13px;
  color: var(--muted);
  border-left-color: var(--line);
}
.example-note p:last-child {
  margin-bottom: 0;
}
.local-lab {
  margin: 22px 0 15px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-raised);
  border-color: var(--line);
}
.local-lab summary {
  font-size: 13px;
  line-height: 1.8;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.local-lab li,.local-lab p {
  font-size: 13px;
  line-height: 1.95;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.local-lab ol {
  padding-left: 21px;
}
.lab-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}
.lab-check input {
  margin-top: 5px;
  accent-color: var(--accent);
}
.lesson-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 17px 0;
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}
.lesson-sources a {
  overflow-wrap: anywhere;
}
.lesson-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 15px;
}
#lesson-resources {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
#lesson-resources .lesson-sources,
#lesson-resources .lesson-downloads {
  display: grid;
  margin: 0;
}
#lesson-resources .lesson-downloads { margin-top: 14px; }
#lesson-resources .secondary {
  width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.7;
}
.inline-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  font-size: inherit;
}
.scaffold-note {
  padding: 10px 13px;
  background: var(--surface-raised);
  border-left: 3px solid var(--line);
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  border-left-color: var(--line);
}
.knowledge-points {
  margin: 0 0 18px;
  padding-left: 20px;
}
.lesson-section-title {
  margin: 26px 0 12px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}
.lesson-concepts {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.lesson-concepts > h3 { margin-top: 8px; }
.lesson-concepts dl { margin: 0; }
.lesson-concepts dl > div { margin: 12px 0; }
.lesson-concepts dt { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.lesson-concepts dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.lesson-concepts dt button {
  appearance: none;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  white-space: normal;
}
.lesson-concepts dt button:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.lesson-concepts dt button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.lesson-concept { scroll-margin-top: 24px; }
.lesson-concept:focus { outline: none; }
#lesson-content .lesson-explanation p,
#lesson-content .lesson-variation > p {
  font-size: 15px;
  color: var(--ink);
  line-height: 2;
  margin: 0 0 16px;
}
.lesson-walkthrough ol {
  padding-left: 24px;
  margin: 0;
}
.lesson-walkthrough li {
  padding-left: 4px;
  margin: 12px 0;
  font-size: 15px;
  line-height: 2;
  color: var(--ink);
}
.lesson-walkthrough li::marker {
  color: var(--accent);
  font-weight: 600;
}
.lesson-variation {
  border-top: 1px solid var(--line);
  margin-top: 24px;
}
.lesson-example-output,
.lesson-variation > .target-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.knowledge-points li {
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
}
.lesson-detail {
  margin: 14px 0;
}
.run-progress { width: 100%; height: 5px; accent-color: var(--accent); }
.lesson-detail>summary,.new-words>summary {
  cursor: pointer;
  font-size: 14px;
  line-height: 1.9;
  color: var(--accent);
  font-weight: 600;
}
.lesson-detail[open]>summary,.new-words[open]>summary {
  margin-bottom: 12px;
}
.new-words {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  padding: 16px 18px;
  margin: 19px 0;
  border-color: var(--line);
}
.new-words h3 {
  margin: 0 0 11px;
  font-size: 14px;
  color: var(--ink);
}
.new-words dl {
  margin: 0;
}
.new-words dl>div {
  margin: 16px 0;
}
.new-words dt {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.new-words dd {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
  white-space: pre-line;
}
.lesson-exponent {
  font-family: inherit;
  font-size: .75em;
  font-variant-numeric: lining-nums;
  line-height: 0;
  vertical-align: super;
  letter-spacing: 0;
  white-space: nowrap;
}
.program-input-section {
  padding: 14px 17px;
  background: var(--surface-raised);
  border-top: 1px solid var(--line);
  border-color: var(--line);
}
.program-input-section label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}
.program-input-section label span {
  font-size: 11px;
  display: block;
  color: var(--muted);
}
.program-input-section textarea {
  display: block;
  width: 100%;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-top: 8px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--field);
  color: var(--muted);
  border-color: var(--line);
}
.program-input-section p {
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  margin: 8px 0 0;
}

/* Course variants */
#course-select {
  width: 100%;
  margin-top: 9px;
  flex-shrink: 0;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  margin: 0;
  min-height: 44px;
}
#course-select:focus-visible {
  outline: 2px solid #90b0ff;
  outline-offset: 3px;
}
.breadcrumb #course-breadcrumb {
  color: inherit;
}
#game-review {
  padding: 0 18px 18px;
}
#game-review fieldset {
  margin: 15px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
  border-color: var(--line);
}
#game-review legend {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.8;
  padding: 0 5px;
  white-space: normal;
}
#game-review textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--muted);
  line-height: 1.9;
  font-size: 13px;
  border-color: var(--line);
}
#game-review label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
  margin-top: 9px;
}
#game-review input {
  flex-shrink: 0;
  margin-top: 4px;
  accent-color: var(--accent);
}
.sidebar .brand {
  color: var(--muted);
  padding: 0 7px;
}
.space-links {
  display: grid;
  gap: 6px;
  flex-shrink: 0;
  margin: 0 0 14px;
}
.nav-space {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  text-decoration: none;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid transparent;
}
.nav-space:hover {
  background: var(--surface-raised);
  color: var(--ink);
}
.nav-space.current {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  color: var(--ink);
  font-weight: 600;
}
.nav-space>span:first-child {
  font-size: 18px;
  color: var(--muted);
}
.nav-space>span:last-child,.nav-space small {
  margin-left: auto;
}
.nav-space small {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
}
.catalog-controls input::placeholder {
  color: var(--muted);
}
.resources-button:hover {
  color: #fff;
}
.topbar-ai-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  white-space: nowrap;
}
.topbar-ai-link:hover {
  text-decoration: underline;
}
.mode-badge .tiny-dot {
  background: var(--accent);
}
.workspace-intro {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 248px;
  margin: 0 0 32px;
  padding: 29px 36px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  isolation: isolate;
  color: var(--ink);
}
.workspace-intro::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, var(--surface-raised), color-mix(in srgb, var(--surface-raised) 78%, transparent) 50%, color-mix(in srgb, var(--surface-raised) 45%, transparent));
  pointer-events: none;
}
.intro-copy {
  min-width: 0;
  position: relative;
  z-index: 1;
}
.intro-copy>span {
  display: block;
  color: #a7c0cb;
  font-size: 9px;
  letter-spacing: 2px;
  line-height: 1.8;
}
.intro-copy h2 {
  color: #f2f1e9;
  font-size: clamp(27px, 2.4vw, 36px);
  font-weight: 500;
  margin: 13px 0 11px;
  line-height: 1.45;
  letter-spacing: 2px;
}
.intro-copy p {
  color: #b7cad4;
  font-size: 12px;
  margin: 0;
  line-height: 1.9;
  letter-spacing: .3px;
}
.intro-horizon-note {
  position: absolute;
  z-index: 1;
  bottom: 19px;
  right: 25px;
  color: #b6cfce;
  font-size: 9px;
  letter-spacing: 2.2px;
}
.intro-horizon-note::before {
  content: "";
  display: inline-block;
  width: 30px;
  height: 1px;
  margin: 0 10px 3px 0;
  background: #b6cfce75;
}

/* Responsive layout: the fixed footer follows the same sidebar token. */
@media (min-width:1550px) {
  main {
    padding-top: 38px;
  }
  .lesson-card {
    padding: 28px 30px;
  }
  .learning-grid {
    grid-template-columns: minmax(0,1fr) 320px;
    gap: 30px;
  }
  #lesson-content p {
    font-size: 15px;
  }
}
@media (max-width:1180px) {
  .sidebar {
    width: var(--sidebar-width);
    padding: 26px 15px 18px;
  }
  .workspace {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
  main {
    padding: 26px 26px 0;
  }
  .topbar {
    padding: 0 26px;
  }
  .learning-grid {
    grid-template-columns: minmax(0,1fr) 260px;
    gap: 19px;
  }
  .mentor-card {
    padding: 18px 15px;
  }
  .lesson-card {
    padding: 24px;
  }
  .stepper {
    max-width: 630px;
  }
  .editor-footer {
    flex-wrap: wrap;
  }
  .editor-footer .primary {
    margin-left: auto;
  }
  .chapter-label {
    font-size: 10px;
  }
  .lesson-nav-button {
    font-size: 12px;
  }
  .lesson-bottom {
    left: var(--sidebar-width);
    padding: 15px 26px;
  }
  :root {
    --sidebar-width: 230px;
  }
  .workspace-intro {
    padding: 27px 28px;
  }
  .top-actions {
    gap: 10px;
  }
  .mode-badge {
    padding: 7px 9px;
    font-size: 10px;
  }
  .topbar-ai-link {
    font-size: 11px;
  }
}
@media (max-width:980px) {
  .sidebar {
    width: var(--sidebar-width);
    padding: 25px 12px 16px;
  }
  .workspace {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
  .learning-grid {
    grid-template-columns: minmax(0,1fr);
  }
  .mentor-column {
    display: block;
  }
  .chapter-footnote {
    display: none;
  }
  .coach-messages {
    min-height: 80px;
    max-height: 240px;
  }
  .coach-actions {
    flex-direction: column;
  }
  .coach-actions button {
    flex: 1;
    min-width: 0;
  }
  .topbar {
    height: auto;
    min-height: 66px;
    padding: 14px 24px;
    align-items: center;
  }
  .chapter-label {
    font-size: 10px;
  }
  .stepper {
    max-width: none;
  }
  .lesson-nav-button {
    padding: 12px 7px;
  }
  .nav-state {
    display: none;
  }
  .lesson-bottom {
    left: var(--sidebar-width);
    padding: 13px 22px;
  }
  .lesson-bottom>span {
    display: none;
  }
  .next-actions {
    width: 100%;
    justify-content: space-between;
  }
  :root {
    --sidebar-width: 208px;
  }
  .topbar-ai-link {
    font-size: 11px;
  }
  .mode-badge {
    display: none;
  }
  .workspace-intro {
    margin-bottom: 28px;
    min-height: 236px;
  }
  .intro-copy h2 {
    font-size: 29px;
  }
}
@media (min-width:701px) and (max-width:980px) {
  .step {
    min-width: 0;
    flex: 1;
    gap: 7px;
    font-size: 12px;
  }
  .step small {
    display: none;
  }
  .step-number {
    flex-shrink: 0;
    width: 27px;
    height: 27px;
  }
  .step-line {
    flex: 0 1 16px;
    min-width: 8px;
    margin: 0 10px;
  }
}
@media (max-height:760px), (max-width:700px) {
  .sidebar-progress { padding: 10px 12px; margin-top: 10px; }
  .sidebar-progress .progress-card p, .sidebar-progress .local-note { display: none; }
  .sidebar-progress progress { margin: 8px 0 0; }
}
@media (min-width:701px) and (max-height:760px) {
  .sidebar {
    padding-top: 16px;
    padding-bottom: 12px;
  }
  .space-label {
    margin-top: 12px;
  }
  .nav-current {
    display: none;
  }
  .space-links {
    margin-bottom: 10px;
    gap: 4px;
  }
  .chapter-label {
    margin-top: 12px;
  }
}
@media (max-width:700px) {
  .app-shell {
    display: block;
    padding-bottom: 102px;
  }
  .sidebar {
    position: relative;
    width: 100%;
    padding: 20px 18px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    padding-bottom: 13px;
  }
  .space-label,.nav-current,.future-chapter {
    display: none;
  }
  .chapter-label {
    margin: 17px 0 10px;
    font-size: 11px;
  }
  #lesson-nav {
    display: block;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 5px;
    max-height: clamp(300px,65dvh,540px);
    min-height: 0;
    overflow-y: auto;
  }
  .lesson-nav-button {
    display: flex;
    flex-direction: row;
    gap: 6px;
    text-align: left;
    padding: 9px 3px;
    font-size: 12px;
    line-height: 1.6;
    min-height: 44px;
  }
  .lesson-nav-button .nav-num {
    width: 21px;
    height: 21px;
  }
  .workspace {
    margin-left: 0;
    width: 100%;
  }
  .topbar {
    height: auto;
    padding: 12px 18px;
    min-height: 56px;
    gap: 12px;
  }
  .breadcrumb {
    font-size: 10px;
    gap: 7px;
    flex: 1;
  }
  .top-actions {
    gap: 0;
  }
  .mode-badge {
    font-size: 12px;
    padding: 6px 8px;
  }
  .avatar {
    display: none;
  }
  main {
    padding: 20px 16px 0;
  }
  .eyebrow {
    font-size: 11px;
  }
  .chapter-chip {
    font-size: 15px;
    letter-spacing: 0;
    line-height: 1.7;
  }
  .lesson-heading>div>p {
    font-size: 14px;
    line-height: 1.9;
  }
  .lesson-heading {
    padding: 24px 20px;
  }
  .lesson-title-row {
    --lesson-title-size: 26px;
    gap: 12px;
  }
  .stepper {
    margin: 23px 0;
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 10px;
  }
  .step {
    font-size: 12px;
    gap: 7px;
  }
  .step small {
    font-size: 12px;
  }
  .step-number {
    width: 27px;
    height: 27px;
    font-size: 11px;
  }
  .step-line {
    margin: 0 9px;
    min-width: 8px;
  }
  .lesson-card {
    padding: 22px 18px;
  }
  h2 {
    font-size: 18px;
  }
  #lesson-content p {
    font-size: 14px;
  }
  .quiz-choice {
    font-size: 12px!important;
  }
  .token-list>div {
    flex-direction: column;
    gap: 2px;
  }
  .token-list {
    gap: 9px;
  }
  .example-code {
    font-size: 12px;
    padding: 14px;
  }
  .mentor-column {
    display: block;
  }
  .learning-tools {
    margin-bottom: 18px;
  }
  .gentle-card {
    display: none;
  }
  .mentor-card {
    padding: 21px 18px;
  }
  .coach-disclosure {
    font-size: 10px;
  }
  .coach-message {
    font-size: 14px;
  }
  .coach-actions button {
    font-size: 12px;
  }
  .question-box input {
    font-size: 12px;
  }
  .editor-footer {
    padding: 12px;
    gap: 9px;
  }
  .editor-footer>span {
    font-size: 10px;
  }
  .primary kbd {
    display: none;
  }
  .frame-line {
    padding-left: 38px;
    font-size: 10px;
  }
  #line-numbers {
    width: 30px;
    font-size: 12px;
  }
  #code-editor {
    font-size: 12px;
  }
  .file-tab {
    font-size: 10px;
  }
  .diff {
    grid-template-columns: 1fr;
  }
  .lesson-bottom>span {
    font-size: 12px;
  }
  .text-button {
    font-size: 12px;
  }
  .page-footer {
    font-size: 9px;
    line-height: 1.9;
    flex-direction: column;
    gap: 4px;
  }
  .coach-disclosure br {
    display: none;
  }
  .lesson-bottom {
    left: 0;
    padding: 12px 14px;
    min-height: 84px;
    padding-bottom: max(12px,env(safe-area-inset-bottom));
  }
  .next-actions {
    gap: 8px;
    width: 100%;
  }
  .next-lesson-button {
    min-width: 0;
    min-height: 50px;
    flex: 1;
    font-size: 13px!important;
    padding: 12px;
  }
  .skip-lesson-button {
    font-size: 11px;
    padding: 10px 11px;
    min-width: 0;
    min-height: 46px;
    flex-shrink: 0;
  }
  .next-arrow {
    margin-left: 4px;
    font-size: 23px;
  }
  .chapter-group-label {
    grid-column: 1/-1;
    text-align: left;
    padding: 10px 3px 2px;
  }
  .diagnosis-source {
    font-size: 12px;
  }
  .diagnosis-card {
    padding: 12px;
  }
  .catalog-toggle {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-raised);
    color: var(--muted);
    font-size: 12px;
    padding: 11px;
    margin-bottom: 10px;
    text-align: left;
    min-height: 44px;
    border-color: var(--line);
  }
  .catalog-controls {
    margin: 0 0 10px;
  }
  .catalog-collapsed #lesson-nav,.catalog-collapsed .catalog-controls {
    display: none;
  }
  .stage-group>summary {
    font-size: 12px;
    padding: 10px;
    color: var(--muted);
  }
  .chapter-group .lesson-nav-button {
    display: flex;
    flex-direction: row;
    text-align: left;
    min-height: 44px;
    font-size: 12px;
    padding: 10px;
    gap: 9px;
  }
  .chapter-group .nav-state {
    display: inline;
    font-size: 10px;
    color: var(--muted);
  }
  .workshop-template {
    margin: 0 10px 12px;
    font-size: 12px;
    padding: 12px;
  }
  .editor-toolbar strong {
    font-size: 12px;
  }
  .editor-toolbar .file-tab {
    display: none;
  }
  .scope-details {
    font-size: 11px;
  }
  .local-lab {
    padding: 14px;
  }
  .lesson-heading .eyebrow {
    flex-wrap: wrap;
  }
  .stepper .step-line {
    display: none;
  }
  .stepper .step {
    min-height: 56px;
    text-align: left;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    padding: 10px 11px;
    border-radius: 10px;
    font-size: 12px;
  }
  .stepper .step small {
    font-size: 10px;
  }
  #course-select {
    margin: 16px 0 0;
    min-height: 44px;
    font-size: 12px;
  }
  .nav-current {
    display: none;
  }
  #game-review {
    padding: 0 12px 12px;
  }
  :root {
    --sidebar-width: 0px;
  }
  .sidebar .brand {
    padding: 0;
  }
  .space-links {
    display: flex;
    margin: 18px 0 0;
    gap: 8px;
  }
  .nav-space {
    flex: 1;
    justify-content: flex-start;
    min-height: 44px;
    padding: 9px 12px;
    font-size: 12px;
    border-color: var(--line);
  }
  .nav-space small {
    font-size: 10px;
  }
  .catalog-controls input {
    font-size: 13px;
  }
  .chapter-group>summary {
    font-size: 12px;
  }
  .topbar-ai-link {
    display: none;
  }
  .workspace-intro {
    padding: 25px 23px 37px;
    min-height: 232px;
    margin-bottom: 26px;
    border-radius: 15px;
  }
  .workspace-intro::after {
    background: linear-gradient(90deg, var(--surface-raised), transparent);
  }
  .intro-copy {
    max-width: 100%;
  }
  .intro-copy>span {
    font-size: 8px;
    letter-spacing: 1.4px;
  }
  .intro-copy h2 {
    font-size: 27px;
    margin: 12px 0 10px;
    letter-spacing: 1px;
  }
  .intro-copy p {
    font-size: 10px;
    max-width: 250px;
  }
  .intro-horizon-note {
    bottom: 13px;
    right: 19px;
    font-size: 8px;
    letter-spacing: 1.3px;
  }
  .stepper .step.active {
    background: var(--accent-soft);
    border-color: var(--line);
  }
  .completion-actions .next-lesson-button {
    min-width: 0;
    width: 100%;
  }
  .result-badge {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion:reduce) {
  * {
    scroll-behavior: auto!important;
    transition: none!important;
  }
}

/* Day reading shares the same blue-grey controls and neutral surfaces. */
html[data-theme="day"] :is(.sidebar,.topbar,.lesson-bottom) {
  background: var(--surface);
}
html[data-theme="day"] :is(.lesson-nav-button.active,.lesson-nav-button:hover,.nav-space.current,.nav-space:hover,.resources-button:hover) {
  color: var(--accent);
}
html[data-theme="day"] :is(.nav-space.current,.quiz-choice.selected) {
  border-color: var(--line-strong);
}
html[data-theme="day"] .lesson-nav-button.active .nav-num {
  background: var(--action);
  color: #fff;
  border-color: var(--action);
}
html[data-theme="day"] .step.active .step-number {
  box-shadow: none;
}
html[data-theme="day"] :is(button,a,summary,textarea,input,select):focus-visible,
html[data-theme="day"] #course-select:focus-visible {
  outline-color: var(--accent);
}
html[data-theme="day"] :is(#code-editor,#game-review textarea,.program-input-section textarea,.question-box input,.catalog-controls input,#course-select) {
  color: var(--ink);
  caret-color: var(--accent);
}
html[data-theme="day"] #code-editor:focus {
  box-shadow: inset 3px 0 var(--accent);
}
html[data-theme="day"] .primary:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
}
html[data-theme="day"] .primary kbd {
  color: var(--gold-ink);
  border-color: var(--line-strong);
}
html[data-theme="day"] :is(.result-badge.success,.completion-card) {
  color: var(--accent);
  background: var(--accent-soft);
}
html[data-theme="day"] .completion-card h3 {
  color: var(--accent);
}
html[data-theme="day"] .result-badge.error {
  color: #8a542b;
  background: #fcf2e6;
}
html[data-theme="day"] :is(.error-heading,.error-location,.error-message,.diagnosis-card h3,.diagnosis-location,.diagnosis-message,.diagnosis-suggestion,.diagnosis-card>p) {
  color: #805b35;
}
html[data-theme="day"] .error-gutter {
  background: #8a542b;
  color: #fff;
}
html[data-theme="day"] .diagnosis-card {
  background: #fffcf5;
  border-color: #dfc5a6;
  border-left-color: #b1824d;
}
html[data-theme="day"] .diagnosis-source {
  background: #f3eadc;
  color: #6c4b29;
}
html[data-theme="day"] :is(#lesson-nav,.coach-messages) {
  scrollbar-color: var(--line-strong) transparent;
}
html[data-theme="day"] .lesson-bottom {
  box-shadow: 0 -4px 24px #243e2508;
}
html[data-theme="day"] dialog {
  box-shadow: 0 24px 90px #20332226;
}
html[data-theme="day"] dialog::backdrop {
  background: rgb(30 48 39 / 40%);
}
html[data-theme="day"] .workspace-intro {
  min-height: 150px;
  padding: 23px 30px;
  margin-bottom: 28px;
  background: var(--accent-soft);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="day"] .workspace-intro::after,
html[data-theme="day"] .intro-horizon-note {
  display: none;
}
html[data-theme="day"] .intro-copy>span {
  color: var(--muted);
}
html[data-theme="day"] .intro-copy h2 {
  color: var(--ink);
  font-size: 26px;
  margin: 8px 0;
  letter-spacing: 1px;
}
html[data-theme="day"] .intro-copy p {
  color: var(--muted);
  font-size: 12px;
}
@media (max-width:700px) {
  html[data-theme="day"] .workspace-intro {
    min-height: 150px;
    padding: 21px 22px;
    margin-bottom: 24px;
  }
  html[data-theme="day"] .intro-copy h2 {
    font-size: 24px;
  }
}

.course-learning-page :is(.intro-copy>span,.intro-copy p,.intro-horizon-note) { color: var(--muted); }
.course-learning-page .intro-copy h2 { color: var(--ink); }
.course-learning-page .workspace-intro .sky-vista { opacity: .3; }
.course-learning-page .example-code { color: var(--ink); background: var(--field); }
.course-learning-page :is(.coach-actions button,.gentle-card) { background: var(--surface); }
.course-learning-page :is(.quiz-choice.selected,.nav-space.current) { border-color: var(--line-strong); }
.course-learning-page .step-line { background: var(--line); }
.course-learning-page .completion-card, .course-learning-page .result-badge.success { color: var(--success-ink); background: var(--success-surface); }
.course-learning-page .completion-card h3 { color: var(--success-ink); }
.course-learning-page .chapter-chip { background: transparent; padding: 0; color: var(--ink); }
.course-learning-page .resources-button { color: var(--ink); background: var(--field); }
.course-learning-page .question-box button { color: var(--gold-ink); }
/* Local course evidence follows the same learning surface as the code editor. */
.course-local-lab{padding:20px;border-top:1px solid var(--line)}.course-local-lab h3{font-size:16px;margin:0 0 8px}.course-local-lab p{font-size:13px;color:var(--muted)}.course-local-lab label{display:flex;gap:10px;align-items:flex-start;font-size:13px;margin:16px 0 8px}.course-local-lab input{accent-color:var(--accent);flex-shrink:0}.course-local-lab textarea{width:100%;box-sizing:border-box;resize:vertical;border:1px solid var(--line);border-radius:8px;background:var(--paper);color:var(--ink);padding:10px;font:inherit;font-size:13px}.course-browser-preview{width:100%;min-height:340px;border:1px solid var(--line);border-radius:10px;background:white}
