/* ------------------------------------------------------------------
   Context step (editor-context.js): map with an icon toolbar | Brief panel.
   Reuses the .pf shell of the Programme workspace for height and panel.
   ------------------------------------------------------------------ */
.pf.ctx {
    grid-template-columns: minmax(0, 1fr) var(--brief-rail-w, 400px);
    grid-template-areas: "main panel";
}
.pf.ctx.is-panelless {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
}
.pf.ctx .pf-totals.is-bare {
    display: none;
}
.pf.ctx.is-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}
.ctx-loading {
    color: var(--gray-600);
    font-size: 14px;
}
.ctx-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-200);
}
.ctx-section p {
    margin: 4px 0;
}
.ctx-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}
.ctx-muted {
    color: var(--gray-600);
    font-size: 12px;
}
.ctx-muted.is-error,
.ctx-manual-error.is-error,
.ctx-search-status.is-error {
    color: var(--red-c92a2a);
}
.ctx-place {
    font-weight: 600;
}
.ctx-links,
.ctx-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}
.ctx-link {
    font-size: 12px;
}
.ctx-oereb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 8px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
}
.ctx-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
}
.ctx-badge.is-binding {
    background: var(--blue-e7f5ff);
    color: var(--blue-1864ab);
}
.ctx-inbrief {
    color: var(--green-2b8a3e);
    font-size: 12px;
}
.ctx-layer-groups,
.ctx-layer-groups ul,
.ctx-layer-results,
.ctx-facts,
.ctx-qtys ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.ctx-layer-group h4 {
    margin: 10px 0 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ctx-layer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    padding: 3px 0;
}
.ctx-layer label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.ctx-layer.is-link-only .ctx-layer-label {
    color: var(--gray-600);
}
.ctx-layer-result {
    padding: 6px 0;
    border-top: 1px solid var(--gray-200);
}
.ctx-layer-result:first-child {
    border-top: none;
}
.ctx-layer-name {
    font-weight: 600;
}
.ctx-facts li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    padding: 2px 0;
}
.ctx-fact-label {
    color: var(--gray-600);
}
.ctx-fact-value {
    font-weight: 600;
}
.ctx-toolbar {
    position: relative;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}
.ctx-tools-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
}
.ctx-menu-wrap {
    display: flex;
}
.ctx-ibtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--gray-700);
    cursor: pointer;
}
.ctx-svg {
    width: 18px;
    height: 18px;
    flex: none;
}
.ctx-ibtn:hover:not(:disabled),
.ctx-ibtn.is-open {
    background: var(--white);
    border-color: var(--gray-200);
    color: var(--gray-900);
}
.ctx-ibtn.is-active {
    background: var(--orange-fff4e6);
    border-color: var(--orange-ffd8a8);
    color: var(--orange-e8590c);
}
.ctx-ibtn:disabled {
    color: var(--gray-400);
    cursor: default;
}
.ctx-ibtn:focus-visible {
    outline: 2px solid var(--blue-1c7ed6);
    outline-offset: 1px;
}
/* Label of an icon button: below it on hover or keyboard focus, hidden while its list is open. */
.ctx-ibtn[data-tip]:hover::after,
.ctx-ibtn[data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    z-index: 10;
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--gray-900);
    color: var(--white);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
}
.ctx-ibtn.is-open::after {
    display: none;
}
.ctx-ibtn-count {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: var(--gray-700);
    color: var(--white);
    font-size: 10px;
    font-weight: 600;
    line-height: 15px;
    text-align: center;
}
.ctx-site-wrap {
    position: relative;
    margin-left: auto;
    min-width: 0;
}
.ctx-site-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 340px;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: var(--white);
    font: inherit;
    font-size: 13px;
    color: var(--gray-900);
    cursor: pointer;
}
.ctx-site-chip:hover,
.ctx-site-chip.is-open {
    background: var(--gray-100);
}
.ctx-site-chip.is-empty {
    border-style: dashed;
    color: var(--gray-600);
}
.ctx-site-chip .ctx-svg {
    width: 16px;
    height: 16px;
    color: var(--blue-1c7ed6);
}
.ctx-site-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ctx-caret {
    font-size: 10px;
    color: var(--gray-600);
}
.ctx-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 320px;
    max-width: calc(100vw - 32px);
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 8px 12px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: 0 10px 28px rgba(var(--black-rgb), 0.16);
    font-size: 13px;
}
.ctx-site-wrap .ctx-menu {
    left: auto;
    right: 0;
    width: 340px;
}
.ctx-menu .ctx-section {
    padding: 2px 0;
    border-bottom: none;
}
.ctx-menu-fact .ctx-head {
    margin-top: 2px;
}
.ctx-menu > .ctx-muted {
    margin: 2px 0 6px;
}
.ctx-menu .ctx-layer-items {
    flex-basis: 100%;
    margin: 0 0 2px 22px;
}
.ctx-layer-items li {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.ctx-layer-items input {
    margin: 0;
}
.ctx-mode-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 2px 0 4px 34px;
}
.ctx-mode-chip {
    padding: 1px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: var(--white);
    font: inherit;
    font-size: 12px;
    color: var(--gray-700);
    cursor: pointer;
}
.ctx-mode-chip:hover,
.ctx-mode-chip:focus-visible {
    border-color: var(--ctx-color, var(--gray-600));
    color: var(--gray-900);
}
.ctx-mode-chip.is-active {
    border-color: var(--ctx-color, var(--gray-600));
    background: var(--gray-100);
    font-weight: 600;
}
.ctx-view-save {
    width: 100%;
    margin-top: 2px;
}
.ctx-view-item {
    border-left-color: var(--orange-e8590c);
    justify-content: space-between;
}
.ctx-view-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ctx-arrow {
    border: none;
    background: none;
}
.ctx-arrow svg {
    display: block;
    overflow: visible;
}
/* Map labels: hint text, dimension and measure lengths. Centred on their point. */
.ctx-label {
    border: none;
    background: none;
}
.ctx-label-text {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(var(--white-rgb), 0.92);
    box-shadow: 0 1px 3px rgba(var(--black-rgb), 0.25);
    color: var(--ctx-color, var(--gray-900));
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    white-space: pre-line;
    max-width: 220px;
    width: max-content;
    pointer-events: auto;
}
.ctx-dimension-label .ctx-label-text {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ctx-measure-label .ctx-label-text {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}
.ctx-menu-head {
    margin: 10px 0 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
}
/* Draw menu: one foldable section per drawing group. */
.ctx-draw-group > summary {
    margin: 6px 0 2px;
    padding: 2px 0;
    cursor: pointer;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ctx-draw-group > summary:hover {
    color: var(--gray-900);
}
.ctx-draw-group > .ctx-muted {
    margin: 0 0 4px;
    font-size: 12px;
}
/* Draw menu: the site comes first, above the drawing groups. */
.ctx-draw-site {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--gray-200);
}
.ctx-draw-site > .ctx-menu-head {
    margin-top: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ctx-draw-site ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
/* Site outline editing: corner handles and the dots that add a point. */
.ctx-site-vertex {
    border-radius: 50%;
    box-sizing: border-box;
    border: 2px solid var(--orange-e8590c);
    background: var(--white);
    cursor: move;
}
.ctx-site-vertex.is-selected {
    background: var(--orange-e8590c);
    box-shadow: 0 0 0 3px rgba(var(--orange-rgb), 0.3);
}
.ctx-site-mid {
    border-radius: 50%;
    box-sizing: border-box;
    border: 1px solid var(--orange-e8590c);
    background: rgba(var(--white-rgb), 0.7);
    opacity: 0.75;
    cursor: copy;
}
.ctx-site-mid:hover {
    opacity: 1;
}
.ctx-underlay-text {
    border: none;
    background: none;
}
.ctx-underlay-text span {
    position: absolute;
    transform: translate(-50%, -50%);
    color: var(--neutral-495057);
    font-size: 10px;
    white-space: nowrap;
    pointer-events: none;
}
.ctx-file {
    position: relative;
    display: inline-block;
    margin-top: 4px;
    cursor: pointer;
}
.ctx-file.is-busy {
    opacity: 0.7;
    cursor: progress;
}
.ctx-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.ctx-file:focus-within {
    outline: 2px solid var(--focus-ring, var(--blue-4dabf7));
    outline-offset: 2px;
}
.ctx-layer-item {
    padding: 1px 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 12px;
    color: var(--gray-700);
    text-align: left;
    cursor: pointer;
}
.ctx-layer-item:hover,
.ctx-layer-item:focus-visible {
    color: var(--gray-900);
    text-decoration: underline;
}
.ctx-menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.ctx-menu .ctx-layer-group h5 {
    margin: 8px 0 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
}
.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-left: 3px solid var(--ctx-color, var(--gray-600));
    border-radius: 0 var(--radius) var(--radius) 0;
    background: none;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.ctx-menu-item:hover,
.ctx-menu-item:focus,
.ctx-menu-item.is-active {
    background: var(--gray-100);
}
.ctx-menu-item + .ctx-menu-item,
.ctx-menu li + li {
    margin-top: 2px;
}
.ctx-menu-sep {
    margin-top: 6px !important;
    padding-top: 6px !important;
    border-top: 1px solid var(--gray-200);
}
.ctx-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--ctx-color, var(--gray-600));
}
.ctx-site-area {
    margin-top: 6px;
}
.ctx-site-area .ctx-field {
    margin-bottom: 2px;
}
.ctx-site-area input {
    max-width: 160px;
}
.ctx-site-area .ctx-muted {
    margin: 0;
    font-size: 12px;
}
.ctx-viewbar strong {
    color: var(--gray-800);
}
.ctx-views {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 6px 0 12px;
}
.ctx-view-thumb {
    margin: 0;
}
.ctx-view-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
    cursor: pointer;
}
.ctx-view-open:hover,
.ctx-view-open:focus-visible {
    border-color: var(--gray-600);
    box-shadow: 0 0 0 2px rgba(var(--blue-rgb), 0.25);
}
.ctx-view-thumb.is-editing .ctx-view-open {
    border-color: var(--orange-e8590c);
    box-shadow: 0 0 0 2px rgba(var(--orange-rgb), 0.3);
}
.ctx-view-map {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    pointer-events: none;
}
.ctx-view-img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    pointer-events: none;
}
.ctx-view-map .leaflet-control-attribution {
    font-size: 8px;
    line-height: 1.2;
}
.ctx-view-thumb figcaption {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 4px;
    font-size: 12px;
}
.ctx-view-thumb figcaption span {
    color: var(--gray-700);
    white-space: pre-wrap;
}
.spv-site-views-head {
    margin: 0 0 6px;
    font-size: 13px;
}
.spv-site-views .ctx-views {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}
.ctx-tool-icon {
    flex: none;
    width: 1.3em;
    color: var(--ctx-color, var(--gray-600));
    font-weight: 700;
    text-align: center;
}
.ctx-note {
    margin: 2px 0;
    color: var(--gray-700);
    font-size: 12px;
    white-space: pre-wrap;
}
.ctx-pending {
    border-left: 4px solid var(--ctx-color, var(--gray-600));
    background: var(--white);
}
.ctx-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 6px 0;
    font-size: 12px;
    color: var(--gray-700);
}
.ctx-field input,
.ctx-field select,
.ctx-field textarea {
    padding: 5px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font: inherit;
    font-size: 13px;
}
.setup-inline-link.is-danger {
    color: var(--red-c92a2a);
}
.ctx-offset-side {
    display: flex;
    gap: 14px;
    margin: 6px 0;
    padding: 0;
    border: 0;
    font-size: 13px;
    color: var(--gray-700);
}
.ctx-offset-side legend {
    float: left;
    margin-right: 4px;
    padding: 0;
    font-size: 12px;
}
.ctx-offset-side label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ctx-offset .ctx-muted {
    margin: 2px 0 6px;
    font-size: 12px;
}
.ctx-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
