:root {
  /* Night palette, adapted from the user's installed Typora theme.
     Fixed dark appearance; tune typography and colors here. */
  color-scheme: dark;
  --bg: #363b40;
  --text: #b8bfc6;
  --heading: #dedede;
  --sub: #adb4bc;
  --edge: #474d54;
  --panel: #2e3033;
  --active: #222222;
  --accent: #aaaaf5;
  --link: #e0e0e0;
  --selection: #4a89dc;
  --code-bg: #333333;
  --code-text: #b8bfc6;
  --code-comment: #da924a;
  --code-keyword: #c88fd0;
  --code-string: #df8585;
  --code-number: #64ab8f;
  --code-function: #aaaaf5;
  --code-type: #9fbad5;
  --code-inline: #cbd1d7;
  --body-size: 16px;
  --body-leading: 1.75;
  --content-width: 914px;
  --code-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--body-size)/var(--body-leading) "Helvetica Neue", Helvetica, Arial, "Microsoft YaHei", "Segoe UI Emoji", sans-serif;
}
::selection { background: var(--selection); color: #ffffff; }
html { scrollbar-color: #70757c var(--panel); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.site-header {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}
.site-header a { color: var(--text); font-size: 20px; font-weight: 700; }
.site-header span { font-size: 13px; color: var(--sub); }
.sidebar-toggle {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 20;
  padding: 9px 14px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel);
  color: var(--heading);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px #0003;
}
.sidebar-toggle:hover { background: var(--active); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body.sidebar-hidden .layout { grid-template-columns: minmax(0, 1fr); }
.layout {
  max-width: 1600px;
  margin: auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}
.sidebar {
  padding: 0;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar { border-right: 1px solid var(--edge); background: var(--panel); }
.sidebar-tabs {
  display: flex;
  flex: 0 0 auto;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--edge);
}
.sidebar-tabs button {
  flex: 1;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 4px;
  background: transparent;
  color: var(--sub);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.sidebar-tabs button:hover { color: var(--heading); }
.sidebar-tabs button[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--accent); }
.sidebar-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.sidebar-panel { min-height: 0; padding: 16px 14px 72px; overflow: auto; }
.outline-empty { color: var(--sub); font-size: 14px; padding: 0 12px; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar ul ul { padding-left: 12px; }
.sidebar a {
  display: block;
  padding: 6px 12px;
  border-left: 2px solid transparent;
  margin: 2px 0;
  border-radius: 6px;
  color: var(--sub);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.sidebar a:hover { background: var(--bg); color: var(--heading); text-decoration: none; }
.sidebar a.active { background: var(--active); color: var(--heading); border-left-color: var(--accent); font-weight: 600; }
.nav-section { margin: 14px 12px 5px; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.sidebar details { margin: 4px 0; }
.sidebar summary.nav-section {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::before {
  content: "\25B6";
  flex: 0 0 10px;
  font-size: 10px;
  color: var(--sub);
}
.sidebar details[open] > summary::before { content: "\25BC"; }
.sidebar summary:hover { background: var(--bg); color: var(--heading); }
.sidebar summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.outline > ul { padding-left: 0; }
.outline ul ul { padding-left: 14px; }
.content { min-width: 0; max-width: var(--content-width); width: 100%; margin: 0 auto; padding: 44px 48px 100px; }
.content :is(h1, h2, h3, h4, h5, h6) {
  color: var(--heading);
  font-family: "Lucida Grande", Corbel, "Microsoft YaHei", sans-serif;
  line-height: 1.4;
  scroll-margin-top: 24px;
  margin: 1.8em 0 .85em;
}
.content h1 { font-size: 2.5rem; font-weight: 400; margin-top: 0; }
.content h2 { font-size: 1.63rem; font-weight: 600; border: 0; padding: 0; }
.content h3 { font-size: 1.17rem; font-weight: 600; }
.content h4 { font-size: 1.12rem; font-weight: 400; }
.content h5, .content h6 { font-size: 1rem; }
.content p { margin: 0 0 1.5rem; }
.content :is(strong, th) { color: var(--heading); }
.content a { text-decoration: underline; text-underline-offset: 3px; }
.content a:hover { color: #ffffff; }
.content hr { height: 2px; border: 0; background: var(--edge); margin: 24px 0; }
.content ul { list-style-type: square; }

/* Map Pandoc tokens to Night colors, keeping readable contrast on #333. */
.content code, .content pre {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-variant-ligatures: none;
  tab-size: 4;
}
.content :not(pre) > code {
  padding: .15em .4em;
  border: 0;
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--code-inline);
  font-size: .9em;
  overflow-wrap: anywhere;
}
.content pre {
  margin: 1.5em 0;
  padding: 18px 24px;
  border: 0;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: var(--code-size);
  line-height: 1.7;
  overflow: auto;
  white-space: pre;
  overflow-wrap: normal;
}
.content pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: inherit;
}
.content div.sourceCode { margin: 1.5em 0; }
.content div.sourceCode pre { margin: 0; }
.content code.sourceCode > span { line-height: inherit; }
.content pre ::selection { background: var(--selection); color: #ffffff; }
.content .sourceCode :is(.kw, .cf, .im, .ot) { color: var(--code-keyword); }
.content .sourceCode :is(.st, .ch, .sc, .ss, .vs) { color: var(--code-string); }
.content .sourceCode :is(.dv, .bn, .fl, .cn) { color: var(--code-number); }
.content .sourceCode :is(.fu, .bu) { color: var(--code-function); }
.content .sourceCode :is(.dt, .at, .pp) { color: var(--code-type); }
.content .sourceCode :is(.co, .an, .cv, .do, .in, .wa) { color: var(--code-comment); font-style: normal; }
.content .sourceCode :is(.op, .ex, .va) { color: var(--code-text); }
.content .sourceCode :is(.al, .er) { color: var(--code-keyword); font-weight: 700; }

.content img { max-width: 100%; height: auto; }
.content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 15px; }
.content th, .content td { border: 1px solid var(--edge); padding: 9px 14px; }
.content th { background: var(--panel); text-align: left; }
.content tbody tr:nth-child(even) { background: var(--panel); }
.content blockquote { border-left: 2px solid var(--edge); padding-left: 24px; margin: 28px 0 28px 16px; color: var(--sub); }
.content .math.display { display: block; overflow-x: auto; padding: 8px 0; }
.page-index ul { padding-left: 24px; }
.page-index .nav-section { margin: 12px 0 4px; }
.skip-link { position: absolute; top: -100px; left: 16px; padding: 8px 16px; background: var(--bg); z-index: 10; }
.skip-link:focus { top: 8px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .layout { display: block; }
  .sidebar { position: static; max-height: 280px; border-right: 0; border-bottom: 1px solid var(--edge); }
  .content { padding: 24px 20px 60px; }
  .content pre { padding: 16px; }
  .site-header { padding: 0 20px; }
}
@media print {
  .site-header, .sidebar, .sidebar-toggle, .skip-link { display: none; }
  .layout { display: block; }
  .content pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
