:root {
  --ink: #14213d;
  --muted: #5d6b82;
  --line: #d9dee7;
  --bg: #f4f6f9;
  --accent: #1d4e89;
  --warn: #9a3412;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input { font: inherit; color: inherit; }
button, .button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.link { border: 0; background: none; padding: 6px 4px; color: var(--accent); }

/* ---------- Map page ---------- */
.map-page { overflow: hidden; }
#map { position: fixed; inset: 0; background: #dfe6ee; }

.topbar {
  position: fixed; z-index: 1000; display: flex; gap: 8px; align-items: center;
  top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; box-shadow: 0 1px 6px rgba(20, 33, 61, .25); }
.seg { display: flex; border-radius: 999px; background: #fff; padding: 3px; flex: none; }
.seg button { border: 0; border-radius: 999px; padding: 7px 12px; font-size: 14px; background: none; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button:disabled { color: #9aa5b5; cursor: default; }
.searchbox { flex: 1; min-width: 0; border-radius: 999px; background: #fff; }
.searchbox input {
  width: 100%; border: 0; background: none; padding: 10px 14px; border-radius: 999px; font-size: 15px;
}
.round {
  flex: none; width: 42px; height: 42px; border-radius: 50%; padding: 0; border: 0;
  background: #fff; color: var(--ink); display: grid; place-items: center;
  box-shadow: 0 1px 6px rgba(20, 33, 61, .25);
}
.locate { position: fixed; z-index: 1000; right: 10px; bottom: calc(34px + env(safe-area-inset-bottom)); }
.locate.busy { color: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

.legend {
  position: fixed; z-index: 900; left: 10px; bottom: calc(34px + env(safe-area-inset-bottom));
  max-width: calc(100% - 80px); font-size: 12px;
  background: rgba(255, 255, 255, .92); padding: 6px 10px; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(20, 33, 61, .2);
}
.legend .years { display: flex; align-items: center; gap: 6px; }
.legend .branches { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.legend .branches:not(:empty) { margin-top: 4px; }
.legend .branches span { display: inline-flex; align-items: center; gap: 4px; }
.legend .branches i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); }
.legend[hidden], .toast[hidden], .sheet[hidden] { display: none; }
.legend .ramp { width: 70px; height: 10px; border-radius: 5px; border: 1px solid var(--ink); }

.toast {
  position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%);
  top: calc(64px + env(safe-area-inset-top)); max-width: calc(100% - 30px);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px;
  text-align: center;
}
.toast a { color: #fff; }

/* Pins */
.pin { background: none; border: 0; }
.pin > svg { display: block; filter: drop-shadow(0 1px 2px rgba(20, 33, 61, .45)); }
.pin.current > svg { filter: drop-shadow(0 0 5px #f59e0b) drop-shadow(0 0 2px #f59e0b); }
/* Leaflet positions marker icons absolutely; never override that here, or the
   icons stack down the page instead of sitting on their coordinates. */
.pin .count {
  position: absolute; top: -6px; right: -9px; min-width: 19px; height: 19px; padding: 0 4px;
  border-radius: 10px; background: #fff; border: 1.5px solid var(--ink); color: var(--ink);
  font: 700 11px/16px system-ui, sans-serif; text-align: center;
}
.me { background: #2b7fff; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(43, 127, 255, .35); }

/* Bottom sheet */
.sheet {
  position: fixed; z-index: 1200; left: 0; right: 0; bottom: 0; max-height: 62vh;
  display: flex; flex-direction: column; background: #fff;
  border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(20, 33, 61, .3);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 700px) {
  .sheet { left: 10px; right: auto; bottom: 10px; width: 400px; max-height: calc(100% - 90px); border-radius: 16px; }
}
.sheet-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 0 12px; min-height: 40px; }
.sheet-bar .close { margin-left: auto; border: 0; background: none; font-size: 28px; line-height: 1; padding: 4px 10px; color: var(--muted); }
.sheet-body { overflow-y: auto; padding: 0 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet h2 { margin: 0; font-size: 21px; line-height: 1.2; }
.sheet h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sheet .sub { color: var(--muted); margin: 2px 0 0; }
.chip {
  display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 999px;
  background: #e7eef8; color: var(--accent); font-size: 13px; font-weight: 600;
}
.timeline, .people { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.timeline li.here { background: #fff8e6; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.timeline .date { color: var(--muted); font-size: 14px; }
.timeline .place { display: block; font-size: 14px; color: var(--muted); }
.timeline button.place { border: 0; background: none; padding: 0; text-align: left; color: var(--accent); }
.people li { border-top: 1px solid var(--line); }
.people button, .people .static {
  display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none;
  padding: 9px 0; text-align: left; border-radius: 0;
}
.people .mini { flex: none; }
.people .mini > svg { display: block; }
.people .who { flex: 1; min-width: 0; }
.people .who small { display: block; color: var(--muted); }
.people .role { color: var(--muted); font-size: 13px; flex: none; }
.empty { color: var(--muted); padding: 10px 0; }

/* ---------- Admin and login pages ---------- */
.page main { max-width: 720px; margin: 0 auto; padding: 16px; }
.page h1 { margin: 0; font-size: 26px; }
.page h2 { margin: 0 0 8px; font-size: 19px; }
.page h3 { margin: 20px 0 4px; font-size: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card.narrow { max-width: 380px; margin: 12vh auto 0; }
.card p { margin: 0 0 12px; }
label { display: block; font-weight: 600; margin-bottom: 12px; }
label input { display: block; width: 100%; margin-top: 5px; font-weight: 400; }
input[type="text"], input[type="search"], input[type="password"], input[type="file"] {
  border: 1px solid #9aa5b5; border-radius: 8px; padding: 9px 10px; background: #fff; min-width: 0;
}
.hint { color: var(--muted); font-size: 14px; }
.notice, .error { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; }
.notice { background: #e6f4ea; color: #14532d; }
.error { background: #fdecea; color: #7f1d1d; }
progress { width: 100%; height: 14px; }
.results { display: flex; flex-direction: column; gap: 6px; }
.results .result { text-align: left; }
.places { list-style: none; margin: 0; padding: 0; }
.places li { border-top: 1px solid var(--line); padding: 12px 0; }
.inline { display: flex; gap: 8px; margin-top: 8px; }
.inline input { flex: 1; }
.tag { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #fef3c7; color: #854d0e; }
.tag.failed { background: #fdecea; color: var(--warn); }
.signout { text-align: center; margin: 20px 0; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; }

/* A wedding in a list: one rings icon, the two people, and the date and place between them. */
.people li.wedding { display: flex; gap: 10px; align-items: center; }
.people .pair { flex: 1; min-width: 0; }
.people .pair button { padding: 7px 0; }
.people .when { margin: 0; color: var(--muted); font-size: 14px; }
.places.compact li { padding: 6px 0; }

/* Moving a pin on the map */
.mover { background: none; border: 0; cursor: grab; }
.movebar {
  position: fixed; z-index: 1200; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto; background: #fff; border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 2px 16px rgba(20, 33, 61, .35);
}
.movebar p { margin: 0 0 10px; font-size: 14px; }
.movebar .row { display: flex; gap: 8px; flex-wrap: wrap; }
.movebar .row button { flex: 1; white-space: nowrap; }
.sheet .tools { margin: 10px 0 0; }
.sheet .tools button { font-size: 14px; padding: 6px 12px; }

/* Settings button and panel */
#settingsBtn { position: relative; }
#settingsBtn.on::after {
  content: ""; position: absolute; top: 7px; right: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: #f59e0b; border: 1.5px solid #fff;
}
.settings {
  position: fixed; z-index: 1050; left: 10px; top: calc(60px + env(safe-area-inset-top));
  width: min(330px, calc(100% - 20px)); background: #fff; border-radius: 14px; padding: 14px;
  box-shadow: 0 2px 16px rgba(20, 33, 61, .35); font-size: 15px;
}
.settings .field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.settings .name { font-weight: 600; margin: 0; flex: none; }
.settings .seg { background: var(--bg); }
.settings select {
  font: inherit; color: inherit; border: 1px solid #9aa5b5; border-radius: 8px; padding: 7px 8px;
  background: #fff; min-width: 0; flex: 1;
}
.settings .check { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-weight: 600; }
.settings .check input { display: inline-block; width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.settings .check small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.settings .field.stack { display: block; }
.settings .field.stack select { display: block; width: 100%; margin-top: 6px; }
