:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e1ec;
  --line-strong: #b8c4d4;
  --text: #0f172a;
  --muted: #475569;
  --soft: #64748b;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --maxw: 1280px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  font-family: "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  line-height: 1.7;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

pre {
  overflow-x: auto;
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.6;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(217, 225, 236, 0.8);
  background: rgba(255, 255, 255, 0.95);
}

.site-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.brand {
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
}

.global-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.global-nav a {
  color: var(--muted);
  font-weight: 600;
}

.course-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.4rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.course-sidebar {
  position: sticky;
  top: 5.2rem;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 225, 236, 0.8);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
}

.course-sidebar__eyebrow,
.chapter-card__eyebrow,
.section-eyebrow,
.quiz-card__eyebrow,
.review-card__eyebrow {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}

.course-sidebar__title {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.1rem;
  line-height: 1.4;
  font-weight: 800;
  color: var(--text);
}

.course-sidebar__title.active,
.course-sidebar__list a.active,
.course-sidebar__list a[aria-current="page"] {
  color: var(--blue);
}

.course-sidebar__list {
  margin: 1rem 0;
  padding-left: 1.2rem;
}

.course-sidebar__list li + li {
  margin-top: 0.6rem;
}

.course-sidebar__list a {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.5;
}

.course-sidebar__list a.is-complete {
  color: var(--green);
}

.course-sidebar__list a.is-complete::after {
  content: " ✓";
  font-weight: 800;
}

.course-sidebar__back {
  display: inline-flex;
  margin-top: 0.6rem;
  font-weight: 700;
}

.course-main {
  min-width: 0;
}

.breadcrumbs {
  color: var(--soft);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

.breadcrumbs a {
  color: var(--soft);
}

.chapter-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
  font-size: 0.86rem;
}

h1 {
  margin: 0.9rem 0 0.4rem;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.15;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.25;
}

h3 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.1rem;
  line-height: 1.35;
}

.lead {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 1.08rem;
}

.course-main section,
.summary-card,
.figure-card,
.simulator-card,
.practice-block,
.code-card,
.quote-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.course-main section + section,
.course-main section + .practice-block,
.practice-block + section,
.figure-card + section,
.simulator-card + section,
.practice-block + .practice-block,
.summary-card + section {
  margin-top: 1.3rem;
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1.1rem 0 1.3rem;
}

.progress-strip__item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}

.progress-strip__label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--soft);
}

.progress-strip__item strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 1.2rem;
  margin-bottom: 1.3rem;
}

.hero-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-card--copy {
  padding: 1.4rem;
}

.hero-card--visual {
  padding: 1rem;
}

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

.chapter-card,
.review-card,
.stat-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 1rem 1.05rem;
}

.chapter-card p,
.review-card p,
.stat-card span {
  color: var(--muted);
}

.chip-row,
.action-row,
.preset-row {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.chip-row {
  margin-top: 1rem;
}

.chip {
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  color: var(--blue);
  font-weight: 800;
  font-size: 0.85rem;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-decoration: none;
}

.button-link:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.button-link--primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.button-link--secondary {
  background: #eff6ff;
  border-color: #c7ddff;
  color: var(--blue);
}

.button-link--ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--muted);
}

.note-card,
.summary-card,
.quote-card,
.insight-card {
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
  background: linear-gradient(180deg, #fcfdff 0%, #f7fbff 100%);
  border: 1px solid var(--line);
}

.summary-card {
  margin-top: 1.3rem;
}

.summary-card--compact {
  margin-top: 0;
}

.note-card strong,
.summary-card h3 {
  display: block;
  margin-bottom: 0.35rem;
}

.figure-card {
  margin-bottom: 1.3rem;
}

.inline-figure {
  display: grid;
  gap: 0.9rem;
}

.inline-figure figcaption {
  color: var(--soft);
  font-size: 0.95rem;
}

.definition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96rem;
}

.definition-table th,
.definition-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0.7rem;
  vertical-align: top;
  text-align: left;
}

.definition-table th {
  font-weight: 800;
  color: var(--soft);
  background: #f8fbff;
}

.formula-block,
.mini-formula {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #f8fbff;
  padding: 1rem 1.05rem;
  margin: 0.9rem 0;
}

.formula-line + .formula-line {
  margin-top: 0.45rem;
}

.practice-block__intro {
  margin-bottom: 1rem;
}

.practice-block__cards,
.review-grid {
  display: grid;
  gap: 1rem;
}

.quiz-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  overflow: hidden;
}

.quiz-card.is-correct {
  border-color: rgba(21, 128, 61, 0.35);
  box-shadow: inset 0 0 0 2px rgba(21, 128, 61, 0.08);
}

.quiz-card.is-wrong {
  border-color: rgba(185, 28, 28, 0.25);
}

.quiz-card__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 1rem 1.05rem 0;
}

.quiz-card__status {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 0.32rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
  background: #eef2f7;
  color: var(--muted);
}

.quiz-card__status.is-correct {
  background: var(--green-soft);
  color: var(--green);
}

.quiz-card__status.is-wrong {
  background: var(--red-soft);
  color: var(--red);
}

.quiz-card__body {
  padding: 0 1.05rem 1rem;
}

.answer-grid {
  display: grid;
  gap: 0.8rem;
  margin: 0.95rem 0 0.7rem;
}

.answer-field {
  display: grid;
  gap: 0.35rem;
  max-width: 220px;
}

.answer-field span {
  font-weight: 700;
  color: var(--muted);
}

.answer-field input {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
}

.answer-field input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.16);
  border-color: var(--blue);
}

.answer-field small {
  color: var(--soft);
  font-size: 0.85rem;
}

.choice-list {
  display: grid;
  gap: 0.65rem;
}

.choice {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fff;
}

.choice input {
  margin: 0;
}

.quiz-card__actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.quiz-card__feedback {
  min-height: 1.7em;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

.quiz-card__feedback.is-correct {
  color: var(--green);
}

.quiz-card__feedback.is-wrong {
  color: var(--red);
}

.quiz-card__details {
  margin-top: 0.55rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.7rem;
}

.quiz-card__details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--blue);
}

.control-group h3 {
  margin-top: 0.2rem;
}

.range-control {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.range-control span {
  font-weight: 700;
}

.range-control input[type="range"] {
  width: 100%;
}

.range-control output {
  width: fit-content;
  min-width: 2.5rem;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  color: var(--blue);
  font-weight: 800;
}

.control-help {
  margin: 0.35rem 0 0;
  color: var(--soft);
  font-size: 0.92rem;
}

.simulator-card {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 1.2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  line-height: 1.4;
}

.insight-card {
  margin-top: 1rem;
  border-left: 4px solid var(--blue);
}

.simulator-plot {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.plot-grid line {
  stroke: rgba(148, 163, 184, 0.28);
  stroke-width: 1;
}

.plot-axis {
  stroke: #475569;
  stroke-width: 2;
}

.plot-axis text,
.plot-label {
  fill: #475569;
  font-size: 12px;
  font-weight: 700;
}

.plot-region {
  fill: rgba(37, 99, 235, 0.18);
  stroke: rgba(37, 99, 235, 0.55);
  stroke-width: 2;
}

.plot-line {
  fill: none;
  stroke-width: 3;
}

.plot-line--constraint {
  stroke: rgba(37, 99, 235, 0.8);
}

.plot-line--objective {
  stroke: rgba(217, 119, 6, 0.95);
  stroke-dasharray: 10 10;
}

.plot-line--opt-edge {
  stroke: rgba(185, 28, 28, 0.85);
  stroke-width: 5;
  stroke-linecap: round;
}

.plot-point circle {
  stroke: #fff;
  stroke-width: 2.5;
  fill: var(--blue);
}

.plot-point.is-best circle {
  fill: #dc2626;
}

.plot-point text {
  fill: #1e293b;
  font-size: 12px;
  font-weight: 700;
}

.code-card {
  margin-top: 1rem;
}

.code-card pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius-md);
}

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

.review-card {
  display: grid;
  gap: 0.6rem;
}

.review-card.is-complete {
  border-color: rgba(21, 128, 61, 0.35);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.review-card__count {
  font-weight: 800;
  color: var(--text);
}

.review-total {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.tips-list {
  margin: 0;
  padding-left: 1.4rem;
}

.tips-list li + li {
  margin-top: 0.45rem;
}

.table-card {
  overflow-x: auto;
}

.page-footer {
  border-top: 1px solid rgba(217, 225, 236, 0.9);
  background: #fff;
}

.page-footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.2rem 1.5rem 2rem;
}

.page-footer__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--soft);
  margin-top: 0.35rem;
}

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

  .course-sidebar {
    position: static;
  }

  .hero-grid,
  .simulator-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .site-header__inner,
  .course-shell,
  .page-footer__inner {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .progress-strip,
  .stats-grid,
  .card-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .quiz-card__head {
    flex-direction: column;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
  }

  .button-link {
    width: 100%;
  }

  .action-row .button-link {
    width: auto;
  }
}

.chapter-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.3rem;
}

.chapter-nav a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 700;
}

.chapter-nav small {
  display: block;
  color: var(--soft);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.mini-formula {
  display: inline-block;
}

.quote-card {
  margin: 0.9rem 0;
  border-left: 4px solid var(--blue);
}

.preset-row {
  margin-top: 1rem;
}

.preset-row__label {
  font-weight: 800;
  color: var(--muted);
}
