@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-sans-3-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}



/* Общие параметры оформления из CTN. */
:root {
  --bg: #f4efe6;
  --panel: #f7f3ec;
  --ink: #2a241e;
  --muted: #6f655b;
  --line: #e3d9cc;
  --accent: #7d3b2e;
  --soft: #efe6d8;
  --sidebar: 300px;
  --scale: 1;
  color-scheme: light;
  font-family: "Source Sans 3", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}
body.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }

a { color: var(--accent); }
button { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 6px 12px;
  background: var(--panel);
}
.skip-link:not(:focus) { clip-path: inset(50%); }

#sidebar, #main { min-width: 0; min-height: 0; }
#sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
#main { overflow: auto; }
#scrim { display: none; }

.tree-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 18px 10px;
  color: var(--muted);
  font-size: 0.8125rem;
}
.tree-tools button { padding: 0; border: 0; background: none; }
.tree-tools button:hover { text-decoration: underline; }
.tree-tools [data-tree="current"] { margin-left: auto; color: var(--accent); }
.tree-branch > summary {
  position: relative;
  display: block;
  padding-block: 7px;
  padding-inline-start: 24px;
  list-style: none;
  cursor: pointer;
  font-weight: 600;
}
.tree-branch > summary::-webkit-details-marker { display: none; }
.tree-branch > summary::before {
  position: absolute;
  top: 50%;
  left: 4px;
  width: 4px;
  height: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--muted);
  transform: translateY(-50%) rotate(-45deg);
  content: "";
}
.tree-branch[open] > summary::before { transform: translateY(-70%) rotate(45deg); }
.tree-branch > .tree-branch, .tree-children { margin-left: 12px; }
.tree-lessons { margin: 0; padding: 0; list-style: none; }
.tree, .tree-children, .tree-lessons {
  display: grid;
  align-content: start;
  row-gap: var(--tree-row-gap);
}
.tree-branch[open] > :is(.tree-children, .tree-branch) { margin-block-start: var(--tree-row-gap); }
.tree-children .row { font-size: 0.875rem; padding-block: 6px; padding-inline-start: 24px; }

.brand, .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.brand { padding: 14px 16px; }
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.brand-mark, #collapse-sidebar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--accent);
  background: color-mix(in srgb, var(--bg) 72%, var(--panel));
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-copy { display: grid; line-height: 1.2; }
.brand strong { font-size: 1.0625rem; font-weight: 560; }
.eyebrow { font-size: 0.75rem; line-height: 1.35; }
#collapse-sidebar {
  align-self: flex-start;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--bg);
}
#collapse-sidebar svg { width: 10px; height: 10px; }

.tree {
  --tree-row-gap: 4px;
  flex: 1;
  overflow: auto;
  padding: 0 12px 20px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 42%, var(--line)) transparent;
}
.row {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  color: inherit;
  font-size: 0.9375rem;
  line-height: 1.35;
  text-decoration: none;
}
.row[aria-current="page"], .row:hover, #collapse-sidebar:hover, .menu-toggle:hover {
  background: var(--soft);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
  min-height: 48px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  font-size: 0.875rem;
}
.toolbar-start, .toolbar-tools, .toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-tools { gap: 12px; margin-left: auto; }
.toolbar-group { gap: 3px; }
.toolbar button, .dialog-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
}
.icon-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
}
.icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toolbar .toolbar-logout {
  border-color: var(--accent);
  color: var(--panel);
  background: var(--accent);
}
.toolbar .toolbar-logout:hover { background: color-mix(in srgb, var(--accent) 84%, var(--ink)); }
.segment button {
  min-width: 25px;
  min-height: 28px;
  padding: 2px 3px;
  border-color: transparent;
}
.toolbar button[aria-pressed="true"] { border-color: var(--line); background: var(--panel); }
.toolbar button:hover:not(.toolbar-logout) { background: var(--soft); }
.menu-toggle {
  display: none;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 2px 8px;
}
.sidebar-collapsed .menu-toggle { display: inline-flex; }
.hamburger {
  flex: none;
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 0 -4px 0 currentColor, 0 4px 0 currentColor;
}

.sheet {
  width: min(760px, calc(100% - 48px));
  margin: 28px auto 64px;
  font-size: calc(1rem * var(--scale));
  line-height: 1.65;
}
h1, h2, h3, h4, h5, h6 { line-height: 1.25; }
h1 { margin: 0.2em 0 0.35em; font-size: 1.55em; font-weight: 560; }
h2 { font-size: 1.25em; font-weight: 560; }
h3 { font-size: 1.22em; font-weight: 620; }
h4 { font-size: 1.09em; font-weight: 600; }
h5 { font-size: 1em; font-weight: 600; }
h6 { font-size: 0.94em; font-weight: 600; }
.eyebrow, .muted, .crumb { color: var(--muted); }
.crumb { margin: 0 0 0.5em; font-size: 0.875em; }

.atlas {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.atlas-branch {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 70%, var(--bg));
}
.atlas-branch h2 { margin: 0; font-size: 1.1em; }
.atlas-trunk {
  display: block;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
}
a.atlas-trunk:hover, a.atlas-node:hover { background: var(--soft); }
.atlas-tree {
  margin: 0 8px 8px 22px;
  padding: 0;
  list-style: none;
}
.atlas-tree > li { position: relative; padding-left: 14px; }
.atlas-tree > li::before {
  position: absolute;
  inset: 0 auto 0.75em 0;
  width: 11px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  content: "";
}
.atlas-node { display: block; padding: 5px 8px; border-radius: 6px; line-height: 1.35; }

.lesson-sheet {
  width: min(1080px, calc(100% - 48px));
  max-width: none;
  container-type: inline-size;
}
.lesson-sheet .sheet-title-row h1 {
  font-size: 1.85em;
  font-weight: 690;
  letter-spacing: -0.02em;
}
.lesson-subtitle { margin: 0 0 0.75rem; color: var(--muted); font-size: 1.12em; }
.timeline-panel, .lesson-side-card, .reading-surface, .lesson-lead-card, .lesson-plan {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.lesson-timeline { margin-bottom: 1.15rem; padding: 0.65rem 0.85rem 0.7rem; }
.principles-title {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.91em;
  font-weight: 680;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}
.timeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline-track li { position: relative; min-width: 0; }
.lesson-timeline .timeline-track::before {
  position: absolute;
  top: 0.35rem;
  inset-inline: 8%;
  height: 1px;
  background: color-mix(in srgb, var(--muted) 55%, var(--line));
  content: "";
}
.lesson-timeline .timeline-track li {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.23rem;
  color: var(--muted);
  text-align: center;
}
.lesson-timeline [aria-current="step"]::before {
  position: absolute;
  top: 0.35rem;
  inset-inline: 10%;
  height: 3px;
  border-radius: 99px;
  background: var(--accent);
  transform: translateY(-50%);
  content: "";
}
.timeline-dot {
  position: relative;
  width: 0.7rem;
  height: 0.7rem;
  border: 1.5px solid color-mix(in srgb, var(--muted) 70%, var(--line));
  border-radius: 50%;
  background: var(--panel);
}
[aria-current="step"] .timeline-dot { border-color: var(--accent); background: var(--accent); }
.principle-hanzi, .history-hanzi, .reading-surface [lang="zh-Hans"] {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  line-height: 1.15;
}
.principle-hanzi { font-size: 1.65em; font-weight: 650; }
.timeline-stage, .timeline-note { max-width: 100%; overflow-wrap: anywhere; }
.timeline-stage { font-weight: 630; line-height: 1.25; }
.timeline-note { color: var(--muted); font-size: 0.85em; line-height: 1.3; }
[aria-current="step"] :is(.timeline-stage, .principle-hanzi, .history-hanzi) { color: var(--accent); }
.lesson-timeline .timeline-note { padding-inline: 0.2rem; }

.lesson-columns { display: grid; gap: 0.75rem; }
.lesson-main, .lesson-side { min-width: 0; }
.lesson-lead {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}
.lesson-lead-card { min-width: 0; padding: 0.65rem 0.8rem; font-size: 0.9em; line-height: 1.5; }
.lesson-lead-card h2 { margin: 0 0 0.35em; font-size: 1.03em; font-weight: 670; }
.lesson-lead-card :is(p, ul) { margin: 0; }
.lesson-lead-card ul { padding-inline-start: 1.2em; }
.lesson-lead-card li + li { margin-top: 0.3em; }
.lesson-lead-card li::marker { color: var(--accent); }
.lesson-plan { min-width: 0; padding: 0.65rem; }
.lesson-contents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 0.65rem;
  margin-bottom: 0.65rem;
}
.lesson-contents-head h2 { margin: 0; font-size: 1.05em; font-weight: 670; }
.lesson-disclosure-tools { display: flex; gap: 0.3rem; }
.lesson-disclosure-tools button {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}
.lesson-disclosure-tools button::before,
.lesson-disclosure-tools [data-lesson-action="expand"]::after {
  grid-area: 1 / 1;
  width: 0.65rem;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  content: "";
}
.lesson-disclosure-tools [data-lesson-action="expand"]::after { transform: rotate(90deg); }
.lesson-disclosure-tools button:hover { background: var(--soft); }
.lesson-outline, .lesson-side { display: grid; align-content: start; gap: 0.45rem; }
.lesson-part { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.lesson-part > summary, .lesson-subsection > summary {
  position: relative;
  list-style: none;
  cursor: pointer;
}
.lesson-part > summary::-webkit-details-marker, .lesson-subsection > summary::-webkit-details-marker { display: none; }
.lesson-part > summary::after, .lesson-subsection > summary::after {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.9rem;
  width: 0.5rem;
  height: 0.5rem;
  border-inline-end: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--muted);
  transform: translateY(-70%) rotate(45deg);
  content: "";
}
.lesson-part[open] > summary::after, .lesson-subsection[open] > summary::after {
  transform: translateY(-30%) rotate(225deg);
}
.lesson-part > summary { padding: 0.48rem 1.85rem 0.48rem 0.6rem; border-radius: 7px; }
.lesson-part > summary:focus-visible { outline: none; }
.lesson-part > summary:focus-visible .lesson-part-name {
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.lesson-part > summary::after { transform: translateY(-50%) rotate(-45deg); }
.lesson-part[open] > summary::after { transform: translateY(-65%) rotate(45deg); }
.lesson-part-title {
  display: grid;
  grid-template-columns: 1.5rem auto minmax(0, 1fr);
  align-items: center;
  gap: 0.15rem 0.65rem;
  margin: 0;
  font-size: 0.975em;
  font-weight: 660;
  line-height: 1.35;
}
.lesson-part-number {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  background: var(--soft);
  font-size: 0.79em;
  font-variant-numeric: tabular-nums;
}
.lesson-part-caption {
  min-width: 0;
  padding-inline-start: 0.65rem;
  border-inline-start: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84em;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.lesson-part > summary:hover, .lesson-subsection > summary:hover { background: color-mix(in srgb, var(--soft) 55%, var(--panel)); }
.lesson-part[open] > summary {
  border-radius: 7px 7px 0 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--soft) 55%, var(--panel));
}
.lesson-part-body { padding: 0.75rem clamp(0.7rem, 3cqi, 1.3rem) 0.9rem; }
.lesson-part[open] > .lesson-part-body, .lesson-subsection[open] > .lesson-subsection-body {
  animation: lesson-reveal 150ms ease-out;
}
@keyframes lesson-reveal { from { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .lesson-part[open] > .lesson-part-body, .lesson-subsection[open] > .lesson-subsection-body { animation: none; }
}
.lesson-subsection { border-top: 1px solid var(--line); }
.lesson-subsection > summary { padding: 0.45rem 1.7rem 0.45rem 0.25rem; }
.lesson-subsection > summary::after { inset-inline-end: 0.5rem; width: 0.36rem; height: 0.36rem; }
.lesson-subsection > summary h4 { margin: 0; }
.lesson-copy[data-lesson-part="theory"] .lesson-subsection > summary h4 { font-size: 0.9em; }
.lesson-subsection[open] > summary h4 { color: var(--accent); }
.lesson-subsection-body { padding: 0 0.25rem 0.35rem; }
.lesson-recap { margin-top: 1rem; padding-top: 0.25rem; border-top: 1px solid var(--line); }
.lesson-sheet :is(summary[id], h3[id], h4[id], h5[id]) { scroll-margin-block-start: 5.25rem; }

.lesson-side-card { padding: 0.45rem 0.65rem; color: var(--ink); }
.lesson-side-card > summary { cursor: pointer; font-size: 1.01em; font-weight: 650; }
.lesson-note { background: var(--soft); }
.lesson-note p { margin: 0.35rem 0 0.15rem; font-size: 0.875em; line-height: 1.5; }
.lesson-structure-list { display: grid; gap: 0.4rem; margin: 0.5rem 0 0.35rem; }
.lesson-structure-list > div + div { padding-top: 0.4rem; border-top: 1px solid var(--line); }
.lesson-structure-list dt { font-size: 0.94em; font-weight: 650; line-height: 1.3; }
.lesson-structure-list a { color: inherit; text-decoration: none; }
.lesson-structure-list a:hover { color: var(--accent); text-decoration: underline; }
.lesson-structure-list dd { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.85em; line-height: 1.35; }
.lesson-side-card [data-lesson-resources] a { display: block; margin-block: 0.3rem; }
.lesson-posters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 5rem), 1fr));
  gap: 0.45rem;
  margin-block: 0.5rem 0.25rem;
}
.lesson-poster {
  display: grid;
  align-content: start;
  gap: 0.28rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.85em;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.lesson-poster:hover, .lesson-poster:focus-visible {
  background: var(--soft);
  color: var(--accent);
}
.lesson-poster img { display: block; width: 100%; height: auto; border-radius: 3px; }

@container (min-width: 860px) {
  .lesson-columns.has-lesson-side { grid-template-columns: minmax(0, 1fr) minmax(13rem, 26%); gap: 1.2rem; }
  .lesson-main { grid-column: 1; grid-row: 1; }
  .lesson-side {
    position: sticky;
    top: 4.1rem;
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    max-height: calc(100dvh - 5rem);
    overflow: auto;
  }
}
@container (max-width: 460px) {
  .lesson-timeline { padding-inline: 0.3rem; }
  .principles-title { padding-inline: 0.3rem; }
  .principle-hanzi { font-size: 1.25em; }
  .lesson-timeline :is(.timeline-stage, .timeline-note) { font-size: 0.75em; }
  .lesson-lead { grid-template-columns: minmax(0, 1fr); gap: 0.45rem; }
  .lesson-part-title { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .lesson-part-number { grid-row: span 2; }
  .lesson-part-caption { grid-column: 2; padding-inline-start: 0; border-inline-start: 0; }
}

.lesson-copy { overflow-wrap: anywhere; }
.lesson-copy :is(p, ul, ol) { margin-block: 0.75em; }
.sheet:not(.reading-article) p:has(+ :is(h1, h2, h3, h4, h5, h6)) { padding-block-end: 0.55em; }
.lesson-copy :is(h2, h3, h4, h5, h6) { line-height: 1.3; }
.lesson-copy h3 { margin: 1.15em 0 0.45em; }
.lesson-copy :is(h4, h5, h6) { margin: 0.85em 0 0.35em; }
.lesson-sheet .lesson-copy h2 { font-size: 1.4em; }
.lesson-part-body .lesson-copy > h3 {
  margin: 1.3em 0 0.45em;
  color: var(--accent);
  font-size: 1.32em;
}
.lesson-part-body .lesson-copy > h3 ~ h3 {
  padding-block-start: 0.65em;
  border-block-start: 1px solid var(--line);
}
.lesson-part-body .lesson-copy > h4 { margin: 0.9em 0 0.3em; }
.lesson-part-body .lesson-copy > h4 + :is(ul, ol) { margin-block-start: 0.25em; }
.lesson-copy li + li { margin-top: 0.2em; }
.lesson-copy li::marker { color: var(--muted); }
.lesson-copy img, .lesson-copy video { display: block; max-width: 100%; height: auto; }
.lesson-table { max-width: 100%; margin: 0.65rem 0; overflow-x: auto; }
.lesson-table table { width: 100%; border-collapse: collapse; font-size: 0.9em; line-height: 1.45; }
.lesson-table :is(th, td) { padding: 0.45em 0.55em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.lesson-table thead { background: var(--soft); }
.lesson-table th { font-weight: 600; }
.lesson-table [scope="row"] { min-width: 6.5em; }

.lesson-video { margin-block: 0.65rem; padding-block: 0.65rem; border-top: 1px solid var(--line); }
.lesson-video-link { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem; color: inherit; text-decoration: none; }
.lesson-video-link:hover strong { text-decoration: underline; }
.lesson-video-poster {
  position: relative;
  display: grid;
  flex: 0 1 11rem;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: var(--soft);
}
.lesson-video-poster img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.lesson-video-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  color: var(--panel);
}
.lesson-video-play::before { border: 0.36rem solid transparent; border-right: 0; border-left: 0.55rem solid; content: ""; }
.lesson-video-duration { position: absolute; inset: auto 0.25rem 0.25rem auto; padding: 0 0.25rem; border-radius: 3px; background: var(--ink); color: var(--panel); font-size: 0.75em; }
.lesson-video-info { display: grid; flex: 1 1 11rem; gap: 0.15rem; font-size: 0.92em; }
.lesson-video-player { width: 100%; margin-top: 0.65rem; background: var(--ink); }

.lesson-sheet, .reading-article { scroll-margin-block-start: 6rem; }
.reading-article { width: min(840px, calc(100% - 48px)); container-type: inline-size; }
.reading-article .lesson-subtitle { margin: 0.3rem 0 1rem; line-height: 1.45; }
.reading-surface { padding: 0.85rem 1rem; }
.reading-surface > p, .reading-illustrated > p { margin-block: 0 0.95em; }
.reading-surface > :last-child, .reading-illustrated > :last-child { margin-bottom: 0; }
.reading-illustrated + .reading-contents { margin-top: 0.95em; }
.reading-surface h2 {
  margin-block: 1.2em 0.55em;
  color: var(--accent);
  font-weight: 680;
}
.reading-surface ul { padding-inline-start: 1.45em; margin-block: 0.25em 0.95em; }
.reading-surface [lang="zh-Hans"] { color: var(--accent); font-weight: 650; }
.reading-surface .reading-term {
  padding: 0.35em 0.7em;
  border-inline-start: 3px solid var(--accent);
  background: var(--soft);
}
.reading-surface :is(th, td) { padding-block: 0.55em; }
.reading-surface .lesson-table [scope="row"] { min-width: 0; }
.reading-surface .lesson-table-index th:first-child { width: 1%; white-space: nowrap; }
.scheme-preview { display: block; color: var(--accent); text-decoration: none; }
.scheme-preview:hover .scheme-preview-label { background: var(--soft); }
.scheme-preview-label, .image-viewer-original {
  display: inline-block;
  padding: 0.14rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.82rem;
  line-height: 1.4;
  text-decoration: none;
}
.scheme-preview-label { margin-top: 0.35rem; }
.image-viewer {
  width: max-content;
  max-width: min(1120px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 26px rgb(30 24 18 / 20%);
}
.image-viewer::backdrop { background: rgb(30 24 18 / 64%); }
.image-viewer-surface:focus { outline: none; }
.image-viewer-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.35rem 0.45rem;
}
.image-viewer-original:hover, .image-viewer-close:hover { background: var(--soft); }
.image-viewer-close {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
}
.image-viewer-close svg { width: 12px; height: 12px; }
.image-viewer img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100dvh - 4.25rem);
  margin-inline: auto;
  object-fit: contain;
}

.reading-figure { margin: 0.2rem 0 1.15rem; }
.reading-figure-compact { --figure-width: 24rem; }
.reading-figure img { width: 100%; border-radius: 6px; }
.reading-figure figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.86em; line-height: 1.4; }
.reading-figure-credit { display: block; margin-top: 0.2em; font-size: 0.91em; }
.reading-figure-credit a { color: inherit; text-underline-offset: 0.15em; }
.reading-illustrated { display: flow-root; }
.reading-illustrated > .reading-figure {
  width: min(100%, var(--figure-width, 10rem));
  margin: 0 auto 0.8em;
}
@container (min-width: 34rem) {
  .reading-illustrated > .reading-figure {
    float: inline-end;
    width: min(31%, var(--figure-width, 10rem));
    margin: 0.2em 0 0.6em 1em;
  }
}
.reading-surface h2[id] { scroll-margin-block-start: 6rem; }
.reading-contents {
  margin-bottom: 1.15rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.reading-contents > summary { cursor: pointer; font-weight: 630; }
.reading-contents ul { font-size: 0.9em; margin: 0.35em 0; }
.reading-contents a { color: inherit; text-underline-offset: 0.15em; }
.reading-contents a:hover { color: var(--accent); }
.reading-dates { display: block; color: var(--muted); font-size: 0.89em; }
.reading-credits {
  margin-top: 1.15rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85em;
  line-height: 1.45;
}
.reading-credits p { margin-block: 0.2em; }

.course-history h4 { margin-top: 0; color: var(--accent); }
.course-history .history-subtitle { margin-top: 0; color: var(--muted); }
.course-history .timeline-track { grid-template-columns: 1fr; margin-top: 0.8rem; }
.course-history .timeline-track li {
  display: grid;
  grid-template-columns: 0.7rem 3.45em minmax(0, 1fr);
  column-gap: 0.7rem;
  padding-bottom: 0.75rem;
  color: var(--muted);
}
.course-history .timeline-track li:last-child { padding-bottom: 0; }
.course-history li:not(:last-child)::before {
  position: absolute;
  top: 0.45rem;
  bottom: -0.45rem;
  inset-inline-start: 0.35rem;
  width: 1px;
  background: color-mix(in srgb, var(--accent) 38%, var(--line));
  content: "";
}
.course-history .timeline-dot, .history-hanzi { grid-row: 1 / span 2; }
.course-history .timeline-dot { margin-top: 0.2rem; }
.history-hanzi { font-size: 1.19em; font-weight: 650; }
.course-history :is(.timeline-stage, .timeline-note) { grid-column: 3; }
.course-history a.timeline-stage { justify-self: start; text-underline-offset: 0.15em; }

.sheet-head { margin: 0.2em 0 0.45em; }
.sheet-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.sheet-title-row h1 { flex: 1 1 16ch; min-width: 0; margin: 0; }
.lesson-switch { display: flex; flex-wrap: wrap; gap: 4px; }

.bookmark-icon {
  width: 11px;
  height: 14px;
  flex: none;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.bookmark-toggle, .bookmarks-launch, .lesson-switch a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.875rem;
  line-height: 1.3;
}
.bookmark-toggle {
  margin-bottom: 0.4rem;
  padding: 3px 7px;
  font-size: 0.8125rem;
}
.bookmark-toggle .bookmark-icon { width: 9px; height: 12px; }
.lesson-switch a {
  padding: 3px 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.8125rem;
}
.lesson-switch a[href]:hover { border-color: var(--accent); }
.lesson-switch a[rel="next"][href] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--panel);
}
.lesson-switch [rel="prev"]::before, .lesson-switch [rel="next"]::after {
  width: 0.32rem;
  height: 0.32rem;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  content: "";
}
.lesson-switch [rel="prev"]::before { transform: rotate(-135deg); }
.lesson-switch [rel="next"]::after { transform: rotate(45deg); }

.bookmark-toggle:hover, .bookmark-list .row:hover { background: var(--soft); }
.bookmark-toggle[aria-pressed="true"] { color: var(--accent); background: var(--soft); }
.bookmark-toggle[aria-pressed="true"] .bookmark-icon { fill: currentColor; }
.bookmarks-count { color: var(--accent); font-variant-numeric: tabular-nums; }

.bookmark-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(480px, 92vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: -16px 0 40px rgb(30 24 18 / 16%);
}
.bookmark-drawer[open] { display: flex; flex-direction: column; }
.bookmark-drawer::backdrop { background: rgb(30 24 18 / 28%); }
.bookmark-drawer-head, .bookmark-drawer-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bookmark-drawer-head { justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bookmark-drawer-head h2 { margin: 0; font-size: 1.0625rem; }
.bookmark-drawer-body { overflow: auto; padding: 8px 16px 24px; }
.bookmark-list { margin: 0; padding: 0; list-style: none; }
.bookmark-list li { display: flex; align-items: center; gap: 8px; }
.bookmark-list .row { flex: 1; min-width: 0; }
.bookmark-list button { color: var(--muted); }

  width: min(390px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}
.dialog-close:not(.icon-button) { padding: 4px 12px; }
.dialog-close:hover { background: var(--soft); }

@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); }
  #sidebar {
    position: fixed;
    z-index: 16;
    inset: 0 auto 0 0;
    width: min(var(--sidebar), calc(100% - 32px));
  }
  #scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    display: block;
    width: 100%;
    border: 0;
    background: rgb(30 24 18 / 28%);
  }
  .menu-toggle { display: inline-flex; }
  .toolbar { padding-inline: 8px; }
  .toolbar-tools { gap: 8px; }
  .sheet { width: calc(100% - 32px); margin-top: 20px; }
}
