@layer components {
  /* ── Full-height map page ── */

  .group-map-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    margin: calc(-1 * var(--block-space)) calc(-1 * var(--inline-space-l));
  }

  .group-map__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5ch;
    padding: var(--block-space) var(--inline-space-l);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-ink-muted);
    text-decoration: none;
    flex-shrink: 0;

    & svg {
      width: 1rem;
      height: 1rem;
    }

    &:hover {
      color: var(--color-link);
    }
  }

  .group-map {
    position: relative;
    flex: 1;
    min-height: 0;
  }

  .group-map__canvas {
    width: 100%;
    height: 100%;
  }

  /* ── Hidden ping data elements ── */

  .group-map__pings {
    display: none;
  }

  /* ── Avatar pin markers ── */

  .group-map__pin {
    background: none;
    border: none;
  }

  .group-map__pin-inner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid oklch(var(--lch-flare));
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.4);
    transition: opacity 300ms ease;
  }

  .group-map__pin--stale .group-map__pin-inner {
    opacity: 0.45;
    border-color: var(--color-border);
  }

  .group-map__pin-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .group-map__pin-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: color-mix(in oklch, var(--color-accent) 20%, var(--color-surface));
    color: var(--color-accent);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: none;
  }

  /* ── Centre-on-me button ── */

  .group-map__locate-btn {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    z-index: 1000;
    width: var(--touch-min);
    height: var(--touch-min);
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
    transition: background 150ms ease, border-color 150ms ease;

    & svg {
      width: 1.25rem;
      height: 1.25rem;
    }

    &:hover {
      border-color: oklch(var(--lch-flare) / 0.4);
      background: color-mix(in oklch, var(--color-surface) 80%, oklch(var(--lch-flare)) 20%);
    }
  }

  /* ── Popup styling ── */

  .group-map__popup .leaflet-popup-content-wrapper {
    background: var(--color-surface);
    color: var(--color-ink);
    border-radius: var(--radius-lg, 0.75rem);
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 16px oklch(0% 0 0 / 0.4);
  }

  .group-map__popup .leaflet-popup-tip {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
  }

  .group-map__popup-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: center;
    padding: 0.25rem;
  }

  .group-map__popup-content strong {
    font-size: 0.875rem;
  }

  .group-map__popup-status {
    font-size: 0.75rem;
  }

  .group-map__popup-status--active {
    color: oklch(var(--lch-laser));
  }

  .group-map__popup-status--stale {
    color: var(--color-ink-muted);
  }

  /* ── Venue overlay markers ── */

  .group-map__venue-marker {
    background: none;
    border: none;

    & span {
      display: block;
      background: oklch(0% 0 0 / 0.7);
      color: oklch(100% 0 0);
      font-size: 0.625rem;
      font-weight: 600;
      padding: 0.15rem 0.35rem;
      border-radius: var(--radius-sm, 0.25rem);
      white-space: nowrap;
      text-align: center;
    }
  }

  /* ── Cluster badges ── */

  .group-map__cluster {
    background: none;
    border: none;
  }

  .group-map__cluster span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in oklch, oklch(var(--lch-flare)) 85%, oklch(0% 0 0));
    color: oklch(100% 0 0);
    font-size: 0.8125rem;
    font-weight: 700;
    border: 2px solid oklch(var(--lch-flare));
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.4);
  }

  .leaflet-cluster-anim .leaflet-marker-icon,
  .leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 300ms ease, opacity 300ms ease;
  }

  /* ── Rally point pin markers ── */

  .group-map__rally-pin {
    background: none;
    border: none;
  }

  .group-map__rally-pin-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: oklch(var(--lch-flare));
    color: oklch(100% 0 0);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm, 0.25rem);
    white-space: nowrap;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.4);

    & svg {
      width: 0.875rem;
      height: 0.875rem;
      flex-shrink: 0;
    }
  }

  /* ── Rally point "+" button ── */

  .group-map__rally-btn {
    position: absolute;
    bottom: 2rem;
    left: 1rem;
    z-index: 1000;
    width: var(--touch-min);
    height: var(--touch-min);
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: oklch(var(--lch-flare));
    color: oklch(100% 0 0);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
    transition: background 150ms ease;

    & svg {
      width: 1.25rem;
      height: 1.25rem;
    }

    &:hover {
      background: color-mix(in oklch, oklch(var(--lch-flare)) 85%, oklch(0% 0 0));
    }
  }

  /* ── Custom spot pin markers ── */

  .group-map__spot-pin {
    background: none;
    border: none;
  }

  .group-map__spot-pin-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: oklch(var(--lch-laser));
    color: oklch(100% 0 0);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm, 0.25rem);
    white-space: nowrap;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.4);

    & svg {
      width: 0.875rem;
      height: 0.875rem;
      flex-shrink: 0;
    }
  }

  /* ── "My Spot" button ── */

  .group-map__spot-btn {
    position: absolute;
    bottom: 5.5rem;
    left: 1rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-ink);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
    transition: background 150ms ease, border-color 150ms ease;

    & svg {
      width: 1rem;
      height: 1rem;
    }

    &:hover {
      border-color: oklch(var(--lch-laser) / 0.4);
    }

    &--active {
      background: oklch(var(--lch-laser));
      color: oklch(100% 0 0);
      border-color: oklch(var(--lch-laser));
    }
  }

  /* ── Lost alert button ── */

  .group-map__lost-btn {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md, 0.5rem);
    border: 1px solid color-mix(in oklch, oklch(var(--lch-golden)) 40%, var(--color-border));
    background: color-mix(in oklch, oklch(var(--lch-golden)) 15%, var(--color-surface));
    color: oklch(var(--lch-golden));
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
    transition: background 150ms ease, border-color 150ms ease;

    & svg {
      width: 1rem;
      height: 1rem;
    }

    &:hover {
      background: color-mix(in oklch, oklch(var(--lch-golden)) 25%, var(--color-surface));
      border-color: oklch(var(--lch-golden));
    }
  }

  /* ── Rally point dialog ── */

  .group-map__rally-dialog {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--color-surface);
    color: var(--color-ink);
    padding: var(--block-space) var(--inline-space-l);
    max-width: 20rem;
    width: 90vw;
    box-shadow: 0 8px 32px oklch(0% 0 0 / 0.5);

    &::backdrop {
      background: oklch(0% 0 0 / 0.6);
    }
  }

  .group-map__rally-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .group-map__rally-form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
  }

  /* ── Rally points list ── */

  .group-map__rally-list {
    padding: var(--block-space) var(--inline-space-l);
    flex-shrink: 0;
    max-height: 12rem;
    overflow-y: auto;
  }

  .group-map__rally-list-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-block-end: 0.5rem;
  }

  .group-map__rally-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;

    &:last-child {
      border-bottom: none;
    }

    &:hover strong {
      color: oklch(var(--lch-flare));
    }
  }

  /* ── Rally point ETAs ── */

  .rally-eta__list {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .rally-eta__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.15em 0.5em;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    background: color-mix(in oklch, oklch(var(--lch-sky)) 15%, var(--color-surface));
    color: oklch(var(--lch-sky));
  }

  .rally-eta__actions {
    width: 100%;
    display: flex;
    gap: 0.25rem;
  }

  .rally-eta__btn {
    flex: 1;
    min-height: 1.75rem;
    padding: 0.2em 0;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-ink-muted);
    cursor: pointer;
    transition: border-color 100ms ease, color 100ms ease;

    &:hover {
      border-color: oklch(var(--lch-sky));
      color: oklch(var(--lch-sky));
    }
  }

  .group-map__rally-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;

    & strong {
      font-size: 0.875rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .group-map__rally-item-meta {
    font-size: 0.75rem;
    color: var(--color-ink-muted);
  }

  .group-map__rally-item-distance:not(:empty)::after {
    content: " · ";
  }

  /* Leaflet layer control dark theme override */

  .group-map .leaflet-control-layers {
    background: var(--color-surface);
    color: var(--color-ink);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 0.5rem);
    box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
    font-size: 0.8125rem;
  }
}
