:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c1f24;
  --text-muted: #5a6272;
  --border: #e3e6ea;
  --accent: #3b6df0;
  --accent-hover: #2f56c4;
  --max-width: 900px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --text: #eef0f3;
    --text-muted: #a3aab7;
    --border: #2c2f36;
    --accent: #6f93ff;
    --accent-hover: #8fa8ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

.toc {
  position: sticky;
  top: 0;
  width: 260px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 32px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.toc h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 16px;
}

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

.toc li {
  margin-bottom: 4px;
}

.toc a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.toc a:hover {
  background: var(--bg);
  color: var(--text);
}

.toc a.active {
  background: var(--accent);
  color: #fff;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 48px clamp(20px, 5vw, 72px) 96px;
  max-width: var(--max-width);
}

.page-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 2.2rem;
}

.subtitle {
  margin: 0 0 4px;
  color: var(--text-muted);
}

.meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

section {
  margin-bottom: 40px;
  scroll-margin-top: 24px;
}

section h2 {
  font-size: 1.35rem;
  margin: 0 0 12px;
}

section h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
  color: var(--text);
}

section p, section li {
  color: var(--text);
}

.page-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

ul {
  padding-left: 20px;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

.contact-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: inline-block;
}

.menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

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

  .toc {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 15;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  }

  .toc.open {
    transform: translateX(0);
  }

  .content {
    padding-top: 88px;
  }
}
