:root {
  --accent: #10b981;
  --accent-dark: #059669;
  --text: #111827;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --border: #e5e7eb;
  --note-bg: #fef3c7;
  --note-border: #f59e0b;
  --tip-bg: #d1fae5;
  --tip-border: #10b981;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; }
body.manual {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "topbar topbar topbar" "sidebar content toc";
  min-height: 100vh;
}
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .ver { margin-left: auto; color: var(--text-muted); font-size: 13px; }
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 18px;
}
.menu-toggle:hover { background: #f3f4f6; }
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  background: var(--bg);
  z-index: 40;
}
.sidebar ol { list-style: none; padding: 0; margin: 0; counter-reset: chap; }
.sidebar li { counter-increment: chap; margin: 4px 0; }
.sidebar a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.sidebar a::before { content: counter(chap, decimal-leading-zero) ". "; color: var(--text-muted); }
.sidebar a:hover { background: #f3f4f6; }
.sidebar a.active { background: var(--accent); color: white; }
.sidebar a.active::before { color: rgba(255,255,255,.85); }
.content {
  grid-area: content;
  padding: 32px 48px 64px;
  max-width: 880px;
  min-width: 0;
}
.content h1 { font-size: 32px; font-weight: 700; margin: 0 0 16px; line-height: 1.2; }
.content h2 { font-size: 24px; font-weight: 600; margin: 40px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); line-height: 1.3; }
.content h3 { font-size: 18px; font-weight: 600; margin: 28px 0 12px; }
.content p { margin: 12px 0; }
.content a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.content code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; word-break: break-word; }
.content pre {
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  margin: 16px 0;
}
.content pre code { background: transparent; padding: 0; }
.content table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  white-space: normal;
}
.shot { margin: 24px 0; }
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: zoom-in;
}
.shot figcaption {
  margin-top: 8px;
  font-style: italic;
  font-size: 14px;
  color: var(--text-muted);
}
.callout {
  border-left: 4px solid var(--note-border);
  background: var(--note-bg);
  padding: 12px 16px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}
.callout-tip { border-left-color: var(--tip-border); background: var(--tip-bg); }
.toc {
  grid-area: toc;
  padding: 32px 16px;
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  font-size: 13px;
}
.toc h4 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 12px; letter-spacing: 0.5px; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 6px 0; }
.toc a { color: var(--text-muted); text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--accent-dark); }
.pager {
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}
.pager a { font-size: 14px; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
  padding: 16px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 95vh; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0,0,0,0.4);
  z-index: 30;
}
.sidebar-backdrop.open { display: block; }

/* Tablet */
@media (max-width: 1024px) {
  body.manual {
    grid-template-columns: 220px 1fr;
    grid-template-areas: "topbar topbar" "sidebar content";
  }
  .toc { display: none; }
  .content { padding: 24px 32px 48px; }
}

/* Mobile */
@media (max-width: 768px) {
  body.manual {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "content";
  }
  .menu-toggle { display: inline-flex; }
  .topbar h1 { font-size: 14px; }
  .topbar .ver { font-size: 12px; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 280px;
    max-width: 80vw;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    padding: 20px 16px 48px;
    max-width: 100%;
  }
  .content h1 { font-size: 26px; }
  .content h2 { font-size: 20px; margin-top: 32px; }
  .content h3 { font-size: 16px; }
  .content p, .content li { font-size: 15px; }
  .shot figcaption { font-size: 13px; }
  .pager { flex-direction: column; }
  .pager a { width: 100%; padding: 8px 0; }
  .pager a:last-child { text-align: right; }
}

/* Print — for boss to print/PDF the manual */
@media print {
  .sidebar, .toc, .topbar, .menu-toggle, .pager, .sidebar-backdrop, .lightbox { display: none !important; }
  body.manual { display: block; }
  .content { padding: 0; max-width: 100%; }
  .shot img { box-shadow: none; }
  .shot { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
}
