:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #fff;
  --surface2: #f0f5fb;
  --text: #172c48;
  --muted: #5d6d80;
  --line: #dce4ed;
  --accent: #235db0;
  --accent2: #194a93;
  --header: #fff;
  --hero: #eaf1f9;
  --plot: #fff;
  --grid: #dbe5f0;
  --blue: #2868c9;
  --orange: #c77a21;
  --shadow: 0 14px 40px rgba(24, 51, 85, .06);
  --course-content-width: 1244px;
  --course-page-gutter: 38px;
  --course-font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1727;
  --surface: #14253a;
  --surface2: #1b3048;
  --text: #e5effa;
  --muted: #b2c2d4;
  --line: #344a60;
  --accent: #8dbbff;
  --accent2: #a7cbff;
  --header: #101f31;
  --hero: #11253c;
  --plot: #112238;
  --grid: #395069;
  --blue: #79b2ff;
  --orange: #ffbd6b;
  --shadow: 0 14px 40px rgba(0, 0, 0, .14);
}

.site-header {
  background: var(--header);
  border-bottom: 1px solid var(--line);
}

.course-header {
  display: flex;
  align-items: center;
  gap: 25px;
  max-width: 1320px;
  height: 76px;
  margin-inline: auto;
  padding-inline: var(--course-page-gutter);
  font: 17px/1.75 var(--course-font);
}

.course-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
}

.course-mark {
  width: 52px;
  height: auto;
  flex: none;
}

.course-header .brand strong {
  display: block;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: .025em;
}

.course-header .brand small {
  display: block;
  margin-top: 5px;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 400;
}

.course-header .theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-inline-start: auto;
  padding: 5px 10px;
  border: 1px solid var(--accent2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.75 var(--course-font);
  white-space: nowrap;
}

.course-header .theme-toggle:hover {
  background: var(--surface2);
}

.course-theme-icon {
  font-size: 22px;
  line-height: 1;
}

.case-page-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
}

.case-page-topbar .breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.case-page-topbar .breadcrumb span {
  padding: 0;
  color: var(--muted);
}

.case-page-topbar .breadcrumb span[aria-hidden] {
  color: var(--line);
}

.case-page-topbar .breadcrumb a,
.case-page-topbar .quiet-link,
.course-page-end a {
  color: var(--accent);
}

.case-page-topbar .quiet-link {
  font-size: 15px;
  white-space: nowrap;
}

html.has-course-masthead {
  scroll-padding-top: 148px;
}

html.has-course-masthead.course-short-masthead {
  scroll-padding-top: 92px;
}

.has-course-masthead .course-masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.course-detail-topbar {
  align-items: center;
  min-height: 54px;
  width: min(var(--course-content-width), calc(100% - 2 * var(--course-page-gutter)));
  margin-inline: auto;
  padding-block: 6px;
}

.course-detail-topbar[hidden] {
  display: none;
}

.course-detail-topbar .breadcrumb {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.course-detail-topbar [aria-current="page"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.course-directory {
  position: relative;
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.course-directory > summary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent2);
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.course-directory > summary::-webkit-details-marker {
  display: none;
}

.course-directory > summary::marker {
  content: "";
}

:is(.course-directory, .course-directory[open]) > summary::after {
  content: none;
}

.course-directory > summary:hover,
.course-directory nav a:hover,
.course-directory nav a[aria-current="location"] {
  background: var(--surface2);
  color: var(--accent2);
}

.toc-icon {
  font-size: 1.12rem;
  line-height: 1;
}

.toc-chevron {
  width: 7px;
  height: 7px;
  margin-left: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.course-directory[open] .toc-chevron {
  transform: translateY(2px) rotate(225deg);
}

.course-directory nav {
  position: absolute;
  inset: calc(100% + 8px) 0 auto auto;
  width: min(340px, calc(100vw - 40px));
  max-height: calc(100vh - 154px);
  max-height: calc(100dvh - 154px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 10px 32px #173b6026;
}

.course-directory:not([open]) nav {
  display: none;
}

.course-directory nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 5px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.course-directory nav a + a {
  margin-top: 2px;
}

.course-directory nav a[aria-current="location"] {
  font-weight: 650;
}

.case-page-topbar a:hover,
.course-page-end a:hover,
.course-contact a:hover {
  text-decoration: underline;
  text-underline-offset: .2em;
}

.course-page-end {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font: 13px/1.75 var(--course-font);
}

.course-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 20px;
  width: min(var(--course-content-width), calc(100% - 2 * var(--course-page-gutter)));
  margin-inline: auto;
  padding: 12px 0 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 14px/1.75 var(--course-font);
  text-align: center;
}

.course-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.course-contact a {
  color: var(--accent2);
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  :root {
    --course-page-gutter: 20px;
  }

  .course-header {
    height: auto;
    min-height: 70px;
    padding-block: 15px;
    gap: 10px;
  }

  .course-header .brand {
    gap: 6px;
  }

  .course-mark {
    width: 37px;
  }

  .course-header .brand strong {
    font-size: 17px;
  }

  .course-header .brand small {
    font-size: 9px;
  }

  .course-header .theme-toggle {
    padding: 5px 7px;
    font-size: 12px;
  }

  .course-theme-icon {
    font-size: 17px;
  }

  .course-page-end {
    flex-direction: column;
  }
}

@media (max-width: 650px) {
  .case-page-topbar .quiet-link {
    font-size: 13px;
  }
}

@media (max-width: 620px) {
  html.has-course-masthead {
    scroll-padding-top: 170px;
  }

  .course-detail-topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .course-detail-topbar .breadcrumb {
    font-size: 13px;
  }

  .course-topbar-actions {
    gap: 12px;
  }

  .course-directory > summary {
    min-height: 38px;
    padding: 6px 10px;
    gap: 7px;
    font-size: .84rem;
  }

  .course-directory nav {
    max-height: calc(100vh - 176px);
    max-height: calc(100dvh - 176px);
  }
}

@media print {
  .course-directory {
    display: none;
  }
}
