:root {
  color-scheme: light;
  --ink: #241033;
  --muted: #675675;
  --paper: #ffffff;
  --field: #f7efff;
  --line: #e4d1f4;
  --green: #57068c;
  --blue: #2f6fb3;
  --red: #d34f73;
  --amber: #b4792d;
  --violet: #8b3fd1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(47, 111, 179, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(87, 6, 140, 0.1) 1px, transparent 1px),
    var(--field);
  background-size: 36px 36px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.course-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 34px;
  height: 100vh;
  padding: 34px;
  background: #57068c;
  color: #ffffff;
}

.back-link,
.module-nav a {
  color: inherit;
  text-decoration: none;
}

.back-link {
  width: fit-content;
  border: 1px solid rgba(217, 189, 255, 0.58);
  border-radius: 8px;
  padding: 9px 12px;
  color: #efe0ff;
  font-size: 0.92rem;
}

.back-link:hover,
.module-nav a:hover {
  background: rgba(217, 189, 255, 0.2);
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.course-rail .eyebrow {
  color: #d9bdff;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 16px 0 12px;
  font-size: clamp(2.7rem, 5vw, 4.9rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.8rem, 3vw, 3.25rem);
  line-height: 1.04;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.course-name {
  margin-bottom: 20px;
  color: #efe0ff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.4;
}

.intro {
  color: #ead8ff;
  line-height: 1.7;
}

.module-nav {
  display: grid;
  gap: 10px;
}

.module-nav a {
  border-radius: 8px;
  padding: 10px 12px;
  color: #ffffff;
  font-weight: 700;
}

.course-meta {
  display: grid;
  gap: 12px;
  margin: auto 0 0;
}

.course-meta div {
  border: 1px solid rgba(217, 189, 255, 0.3);
  border-radius: 8px;
  padding: 12px;
  background: rgba(217, 189, 255, 0.16);
}

.course-meta dt {
  color: #d9bdff;
  font-size: 0.82rem;
}

.course-meta dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.course-main {
  width: min(1160px, 100%);
  padding: 48px;
}

.hero-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 44px rgba(20, 32, 28, 0.08);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
  gap: 28px;
  align-items: center;
  padding: 34px;
}

.hero-panel p,
.panel-note,
.concept-detail p,
.concept-detail li {
  color: var(--muted);
  line-height: 1.7;
}

.overview-grid {
  display: grid;
  gap: 14px;
}

.overview-grid article {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 14px;
  align-items: center;
  border: 1px solid #e1d5e9;
  border-radius: 8px;
  padding: 14px;
  background: #f5e9ff;
}

.overview-grid p {
  grid-column: 2;
  margin: 0;
  font-size: 0.94rem;
}

.mini-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #57068c;
  color: #efe0ff;
  font-weight: 900;
}

.overview-grid article:nth-child(2) .mini-icon {
  background: #2f6fb3;
}

.overview-grid article:nth-child(3) .mini-icon {
  background: #b4792d;
}

.concept-node[data-topic="eigenstructure"] span,
.concept-node[data-topic="stability"] span {
  background: #ffe8ef;
  color: #d34f73;
}

.concept-node[data-topic="linear-maps"] span,
.concept-node[data-topic="matrix-exponential"] span {
  background: #e7f0ff;
  color: #2f6fb3;
}

.concept-node[data-topic="ode-systems"] span {
  background: #f7ead6;
  color: #b4792d;
}

.panel {
  margin-top: 28px;
  padding: 28px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.panel-heading .panel-note {
  max-width: 320px;
  margin: 0;
}

.concept-board {
  position: relative;
  min-height: 430px;
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid #dcd2e8;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 25%, rgba(180, 121, 45, 0.14), transparent 24%),
    radial-gradient(circle at 74% 72%, rgba(87, 6, 140, 0.18), transparent 28%),
    #fcf8ff;
}

.concept-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.concept-lines line {
  stroke: rgba(87, 6, 140, 0.32);
  stroke-width: 2;
}

.concept-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 190px;
  border: 1px solid #e5d0f5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px;
  font-weight: 800;
  text-align: left;
  box-shadow: 0 12px 28px rgba(20, 32, 28, 0.12);
  touch-action: none;
  user-select: none;
}

.concept-node span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f0e1ff;
  color: var(--green);
  font-weight: 900;
}

.concept-node.is-active {
  border-color: rgba(87, 6, 140, 0.82);
  box-shadow: 0 16px 34px rgba(87, 6, 140, 0.28);
}

.concept-node.is-dragging {
  z-index: 3;
}

.concept-detail {
  margin-top: 18px;
  border: 1px solid #e8d7f3;
  border-radius: 8px;
  background: #ffffff;
  padding: 20px;
}

.concept-detail ul {
  margin: 0;
  padding-left: 20px;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

.matrix-controls {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.matrix-controls label {
  display: grid;
  grid-template-columns: 28px 1fr 44px;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--green);
}

.system-readout {
  display: grid;
  gap: 10px;
  margin: 0;
}

.system-readout div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid #eadbf4;
  border-radius: 8px;
  padding: 12px;
  background: #fcf8ff;
}

.system-readout dt {
  color: var(--muted);
  font-size: 0.86rem;
}

.system-readout dd {
  margin: 0;
  font-weight: 850;
}

.phase-plane {
  width: 100%;
  min-height: 420px;
  border: 1px solid #dcd2e8;
  border-radius: 8px;
  background: #f8f3ff;
}

.axis {
  stroke: rgba(36, 16, 51, 0.58);
  stroke-width: 1.6;
}

.field-line {
  stroke: rgba(47, 111, 179, 0.78);
  stroke-width: 2;
  stroke-linecap: round;
}

.field-line.strong {
  stroke: rgba(211, 79, 115, 0.78);
}

.equilibrium {
  fill: var(--ink);
}

.note-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.note-form input,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px;
  font-size: 1rem;
}

.note-form textarea {
  min-height: 110px;
  resize: vertical;
}

.note-form button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  padding: 13px 16px;
  font-weight: 800;
}

.note-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.note-card {
  border: 1px solid #e8d7f3;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.note-card h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.note-card p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.note-card time {
  color: #75637f;
  font-size: 0.84rem;
}

@media (max-width: 980px) {
  .course-shell {
    grid-template-columns: 1fr;
  }

  .course-rail {
    position: relative;
    height: auto;
  }

  .course-main {
    padding: 28px;
  }

  .hero-panel,
  .split-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .course-main,
  .course-rail,
  .hero-panel,
  .panel {
    padding: 22px;
  }

  h1 {
    font-size: 3rem;
  }

  h2 {
    font-size: 2rem;
  }

  .panel-heading {
    display: block;
  }

  .concept-board {
    min-height: 560px;
  }

  .concept-node {
    min-width: 160px;
  }

  .system-readout div,
  .matrix-controls label {
    grid-template-columns: 1fr;
  }
}
