/* The top bar: slim, and always within reach. */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 40; height: var(--bar-h);
  display: flex; align-items: center; gap: .25rem; padding: 0 max(.35rem, env(safe-area-inset-right)) 0 max(.35rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule); font-family: var(--sans); font-size: .875rem;
}
.bar a, .bar button { color: var(--ink); text-decoration: none; background: none; border: 0; }
.bar-btn { display: inline-flex; align-items: center; gap: .4em; min-height: 2.75rem; min-width: 2.75rem; justify-content: center; padding: 0 .5rem; border-radius: var(--radius); font-weight: 500; }
.bar-btn:hover { background: var(--paper-sunk); }
.bar-title { flex: 1 1 auto; min-width: 0; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 .25rem; font-size: .8125rem; }
@media (max-width: 30rem) { .bar-title.book { visibility: hidden; } }
.reading-progress { position: fixed; top: var(--bar-h); left: 0; right: 0; height: 2px; z-index: 41; background: var(--accent); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.toc-book { display: block; font-family: var(--sans); font-size: .875rem; color: var(--ink-2); text-decoration: none; margin-bottom: .4rem; }
.toc-book:hover { color: var(--accent); }
.bar-label { display: none; }
@media (min-width: 48rem) { .bar-label { display: inline; } .bar-title { font-size: .875rem; } }
.lang-switch { display: flex; align-items: center; flex: none; }
.lang-switch button { min-height: 2.75rem; padding: 0 .36rem; font-size: .8125rem; color: var(--ink-2); border-radius: var(--radius); position: relative; }
.lang-switch button:hover { color: var(--ink); background: var(--paper-sunk); }
.lang-switch button[aria-current="true"] { color: var(--ink); font-weight: 650; }
.lang-switch button[aria-current="true"]::after { content: ""; position: absolute; left: .36rem; right: .36rem; bottom: .5rem; height: 2px; background: var(--accent); }
@media (min-width: 30rem) { .lang-switch button { padding: 0 .55rem; font-size: .875rem; } .lang-switch button[aria-current="true"]::after { left: .55rem; right: .55rem; } }

.skip { position: fixed; top: .4rem; left: .4rem; z-index: 60; background: var(--ink); color: var(--paper); padding: .5rem .9rem; border-radius: var(--radius); font-family: var(--sans); transform: translateY(-300%); }
.skip:focus { transform: none; }

.main { padding-top: var(--bar-h); min-height: 100svh; }
.main:focus { outline: none; }
h1:focus, h2:focus { outline: none; }

.toast { position: fixed; bottom: max(1rem, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 50; width: max-content; max-width: calc(100vw - 2rem); background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: .875rem; padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); }

/* A page is a single reading column, with room for margins on wide screens. */
.page { padding: 0 var(--gutter); overflow-x: clip; }
.col { max-width: var(--column); margin-inline: auto; }
.wide { max-width: var(--bench-width); margin-inline: auto; }

/* Cover */
.cover { min-height: calc(100svh - var(--bar-h)); display: flex; flex-direction: column; justify-content: center; padding: 2rem var(--gutter) 3rem; }
.cover-in { width: 100%; max-width: 46rem; margin-inline: auto; }
.cover-tiles { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 2.2rem; font-size: .95rem; }
.cover-tiles .tile { padding: .3em .55em; border-radius: .3em; }
.cover h1 { font-size: clamp(2.75rem, 11vw, 5.4rem); line-height: 1.02; letter-spacing: -.018em; font-weight: 650; margin-bottom: .35em; }
.cover .sub { font-size: clamp(1.15rem, 3vw, 1.45rem); line-height: 1.35; color: var(--ink-2); margin-bottom: 1.2em; text-wrap: pretty; }
.cover .blurb { max-width: 34em; margin-bottom: 1.6em; }
.cover .quiet-progress { font-family: var(--sans); font-size: .875rem; color: var(--ink-2); margin: .9rem 0 0; }
.cover-links { font-family: var(--sans); font-size: .9375rem; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-top: 2.4rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

/* Quiet progress mark */
.progress-tiles { display: flex; flex-wrap: wrap; gap: 3px; margin: 1.4rem 0 0; }
.progress-tiles span { width: .72rem; height: .72rem; border-radius: 2px; background: var(--paper-sunk); border: 1px solid var(--rule); }
.progress-tiles span.on { background: var(--accent); border-color: var(--accent); }

/* Table of contents, set like a real book's. */
.toc { padding: 3rem var(--gutter) 5rem; }
.toc h1 { font-size: clamp(2rem, 7vw, 3rem); margin-bottom: .3em; }
.toc-part { margin-top: 2.6rem; }
.toc-part h2 { font-size: 1.25rem; font-weight: 650; }
.toc-part h2 a { text-decoration: none; }
.toc-part .part-no { display: block; font-family: var(--sans); font-size: .75rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: .25rem; }
.toc-list { list-style: none; padding: 0; margin: .6rem 0 0; border-top: 1px solid var(--rule); }
.toc-item a { display: grid; grid-template-columns: 1.9rem minmax(0, 1fr) auto; gap: .1rem .4rem; padding: .62rem 0; text-decoration: none; border-bottom: 1px solid var(--rule); align-items: baseline; }
.toc-item a:hover .toc-title { color: var(--accent); }
.toc-no { font-family: var(--sans); font-size: .875rem; color: var(--ink-3); font-variant-numeric: lining-nums tabular-nums; }
.toc-title { font-weight: 550; line-height: 1.3; transition: color .15s; }
.toc-sub { grid-column: 2; font-size: .9rem; line-height: 1.35; color: var(--ink-2); }
.toc-meta { grid-row: 1; grid-column: 3; font-family: var(--sans); font-size: .8125rem; color: var(--ink-3); white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; }
.toc-mark { width: .7rem; height: .7rem; border-radius: 2px; background: var(--accent); display: inline-block; }
.toc-back { list-style: none; padding: 0; margin: 2.6rem 0 0; font-family: var(--sans); border-top: 1px solid var(--rule-strong); }
.toc-back a { display: block; padding: .7rem 0; border-bottom: 1px solid var(--rule); text-decoration: none; font-weight: 550; }

/* Part openers */
.part-open { padding: 2.2rem var(--gutter) 4rem; }
@media (min-width: 48rem) { .part-open { padding-top: 5rem; } }
.part-in { width: 100%; max-width: 44rem; margin-inline: auto; }
.part-tiles { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1.6rem; }
.part-tiles i { width: 1.9rem; height: 1.9rem; border-radius: .3rem; background: var(--accent-tint); display: block; }
.part-tiles i.on { background: var(--accent); }
.part-label { font-family: var(--sans); font-size: .8125rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: .45rem; }
.part-open h1 { font-size: clamp(2.25rem, 8.5vw, 4rem); line-height: 1.06; letter-spacing: -.012em; margin-bottom: .6em; }
.part-lessons { list-style: none; margin: 0 0 1.8rem; padding: 0; }
.part-lessons a { display: flex; gap: .7rem; padding: .36rem 0; text-decoration: none; align-items: baseline; line-height: 1.3; }
.part-lessons a:hover { color: var(--accent); }
.part-lessons .toc-no { flex: none; width: 1.4rem; }

/* Lesson opener: the hook stands on its own. */
.opener { padding: 2.1rem 0 1.5rem; }
@media (min-width: 48rem) { .opener { padding: 4rem 0 2rem; } }
.part-strip { display: flex; gap: 3px; margin-bottom: .7rem; }
.part-strip i { width: 1.05rem; height: .42rem; border-radius: 1px; background: var(--accent-tint); }
.part-strip i.on { background: color-mix(in srgb, var(--accent) 55%, var(--accent-tint)); }
.part-strip i.now { background: var(--accent); }
.lesson-meta { font-family: var(--sans); font-size: .8125rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: .1rem .6rem; margin-bottom: 1.2rem; }
.lesson-meta b { color: var(--accent); font-weight: 650; }
.lesson-meta a { text-decoration: none; }
.lesson-meta a:hover { text-decoration: underline; }
.opener h1 { font-size: clamp(2.15rem, 7.6vw, 3.5rem); line-height: 1.06; letter-spacing: -.012em; font-weight: 650; margin-bottom: .3em; }
.opener .subtitle { font-size: clamp(1.0625rem, 2.6vw, 1.25rem); font-style: italic; color: var(--ink-2); line-height: 1.35; margin-bottom: 1.7em; text-wrap: pretty; }
.hook { font-size: clamp(1.1875rem, 3.2vw, 1.4375rem); line-height: 1.5; margin: 0; text-wrap: pretty; }
.hook::first-letter { float: left; font-size: 3.05em; line-height: .86; font-weight: 650; color: var(--accent); padding: .05em .05em 0 0; }
.done-mark { font-family: var(--sans); font-size: .8125rem; color: var(--good); font-weight: 600; display: inline-flex; gap: .3em; align-items: center; }

.objectives { font-family: var(--sans); font-size: .9375rem; line-height: 1.45; margin: 0 0 2.2rem; border-bottom: 1px solid var(--rule); }
.objectives summary { font-weight: 600; font-size: .875rem; color: var(--ink-2); min-height: 2.75rem; display: flex; align-items: center; gap: .45rem; cursor: pointer; list-style: none; }
.objectives summary::-webkit-details-marker { display: none; }
.objectives summary::before { content: ""; width: .45em; height: .45em; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.objectives[open] summary::before { transform: rotate(45deg); }
.read .objectives ul, .objectives ul { margin: 0 0 .8rem; padding: 0; list-style: none; }
.read .objectives li, .objectives li { padding-left: 1.25em; position: relative; margin: .32em 0; }
.objectives li::before { content: ""; position: absolute; left: 0; top: .42em; width: .55em; height: .55em; border-radius: 2px; background: var(--accent-tint); border: 1px solid var(--accent); }

/* Reading */
.read h3 { font-size: 1.3125rem; margin: 2em 0 .55em; font-weight: 650; }
.read > :first-child { margin-top: 0; }
.read ul, .read ol, .prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.read ol { padding-left: 1.65em; }
.read li, .prose li { margin: .38em 0; padding-left: .15em; }
.read li::marker { color: var(--accent); }
.read ol li::marker { font-family: var(--sans); font-size: .9em; font-weight: 600; }
.plain-quote { margin: 1.2em 0; padding: .3em 0 .3em 1em; border-left: 3px solid var(--accent); font-style: italic; }
.plain-quote p:last-child { margin-bottom: 0; }

.callout { font-size: .96em; background: var(--paper-sunk); border-left: 3px solid var(--accent); padding: .8rem 1rem; margin: 1.5em 0; border-radius: 0 var(--radius) var(--radius) 0; }
.callout-label { display: block; font-family: var(--sans); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .3rem; }
.callout p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 1.3em 0 1.5em; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
.table-wrap table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .875rem; line-height: 1.38; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: .55em .7em .55em 0; border-bottom: 1px solid var(--rule); overflow-wrap: break-word; }
.table-wrap thead th { font-weight: 650; border-bottom: 1px solid var(--rule-strong); font-size: .8125rem; }
.table-wrap tr:last-child td { border-bottom: 0; }
@media (max-width: 30rem) { .table-wrap th, .table-wrap td { padding-right: .5em; } }

.code { font-family: var(--mono); font-size: .8125rem; line-height: 1.5; background: var(--term-bg); color: var(--term-ink); padding: .75rem .9rem; border-radius: var(--radius); margin: 1em 0 1.3em; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Terms: a dotted rule, tap to read. In the margin on wide screens. */
.term-btn { color: inherit; text-decoration: underline dotted var(--accent) 1.5px; text-underline-offset: .22em; cursor: pointer; }
.term-btn:hover { background: var(--accent-tint); color: var(--t-ink); border-radius: 2px; }
.sidenote { display: none; }
@media (min-width: 75rem) {
  .has-margin .sidenote {
    display: block; float: right; clear: right; width: 15rem; margin-right: -17rem; margin-top: .3em; margin-bottom: .9rem;
    font-family: var(--sans); font-size: .8125rem; line-height: 1.42; color: var(--ink-2); font-weight: 400; font-style: normal;
    padding-left: .7rem; border-left: 2px solid var(--accent-tint); text-align: left; transition: border-color .2s, color .2s;
  }
  .has-margin .sidenote b { color: var(--ink); font-weight: 650; display: block; }
  .has-margin .sidenote.lit { border-left-color: var(--accent); color: var(--ink); }
  .has-margin .read h3 { clear: right; }
  .has-margin .bench-section, .has-margin .lesson-end { clear: both; }
  .objectives.in-margin { float: left; clear: left; width: 14rem; margin: 0 0 1rem -16.5rem; border-bottom: 0; font-size: .8125rem; color: var(--ink-2); }
  .objectives.in-margin summary { min-height: 0; margin-bottom: .4rem; pointer-events: none; color: var(--accent); }
  .objectives.in-margin summary::before { display: none; }
}
.sheet-back { position: fixed; inset: 0; z-index: 70; background: rgb(20 15 8 / 45%); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 34rem; background: var(--paper-raised); color: var(--ink); padding: 1.1rem 1.1rem max(1.1rem, env(safe-area-inset-bottom)); border-radius: .9rem .9rem 0 0; box-shadow: var(--shadow); font-family: var(--serif); border-top: 3px solid var(--accent); animation: sheet-up .22s var(--ease); }
.sheet h2 { font-size: 1.2rem; margin-bottom: .35rem; }
.sheet p { margin: 0 0 .8rem; line-height: 1.45; }
@keyframes sheet-up { from { transform: translateY(30%); opacity: 0; } }

/* Section headings outside Read */
.sec-head { font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; font-weight: 650; color: var(--ink); margin: 0 0 .8rem; display: flex; align-items: center; gap: .5rem; text-wrap: balance; }
.sec-head::before { content: ""; width: .62em; height: .62em; flex: none; border-radius: 2px; background: var(--accent); }
.section { margin-top: 3rem; }
.lab-lead { max-width: var(--column); }
.lab-lead p:last-child { margin-bottom: 0; }

/* The workbench: a cutting mat, so that you can tell at a glance you've gone from reading to doing. */
.bench-section {
  margin: 3rem calc(50% - 50vw) 0; padding: 2rem var(--gutter) 2.2rem;
  background-color: var(--bench);
  background-image: linear-gradient(var(--bench-line) 1px, transparent 1px), linear-gradient(90deg, var(--bench-line) 1px, transparent 1px);
  background-size: 24px 24px;
  border-block: 1px solid var(--rule-strong);
}
.bench-section > .sec-head, .bench-section > .lab-lead, .bench { max-width: var(--bench-width); margin-inline: auto; }
.bench-section > .lab-lead { max-width: var(--bench-width); }
.bench-section > .lab-lead > * { max-width: var(--column); }
.bench { font-family: var(--sans); font-size: 1rem; line-height: 1.5; margin-top: 1.6rem; }
.bench + .bench { border-top: 1px solid var(--rule-strong); padding-top: 1.8rem; margin-top: 2rem; }
.bench-in { position: relative; }
.lab-title { font-family: var(--serif); font-size: 1.25rem; font-weight: 650; line-height: 1.2; margin-bottom: .35rem; }
.lab-intro { color: var(--ink-2); margin: 0 0 1rem; max-width: 46rem; }

/* Try it */
.prompt-box { position: relative; background: var(--paper-raised); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: .85rem .95rem .7rem; margin: 1rem 0; font-family: var(--mono); font-size: .875rem; line-height: 1.55; }
.prompt-box p { margin: 0 0 .7rem; white-space: pre-wrap; }

.remember { background: color-mix(in srgb, var(--accent-tint) 38%, var(--paper)); border-radius: var(--radius); padding: 1rem 1.15rem; }
.remember ul { margin: 0; padding-left: 1.2em; }
.remember li { margin: .45em 0; }
.remember li::marker { color: var(--accent); }

/* Sources */
.sources ol { list-style: none; padding: 0; margin: 0; font-family: var(--sans); font-size: .875rem; line-height: 1.4; }
.sources li { padding: .5rem 0; border-top: 1px solid var(--rule); }
.source-title { font-weight: 550; overflow-wrap: anywhere; }
.source-meta { color: var(--ink-2); font-size: .8125rem; display: block; }
.terms-extra { font-family: var(--sans); font-size: .9375rem; }
.terms-extra dt { font-weight: 650; margin-top: .6rem; }
.terms-extra dd { margin: 0; color: var(--ink-2); line-height: 1.4; }

.lesson-end { margin: 3.4rem 0 4rem; padding-top: 1.4rem; border-top: 2px solid var(--accent); display: grid; gap: .7rem; }
.lesson-end .btn.primary { width: 100%; min-height: 3.1rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; font-family: var(--sans); font-size: .875rem; }
.pager a { display: block; text-decoration: none; padding: .55rem 0; min-height: 2.75rem; line-height: 1.3; }
.pager a:hover { color: var(--accent); }
.pager .dir { display: block; color: var(--ink-3); font-size: .8125rem; }
.pager .next { text-align: right; grid-column: 2; }

/* Glossary and all-sources pages */
.ref-page { padding: 2.6rem var(--gutter) 5rem; }
.ref-page h1 { font-size: clamp(2rem, 7vw, 2.9rem); margin-bottom: .6em; }
.gloss-list { margin: 1.4rem 0 0; }
.gloss-item { padding: .8rem 0; border-top: 1px solid var(--rule); scroll-margin-top: calc(var(--bar-h) + .5rem); }
.gloss-item.hit { background: var(--accent-tint); color: var(--t-ink); }
.gloss-item dt { font-weight: 650; }
.gloss-item dd { margin: .1rem 0 0; line-height: 1.45; }
.gloss-links { display: flex; flex-wrap: wrap; gap: .1rem .7rem; font-family: var(--sans); font-size: .8125rem; margin-top: .2rem; }
.source-group { margin-top: 2.2rem; }
.source-group h2 { font-size: 1.15rem; margin-bottom: .5rem; }
.data-note { margin: .4rem 0 1.2rem; }

/* Final test and the completion card */
.final { padding: 2.6rem var(--gutter) 5rem; }
.final h1 { font-size: clamp(2rem, 7vw, 2.9rem); margin-bottom: .5em; }
.q-count { font-family: var(--sans); font-size: .875rem; color: var(--ink-2); margin-bottom: .3rem; }
.final-score { font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 650; line-height: 1.15; margin: 0 0 .5em; }
.miss-list { list-style: none; padding: 0; margin: .4rem 0 1.5rem; }
.miss-list li { padding: .6rem 0; border-top: 1px solid var(--rule); font-size: .96em; line-height: 1.4; }
.miss-list a { font-family: var(--sans); font-size: .875rem; }
.card-form { margin: 1.4rem 0; }
.cert { background: var(--paper-raised); border: 1px solid var(--rule-strong); padding: 2rem 1.4rem; text-align: center; margin: 1.2rem 0; border-radius: var(--radius); }
.cert .progress-tiles { justify-content: center; margin: 0 0 1.2rem; }
.cert-title { font-family: var(--sans); font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--p1); margin-bottom: .7rem; }
.cert-body { font-size: clamp(1.25rem, 4.5vw, 1.625rem); line-height: 1.3; margin: 0; text-wrap: balance; }

/* Small print */
.small-print { font-family: var(--sans); font-size: .8125rem; color: var(--ink-2); line-height: 1.45; }
.settings { padding: .9rem 0 3rem; }
