* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.page {
  max-width: 1680px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}

.site-footer {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px 32px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer-links {
  display: flex;
  gap: 16px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  margin-bottom: 16px;
}

.brand {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 20px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
}

.site-nav a.active {
  color: var(--text);
}

.tagline {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
}

.tagline-note {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  opacity: 0.85;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  background: var(--chip-bg);
  color: var(--chip-text);
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}

.choose-btn {
  display: inline-block;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choose-btn:hover {
  border-color: var(--text);
  background: var(--surface);
}

.choose-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.change-link {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.change-link:hover { background: var(--accent-soft); }

.dark-mode-toggle {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: grayscale(1);
}

.dark-mode-toggle:hover {
  background: var(--accent-soft);
}

.dark-mode-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Mobile (≤ 720px) ─────────────────────────────────────────────
   Phone layout: tighter page padding, header wraps to two rows,
   nav links sit on their own row so the brand + auth + dark-mode
   buttons stop overlapping.                                          */
@media (max-width: 720px) {
  .page {
    padding: 16px 14px 64px;
  }

  .site-header {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 0 12px;
    margin-bottom: 12px;
  }

  .brand {
    font-size: 18px;
  }

  /* Nav drops to a full-width second row so it never collides with
     the brand or the auth/dark-mode controls. Links become chip-style
     tap targets so they're easier to hit on a phone and the active
     page reads clearly at a glance. */
  .site-nav {
    order: 3;
    width: 100%;
    gap: 6px;
    justify-content: space-between;
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid var(--border);
  }

  .site-nav a {
    flex: 1 1 0;
    text-align: center;
    padding: 9px 10px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13.5px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .site-nav a:active {
    background: var(--accent-soft);
  }

  .site-nav a.active {
    background: var(--accent-soft);
    color: var(--text);
    font-weight: 600;
  }

  /* Auth slot keeps its margin-left:auto so it stays on the brand row,
     pushed to the right. The dark-mode toggle sits next to it. */
  #auth-header-slot {
    margin-left: auto;
  }

  .dark-mode-toggle {
    margin-left: 0;
    padding: 6px;
    font-size: 18px;
  }

  .tagline {
    font-size: 14px;
    margin-bottom: 12px;
  }

  .site-footer {
    padding: 16px 14px 24px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 12.5px;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 12px 10px 56px;
  }

  .site-nav {
    gap: 12px;
    font-size: 13px;
  }
}
