:root, html[data-theme="night"] {
  --bg: #12151C; --ink: #F4F6F8; --muted: #9AA3B2; --card: #1A1E28; --card-2: #222838; --line: #2C3344;
  --pine: #7EB6C9; --gold: #C6A15A; --clay: #C084FC; --danger: #E08A80; --accent: #7EB6C9; --on-accent: #10141C;
  --water: #0C1018; --land: #1C2433; --border: #3A4558; --visited: #2DD4BF; --national: #2DD4BF; --state: #C084FC;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28); --serif: Fraunces, Georgia, serif; --sans: "Source Sans 3", "Segoe UI", sans-serif; --radius: 16px;
}
html[data-theme="day"], html[data-theme="light"] { --bg:#F6F4F0; --ink:#1B2330; --muted:#5C6675; --card:#FFFFFF; --card-2:#F3F0EA; --line:#E3DDD4; --pine:#0F6E6A; --gold:#8A6230; --clay:#7C3AED; --danger:#9E3B34; --accent:#0F6E6A; --on-accent:#F4FBF8; --water:#E4EEF3; --land:#E8E2D6; --border:#D0CBC2; --visited:#0F766E; --national:#0F766E; --state:#7C3AED; --shadow: 0 12px 28px rgba(40,32,20,.08); }
html[data-theme="aurora"] { --bg:#0C1020; --ink:#F4F7FF; --muted:#A9B4C9; --card:#161B2E; --card-2:#1C1434; --line:#2A3150; --pine:#8B7CFF; --gold:#C4B5FD; --clay:#E879F9; --danger:#F0A0A8; --accent:#8B7CFF; --on-accent:#F7F5FF; --water:#070A14; --land:#161B2E; --border:#3A4260; --visited:#2DD4BF; --national:#2DD4BF; --state:#E879F9; }
html[data-contrast="high"] { --ink:#fff; --muted:#f4f4f4; --line:#fff; }
html[data-theme="day"][data-contrast="high"] { --ink:#111; --muted:#1a1a1a; --bg:#fff; --line:#111; }
.card, .stat { background: linear-gradient(180deg, var(--card), var(--card-2)); }
html[data-theme="aurora"] body { background: linear-gradient(165deg, #12182C 0%, #0C1020 42%, #1A1430 100%); }
html[data-theme="night"] .top h1, html[data-theme="aurora"] .top h1 { background: linear-gradient(90deg, var(--ink), var(--national)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.atlas { position: relative; background: var(--water); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.atlas canvas { width: 100%; height: min(68vh, 640px); display: block; touch-action: none; }
.atlas-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.atlas-tools button, .theme-open { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-weight: 600; }
.theme-dock { position: fixed; z-index: 6; left: 14px; bottom: 16px; }
.site-bar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.site-bar a { color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 22px; }
.atlas-caption, .atlas-credit, .atlas-legend { margin: 0; padding: 6px 12px; color: var(--muted); font-size: 13px; }
.atlas-legend { display: flex; gap: 12px; flex-wrap: wrap; }
.atlas-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 99px; margin-right: 4px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.theme-grid button { display: flex; gap: 8px; align-items: center; background: var(--card-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.theme-grid button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 2px solid; }
#theme-picker { border: 0; background: var(--card); color: var(--ink); border-radius: 18px; padding: 16px; width: min(420px, calc(100% - 24px)); }
#theme-picker::backdrop { background: rgba(0,0,0,.55); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -40px; background: var(--gold); color: #121614; padding: 8px 12px; border-radius: 999px; }
.skip:focus { top: 12px; }
a { color: var(--gold); }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; margin: 0; }
h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.05; }
h2 { font-size: 28px; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 220px 1fr; }
.nav { padding: 20px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; background: var(--card); }
.brand { font-family: var(--serif); font-size: 22px; padding: 6px 10px 14px; }
.nav button, .btn, .icon-btn { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 10px 14px; text-align: left; cursor: pointer; }
.nav button { color: var(--muted); display: flex; gap: 8px; align-items: center; }
.nav button[aria-current="page"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.main { padding: 28px 22px 80px; max-width: 1080px; }
.top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat { font-family: var(--serif); font-size: 36px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.filters button, .seg button { background: transparent; color: var(--muted); border: 1px solid transparent; }
.filters button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: transparent; }
.who { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.who button { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; background: transparent; color: var(--ink); border: 1px solid var(--line); }
.who button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; font-style: normal; font-size: 12px; color: #12151C; object-fit: cover; }
.member-line { display: flex; gap: 10px; align-items: flex-start; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); }
.who-field { margin: 8px 0; }
dialog { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; width: min(480px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.view-toggle { margin-bottom: 10px; }
.nav .who-field select { width: 100%; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.glass { background: color-mix(in srgb, var(--card) 84%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 16px; }
.shell.map-mode { height: 100vh; overflow: hidden; }
.map-main { position: relative; height: 100vh; max-width: none !important; padding: 0 !important; }
.map-stage { position: absolute; inset: 0; }
.map-stage .atlas, .map-stage .atlas canvas { height: 100%; border: 0; border-radius: 0; touch-action: none; }
.float { position: absolute; z-index: 4; }
.float.tl { top: 12px; left: 12px; display: flex; flex-direction: column; gap: 8px; padding: 10px; width: min(380px, calc(100% - 24px)); }
.float.br { right: 12px; bottom: 12px; display: flex; flex-direction: column; padding: 4px; }
.float.bl { left: 12px; bottom: 12px; padding: 8px 12px; max-width: 240px; }
.zoom button, .float button { background: transparent; color: var(--muted); border: 1px solid transparent; }
.float button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.zoom button { width: 40px; height: 40px; border: 0; color: var(--ink); font-size: 20px; border-radius: 12px; }
.zoom .basemap { display: flex; gap: 0; margin: 4px; }
.zoom .basemap button { width: auto; height: 32px; padding: 0 8px; font-size: 13px; font-weight: 700; }
.imagery-credit { position: absolute; left: 12px; right: 88px; bottom: 64px; z-index: 4; margin: 0; color: #fff; font-size: 11px; line-height: 1.3; text-shadow: 0 1px 2px #000; pointer-events: none; }
.map-search-label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.map-search { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.map-search::placeholder { color: var(--muted); }
.legend summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.back { background: transparent; border: 0; color: var(--ink); font-weight: 700; padding: 0 0 8px; cursor: pointer; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.crumbs button { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; }
.map-popup { position: absolute; z-index: 5; left: 12px; bottom: 72px; padding: 12px; display: flex; flex-direction: column; gap: 8px; width: min(280px, calc(100% - 24px)); }
.map-popup[hidden] { display: none; }
.bulk { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.nav .check { margin: 2px 10px 8px; color: var(--muted); font-size: 14px; line-height: 1.2; }
.nav .check input { width: 16px; height: 16px; margin: 0; padding: 0; flex: 0 0 16px; accent-color: var(--accent); }
.nav .check span { flex: 1; }
.btn { background: var(--pine); color: var(--bg); border-color: var(--pine); font-weight: 600; }
html[data-theme="light"] .btn { color: #f4efe6; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field span { font-weight: 600; font-size: 14px; }
input, select, textarea { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
.alert { color: var(--danger); font-size: 14px; min-height: 1.2em; }
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: left; width: 100%; color: inherit; cursor: pointer; }
.item strong { display: block; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; background: var(--card-2); color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 14px; }
.empty, .error, .loading { padding: 28px 8px; }
.error { border: 1px solid var(--danger); border-radius: var(--radius); padding: 16px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(12px); background: var(--gold); color: #121614; padding: 10px 14px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; z-index: 5; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.undo { pointer-events: auto; display: flex; gap: 10px; align-items: center; }
#toast button { background: transparent; border: 0; font-weight: 700; cursor: pointer; color: inherit; }
dialog { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 18px; padding: 20px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.map-wrap { background: #0c100e; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
canvas.map { width: 100%; height: min(68vh, 640px); display: block; touch-action: none; }
.photo { width: 100%; max-height: 280px; object-fit: cover; border-radius: 12px; background: var(--card-2); }
.signin { max-width: 460px; margin: 8vh auto; padding: 0 16px 40px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 88px; margin-top: 8px; }
.bars i { display: block; flex: 1; background: var(--pine); border-radius: 4px 4px 0 0; min-height: 2px; }
@media (max-width: 800px) {
  .theme-dock { left: auto; right: 10px; top: 8px; bottom: auto; }
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; z-index: 2; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 96px 8px 8px; }
  .brand { display: none; }
  .nav button { white-space: nowrap; }
  .main { padding: 18px 14px 32px; }
  .item { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
