.map-item-preview {
    pointer-events: auto;
    position: absolute;
    z-index: 20;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100% - 8px);
    overflow: hidden;
    padding: .75rem;
    border: 1px solid var(--border-interactive);
    border-radius: var(--radius-md, 8px);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: .875rem;
    overflow-wrap: anywhere;
}
.map-item-preview[hidden] { display: none; }
.staff-calendar-booking-preview { z-index: 30; }
.staff-calendar-booking-preview > strong { padding-right: 2rem; }
.staff-calendar-booking-preview > p { color: var(--text-secondary); font-size: .8125rem; margin: 0 0 .5rem; }
.staff-calendar-booking-preview .map-item-preview-open { color: var(--accent-link); }
.staff-calendar-preview-close { position: absolute; top: .375rem; right: .375rem; min-width: 28px; min-height: 28px; padding: .125rem; border: 1px solid var(--border-interactive); border-radius: var(--radius-sm, 6px); background: var(--bg-card); color: var(--text-primary); font: inherit; }
.staff-calendar-preview-close:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.map-item-preview > strong {
    display: block;
    flex: none;
    margin-bottom: .5rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}
.map-item-preview-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.map-item-preview-fields {
    display: grid;
    grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr);
    gap: .5rem .75rem;
    margin: 0;
}
.map-item-preview-fields dt {
    color: var(--text-secondary);
    font-weight: 600;
}
.map-item-preview-fields dd { margin: 0; min-width: 0; }
.map-item-preview-section {
    margin: .75rem 0 .5rem;
    font-weight: 600;
    color: var(--text-primary);
}
.map-item-preview-photo {
    position: relative;
    display: block;
    max-width: 100%;
    width: 8rem;
    height: 8rem;
    padding: .25rem;
    border: 1px solid var(--border-interactive);
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-secondary);
    cursor: pointer;
}
.map-item-preview-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.map-item-preview-photo-action {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    transform: translate(-50%, -50%);
    border: 1px solid var(--border-interactive);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
}
.map-item-preview-photo:hover .map-item-preview-photo-action,
.map-item-preview-photo:focus-visible .map-item-preview-photo-action { opacity: 1; }
@media (pointer: coarse) {
    .map-item-preview-photo-action { opacity: 1; }
}
@media (max-width: 420px) {
    .map-item-preview-fields { grid-template-columns: minmax(0, 1fr); gap: .125rem; }
    .map-item-preview-fields dd { margin-bottom: .5rem; }
}
.map-item-preview-trigger {
    pointer-events: auto;
    position: absolute;
    bottom: 2rem;
    left: .5rem;
    z-index: 21;
    padding: .5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-interactive);
    border-radius: var(--radius-md, 8px);
    /* The map already has a pointer-driven preview; expose this alternate entry on focus. */
    clip-path: inset(50%);
}
.map-item-preview-trigger:focus { clip-path: none; }
.map-item-preview-open {
    display: block;
    flex: none;
    min-height: 24px;
    margin-top: .5rem;
    padding: .5rem 0 .125rem;
    border: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--accent-link);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}
.map-item-preview-open[hidden] { display: none; }
.map-item-preview-open:disabled { cursor: wait; }
.map-div:focus-visible, .map-item-preview:focus-visible, .map-item-preview-trigger:focus-visible,
.map-item-preview-open:focus-visible, .map-item-preview-photo:focus-visible,
.map-item-preview-body:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}
.map-item-preview .map-cluster-list-item:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: -2px;
}

/* A Street Manager event in a map pop-up or hover preview (StreetManagerPermitEvents.BuildSummaryHtml). */
.sm-event {
    --sm-type: #6b7280;
    min-width: 18rem;
    max-width: 24rem;
    color: var(--text-primary);
    font-size: .8125rem;
    line-height: 1.4;
}
/* The map's colours for each kind of work, so the card matches the line drawn on the map. */
.sm-event--permit { --sm-type: #f59e0b; }
.sm-event--activity { --sm-type: #9333ea; }
.sm-event--section58 { --sm-type: #2563eb; }
.sm-event-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .375rem .5rem;
    margin-bottom: .5rem;
}
.sm-event-type {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    color: var(--text-secondary);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.sm-event-type::before {
    content: "";
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--sm-type);
}
.sm-event-status {
    padding: .0625rem .5rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: .6875rem;
    font-weight: 600;
    white-space: nowrap;
}
.sm-event-status--live { border-color: currentColor; color: var(--accent-success-text); }
.sm-event-status--planned { border-color: currentColor; color: var(--accent-link); }
.sm-event-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}
.sm-event-ref {
    margin: .125rem 0 0;
    color: var(--text-secondary);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .75rem;
}
.sm-event-section {
    margin: .75rem 0 .375rem;
    padding-top: .625rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
/* A fixed label column, so the values line up from one section to the next. */
.sm-event-details {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: .3125rem .75rem;
    margin: 0;
}
.sm-event-details dt { color: var(--text-secondary); font-weight: 400; }
.sm-event-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sm-event-source {
    margin: .75rem 0 0;
    color: var(--text-secondary);
    font-size: .6875rem;
}
.sm-event-empty { margin: 0; color: var(--text-secondary); }
/* The card carries its own title, so the hover preview's (the bare reference) is not repeated. */
.map-item-preview:has(.sm-event) > strong { display: none; }
.map-item-preview .sm-event { max-width: none; }
