:root {
  --ink: #1c2434;
  --muted: #5c6778;
  --line: #e3e7ee;
  --paper: #fbfbfc;
  --sidebar: #f3f5f8;
  --selected: #e7ebf2;
  --navy: #1e2540;
  --link: #1f6feb;
  --code: #f0f3f7;
  --warn: #8a5a12;
  --warn-bg: #fff6e8;
  --shadow: 0 18px 50px rgba(22, 28, 45, 0.16);
  --sidebar-w: 292px;
  --toc-w: 220px;
  --serif: "Iowan Old Style", Palatino, "Songti SC", "Noto Serif SC", serif;
  --sans: "SF Pro Text", "PingFang SC", "Hiragino Sans", "Hiragino Sans GB", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "Source Code Pro", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.7;
}

button, input { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  min-height: 100vh;
}

.topbar {
  display: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 8px;
  text-decoration: none;
  color: var(--navy);
}
.brand:hover { text-decoration: none; }
.mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}
.brand strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}
.brand span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: -2px;
}
.langs { display: block; margin: 4px 14px 0; }
.lang-menu {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
}

.search-btn {
  margin: 8px 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.search-btn kbd {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--paper);
}

.nav {
  overflow: auto;
  padding: 4px 10px 28px;
}
.nav-section {
  margin: 16px 8px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b95a5;
}
.nav a.item {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  text-decoration: none;
}
.nav a.item:hover { background: rgba(255,255,255,0.7); }
.nav a.item.active {
  background: var(--selected);
  font-weight: 600;
}

.main {
  margin-left: var(--sidebar-w);
  display: grid;
  grid-template-columns: minmax(0, 760px) var(--toc-w);
  justify-content: center;
  gap: 36px;
  padding: 42px 40px 80px;
}

article h1 {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.lede {
  font-size: 18px;
  color: #3d4656;
  margin: 0 0 28px;
}
article h2 {
  font-size: 22px;
  line-height: 1.3;
  margin: 36px 0 10px;
  scroll-margin-top: 18px;
}
article h3 {
  font-size: 17px;
  margin: 24px 0 8px;
}
article p { margin: 0 0 14px; }
article ul, article ol { margin: 0 0 16px; padding-left: 1.3em; }
article li { margin: 4px 0; }
article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}
article blockquote {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border-left: 3px solid #e0b15a;
  color: #4d3b1e;
  border-radius: 0 8px 8px 0;
}
article blockquote p:last-child { margin: 0; }
article code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
article pre {
  background: #171c28;
  color: #e8edf5;
  padding: 14px 16px;
  border-radius: 10px;
  overflow: auto;
  margin: 0 0 16px;
}
article pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
}
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 14.5px;
}
article th, article td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px 10px;
  vertical-align: top;
}
article th { font-size: 12px; color: var(--muted); font-weight: 650; }
.crumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.pager a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ink);
  max-width: 46%;
}
.pager a.next { margin-left: auto; text-align: right; }
.pager small { color: var(--muted); font-size: 12px; }
.pager strong { font-weight: 600; }
.pager a:hover strong { color: var(--link); }

.toc {
  position: sticky;
  top: 28px;
  align-self: start;
  font-size: 13px;
}
.toc p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0 4px 10px;
  border-left: 2px solid var(--line);
  line-height: 1.4;
}
.toc a:hover, .toc a.active {
  color: var(--ink);
  border-left-color: var(--navy);
}

.menu-btn, .backdrop { display: none; }

.search-layer {
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 34, 0.38);
  z-index: 40;
  display: flex;
  justify-content: center;
  padding-top: 12vh;
}
.search-panel {
  width: min(640px, calc(100vw - 32px));
  background: white;
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.search-panel input {
  border: 0;
  outline: none;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.results { overflow: auto; padding: 6px; }
.result {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.result.active, .result:hover { background: var(--sidebar); }
.result b { display: block; font-weight: 600; }
.result em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
}
.empty-search { color: var(--muted); padding: 16px; }

@media (max-width: 1080px) {
  .main { grid-template-columns: minmax(0, 760px); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 72px 20px 64px; }
  .menu-btn {
    display: grid;
    place-items: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 30;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: white;
    cursor: pointer;
  }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(18, 22, 34, 0.35);
    z-index: 15;
  }
  article h1 { font-size: 32px; }
}
