:root {
  --text: #1a1a1a;
  --text-muted: #666;
  --bg: #ffffff;
  --bg-section: #f8f8f6;
  --border: #e0e0dc;
  --accent: #1a1a1a;
  --accent-light: #f0f0ec;
  --badge-complete: #2d6a4f;
  --badge-progress: #b5790a;
  --badge-open: #555;
  font-size: 17px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

/* NAV */
#topnav {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 2rem;
  z-index: 100;
  flex-wrap: wrap;
}

.nav-brand a {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  flex: 1;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.15s;
}

.nav-links a:hover { color: var(--text); }

.nav-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-pdf, .btn-github {
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-pdf {
  background: var(--text);
  color: white;
}

.btn-github {
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-pdf:hover { opacity: 0.85; }
.btn-github:hover { border-color: var(--text); }

/* HERO */
#hero {
  max-width: 760px;
  margin: 5rem auto 4rem;
  padding: 0 2rem;
  text-align: center;
}

#hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 560px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--text);
  color: white;
}

.btn-secondary {
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-primary:hover { opacity: 0.85; }
.btn-secondary:hover { border-color: var(--text); }

/* SEARCH */
#search-bar {
  max-width: 760px;
  margin: 0 auto 3rem;
  padding: 0 2rem;
  position: relative;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus { border-color: var(--text); }

#search-results {
  position: absolute;
  top: 100%;
  left: 2rem;
  right: 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 50;
  display: none;
}

#search-results.visible { display: block; }

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--accent-light); }

/* CHAPTERS */
#content {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 2rem;
}

.chapter {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}

.chapter:last-child { border-bottom: none; }

.chapter h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chapter-status { margin-bottom: 0.75rem; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge.complete { background: #d8f3e3; color: var(--badge-complete); }
.badge.in-progress { background: #fef3cd; color: var(--badge-progress); }
.badge.open { background: var(--bg-section); color: var(--badge-open); }

.chapter p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.read-link, .contribute-link {
  font-size: 0.88rem;
  text-decoration: none;
  margin-right: 1.5rem;
}

.read-link { color: var(--text); font-weight: 500; }
.read-link:hover { text-decoration: underline; }
.contribute-link { color: var(--text-muted); }
.contribute-link:hover { color: var(--text); }

/* ABOUT */
#about {
  max-width: 760px;
  margin: 4rem auto;
  padding: 2.5rem 2rem;
  background: var(--bg-section);
  border-radius: 12px;
}

#about h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

#about p { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 0.5rem; }
#about a { color: var(--text); font-size: 0.88rem; }

/* FOOTER */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  margin-top: 4rem;
}

footer a { color: var(--text-muted); font-size: 0.85rem; margin: 0 0.5rem; text-decoration: none; }
footer a:hover { color: var(--text); }
.footer-note { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.5rem; }

@media (max-width: 640px) {
  #topnav { padding: 0.6rem 1rem; gap: 0.75rem; }
  .nav-links { display: none; }
  #hero { margin-top: 3rem; }
  #hero h1 { font-size: 1.8rem; }
}
