body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background-color: white;
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact;
}

/* Layout: sidebar + content */
#layout {
  display: flex;
  min-height: 100vh;
}

#content {
  max-width: 854px;
  margin: 0 auto;
  padding: 30px;
  flex: 1;
  min-width: 0;
}

/* Links */
a { color: #4183C4; }
a.absent { color: #cc0000; }

/* Headings */
h1, h2, h3, h4, h5, h6 {
  margin: 20px 0 10px;
  padding: 0;
  font-weight: bold;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

h1 { font-size: 28px; color: black; }
h2 { font-size: 24px; border-bottom: 1px solid #ccc; color: black; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }
h6 { color: #777; font-size: 14px; }

h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code,
h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
  font-size: inherit;
}

/* Block elements */
p, blockquote, ul, ol, dl, li, table, pre {
  margin: 15px 0;
}

hr {
  border: 0 none;
  color: #ccc;
  height: 4px;
  padding: 0;
}

/* Lists */
li { margin: 0; }
ul, ol { padding-left: 30px; }
ul :first-child, ol :first-child { margin-top: 0; }
li > p { margin-bottom: 0; }
ul, li > ul { margin-top: 0; margin-bottom: 0; }

/* Definition lists */
dl { padding: 0; }
dl dt {
  font-size: 14px;
  font-weight: bold;
  font-style: italic;
  padding: 0;
  margin: 15px 0 5px;
}
dl dt:first-child { padding: 0; }
dl dt > :first-child { margin-top: 0; }
dl dt > :last-child { margin-bottom: 0; }
dl dd { margin: 0 0 15px; padding: 0 15px; }
dl dd > :first-child { margin-top: 0; }
dl dd > :last-child { margin-bottom: 0; }

/* Blockquotes */
blockquote {
  border-left: 4px solid #ddd;
  padding: 0 15px;
  color: #777;
}
blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }

/* Tables */
table { padding: 0; border-collapse: collapse; }
table tr {
  border-top: 1px solid #ccc;
  background-color: white;
  margin: 0;
  padding: 0;
}
table tr:nth-child(2n) { background-color: #f8f8f8; }
table tr th {
  font-weight: bold;
  border: 1px solid #ccc;
  margin: 0;
  padding: 6px 13px;
}
table tr td {
  border: 1px solid #ccc;
  margin: 0;
  padding: 6px 13px;
}
table tr th :first-child, table tr td :first-child { margin-top: 0; }
table tr th :last-child, table tr td :last-child { margin-bottom: 0; }

/* Images: flowing thumbnails */
#content img {
  max-width: 200px;
  max-height: 150px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 3px;
  margin: 4px 4px 4px 0;
  vertical-align: top;
  transition: opacity 0.15s;
}
#content img:hover {
  opacity: 0.8;
}

/* Lightbox overlay */
#lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  cursor: pointer;
  justify-content: center;
  align-items: center;
}
#lightbox.visible {
  display: flex;
}
#lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: none;
  border-radius: 0;
  cursor: default;
  margin: 0;
}

img { max-width: 100%; }

/* Code */
code, tt {
  margin: 0 2px;
  padding: 0 5px;
  white-space: nowrap;
  border: 1px solid #eaeaea;
  background-color: #f8f8f8;
  border-radius: 3px;
}
pre code {
  margin: 0;
  padding: 0;
  white-space: pre;
  border: none;
  background: transparent;
}
pre {
  background-color: #f8f8f8;
  border: 1px solid #ccc;
  font-size: 13px;
  line-height: 19px;
  overflow: auto;
  padding: 6px 10px;
  border-radius: 3px;
}
pre code, pre tt {
  background-color: transparent;
  border: none;
}

/* Superscript */
sup {
  font-size: 0.83em;
  vertical-align: super;
  line-height: 0;
}

/* TOC sidebar */
#toc {
  width: 260px;
  min-width: 260px;
  background: #f9f9f9;
  border-right: 1px solid #ddd;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  font-size: 13px;
}
#toc-inner {
  padding: 15px;
}
#toc > div > strong {
  display: block;
  margin-bottom: 10px;
  font-size: 16px;
}
#toc > div > strong a {
  color: black;
  text-decoration: none;
}
#toc hr {
  height: 1px;
  background: #ddd;
  margin: 10px 0;
}
#toc ul {
  margin: 3px 0;
  padding-left: 16px;
  list-style: none;
}
#toc > div > ul {
  padding-left: 0;
}
#toc li {
  margin: 2px 0;
  line-height: 1.4;
}
#toc a {
  color: #333;
  text-decoration: none;
}
#toc a:hover {
  color: #4183C4;
}
#toc a.active {
  color: #4183C4;
  font-weight: bold;
}

/* Page navigation in sidebar */
.page-nav {
  padding-left: 0 !important;
  margin: 8px 0 !important;
}
.page-nav li {
  margin: 4px 0;
}
.page-nav li a {
  font-size: 13px;
}
.page-nav li.active a {
  font-weight: bold;
  color: #4183C4;
}

/* TOC toggle */
.toc-toggle {
  cursor: pointer;
  display: inline-block;
  width: 14px;
  font-size: 10px;
  color: #999;
  user-select: none;
}
.toc-toggle:hover {
  color: #333;
}
li.collapsed > ul {
  display: none;
}

/* Mobile: hide sidebar, show TOC inline */
@media (max-width: 900px) {
  #layout {
    flex-direction: column;
  }
  #toc {
    width: auto;
    min-width: auto;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }
}

@media print {
  #toc { display: none; }
  #layout { display: block; }
  table, pre { page-break-inside: avoid; }
  pre { word-wrap: break-word; }
}
