:root[data-theme="light"] {
  --bg: #f5f7f5;
  --fg: #172b27;
  --muted: #50635c;
  --card: #ffffff;
  --accent: #286343;
  --warm: #945116;
  --line: #c9d6ce;
  color-scheme: light;
}

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

header.site[data-site-header] .site-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  min-height: 32px;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
header.site[data-site-header] .site-theme svg { width: 16px; height: 16px; }
header.site[data-site-header] .site-theme:hover { color: var(--fg); }
header.site[data-site-header] .site-theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header.site[data-site-header] .site-theme .theme-moon { display: none; }
:root[data-theme="light"] header.site[data-site-header] .site-theme .theme-sun { display: none; }
:root[data-theme="light"] header.site[data-site-header] .site-theme .theme-moon { display: block; }

:root[data-theme="light"] .topic-card:hover { background: #e8eee9; }
:root[data-theme="light"] .help-tabs { background: var(--card); }
:root[data-theme="light"] .note,
:root[data-theme="light"] .topic details,
:root[data-theme="light"] .mini-cards > div { background: #e8eee9; }
:root[data-theme="light"] body.home { background-image: none; }
:root[data-theme="light"] .hero,
:root[data-theme="light"] .hero p,
:root[data-theme="light"] .hero p.kicker,
:root[data-theme="light"] .hero .soon,
:root[data-theme="light"] .hero .soon a { color: var(--fg); }
:root[data-theme="light"] .home .hero .button.secondary { box-shadow: inset 0 0 0 1px currentColor; }

body.map-page { background: var(--bg); color: var(--fg); }
body.map-page :is(#account, #details, #legend-panel, #shared-route, #route-profile-panel) {
  background: var(--card);
  border-color: var(--line);
  color: var(--fg);
}
body.map-page :is(#details, #shared-route, #route-profile-panel) {
  background: color-mix(in srgb, var(--card) 74%, transparent);
}
body.map-page :is(input, select) { background: var(--bg); color: var(--fg); border-color: var(--line); }
body.map-page button.secondary { background: var(--card); color: var(--accent); }
body.map-page :is(#account-status, #map-status, #road-status, .muted, .chart-label, #route-summary small) { color: var(--muted); }
:root[data-theme="dark"] #route-gap-status { color: #ffb057; }

header.site[data-site-header] {
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  background: var(--bg, #091316);
  color: var(--fg, #f5f5f2);
  border-bottom: 1px solid var(--line, #2d4742);
  font: 1rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header.site[data-site-header] .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  width: 100%;
  max-width: 1200px;
  height: auto;
  min-height: 72px;
  margin: 0 auto;
  padding: 12px 20px;
}

header.site[data-site-header] .brand {
  flex-shrink: 0;
  min-height: 44px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", -apple-system, sans-serif;
}

header.site[data-site-header] nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  overflow: visible;
}

header.site[data-site-header] nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--muted, #b0bebb);
  text-decoration: none;
  font-weight: 600;
}

header.site[data-site-header] nav a:hover,
header.site[data-site-header] nav a[aria-current="page"] {
  background: var(--card, #132126);
  color: var(--fg, #f5f5f2);
}

header.site[data-site-header] nav a[aria-current="page"] {
  box-shadow: inset 0 -2px var(--accent, #7dab8f);
}

header.site[data-site-header] #account-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}
header.site[data-site-header] .site-create-account {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  text-decoration: none;
}
.site-signup-form { display: grid; gap: 10px; max-width: 440px; }
.site-signup-form[hidden] { display: none; }
.site-signup-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
}
.site-signup-form small { color: var(--muted); }
.site-signup-form button:disabled { opacity: 0.6; cursor: wait; }

header.site[data-site-header] button,
header.site[data-site-header] summary,
.site-auth-dialog button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line, #2d4742);
  border-radius: 10px;
  background: var(--card, #132126);
  color: var(--fg, #f5f5f2);
  font: inherit;
  cursor: pointer;
}

header.site[data-site-header] #account-menu {
  position: relative;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

header.site[data-site-header] summary { list-style: none; }
header.site[data-site-header] summary::-webkit-details-marker { display: none; }
header.site[data-site-header] summary svg { width: 20px; height: 20px; flex-shrink: 0; }
header.site[data-site-header] #signed-in-user { font-size: 0.9rem; overflow-wrap: anywhere; }

header.site[data-site-header] .account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1;
  width: min(300px, calc(100vw - 40px));
  padding: 16px;
  border: 1px solid var(--line, #2d4742);
  border-radius: 12px;
  background: var(--card, #132126);
  box-shadow: 0 12px 32px #0005;
  overflow-wrap: anywhere;
}

header.site[data-site-header] .account-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted, #b0bebb);
  font-size: 0.85rem;
}

header.site[data-site-header] .account-dropdown button { width: 100%; }
header.site[data-site-header] #account-menu-status { font-size: 0.9rem; }
header.site[data-site-header] [hidden],
.site-auth-notice[hidden] { display: none !important; }

header.site[data-site-header] :is(a, button, summary, select):focus-visible,
.site-auth-dialog :is(button, input):focus-visible {
  outline: 3px solid var(--accent, #7dab8f);
  outline-offset: 3px;
}

.site-auth-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line, #2d4742);
  border-radius: 16px;
  background: var(--bg, #091316);
  color: var(--fg, #f5f5f2);
  font: inherit;
  overflow-y: auto;
}

.site-auth-dialog::backdrop { background: #000a; }
.site-auth-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-auth-heading h2 { margin: 0; }
.site-auth-dialog form { display: grid; gap: 10px; }
.site-auth-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line, #2d4742);
  border-radius: 8px;
  background: var(--card, #132126);
  color: var(--fg, #f5f5f2);
  font: inherit;
}
.site-auth-dialog button[type="submit"] {
  margin-top: 8px;
  background: var(--accent, #7dab8f);
  color: var(--bg, #091316);
  font-weight: 700;
}
.site-auth-dialog #account-status { min-height: 1.55em; margin-bottom: 0; }
.site-auth-notice { margin: 0; padding: 12px 20px; background: var(--card, #132126); color: var(--fg, #f5f5f2); }
header.site[data-site-header] button:disabled,
.site-auth-dialog button:disabled { opacity: 0.65; cursor: wait; }

@media (max-width: 1000px) {
  header.site[data-site-header] nav { order: 3; flex-basis: 100%; }
  header.site[data-site-header] #account-actions { margin-left: auto; }
}

@media (max-width: 480px) {
  header.site[data-site-header] .wrap { padding: 10px 12px; gap: 8px 12px; }
  header.site[data-site-header] nav { gap: 4px; }
  header.site[data-site-header] nav a { flex: 1 0 auto; padding: 8px 10px; }
  header.site[data-site-header] #account-actions { max-width: 100%; }
  header.site[data-site-header] .account-dropdown { width: min(300px, calc(100vw - 24px)); }
}
