:root {
  --bg: #f8f6f2;
  --panel: #fffdf8;
  --text: #1f2426;
  --muted: #5a676b;
  --line: #d9d2c4;
  --accent: #c54117;
  --accent-soft: #f6d9cf;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  --sans: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

.layout-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 500px at 10% -10%, #f4e4d6 0%, rgba(244, 228, 214, 0) 70%),
    radial-gradient(900px 500px at 100% 0%, #dde8ec 0%, rgba(221, 232, 236, 0) 65%);
  z-index: -1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  background: rgba(248, 246, 242, 0.85);
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.85rem 1.2rem;
}

.menu-btn {
  display: none;
  font-size: 1.1rem;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
}

.brand h1 {
  font-size: 1.15rem;
  margin: 0;
  line-height: 1.2;
}

.brand-kicker {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.topbar-meta {
  display: flex;
  gap: 0.55rem;
}

.pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  min-height: calc(100vh - 65px);
}

.sidebar,
.toc {
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.8);
}

.toc {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.sidebar-inner,
.toc-inner {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 1rem;
}

.search-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  margin-bottom: 0.85rem;
  background: #fff;
}

.doc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.doc-link {
  display: block;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.58rem 0.62rem;
  text-decoration: none;
  color: var(--text);
}

.doc-link small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

.doc-link:hover {
  background: #fff;
  border-color: var(--line);
}

.doc-link.active {
  background: var(--accent-soft);
  border-color: #f0b29e;
}

.main {
  padding: 1.4rem 2rem 3.2rem;
}

.doc-article {
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.3rem 1.6rem 1.6rem;
  box-shadow: 0 20px 44px rgba(48, 43, 37, 0.06);
}

.section-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

#docTitle {
  margin: 0.3rem 0 0.6rem;
  font-size: 1.55rem;
  font-family: var(--serif);
}

.doc-summary {
  margin: 0 0 1rem;
  color: var(--muted);
  max-width: 68ch;
}

.md-body {
  line-height: 1.6;
}

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  font-family: var(--serif);
  line-height: 1.25;
  margin-top: 1.5rem;
  scroll-margin-top: 88px;
}

.md-body h1 {
  font-size: 1.6rem;
}

.md-body h2 {
  font-size: 1.3rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35rem;
}

.md-body h3 {
  font-size: 1.08rem;
}

.md-body p,
.md-body li {
  max-width: 72ch;
}

.md-body a {
  color: var(--accent);
}

.md-body code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #f3eee6;
  padding: 0.15rem 0.35rem;
  border-radius: 5px;
}

.md-body pre {
  background: #221d19;
  color: #f4efe8;
  border-radius: 10px;
  overflow-x: auto;
  padding: 0.85rem;
}

.md-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.md-body blockquote {
  margin: 0.8rem 0;
  border-left: 4px solid #e6b8aa;
  background: #fdf1ed;
  padding: 0.35rem 0.8rem;
  color: #5f4a43;
}

.md-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.md-body th,
.md-body td {
  border: 1px solid var(--line);
  padding: 0.48rem 0.52rem;
  text-align: left;
  vertical-align: top;
}

.md-body th {
  background: #f4efe6;
}

.doc-pagination {
  border-top: 1px solid var(--line);
  margin-top: 1.3rem;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
}

.doc-pagination button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font-family: var(--sans);
  cursor: pointer;
}

.doc-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toc-inner h3 {
  margin-top: 0;
  font-size: 0.95rem;
}

#tocNav {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

#tocNav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 7px;
  padding: 0.28rem 0.38rem;
}

#tocNav a:hover,
#tocNav a.active {
  color: var(--text);
  background: #f2eee6;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-meta {
    display: none;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 65px auto 0 0;
    width: min(88vw, 320px);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    z-index: 12;
    border-right: 1px solid var(--line);
    box-shadow: 20px 0 38px rgba(20, 20, 20, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 1rem 0.8rem 2.5rem;
  }

  .doc-article {
    padding: 1rem;
  }
}
