/* Shared reading furniture. Diagrams keep their own styles and scroll locally. */
:root { --book-muted: #686254; --book-border: #ddd6c4; }
.book-page { margin: 0; }
.book-page *, .book-page *::before, .book-page *::after { box-sizing: border-box; }
.book-page :is(p, li, h1, h2, h3, a, span) { overflow-wrap: anywhere; }
.book-page :is(pre, pre *, .book-scroll *) { overflow-wrap: normal; }
.book-page img { max-width: 100%; height: auto; }
.book-page :is(button, input, select, summary) { touch-action: manipulation; }
.book-page :is(button, input, select, summary, a):focus-visible,
.book-page [tabindex="0"]:focus-visible { outline: 3px solid #2b4a7a; outline-offset: 3px; }
.book-page [tabindex="-1"]:focus { outline: none; }
.book-dark { --book-muted: #c1bba9; }
.book-dark :is(a, button):focus-visible { outline-color: #f4f1e9; }
.book-skip { position: fixed; z-index: 100; top: 8px; left: 12px; transform: translateY(-160%); padding: 12px 18px; background: #22201a; color: #fff !important; border-radius: 4px; }
.book-skip:focus { transform: none; }
.book-toolbar { height: 61px; }
/* The framework host has viewport height with overflowing content, so sticky
   would stop at its lower edge. Reserve space here and fix the bar itself. */
.book-toolbar-fixed { position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: #f4f1e9; border-bottom: 1px solid var(--book-border); }
.book-toolbar-inner { max-width: 1180px; height: 60px; padding: 0 40px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; font: 500 14px/1.25 'IBM Plex Sans', sans-serif; }
.book-toolbar a { border: none; }
.book-brand { color: #22201a; font-weight: 600; }
.book-course-button, .book-course-close { display: inline-flex; align-items: center; justify-content: center; gap: 9px; flex: none; min-height: 44px; padding: 8px 12px; border: 1px solid #bcb3a0; border-radius: 4px; background: transparent; color: #22201a; font: 600 14px/1.25 'IBM Plex Sans', sans-serif; cursor: pointer; }
.book-course-button:hover, .book-course-close:hover { background: #eae4d6; }
.book-course-open { overflow: hidden; }
.book-course-dialog { width: min(460px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 24px; border: none; border-left: 1px solid var(--book-border); background: #f4f1e9; color: #22201a; font: 15px/1.45 'IBM Plex Sans', sans-serif; overflow-y: auto; overscroll-behavior: contain; }
.book-course-dialog::backdrop { background: #22201a66; }
.book-course-dialog[open] { display: flex; flex-direction: column; }
.book-course-dialog > nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; margin: -4px; }
.book-course-heading { display: flex; flex: none; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.book-course-heading h2 { margin: 0; font: 700 26px/1.2 Spectral, serif; }
.book-course-heading p { margin: 6px 0 0; font-size: 13px; color: var(--book-muted); }
.book-course-dialog h3 { margin: 22px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--book-muted); }
.book-course-dialog ol { margin: 0; padding: 0; list-style: none; }
.book-course-dialog a { display: flex; align-items: baseline; gap: 10px; min-height: 44px; padding: 10px; border: none; border-radius: 4px; color: #2b4a7a; text-decoration: none; }
.book-course-dialog a:hover { background: #eae4d6; }
.book-course-dialog a[aria-current="page"] { background: #dfe5ef; color: #203b64; font-weight: 600; }
.book-course-tag { flex: 0 0 25px; font: 500 12px/1.5 'IBM Plex Mono', monospace; color: var(--book-muted); }
.book-course-label { flex: 1; min-width: 0; }
.book-course-current { flex: none; font-size: 11px; }
.book-course-utilities { padding-bottom: 12px; border-bottom: 1px solid var(--book-border); }
.book-header { max-width: 1180px; margin: 0 auto; padding: 44px 40px 40px; }
.book-breadcrumbs { margin: 0 0 12px; color: var(--book-muted); font: 500 14px/1.5 'IBM Plex Sans', sans-serif; }
.book-breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 0; padding: 0; list-style: none; }
.book-breadcrumbs li { display: flex; align-items: baseline; gap: 10px; min-width: 0; max-width: 100%; }
.book-breadcrumbs a, .book-breadcrumbs [aria-current="page"] { padding: 4px 0; }
.book-breadcrumbs [aria-current="page"] { color: #534b3c; }
.book-breadcrumb-separator { flex: none; }
.lecture-layout { max-width: 1180px; margin: 0 auto; padding: 0 40px 120px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 56px; align-items: start; }
.book-main { min-width: 0; width: 100%; max-width: 720px; }
.book-main :is(div, section, details, figure), .course-content :is(div, section) { min-width: 0; }
.book-main pre { max-width: 100%; overflow: auto; }
.book-sidebar { position: sticky; top: 84px; max-height: calc(100dvh - 108px); overflow: auto; padding: 6px 4px 4px; }
.book-toc > summary { padding: 10px 14px; font: 600 13px 'IBM Plex Sans', sans-serif; color: #534b3c; cursor: pointer; }
.book-toc-links { display: flex; flex-direction: column; gap: 2px; }
.book-toc-links a { min-height: 36px; }
.book-toc-links a[aria-current="location"] { border-left-color: #2b4a7a; }
.book-progress-panel { margin-top: 24px; padding: 14px; background: #efe9da; border: 1px solid #e2dbc8; border-radius: 2px; font-size: 12.5px; line-height: 1.55; color: #6b6656; }
.book-progress-bar { position: fixed; top: 0; left: 0; height: 3px; z-index: 70; transition: width .1s linear; }
.book-page [data-sec], .book-page #main-content { scroll-margin-top: 84px; }
.book-section-heading { display: flex; align-items: baseline; gap: 12px; }
.book-section-heading > h2 { flex: 1; min-width: 0; }
.section-copy { flex: none; background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 4px; padding: 6px 8px; font: 500 12px/1.4 'IBM Plex Sans', sans-serif; cursor: pointer; }
.section-copy:hover { background: #8a6d3b18; }
.book-scroll { max-width: 100%; overflow: auto; overscroll-behavior-x: contain; }
.book-scroll > .book-diagram { min-width: 580px; }
.step-tabs { display: flex; flex-wrap: wrap; }
.step-tabs button { min-width: 100px; }
.book-actions { flex-wrap: wrap; }
.book-page button { max-width: 100%; }
.results-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.results-table th, .results-table td { padding: 10px; border-bottom: 1px solid #e2dbc8; text-align: left; }
.results-table th { color: #6b6656; font-weight: 600; }
.course-header { max-width: 960px; margin: 0 auto; padding: 44px 40px 20px; }
.course-content { max-width: 960px; margin: 0 auto; padding: 24px 40px 120px; }
.course-chapters { display: flex; flex-direction: column; gap: 10px; }
.course-part { margin: 18px 0 2px; font: 700 20px/1.3 Spectral, serif; }
.course-card { border: 1px solid var(--book-border); border-radius: 5px; background: #fff; }
.course-card-overview { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: start; gap: 14px; padding: 16px; }
.course-card-tag { display: flex; align-items: center; justify-content: center; height: 38px; border-radius: 4px; background: #f0ede2; color: #795e30; font: 600 14px 'IBM Plex Mono', monospace; }
.course-card-heading { margin: 0; font: 700 20px/1.25 Spectral, serif; }
.course-card-heading a { border: none; color: #22201a; }
.course-card-meta { margin: 5px 0 0; color: var(--book-muted); font-size: 13.5px; line-height: 1.5; }
.course-card-actions { display: flex; flex-direction: column; align-items: start; gap: 2px; }
.course-card-actions a, .course-card-actions button { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 6px 8px; font: 600 13px/1.4 'IBM Plex Sans', sans-serif; }
.course-card-actions a { border: none; }
.course-card-actions button { background: transparent; border: 1px solid var(--book-border); border-radius: 4px; color: #534b3c; cursor: pointer; }
.course-card-actions button:hover { background: #f4f1e9; }
.course-panel { border-top: 1px solid #ece6d6; padding: 16px; }
.course-topics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.course-panel[hidden] { display: none !important; }
.self-test { max-width: 820px; margin: 0 auto; padding: 56px 32px 100px; }
.book-status { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 5px; background: #22201a; color: #fff; font: 15px/1.5 'IBM Plex Sans', sans-serif; box-shadow: 0 2px 8px #0003; }
.book-status:empty { display: none; }
.book-copy-dialog { width: min(520px, calc(100% - 32px)); padding: 24px; border: 1px solid #8a6d3b; border-radius: 6px; background: #f4f1e9; color: #22201a; font: 16px/1.5 'IBM Plex Sans', sans-serif; }
.book-copy-dialog::backdrop { background: #0006; }
.book-copy-dialog input { display: block; width: 100%; margin: 12px 0; padding: 10px; font: 14px monospace; }
.book-copy-dialog button { padding: 10px 18px; }
@media (max-width: 860px) {
  .book-toolbar-inner { padding: 0 20px; gap: 10px; }
  .book-header { padding: 40px 20px 28px; }
  .lecture-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 0 20px 64px; }
  .book-main { max-width: none; }
  .book-sidebar { top: 68px; z-index: 40; max-height: calc(100dvh - 84px); padding: 0; background: #f4f1e9; border: 1px solid #d5cdbb; border-radius: 5px; box-shadow: 0 2px 5px #0001; }
  .book-toc > summary { min-height: 44px; padding: 12px 14px; }
  .book-toc-links { max-height: 60vh; overflow: auto; padding: 0 6px 8px; }
  .book-toc-links a { min-height: 44px; }
  .book-progress-panel { display: none; }
  .book-page [data-sec], .book-page #main-content { scroll-margin-top: 132px; }
  .course-header { padding: 40px 20px 20px; }
  .course-content { padding: 24px 20px 64px; }
  .self-test { padding: 40px 20px 64px; }
}
@media (min-width: 861px) {
  .book-toc > summary { list-style: none; cursor: default; pointer-events: none; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }
  .book-toc > summary::-webkit-details-marker { display: none; }
}
@media (max-width: 560px) {
  .book-course-dialog { padding: 20px; }
  .course-card-overview { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 14px; }
  .course-card-actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
  .course-card-actions a, .course-card-actions button { min-height: 44px; }
  .book-columns, .paired, .course-topics { grid-template-columns: minmax(0, 1fr) !important; }
  .chapter-banner, .chapter-summary { padding: 24px 20px !important; }
  .book-section-heading { flex-wrap: wrap; gap: 0 12px; }
  .book-section-heading > h2 { flex-basis: 100%; margin-bottom: 10px !important; }
  .section-copy { margin-bottom: 18px; min-height: 36px; }
  .results-table th, .results-table td { padding: 8px 5px; }
  .book-page :is(input, select) { max-width: 100%; font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  .book-page *, .book-page *::before, .book-page *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
