:root,
html[data-theme="light"] {
  --font: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  --bg: #f7f7f7;
  --text: #1a1a1a;
  --elev: #eee;
  --header: #444;
  --header-text: #fff;
  --accent: #007bff;
  --button-hover: #0056cc;
}

html[data-theme="dark"] {
  --bg: #1b1b1b;
  --text: #f7f7f7;
  --elev: #222;
  --header: #222;
  --header-text: #f7f7f7;
  --accent: #4c8dff;
  --button-hover: #3a70d6;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #1b1b1b;
    --text: #f7f7f7;
    --elev: #222;
    --header: #222;
    --header-text: #f7f7f7;
    --accent: #4c8dff;
    --button-hover: #3a70d6;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font), serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

header {
  text-align: center;
  padding: 1rem;
  background: var(--header);
  color: var(--header-text);
  transition: background-color .25s ease, color .25s ease;
}

.header-link {
  text-decoration: none;
  color: var(--header-text);
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 700;
}

nav {
  margin-top: .5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

nav a {
  text-decoration: none;
  font-weight: 600;
  color: var(--header-text);
  opacity: .85;
  padding-bottom: .2rem;
}

nav a.active {
  border-bottom: 2px solid var(--accent);
  opacity: 1;
}

main {
  max-width: 900px;
  margin: auto;
  padding: 2rem 1rem;
}

h2 {
  border-bottom: 2px solid var(--accent);
  padding-bottom: .4rem;
  margin-top: 2rem;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.4;
}

ul, ol { margin-left: 1.25rem; }

img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

footer {
  text-align: center;
  padding: 1rem;
  background: var(--header);
  color: var(--header-text);
  transition: background-color .25s ease, color .25s ease;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 20px;
  padding: .7rem 1.1rem;
  cursor: pointer;
  margin: .5rem;
  transition: transform .12s ease, background .12s ease;
}

button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
}

.theme-toggle {
  position: fixed;
  right: .75rem;
  bottom: .75rem;
  z-index: 10;
  font-size: .9rem;
}

@media (max-width: 600px) {
  main { padding: 1.25rem 1rem; }
  nav { gap: .6rem; }
}