:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #eef7f5;
  --ink: #172024;
  --muted: #607178;
  --line: #dbe5e7;
  --teal: #0f8a83;
  --teal-dark: #0a6864;
  --blue: #2457a7;
  --amber: #d89318;
  --coral: #d95d45;
  --mint: #dff4ee;
  --shadow: 0 18px 48px rgba(22, 38, 43, 0.12);
  --shadow-soft: 0 10px 28px rgba(22, 38, 43, 0.08);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11171a;
  --surface: #182124;
  --surface-strong: #142d2d;
  --ink: #edf5f4;
  --muted: #a4b5ba;
  --line: #2d3b40;
  --teal: #4fc7bd;
  --teal-dark: #74d9d0;
  --blue: #77a4ff;
  --amber: #efb84d;
  --coral: #ff8a72;
  --mint: #183834;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 138, 131, 0.07), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid rgba(216, 147, 24, 0.45);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.course-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  padding: 24px;
}

[data-theme="dark"] .course-rail {
  background: rgba(24, 33, 36, 0.82);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.brand-lockup h1,
.topbar h2,
.lesson-hero h2,
.side-panel h3,
.lesson-copy h3,
.quiz-box h3,
.panel-heading h3 {
  margin: 0;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.brand-lockup h1 {
  font-size: 1.25rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rail-panel,
.side-panel,
.study-surface,
.lesson-hero,
.objective-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.progress-panel {
  margin: 24px 0 18px;
  padding: 16px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-head strong {
  color: var(--ink);
  font-size: 1.25rem;
}

.progress-track {
  height: 10px;
  margin: 12px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), transparent 20%);
}

.progress-meter {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  transition: width 240ms ease;
}

.rail-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.lesson-list {
  display: grid;
  gap: 8px;
}

.lesson-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.lesson-button:hover,
.lesson-button.active {
  border-color: var(--line);
  background: var(--surface);
}

.lesson-button.active {
  box-shadow: var(--shadow-soft);
}

.lesson-button.complete .lesson-number {
  background: var(--teal);
  color: #fff;
}

.lesson-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.lesson-name {
  display: block;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.lesson-state {
  color: var(--teal-dark);
  font-weight: 900;
}

.full-width {
  width: 100%;
  margin-top: 16px;
}

.app-main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h2 {
  max-width: 780px;
  font-size: 1.55rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-shell {
  display: flex;
  align-items: center;
  min-width: 310px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  box-shadow: var(--shadow-soft);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.lesson-workspace {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.lesson-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(280px, 0.74fr);
  min-height: 294px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 30px;
}

.lesson-meta {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lesson-hero h2 {
  max-width: 720px;
  font-size: 2.2rem;
}

.lesson-hero p {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.65;
}

.image-plane {
  position: relative;
  min-height: 294px;
  margin: 0;
  overflow: hidden;
  background: var(--surface-strong);
}

.image-plane::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface) 0%, transparent 34%);
  content: "";
  pointer-events: none;
}

.image-plane img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.hero-actions,
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.ghost-button,
.quiet-button,
.icon-button,
.small-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button,
.quiet-button,
.icon-button,
.small-button {
  background: var(--surface);
  color: var(--ink);
}

.ghost-button:hover,
.quiet-button:hover,
.icon-button:hover,
.small-button:hover {
  border-color: color-mix(in srgb, var(--teal), var(--line) 35%);
  background: var(--surface-strong);
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.objective-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.objective-chip {
  min-height: 78px;
  padding: 14px;
  color: var(--muted);
  line-height: 1.42;
}

.objective-chip strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.86rem;
}

.study-surface {
  overflow: hidden;
}

.tabbar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
}

.tab-button.active {
  border-color: var(--line);
  background: var(--mint);
  color: var(--teal-dark);
}

.tab-panel {
  display: none;
  padding: 24px;
}

.tab-panel.active {
  display: block;
}

.lesson-copy {
  max-width: 860px;
}

.lesson-copy h3,
.practice-layout h3,
.quiz-box h3 {
  margin: 0 0 10px;
}

.lesson-copy p,
.practice-layout p,
.quiz-box p {
  color: var(--muted);
  line-height: 1.7;
}

.note-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  border-left: 4px solid var(--teal);
  background: color-mix(in srgb, var(--surface-strong), transparent 12%);
  padding: 12px 14px;
  line-height: 1.55;
}

.code-layout,
.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.code-window,
.output-window,
.editor-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #11191d;
  color: #eef8f7;
}

.window-bar,
.editor-shell span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #182328;
  color: #b9cbcf;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

pre {
  margin: 0;
}

code,
textarea {
  font-family: var(--mono);
}

.code-window pre,
.output-window pre {
  min-height: 340px;
  overflow: auto;
  padding: 18px;
  line-height: 1.62;
  white-space: pre;
}

.output-window pre {
  color: #d9f3a7;
}

.editor-shell {
  display: grid;
}

.editor-shell textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: #11191d;
  color: #eef8f7;
  padding: 18px;
  line-height: 1.55;
  tab-size: 4;
}

.result-box {
  min-height: 54px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
  padding: 14px;
  line-height: 1.5;
}

.result-box.pass {
  border-color: color-mix(in srgb, var(--teal), var(--line));
  background: var(--mint);
  color: var(--teal-dark);
}

.result-box.fail {
  border-color: color-mix(in srgb, var(--coral), var(--line));
  background: color-mix(in srgb, var(--coral), transparent 88%);
  color: var(--coral);
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
  text-align: left;
  font-weight: 750;
}

.choice-button:hover,
.choice-button.selected {
  border-color: var(--teal);
  background: var(--mint);
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.reference-item {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.reference-item h4 {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 0.95rem;
}

.reference-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.study-column {
  display: grid;
  gap: 16px;
}

.side-panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 14px;
}

.path-stack {
  display: grid;
  gap: 10px;
}

.path-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.path-dot {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--mint);
  color: var(--teal-dark);
  font-weight: 900;
}

.path-item.done .path-dot {
  background: var(--teal);
  color: #fff;
}

.path-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.path-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.concept-list {
  display: grid;
  gap: 8px;
  max-height: 570px;
  overflow-y: auto;
  padding-right: 2px;
}

.concept-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.concept-row:hover {
  border-color: var(--teal);
  background: var(--surface-strong);
}

.concept-row strong {
  display: block;
  margin-bottom: 5px;
}

.concept-row span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.42;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .learning-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .study-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .course-rail {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lesson-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .lesson-list::-webkit-scrollbar {
    display: none;
  }

  .lesson-button {
    flex: 0 0 min(330px, calc(100vw - 64px));
    scroll-snap-align: start;
  }

  .app-main {
    padding: 20px;
  }

  .topbar,
  .top-actions {
    display: grid;
    width: 100%;
  }

  .search-shell {
    min-width: 0;
  }

  .lesson-hero,
  .code-layout,
  .practice-layout,
  .study-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .image-plane {
    min-height: 220px;
  }

  .image-plane::after {
    background: linear-gradient(180deg, transparent, var(--surface));
  }

  .objective-strip,
  .reference-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .course-rail,
  .app-main,
  .hero-copy,
  .tab-panel {
    padding: 16px;
  }

  .lesson-hero h2 {
    font-size: 1.7rem;
  }

  .topbar h2 {
    font-size: 1.25rem;
  }

  .hero-actions,
  .practice-actions {
    display: grid;
  }

  .primary-button,
  .ghost-button,
  .quiet-button,
  .icon-button {
    width: 100%;
  }

  .course-rail .quiet-button.full-width {
    width: auto;
    min-height: 28px;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0;
    text-align: left;
    box-shadow: none;
  }
}
