/* ===== Vazirmatn variable font ===== */
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}

/* ===== Design tokens ===== */
:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2230;
  --border: #2a3140;
  --text: #dbe2ec;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.14);
  --mark: rgba(255, 200, 60, 0.35);
  --code-bg: #11151c;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --sidebar-w: 300px;
  --toc-w: 220px;
  --content-w: 860px;
  --content-fs: 16.5px;
  --content-lh: 2;
  --code-fs: 13.5px;
  --content-font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  color-scheme: dark;
}
html[data-theme='light'] {
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --bg-elev2: #eef1f5;
  --border: #d8dee6;
  --text: #1f2530;
  --text-dim: #57606a;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.1);
  --mark: rgba(255, 200, 60, 0.5);
  --code-bg: #f4f6f8;
  --shadow: 0 12px 36px rgba(70, 80, 100, 0.2);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  font-size: 16px;
  line-height: 2;
}

/* ===== Progress bar ===== */
#progress {
  position: fixed;
  top: 0;
  right: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width 0.1s linear;
}

/* ===== PWA install banner ===== */
#pwa-banner {
  position: sticky;
  top: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%), var(--bg-elev);
  border-bottom: 1px solid var(--border);
  direction: rtl;
  text-align: right;
  font-size: 13.5px;
}
#pwa-banner[hidden] { display: none; }
.pwa-icon { font-size: 18px; flex-shrink: 0; }
.pwa-text { flex: 1; color: var(--text); min-width: 0; }
.pwa-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.pwa-btn:active { transform: scale(0.94); }
.pwa-btn-yes { border: none; background: var(--accent); color: #fff; }
.pwa-btn-yes:hover { filter: brightness(1.08); }
.pwa-btn-no { border: 1px solid var(--border); background: transparent; color: var(--text-dim); }
.pwa-btn-no:hover { border-color: var(--text-dim); color: var(--text); }
.pwa-settings-btn {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.pwa-settings-btn:hover { border-color: var(--accent); }
.pwa-settings-btn:active { transform: scale(0.94); }
@media (max-width: 640px) {
  #pwa-banner { flex-wrap: wrap; }
  .pwa-text { flex-basis: 100%; order: -1; }
}

/* ===== Top bar ===== */
#topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  direction: rtl; text-align: right;
}
.spacer { flex: 1; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-elev2); color: var(--text); }
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 180px;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text); }
kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-elev2);
  color: var(--text-dim);
  direction: ltr;
}
#menu-btn { display: none; }
.dname { direction: ltr; unicode-bidi: isolate; }

/* ===== Layout ===== */
#layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1500px;
  margin: 0 auto;
}

/* ===== Sidebar ===== */
#sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 16px 12px 40px;
  border-left: 1px solid var(--border);
  font-size: 13.5px;
  scrollbar-width: thin;
}
.side-search {
  position: sticky;
  top: -16px;
  z-index: 2;
  padding: 4px 2px 10px;
  margin-top: -6px;
  background: var(--bg);
}
@media (max-width: 900px) {
  .side-search { background: var(--bg-elev); top: -20px; }
}
.side-search input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s ease;
}
.side-search input:focus { border-color: var(--accent); }
.side-search input::placeholder { color: var(--text-dim); }
#sidebar details { margin-bottom: 2px; }
#sidebar summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  user-select: none;
  direction: rtl; text-align: right;
}
#sidebar summary::-webkit-details-marker { display: none; }
#sidebar summary::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 5px solid var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}
#sidebar details[open] > summary::before { transform: rotate(-90deg); }
#sidebar summary:hover { background: var(--bg-elev2); }
#sidebar .children { padding-right: 14px; }
#sidebar a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl; text-align: right;
  border-right: 2px solid transparent;
}
#sidebar a:hover { background: var(--bg-elev2); color: var(--text); }
#sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-right-color: var(--accent);
}
#backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 44;
}

/* ===== Resizers (mouse + touch via pointer events) ===== */
#sidebar-resizer {
  position: fixed;
  top: 56px;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
  z-index: 40;
}
#content-resizer, #toc-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: col-resize;
  touch-action: none;
  z-index: 10;
}
#toc-resizer { position: fixed; top: 56px; bottom: 0; z-index: 40; }
#sidebar-resizer::after, #content-resizer::after, #toc-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 4px;
  width: 2px;
  background: transparent;
  transition: background 0.15s ease;
}
#sidebar-resizer:hover::after, #sidebar-resizer.dragging::after,
#content-resizer:hover::after, #content-resizer.dragging::after,
#toc-resizer:hover::after, #toc-resizer.dragging::after {
  background: var(--accent);
}
body.resizing { cursor: col-resize; user-select: none; }
@media (max-width: 1200px) {
  #toc-resizer { display: none; }
}
@media (max-width: 900px) {
  #sidebar-resizer, #content-resizer { display: none; }
}

/* ===== Main content ===== */
#main {
  padding: 28px 44px 80px;
  min-width: 0;
  position: relative;
}
#breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
  direction: rtl; text-align: right;
}
#breadcrumb a { color: var(--text-dim); text-decoration: none; }
#breadcrumb a:hover { color: var(--accent); }
#breadcrumb .sep { opacity: 0.5; }

/* ===== Markdown body ===== */
.markdown-body {
  max-width: var(--content-w);
  font-size: var(--content-fs);
  line-height: var(--content-lh);
  font-family: var(--content-font);
  direction: rtl;
  text-align: right;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  line-height: 1.6;
  font-weight: 700;
  margin: 1.6em 0 0.6em;
  scroll-margin-top: 76px;
  position: relative;
}
.markdown-body h1 { font-size: 1.9em; margin-top: 0.2em; border-bottom: 1px solid var(--border); padding-bottom: 0.4em; }
.markdown-body h2 { font-size: 1.45em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.2em; }
.heading-anchor {
  position: absolute;
  right: -1.1em;
  top: 0;
  opacity: 0;
  color: var(--accent);
  text-decoration: none;
  font-weight: 400;
}
h1:hover .heading-anchor, h2:hover .heading-anchor, h3:hover .heading-anchor,
h4:hover .heading-anchor, h5:hover .heading-anchor, h6:hover .heading-anchor { opacity: 1; }

.markdown-body p { margin: 0.8em 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body ul, .markdown-body ol { padding-right: 1.6em; padding-left: 0; margin: 0.8em 0; }
.markdown-body li { margin: 0.3em 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

.markdown-body blockquote {
  margin: 1em 0;
  padding: 0.5em 1.2em;
  border-right: 4px solid var(--accent);
  border-left: none;
  background: var(--bg-elev);
  border-radius: 6px;
  color: var(--text-dim);
}

/* Inline code — LTR island inside RTL text */
.markdown-body code {
  font-family: 'Cascadia Code', ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.86em;
  background: var(--bg-elev2);
  padding: 2px 6px;
  border-radius: 5px;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Code blocks */
.markdown-body pre {
  position: relative;
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  line-height: 1.6;
  margin: 1em 0;
}
.markdown-body pre code { background: none; padding: 0; font-size: var(--code-fs); }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.markdown-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.ok { color: #3fb950; border-color: #3fb950; opacity: 1; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1em 0; }
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 14px;
  text-align: right;
}
.markdown-body th { background: var(--bg-elev); font-weight: 700; }
.markdown-body tr:nth-child(even) td { background: var(--bg-elev); }

/* Mermaid */
.mermaid-wrap {
  direction: ltr;
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 1.2em 0;
  overflow-x: auto;
}
.mermaid-wrap svg { max-width: 100%; height: auto; }
.mermaid-error {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  color: #f85149;
  white-space: pre-wrap;
}

/* ===== Prev / next ===== */
#prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: var(--content-w);
  margin-top: 48px;
}
#prevnext a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-elev);
  transition: border-color 0.15s;
  min-width: 0;
}
#prevnext a:hover { border-color: var(--accent); }
#prevnext .label { font-size: 12px; color: var(--text-dim); display: block; }
#prevnext .title { font-weight: 600; font-size: 14px; direction: rtl; text-align: right; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#prevnext a.next { text-align: left; }
#prevnext .ph { visibility: hidden; }

/* ===== Page TOC ===== */
#page-toc {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 24px 14px;
  font-size: 12.5px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
#page-toc .toc-title { font-weight: 700; color: var(--text-dim); margin-bottom: 8px; font-size: 11.5px; letter-spacing: 0.03em; }
#page-toc a {
  display: block;
  padding: 3px 8px;
  color: var(--text-dim);
  text-decoration: none;
  border-right: 2px solid var(--border);
  border-radius: 0;
  direction: rtl; text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#page-toc a.h3 { padding-right: 20px; }
#page-toc a:hover { color: var(--text); }
#page-toc a.active { color: var(--accent); border-right-color: var(--accent); }

/* ===== Search overlay ===== */
#search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 70;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 16px 16px;
}
#search-overlay[hidden] { display: none; }
#search-panel {
  width: 100%;
  max-width: 640px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
#search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  direction: rtl; text-align: right;
}
#search-results { overflow-y: auto; padding: 8px; }
.search-result {
  display: block;
  padding: 10px 14px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  direction: rtl;
  text-align: right;
}
.search-result:hover, .search-result.selected { background: var(--accent-soft); }
.search-result .r-title { font-weight: 600; font-size: 14.5px; direction: rtl; text-align: right; }
.search-result .r-chapter {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 0 8px;
  margin-right: 8px;
  direction: ltr;
}
.search-result .r-snippet {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.9;
  direction: rtl;
  text-align: right;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 30px; text-align: center; color: var(--text-dim); font-size: 14px; }

/* ===== Settings ===== */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 70;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 16px 16px;
}
#settings-overlay[hidden] { display: none; }
#settings-panel {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}
.settings-body { padding: 8px 18px 18px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.setting-row:last-of-type { border-bottom: none; }
.settings-hint { color: var(--text-dim); font-size: 12px; line-height: 1.9; border-bottom: none; padding-bottom: 4px; }
.setting-ctl { display: flex; align-items: center; gap: 10px; direction: ltr; }
.setting-ctl input[type='range'] { width: 150px; accent-color: var(--accent); }
.setting-ctl output { min-width: 46px; font-size: 12px; color: var(--text-dim); text-align: center; }
.setting-ctl select {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  direction: rtl;
}
#theme-swatches { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-start; }
.theme-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active {
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.25),
    0 0 0 2px var(--bg-elev), 0 0 0 4px var(--text-dim);
}
.settings-footer { padding-top: 14px; text-align: left; }
#settings-reset {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev2);
  color: var(--text);
  cursor: pointer;
}
#settings-reset:hover { border-color: var(--accent); }
#settings-close { font-size: 14px; }

/* ===== States ===== */
.loading, .error-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.error-state h2 { color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  #layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  #page-toc { display: none; }
}
@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; }
  #menu-btn { display: inline-flex; }
  #sidebar {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    height: calc(100vh - 56px);
    width: min(84vw, 320px);
    background: var(--bg-elev);
    z-index: 45;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
    padding-top: 20px;
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open #backdrop { display: block; }
  #main { padding: 20px 18px 60px; }
  .search-trigger {
    flex: 0 0 36px;
    min-width: 36px;
    width: 36px;
    padding: 0;
    justify-content: center;
    border: none;
    background: transparent;
  }
  .search-trigger:hover { background: var(--bg-elev2); }
  .search-trigger span, .search-trigger kbd { display: none; }
  .brand { flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
  .brand span { font-size: 13px; }
  #prevnext { grid-template-columns: 1fr; }
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* page change */
#content.page-enter, #prevnext.page-enter, #breadcrumb.page-enter {
  animation: fadeUp 0.3s ease both;
}
#page-toc.page-enter { animation: fadeDown 0.3s ease both; }

/* modals — display:none → visible restarts these each open */
#search-overlay:not([hidden]), #settings-overlay:not([hidden]) { animation: overlayIn 0.18s ease; }
#search-overlay:not([hidden]) #search-panel,
#settings-overlay:not([hidden]) #settings-panel {
  animation: panelIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.search-result { animation: fadeDown 0.18s ease both; }

/* sidebar folder expand */
#sidebar details[open] > .children { animation: fadeDown 0.2s ease; }
body.sidebar-open #backdrop { animation: overlayIn 0.2s ease; }

/* hover micro-transitions */
#sidebar a, #sidebar summary, #page-toc a, .icon-btn, .search-trigger,
#breadcrumb a, .markdown-body a, .copy-btn, #settings-reset, .search-result {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#prevnext a { transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease; }
#prevnext a:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); }
.icon-btn:active, .copy-btn:active, #settings-reset:active { transform: scale(0.92); }
.icon-btn, .copy-btn, #settings-reset { transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ===== Print ===== */
@media print {
  #topbar, #sidebar, #page-toc, #prevnext, #progress, #backdrop, #search-overlay, .copy-btn { display: none !important; }
  #layout { display: block; }
  body { background: #fff; color: #000; }
  .markdown-body { max-width: none; }
  .markdown-body pre { border: 1px solid #ccc; }
  a { color: #000; }
}
