:root {
  --bg: #0b1020;
  --panel: #121a2e;
  --panel2: #18233b;
  --line: #263653;
  --text: #edf3ff;
  --muted: #9eacc6;
  --cyan: #65d7e8;
  --purple: #a78bfa;
  --green: #70dfa8;
  --orange: #ffc477;
  --red: #ff8c9b;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
  --sidebar-bg: #0c1425ed;
  --formula-bg: #0a1425;
  --formula-border: #2a4961;
  --formula-text: #e9f8ff;
  --callout-bg: #122b3a;
  --warn-bg: #30291e;
  --mini-bg: #0d1729;
  --opt-bg: #0e192b;
  --opt-sel-bg: #153144;
  --feedback-bg: #172b31;
  --node-bg: #142b3b;
  --node-border: #3b6176;
  --card-bg: linear-gradient(145deg, #151f34, #111a2c);
  --hero-bg: linear-gradient(120deg, #172b42ee, #1d2141ee);
  --nav-btn-hover: #17233a;
  --nav-btn-active: linear-gradient(90deg, #203b50, #202443);
  --result-bg: #0a1728;
  --result-border: #34546b;
  --input-bg: #0b1425;
}

html.light-theme {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel2: #f1f5f9;
  --line: #d8e2ee;
  --text: #0f172a;
  --muted: #576785;
  --cyan: #0284c7;
  --purple: #7c3aed;
  --green: #059669;
  --orange: #d97706;
  --red: #e11d48;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
  --sidebar-bg: #ffffff;
  --formula-bg: #f0f5fc;
  --formula-border: #bfd2e8;
  --formula-text: #0b2545;
  --callout-bg: #e0f2fe;
  --warn-bg: #fef3c7;
  --mini-bg: #f8fafc;
  --opt-bg: #f8fafc;
  --opt-sel-bg: #e0f2fe;
  --feedback-bg: #ecfdf5;
  --node-bg: #e2eaf5;
  --node-border: #93c5fd;
  --card-bg: linear-gradient(145deg, #ffffff, #f8fafc);
  --hero-bg: linear-gradient(120deg, #e2eaf5, #e6e9f8);
  --nav-btn-hover: #f1f5f9;
  --nav-btn-active: linear-gradient(90deg, #e0f2fe, #ede9fe);
  --result-bg: #f0fdf4;
  --result-border: #86efac;
  --input-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: radial-gradient(ellipse at 75% -15%, rgba(38, 54, 91, 0.35) 0, transparent 42%), var(--bg);
  color: var(--text);
  font: 15px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
}

html.light-theme body {
  background: radial-gradient(ellipse at 75% -15%, rgba(186, 215, 248, 0.45) 0, transparent 42%), var(--bg);
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 285px 1fr;
  min-height: 100vh;
}

.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 9px 23px;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: grid;
  place-items: center;
  color: #08111f;
  font-weight: 900;
  font-size: 20px;
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.navlabel {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 10px;
  font-weight: 800;
  padding: 14px 10px 7px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 11px;
  border-radius: 10px;
  display: flex;
  gap: 11px;
  align-items: center;
  transition: all 0.15s ease;
  width: 100%;
}

.nav button:hover {
  background: var(--nav-btn-hover);
  color: var(--text);
}

.nav button.active {
  background: var(--nav-btn-active);
  border-color: var(--line);
  color: var(--text);
  font-weight: 600;
}

.num {
  font-size: 11px;
  color: var(--cyan);
  font-weight: 800;
  min-width: 24px;
}

.sidefoot {
  margin: auto 8px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}

main {
  min-width: 0;
  padding: 30px clamp(18px, 4vw, 58px) 70px;
  max-width: 1450px;
  width: 100%;
  margin: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.crumb {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.crumb span {
  color: var(--cyan);
}

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

.ghost {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.ghost:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.hero {
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--hero-bg);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "MDP";
  position: absolute;
  right: 3%;
  top: 5%;
  font-size: clamp(80px, 15vw, 190px);
  font-weight: 900;
  color: rgba(125, 160, 210, 0.08);
  letter-spacing: -0.08em;
  pointer-events: none;
}

.eyebrow {
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  margin: 12px 0;
}

.hero p {
  color: var(--muted);
  max-width: 720px;
  font-size: 17px;
  margin: 0;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.pill {
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  background: rgba(125, 160, 210, 0.08);
}

.section {
  margin-top: 28px;
}

.sectionhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 15px;
  margin-bottom: 13px;
  flex-wrap: wrap;
}

.sectionhead h2 {
  font-size: 21px;
  margin: 0;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
}

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

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  min-width: 0;
}

.card h3 {
  margin: 7px 0 6px;
  font-size: 16px;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card .tag {
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 800;
}

.lesson-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.lesson-card:hover {
  transform: translateY(-3px);
  border-color: var(--cyan);
  background: var(--panel2);
}

.lesson-card .index {
  font-size: 23px;
  font-weight: 850;
  color: var(--purple);
}

.progress-wrap {
  height: 8px;
  border-radius: 10px;
  background: var(--panel2);
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--line);
}

.progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  transition: width 0.3s ease;
}

.pagehead {
  margin: 15px 0 24px;
}

.pagehead h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.035em;
  margin: 8px 0;
}

.pagehead p {
  color: var(--muted);
  max-width: 850px;
  margin: 0;
}

.lessonmeta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.layout2 {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.content {
  display: grid;
  gap: 15px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 21px;
}

.panel h2 {
  font-size: 19px;
  margin: 0 0 10px;
}

.panel h3 {
  font-size: 15px;
  margin: 17px 0 6px;
}

.panel p {
  color: var(--text);
  opacity: 0.92;
  margin: 8px 0;
}

.panel ul, .panel ol {
  color: var(--text);
  opacity: 0.92;
  padding-left: 21px;
}

.formula {
  background: var(--formula-bg);
  border: 1px solid var(--formula-border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  font: 500 clamp(17px, 2.4vw, 25px)/1.6 Georgia, serif;
  color: var(--formula-text);
  margin: 13px 0;
  overflow-x: auto;
}

.formula small {
  display: block;
  font: 12px/1.5 system-ui, sans-serif;
  color: var(--muted);
  margin-top: 4px;
}

.callout {
  border-left: 3px solid var(--cyan);
  background: var(--callout-bg);
  padding: 12px 15px;
  border-radius: 0 10px 10px 0;
  color: var(--text);
  margin: 13px 0;
}

.warn {
  border-left-color: var(--orange);
  background: var(--warn-bg);
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mini {
  background: var(--mini-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.mini strong {
  display: block;
  color: var(--cyan);
  font-size: 13px;
  margin-bottom: 5px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.table th, .table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.table th {
  color: var(--muted);
  font-weight: 700;
}

.table td {
  color: var(--text);
}

.controls {
  display: grid;
  gap: 13px;
}

.control label {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 5px;
}

.control input[type=range] {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
}

.control input[type=number] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px;
}

.result {
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  border-radius: 12px;
  padding: 15px;
}

.result span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.result strong {
  font-size: 29px;
  color: var(--green);
}

.quiz {
  display: grid;
  gap: 9px;
}

.option {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--opt-bg);
  color: var(--text);
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.option:hover {
  border-color: var(--cyan);
}

.option.selected {
  border-color: var(--cyan);
  background: var(--opt-sel-bg);
  font-weight: 600;
}

.feedback {
  padding: 11px;
  border-radius: 9px;
  background: var(--feedback-bg);
  color: var(--green);
  font-size: 13px;
  border: 1px solid var(--line);
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.primary {
  background: linear-gradient(100deg, #49bfd0, #8e82e9);
  border: 0;
  color: #081322;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 800;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
}

.node {
  border: 1px solid var(--node-border);
  background: var(--node-bg);
  border-radius: 11px;
  padding: 12px 15px;
  text-align: center;
  min-width: 110px;
  color: var(--text);
}

.node small {
  color: var(--muted);
  font-size: 11px;
}

.arrow {
  color: var(--cyan);
  font-size: 22px;
  font-weight: bold;
}

.barlist {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.barrow {
  display: grid;
  grid-template-columns: 65px 1fr 45px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.barbg {
  height: 10px;
  background: var(--panel2);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.barfill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 20px;
  transition: width 0.2s ease;
}

.footer {
  margin-top: 35px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1000px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .layout2 {
    grid-template-columns: 1fr;
  }
  .app {
    grid-template-columns: 245px 1fr;
  }
  .sidebar {
    padding: 18px 12px;
  }
}

@media (max-width: 700px) {
  .app {
    display: block;
  }
  .sidebar {
    height: auto;
    position: relative;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .brand {
    padding: 4px 7px 10px;
  }
  .navlabel, .sidefoot {
    display: none;
  }
  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav button {
    white-space: nowrap;
    font-size: 12px;
    padding: 8px;
    width: auto;
  }
  .num {
    min-width: auto;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .two {
    grid-template-columns: 1fr;
  }
  main {
    padding: 18px 14px 50px;
  }
  .topbar {
    margin-bottom: 15px;
  }
  .hero {
    border-radius: 17px;
  }
  .hero::after {
    display: none;
  }
}

/* Detailed lecture content: keep wide formulas/tables inside the panel on narrow screens */
.content { grid-template-columns: minmax(0, 1fr); }
.content > * { min-width: 0; }
.panel { overflow-wrap: anywhere; }
.panel .table { display: block; overflow-x: auto; }
.panel .formula { overflow-x: auto; }
@media (max-width: 1000px) {
  .layout2 { grid-template-columns: minmax(0, 1fr); }
}

/* ===== Readability upgrade: larger type + wider reading column ===== */
body { font-size: 17px; line-height: 1.75; }
.app { grid-template-columns: 250px minmax(0, 1fr); }
main { max-width: 1760px; padding: 28px clamp(16px, 2.6vw, 40px) 70px; }
.layout2 { grid-template-columns: minmax(0, 1fr) minmax(250px, 290px); gap: 18px; }

.pagehead h1 { font-size: clamp(32px, 4vw, 48px); }
.pagehead p { font-size: 19px; max-width: 1000px; }
.eyebrow { font-size: 12.5px; }
.pill { font-size: 13.5px; }

.panel { padding: 26px 30px; }
.panel h2 { font-size: 24px; line-height: 1.3; margin: 0 0 12px; }
.panel h3 { font-size: 19.5px; margin: 24px 0 8px; }
.panel p, .panel ul, .panel ol { font-size: 18px; line-height: 1.8; opacity: 1; }
.panel li { margin: 6px 0; }
.panel ul, .panel ol { padding-left: 26px; }
.formula { font-size: clamp(20px, 2.4vw, 30px); padding: 22px; }
.formula small { font-size: 15.5px; }
.callout { font-size: 17.5px; line-height: 1.75; padding: 15px 18px; }
.mini { font-size: 16.5px; }
.mini strong { font-size: 16px; }
.table { font-size: 16.5px; }
.table th, .table td { padding: 11px 14px; }

.card h3 { font-size: 18px; }
.card p { font-size: 15.5px; }
.sectionhead h2 { font-size: 24px; }
.hero p { font-size: 19px; max-width: 860px; }

.control label { font-size: 15.5px; }
.result span { font-size: 14.5px; }
.option { font-size: 16.5px; padding: 12px 15px; }
.feedback { font-size: 16px; }
.node small { font-size: 13px; }
.barrow { font-size: 14px; }
.nav button { font-size: 15.5px; }
.num { font-size: 12.5px; }
.ghost { font-size: 14.5px; }
.crumb { font-size: 14px; }
.sidefoot { font-size: 14px; }
.footer { font-size: 14px; }

html.light-theme { --muted: #46546f; }

@media (max-width: 1280px) {
  .layout2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 230px minmax(0, 1fr); }
}
@media (max-width: 700px) {
  body { font-size: 16.5px; }
  .panel { padding: 20px 18px; }
  .panel h2 { font-size: 21px; }
  .panel h3 { font-size: 18px; }
  .panel p, .panel ul, .panel ol { font-size: 17px; }
  .formula { font-size: 19px; padding: 16px 12px; }
  .nav button { font-size: 13px; }
}

/* ===== Full-width lesson layout ===== */
main { max-width: 1440px; }
.lesson-full { width: 100%; }
.panel[id^="lesson-sec-"] { scroll-margin-top: 20px; }
.lesson-map {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 18px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.map-label {
  font-size: 12.5px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); margin-right: 6px;
}
.map-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--opt-bg); color: var(--text);
  border-radius: 99px; padding: 6px 14px 6px 6px; font-size: 15px; line-height: 1.3;
}
.map-chip:hover { border-color: var(--cyan); }
.map-num {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--cyan); color: var(--panel); font-size: 12.5px; font-weight: 800;
}
.lesson-extras { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 15px; }
@media (max-width: 760px) {
  .lesson-extras { grid-template-columns: minmax(0, 1fr); }
  .map-chip { font-size: 14px; }
}
