/* ---------- Design tokens ---------- */
:root {
  --bg: #fbf6ee;
  --bg-alt: #f3ecdf;
  --surface: #ffffff;
  --text: #2b2016;
  --text-muted: #6b5d4d;
  --accent: #c9701c;
  --accent-ink: #ffffff;
  --accent-2: #2f7d68;
  --border: #e7dcc7;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 30px -18px rgba(43, 32, 22, 0.35);
  --maxw: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18120b;
    --bg-alt: #221a10;
    --surface: #241b12;
    --text: #f3ecdf;
    --text-muted: #c2b39c;
    --accent: #e3a15c;
    --accent-ink: #201304;
    --accent-2: #58bfa4;
    --border: #3a2e1e;
    --shadow: 0 16px 34px -18px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.75em 1em;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.85em 1.4em;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { box-shadow: var(--shadow); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost {
  background: var(--bg-alt);
  color: var(--text);
}
.btn-ghost:hover { background: var(--border); }
.btn-block { width: 100%; }
.btn-small { padding: 0.55em 1.1em; font-size: 0.85rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
}
.brand-mark { border-radius: 6px; }

.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle-bar {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.primary-nav {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.primary-nav.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.primary-nav a {
  padding: 0.65em 0.25em;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.primary-nav a:last-child { border-bottom: none; margin-top: 0.5rem; }
.primary-nav .btn { justify-content: center; }

@media (min-width: 780px) {
  .nav-toggle { display: none; }
  .primary-nav {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 1.75rem;
    padding: 0;
    background: none;
    border: none;
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  .primary-nav a { border: none; padding: 0; font-weight: 500; }
  .primary-nav a:last-child { margin-top: 0; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 4rem 0 3.5rem;
  text-align: center;
  background:
    radial-gradient(60% 60% at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--bg);
}
.hero-mark { margin: 0 auto 1.5rem; }
.hero h1 {
  font-size: clamp(1.9rem, 5vw + 0.5rem, 3.1rem);
  letter-spacing: -0.02em;
  max-width: 18ch;
  margin-inline: auto;
  margin-bottom: 0.6em;
}
.hero-lede {
  max-width: 46ch;
  margin: 0 auto 1.75rem;
  font-size: 1.05rem;
}
.hero-ctas {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 320px;
  margin: 0 auto;
}
.hero-note {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (min-width: 560px) {
  .hero-ctas { flex-direction: row; justify-content: center; max-width: none; }
}

/* ---------- Sections ---------- */
section { padding: 3.5rem 0; }
section h2 {
  font-size: clamp(1.5rem, 3vw + 0.5rem, 2.1rem);
  text-align: center;
  letter-spacing: -0.01em;
}
.section-lede {
  text-align: center;
  max-width: 52ch;
  margin: 0 auto 2.5rem;
}
.section-footnote {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 2rem;
}

.how-it-works { background: var(--bg-alt); }

/* ---------- Steps ---------- */
.steps {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.step h3 { font-size: 1.05rem; }
.step p { margin: 0; font-size: 0.95rem; }

@media (min-width: 780px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Features ---------- */
.feature-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-top: 2.5rem;
}
.feature {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}
.feature h3 {
  font-size: 1.05rem;
  color: var(--accent-2);
}
.feature p { margin: 0; font-size: 0.95rem; }

@media (min-width: 640px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); column-gap: 2rem; }
}
@media (min-width: 980px) {
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Safety ---------- */
.safety { background: var(--bg-alt); }
.safety-grid .feature h3 { color: var(--accent); }

/* ---------- Downloads ---------- */
.downloads-block { margin-top: 2.5rem; }
.downloads-block:first-of-type { margin-top: 0; }
.downloads-block h3 {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
}

.card-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}
.card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}
.card h4 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: auto;
}
.card-footnote {
  font-size: 0.8rem;
  margin: 0.75rem 0 0;
}

@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 980px) {
  #downloads-server .card-grid,
  #downloads-server-headless .card-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  background: var(--bg-alt);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}
.footer-inner p { margin: 0; font-size: 0.85rem; }
.brand-footer { font-size: 1rem; }

/* ---------- Policy page ---------- */
.policy { max-width: 720px; }
.policy h1 { text-align: center; }
.policy .intro-lede { text-align: center; margin-bottom: 2.5rem; }
.policy h2 {
  font-size: 1.25rem;
  margin-top: 2.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent-2);
}
.policy ul { padding-left: 1.2rem; }
.policy li { margin-bottom: 0.5em; color: var(--text-muted); }
.policy .last-updated {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 2.5rem;
}
.policy .guide-back { font-size: 0.9rem; margin-bottom: 2rem; }
.policy pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}
.policy code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.policy :not(pre) > code {
  background: var(--bg-alt);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  padding: 0.75em 1.25em;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 200;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
