/* Instrument Serif (SIL Open Font License), self-hosted from ./fonts */
@font-face { font-family: 'Instrument Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/instrument-serif-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Instrument Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/instrument-serif-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/instrument-serif-italic-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/instrument-serif-italic-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: rgb(250, 250, 242);
  --bg-alt: rgb(246, 246, 238);
  --bg-2: rgb(238, 238, 232);
  --text: rgb(62, 44, 27);
  --muted: #5c5c5c;
  --faint: #ababab;
  --accent: #c45d3e;
  --border: rgba(62, 44, 27, 0.12);
  --surface: #fff;
  --guide: rgba(66, 76, 87, 0.25);
  --mark: rgba(196, 93, 62, .18);
  --outline-idle: #948b7e;
  color-scheme: light;
  --serif: 'Times New Roman', Times, serif;
  --display: 'Instrument Serif', 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* Dark palette: follows the OS unless the toggle picked a theme (stored in localStorage). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1b19; --bg-alt: #22211e; --bg-2: #2d2b27; --text: #e3ded4; --muted: #a59f95; --faint: #6e685f;
    --accent: #e0805f; --border: rgba(255, 255, 255, 0.09); --surface: #262420; --guide: rgba(255, 255, 255, 0.16);
    --mark: rgba(224, 128, 95, .3); --outline-idle: #8a8378; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1b19; --bg-alt: #22211e; --bg-2: #2d2b27; --text: #e3ded4; --muted: #a59f95; --faint: #6e685f;
  --accent: #e0805f; --border: rgba(255, 255, 255, 0.09); --surface: #262420; --guide: rgba(255, 255, 255, 0.16);
  --mark: rgba(224, 128, 95, .3); --outline-idle: #8a8378; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .2s ease; }
a:hover { border-bottom-color: var(--accent); }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; min-height: 100vh; }
.left {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 32px 14px 32px 14px;
  font-size: 14px; line-height: 1.3;
}
.center { padding: 24px 40px 80px; min-width: 0; }
.center article { max-width: 700px; margin: 0 auto; }
.right { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 24px 24px 32px; font-size: 14px; line-height: 1.3; }

/* ---------- left column */
.left-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.site-name { font-family: var(--display); font-size: 1.4em; color: var(--text); }
.site-name:hover { border-bottom-color: transparent; }
.menu-toggle { display: none; background: none; border: 0; font-size: 20px; color: var(--text); cursor: pointer; padding: 4px 8px; }

/* Theme toggle: pill with a sliding knob, sun (light) or moon (dark) on the free side */
.theme-toggle {
  position: relative; display: block; width: 40px; height: 22px; padding: 0; margin: 0 0 16px 4px; cursor: pointer;
  background: var(--bg); border: 0; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted);
}
.theme-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); transition: transform .2s ease;
}
.theme-toggle svg { position: absolute; top: 4px; width: 14px; height: 14px; }
.theme-toggle .sun { right: 4px; }
.theme-toggle .moon { left: 4px; display: none; }
[data-theme="dark"] .theme-toggle::after { transform: translateX(18px); }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.search { position: relative; margin-bottom: 16px; }
.search input {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235c5c5c' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 8px 50%;
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px 7px 32px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--faint); }
.search-results { list-style: none; margin: 8px 0 0; padding: 0; }
.search-results li a { display: block; padding: 6px 8px; border-radius: 4px; color: var(--text); border: 0; }
.search-results li a:hover, .search-results li a.sel { background: var(--bg-2); }
.search-results li a:hover .r-sub, .search-results li a.sel .r-sub { color: var(--text); }
.search-results .r-title { display: block; }
.search-results .r-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; }
.search-results .empty { color: var(--muted); padding: 6px 8px; }
.sidebar.searching .tree { display: none; }

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; margin-left: 6px; border-left: 1px solid var(--border); }
.tree li a, .tree summary { display: block; padding: 6px 6px 6px 18px; border-radius: 4px; color: var(--text); border: 0; cursor: pointer; }
.tree ul ul li a { padding-left: 8px; }
.tree li a:hover, .tree summary:hover { background: var(--bg-2); }
.tree li a.active { color: var(--accent); }
.tree summary { list-style: none; position: relative; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: ''; position: absolute; left: 5px; top: 50%; width: 5px; height: 5px;
  border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
  transform: translateY(-65%) rotate(-45deg); transition: transform .15s ease;
}
.tree details[open] > summary::before { transform: translateY(-75%) rotate(45deg); }

/* ---------- article */
.page-title { font-family: var(--display); font-weight: normal; font-size: 2.6em; line-height: 1.2; margin: 0.4em 0 0.8em; }
article h1, article h2, article h3, article h4, article h5, article h6 { font-weight: normal; line-height: 1.25; margin: 1.4em 0 0.5em; }
article h1 { font-family: var(--display); font-size: 1.8em; }
article h2 { font-family: var(--display); font-style: italic; font-size: 1.55em; }
article h3 { font-family: var(--display); font-size: 1.3em; }
article h4 { font-size: 1.12em; font-weight: bold; }
article h5, article h6 { font-size: 1em; font-weight: bold; }
article p { margin: 0 0 1em; }
article ul, article ol { padding-left: 1.6em; margin: 0 0 1em; }
article li { margin: 0.25em 0; }
article li > ul, article li > ol { margin: 0.25em 0; }
article ul ul { position: relative; }
article ul ul::before { content: ''; position: absolute; left: -11px; top: 0; bottom: 0; border-left: 1px solid var(--guide); }
article li::marker { color: var(--faint); }
article img, article video { max-width: 100%; height: auto; border-radius: 4px; display: block; margin: 0.6em 0; }
article li img { display: inline-block; vertical-align: top; }
article blockquote { margin: 0 0 1em; padding: 0 0 0 1em; border-left: 2px solid var(--accent); color: var(--muted); }
article hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
article code { font-family: var(--mono); font-size: 0.85em; background: var(--surface); padding: 0.1em 0.3em; border-radius: 4px; }
article pre { background: var(--surface); padding: 1em; border-radius: 6px; overflow-x: auto; line-height: 1.45; border: 1px solid var(--border); }
article pre code { padding: 0; font-size: 0.82em; background: none; }
article table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; max-width: 100%; }
article th, article td { border: 1px solid var(--border); padding: 4px 10px; text-align: left; vertical-align: top; }
article th { background: var(--bg-alt); font-weight: bold; }
article aside { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; padding: 0.8em 1em; margin: 0 0 1em; }
article .unresolved { color: var(--muted); }
article input[type=checkbox] { margin-right: 0.4em; }

.post-sep { border: 0; border-top: 1px solid var(--border); max-width: 700px; margin: 5em auto 2em; }

/* ---------- right column outline */
.outline-title { font-family: var(--display); font-size: 1.35em; color: var(--text); margin: 0 0 10px; }
.outline ul { list-style: none; margin: 0; padding: 0; }
.outline li a { display: block; padding: 4px 8px; margin-left: -8px; border-radius: 4px; color: var(--outline-idle); border: 0; transition: color .15s ease, background-color .15s ease; }
.outline li a.current { color: var(--text); }
.outline li a:hover { color: var(--text); background: var(--bg-2); }
.outline .d2 { padding-left: 12px; } .outline .d3 { padding-left: 24px; }
.outline .d4, .outline .d5, .outline .d6 { padding-left: 36px; }

/* ---------- responsive */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr) 220px; }
  .center { padding: 24px 28px 80px; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .right { display: none; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .left { position: sticky; z-index: 10; height: auto; max-height: 100vh; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; background: var(--bg); }
  .left-top { margin-bottom: 0; }
  .menu-toggle { display: block; }
  .sidebar { display: none; padding-top: 16px; }
  .left.open .sidebar { display: block; }
  .center { padding: 8px 16px 64px; }
  .page-title { font-size: 2.2em; }
}
