:root {
  color-scheme: dark;
  --ink: #dedede;
  --muted: #adadad;
  --panel: #202020;
  --panel-2: #282828;
  --line: #373737;
  --accent: #55a7ff;
  --header-height: 58px;
  --nav-width: 250px;
}

* { box-sizing: border-box; }
html { background: #191919; }
body {
  margin: 0;
  color: var(--ink);
  background: #191919;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.reader-header {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: #202020;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.reader-header button, .reader-header a { color: inherit; }
.reader-header button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  background: var(--panel-2);
  cursor: pointer;
}
#menu-toggle { display: none; }
.brand { font-size: 16px; font-weight: 650; text-decoration: none; }
.doc-kind { color: var(--muted); }
#print-button { margin-left: auto; }

#outline {
  position: fixed;
  z-index: 21;
  inset: var(--header-height) auto 0 0;
  width: var(--nav-width);
  overflow: auto;
  padding: 28px 12px 28px 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: #535353 transparent;
}
#outline h2 { margin: 0 0 22px; color: var(--muted); font-size: 12px; font-weight: 500; }
#outline a {
  display: block;
  margin: 2px 0;
  padding: 6px 8px;
  padding-left: calc(var(--depth, 0) * 12px);
  border-radius: 5px;
  color: #c4c4c4;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  transition: color .15s, background .15s;
}
#outline a:hover { color: #fff; background: rgba(85,167,255,.11); }
#outline a[aria-current="true"] { color: #4ca3ff; font-weight: 650; }

main#top { padding-top: var(--header-height); }
#manual { width: min(834px, calc(100% - var(--nav-width) - 20px)); margin-left: max(calc(var(--nav-width) + 10px), calc((100% - 834px) / 2)); background:#212121; padding: 14px 0 66px; }
.pdf-page { position: relative; width: 100%; margin: 0; scroll-margin-top: calc(var(--header-height) + 16px); }
.pdf-page .anchor { position: absolute; left: 0; width: 1px; height: 1px; scroll-margin-top: var(--header-height); pointer-events: none; }
svg.paper { display: block; width: 100%; height: auto; overflow: hidden; background: #212121; }
svg.paper text { white-space:pre; }
:focus-visible { outline: 2px solid #67adff; outline-offset: 2px; }
svg.paper a.figure { cursor: zoom-in; }

#lightbox[open] { display: grid; place-items: center; }
#lightbox {
  width: min(96vw, 1400px);
  max-width: none;
  max-height: 94vh;
  padding: 42px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #101620;
}
#lightbox::backdrop { background: rgba(0,0,0,.82); }
#lightbox-image { display: block; max-width: 100%; max-height: calc(94vh - 70px); object-fit: contain; }
#close-lightbox { position: absolute; top: 10px; right: 12px; border: 0; color: var(--ink); background: transparent; font-size: 22px; cursor: pointer; }

@media (max-width: 760px) {
  :root { --header-height: 54px; }
  .reader-header { left: 0; padding: 0 12px; gap: 10px; }
  #menu-toggle { display: inline-block; }
  #outline { top: var(--header-height); width: min(84vw, var(--nav-width)); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 8px 0 24px rgba(0,0,0,.3); }
  body.menu-open #outline { transform: translateX(0); }
  main#top { margin-left: 0; }
  #manual { width: 100%; margin:0; padding: 10px 0 48px; }
  .pdf-page { margin-bottom: 0; }
  body.menu-open::after { content: ""; position: fixed; z-index: 19; inset: var(--header-height) 0 0; background: rgba(0,0,0,.45); }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; }
  .reader-header, #outline { display: none !important; }
  main#top { margin: 0; padding: 0; }
  #manual { width: 100%; margin:0; padding: 0; background:white; }
  .pdf-page { margin: 0; break-after: page; page-break-after: always; }
  .pdf-page:last-child { break-after: auto; page-break-after: auto; }
  svg.paper { background: #fff; }
  .paper text { fill:#252525; }
  .paper text[fill="#f2f2f2"] { fill:white; }
  .paper rect[fill="#303236"] { fill:#edefef; }
  .paper rect[fill="#493d23"] { fill:#fff5d9; }
  .paper rect[fill="#293f30"] { fill:#e5f3e8; }
  #lightbox { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
