#results-panel,
.results-panel {
    --results-width: min(360px, 31vw);
    --results-float-gap: var(--panel-gap, 12px);
    --results-bottom-clearance: 52px;
    position: absolute;
    z-index: 3;
    top: var(--results-float-gap);
    right: var(--results-float-gap);
    bottom: auto;
    width: var(--results-width);
    max-height: calc(100% - (var(--results-float-gap) * 2) - var(--results-bottom-clearance));
    height: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #fff;
    background: var(--overlay-dark-bg);
    -webkit-backdrop-filter: var(--overlay-backdrop);
    backdrop-filter: var(--overlay-backdrop);
    border: 1px solid #444;
    border-radius: var(--ui-radius, 10px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
    font-family: "Clarity City", "Segoe UI", sans-serif;
}

.results-panel[hidden] {
    display: none !important;
}

.results-panel__handle {
    display: none;
}

.results-panel__header {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 14px;
    border-bottom: 4px solid var(--ohaz-yellow, #f8e109);
}

/* title and subtitle wrap together, leaving the header row free for actions */
.results-panel__heading {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px 10px;
    min-width: 0;
}

.results-panel__header h2 {
    min-width: 0;
    margin: 0;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 21px;
    font-weight: 600;
    line-height: 1.25;
}

/* match the title's line height so the close icon centers on its first line */
.results-panel__header .modal__close {
    padding: 0 8px;
    font-size: 28px;
    line-height: 26.25px;
}

.results-panel__subtitle {
    margin: 0;
    color: #c8c8c8;
    font-size: 13px;
    line-height: 1.3;
}

.results-panel__content {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 18px 12px;
}

.results-panel__footer {
    flex: 0 0 auto;
    padding: 12px 18px 14px;
    border-top: 1px solid #444;
}

.results-panel__actions {
    display: flex;
    gap: 8px;
}

.results-panel__export,
.results-panel__share {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--ohaz-yellow, #f8e109);
    padding: 10px 12px;
    color: var(--ohaz-grey, #2f2e2e);
    background: var(--ohaz-yellow, #f8e109);
    border-radius: var(--ui-radius-sm, 6px);
    font: 600 13px/1.2 "Clarity City", sans-serif;
    cursor: pointer;
}

.results-panel__export:hover,
.results-panel__export:focus-visible,
.results-panel__share:hover,
.results-panel__share:focus-visible {
    background: #fff6a8;
}

.results-panel__export:focus-visible,
.results-panel__share:focus-visible {
    outline: 2px solid var(--ohaz-yellow, #f8e109);
    outline-offset: 2px;
}

.results-panel__export:disabled,
.results-panel__share:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.results-panel[aria-busy="true"] .results-panel__export:disabled {
    cursor: wait;
}

/* icon sits left of the label and the pair stays centered */
.results-panel__share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.results-panel__status {
    min-height: 16px;
    margin: 8px 0 0;
    padding: 0;
    color: #c8c8c8;
    font-size: 11px;
}

/* take no space until there is a message; stays rendered so the live region still announces */
.results-panel__status:empty {
    min-height: 0;
    margin: 0;
}

.results-panel__empty,
.results-panel__loading {
    margin: 0;
    color: #c8c8c8;
    font-size: 13px;
    line-height: 1.5;
}

.results-panel__error {
    margin: 0;
    color: #ff8a8a;
    font-size: 13px;
    line-height: 1.5;
}

.results-panel__qualifier {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 14px;
    color: #e0e0e0;
    font-size: 12px;
    line-height: 1.4;
}

/* hollow square matches the export legend's selected-boundary swatch */
.results-panel__qualifier::before {
    content: '';
    flex: none;
    box-sizing: border-box;
    width: 14px;
    height: 14px;
    margin-top: 1px;
    border: 2.5px solid var(--ohaz-yellow, #f8e109);
}

/* the first key row carries the divider under the coverage figures */
.results-panel__body > :not(.results-panel__qualifier) + .results-panel__qualifier {
    margin-top: 22px;
    border-top: 1px solid #444;
    padding-top: 14px;
}

/* stacked keys read as one group below the coverage figures */
.results-panel__qualifier + .results-panel__qualifier {
    margin-top: -8px;
}

/* the divider already sits above the key, so the land status follows without its own */
.results-panel__qualifier + .results-panel__land-mix {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

/* horizontal stroke matches the export legend's line swatch; color matches TRANSMISSION_LINE_COLOR in js/map-layers.js */
.results-panel__qualifier--transmission-lines::before {
    height: 0;
    margin-top: 7px;
    border: 0;
    border-top: 3px solid #c2188f;
}

.results-panel__line {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.4;
}

.results-panel__camera-counts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* background comes from the provider's marker color */
.results-panel__camera-count {
    padding: 1px 6px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--camera-count-color, #727272) 60%, transparent);
    color: #fff;
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
}

.results-panel__lead {
    font-size: 17px;
    font-weight: 600;
}

.results-panel__land-mix {
    margin-top: 22px;
    border-top: 1px solid #444;
    padding-top: 14px;
}

.results-panel__land-mix-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-bottom: 4px;
}

.results-panel__land-mix-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.results-panel__land-info {
    color: #c8c8c8;
}

.results-panel__land-info:hover,
.results-panel__land-info:focus-visible {
    color: #fff;
}

.results-panel__chart {
    min-height: 180px;
    width: 100%;
}

.results-panel__chart:not(:empty) {
    color: #c8c8c8;
    font-size: 13px;
    line-height: 1.4;
}

.results-panel__land-stats {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.results-panel__land-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    line-height: 1.35;
}

.results-panel__land-note {
    margin: 12px 0 0;
    color: #c8c8c8;
    font-size: 12px;
    line-height: 1.45;
}

.results-panel__land-swatch {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.results-panel__camera-preview {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    /* camera frames are 16:9; matching them keeps the whole image visible */
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: var(--ui-radius-sm, 6px);
}

.results-panel__camera-image {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.results-panel__camera-placeholder {
    padding: 16px;
    color: #c8c8c8;
    font-size: 13px;
    text-align: center;
}

.results-panel__camera a {
    color: #fff;
    font-weight: 600;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--ohaz-yellow, #f8e109);
}

.results-panel__camera-overlay {
    position: absolute;
    z-index: 1;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.results-panel__feed {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    text-decoration: none;
    /* text sits directly on the image, so a shadow keeps it readable */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.results-panel__feed span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* room for the underline, which overflow: hidden would otherwise clip */
    padding-bottom: 5px;
    margin-bottom: -5px;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--ohaz-yellow, #f8e109);
    text-underline-offset: 3px;
}

.results-panel__feed i {
    flex: 0 0 auto;
    color: var(--ohaz-yellow, #f8e109);
}

.results-panel__camera-pan {
    flex: 0 0 auto;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.results-panel__camera .results-panel__lead {
    margin: 14px 0 0;
    font-size: 16px;
}

.results-panel__camera a:focus-visible {
    outline: 2px solid var(--ohaz-yellow, #f8e109);
    outline-offset: 2px;
}

/* export preview layout; the shared shell lives in css/modal.css */
/* both classes so this beats the 440px .modal__dialog width loaded later in modal.css */
.modal__dialog.results-export-modal__dialog {
    width: min(1200px, 90vw);
    max-height: 90vh;
}

.results-export-modal__preview-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px 16px;
    background: #1a1a1a;
}

.results-export-modal__preview {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #444;
}

/* report pages stack with a gap, like pages in a PDF viewer */
.results-export-modal__preview + .results-export-modal__preview {
    margin-top: 12px;
}

.results-export-chooser__options {
    display: grid;
    gap: 10px;
}

.results-export-chooser__option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    color: #fff;
    background: #3a3939;
    border: 1px solid #555;
    border-radius: var(--ui-radius-sm, 6px);
    font: 13px/1.4 "Clarity City", sans-serif;
    text-align: left;
    cursor: pointer;
}

.results-export-chooser__option:hover,
.results-export-chooser__option:focus-visible {
    border-color: var(--ohaz-yellow, #f8e109);
}

.results-export-chooser__option:focus-visible {
    outline: 2px solid var(--ohaz-yellow, #f8e109);
    outline-offset: 2px;
}

.results-export-chooser__option > i {
    width: 20px;
    margin-top: 2px;
    color: var(--ohaz-yellow, #f8e109);
    font-size: 18px;
    text-align: center;
}

.results-export-chooser__option strong {
    display: block;
    margin-bottom: 2px;
}

.results-export-chooser__detail {
    color: #c8c8c8;
    font-size: 12px;
}

@media (max-width: 900px) {
    body:has(#control-sidebar:not(.is-collapsed)) #results-panel {
        display: none;
    }

    #results-panel,
    .results-panel {
        top: auto;
        left: var(--results-float-gap);
        right: var(--results-float-gap);
        bottom: calc(var(--results-bottom-clearance) + var(--results-float-gap));
        width: auto;
        height: auto;
        max-height: min(48vh, 380px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        border: 1px solid #444;
        border-top: 4px solid var(--ohaz-yellow, #f8e109);
        border-radius: var(--ui-radius, 10px);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
    }

    .results-panel__handle {
        display: block;
        flex: 0 0 auto;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        background: #666;
    }

    .results-panel__header {
        padding-top: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .results-panel,
    .results-panel__export,
    .results-panel__share,
    .results-panel__camera a {
        transition: none;
        animation: none;
    }
}
