body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #f9fafb;
  color: #111827;
  min-height: 100vh;
  overflow-x: hidden;
}
main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 4px 12px rgba(91, 33, 182, 0.25);
}
.site-nav-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 0 0.75rem 1rem;
  min-width: 0;
}
.site-nav-brand {
  flex: none;
  font-weight: 700;
  font-size: 1.125rem;
  color: inherit;
  text-decoration: none;
}
.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-right: 1rem;
  touch-action: pan-x;
}
.site-nav-links::-webkit-scrollbar {
  display: none;
}
.site-nav-links .nav-link {
  flex: none;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.375rem;
}
.site-nav-links .nav-link:hover,
.site-nav-links .nav-link:focus-visible {
  background: #6d28d9;
}
.nav-link-badge {
  position: relative;
}
.invite-badge {
  position: absolute;
  top: -0.2rem;
  right: -0.15rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  line-height: 1rem;
  border-radius: 9999px;
  text-align: center;
}
.invite-badge.hidden {
  display: none;
}
nav a {
  color: inherit;
  text-decoration: none;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background-color: #7c3aed;
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: background-color 0.15s;
}
.btn-primary:hover {
  background-color: #6d28d9;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background-color: #e5e7eb;
  color: #1f2937;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: background-color 0.15s;
}
.btn-secondary:hover {
  background-color: #d1d5db;
}
.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
}
.input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #8b5cf6;
  border-color: transparent;
}
.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}
.card {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border: 1px solid #f3f4f6;
  padding: 1rem;
}
.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background-color: #ede9fe;
  color: #6d28d9;
  font-size: 0.75rem;
  border-radius: 9999px;
}
.tag-muted {
  background-color: #f3f4f6;
  color: #4b5563;
}
.tag-toggle {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  transition: all 0.15s;
}
.tag-toggle:hover {
  border-color: #8b5cf6;
}
.tag-toggle.active {
  background-color: #7c3aed;
  color: white;
  border-color: #7c3aed;
}
.tag-color-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.person-tooltip {
  display: none;
  position: absolute;
  z-index: 30;
  background: #1f2937;
  color: #f9fafb;
  font-size: 0.875rem;
  line-height: 1.4;
  border-radius: 0.9rem;
  padding: 0.55rem 0.8rem;
  max-width: 16rem;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.person-tooltip.is-visible {
  display: block;
}
.person-tooltip::before {
  content: "";
  position: absolute;
  top: 12px;
  left: -7px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 8px solid #1f2937;
}
.person-tooltip.person-tooltip-flip::before {
  left: auto;
  right: -7px;
  border-right: 0;
  border-left: 8px solid #1f2937;
}
.person-tooltip-status {
  display: inline-block;
  margin-top: 0.2rem;
  color: #e5e7eb;
  font-style: italic;
}
#graph-wrapper {
  overflow: visible;
  height: 36rem;
  min-height: 36rem;
}
.graph-settings {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 6;
}
.graph-settings-cog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.94);
  color: #4b5563;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  cursor: pointer;
}
.graph-settings-cog:hover,
.graph-settings-cog[aria-expanded="true"] {
  color: #111827;
  border-color: #d1d5db;
  background: #fff;
}
.graph-settings-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  width: min(18.5rem, calc(100vw - 2.5rem));
  max-height: min(28rem, 70vh);
  overflow: auto;
  padding: 0;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #e5e7eb;
  border-radius: 0.6rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.graph-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.85rem;
  color: #111827;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.97);
  z-index: 1;
}
.graph-settings-close {
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}
.graph-settings-close:hover {
  color: #111827;
}
.graph-settings-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
}
.graph-settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}
.graph-settings-label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #4b5563;
}
.graph-settings-label em {
  font-style: normal;
  color: #111827;
  font-variant-numeric: tabular-nums;
}
.graph-settings-field input[type="range"] {
  width: 100%;
  accent-color: #374151;
}
.graph-settings-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.8rem;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
}
.graph-settings-check input {
  flex: none;
}
.graph-settings-checks {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.graph-settings-checks:empty {
  display: none;
}
.graph-settings-checks:not(:empty) + .graph-settings-check {
  margin-top: 0.1rem;
}
.graph-settings-sep {
  height: 1px;
  background: #f3f4f6;
  margin: 0.1rem 0;
}
.person-tooltip strong {
  color: #fff;
  font-weight: 600;
}
.person-tooltip .person-tooltip-dim {
  color: #9ca3af;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #4b5563;
}
.graph-legend-wrap {
  margin-top: 0.75rem;
}
.graph-legend-details {
  border: 0;
}
.graph-legend-summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7280;
  list-style: none;
  user-select: none;
}
.graph-legend-summary::-webkit-details-marker {
  display: none;
}
.graph-legend-summary::before {
  content: '▸ ';
  color: #9ca3af;
}
.graph-legend-details[open] .graph-legend-summary::before {
  content: '▾ ';
}
.graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.graph-legend-swatch {
  display: inline-block;
  width: 1.1rem;
  height: 0.4rem;
  border-radius: 9999px;
}

/* Map height must live here rather than in a utility class: Leaflet measures
   the container as soon as the page script runs, which is before the deferred
   Tailwind CDN script has applied anything. */
.map-heading {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.75rem;
}
.map-wrapper {
  position: relative;
}
/* Leaflet's own panes climb to z-index 700, and #map sets no z-index of its
   own, so the bubble competes with them in the wrapper's stacking context. */
.map-wrapper .person-tooltip {
  z-index: 800;
}
.map-panel {
  width: 100%;
  height: 65vh;
  min-height: 20rem;
  background: #eef2f7;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

.collapsible > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.collapsible > summary::-webkit-details-marker {
  display: none;
}
.collapsible > summary::before {
  content: "▸";
  color: #6b7280;
  transition: transform 0.15s;
}
.collapsible[open] > summary::before {
  transform: rotate(90deg);
}

.person-swatch {
  display: block;
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  background-size: cover;
  background-position: center;
}
.person-swatch.has-image {
  border-width: 3px;
  border-style: solid;
}

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.avatar-preview {
  display: block;
  flex: none;
  width: 5rem;
  height: 5rem;
  border-radius: 9999px;
  border: 3px solid #7c3aed;
  background-size: cover;
  background-position: center;
}
.avatar-editor-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Tailwind's .hidden arrives with the deferred CDN script, too late to stop a
   full-screen modal flashing on load. */
.cropper-backdrop.hidden {
  display: none;
}
.cropper-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.6);
}
.cropper-panel {
  width: 100%;
  max-width: 22rem;
  padding: 1.25rem;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}
.cropper-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0.5rem;
  background: #111827;
  touch-action: none;
}
.cropper-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.cropper-stage canvas:active {
  cursor: grabbing;
}
/* The mask leaves only the area outside the crop circle painted. */
.cropper-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.45);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 49.5%, #000 50%);
  mask: radial-gradient(circle at 50% 50%, transparent 49.5%, #000 50%);
}
.cropper-zoom {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0;
}
.cropper-zoom input {
  flex: 1;
}
.cropper-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Leaflet's stylesheet loads after this one, so clearing .leaflet-div-icon's
   white box needs the extra specificity. */
.leaflet-div-icon.map-pin-wrapper {
  background: transparent;
  border: 0;
}
.map-pin {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  border: 3px solid #7c3aed;
  background-size: cover;
  background-position: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.map-pin-self {
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.map-spider-leg {
  pointer-events: none;
}
.person-status {
  position: relative;
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.4rem 0.75rem;
  background: #f3f4f6;
  border-radius: 0.9rem;
  color: #374151;
  font-style: italic;
}
.person-status::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 14px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid #f3f4f6;
}

.setting-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.setting {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}
.setting-title {
  display: block;
}
.setting-hint {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.15rem;
}

/* Injected after the Tailwind CDN has scanned the page, so these rows cannot
   rely on utility classes. */
.share-count {
  font-size: 0.8rem;
  font-weight: 400;
  color: #6b7280;
}
.share-banner {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.8rem;
}
.share-banner.is-hidden {
  display: none;
}
.is-hidden {
  display: none !important;
}
.share-list {
  margin-top: 0.5rem;
}
.share-empty {
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 0.75rem;
}
.share-row {
  display: grid;
  grid-template-columns: minmax(0, 11rem) 1fr;
  align-items: center;
  gap: 0.4rem 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f3f4f6;
}
@media (max-width: 40rem) {
  .share-row {
    grid-template-columns: 1fr;
  }
  #graph-wrapper {
    height: 24rem;
    min-height: 24rem;
  }
}
.share-row:last-child {
  border-bottom: 0;
}
.share-person {
  display: flex;
  flex-direction: column;
}
.share-name {
  font-weight: 600;
}
.share-handle {
  font-size: 0.75rem;
  color: #9ca3af;
}
.share-directions {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.35rem 0.75rem;
  font-size: 0.875rem;
}
.share-direction-label {
  color: #6b7280;
}
.share-direction-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.share-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.share-chip-on {
  background: #dcfce7;
  color: #166534;
}
.share-chip-off {
  background: #f3f4f6;
  color: #4b5563;
}
.share-chip-wait {
  background: #fef3c7;
  color: #92400e;
}
.share-chip-paused {
  background: #ffedd5;
  color: #9a3412;
}
.share-action {
  font-size: 0.8rem;
  color: #6d28d9;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}
.share-action:hover {
  color: #4c1d95;
}
.share-action-danger {
  color: #b91c1c;
}
.share-action-danger:hover {
  color: #7f1d1d;
}

.username-status {
  font-size: 0.8rem;
  margin-top: 0.35rem;
  min-height: 1.1rem;
}
.username-status-idle {
  color: #6b7280;
}
.username-status-pending {
  color: #6b7280;
}
.username-status-ok {
  color: #15803d;
}
.username-status-error {
  color: #b91c1c;
}

.graph-tooltip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  margin-top: 0.25rem;
}
.graph-tooltip-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.graph-tooltip-swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font-size: 0.875rem;
  line-height: 1.35;
}
.install-banner-text {
  flex: 1;
}
.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.install-banner-btn {
  background: #7c3aed;
  color: #fff;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  font-size: 0.8125rem;
}
.install-banner-dismiss {
  background: transparent;
  color: #9ca3af;
  border: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.9rem;
  line-height: 1;
}

@media (display-mode: standalone) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
