:root {
  --left-column: clamp(280px, 24.9vw, 360px);
  --right-column: clamp(240px, 20.84vw, 300px);
  --page-bg: #f6f8fb;
  --sidebar-bg: #ffffff;
  --text: #1f2937;
  --text-muted: #596982;
  --text-faint: #8b96a8;
  --border: #d9e2ef;
  --border-soft: #e8edf4;
  --accent: #7c4dff;
  --accent-soft: rgba(124, 77, 255, 0.12);
  --callout-bg: #eef8ff;
  --callout-border: #03a6ff;
  --table-head: #e1e4e8;
  --table-row-alt: rgba(218, 225, 235, 0.32);
  --code-bg: #edf1f6;
  --scroll-thumb: #a9bbcf;
  --theme-color: #7c4dff;
}

:root[data-theme="dark"] {
  --page-bg: #20242c;
  --sidebar-bg: #181c22;
  --text: #e5e9f0;
  --text-muted: #aab4c3;
  --text-faint: #788495;
  --border: #39414e;
  --border-soft: #303744;
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.14);
  --callout-bg: #1d3442;
  --callout-border: #38bdf8;
  --table-head: #353c47;
  --table-row-alt: rgba(255, 255, 255, 0.025);
  --code-bg: #2b313b;
  --scroll-thumb: #607086;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  background: var(--page-bg);
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.3;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.loading-state {
  padding-top: 40vh;
  color: var(--text-muted);
  text-align: center;
}

/* Left vault tree */
body .sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: var(--left-column);
  padding: 32px 0 52px 18px;
  overflow: hidden auto;
  overscroll-behavior: contain;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  transition: transform 180ms ease;
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar,
.content::-webkit-scrollbar,
.outline-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb,
.outline-nav::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
}

.app-name {
  position: static;
  margin: 0 18px 0 0;
  padding: 0;
}

.app-name-link {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.site-brand {
  display: block;
}

.site-brand img {
  display: block;
  width: min(240px, 100%);
  height: auto;
  max-height: 55px;
  object-fit: contain;
  object-position: left center;
  border: 0;
  border-radius: 7px;
}

.site-brand > span {
  display: block;
  margin-top: 18px;
  font-size: 21px;
  font-weight: 720;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.site-theme-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  margin: 30px 18px 10px 0;
}

.site-theme-toggle > img {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  opacity: 0.9;
}

.theme-switch {
  position: relative;
  width: 50px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  background: var(--border);
  border: 0;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--border);
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(22, 28, 37, 0.22);
  transition: transform 160ms ease;
}

:root[data-theme="dark"] .theme-switch-knob {
  transform: translateX(28px);
}

.sidebar .search {
  margin: 0 18px 10px 0;
  padding: 0;
  border: 0;
}

.sidebar .search input[type="search"] {
  width: 100%;
  height: 33px;
  padding: 6px 10px 6px 31px;
  color: var(--text);
  font-size: 14px;
  background-color: transparent;
  background-image: url("search.svg");
  background-repeat: no-repeat;
  background-position: 8px center;
  background-size: 16px 16px;
  border: 1px solid var(--border);
  border-radius: 5px;
  outline: none;
}

.sidebar .search input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sidebar .search .clear-button {
  align-items: center;
  justify-content: center;
}

.sidebar .search .results-panel {
  margin: 8px 0 14px;
  padding: 4px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.sidebar .search .matching-post {
  border-bottom: 1px solid var(--border-soft);
}

.sidebar .search a {
  display: block;
  padding: 7px 8px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.sidebar .search-keyword {
  color: var(--accent);
  font-weight: 700;
}

.sidebar-nav {
  padding: 0 18px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.sidebar-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-nav ul ul {
  margin-left: 12px;
  padding-left: 11px;
  border-left: 1px solid var(--border);
}

.sidebar-nav li {
  position: relative;
  margin: 0;
}

.sidebar-nav a,
.sidebar-nav li.tree-folder > strong,
.sidebar-nav li.tree-folder > p > strong {
  display: block;
  min-height: 31px;
  padding: 6px 5px 6px 18px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 19px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 4px;
}

.sidebar-nav li.tree-folder > p {
  margin: 0;
}

.sidebar-nav li.tree-folder > strong,
.sidebar-nav li.tree-folder > p > strong {
  cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav li.tree-folder > strong:hover,
.sidebar-nav li.tree-folder > p > strong:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-nav a.active {
  color: var(--accent);
  font-weight: 500;
  background: transparent;
  box-shadow: inset 1px 0 0 var(--accent);
  border-radius: 0;
}

.tree-caret {
  position: absolute;
  z-index: 2;
  top: 5px;
  left: 0;
  width: 19px;
  height: 21px;
  padding: 4px;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 3px;
}

.tree-caret:hover {
  background: var(--accent-soft);
}

.tree-caret img {
  display: block;
  width: 11px;
  height: 11px;
  color: var(--text-faint);
  transform: rotate(-90deg);
  transition: transform 140ms ease;
}

.tree-expanded > .tree-caret img {
  transform: rotate(0deg);
}

.tree-collapsed > ul {
  display: none !important;
}

/* Center document */
.content {
  position: fixed;
  z-index: 1;
  inset: 0 var(--right-column) 0 var(--left-column);
  margin: 0;
  padding: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  background: var(--page-bg);
  transition: left 180ms ease;
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
}

.markdown-section {
  width: 100%;
  max-width: 766px;
  min-height: 100%;
  margin: 0;
  padding: 68px 34px 96px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: break-word;
}

.markdown-section > :first-child {
  margin-top: 10px;
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4,
.markdown-section h5,
.markdown-section h6 {
  color: var(--text);
  font-weight: 680;
  line-height: 1.2;
  letter-spacing: -0.025em;
  scroll-margin-top: 30px;
}

.markdown-section h1 {
  margin: 10px 0 19px;
  padding: 0 0 16px;
  font-size: 41.6px;
  font-weight: 720;
  border-bottom: 1px solid var(--border);
}

.markdown-section h2 {
  margin: 40px 0 12px;
  padding: 0 0 11px;
  font-size: 22.72px;
  border-bottom: 1px solid var(--border);
}

.markdown-section h3 {
  margin: 30px 0 8px;
  font-size: 20.5px;
}

.markdown-section h4 {
  margin: 24px 0 5px;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.markdown-section h5,
.markdown-section h6 {
  margin: 22px 0 5px;
  font-size: 17px;
}

.markdown-section p {
  margin: 16px 0;
}

.markdown-section a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-section a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-section a.anchor {
  color: inherit;
}

.markdown-section blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  color: var(--text);
  background: var(--callout-bg);
  border-left: 4px solid var(--callout-border);
}

.markdown-section blockquote p {
  margin: 0;
}

.markdown-section ul,
.markdown-section ol {
  margin: 12px 0;
  padding-left: 28px;
}

.markdown-section li {
  margin: 4px 0;
}

.markdown-section hr {
  margin: 34px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.markdown-section code {
  padding: 2px 5px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 4px;
}

.markdown-section pre {
  margin: 18px 0;
  padding: 14px 16px;
  overflow: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.markdown-section pre code {
  padding: 0;
  background: transparent;
}

.markdown-section table {
  display: table;
  width: 100%;
  margin: 16px 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15.2px;
  line-height: 1.3;
  border-spacing: 0;
  border-collapse: collapse;
  background: var(--sidebar-bg);
}

.markdown-section th,
.markdown-section td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--border);
}

.markdown-section th {
  color: var(--text);
  font-size: 16px;
  font-weight: 680;
  background: var(--table-head);
}

.markdown-section tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

.markdown-section img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.markdown-section img[src*="Publish%20Assets"],
.markdown-section img[src*="Publish Assets"] {
  border: 0;
}

.markdown-section iframe,
.markdown-section video,
.markdown-section .responsive-media {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 18px 0;
  background: #000;
  border: 0;
  border-radius: 6px;
}

.markdown-section .attachment-download {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 4px 0;
  padding: 6px 12px;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
}

/* Right in-page outline */
.outline-panel {
  position: fixed;
  z-index: 20;
  inset: 0 0 0 auto;
  width: var(--right-column);
  padding: 32px 24px 58px;
  overflow: hidden;
  color: var(--text-muted);
  background: var(--page-bg);
}

.outline-title {
  margin-bottom: 11px;
  padding-bottom: 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.025em;
  border-bottom: 1px solid var(--border);
}

.outline-nav {
  height: calc(100% - 38px);
  overflow: hidden auto;
  padding-right: 5px;
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
}

.outline-link {
  display: block;
  width: 100%;
  padding: 5px 8px 5px 11px;
  cursor: pointer;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.25;
  text-align: left;
  text-overflow: ellipsis;
  background: transparent;
  border: 0;
  border-left: 1px solid transparent;
}

.outline-link:hover,
.outline-link.active {
  color: var(--accent);
}

.outline-link.level-1,
.outline-link.level-2,
.outline-link.level-3 {
  border-left-color: var(--border);
}

.outline-link.level-1 { padding-left: 29px; }
.outline-link.level-2 { padding-left: 45px; }
.outline-link.level-3 { padding-left: 61px; }

.powered-by {
  position: fixed;
  z-index: 25;
  right: 19px;
  bottom: 17px;
  color: var(--text-faint);
  font-size: 12px;
  text-decoration: none;
}

.powered-by:hover {
  color: var(--accent);
}

.desktop-sidebar-toggle {
  position: fixed;
  z-index: 60;
  bottom: 0;
  left: calc(var(--left-column) - 35px);
  width: 27px;
  height: 18px;
  padding: 2px 6px;
  cursor: pointer;
  background: #ecf8ff;
  border: 1px solid #9edcff;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  transition: left 180ms ease;
}

.desktop-sidebar-toggle img {
  display: block;
  width: 13px;
  height: 13px;
  color: #03a6ff;
  transform: rotate(90deg);
}

body.nav-collapsed .sidebar {
  transform: translateX(-100%);
}

body.nav-collapsed .content {
  left: 0;
}

body.nav-collapsed .desktop-sidebar-toggle {
  left: 0;
}

body.nav-collapsed .desktop-sidebar-toggle img {
  transform: rotate(-90deg);
}

.mobile-site-header,
.nav-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  :root {
    --left-column: clamp(280px, 30vw, 320px);
    --right-column: 0px;
  }

  .outline-panel,
  .powered-by {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --left-column: min(390px, 100vw);
  }

  .mobile-site-header {
    position: fixed;
    z-index: 80;
    inset: 0 0 auto 0;
    display: grid;
    grid-template-columns: 50px 185px minmax(0, 1fr);
    align-items: center;
    height: 50px;
    color: var(--text);
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
  }

  .mobile-nav-trigger {
    display: grid;
    width: 50px;
    height: 50px;
    padding: 0;
    cursor: pointer;
    place-items: center;
    background: transparent;
    border: 0;
  }

  .mobile-nav-trigger img {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
  }

  .mobile-brand-image {
    align-self: center;
    height: 44px;
    overflow: hidden;
    border-radius: 6px;
  }

  .mobile-brand-image img {
    display: block;
    width: 167px;
    height: 38px;
    margin-top: 3px;
    object-fit: contain;
    object-position: left center;
  }

  .mobile-brand-title {
    align-self: center;
    max-height: 48px;
    padding: 0 8px 0 0;
    overflow: hidden;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.28;
    text-decoration: none;
  }

  body .sidebar {
    top: 50px;
    height: calc(100vh - 50px);
    padding: 30px 18px 48px;
    transform: translateX(-100%);
    border-right: 0;
    box-shadow: none;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 34px rgba(24, 31, 42, 0.18);
  }

  .sidebar .app-name {
    display: none;
  }

  .site-theme-toggle {
    margin: 0 0 9px;
  }

  .sidebar .search {
    margin: 0 0 10px;
  }

  .sidebar-nav {
    padding-right: 0;
  }

  .nav-backdrop {
    position: fixed;
    z-index: 35;
    inset: 50px 0 0 0;
    width: 100%;
    height: calc(100% - 50px);
    padding: 0;
    background: rgba(14, 20, 28, 0.18);
    border: 0;
  }

  body.nav-open .nav-backdrop {
    display: block;
  }

  .content,
  body.nav-collapsed .content {
    inset: 50px 0 0 0;
  }

  .markdown-section {
    max-width: none;
    padding: 68px 18px 78px;
    font-size: 16px;
    line-height: 1.72;
  }

  .markdown-section h1 {
    margin: 11px 0 19px;
    padding-bottom: 27px;
    font-size: 37px;
    line-height: 1.15;
  }

  .markdown-section h2 {
    font-size: 25px;
  }

  .markdown-section table {
    display: block;
    overflow-x: auto;
    white-space: normal;
  }

  .markdown-section th,
  .markdown-section td {
    min-width: 120px;
  }

  .desktop-sidebar-toggle,
  .sidebar-toggle,
  .outline-panel,
  .powered-by {
    display: none !important;
  }
}

@media (max-width: 380px) {
  .mobile-site-header {
    grid-template-columns: 48px 162px minmax(0, 1fr);
  }

  .mobile-brand-image img {
    width: 150px;
  }

  .mobile-brand-title {
    font-size: 16px;
  }
}

@media print {
  body {
    overflow: visible;
    background: #fff;
  }

  .sidebar,
  .outline-panel,
  .mobile-site-header,
  .desktop-sidebar-toggle,
  .powered-by,
  .nav-backdrop {
    display: none !important;
  }

  .content {
    position: static;
    overflow: visible;
  }

  .markdown-section {
    max-width: none;
    padding: 0;
  }
}
