html {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(to bottom, #f8f8f4 0, #fcfcf9 12rem, #fff 22rem);
  color: #111;
  font-family: "KaTeX_Main", "Latin Modern Roman", "CMU Serif", "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.55;
}

a {
  color: #173ea9;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-layout {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem 1.4rem 3rem;
}

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 2.6rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 1.4rem;
  align-self: start;
}

.sidebar-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1rem;
  color: #555;
  font-size: 0.92rem;
  line-height: 1.2;
}

.sidebar-back:hover {
  color: #173ea9;
  text-decoration: none;
}

.sidebar-title {
  margin: 0 0 1rem;
  font-size: 1.55rem;
  line-height: 1.15;
}

.sidebar-subtitle {
  margin: 0 0 1rem;
  color: #444;
  font-size: 0.97rem;
  line-height: 1.45;
}

.chapter-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid #d9d7cb;
}

.chapter-list li {
  margin: 0;
  border-bottom: 1px solid #e5e3d7;
}

.chapter-link {
  display: block;
  padding: 0.72rem 0.1rem;
  color: #202020;
  line-height: 1.35;
}

.chapter-link:hover {
  color: #173ea9;
  text-decoration: none;
}

.chapter-link.active {
  color: #173ea9;
  font-weight: 700;
}

.content {
  min-width: 0;
}

.content-header {
  margin-bottom: 1.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #d9d7cb;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: #555;
}

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.content-header h1 {
  margin: 0;
  font-size: 2.1rem;
}

h2 {
  margin: 0 0 0.7rem;
  font-size: 1.48rem;
}

h3 {
  margin: 1.45rem 0 0.45rem;
  font-size: 1.08rem;
}

p,
ul,
ol,
figure {
  margin: 0.68rem 0;
}

ul,
ol {
  padding-left: 1.6rem;
}

li + li {
  margin-top: 0.18rem;
}

.chapter {
  max-width: 45rem;
}

.mjx-container[jax="SVG"] {
  margin: 0.85rem 0;
}

.mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
}

.inline-image {
  display: block;
  max-width: 13.5rem;
  height: auto;
  margin: 0.55rem auto 1.1rem;
}

.inline-image-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: center;
  margin: 0.9rem 0 1.2rem;
}

.mm-figure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin: 1rem 0 1.4rem;
}

.mm-figure-card {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-figure-image {
  display: block;
  width: 100%;
  height: 20.5rem;
  object-fit: contain;
}

.correlation-image {
  max-width: 16rem;
}

.normal-image {
  max-width: 16rem;
}

.large-portfolios-image {
  max-width: 29rem;
}

.diversification-example-image {
  max-width: 18rem;
}

.diversification-limit-image {
  max-width: 18rem;
}

.tbill-line-image {
  max-width: 18rem;
}

.gm-motorola-image {
  max-width: 18rem;
}

.gm-motorola-table-image {
  max-width: 18rem;
}

.efficient-frontier-image {
  max-width: 18rem;
}

.gm-ibm-mot-table-image {
  max-width: 18rem;
}

.gm-ibm-mot-frontier-image {
  max-width: 18rem;
}

.tangency-portfolio-image {
  max-width: 18rem;
}

.sml-pricing-image {
  max-width: 18rem;
}

.cml-sml-combined-image {
  max-width: 18rem;
}

.chapter-risk .inline-image {
  max-width: 17rem;
}

.chapter-risk .correlation-image {
  max-width: 23rem;
}

.chapter-normal .inline-image {
  max-width: 14.5rem;
}

.chapter-normal .normal-image {
  max-width: 17rem;
}

.chapter-two-asset .gm-motorola-image {
  max-width: 21rem;
}

.chapter-two-asset .gm-motorola-table-image {
  max-width: 21rem;
}

.chapter-two-asset .tbill-line-image {
  max-width: 21rem;
}

.chapter-many-stocks .diversification-example-image {
  max-width: 21rem;
}

.chapter-many-stocks .diversification-limit-image {
  max-width: 21rem;
}

.chapter-many-stocks .efficient-frontier-image {
  max-width: 21rem;
}

.chapter-many-stocks .gm-ibm-mot-table-image {
  max-width: 21rem;
}

.chapter-many-stocks .gm-ibm-mot-frontier-image {
  max-width: 21rem;
}

.chapter-risk-free .tangency-portfolio-image {
  max-width: 23rem;
}

.chapter-capm .sml-pricing-image {
  max-width: 21rem;
}

.chapter-capm .cml-sml-combined-image {
  max-width: 42rem;
}

.matrix-image {
  max-width: calc(50% - 0.5rem);
  flex: 0 1 calc(50% - 0.5rem);
}

.matrix-image-small {
  max-width: 38%;
  flex-basis: 38%;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 45rem;
  margin-top: 2.4rem;
  padding-top: 1rem;
  border-top: 1px solid #d9d7cb;
}

.chapter-nav a {
  display: inline-block;
}

.chapter-nav .next {
  margin-left: auto;
  text-align: right;
}

@media (max-width: 920px) {
  body {
    font-size: 17px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 1.4rem;
  }

  .sidebar {
    position: static;
  }

  .chapter-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1rem;
    border-top: 0;
  }

  .chapter-list li {
    border-bottom: 0;
  }

  .chapter-link {
    padding: 0.2rem 0;
  }
}

@media (max-width: 760px) {
  .page-layout {
    padding-inline: 1rem;
  }

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

  .inline-image-row {
    flex-wrap: wrap;
  }

  .mm-figure-grid {
    grid-template-columns: 1fr;
  }

  .mm-figure-image {
    height: auto;
  }

  .matrix-image {
    max-width: 100%;
    flex-basis: 100%;
  }

  .matrix-image-small {
    max-width: 100%;
    flex-basis: 100%;
  }

  .content-header h1 {
    font-size: 1.8rem;
  }

  .chapter-nav {
    display: block;
  }

  .chapter-nav .next {
    margin-left: 0;
    margin-top: 0.6rem;
    text-align: left;
  }
}


.example-box {
  margin: 1rem 0 1.3rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(31, 79, 184, 0.28);
  border-radius: 10px;
  background: rgba(32, 92, 214, 0.06);
}

.example-box > :first-child {
  margin-top: 0;
}

.example-box > :last-child {
  margin-bottom: 0;
}

.formula-block {
  margin: 0.9rem 0;
}

.formula-highlight {
  margin: 0.9rem 0;
}

.formula-highlight .mjx-container[jax="SVG"] {
  margin: 0;
}

.definition-list {
  display: grid;
  grid-template-columns: minmax(0, max-content) 1fr;
  gap: 0.3rem 1rem;
  margin: 0.75rem 0 1rem;
}

.definition-list dt {
  font-weight: 700;
}

.definition-list dd {
  margin: 0;
}

.mm-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.9rem 0 1.15rem;
  font-size: 0.98rem;
}

.mm-table thead th {
  border-top: 2px solid #3a3a3a;
  border-bottom: 1px solid #8b8a84;
  padding: 0.55rem 0.6rem;
  text-align: left;
}

.mm-table tbody td,
.mm-table tbody th {
  border-bottom: 1px solid #dfddd3;
  padding: 0.52rem 0.6rem;
  vertical-align: top;
  text-align: left;
}

.mm-table tbody tr:last-child td,
.mm-table tbody tr:last-child th {
  border-bottom: 2px solid #3a3a3a;
}

.mm-table .row-strong {
  background: rgba(0, 0, 0, 0.06);
}

.mm-table .row-soft {
  background: rgba(0, 0, 0, 0.03);
}

.mm-table.centered td,
.mm-table.centered th,
.mm-table.centered thead th {
  text-align: center;
}

.diagram-wrap {
  display: flex;
  justify-content: center;
  margin: 1rem 0 1.2rem;
}

.tax-diagram {
  max-width: 30rem;
  width: 100%;
  height: auto;
}

.tax-diagram text {
  font-family: "KaTeX_Main", "Latin Modern Roman", "CMU Serif", "Times New Roman", serif;
  fill: #161616;
}

.note-list {
  margin-top: 0.35rem;
}

.chapter ul li strong {
  font-weight: 700;
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }

  .sidebar {
    position: static;
  }

  .chapter {
    max-width: none;
  }

  .definition-list {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }
}
