:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1a1d26;
  --text-secondary: #5c6370;
  --accent: #e63946;
  --accent-soft: rgba(230, 57, 70, 0.08);
  --border: #e8eaed;
  --highlight: #fff8e6;
  --highlight-border: #f0d78c;
  --link: #2563eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 860px;
  --header-height: 56px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover {
  text-decoration: underline;
}

/* Top bar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}

.site-header__inner {
  max-width: calc(var(--max-width) + 280px);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  text-decoration: none;
}

.site-brand__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.site-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Layout */
.page-layout {
  max-width: calc(var(--max-width) + 280px);
  margin: 0 auto;
  padding: 32px 20px 80px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  align-items: start;
}

@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 1fr;
    padding: 20px 16px 64px;
    gap: 0;
  }
}

/* Sidebar TOC */
.toc {
  position: sticky;
  top: calc(var(--header-height) + 24px);
}

@media (max-width: 900px) {
  .toc {
    position: static;
    margin-bottom: 24px;
  }
}

.toc__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.toc__title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc__list li {
  margin: 0;
}

.toc__list a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.toc__list a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

/* Main content */
.doc {
  min-width: 0;
}

.doc__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc__hero {
  padding: 40px 40px 32px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #fff 0%, #fafbfc 100%);
}

@media (max-width: 600px) {
  .doc__hero {
    padding: 28px 20px 24px;
  }
}

.doc__title {
  margin: 0 0 12px;
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

.doc__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.doc__meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc__meta strong {
  font-weight: 600;
  color: var(--text);
}

.doc__body {
  padding: 32px 40px 48px;
}

@media (max-width: 600px) {
  .doc__body {
    padding: 24px 20px 36px;
  }
}

/* Typography */
.doc__body p {
  margin: 0 0 16px;
  color: var(--text);
}

.doc__body p:last-child {
  margin-bottom: 0;
}

.doc__body h2 {
  margin: 40px 0 16px;
  padding-top: 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  scroll-margin-top: calc(var(--header-height) + 16px);
}

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

.doc__body h3 {
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.doc__body strong,
.doc__body b {
  font-weight: 600;
  color: var(--text);
}

.doc__body a {
  word-break: break-all;
}

/* Alert / highlight box */
.callout {
  margin: 24px 0;
  padding: 16px 20px;
  background: var(--highlight);
  border: 1px solid var(--highlight-border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.7;
}

.callout--warning {
  background: var(--accent-soft);
  border-color: rgba(230, 57, 70, 0.2);
}

.callout__label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Lists */
.doc__body ol,
.doc__body ul {
  margin: 0 0 16px;
  padding-left: 1.4em;
}

.doc__body li {
  margin-bottom: 8px;
}

.doc__body li:last-child {
  margin-bottom: 0;
}

/* Subsection label */
.subsection-label {
  margin: 20px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Contact card */
.contact-card {
  margin-top: 8px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.contact-card p {
  margin: 0 0 8px !important;
  font-size: 14px;
}

.contact-card p:last-child {
  margin-bottom: 0 !important;
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s, background 0.15s;
  z-index: 90;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Footer */
.doc__footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.doc__footer a {
  font-weight: 500;
}

.callout a {
  color: var(--link);
  font-weight: 600;
}

.callout strong a {
  color: var(--link);
}

@media (max-width: 900px) {
  .toc__card {
    padding: 12px 14px;
  }

  .toc__list {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .toc__list::-webkit-scrollbar {
    display: none;
  }

  .toc__list li {
    flex-shrink: 0;
  }

  .toc__list a {
    white-space: nowrap;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #1a1d26;
    --text: #e8eaed;
    --text-secondary: #9aa0a6;
    --border: #2d3139;
    --highlight: #2a2416;
    --highlight-border: #4a3f20;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.2);
  }

  .site-header {
    background: rgba(26, 29, 38, 0.92);
  }

  .doc__hero {
    background: linear-gradient(135deg, #1a1d26 0%, #151820 100%);
  }

  .contact-card {
    background: #151820;
  }
}
