:root {
  color-scheme: light;
  --primary: #9373ee;
  --primary-hover: #7a60c4;
  --primary-soft: #f3eefe;
  --primary-softer: #fbf9ff;
  --bg: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.84);
  --bg-muted: #f7f8fb;
  --text: #1f2430;
  --text-muted: #667085;
  --border: #eceef3;
  --border-strong: #dde1ea;
  --code-bg: #111827;
  --code-text: #e6edf3;
  --shadow: 0 16px 44px rgba(35, 26, 75, 0.08);
  --sidebar-width: 400px;
  --toc-width: 190px;
  --resizer-hit: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --primary: #8276c9;
  --primary-hover: #9c90d4;
  --primary-soft: #252333;
  --primary-softer: #1e1c28;
  --bg: #1a1922;
  --bg-panel: rgba(26, 25, 34, 0.82);
  --bg-muted: #211f2b;
  --text: #f3f1f9;
  --text-muted: #a7a2b8;
  --border: #302d3d;
  --border-strong: #454059;
  --code-bg: #0c111d;
  --code-text: #f1f5f9;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 63% -12%, rgba(147, 115, 238, 0.13), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  width: var(--sidebar-width);
  height: 100vh;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
}

.panel-resizer {
  position: relative;
  z-index: 25;
  flex: 0 0 var(--resizer-hit);
  width: var(--resizer-hit);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.panel-resizer::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  content: "";
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    width 0.16s ease;
}

.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.panel-resizer.is-dragging::before {
  width: 3px;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(147, 115, 238, 0.13);
}

.panel-resizer:focus-visible {
  outline: none;
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing iframe,
body.is-resizing pre,
body.is-resizing code,
body.is-resizing a {
  pointer-events: none;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 12px;
}

.brand {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 12px;
}

.brand strong {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo-mark {
  position: relative;
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  /*background: linear-gradient(135deg, #6c4cff, #58c7e8);*/
  color: #ffffff;
  font-weight: 700;
}

.logo-mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-mark span {
  position: relative;
}

.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--bg-muted);
  color: var(--text);
}

.theme-icon {
  position: relative;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: currentColor;
}

.theme-icon::before,
.theme-icon::after {
  position: absolute;
  content: "";
}

.theme-icon::before {
  inset: -4px;
  border: 2px dotted currentColor;
  border-radius: 50%;
}

[data-theme="dark"] .theme-icon::after {
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-panel);
}

.search-wrap {
  position: relative;
  margin: 10px 20px 0;
  color: var(--text-muted);
}

.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.search-wrap input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--bg-muted);
  color: var(--text);
  padding: 0 14px 0 40px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.search-wrap input:focus {
  border-color: rgba(147, 115, 238, 0.72);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(147, 115, 238, 0.14);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 20px 40px;
}

.nav-label {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.tree-node,
.tree-children a {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: left;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.tree-node {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 7px 10px;
  font-weight: 560;
}

.tree-node.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.tree-children {
  margin-top: 10px;
  padding-left: 12px;
}

.tree-children a {
  margin: 2px 0;
  padding: 6px 10px;
  font-size: 13px;
}

.tree-node:hover,
.tree-children a:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.empty-search {
  margin: 18px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.main-pane {
  height: 100vh;
  min-width: 0;
  flex: 1;
  overflow-y: auto;
}

.mobile-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: none;
  height: 54px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 0 14px;
  backdrop-filter: blur(16px);
}

.mobile-bar span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-layout {
  display: grid;
  width: min(1160px, 100%);
  min-height: 100vh;
  grid-template-columns: minmax(320px, 1fr) var(--resizer-hit) var(--toc-width);
  gap: 24px;
  margin: 0 auto;
  padding: 28px 40px 80px;
}

.doc-card {
  min-width: 0;
}

.doc-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 32px;
  font-weight: 650;
  line-height: 1.25;
}

.updated-at {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.copy-page {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 8px 0 0 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  white-space: nowrap;
  transition:
    border-color 0.18s ease,
    color 0.18s ease,
    background 0.18s ease;
}

.copy-page:hover {
  border-color: rgba(147, 115, 238, 0.78);
  color: var(--primary-hover);
}

.action-menu {
  width: 32px;
  height: 32px;
  border-color: var(--border-strong);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: var(--bg);
}

.mobile-copy {
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
}

.markdown-body {
  color: var(--text);
  font-size: 15px;
  line-height: 1.76;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  position: relative;
  scroll-margin-top: 26px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0;
}

.markdown-body h2 {
  margin: 34px 0 14px;
  font-size: 24px;
  line-height: 1.35;
}

.markdown-body h2:first-child {
  margin-top: 0;
}

.markdown-body h3 {
  margin: 26px 0 10px;
  font-size: 19px;
  line-height: 1.45;
}

.markdown-body h4 {
  margin: 23px 0 10px;
  font-size: 17px;
}

.markdown-body h5 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.markdown-body h2:hover::after,
.markdown-body h3:hover::after,
.markdown-body h4:hover::after,
.markdown-body h5:hover::after {
  content: "#";
  margin-left: 8px;
  color: var(--primary);
  font-size: 0.82em;
}

.markdown-body p {
  margin: 10px 0;
  overflow-wrap: anywhere;
}

.markdown-body a {
  color: var(--primary-hover);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-line {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.markdown-body ul,
.markdown-body ol {
  margin: 10px 0 18px;
  padding-left: 22px;
}

.markdown-body li {
  margin: 5px 0;
}

.markdown-body .task-list {
  padding-left: 0;
  list-style: none;
}

.markdown-body .task-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.markdown-body .task-list input {
  margin-top: 0.42em;
}

.markdown-body blockquote,
.markdown-body .notice,
.markdown-body .callout {
  margin: 14px 0 18px;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--text);
  padding: 10px 13px;
}

.markdown-body .callout-info,
.markdown-body .callout-notice {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}

.markdown-body .callout-success {
  border-left-color: #1f8a5f;
  background: rgba(31, 138, 95, 0.1);
}

.markdown-body .callout-warning {
  border-left-color: #b7791f;
  background: rgba(183, 121, 31, 0.12);
}

.markdown-body .callout-danger {
  border-left-color: #c24136;
  background: rgba(194, 65, 54, 0.11);
}

.markdown-body blockquote p,
.markdown-body .notice p,
.markdown-body .callout p {
  margin: 0;
}

.markdown-body hr {
  height: 1px;
  border: 0;
  background: var(--border);
  margin: 26px 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 14px 0 22px;
}

.markdown-body .doc-image-button {
  display: inline-block;
  max-width: 100%;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  padding: 0;
}

.markdown-body .doc-image-button img {
  width: var(--image-width, auto);
}

.markdown-body .image-align-left {
  display: block;
  margin-right: auto;
  text-align: left;
}

.markdown-body .image-align-center {
  display: block;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
}

.markdown-body .image-align-right {
  display: block;
  margin-left: auto;
  text-align: right;
}

.markdown-body .image-align-center img {
  margin-right: auto;
  margin-left: auto;
}

.markdown-body .image-align-right img {
  margin-right: 0;
  margin-left: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}

.markdown-body th {
  background: var(--bg-muted);
  font-weight: 650;
}

.markdown-body .cell-align-left {
  text-align: left;
}

.markdown-body .cell-align-center {
  text-align: center;
}

.markdown-body .cell-align-right {
  text-align: right;
}

.markdown-body .align-center table th,
.markdown-body .align-center table td {
  text-align: center;
}

.markdown-body .align-right table th,
.markdown-body .align-right table td {
  text-align: right;
}

.markdown-body :not(pre) > code {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-muted);
  color: var(--primary-hover);
  padding: 0.08em 0.34em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.markdown-body kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
  box-shadow: inset 0 -1px 0 rgba(20, 24, 34, 0.06);
  color: var(--text);
  padding: 0.08em 0.42em;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.86em;
}

.markdown-body .rich-mark {
  border-radius: 4px;
  padding: 0.02em 0.18em;
}

.markdown-body .rich-badge {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  border-radius: 999px;
  background: rgba(15, 159, 143, 0.12);
  color: #0b776d;
  padding: 0 8px;
  font-size: 0.86em;
  font-weight: 650;
}

[data-theme="dark"] .markdown-body .rich-badge {
  color: #7fd4ca;
}

.markdown-body .rich-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  padding: 0 12px;
  text-decoration: none;
}

.markdown-body .rich-button:hover {
  background: var(--primary-hover);
}

.markdown-body .align-left {
  text-align: left;
}

.markdown-body .align-center {
  text-align: center;
}

.markdown-body .align-right {
  text-align: right;
}

.markdown-body .rich-card {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: 0 8px 24px rgba(28, 38, 70, 0.05);
  padding: 14px 16px;
}

.markdown-body .rich-card h4 {
  margin-top: 0;
}

.markdown-body .rich-details {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  padding: 10px 12px;
}

.markdown-body .rich-details summary {
  cursor: pointer;
  font-weight: 650;
}

.markdown-body .rich-details-body {
  margin-top: 10px;
}

.markdown-body .rich-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.markdown-body .rich-columns > section {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  padding: 12px 14px;
}

.markdown-body pre {
  position: relative;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: var(--code-bg);
  box-shadow: 0 10px 26px rgba(10, 14, 24, 0.1);
  color: var(--code-text);
  margin: 12px 0 20px;
  padding: 18px 18px;
}

.markdown-body .code-label {
  display: inline-flex;
  margin: 0 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: currentColor;
  padding: 2px 8px;
  font-size: 11px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  opacity: 0.82;
}

.markdown-body pre.code-theme-midnight {
  background: #111827;
  color: #e6edf3;
}

.markdown-body pre.code-theme-graphite {
  background: #20242d;
  color: #f4f5f7;
}

.markdown-body pre.code-theme-ocean {
  background: #07344d;
  color: #d8f3ff;
}

.markdown-body pre.code-theme-forest {
  background: #143425;
  color: #d8f7e7;
}

.markdown-body pre.code-theme-violet {
  background: #2c214b;
  color: #efe7ff;
}

.markdown-body pre.code-theme-sunset {
  background: #4a2431;
  color: #ffe4dd;
}

.markdown-body pre.code-theme-rose {
  background: #4b1d32;
  color: #ffe2ee;
}

.markdown-body pre.code-theme-amber {
  background: #3d2a0b;
  color: #ffe8b0;
}

.markdown-body pre.code-theme-paper {
  border-color: var(--border);
  background: #f8fafc;
  color: #1f2937;
}

.markdown-body pre.code-theme-paper .copy-code {
  border-color: rgba(31, 41, 55, 0.18);
  background: rgba(31, 41, 55, 0.08);
  color: #1f2937;
}

.markdown-body pre.code-theme-terminal {
  background: #030712;
  color: #b7f7c4;
}

.markdown-body pre code {
  display: block;
  min-width: max-content;
  padding-right: 54px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.72;
  white-space: pre;
}

.copy-code {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbe4f0;
  cursor: pointer;
  padding: 3px 8px;
  font-size: 12px;
  opacity: 0;
  transition:
    opacity 0.18s ease,
    background 0.18s ease;
}

.markdown-body pre:hover .copy-code,
.copy-code:focus-visible {
  opacity: 1;
}

.copy-code:hover {
  background: rgba(255, 255, 255, 0.16);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(7, 10, 18, 0.82);
  padding: 52px 20px 18px;
}

.image-lightbox[hidden] {
  display: none;
}

.lightbox-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.lightbox-stage.is-dragging {
  cursor: grabbing;
}

.image-lightbox img {
  max-width: min(1100px, 92vw);
  max-height: calc(100vh - 148px);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  transform-origin: center center;
  transition: transform 0.06s linear;
  user-select: none;
  will-change: transform;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 20px;
}

.image-lightbox button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  padding: 8px 12px;
}

.lightbox-controls {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(7, 10, 18, 0.62);
  color: #ffffff;
  padding: 8px;
  backdrop-filter: blur(10px);
}

.lightbox-controls span {
  min-width: 54px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .image-lightbox {
    padding: 58px 10px 14px;
  }

  .image-lightbox img {
    max-width: 94vw;
    max-height: calc(100vh - 142px);
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
  }

  .lightbox-controls {
    width: min(330px, 94vw);
    justify-content: center;
  }

  .lightbox-controls button {
    min-height: 36px;
    padding: 6px 10px;
  }
}

.toc {
  position: sticky;
  top: 30px;
  align-self: start;
  color: var(--text-muted);
  min-width: 0;
  width: var(--toc-width);
  padding: 2px 0 2px 0;
}

.toc-resizer {
  position: sticky;
  top: 0;
  height: calc(100vh + 108px);
  align-self: start;
  margin-top: -28px;
  margin-bottom: -80px;
}

.toc p {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.toc a {
  display: block;
  border-radius: 6px;
  margin: 2px 0;
  padding: 5px 8px;
  font-size: 13px;
  line-height: 1.42;
}

.toc .toc-subitem {
  padding-left: 18px;
}

.toc a:hover,
.toc a.is-current {
  background: var(--primary-soft);
  color: var(--primary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  transform: translate(-50%, 18px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--text);
  box-shadow: var(--shadow);
  color: var(--bg);
  opacity: 0;
  padding: 9px 13px;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-mask {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 18, 30, 0.38);
}

@media (max-width: 1180px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
    width: min(900px, 100%);
  }

  .toc-resizer,
  .toc {
    display: none;
  }
}

@media (max-width: 880px) {
  :root {
    --sidebar-width: 320px;
  }

  body {
    background: var(--bg);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    max-width: calc(100vw - 52px);
    transform: translateX(-102%);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
  }

  .sidebar-resizer {
    display: none;
  }

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

  .mobile-bar {
    display: flex;
  }

  .main-pane {
    width: 100%;
  }

  .doc-layout {
    padding: 24px 20px 64px;
  }

  .doc-title-row {
    display: block;
  }

  .actions {
    display: none;
  }

  h1 {
    font-size: 28px;
  }
}

@media (max-width: 520px) {
  .doc-layout {
    padding-inline: 16px;
  }

  h1 {
    font-size: 25px;
  }

  .markdown-body {
    font-size: 14px;
  }

  .markdown-body h2 {
    font-size: 22px;
  }

  .markdown-body h3 {
    font-size: 18px;
  }

  .markdown-body pre {
    margin-inline: -2px;
    padding: 16px 14px;
  }
}
