:root {
  color-scheme: light;
  --ink: #20242c;
  --muted: #586170;
  --line: #d8dde7;
  --paper: #fbfcfe;
  --panel: #ffffff;
  --blue: #2563a9;
  --teal: #0f766e;
  --green: #2f7d47;
  --red: #b33a3a;
  --yellow: #b66f00;
  --lavender: #6d5bd0;
  --soft-blue: #eef5fc;
  --soft-teal: #eef8f6;
  --soft-red: #fff1f1;
  --soft-yellow: #fff7e8;
  --shadow: 0 12px 30px rgba(34, 43, 63, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--blue);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: #f2f6fb;
  overflow-y: auto;
}

.course,
.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
}

.nav-title {
  margin: 8px 0 18px;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: 0;
}

nav {
  display: grid;
  gap: 3px;
}

nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #283142;
  text-decoration: none;
  font-size: 0.94rem;
}

nav a:hover,
nav a:focus,
nav a.active {
  border-color: #bdc9da;
  background: #ffffff;
  outline: none;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.resource-links a {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #ffffff;
  text-decoration: none;
  font-weight: 750;
  font-size: 0.88rem;
}

.resource-links.wide {
  margin-top: 24px;
}

.aside-note {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  min-width: 0;
}

section {
  padding: 58px clamp(22px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
}

section:nth-child(even) {
  background: #ffffff;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.96fr);
  gap: clamp(28px, 5vw, 58px);
  align-items: center;
  min-height: 78vh;
  background: #f8fbff;
}

.hero h2 {
  max-width: 860px;
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(1.65rem, 3.4vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

section:not(.hero) h2 {
  font-size: clamp(1.55rem, 2.8vw, 2.6rem);
  line-height: 1.08;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  line-height: 1.18;
  letter-spacing: 0;
}

h4 {
  margin: 0 0 8px;
  color: #2a3445;
}

p {
  max-width: 80ch;
}

.institution {
  color: var(--muted);
  font-weight: 750;
}

.lead {
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  color: #394354;
  max-width: 68ch;
}

.section-head {
  max-width: 920px;
}

.learning-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  max-width: 840px;
}

.map-item,
.concept,
.exercise,
.metric,
.code-card,
.output-card,
.definition,
.step,
.table-wrap,
.text-output,
.token-box,
.pipeline-readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-item {
  padding: 14px;
  min-height: 122px;
}

.map-item strong,
.definition strong {
  display: block;
  margin-bottom: 4px;
}

.map-item span,
.concept p,
.exercise p,
.metric p,
.step span,
.definition p {
  color: var(--muted);
}

.viz-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-viz {
  align-self: center;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  background: #ffffff;
}

#pixelCanvas {
  cursor: crosshair;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.blue { background: var(--blue); }
.teal { background: var(--teal); }
.green { background: var(--green); }
.red { background: var(--red); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.9fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: start;
}

.grid-2 > *,
.code-grid > *,
.learning-map > *,
.timeline > * {
  min-width: 0;
}

.chapter-grid {
  margin-top: 18px;
}

.concept,
.exercise,
.definition {
  padding: 18px;
}

.definition {
  margin: 18px 0;
  border-left: 4px solid var(--teal);
  box-shadow: none;
}

.definition.warning {
  border-left-color: var(--yellow);
  background: var(--soft-yellow);
}

.definition.danger {
  border-left-color: var(--red);
  background: var(--soft-red);
}

.definition p,
.concept p,
.exercise p {
  margin-bottom: 0;
}

.clean-list {
  padding-left: 20px;
}

.clean-list li {
  margin-bottom: 7px;
}

.formula {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--teal);
  background: var(--soft-teal);
  border-radius: 0 8px 8px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
  white-space: nowrap;
}

.math-details {
  margin: 18px 0 0;
  border: 1px solid #cad6e5;
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: 0 8px 22px rgba(34, 43, 63, 0.06);
  overflow: hidden;
}

.math-details summary {
  cursor: pointer;
  padding: 13px 16px;
  color: #243047;
  font-weight: 800;
  list-style-position: inside;
}

.math-details summary:hover,
.math-details summary:focus {
  background: #eef5fc;
  outline: none;
}

.math-details p,
.math-details ol {
  margin: 0;
  padding: 0 16px 14px;
  color: #495466;
}

.math-details pre {
  margin: 0 16px 16px;
  border-radius: 8px;
}

.controls {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #364052;
  font-weight: 700;
  font-size: 0.94rem;
}

label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 9px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  border: 1px solid #b9c5d6;
  border-radius: 8px;
  padding: 10px 11px;
  color: #20242c;
  background: #ffffff;
  font: inherit;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

input[type="range"]:disabled {
  opacity: 0.45;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

.metric-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid #cbd7e6;
  border-radius: 7px;
  background: #f8fbff;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 750;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.step {
  padding: 12px;
  min-height: 118px;
}

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

.stage-list {
  margin: 14px 0 0;
  padding-left: 20px;
}

.stage-list li {
  margin-bottom: 7px;
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.code-card,
.output-card {
  margin-top: 22px;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.code-grid .code-card,
.code-grid .output-card {
  margin-top: 0;
}

.code-grid .code-card:only-child {
  grid-column: 1 / -1;
}

.output-card h3 {
  padding: 12px 14px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #f6f8fb;
  font-size: 1rem;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f6f8fb;
}

.code-head h3 {
  margin: 0;
  font-size: 1rem;
}

.code-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.run-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.run-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  max-width: 100%;
  background: #101722;
  color: #edf4ff;
  font-size: 0.9rem;
  line-height: 1.55;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

p code,
td code,
li code {
  background: #eef2f7;
  color: #1e2b3d;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  font-size: 0.93em;
}

button {
  appearance: none;
  border: 1px solid #b9c5d6;
  background: #ffffff;
  color: #263244;
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover,
button:focus {
  border-color: var(--blue);
  outline: none;
}

.copy-button.copied {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.code-context {
  margin: 14px 0;
  color: #536174;
  font-size: 0.94rem;
}

.api-output {
  border-top: 1px solid #2a3544;
  background: #0f1722;
}

.api-output-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid #243144;
  background: #172233;
  color: #dfe8f7;
}

.api-output-head p {
  margin: 0;
  color: #aebbd0;
  font-size: 0.82rem;
}

.api-output pre {
  background: #0f1722;
  color: #eaf2ff;
  min-height: 54px;
}

.api-output.idle pre,
.api-output.loading pre {
  color: #b8c5d8;
}

.api-output.ready {
  border-top-color: rgba(46, 125, 50, 0.6);
}

.api-output.error {
  border-top-color: rgba(184, 62, 52, 0.75);
}

.api-output.error .api-output-head {
  background: #331d1c;
}

.media-output-grid {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-top: 1px solid #243144;
  background: #111b29;
}

.media-output {
  margin: 0;
  padding: 12px;
  border: 1px solid #314158;
  border-radius: 8px;
  background: #0f1722;
}

.media-output img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
  background: #ffffff;
}

.media-output audio {
  width: 100%;
}

.media-output figcaption {
  margin-top: 9px;
  color: #d7e3f4;
  font-size: 0.88rem;
  line-height: 1.45;
}

.text-output {
  min-height: 118px;
  margin-top: 16px;
  padding: 16px;
  box-shadow: none;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.text-output.bad {
  border-left: 4px solid var(--red);
  background: var(--soft-red);
}

.text-output.good {
  border-left: 4px solid var(--green);
  background: #eff8f1;
}

.token-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.token-box {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 128px;
  padding: 12px;
  box-shadow: none;
}

.token {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #cbd7e8;
  border-radius: 8px;
  background: #f7fbff;
  color: #22304a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.token.drop {
  border-style: dashed;
  color: #7b4550;
  background: #fff5f6;
}

.jp-source {
  margin: 16px 0 12px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-blue);
  border: 1px solid #ccd8e8;
  font-size: 1.08rem;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.pos-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.pos-item strong {
  display: block;
  margin-bottom: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pos-item span {
  color: var(--muted);
  font-weight: 800;
}

.pipeline-readout {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  box-shadow: none;
}

.pipeline-row {
  display: grid;
  gap: 7px;
}

.pipeline-row strong {
  color: #2a3445;
}

.exercise-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f8fb;
  color: #2a3445;
}

.entity-output {
  min-height: 140px;
  margin-top: 16px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.entity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px;
  padding: 0 6px;
  border-radius: 6px;
  background: #eaf2ff;
  color: #17345f;
  font-weight: 750;
}

.entity span {
  padding: 1px 5px;
  border-radius: 5px;
  background: #2563a9;
  color: #ffffff;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.bar-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(86px, 120px) 1fr 42px;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  font-weight: 750;
  color: #263244;
  overflow-wrap: anywhere;
}

.bar-row div {
  height: 18px;
  background: #e9eef6;
  border-radius: 4px;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2563a9, #0f766e);
}

.bar-row strong {
  text-align: right;
  color: #394354;
}

.matrix-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.panel-note,
.topic-context {
  margin: 0 0 14px;
  color: #536174;
  font-size: 0.92rem;
}

.panel-note code {
  font-size: 0.86em;
}

.sample-docs {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.sample-docs strong {
  display: block;
  margin-bottom: 9px;
  color: #20242c;
}

.sample-docs ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.15rem;
}

.sample-docs li {
  color: #3b4658;
  line-height: 1.45;
}

.sample-docs span {
  display: inline-flex;
  min-width: 42px;
  margin-right: 6px;
  font-weight: 800;
  color: #1f5f8f;
}

.matrix-wrap table {
  min-width: 840px;
  font-size: 0.78rem;
}

.matrix-wrap th,
.matrix-wrap td {
  padding: 7px 8px;
  text-align: center;
}

.matrix-wrap td.filled {
  background: #edf8f6;
  color: #0f5f58;
  font-weight: 800;
}

.topic-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  min-height: 160px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.topic-cloud span {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 7px;
  background: #f0f4fb;
  color: #1e2b3d;
  font-weight: 800;
}

.check-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.check-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ethics-score {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 8px;
  background: #f0f4fb;
  color: #263244;
  font-weight: 800;
}

.ethics-score.level-5 {
  background: #eff8f1;
  color: #245f34;
}

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

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

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

  .hero,
  .grid-2,
  .code-grid,
  .token-columns {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  section {
    padding: 42px 18px;
  }

  .learning-map,
  .timeline,
  nav,
  .pos-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  pre {
    font-size: 0.82rem;
  }

  .formula {
    white-space: normal;
  }
}
