:root {
  --primary: #007acc;
  --primary-hover: #005f99;
  --text: #1e293b;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
  --primary: #66b7ff;
  --primary-hover: #8dd1ff;
  --text: #e2e8f0;
  --bg: #0f172a;
  --surface: #1e293b;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.35);
  --shadow: 0 6px 18px rgba(2, 6, 23, 0.6);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  color-scheme: light;
  transition: background 0.3s ease, color 0.3s ease;
}

:root[data-theme="dark"] body {
  color-scheme: dark;
}

header {
  background: var(--surface);
  box-shadow: var(--shadow);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  text-align: center;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

h2 {
  color: var(--primary);
  margin: 2rem 0 1rem;
}

h3 {
  color: var(--primary);
  margin: 1.5rem 0 0.75rem;
}

p {
  max-width: 800px;
  margin: 0.5rem auto;
  font-size: 1.1rem;
  text-align: center;
}

nav {
  margin-top: 1rem;
}

nav a {
  margin: 0 1rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
  transition: color 0.2 sease;
}

nav a:hover {
  color: var(--primary-hover);
}

.toc-toggle-container {
  max-width: 1200px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  text-align: right;
}

.toc-toggle {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.toc-toggle:hover {
  background: #005f99;
  transform: translateY(-1px);
}

.toc-toggle:focus-visible {
  outline: 3px solid rgba(0, 122, 204, 0.35);
  outline-offset: 2px;
}

.layout {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  align-items: flex-start;
}

.toc {
  position: sticky;
  top: 2rem;
  align-self: flex-start;
  min-width: 220px;
  max-width: 280px;
  background: white;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.toc--collapsed {
  display: none;
}

.toc__title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.toc__link {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
  padding-left: 0.5rem;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.toc__link:hover,
.toc__link:focus-visible {
  color: var(--primary);
  border-color: var(--primary);
  transform: translateX(2px);
}

.toc__item--level-h3 .toc__link {
  font-size: 0.9rem;
  padding-left: 1.25rem;
}

main {
  flex: 1;
  max-width: 720px;
  margin: 0;
  padding: 0;
  min-width: 0;
}

main h2,
main h3,
main p {
  text-align: left;
}

main p {
  margin: 0.5rem 0;
}

footer {
  margin-top: 3rem;
  padding: 2rem;
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .toc-toggle-container {
    text-align: left;
  }

  .layout {
    flex-direction: column;
    padding-top: 1.5rem;
  }

  .toc {
    position: static;
    width: 100%;
    max-width: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  }
}


