:root {
  color-scheme: light;
}

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

body {
  font-family: system-ui, sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 3.5rem 20px 40px;
  color: #333;
  background-color: #fff;
  line-height: 1.6;
  transition: background-color 0.2s, color 0.2s;
}

:root[data-theme="dark"] body {
  color: #e0e0e0;
  background-color: #1e1e1e;
}

h1 {
  font-size: 1.4rem;
  margin-top: 0;
}

h2 {
  font-size: 1rem;
  margin-top: 1.6em;
}

h3 {
  font-size: 0.95rem;
  margin-top: 1.4em;
}

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.75em 20px;
  font-size: 0.95rem;
  z-index: 10;
}

:root[data-theme="dark"] nav {
  background: #1e1e1e;
  border-bottom-color: #444;
}

nav > div {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  align-items: center;
  justify-content: center;
}

nav a {
  color: #0969da;
  text-decoration: none;
  flex: 0 0 auto;
}

nav a:hover {
  text-decoration: underline;
}

nav a.active {
  color: #333;
  font-weight: 500;
  text-decoration: none;
}

@media (max-width: 640px) {
  body {
    padding: 5.75rem 16px 40px;
  }

  nav {
    padding: 0.55em 16px;
  }

  nav > div {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  nav > div::-webkit-scrollbar {
    display: none;
  }

  nav a {
    white-space: nowrap;
  }
}

:root[data-theme="dark"] nav a {
  color: #58a6ff;
}

:root[data-theme="dark"] nav a.active {
  color: #e0e0e0;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: #fff;
  border: 1px solid #d0d7de;
  padding: 0.3em 0.5em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  line-height: 1;
  transition: background-color 0.2s, border-color 0.2s;
  z-index: 100;
}

.theme-toggle:hover {
  background-color: #f6f8fa;
}

:root[data-theme="dark"] .theme-toggle {
  background: #2d2d2d;
  border-color: #555;
  color: #e0e0e0;
}

:root[data-theme="dark"] .theme-toggle:hover {
  background-color: #3a3a3a;
}

code {
  background-color: #f6f8fa;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

:root[data-theme="dark"] code {
  background-color: #2d2d2d;
  color: #e0e0e0;
}

kbd {
  background-color: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 0.2em 0.4em;
  font-family: monospace;
  font-size: 0.85em;
}

:root[data-theme="dark"] kbd {
  background-color: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

table th,
table td {
  border: 1px solid #d0d7de;
  padding: 0.75em;
  text-align: left;
}

table th {
  background-color: #f6f8fa;
  font-weight: 600;
}

:root[data-theme="dark"] table th,
:root[data-theme="dark"] table td {
  border-color: #444;
}

:root[data-theme="dark"] table th {
  background-color: #2d2d2d;
  color: #e0e0e0;
}

ul, ol {
  margin: 1em 0;
  padding-left: 2em;
}

li {
  margin: 0.5em 0;
}

em {
  font-style: italic;
}

strong {
  font-weight: 600;
}
