﻿:root {
  --bg: #eef5fb;
  --panel: #ffffff;
  --line: #dde8f3;
  --text: #1f3d59;
  --muted: #6e879f;
  --accent: #5a9fd8;
  --accent-strong: #3d84c2;
  --accent-soft: #e9f4ff;
  --warn: #e74c3c;
  --shadow: 0 12px 30px rgba(23, 66, 95, 0.1);
  --radius: 12px;
  --sidebar-width: 296px;
  --sidebar-peek: 20px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 320px at 100% -120px, rgba(90, 159, 216, 0.2), transparent 62%),
    linear-gradient(180deg, #fafcfd 0%, var(--bg) 100%);
}

body.is-loading {
  overflow: hidden;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(700px 260px at 50% -60px, rgba(90, 159, 216, 0.22), transparent 70%),
    linear-gradient(180deg, #f8fbff 0%, #e9f3fc 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(400px, 100%);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #d7e8f8;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(30, 78, 112, 0.15);
  padding: 26px 24px 20px;
  text-align: center;
}

.loading-title {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  color: #2c5276;
}

.loading-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  border: 1px solid #c9dcf0;
  background: #edf5fd;
  overflow: hidden;
}

.loading-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #70afe0, #4f95ce);
  transition: width 0.18s ease;
}

.loading-percent {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #4a789f;
  letter-spacing: 0.5px;
}

.menu-toggle {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
  z-index: 50;
  display: none;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 35, 51, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 20;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  overflow-y: auto;
  overflow-x: visible;
  transition: transform 0.32s ease;
  z-index: 30;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  width: 28px;
  height: 66px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 8px 24px rgba(23, 66, 95, 0.12);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}

.sidebar-collapse-btn:hover {
  background: #f3f8fd;
  color: #2f74b0;
  box-shadow: 0 10px 28px rgba(23, 66, 95, 0.16);
}

.collapse-icon {
  display: block;
  line-height: 1;
  font-size: 14px;
  transition: transform 0.32s ease;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * (var(--sidebar-width) - var(--sidebar-peek))));
}

body.sidebar-collapsed .collapse-icon {
  transform: rotate(180deg);
}

.search-box {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
}

.search-box input {
  width: 100%;
  border: 0;
  font-size: 15px;
  color: var(--muted);
  outline: none;
  background: transparent;
}

.brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 8px;
  border-radius: 16px;
  background: linear-gradient(135deg, #67b4ea, #3d84c2);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 22px;
}

.brand p {
  margin: 0;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--muted);
}

.brand-note {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  color: #4f7ea8;
  letter-spacing: 1px;
}

.toc {
  padding: 16px 18px 28px;
  display: grid;
  gap: 8px;
}

.toc-empty {
  margin: 0;
  border: 1px dashed #d4e6f7;
  border-radius: 8px;
  background: #f6faff;
  padding: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.toc-link {
  text-decoration: none;
  color: #3a5672;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.toc-link:hover,
.toc-link.active {
  color: var(--accent-strong);
  background: #eff6ff;
  border-left-color: var(--accent-strong);
}

.toc-link[data-level="2"] {
  padding-left: 24px;
}

.toc-link[data-level="3"] {
  padding-left: 36px;
}

.toc-link[data-level="4"] {
  padding-left: 48px;
}

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.32s ease;
}

body.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-peek);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 252, 253, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 130px 12px 42px;
}

.top-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 28px;
  align-items: center;
}

.top-nav a {
  text-decoration: none;
  color: #304f6c;
  font-weight: 700;
  padding: 10px 2px;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}

.back-btn {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, #5fa8e2, #3d84c2);
  border: 1px solid #4d95d1;
  border-radius: 9px;
  padding: 8px 12px;
  box-shadow: 0 8px 18px rgba(61, 132, 194, 0.24);
  transition: filter 0.2s ease, transform 0.2s ease;
}

.back-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-50%) translateX(-1px);
}

.doc-content {
  width: min(900px, calc(100% - 72px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.doc-content > :first-child {
  margin-top: 0;
}

.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4 {
  scroll-margin-top: 86px;
}

.doc-content h3,
.doc-content h4 {
  margin: 34px 0 12px;
  color: #264b6a;
  font-weight: 700;
}

.doc-content h3 {
  font-size: clamp(22px, 2vw, 30px);
}

.doc-content h4 {
  font-size: clamp(19px, 1.6vw, 24px);
}

.doc-content blockquote {
  margin: 14px 0;
  border-left: 4px solid #8ebce4;
  background: #f2f8ff;
  border-radius: 6px;
  padding: 10px 14px;
  color: #2d5274;
}

.doc-content pre {
  background: #1d3246;
  color: #e8f3ff;
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
}

.doc-content pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.doc-content hr {
  border: 0;
  border-top: 1px solid #dde8f3;
  margin: 24px 0;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.doc-content th,
.doc-content td {
  border: 1px solid #d9e8f7;
  padding: 9px 10px;
  text-align: left;
}

.doc-content th {
  background: #eff6ff;
}

.doc-content img {
  max-width: 100%;
  border-radius: 8px;
}

.doc-section {
  margin-bottom: 40px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #e8eff7;
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: 0 8px 24px rgba(23, 60, 80, 0.04);
  opacity: 0;
  transform: translateY(20px);
  animation: rise-in 0.58s ease forwards;
}

.doc-section:nth-of-type(2) {
  animation-delay: 0.07s;
}

.doc-section:nth-of-type(3) {
  animation-delay: 0.14s;
}

.doc-section:nth-of-type(4) {
  animation-delay: 0.21s;
}

.doc-section:nth-of-type(5) {
  animation-delay: 0.28s;
}

h1,
h2 {
  margin: 0 0 22px;
  font-family: "STZhongsong", "Noto Serif SC", serif;
  color: #22415f;
}

h1 {
  font-size: clamp(36px, 4vw, 52px);
}

h2 {
  font-size: clamp(28px, 3vw, 38px);
}

p,
li {
  line-height: 1.9;
  font-size: 18px;
  color: #304f6a;
}

ul,
ol {
  margin: 12px 0 0;
  padding-left: 24px;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

code {
  background: #f2f7fb;
  color: #2b506f;
  border: 1px solid #e5eef5;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.92em;
}

.notice {
  margin: 0 0 14px;
  padding: 16px 18px;
  border-radius: 8px;
  border: 1px solid #d6e6f6;
  background: var(--accent-soft);
  line-height: 1.75;
  font-size: 18px;
}

.notice.warning {
  color: var(--warn);
  font-weight: 700;
}

.notice.tip {
  background: #f1f7ff;
  border-color: #d9e9fa;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .menu-toggle {
    display: block;
  }

  .sidebar-collapse-btn {
    display: none;
  }

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

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  body.mobile-nav-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    margin-left: 0 !important;
  }

  .topbar {
    padding: 12px 14px;
  }

  .top-nav {
    justify-content: flex-start;
    overflow-x: auto;
    white-space: nowrap;
    gap: 18px;
    padding-right: 100px;
  }

  .back-btn {
    right: 10px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .doc-content {
    width: calc(100% - 30px);
    padding-top: 18px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 30px;
  }

  p,
  li,
  .notice {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
