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

:root {
  --primary: #1664FF;
  --primary-bg: rgba(22, 100, 255, 0.08);
  --text: #111;
  --text-secondary: #4e5969;
  --text-tertiary: #86909c;
  --border: #e5e6eb;
  --header-h: 56px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', SimSun, sans-serif;
  background: #fff;
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: #000;
  text-decoration: none;
  letter-spacing: -0.3px;
}

.legal-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 56px;
}

/* Sidebar */
.legal-sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  padding: 32px 0 24px;
}

.doc-switch {
  display: flex;
  padding: 3px;
  background: #f2f3f5;
  border-radius: 8px;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.doc-switch a {
  flex: 1;
  text-align: center;
  font-size: 14px;
  line-height: 32px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.doc-switch a:hover { color: var(--text); }
.doc-switch a.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.toc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 1px;
  padding: 0 12px 8px;
  flex-shrink: 0;
}

.toc-toggle { display: none; }

.toc {
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
}
.toc a {
  display: flex;
  gap: 8px;
  padding: 7px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc a:hover { color: var(--text); background: #f7f8fa; }
.toc a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-bg);
  font-weight: 500;
}
.toc-num {
  flex-shrink: 0;
  min-width: 1.4em;
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.7;
}

/* Document */
.document-container {
  max-width: 820px;
  padding: 40px 0 120px;
}

.doc-title {
  text-align: center;
  font-size: 26px;
  font-weight: bold;
  color: #000;
  margin-bottom: 20px;
}

.doc-meta {
  text-align: right;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.preamble {
  font-size: 16px;
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-indent: 2em;
  margin-bottom: 40px;
  color: #000;
  line-height: 2;
}

.section {
  margin-bottom: 28px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.section-title {
  font-size: 19px;
  font-weight: bold;
  color: #000;
  margin: 40px 0 16px;
}
.section p {
  font-size: 16px;
  text-indent: 2em;
  margin-bottom: 12px;
  line-height: 2;
}
.section ul, .section ol {
  margin-bottom: 16px;
  padding-left: 4em;
}
.section li {
  font-size: 16px;
  margin-bottom: 8px;
  line-height: 2;
}

.doc-footer {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px dashed #ccc;
  font-size: 14px;
  color: #666;
  text-align: center;
}
.doc-footer a { color: #000; text-decoration: underline; font-weight: 500; }
.doc-footer a:hover { color: var(--primary); }

.to-top {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s, color 0.2s;
}
.to-top.visible { opacity: 1; visibility: visible; }
.to-top:hover { color: var(--primary); }

@media (max-width: 960px) {
  .site-header { padding: 0 16px; }

  .legal-layout {
    display: block;
    padding: 0;
  }

  .legal-sidebar {
    top: var(--header-h);
    z-index: 90;
    max-height: none;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
  }
  .doc-switch { margin-bottom: 10px; }
  .toc-label { display: none; }

  .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
  }
  .toc-toggle-text {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .toc-toggle-arrow { transition: transform 0.2s; color: var(--text-tertiary); }
  .legal-sidebar.open .toc-toggle-arrow { transform: rotate(180deg); }

  .toc {
    display: none;
    max-height: 60vh;
    margin-top: 8px;
    border-left: none;
  }
  .legal-sidebar.open .toc { display: block; }
  .toc a { margin-left: 0; border-left: none; border-radius: 6px; }

  .document-container { padding: 28px 16px 96px; }
  .doc-title { font-size: 20px; }
  .doc-meta { font-size: 13px; }
  .section { scroll-margin-top: calc(var(--header-h) + 132px); }
  .section ul, .section ol { padding-left: 2.5em; }
  .to-top { right: 16px; bottom: 24px; }
}

@media print {
  .site-header, .legal-sidebar, .to-top { display: none; }
  .legal-layout { display: block; padding: 0; }
  .document-container { padding: 0; max-width: none; }
}
