:root {
  --qu-burgundy: #8a1538;
  --qu-burgundy-dark: #65102a;
  --qu-gold: #c59b3a;
  --ink: #1f2933;
  --muted: #61707f;
  --surface: #f7f8fa;
  --line: #e2e6eb;
  --green: #17795b;
  --blue: #2563a6;
}

body, .book.font-family-1 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--ink); }
.book .book-summary { background: #fbfbfc; border-right: 1px solid var(--line); }
.book .book-summary ul.summary li a { color: #3f4852; padding: 9px 16px; }
.book .book-summary ul.summary li.active > a { color: var(--qu-burgundy); border-left: 4px solid var(--qu-burgundy); background: #f7edf1; font-weight: 650; }
.book .book-summary ul.summary li a:hover { color: var(--qu-burgundy); background: #faf2f5; }
.course-brand a { background: var(--qu-burgundy); color: white !important; font-size: 1.25rem; font-weight: 750; letter-spacing: .04em; padding: 18px 16px !important; }
.course-meta { color: var(--muted); font-size: .8rem; padding: 12px 16px; }
.book .book-body .page-wrapper .page-inner { max-width: 920px; padding: 2rem 3rem 4rem; }
h1, h2, h3 { color: var(--qu-burgundy); letter-spacing: -.015em; }
h1 { border-bottom: 3px solid var(--qu-burgundy); padding-bottom: .45rem; }
h2 { margin-top: 2rem; border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
h3 { color: var(--qu-burgundy-dark); }
p, li { line-height: 1.68; }
a { color: var(--qu-burgundy); }

.hero { background: linear-gradient(135deg, var(--qu-burgundy), var(--qu-burgundy-dark)); color: white; padding: 1.5rem 1.7rem; margin: 1rem 0 1.8rem; border-radius: 10px; box-shadow: 0 8px 24px rgba(101,16,42,.15); }
.hero h2, .hero a { color: white; }
.hero h2 { border: 0; margin-top: 0; }
.welcome-info-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 1.15rem; margin: 1rem 0 1.9rem; align-items: stretch; }
.welcome-info-card { min-width: 0; padding: 1rem 1.1rem; border-radius: 12px; color: white; background: linear-gradient(145deg, var(--qu-burgundy), var(--qu-burgundy-dark)); box-shadow: 0 8px 24px rgba(101,16,42,.16); font-size: 1.13rem; word-break: normal; overflow-wrap: normal; }
.welcome-info-card h2 { margin: 0 0 .65rem; padding: 0 0 .42rem; border-bottom: 1px solid rgba(255,255,255,.28); color: white; font-size: 1.55rem; white-space: nowrap; }
.welcome-info-card h3 { margin: .45rem 0 .6rem; color: white; text-align: center; font-size: 1.28rem; }
.welcome-info-card a { color: white; text-decoration-color: rgba(255,255,255,.6); white-space: nowrap; word-break: normal; overflow-wrap: normal; }
.welcome-info-card a:hover { color: #ffe7a6; }
.welcome-info-list { margin: 0; }
.welcome-info-list > div { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .65rem; padding: .22rem 0; border-bottom: 1px solid rgba(255,255,255,.1); align-items: baseline; }
.welcome-info-list > div:last-child { border-bottom: 0; }
.welcome-info-list dt { margin: 0; font-weight: 750; white-space: nowrap; word-break: normal; overflow-wrap: normal; }
.welcome-info-list dd { min-width: 0; margin: 0; word-break: normal; overflow-wrap: normal; }
.welcome-instructor-photo { display: block; width: 160px; height: 160px; max-width: 52%; margin: .1rem auto 0; border: 4px solid rgba(255,255,255,.9); border-radius: 50%; object-fit: cover; object-position: center 22%; box-shadow: 0 6px 18px rgba(37,5,16,.28); }
.instructor-info-card .welcome-info-list > div { grid-template-columns: max-content minmax(0, 1fr); }
.checkpoint, .keyidea, .r-note, .finance, .actuarial, .warning, .definition-box, .theorem-box, .interpretation, .example-box { padding: 1rem 1.1rem; margin: 1.25rem 0; border-radius: 7px; border: 1px solid var(--line); }
.definition-box { background: #fff8d8; border-left: 5px solid #d7a900; }
.theorem-box { background: #eaf7ef; border-left: 5px solid #23824f; }
.interpretation { background: #edf5ff; border-left: 5px solid #2774b8; }
.example-box { background: #f6f7f9; border-left: 5px solid #687684; }
.definition-box::before, .theorem-box::before, .interpretation::before, .example-box::before { display: block; margin-bottom: .45rem; font-weight: 800; letter-spacing: .02em; }
.definition-box::before { content: "DEFINITION"; color: #8a6900; }
.theorem-box::before { content: "THEOREM / RESULT"; color: #17633b; }
.interpretation::before { content: "INTERPRETATION"; color: #1f5f96; }
.example-box::before { content: "EXAMPLE"; color: #4c5965; }
.checkpoint { background: #fff9e9; border-left: 5px solid var(--qu-gold); }
.keyidea { background: #edf8f4; border-left: 5px solid var(--green); }
.r-note { background: #eef5fc; border-left: 5px solid var(--blue); }
.finance { background: #f7edf1; border-left: 5px solid var(--qu-burgundy); }
.actuarial { background: #f4f0fa; border-left: 5px solid #7653a6; }
.warning { background: #fff1f0; border-left: 5px solid #c0392b; }

details { position: relative; z-index: 5; margin: 1rem 0 1.25rem; padding: .75rem .9rem; border: 1px solid #d8dde4; border-radius: 7px; background: #fcfcfd; }
details[open] { box-shadow: 0 3px 12px rgba(31,41,51,.06); }
summary { position: relative; z-index: 6; color: var(--qu-burgundy); font-weight: 700; cursor: pointer; padding: .25rem; }
.book .book-body .navigation-prev,
.book .book-body .navigation-next { display: none !important; pointer-events: none !important; }
pre { border-radius: 6px; border: 1px solid #dce2e8; }
pre.r { border-left: 4px solid var(--blue); }
.sourceCode { font-size: .93em; }
.r-code-fold { position: relative; z-index: 4; margin: 1rem 0; padding: 0; border: 1px solid #cfd9e4; border-radius: 7px; background: #f7faff; overflow: hidden; }
.r-code-fold[open] { box-shadow: 0 3px 12px rgba(31,41,51,.06); }
.r-code-fold > summary { display: block; padding: .65rem .9rem; color: #1f5f96; background: #edf5ff; font-weight: 750; cursor: pointer; user-select: none; }
.r-code-fold > summary::-webkit-details-marker { display: none; }
.r-code-fold > summary::before { content: "▶"; display: inline-block; width: 1.25rem; font-size: .8em; transition: transform .15s ease; }
.r-code-fold[open] > summary::before { transform: rotate(90deg); }
.r-code-fold .label-hide { display: none; }
.r-code-fold[open] .label-show { display: none; }
.r-code-fold[open] .label-hide { display: inline; }
.r-code-fold > .sourceCode { margin: 0; border: 0; border-radius: 0; }
.r-code-fold > .sourceCode pre { margin: 0; border: 0; border-radius: 0; }
.r-code-fold > pre, .r-code-fold > p, .r-code-fold > table, .r-code-fold > .html-widget { margin: .75rem .9rem 1rem; }
.r-code-fold > p img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.distribution-explorer, .continuous-explorer, .bivariate-explorer { margin: 1.2rem 0 1.8rem; padding: 1rem; border: 1px solid #d8dde4; border-top: 5px solid var(--qu-burgundy); border-radius: 8px; background: #fff; box-shadow: 0 4px 14px rgba(31,41,51,.06); }
.distribution-explorer::before, .continuous-explorer::before, .bivariate-explorer::before { display: block; color: var(--qu-burgundy); font-weight: 800; margin-bottom: .75rem; letter-spacing: .02em; }
.distribution-explorer::before { content: "INTERACTIVE DISTRIBUTION EXPLORER"; }
.continuous-explorer::before { content: "INTERACTIVE DENSITY EXPLORER"; }
.bivariate-explorer::before { content: "INTERACTIVE BIVARIATE NORMAL EXPLORER"; }
.dist-controls { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: .65rem 1.2rem; padding: .75rem; background: #f7edf1; border-radius: 6px; }
.dist-controls label span { display: block; color: var(--ink); font-size: .9rem; }
.dist-controls input { width: 100%; accent-color: var(--qu-burgundy); }
.dist-chart { margin-top: .75rem; overflow-x: auto; }
.dist-chart svg { display: block; width: 100%; min-width: 460px; max-height: 300px; }
.dual-chart { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; overflow: visible; }
.dual-chart .chart-panel { min-width: 0; border: 1px solid #e1e5e9; border-radius: 7px; padding: .35rem; background: #fff; }
.dual-chart .chart-panel h4 { margin: .2rem 0 .15rem; color: var(--qu-burgundy); text-align: center; font-size: .92rem; }
.dual-chart .chart-panel svg { min-width: 0; width: 100%; }
.dist-chart svg rect { fill: var(--qu-burgundy); opacity: .86; }
.dist-chart svg rect:hover { fill: var(--qu-gold); opacity: 1; }
.dist-chart svg .current-bar { fill: var(--qu-burgundy); opacity: .82; }
.dist-chart svg .comparison-bar { fill: var(--qu-gold); opacity: .68; }
.dist-chart svg .density-line { fill: none; stroke: var(--qu-burgundy); stroke-width: 4; }
.dist-chart svg .comparison-density-line { fill: none; stroke: var(--qu-gold); stroke-width: 4; stroke-dasharray: 10 5; }
.dist-chart svg .density-area { fill: #f7dce5; stroke: none; }
.dist-chart svg .scatter-point { fill: var(--qu-burgundy); opacity: .32; }
.dist-chart svg .ellipse { fill: none; stroke: var(--qu-burgundy); stroke-width: 2.2; }
.dist-chart svg .comparison-ellipse { fill: none; stroke: var(--qu-gold); stroke-width: 2.2; stroke-dasharray: 9 5; }
.dist-chart svg .tick { stroke: #52606d; stroke-width: 1; }
.dist-chart svg line { stroke: #52606d; stroke-width: 1; }
.dist-chart svg text { fill: #52606d; font-size: 11px; }
.dist-stats { padding: .5rem .75rem; color: #344250; background: #f7f8fa; border-radius: 5px; font-size: .92rem; }
.comparison-tools { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; padding: .65rem .75rem; border-top: 1px solid #e2d5da; background: #fff; }
.comparison-tools button { border: 1px solid var(--qu-burgundy); border-radius: 5px; padding: .45rem .7rem; background: white; color: var(--qu-burgundy); font-weight: 700; cursor: pointer; }
.comparison-tools button:hover { background: #f7edf1; }
.comparison-tools button:disabled { opacity: .45; cursor: default; }
.shape-legend { margin-left: auto; color: var(--muted); font-size: .84rem; }
.shape-legend i { display: inline-block; width: .9rem; height: .7rem; margin: 0 .25rem 0 .65rem; border-radius: 2px; vertical-align: middle; }
.current-swatch { background: var(--qu-burgundy); }
.comparison-swatch { background: var(--qu-gold); }
table { width: 100%; margin: 1rem 0 1.4rem; }
thead { background: var(--qu-burgundy); color: white; }

/* Distribution summary tables: keep column headings visible and readable. */
#summary-of-discrete-distributions table,
#summary-of-continuous-distributions table {
  display: table;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
}
#summary-of-discrete-distributions thead,
#summary-of-continuous-distributions thead {
  display: table-header-group !important;
  background: var(--qu-burgundy) !important;
}
#summary-of-discrete-distributions thead th,
#summary-of-continuous-distributions thead th {
  display: table-cell !important;
  color: #fff !important;
  background: var(--qu-burgundy) !important;
  font-weight: 800;
  text-align: center !important;
  vertical-align: middle;
  padding: .75rem .65rem;
  white-space: nowrap;
  border-bottom: 3px solid #d4af37;
}
#summary-of-discrete-distributions tbody td,
#summary-of-continuous-distributions tbody td {
  vertical-align: middle;
  padding: .65rem;
}
th, td { padding: .55rem .7rem !important; }
tbody tr:nth-child(even) { background: #f7f8fa; }

/* Welcome-page assessment tables */
#assessment-and-grade-distribution table {
  display: table;
  width: 100%;
  margin: 1rem 0 2rem;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid #d8dde4;
  border-radius: 10px;
  background: white;
  box-shadow: 0 6px 18px rgba(31,41,51,.08);
}
#assessment-and-grade-distribution thead th {
  padding: .8rem .9rem !important;
  border: 0;
  background: linear-gradient(135deg, var(--qu-burgundy), var(--qu-burgundy-dark));
  color: white;
  font-size: .94rem;
  letter-spacing: .015em;
  vertical-align: middle;
}
#assessment-and-grade-distribution tbody td {
  padding: .72rem .9rem !important;
  border-top: 1px solid #e7eaee;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  vertical-align: middle;
}
#assessment-and-grade-distribution tbody tr:nth-child(odd) { background: #fff; }
#assessment-and-grade-distribution tbody tr:nth-child(even) { background: #faf6f7; }
#assessment-and-grade-distribution tbody tr:hover { background: #f4e7ec; }
#assessment-and-grade-distribution table:first-of-type tbody tr:last-child {
  background: #fff3cf;
  color: #6b5200;
  font-weight: 800;
}
#assessment-and-grade-distribution table:first-of-type th:nth-child(2),
#assessment-and-grade-distribution table:first-of-type td:nth-child(2) {
  width: 6.5rem;
  text-align: center !important;
  white-space: nowrap;
  font-weight: 750;
}
#assessment-and-grade-distribution table:nth-of-type(2) th,
#assessment-and-grade-distribution table:nth-of-type(2) td {
  text-align: center !important;
}
#assessment-and-grade-distribution table:nth-of-type(2) tbody tr:first-child {
  background: #eaf7ef;
  color: #17633b;
  font-weight: 800;
}
#assessment-and-grade-distribution table:nth-of-type(2) tbody tr:last-child {
  background: #fff1f0;
  color: #9f2d24;
  font-weight: 800;
}
.figure { margin: 1.4rem auto; text-align: center; }
.figure img { border-radius: 6px; }
.caption { color: var(--muted); font-size: .9rem; }

@media (max-width: 700px) {
  .book .book-body .page-wrapper .page-inner { padding: 1.2rem 1.1rem 3rem; }
  .hero { padding: 1rem; }
  .welcome-info-grid { grid-template-columns: 1fr; }
  .welcome-info-card { padding: 1.15rem; }
  .welcome-info-card h2 { white-space: normal; }
  .welcome-info-list > div, .instructor-info-card .welcome-info-list > div { grid-template-columns: 1fr; gap: .08rem; }
  #assessment-and-grade-distribution { overflow-x: auto; }
  #assessment-and-grade-distribution table { min-width: 620px; font-size: .9rem; }
  .dual-chart { grid-template-columns: 1fr; }
}
.venn-concepts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1.1rem 0 1.4rem;
}

.venn-card {
  background: #fff;
  border: 1px solid #ead5dc;
  border-radius: 10px;
  padding: 0.55rem;
  text-align: center;
  overflow: hidden;
}

.venn-card svg { width: 100%; height: auto; display: block; }
.venn-card strong, .venn-card span { display: block; white-space: normal; }
.venn-card strong { color: #70132f; font-size: 1.12em; line-height: 1.25; }
.venn-card span { color: #59636d; font-size: 0.9em; line-height: 1.35; margin: 0.2rem 0 0.35rem; }
.venn-universe { fill: #faf7f8; stroke: #9aa2a9; stroke-width: 1.5; }
.venn-fill, .venn-intersection, .venn-complement { fill: #8a1538; fill-opacity: 0.7; }
.venn-cutout { fill: #fff; }
.venn-outline { fill: none; stroke: #5d172c; stroke-width: 2.4; }
.venn-card text { fill: #24282d; font: 700 16px sans-serif; }
.venn-card .venn-s-label { fill: #fff; font-size: 13px; }

@media (max-width: 720px) {
  .venn-concepts { grid-template-columns: 1fr; }
}

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

.demorgan-card {
  border: 1px solid #ead5dc;
  border-radius: 10px;
  padding: 0.55rem;
  text-align: center;
  background: #fff;
}

.demorgan-card svg { display: block; width: 100%; height: auto; }
.demorgan-card strong, .demorgan-card span { display: block; }
.demorgan-card strong { color: #70132f; font-size: 1.05em; }
.demorgan-card span { color: #59636d; font-size: 0.9em; margin-top: 0.25rem; }
.demorgan-card text { fill: #24282d; font: 700 16px sans-serif; }

@media (max-width: 720px) {
  .demorgan-grid { grid-template-columns: 1fr; }
}
.probability-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0 1.35rem;
  border: 1px solid #d8b8c3;
  border-radius: 9px;
  overflow: hidden;
}

.probability-table thead th {
  background: #8a1538 !important;
  color: #fff !important;
  font-weight: 700;
  text-align: center;
  padding: 0.65rem 0.8rem;
}

.probability-table tbody th,
.probability-table tbody td {
  padding: 0.6rem 0.8rem;
  border-top: 1px solid #ead5dc;
}

.probability-table tbody th { text-align: left; color: #541126; }
.probability-table tbody td { text-align: center; }
.probability-table .total-row { background: #f8edf1; font-weight: 700; }

/* Joint-distribution tables use a body header row because the GitBook theme
   suppresses the visual background of ordinary thead elements. */
.joint-probability-table .joint-table-header th {
  display: table-cell !important;
  background: #8a1538 !important;
  color: #fff !important;
  font-weight: 800 !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding: .72rem .8rem !important;
  border-top: 0 !important;
  border-bottom: 3px solid #d4af37 !important;
  white-space: normal;
}
.book .book-summary ul.summary li.course-profile {
  margin-top: 8px;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.course-profile img {
  width: 92px;
  height: 110px;
  object-fit: cover;
  object-position: center 23%;
  border-radius: 7px;
  border: 2px solid #fff;
  box-shadow: 0 3px 14px rgba(84, 17, 38, 0.18);
}

.course-profile-name {
  margin-top: 0;
  color: #541126;
  font-weight: 750;
  font-size: 1.38rem;
  line-height: 1.3;
  text-align: left;
}

.book .book-summary ul.summary li.course-profile a.course-profile-website {
  display: block;
  padding: 3px 0 10px;
  color: #687383;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.book .book-summary ul.summary li.course-profile a.course-profile-about {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid #b88a99;
  background: #fff;
  color: #70132f;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.book .book-summary ul.summary li.course-profile a.course-profile-about:hover {
  background: #8a1538;
  border-color: #8a1538;
  color: #fff;
}
/* Expandable chapter navigation ----------------------------------------- */
.book .book-summary ul.summary > li.chapter.sidebar-parent {
  position: relative;
}

.book .book-summary ul.summary > li.chapter.sidebar-parent > a {
  padding-right: 3rem;
}

.book .book-summary .sidebar-chapter-toggle {
  position: absolute;
  top: 0.32rem;
  right: 0.55rem;
  z-index: 3;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  color: #7b1534;
  background: transparent;
  font-size: 1.25rem;
  line-height: 2rem;
  text-align: center;
  cursor: pointer;
}

.book .book-summary .sidebar-chapter-toggle:hover,
.book .book-summary .sidebar-chapter-toggle:focus-visible {
  color: #ffffff;
  background: #7b1534;
  outline: none;
}

.book .book-summary .sidebar-chapter-toggle::before {
  display: inline-block;
  content: "\25B6";
  transition: transform 160ms ease;
}

.book .book-summary ul.summary > li.chapter.sidebar-parent.sidebar-open >
  .sidebar-chapter-toggle::before {
  transform: rotate(90deg);
}

.book .book-summary ul.summary > li.chapter.sidebar-parent > ul {
  display: none !important;
}

.book .book-summary ul.summary > li.chapter.sidebar-parent.sidebar-open > ul {
  display: block !important;
}
