/* Reading starts on the studio ground. The index holds the reading controls. */
.reader {
  --paper: #080b0e;
  --sheet: #141a20;
  --type: #e7ebef;
  --body-type: #c6ced6;
  --secondary-type: #a0acb8;
  --rule: #343d47;
  --active: #ffd8a6;
  --selected: #22272b;
  --sea: #a6cbe4;
  --green: #aed2c0;
  --alert: #f2bea9;

  width: 100%;
}
[data-reading-theme="light"] .reader {
  --paper: #f6f7f8;
  --sheet: #eaedf0;
  --type: #1b2631;
  --body-type: #303c47;
  --secondary-type: #51606c;
  --rule: #bac3ca;
  --active: #7c4c1c;
  --selected: #e4e8eb;
  --sea: #305c78;
  --green: #315e50;
  --alert: #843d2e;
}
[data-reading-theme="light"] .reader-paper { color-scheme: light; }


.reader { min-height: 100vh; background: var(--paper); color: var(--type); }
.reader-layout { width: min(calc(100% - 2 * var(--gutter)), 74rem); display: grid; grid-template-columns: clamp(14rem, 22vw, 18rem) minmax(0, 1fr); column-gap: clamp(2rem, 5.9vw, 6.3rem); align-items: start; padding-block: clamp(1rem, 4.5vh, 3.5rem); }
.reader :is(a, button, input, summary):focus-visible { outline: 2px solid var(--active); outline-offset: 2px; }
.reader-rail { position: sticky; top: 1rem; z-index: 3; display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 2rem); background: var(--paper); }
.reader-controls { display: flex; align-items: center; gap: .12rem; }
.reader-return { min-height: 44px; display: inline-flex; align-items: center; gap: .55rem; font: 500 .9rem/1 var(--sans); text-decoration: none; color: var(--body-type); }
.reader-return .ui-icon { width: .95rem; height: .95rem; transition: transform .25s var(--ease); }
.reader-return:hover { color: var(--active); }
.reader-return:hover .ui-icon { transform: translateX(-2px); }
.reader-controls .reading-switch { margin-left: auto; }
.reader-controls :is(.reading-switch, .resource-toggle) { color: var(--secondary-type); }
.reader-controls :is(.reading-switch, .resource-toggle):is(:hover,:focus-visible), .reader-controls details[open] summary { color: var(--active); }
.reader-controls .resource-panel { top: calc(100% + 2px); bottom: auto; right: 0; }
.reader-identity { display: flex; gap: .65rem; align-items: center; margin: clamp(.8rem, 3vh, 2rem) 0 clamp(.75rem, 2.7vh, 1.8rem); }
.reader-emblem { flex: 0 0 clamp(2.8rem, 4.3vw, 4.25rem); }
.reader-identity h1 { display: inline-block; margin: 0; font: 500 clamp(1.5rem, 2.15vw, 2.05rem)/1.03 var(--sans); letter-spacing: -.052em; text-wrap: balance; }
[data-reading-theme="light"] .reader-title-main { background: none; color: var(--type); }
.reader-duration, .reader-progress-bottom, .reader-position, .reader-toc summary, .reader-index-num, .panel-context, .save-note, .reader-article h2.part { font: 400 .74rem/1.45 var(--mono); }
.reader-duration { margin: .4rem 0 0; color: var(--secondary-type); }
.reader-progress { padding: 0 .1rem; }
.reader-progress-bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--secondary-type); }
.reader-reset { min-height: 32px; padding: .15rem .2rem; font: inherit; color: var(--secondary-type); border: 0; background: transparent; text-underline-offset: .2em; }
.reader-reset:enabled { text-decoration: underline; }
.reader-reset:disabled { opacity: .65; cursor: default; }
.reader-bar { height: 2px; background: var(--rule); }
#progress-fill { display: block; width: 0; height: 100%; background: var(--active); transition: width .22s var(--ease); }
.save-note { color: var(--secondary-type); }
.reader-toc { display: flex; flex-direction: column; min-height: 0; }
.reader-toc details { min-height: 0; }
.reader-toc summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: .7rem .1rem; gap: 1rem; color: var(--secondary-type); list-style: none; }
.reader-toc summary::-webkit-details-marker { display: none; }
.reader-toc summary::after { content: ""; width: .45rem; height: .45rem; margin: 0 .35rem .18rem 0; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg); transition: transform .24s var(--ease); }
.reader-toc [open] > summary::after { transform: rotate(225deg); }
.reader-toc-small { display: none; }
html:not([data-reader-enhanced]) .reader-rail { position: static; max-height: none; }
html:not([data-reader-enhanced]) .reader-index-scroll { max-height: 55vh; }
.reader-index-scroll { overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.reader-index-track { position: relative; isolation: isolate; }
.reader-index-marker { display: none; }
.reader-toc ol { margin: 0; padding: 0 0 .3rem; list-style: none; }
.reader-toc li { margin: 0; }
.reader-toc a { display: flex; align-items: baseline; gap: .6rem; padding: .52rem .68rem; text-decoration: none; color: var(--body-type); font: 400 .9rem/1.36 var(--sans); transition: color .2s, background-color .2s; }
.reader-toc a:hover { color: var(--type); background: color-mix(in srgb, var(--selected) 55%, transparent); }
.reader-toc :focus-visible { outline-offset: -2px !important; }
.reader-toc a.is-current { color: var(--type); }
.reader-toc .toc-group { margin-top: .55rem; padding-top: .4rem; border-top: 1px solid var(--rule); }
.reader-toc .toc-group a { font-weight: 500; }
.reader-index-num { flex: 0 0 2.05rem; color: var(--secondary-type); letter-spacing: .02em; }
.is-current .reader-index-num { color: var(--active); }
.toc-step.is-done .reader-index-num { color: var(--green); }
.toc-step.is-done .reader-index-num::after { content: "✓"; font-size: .82em; margin-left: .1em; }
.reader-workspace { width: 100%; min-width: 0; max-width: 47rem; }
.reader-article { color: var(--body-type); font: 400 clamp(1.025rem, 1.16vw, 1.12rem)/1.65 var(--sans); overflow-wrap: anywhere; }
.panel-content { width: min(100%, 66ch); padding-block: 1.5rem; }
.reader-panel:focus { outline: 0; }
.reader-panel + .reader-panel { border-top: 1px solid var(--rule); }
.reader-pager { display: none; }
.reader-article :is(h2, h3, h4, h5, h6) {
  color: var(--type);
  font-family: var(--display);
  font-weight: 500;
  text-wrap: balance;
  letter-spacing: -.04em;
}
.reader-article h2 {
  margin: 2.65rem 0 .95rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule);
  font-size: clamp(1.75rem, 2.3vw, 2.5rem);
  line-height: 1.15;
}


.reader-article h3 { font-size: clamp(1.45rem, 1.9vw, 2rem); line-height: 1.23; }
.reader-article h4, .reader-article h5 { font-size: 1.3rem; margin: 1.5rem 0 .5rem; }
.reader-article :is(h2[id], h3[id], h4[id], section[id]) { scroll-margin-top: 1.25rem; }
.reader-article p { margin: 0 0 1.05em; }
.reader-article strong { font-weight: 600; color: var(--type); }
.reader-article :is(ul, ol) { margin: .75rem 0 1.2rem; padding-left: 1.65em; }
.reader-article li + li { margin-top: .38em; }
.reader-article li::marker { color: var(--secondary-type); font-weight: 600; }
.reader-article a { color: var(--sea); text-decoration: underline; text-underline-offset: .16em; }
.reader-article a:hover { color: var(--type); }
.reader-article .subhead {
  margin: 1.45rem 0 .45rem;
  color: var(--type);
  font-weight: 600;
  font-size: 1.06em;
}
.reader-article code, .reader-article .placeholder { font: .87em var(--mono); background: var(--sheet); }
.reader-article .verify { font-size: .87em; color: var(--secondary-type); text-decoration: underline dotted; }
.reader-article .checklist { padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.reader-article .checklist li {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  margin: 0;
  padding: .55rem .25rem;
  border-bottom: 1px solid var(--rule);
}
.reader-article .checklist a { flex: 1; color: var(--type); text-decoration: none; }
.reader-article .checklist a:hover { text-decoration: underline; }
.reader-article .checklist .is-done a { color: var(--secondary-type); text-decoration: line-through; }
.reader-article .step-check { flex: 0 0 auto; width: 1.2rem; height: 1.2rem; accent-color: var(--active); cursor: pointer; }
.reader-article .checklist .step-check { margin: .27rem .15rem 0 0; }
.reader-article .step { margin: 0; }
.reader-article .step-head { display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.05rem; }
.reader-article .step-head h3 { margin: 0; flex: 1; }
.reader-article .step-num { margin-right: .4em; color: var(--active); font: 400 .7em/1 var(--mono); }
.reader-article .done-toggle {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: .45rem;
  min-height: 44px;
  padding: .35rem .65rem;
  border: 1px solid var(--rule);
  color: var(--type);
  border-radius: 2px;
  font: 500 .91rem/1.25 var(--sans);
  cursor: pointer;
}
.reader-article .done-toggle { transition: background-color .23s var(--ease), border-color .23s var(--ease); }
.reader-article .done-toggle input { margin: 0; }
.reader-article .done-toggle:hover, .reader-article .done-toggle:has(:checked) { background: var(--sheet); }
.reader-article .done-toggle:has(:checked) { border-color: color-mix(in srgb, var(--green) 52%, var(--rule)); }
.reader-article .step-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-top: 1.4rem; }
.reader-article .top-link { padding-block: .4rem; font-size: .95rem; }
.reader-article .callout {
  --callout-rule: var(--secondary-type);
  margin: 1.1rem 0;
  padding: .95rem clamp(.9rem, 2vw, 1.25rem);
  background: var(--sheet);
  border-left: 2px solid var(--callout-rule);
}
.reader-article .callout > :last-child { margin-bottom: 0; }
.reader-article .callout-why, .reader-article .callout-advanced { --callout-rule: var(--sea); }
.reader-article .callout-check { --callout-rule: var(--green); }
.reader-article .callout-heads, .reader-article .callout-expert { --callout-rule: var(--active); }
.reader-article .callout-trouble, .reader-article .callout-warn { --callout-rule: var(--alert); }
.reader-article .callout p:first-child > strong:first-child { color: var(--callout-rule); }
.reader-article details.callout { padding-block: .35rem; }
.reader-article details.callout > summary {
  display: list-item;
  min-height: 44px;
  padding: .55rem 0;
  color: var(--type);
  font-weight: 600;
  cursor: pointer;
}
.reader-article details.callout > summary::marker { color: var(--callout-rule); }
.reader-article details.callout[open] { padding-bottom: 1rem; }
.reader-article .adv-hint { font-weight: 400; font-size: .92em; color: var(--secondary-type); }
.reader-article details.callout details { margin: 1rem 0 0; border-top: 1px solid var(--rule); }


/* The chapter label occupies the same place on each step, including a chapter's first. */
.reader-article .panel-context, .reader-article h2.part {
  display: flex; align-items: center; gap: .65rem; margin: 0 0 .95rem; padding: 0; border: 0;
  letter-spacing: .035em; font: 400 .74rem/1.4 var(--mono); color: var(--secondary-type);
}
.reader-article :is(.panel-context, h2.part)::before { content: ""; flex: 0 0 1.8rem; height: 1px; background: linear-gradient(90deg, transparent, var(--active)); }
.reader-article .panel-content > h2:not(.part), .reader-article .step-head h3 {
  margin: 0 0 1.1rem; padding: 0; border: 0; font: 500 clamp(2.05rem, 3.45vw, 3.65rem)/1.065 var(--sans); letter-spacing: -.052em; text-wrap: balance;
}
.reader-article .step-head { align-items: start; margin: 0 0 1.35rem; }
.reader-article .step-head h3 { margin: 0; }
.reader-article .step-head .done-toggle { margin-top: .2rem; }
.chapter-alias { display: block; height: 0; }

@media screen {
  html[data-reader-enhanced], html[data-reader-enhanced] body { height: 100%; overflow: hidden; }
  [data-reader-enhanced] .reader { height: 100vh; height: 100dvh; min-height: 0; }
  [data-reader-enhanced] .reader-layout { height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  [data-reader-enhanced] .reader-rail { position: relative; top: 0; max-height: none; }
  [data-reader-enhanced] .reader-toc, [data-reader-enhanced] #toc[open] { min-height: 0; overflow: hidden; }
  [data-reader-enhanced] #toc[open] { display: flex; flex-direction: column; }
  [data-reader-enhanced] #toc[open]::details-content { display: contents; }
  [data-reader-enhanced] #toc summary { flex: none; }
  [data-reader-enhanced] .reader-index-scroll { min-height: 0; }
  [data-reader-enhanced] .reader-index-marker {
    display: block; position: absolute; z-index: -1; pointer-events: none; top: 0; inset-inline: 0;
    transform: translateY(var(--marker-y, 0px)); height: var(--marker-height, 0px);
    border-inline-start: 2px solid var(--active);
    background: linear-gradient(90deg, color-mix(in srgb, var(--active) 10%, transparent), color-mix(in srgb, var(--active) 3%, transparent) 70%, transparent);
    transition: transform .32s cubic-bezier(.22,.68,.14,1), height .28s var(--ease);
  }
  [data-reader-enhanced] .reader-article .step-num { display: none; }
  [data-reader-enhanced] .reader-workspace { min-height: 0; display: grid; grid-template-rows: minmax(0,1fr) auto; }
  [data-reader-enhanced] .reader-article { position: relative; min-height: 0; overflow: hidden; overflow: clip; isolation: isolate; }
  [data-reader-enhanced] .reader-article::before, [data-reader-enhanced] .reader-article::after {
    content: ""; position: absolute; z-index: 2; pointer-events: none; inset-inline: 0;
  }
  [data-reader-enhanced] .reader-article::before { top: 0; height: 7px; background: linear-gradient(var(--paper), transparent); }
  [data-reader-enhanced] .reader-article::after { bottom: 0; height: 14px; background: linear-gradient(transparent, var(--paper)); }
  [data-reader-enhanced] .reader-panel {
    position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom;
    border: 0; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; scrollbar-gutter: stable;
  }
  [data-reader-enhanced] .panel-content { padding: clamp(1.25rem, 3.4vh, 2.4rem) 1rem clamp(1.8rem, 5vh, 4rem) .2rem; }
  [data-reader-enhanced] .reader-pager {
    position: relative; display: grid; align-items: center; grid-template-columns: minmax(0, 1fr) auto minmax(0,1fr);
    gap: .65rem; padding: .6rem .15rem 0; width: 100%;
  }
  .reader-pager::before { content: ""; position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, var(--rule), color-mix(in srgb,var(--active) 45%,var(--rule)) 50%, var(--rule)); }
  .reader-pager a { display: inline-flex; align-items: center; justify-self: start; gap: .5em; padding: .45rem .16rem; min-height: 44px; text-decoration: none; color: var(--type); font: 500 .97rem/1.2 var(--sans); }
  .reader-pager a:last-child { justify-self: end; }
  .reader-pager .ui-icon { width: 1.15em; height: 1.15em; color: var(--active); transition: transform .25s var(--ease); }
  [data-reader-next] svg { transform: rotate(180deg); }
  .reader-pager a:is(:hover, :focus-visible) { color: var(--active); }
  .reader-pager [data-reader-prev]:hover svg { transform: translateX(-3px); }
  .reader-pager [data-reader-next]:hover svg { transform: translateX(3px) rotate(180deg); }
  .reader-pager a[aria-disabled="true"] { opacity: .36; cursor: default; }
  .reader-position { color: var(--secondary-type); text-align: center; text-wrap: balance; }
}
@media screen and (max-width:959px) {
  .reader-layout { display: block; width: min(calc(100% - 2 * var(--gutter)), 46rem); }
  .reader-rail { position: relative; top: auto; display: grid; grid-template-columns: 1fr auto; gap: 0 .7rem; align-items: center; max-height: none; }
  .reader-controls, .reader-identity { grid-area: 1 / 1 / 2 / -1; }
  .reader-identity { margin: 0 91px 0 47px; gap: .35rem; pointer-events: none; }
  .reader-identity h1 { font-size: clamp(1.05rem, 3vw, 1.6rem); }
  .reader-emblem { flex-basis: 2.8rem; }
  .reader-duration, .reader-return > span { display: none; }
  .reader-return { width: 44px; justify-content: center; margin-left: -.55rem; }
  .reader-toc { grid-area: 2 / 1; }
  .reader-toc-small { display: inline; }
  .reader-toc-wide { display: none; }
  .reader-toc summary { justify-content: start; gap: .55rem; min-height: 40px; }
  .reader-progress { grid-area: 2 / 2; min-width: min(9.5rem, 41vw); padding: 0 0 .25rem; }
  .reader-controls .resource-panel { right: 0; }
  .reader-index-scroll { max-height: 56vh; }
  [data-reader-enhanced] .reader-layout {
    display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr);
    gap: .4rem; padding-block: max(.25rem, env(safe-area-inset-top)) max(.3rem, env(safe-area-inset-bottom));
  }
  [data-reader-enhanced] .reader-rail { border-bottom: 1px solid var(--rule); }
  [data-reader-enhanced] .reader-toc, [data-reader-enhanced] #toc[open] { overflow: visible; }
  [data-reader-enhanced] .reader-index-scroll {
    position: absolute; z-index: 4; inset: 100% 0 auto; padding: .4rem .35rem; background: var(--paper);
    border-bottom: 1px solid var(--rule); box-shadow: 0 15px 24px #0003;
    max-height: min(60vh, 36rem); max-height: min(60dvh, 36rem);
  }
  [data-reader-enhanced] .panel-content { width: 100%; padding: 1.3rem .4rem 2.2rem .13rem; }
  [data-reader-enhanced] .reader-pager { width: 100%; padding: .18rem 0 0; }
}
@media screen and (max-width: 480px) {
  .reader-emblem { display: none; }
  .reader-layout { width: calc(100% - 2.1rem); }
  .reader-article { font-size: 1rem; line-height: 1.59; }
  .reader-article .panel-content > h2:not(.part), .reader-article .step-head h3 { font-size: clamp(1.85rem, 6.4vw, 2.15rem); }
  .reader-article .step-head { flex-direction: column; gap: .6rem; margin-bottom: .8rem; }
  .reader-article .step-head .done-toggle { margin-top: 0; }
  .reader-position { font-size: .69rem; }
}
@media screen and (max-height: 490px) {
  .reader-layout { padding-block: .25rem; }
  .reader-identity { margin-block: .1rem; }
  [data-reader-enhanced] .panel-content { padding-block: .7rem 1.75rem; }
  .reader-article .panel-content > h2:not(.part), .reader-article .step-head h3 { font-size: 1.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .reader *, .reader *::before, .reader *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  html, body, .reader { background: white; }
  .reader { --paper: white; --sheet: white; --type: black; --body-type: black; --secondary-type: #333; --rule: #777; --active: #333; --sea: #333; --alert: #333; --green: #333; min-height: auto; }
  .reader-layout, .reader-rail, .reader-workspace { display: block; position: static; max-height: none; padding: 0; margin: 0; width: auto; }
  .reader-controls, .reader-emblem, .reader-progress, .reader-toc, .reader-pager, .done-toggle, .step-foot { display: none !important; }
  .reader-identity { margin: 0 0 1rem; }
  .reader-title-main { background: none; color: black; }
  .reader-article { font-size: 10.5pt; }
  .reader-panel, .reader-panel[hidden] { display: block !important; opacity: 1 !important; transform: none !important; border: 0; }
  .panel-content { width: auto; padding: .45rem 0; }
  .reader-article .panel-context { display: none; }
  .reader-article :is(h2,h3,.step-head,.subhead,summary) { break-after: avoid-page; }
  .reader-article .step-head h3, .reader-article .panel-content > h2:not(.part) { font-size: 20pt; }
  .reader-article details::details-content { display: contents; content-visibility: visible; }
}
